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