@codingame/monaco-vscode-views-service-override 2.1.4 → 2.2.0-next.2

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.
Files changed (107) hide show
  1. package/index.d.ts +11 -9
  2. package/index.js +8 -6
  3. package/package.json +11 -11
  4. package/tools/views.d.ts +102 -0
  5. package/tools/views.js +253 -0
  6. package/views.d.ts +4 -99
  7. package/views.js +52 -280
  8. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  9. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +0 -180
  10. package/vscode/src/vs/base/browser/ui/grid/grid.js +0 -494
  11. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +0 -6
  12. package/vscode/src/vs/base/browser/ui/grid/gridview.js +0 -1112
  13. package/vscode/src/vs/base/common/codicons.d.ts +0 -579
  14. package/vscode/src/vs/platform/webview/common/mimeTypes.js +0 -24
  15. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +0 -64
  16. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +0 -790
  17. package/vscode/src/vs/workbench/browser/actions/listCommands.js +0 -764
  18. package/vscode/src/vs/workbench/browser/layout.d.ts +0 -26
  19. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +0 -612
  20. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +0 -6
  21. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +0 -6
  22. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +0 -150
  23. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +0 -6
  24. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +0 -605
  25. package/vscode/src/vs/workbench/browser/parts/compositePart.js +0 -335
  26. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +0 -223
  27. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +0 -1407
  28. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +0 -186
  29. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +0 -511
  30. package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +0 -112
  31. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +0 -1020
  32. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +0 -391
  33. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +0 -6
  34. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +0 -6
  35. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +0 -6
  36. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +0 -645
  37. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +0 -379
  38. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +0 -68
  39. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +0 -146
  40. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +0 -6
  41. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +0 -222
  42. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +0 -299
  43. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +0 -365
  44. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +0 -135
  45. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +0 -6
  46. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +0 -17
  47. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +0 -145
  48. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +0 -214
  49. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +0 -6
  50. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +0 -78
  51. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +0 -63
  52. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +0 -119
  53. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +0 -6
  54. package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +0 -79
  55. package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +0 -74
  56. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +0 -256
  57. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +0 -99
  58. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +0 -444
  59. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +0 -432
  60. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +0 -786
  61. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +0 -488
  62. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +0 -522
  63. package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +0 -152
  64. package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +0 -63
  65. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +0 -409
  66. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +0 -6
  67. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +0 -693
  68. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +0 -240
  69. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +0 -77
  70. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +0 -42
  71. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +0 -71
  72. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +0 -348
  73. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +0 -98
  74. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +0 -146
  75. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +0 -105
  76. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +0 -401
  77. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +0 -197
  78. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +0 -41
  79. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +0 -128
  80. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +0 -6
  81. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +0 -612
  82. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +0 -158
  83. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +0 -264
  84. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +0 -173
  85. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +0 -6
  86. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +0 -282
  87. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +0 -360
  88. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +0 -133
  89. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +0 -290
  90. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +0 -96
  91. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +0 -88
  92. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +0 -79
  93. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +0 -648
  94. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +0 -65
  95. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +0 -59
  96. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +0 -142
  97. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +0 -121
  98. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +0 -68
  99. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +0 -235
  100. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +0 -145
  101. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +0 -670
  102. package/vscode/src/vs/workbench/services/history/browser/historyService.js +0 -1484
  103. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +0 -6
  104. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +0 -523
  105. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +0 -101
  106. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +0 -713
  107. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +0 -598
@@ -1,648 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { isFirefox } from 'vscode/vscode/vs/base/browser/browser';
3
- import { addDisposableListener, getActiveWindow, EventType } from 'vscode/vscode/vs/base/browser/dom';
4
- import { ThrottledDelayer } from 'vscode/vscode/vs/base/common/async';
5
- import { streamToBuffer } from 'vscode/vscode/vs/base/common/buffer';
6
- import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
7
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
8
- import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
9
- import { FileAccess, COI } from 'vscode/vscode/vs/base/common/network';
10
- import { URI } from 'vscode/vscode/vs/base/common/uri';
11
- import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
12
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
13
- import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
14
- import { MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
15
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
16
- import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
17
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
18
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
19
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
20
- import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
21
- import { IRemoteAuthorityResolverService } from 'vscode/vscode/vs/platform/remote/common/remoteAuthorityResolver';
22
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
23
- import { ITunnelService } from 'vscode/vscode/vs/platform/tunnel/common/tunnel';
24
- import { WebviewPortMappingManager } from '../../../../platform/webview/common/webviewPortMapping.js';
25
- import { parentOriginHash } from 'vscode/vscode/vs/base/browser/iframe';
26
- import { loadLocalResource, WebviewResourceResponse } from './resourceLoading.js';
27
- import { areWebviewContentOptionsEqual } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview';
28
- import { WebviewFindWidget } from './webviewFindWidget.js';
29
- import { decodeAuthority, webviewRootResourceAuthority, webviewGenericCspSource } from 'vscode/vscode/vs/workbench/contrib/webview/common/webview';
30
- import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
31
- import { $window } from 'vscode/vscode/vs/base/browser/window';
32
-
33
- var WebviewState;
34
- ( (function(WebviewState) {
35
- ( (function(Type) {
36
- Type[Type["Initializing"] = 0] = "Initializing";
37
- Type[Type["Ready"] = 1] = "Ready";
38
- })(WebviewState.Type || (WebviewState.Type = {})));
39
- class Initializing {
40
- constructor(pendingMessages) {
41
- this.pendingMessages = pendingMessages;
42
- this.type = 0 ;
43
- }
44
- }
45
- WebviewState.Initializing = Initializing;
46
- WebviewState.Ready = { type: 1 };
47
- })(WebviewState || (WebviewState = {})));
48
- const webviewIdContext = 'webviewId';
49
- let WebviewElement = class WebviewElement extends Disposable {
50
- get platform() { return 'browser'; }
51
- get element() { return this._element; }
52
- get isFocused() {
53
- if (!this._focused) {
54
- return false;
55
- }
56
- if ($window.document.activeElement && $window.document.activeElement !== this.element) {
57
- return false;
58
- }
59
- return true;
60
- }
61
- constructor(initInfo, webviewThemeDataProvider, configurationService, contextMenuService, notificationService, _environmentService, _fileService, _logService, _remoteAuthorityResolverService, _telemetryService, _tunnelService, instantiationService, _accessibilityService) {
62
- super();
63
- this.webviewThemeDataProvider = webviewThemeDataProvider;
64
- this._environmentService = _environmentService;
65
- this._fileService = _fileService;
66
- this._logService = _logService;
67
- this._remoteAuthorityResolverService = _remoteAuthorityResolverService;
68
- this._telemetryService = _telemetryService;
69
- this._tunnelService = _tunnelService;
70
- this._accessibilityService = _accessibilityService;
71
- this.id = generateUuid();
72
- this._expectedServiceWorkerVersion = 4;
73
- this._state = new WebviewState.Initializing([]);
74
- this._resourceLoadingCts = this._register(( new CancellationTokenSource()));
75
- this._focusDelayer = this._register(( new ThrottledDelayer(50)));
76
- this._onDidHtmlChange = this._register(( new Emitter()));
77
- this.onDidHtmlChange = this._onDidHtmlChange.event;
78
- this._messageHandlers = ( new Map());
79
- this.checkImeCompletionState = true;
80
- this._disposed = false;
81
- this._onMissingCsp = this._register(( new Emitter()));
82
- this.onMissingCsp = this._onMissingCsp.event;
83
- this._onDidClickLink = this._register(( new Emitter()));
84
- this.onDidClickLink = this._onDidClickLink.event;
85
- this._onDidReload = this._register(( new Emitter()));
86
- this.onDidReload = this._onDidReload.event;
87
- this._onMessage = this._register(( new Emitter()));
88
- this.onMessage = this._onMessage.event;
89
- this._onDidScroll = this._register(( new Emitter()));
90
- this.onDidScroll = this._onDidScroll.event;
91
- this._onDidWheel = this._register(( new Emitter()));
92
- this.onDidWheel = this._onDidWheel.event;
93
- this._onDidUpdateState = this._register(( new Emitter()));
94
- this.onDidUpdateState = this._onDidUpdateState.event;
95
- this._onDidFocus = this._register(( new Emitter()));
96
- this.onDidFocus = this._onDidFocus.event;
97
- this._onDidBlur = this._register(( new Emitter()));
98
- this.onDidBlur = this._onDidBlur.event;
99
- this._onFatalError = this._register(( new Emitter()));
100
- this.onFatalError = this._onFatalError.event;
101
- this._onDidDispose = this._register(( new Emitter()));
102
- this.onDidDispose = this._onDidDispose.event;
103
- this._hasAlertedAboutMissingCsp = false;
104
- this._hasFindResult = this._register(( new Emitter()));
105
- this.hasFindResult = this._hasFindResult.event;
106
- this._onDidStopFind = this._register(( new Emitter()));
107
- this.onDidStopFind = this._onDidStopFind.event;
108
- this.providedViewType = initInfo.providedViewType;
109
- this.origin = initInfo.origin ?? this.id;
110
- this._encodedWebviewOriginPromise = parentOriginHash($window.origin, this.origin).then(id => this._encodedWebviewOrigin = id);
111
- this._options = initInfo.options;
112
- this.extension = initInfo.extension;
113
- this._content = {
114
- html: '',
115
- title: initInfo.title,
116
- options: initInfo.contentOptions,
117
- state: undefined
118
- };
119
- this._portMappingManager = this._register(( new WebviewPortMappingManager(
120
- () => this.extension?.location,
121
- () => this._content.options.portMapping || [],
122
- this._tunnelService
123
- )));
124
- this._element = this._createElement(initInfo.options, initInfo.contentOptions);
125
- const subscription = this._register(addDisposableListener(initInfo.codeWindow ?? getActiveWindow(), 'message', (e) => {
126
- if (!this._encodedWebviewOrigin || e?.data?.target !== this.id) {
127
- return;
128
- }
129
- if (e.data.channel === 'webview-ready') {
130
- if (this._messagePort) {
131
- return;
132
- }
133
- this._logService.debug(`Webview(${this.id}): webview ready`);
134
- this._messagePort = e.ports[0];
135
- this._messagePort.onmessage = (e) => {
136
- const handlers = this._messageHandlers.get(e.data.channel);
137
- if (!handlers) {
138
- console.log(`No handlers found for '${e.data.channel}'`);
139
- return;
140
- }
141
- handlers?.forEach(handler => handler(e.data.data, e));
142
- };
143
- this.element?.classList.add('ready');
144
- if (this._state.type === 0 ) {
145
- this._state.pendingMessages.forEach(({ channel, data }) => this.doPostMessage(channel, data));
146
- }
147
- this._state = WebviewState.Ready;
148
- subscription.dispose();
149
- }
150
- }));
151
- this._register(this.on('no-csp-found', () => {
152
- this.handleNoCspFound();
153
- }));
154
- this._register(this.on('did-click-link', ({ uri }) => {
155
- this._onDidClickLink.fire(uri);
156
- }));
157
- this._register(this.on('onmessage', ({ message, transfer }) => {
158
- this._onMessage.fire({ message, transfer });
159
- }));
160
- this._register(this.on('did-scroll', ({ scrollYPercentage }) => {
161
- this._onDidScroll.fire({ scrollYPercentage });
162
- }));
163
- this._register(this.on('do-reload', () => {
164
- this.reload();
165
- }));
166
- this._register(this.on('do-update-state', (state) => {
167
- this.state = state;
168
- this._onDidUpdateState.fire(state);
169
- }));
170
- this._register(this.on('did-focus', () => {
171
- this.handleFocusChange(true);
172
- }));
173
- this._register(this.on('did-blur', () => {
174
- this.handleFocusChange(false);
175
- }));
176
- this._register(this.on('did-scroll-wheel', (event) => {
177
- this._onDidWheel.fire(event);
178
- }));
179
- this._register(this.on('did-find', ({ didFind }) => {
180
- this._hasFindResult.fire(didFind);
181
- }));
182
- this._register(this.on('fatal-error', (e) => {
183
- notificationService.error(( localizeWithPath(
184
- 'vs/workbench/contrib/webview/browser/webviewElement',
185
- 'fatalErrorMessage',
186
- "Error loading webview: {0}",
187
- e.message
188
- )));
189
- this._onFatalError.fire({ message: e.message });
190
- }));
191
- this._register(this.on('did-keydown', (data) => {
192
- this.handleKeyEvent('keydown', data);
193
- }));
194
- this._register(this.on('did-keyup', (data) => {
195
- this.handleKeyEvent('keyup', data);
196
- }));
197
- this._register(this.on('did-context-menu', (data) => {
198
- if (!this.element) {
199
- return;
200
- }
201
- if (!this._contextKeyService) {
202
- return;
203
- }
204
- const elementBox = this.element.getBoundingClientRect();
205
- const contextKeyService = this._contextKeyService.createOverlay([
206
- ...Object.entries(data.context),
207
- [webviewIdContext, this.providedViewType],
208
- ]);
209
- contextMenuService.showContextMenu({
210
- menuId: MenuId.WebviewContext,
211
- menuActionOptions: { shouldForwardArgs: true },
212
- contextKeyService,
213
- getActionsContext: () => ({ ...data.context, webview: this.providedViewType }),
214
- getAnchor: () => ({
215
- x: elementBox.x + data.clientX,
216
- y: elementBox.y + data.clientY
217
- })
218
- });
219
- }));
220
- this._register(this.on('load-resource', async (entry) => {
221
- try {
222
- const authority = decodeAuthority(entry.authority);
223
- const uri = ( URI.from({
224
- scheme: entry.scheme,
225
- authority: authority,
226
- path: decodeURIComponent(entry.path),
227
- query: entry.query ? decodeURIComponent(entry.query) : entry.query,
228
- }));
229
- this.loadResource(entry.id, uri, entry.ifNoneMatch);
230
- }
231
- catch (e) {
232
- this._send('did-load-resource', {
233
- id: entry.id,
234
- status: 404,
235
- path: entry.path,
236
- });
237
- }
238
- }));
239
- this._register(this.on('load-localhost', (entry) => {
240
- this.localLocalhost(entry.id, entry.origin);
241
- }));
242
- this._register(Event.runAndSubscribe(webviewThemeDataProvider.onThemeDataChanged, () => this.style()));
243
- this._register(_accessibilityService.onDidChangeReducedMotion(() => this.style()));
244
- this._register(_accessibilityService.onDidChangeScreenReaderOptimized(() => this.style()));
245
- this._register(contextMenuService.onDidShowContextMenu(() => this._send('set-context-menu-visible', { visible: true })));
246
- this._register(contextMenuService.onDidHideContextMenu(() => this._send('set-context-menu-visible', { visible: false })));
247
- this._confirmBeforeClose = configurationService.getValue('window.confirmBeforeClose');
248
- this._register(configurationService.onDidChangeConfiguration(e => {
249
- if (e.affectsConfiguration('window.confirmBeforeClose')) {
250
- this._confirmBeforeClose = configurationService.getValue('window.confirmBeforeClose');
251
- this._send('set-confirm-before-close', this._confirmBeforeClose);
252
- }
253
- }));
254
- this._register(this.on('drag-start', () => {
255
- this._startBlockingIframeDragEvents();
256
- }));
257
- if (initInfo.options.enableFindWidget) {
258
- this._webviewFindWidget = this._register(instantiationService.createInstance(WebviewFindWidget, this));
259
- }
260
- this._encodedWebviewOriginPromise.then(encodedWebviewOrigin => {
261
- if (!this._disposed) {
262
- this._initElement(encodedWebviewOrigin, this.extension, this._options);
263
- }
264
- });
265
- }
266
- dispose() {
267
- this._disposed = true;
268
- this.element?.remove();
269
- this._element = undefined;
270
- this._messagePort = undefined;
271
- if (this._state.type === 0 ) {
272
- for (const message of this._state.pendingMessages) {
273
- message.resolve(false);
274
- }
275
- this._state.pendingMessages = [];
276
- }
277
- this._onDidDispose.fire();
278
- this._resourceLoadingCts.dispose(true);
279
- super.dispose();
280
- }
281
- setContextKeyService(contextKeyService) {
282
- this._contextKeyService = contextKeyService;
283
- }
284
- postMessage(message, transfer) {
285
- return this._send('message', { message, transfer });
286
- }
287
- async _send(channel, data, _createElement = []) {
288
- if (this._state.type === 0 ) {
289
- let resolve;
290
- const promise = ( new Promise(r => resolve = r));
291
- this._state.pendingMessages.push({ channel, data, transferable: _createElement, resolve: resolve });
292
- return promise;
293
- }
294
- else {
295
- return this.doPostMessage(channel, data, _createElement);
296
- }
297
- }
298
- _createElement(options, _contentOptions) {
299
- const element = document.createElement('iframe');
300
- element.name = this.id;
301
- element.className = `webview ${options.customClasses || ''}`;
302
- element.sandbox.add('allow-scripts', 'allow-same-origin', 'allow-forms', 'allow-pointer-lock', 'allow-downloads');
303
- const allowRules = ['cross-origin-isolated', 'autoplay'];
304
- if (!isFirefox) {
305
- allowRules.push('clipboard-read', 'clipboard-write');
306
- }
307
- element.setAttribute('allow', allowRules.join('; '));
308
- element.style.border = 'none';
309
- element.style.width = '100%';
310
- element.style.height = '100%';
311
- element.focus = () => {
312
- this._doFocus();
313
- };
314
- return element;
315
- }
316
- _initElement(encodedWebviewOrigin, extension, options) {
317
- const params = {
318
- id: this.id,
319
- origin: this.origin,
320
- swVersion: String(this._expectedServiceWorkerVersion),
321
- extensionId: extension?.id.value ?? '',
322
- platform: this.platform,
323
- 'vscode-resource-base-authority': webviewRootResourceAuthority,
324
- parentOrigin: $window.origin,
325
- };
326
- if (this._options.disableServiceWorker) {
327
- params.disableServiceWorker = 'true';
328
- }
329
- if (this._environmentService.remoteAuthority) {
330
- params.remoteAuthority = this._environmentService.remoteAuthority;
331
- }
332
- if (options.purpose) {
333
- params.purpose = options.purpose;
334
- }
335
- params.serviceWorkerUri = ( ( FileAccess.asBrowserUri('vs/workbench/contrib/webview/browser/pre/service-worker.js')).toString(true));
336
- params.fakeHtmlUri = ( ( FileAccess.asBrowserUri('vs/workbench/contrib/webview/browser/pre/fake.html')).toString(true));
337
- COI.addSearchParam(params, true, true);
338
- const queryString = ( ( new URLSearchParams(params)).toString());
339
- const fileName = isFirefox ? 'index-no-csp.html' : 'index.html';
340
- const relativeIframeSrc = ( FileAccess.asBrowserUri(`vs/workbench/contrib/webview/browser/pre/${fileName}`));
341
- this.element.setAttribute('src', `${( relativeIframeSrc.toString(true))}?${queryString}`);
342
- }
343
- mountTo(element) {
344
- if (!this.element) {
345
- return;
346
- }
347
- if (this._webviewFindWidget) {
348
- element.appendChild(this._webviewFindWidget.getDomNode());
349
- }
350
- for (const eventName of [EventType.MOUSE_DOWN, EventType.MOUSE_MOVE, EventType.DROP]) {
351
- this._register(addDisposableListener(element, eventName, () => {
352
- this._stopBlockingIframeDragEvents();
353
- }));
354
- }
355
- for (const node of [element, $window]) {
356
- this._register(addDisposableListener(node, EventType.DRAG_END, () => {
357
- this._stopBlockingIframeDragEvents();
358
- }));
359
- }
360
- element.id = this.id;
361
- element.appendChild(this.element);
362
- }
363
- _startBlockingIframeDragEvents() {
364
- if (this.element) {
365
- this.element.style.pointerEvents = 'none';
366
- }
367
- }
368
- _stopBlockingIframeDragEvents() {
369
- if (this.element) {
370
- this.element.style.pointerEvents = 'auto';
371
- }
372
- }
373
- webviewContentEndpoint(encodedWebviewOrigin) {
374
- const webviewExternalEndpoint = this._environmentService.webviewExternalEndpoint;
375
- if (!webviewExternalEndpoint) {
376
- throw new Error(`'webviewExternalEndpoint' has not been configured. Webviews will not work!`);
377
- }
378
- const endpoint = webviewExternalEndpoint.replace('{{uuid}}', encodedWebviewOrigin);
379
- if (endpoint[endpoint.length - 1] === '/') {
380
- return endpoint.slice(0, endpoint.length - 1);
381
- }
382
- return endpoint;
383
- }
384
- doPostMessage(channel, data, transferable = []) {
385
- if (this.element && this._messagePort) {
386
- this._messagePort.postMessage({ channel, args: data }, transferable);
387
- return true;
388
- }
389
- return false;
390
- }
391
- on(channel, handler) {
392
- let handlers = this._messageHandlers.get(channel);
393
- if (!handlers) {
394
- handlers = ( new Set());
395
- this._messageHandlers.set(channel, handlers);
396
- }
397
- handlers.add(handler);
398
- return toDisposable(() => {
399
- this._messageHandlers.get(channel)?.delete(handler);
400
- });
401
- }
402
- handleNoCspFound() {
403
- if (this._hasAlertedAboutMissingCsp) {
404
- return;
405
- }
406
- this._hasAlertedAboutMissingCsp = true;
407
- if (this.extension?.id) {
408
- if (this._environmentService.isExtensionDevelopment) {
409
- this._onMissingCsp.fire(this.extension.id);
410
- }
411
- const payload = {
412
- extension: this.extension.id.value
413
- };
414
- this._telemetryService.publicLog2('webviewMissingCsp', payload);
415
- }
416
- }
417
- reload() {
418
- this.doUpdateContent(this._content);
419
- const subscription = this._register(this.on('did-load', () => {
420
- this._onDidReload.fire();
421
- subscription.dispose();
422
- }));
423
- }
424
- setHtml(html) {
425
- this.doUpdateContent({ ...this._content, html });
426
- this._onDidHtmlChange.fire(html);
427
- }
428
- setTitle(title) {
429
- this._content = { ...this._content, title };
430
- this._send('set-title', title);
431
- }
432
- set contentOptions(options) {
433
- this._logService.debug(`Webview(${this.id}): will update content options`);
434
- if (areWebviewContentOptionsEqual(options, this._content.options)) {
435
- this._logService.debug(`Webview(${this.id}): skipping content options update`);
436
- return;
437
- }
438
- this.doUpdateContent({ ...this._content, options });
439
- }
440
- set localResourcesRoot(resources) {
441
- this._content = {
442
- ...this._content,
443
- options: { ...this._content.options, localResourceRoots: resources }
444
- };
445
- }
446
- set state(state) {
447
- this._content = { ...this._content, state };
448
- }
449
- set initialScrollProgress(value) {
450
- this._send('initial-scroll-position', value);
451
- }
452
- doUpdateContent(newContent) {
453
- this._logService.debug(`Webview(${this.id}): will update content`);
454
- this._content = newContent;
455
- const allowScripts = !!this._content.options.allowScripts;
456
- this._send('content', {
457
- contents: this._content.html,
458
- title: this._content.title,
459
- options: {
460
- allowMultipleAPIAcquire: !!this._content.options.allowMultipleAPIAcquire,
461
- allowScripts: allowScripts,
462
- allowForms: this._content.options.allowForms ?? allowScripts,
463
- },
464
- state: this._content.state,
465
- cspSource: webviewGenericCspSource,
466
- confirmBeforeClose: this._confirmBeforeClose,
467
- });
468
- }
469
- style() {
470
- let { styles, activeTheme, themeLabel, themeId } = this.webviewThemeDataProvider.getWebviewThemeData();
471
- if (this._options.transformCssVariables) {
472
- styles = this._options.transformCssVariables(styles);
473
- }
474
- const reduceMotion = this._accessibilityService.isMotionReduced();
475
- const screenReader = this._accessibilityService.isScreenReaderOptimized();
476
- this._send('styles', { styles, activeTheme, themeId, themeLabel, reduceMotion, screenReader });
477
- }
478
- handleFocusChange(isFocused) {
479
- this._focused = isFocused;
480
- if (isFocused) {
481
- this._onDidFocus.fire();
482
- }
483
- else {
484
- this._onDidBlur.fire();
485
- }
486
- }
487
- handleKeyEvent(type, event) {
488
- const emulatedKeyboardEvent = ( new KeyboardEvent(type, event));
489
- Object.defineProperty(emulatedKeyboardEvent, 'target', {
490
- get: () => this.element,
491
- });
492
- $window.dispatchEvent(emulatedKeyboardEvent);
493
- }
494
- windowDidDragStart() {
495
- this._startBlockingIframeDragEvents();
496
- }
497
- windowDidDragEnd() {
498
- this._stopBlockingIframeDragEvents();
499
- }
500
- selectAll() {
501
- this.execCommand('selectAll');
502
- }
503
- copy() {
504
- this.execCommand('copy');
505
- }
506
- paste() {
507
- this.execCommand('paste');
508
- }
509
- cut() {
510
- this.execCommand('cut');
511
- }
512
- undo() {
513
- this.execCommand('undo');
514
- }
515
- redo() {
516
- this.execCommand('redo');
517
- }
518
- execCommand(command) {
519
- if (this.element) {
520
- this._send('execCommand', command);
521
- }
522
- }
523
- async loadResource(id, uri, ifNoneMatch) {
524
- try {
525
- const result = await loadLocalResource(uri, {
526
- ifNoneMatch,
527
- roots: this._content.options.localResourceRoots || [],
528
- }, this._fileService, this._logService, this._resourceLoadingCts.token);
529
- switch (result.type) {
530
- case WebviewResourceResponse.Type.Success: {
531
- const buffer = await this.streamToBuffer(result.stream);
532
- return this._send('did-load-resource', {
533
- id,
534
- status: 200,
535
- path: uri.path,
536
- mime: result.mimeType,
537
- data: buffer,
538
- etag: result.etag,
539
- mtime: result.mtime
540
- }, [buffer]);
541
- }
542
- case WebviewResourceResponse.Type.NotModified: {
543
- return this._send('did-load-resource', {
544
- id,
545
- status: 304,
546
- path: uri.path,
547
- mime: result.mimeType,
548
- mtime: result.mtime
549
- });
550
- }
551
- case WebviewResourceResponse.Type.AccessDenied: {
552
- return this._send('did-load-resource', {
553
- id,
554
- status: 401,
555
- path: uri.path,
556
- });
557
- }
558
- }
559
- }
560
- catch {
561
- }
562
- return this._send('did-load-resource', {
563
- id,
564
- status: 404,
565
- path: uri.path,
566
- });
567
- }
568
- async streamToBuffer(stream) {
569
- const vsBuffer = await streamToBuffer(stream);
570
- return vsBuffer.buffer.buffer;
571
- }
572
- async localLocalhost(id, origin) {
573
- const authority = this._environmentService.remoteAuthority;
574
- const resolveAuthority = authority ? await this._remoteAuthorityResolverService.resolveAuthority(authority) : undefined;
575
- const redirect = resolveAuthority ? await this._portMappingManager.getRedirect(resolveAuthority.authority, origin) : undefined;
576
- return this._send('did-load-localhost', {
577
- id,
578
- origin,
579
- location: redirect
580
- });
581
- }
582
- focus() {
583
- this._doFocus();
584
- this.handleFocusChange(true);
585
- }
586
- _doFocus() {
587
- if (!this.element) {
588
- return;
589
- }
590
- try {
591
- this.element.contentWindow?.focus();
592
- }
593
- catch {
594
- }
595
- this._focusDelayer.trigger(async () => {
596
- if (!this.isFocused || !this.element) {
597
- return;
598
- }
599
- if ($window.document.activeElement && $window.document.activeElement !== this.element && $window.document.activeElement?.tagName !== 'BODY') {
600
- return;
601
- }
602
- this._send('focus', undefined);
603
- });
604
- }
605
- find(value, previous) {
606
- if (!this.element) {
607
- return;
608
- }
609
- this._send('find', { value, previous });
610
- }
611
- updateFind(value) {
612
- if (!value || !this.element) {
613
- return;
614
- }
615
- this._send('find', { value });
616
- }
617
- stopFind(keepSelection) {
618
- if (!this.element) {
619
- return;
620
- }
621
- this._send('find-stop', { clearSelection: !keepSelection });
622
- this._onDidStopFind.fire();
623
- }
624
- showFind(animated = true) {
625
- this._webviewFindWidget?.reveal(undefined, animated);
626
- }
627
- hideFind(animated = true) {
628
- this._webviewFindWidget?.hide(animated);
629
- }
630
- runFindAction(previous) {
631
- this._webviewFindWidget?.find(previous);
632
- }
633
- };
634
- WebviewElement = ( __decorate([
635
- ( __param(2, IConfigurationService)),
636
- ( __param(3, IContextMenuService)),
637
- ( __param(4, INotificationService)),
638
- ( __param(5, IWorkbenchEnvironmentService)),
639
- ( __param(6, IFileService)),
640
- ( __param(7, ILogService)),
641
- ( __param(8, IRemoteAuthorityResolverService)),
642
- ( __param(9, ITelemetryService)),
643
- ( __param(10, ITunnelService)),
644
- ( __param(11, IInstantiationService)),
645
- ( __param(12, IAccessibilityService))
646
- ], WebviewElement));
647
-
648
- export { WebviewElement };