@codingame/monaco-vscode-api 1.85.0 → 1.85.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.
- package/README.md +31 -13
- package/contributions.js +1 -0
- package/missing-services.js +396 -68
- package/monaco-editor-treemending.patch +957 -950
- package/package.json +8 -7
- package/service-override/tools/editor.js +1 -1
- package/services.js +10 -6
- package/vscode/src/vs/base/browser/ui/tree/treeDefaults.js +14 -0
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionEnablementService.js +140 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/extensions/common/extensions.d.ts +1062 -93
- package/vscode/src/vs/platform/files/common/inMemoryFilesystemProvider.js +220 -0
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/quickinput/browser/quickPickPin.js +102 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/platform/userDataSync/common/content.js +9 -0
- package/vscode/src/vs/platform/userDataSync/common/settingsMerge.js +514 -0
- package/vscode/src/vs/platform/userDataSync/common/userDataSync.js +154 -2
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncAccount.js +43 -1
- package/vscode/src/vs/platform/userDataSync/common/userDataSyncMachines.js +177 -0
- package/vscode/src/vs/workbench/api/common/extHostApiCommands.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostTypeConverters.js +1 -1
- package/vscode/src/vs/workbench/api/common/extHostWebview.js +2 -2
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/browser/parts/views/checkbox.js +105 -0
- package/vscode/src/vs/workbench/browser/parts/views/media/views.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/views/treeView.js +1614 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/languageConfigurationExtensionPoint.js +7 -7
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.js +73 -2
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/tasks/common/taskDefinitionRegistry.js +6 -6
- package/vscode/src/vs/workbench/contrib/tasks/common/taskService.js +12 -2
- package/vscode/src/vs/workbench/contrib/tasks/common/tasks.js +712 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.js +130 -0
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +20 -1
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverSchema.js +205 -0
- package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverUtils.js +11 -0
- package/vscode/src/vs/workbench/services/configurationResolver/common/variableResolver.js +9 -9
- package/vscode/src/vs/workbench/services/extensionManagement/browser/extensionBisect.js +1 -1
- package/vscode/src/vs/workbench/services/keybinding/common/keybindingEditing.js +2 -2
- package/vscode/src/vs/workbench/services/languageStatus/common/languageStatusService.js +24 -1
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorInput.js +41 -0
- package/vscode/src/vs/workbench/services/preferences/browser/keybindingsEditorModel.js +588 -0
- package/vscode/src/vs/workbench/services/preferences/common/preferencesEditorInput.js +43 -0
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/search/common/search.js +3 -3
- package/vscode/src/vs/workbench/services/terminal/common/embedderTerminalService.js +75 -1
- package/vscode/src/vs/workbench/services/timer/browser/timerService.js +240 -1
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +31 -1
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +25 -1
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfileIcons.js +75 -1
- package/vscode/src/vs/workbench/services/userDataSync/common/userDataSync.js +74 -4
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
- package/vscode/src/vs/base/parts/request/browser/request.js +0 -60
- package/vscode/src/vs/platform/request/browser/requestService.js +0 -28
- package/vscode/src/vs/platform/request/common/requestIpc.js +0 -17
- package/vscode/src/vs/platform/url/common/urlService.js +0 -17
- package/vscode/src/vs/workbench/services/configuration/common/jsonEditingService.js +0 -120
- package/vscode/src/vs/workbench/services/decorations/browser/decorationsService.js +0 -319
- package/vscode/src/vs/workbench/services/files/browser/elevatedFileService.js +0 -9
- package/vscode/src/vs/workbench/services/host/browser/browserHostService.js +0 -408
- package/vscode/src/vs/workbench/services/request/browser/requestService.js +0 -48
- package/vscode/src/vs/workbench/services/textfile/browser/browserTextFileService.js +0 -56
- package/vscode/src/vs/workbench/services/textfile/browser/textFileService.js +0 -639
- package/vscode/src/vs/workbench/services/textfile/common/textFileEditorModelManager.js +0 -402
- package/vscode/src/vs/workbench/services/textfile/common/textFileSaveParticipant.js +0 -62
- package/vscode/src/vs/workbench/services/themes/browser/browserHostColorSchemeService.js +0 -38
- package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +0 -295
- package/vscode/src/vs/workbench/services/url/browser/urlService.js +0 -47
- package/vscode/src/vs/workbench/services/views/common/treeViewsService.js +0 -20
- package/vscode/src/vs/workbench/services/workspaces/common/canonicalUriService.js +0 -19
package/assets/index-no-csp.html
DELETED
|
@@ -1,1226 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" style="width: 100%; height: 100%;">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
|
|
7
|
-
<!-- Disable pinch zooming -->
|
|
8
|
-
<meta name="viewport"
|
|
9
|
-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body style="margin: 0; overflow: hidden; width: 100%; height: 100%; overscroll-behavior-x: none;" role="document">
|
|
13
|
-
<!-- TODO: Remove additional script tag once Firefox is fixed https://bugzilla.mozilla.org/show_bug.cgi?id=1737882 -->
|
|
14
|
-
<script></script>
|
|
15
|
-
<script async type="module">
|
|
16
|
-
// @ts-check
|
|
17
|
-
/// <reference lib="dom" />
|
|
18
|
-
|
|
19
|
-
const isSafari = (
|
|
20
|
-
navigator.vendor && navigator.vendor.indexOf('Apple') > -1 &&
|
|
21
|
-
navigator.userAgent &&
|
|
22
|
-
navigator.userAgent.indexOf('CriOS') === -1 &&
|
|
23
|
-
navigator.userAgent.indexOf('FxiOS') === -1
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const isFirefox = (
|
|
27
|
-
navigator.userAgent &&
|
|
28
|
-
navigator.userAgent.indexOf('Firefox') >= 0
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const searchParams = new URL(location.toString()).searchParams;
|
|
32
|
-
const ID = searchParams.get('id');
|
|
33
|
-
const webviewOrigin = searchParams.get('origin');
|
|
34
|
-
const onElectron = searchParams.get('platform') === 'electron';
|
|
35
|
-
const disableServiceWorker = searchParams.has('disableServiceWorker');
|
|
36
|
-
const expectedWorkerVersion = parseInt(searchParams.get('swVersion'));
|
|
37
|
-
const serviceWorkerUri = searchParams.get('serviceWorkerUri');
|
|
38
|
-
const fakeHtmlUri = searchParams.get('fakeHtmlUri');
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Use polling to track focus of main webview and iframes within the webview
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} handlers
|
|
44
|
-
* @param {() => void} handlers.onFocus
|
|
45
|
-
* @param {() => void} handlers.onBlur
|
|
46
|
-
*/
|
|
47
|
-
const trackFocus = ({ onFocus, onBlur }) => {
|
|
48
|
-
const interval = 250;
|
|
49
|
-
let isFocused = document.hasFocus();
|
|
50
|
-
setInterval(() => {
|
|
51
|
-
const isCurrentlyFocused = document.hasFocus();
|
|
52
|
-
if (isCurrentlyFocused === isFocused) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
isFocused = isCurrentlyFocused;
|
|
56
|
-
if (isCurrentlyFocused) {
|
|
57
|
-
onFocus();
|
|
58
|
-
} else {
|
|
59
|
-
onBlur();
|
|
60
|
-
}
|
|
61
|
-
}, interval);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const getActiveFrame = () => {
|
|
65
|
-
return /** @type {HTMLIFrameElement | undefined} */ (document.getElementById('active-frame'));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const getPendingFrame = () => {
|
|
69
|
-
return /** @type {HTMLIFrameElement | undefined} */ (document.getElementById('pending-frame'));
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @template T
|
|
74
|
-
* @param {T | undefined | null} obj
|
|
75
|
-
* @return {T}
|
|
76
|
-
*/
|
|
77
|
-
function assertIsDefined(obj) {
|
|
78
|
-
if (typeof obj === 'undefined' || obj === null) {
|
|
79
|
-
throw new Error('Found unexpected null');
|
|
80
|
-
}
|
|
81
|
-
return obj;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const vscodePostMessageFuncName = '__vscode_post_message__';
|
|
85
|
-
|
|
86
|
-
const defaultStyles = document.createElement('style');
|
|
87
|
-
defaultStyles.id = '_defaultStyles';
|
|
88
|
-
defaultStyles.textContent = `
|
|
89
|
-
html {
|
|
90
|
-
scrollbar-color: var(--vscode-scrollbarSlider-background) var(--vscode-editor-background);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
body {
|
|
94
|
-
overscroll-behavior-x: none;
|
|
95
|
-
background-color: transparent;
|
|
96
|
-
color: var(--vscode-editor-foreground);
|
|
97
|
-
font-family: var(--vscode-font-family);
|
|
98
|
-
font-weight: var(--vscode-font-weight);
|
|
99
|
-
font-size: var(--vscode-font-size);
|
|
100
|
-
margin: 0;
|
|
101
|
-
padding: 0 20px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
img, video {
|
|
105
|
-
max-width: 100%;
|
|
106
|
-
max-height: 100%;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
a, a code {
|
|
110
|
-
color: var(--vscode-textLink-foreground);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
a:hover {
|
|
114
|
-
color: var(--vscode-textLink-activeForeground);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
a:focus,
|
|
118
|
-
input:focus,
|
|
119
|
-
select:focus,
|
|
120
|
-
textarea:focus {
|
|
121
|
-
outline: 1px solid -webkit-focus-ring-color;
|
|
122
|
-
outline-offset: -1px;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
code {
|
|
126
|
-
color: var(--vscode-textPreformat-foreground);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
blockquote {
|
|
130
|
-
background: var(--vscode-textBlockQuote-background);
|
|
131
|
-
border-color: var(--vscode-textBlockQuote-border);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
kbd {
|
|
135
|
-
background-color: var(--vscode-keybindingLabel-background);
|
|
136
|
-
color: var(--vscode-keybindingLabel-foreground);
|
|
137
|
-
border-style: solid;
|
|
138
|
-
border-width: 1px;
|
|
139
|
-
border-radius: 3px;
|
|
140
|
-
border-color: var(--vscode-keybindingLabel-border);
|
|
141
|
-
border-bottom-color: var(--vscode-keybindingLabel-bottomBorder);
|
|
142
|
-
box-shadow: inset 0 -1px 0 var(--vscode-widget-shadow);
|
|
143
|
-
vertical-align: middle;
|
|
144
|
-
padding: 1px 3px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
::-webkit-scrollbar {
|
|
148
|
-
width: 10px;
|
|
149
|
-
height: 10px;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
::-webkit-scrollbar-corner {
|
|
153
|
-
background-color: var(--vscode-editor-background);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
::-webkit-scrollbar-thumb {
|
|
157
|
-
background-color: var(--vscode-scrollbarSlider-background);
|
|
158
|
-
}
|
|
159
|
-
::-webkit-scrollbar-thumb:hover {
|
|
160
|
-
background-color: var(--vscode-scrollbarSlider-hoverBackground);
|
|
161
|
-
}
|
|
162
|
-
::-webkit-scrollbar-thumb:active {
|
|
163
|
-
background-color: var(--vscode-scrollbarSlider-activeBackground);
|
|
164
|
-
}
|
|
165
|
-
::highlight(find-highlight) {
|
|
166
|
-
background-color: var(--vscode-editor-findMatchHighlightBackground);
|
|
167
|
-
}
|
|
168
|
-
::highlight(current-find-highlight) {
|
|
169
|
-
background-color: var(--vscode-editor-findMatchBackground);
|
|
170
|
-
}`;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @param {boolean} allowMultipleAPIAcquire
|
|
174
|
-
* @param {*} [state]
|
|
175
|
-
* @return {string}
|
|
176
|
-
*/
|
|
177
|
-
function getVsCodeApiScript(allowMultipleAPIAcquire, state) {
|
|
178
|
-
const encodedState = state ? encodeURIComponent(state) : undefined;
|
|
179
|
-
return /* js */`
|
|
180
|
-
globalThis.acquireVsCodeApi = (function() {
|
|
181
|
-
const originalPostMessage = window.parent['${vscodePostMessageFuncName}'].bind(window.parent);
|
|
182
|
-
const doPostMessage = (channel, data, transfer) => {
|
|
183
|
-
originalPostMessage(channel, data, transfer);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
let acquired = false;
|
|
187
|
-
|
|
188
|
-
let state = ${state ? `JSON.parse(decodeURIComponent("${encodedState}"))` : undefined};
|
|
189
|
-
|
|
190
|
-
return () => {
|
|
191
|
-
if (acquired && !${allowMultipleAPIAcquire}) {
|
|
192
|
-
throw new Error('An instance of the VS Code API has already been acquired');
|
|
193
|
-
}
|
|
194
|
-
acquired = true;
|
|
195
|
-
return Object.freeze({
|
|
196
|
-
postMessage: function(message, transfer) {
|
|
197
|
-
doPostMessage('onmessage', { message, transfer }, transfer);
|
|
198
|
-
},
|
|
199
|
-
setState: function(newState) {
|
|
200
|
-
state = newState;
|
|
201
|
-
doPostMessage('do-update-state', JSON.stringify(newState));
|
|
202
|
-
return newState;
|
|
203
|
-
},
|
|
204
|
-
getState: function() {
|
|
205
|
-
return state;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
})();
|
|
210
|
-
delete window.parent;
|
|
211
|
-
delete window.top;
|
|
212
|
-
delete window.frameElement;
|
|
213
|
-
`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** @type {Promise<void>} */
|
|
217
|
-
const workerReady = new Promise((resolve, reject) => {
|
|
218
|
-
if (disableServiceWorker) {
|
|
219
|
-
return resolve();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (!areServiceWorkersEnabled()) {
|
|
223
|
-
return reject(new Error('Service Workers are not enabled. Webviews will not work. Try disabling private/incognito mode.'));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const swPath = encodeURI(`${serviceWorkerUri}?v=${expectedWorkerVersion}&vscode-resource-base-authority=${searchParams.get('vscode-resource-base-authority')}&remoteAuthority=${searchParams.get('remoteAuthority') ?? ''}`);
|
|
227
|
-
navigator.serviceWorker.register(swPath)
|
|
228
|
-
.then(async registration => {
|
|
229
|
-
/**
|
|
230
|
-
* @param {MessageEvent} event
|
|
231
|
-
*/
|
|
232
|
-
const versionHandler = async (event) => {
|
|
233
|
-
if (event.data.channel !== 'version') {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
navigator.serviceWorker.removeEventListener('message', versionHandler);
|
|
238
|
-
if (event.data.version === expectedWorkerVersion) {
|
|
239
|
-
return resolve();
|
|
240
|
-
} else {
|
|
241
|
-
console.log(`Found unexpected service worker version. Found: ${event.data.version}. Expected: ${expectedWorkerVersion}`);
|
|
242
|
-
console.log(`Attempting to reload service worker`);
|
|
243
|
-
|
|
244
|
-
// If we have the wrong version, try once (and only once) to unregister and re-register
|
|
245
|
-
// Note that `.update` doesn't seem to work desktop electron at the moment so we use
|
|
246
|
-
// `unregister` and `register` here.
|
|
247
|
-
return registration.unregister()
|
|
248
|
-
.then(() => navigator.serviceWorker.register(swPath))
|
|
249
|
-
.finally(() => { resolve(); });
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
navigator.serviceWorker.addEventListener('message', versionHandler);
|
|
253
|
-
|
|
254
|
-
const postVersionMessage = (/** @type {ServiceWorker} */ controller) => {
|
|
255
|
-
controller.postMessage({ channel: 'version' });
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// At this point, either the service worker is ready and
|
|
259
|
-
// became our controller, or we need to wait for it.
|
|
260
|
-
// Note that navigator.serviceWorker.controller could be a
|
|
261
|
-
// controller from a previously loaded service worker.
|
|
262
|
-
const currentController = navigator.serviceWorker.controller;
|
|
263
|
-
if (currentController?.scriptURL.endsWith(swPath)) {
|
|
264
|
-
// service worker already loaded & ready to receive messages
|
|
265
|
-
postVersionMessage(currentController);
|
|
266
|
-
} else {
|
|
267
|
-
if (currentController) {
|
|
268
|
-
console.log(`Found unexpected service worker controller. Found: ${currentController.scriptURL}. Expected: ${swPath}. Waiting for controllerchange.`);
|
|
269
|
-
} else {
|
|
270
|
-
console.log(`No service worker controller found. Waiting for controllerchange.`);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Either there's no controlling service worker, or it's an old one.
|
|
274
|
-
// Wait for it to change before posting the message
|
|
275
|
-
const onControllerChange = () => {
|
|
276
|
-
navigator.serviceWorker.removeEventListener('controllerchange', onControllerChange);
|
|
277
|
-
if (navigator.serviceWorker.controller) {
|
|
278
|
-
postVersionMessage(navigator.serviceWorker.controller);
|
|
279
|
-
} else {
|
|
280
|
-
return reject(new Error('No controller found.'));
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
navigator.serviceWorker.addEventListener('controllerchange', onControllerChange);
|
|
284
|
-
}
|
|
285
|
-
}).catch(error => {
|
|
286
|
-
if (!onElectron && error instanceof Error && error.message.includes('user denied permission')) {
|
|
287
|
-
return reject(new Error(`Could not register service worker. Please make sure third party cookies are enabled: ${error}`));
|
|
288
|
-
}
|
|
289
|
-
return reject(new Error(`Could not register service worker: ${error}.`));
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @type {import('../webviewMessages').WebviewHostMessaging}
|
|
295
|
-
*/
|
|
296
|
-
const hostMessaging = new class HostMessaging {
|
|
297
|
-
|
|
298
|
-
constructor() {
|
|
299
|
-
this.channel = new MessageChannel();
|
|
300
|
-
|
|
301
|
-
/** @type {Map<string, Array<(event: MessageEvent, data: any) => void>>} */
|
|
302
|
-
this.handlers = new Map();
|
|
303
|
-
|
|
304
|
-
this.channel.port1.onmessage = (e) => {
|
|
305
|
-
const channel = e.data.channel;
|
|
306
|
-
const handlers = this.handlers.get(channel);
|
|
307
|
-
if (handlers) {
|
|
308
|
-
for (const handler of handlers) {
|
|
309
|
-
handler(e, e.data.args);
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
console.log('no handler for ', e);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
postMessage(channel, data, transfer) {
|
|
318
|
-
this.channel.port1.postMessage({ channel, data }, transfer);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
onMessage(channel, handler) {
|
|
322
|
-
let handlers = this.handlers.get(channel);
|
|
323
|
-
if (!handlers) {
|
|
324
|
-
handlers = [];
|
|
325
|
-
this.handlers.set(channel, handlers);
|
|
326
|
-
}
|
|
327
|
-
handlers.push(handler);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
async signalReady() {
|
|
331
|
-
const start = (/** @type {string} */ parentOrigin) => {
|
|
332
|
-
window.parent.postMessage({ target: ID, channel: 'webview-ready', data: {} }, parentOrigin, [this.channel.port2]);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
const parentOrigin = searchParams.get('parentOrigin');
|
|
336
|
-
|
|
337
|
-
return start(parentOrigin);
|
|
338
|
-
}
|
|
339
|
-
}();
|
|
340
|
-
|
|
341
|
-
const unloadMonitor = new class {
|
|
342
|
-
|
|
343
|
-
constructor() {
|
|
344
|
-
this.confirmBeforeClose = 'keyboardOnly';
|
|
345
|
-
this.isModifierKeyDown = false;
|
|
346
|
-
|
|
347
|
-
hostMessaging.onMessage('set-confirm-before-close', (_e, data) => {
|
|
348
|
-
this.confirmBeforeClose = data;
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
hostMessaging.onMessage('content', (_e, data) => {
|
|
352
|
-
this.confirmBeforeClose = data.confirmBeforeClose;
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
window.addEventListener('beforeunload', (event) => {
|
|
356
|
-
if (onElectron) {
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
switch (this.confirmBeforeClose) {
|
|
361
|
-
case 'always': {
|
|
362
|
-
event.preventDefault();
|
|
363
|
-
event.returnValue = '';
|
|
364
|
-
return '';
|
|
365
|
-
}
|
|
366
|
-
case 'never': {
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
case 'keyboardOnly':
|
|
370
|
-
default: {
|
|
371
|
-
if (this.isModifierKeyDown) {
|
|
372
|
-
event.preventDefault();
|
|
373
|
-
event.returnValue = '';
|
|
374
|
-
return '';
|
|
375
|
-
}
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
onIframeLoaded(/** @type {HTMLIFrameElement} */ frame) {
|
|
383
|
-
assertIsDefined(frame.contentWindow).addEventListener('keydown', e => {
|
|
384
|
-
this.isModifierKeyDown = e.metaKey || e.ctrlKey || e.altKey;
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
assertIsDefined(frame.contentWindow).addEventListener('keyup', () => {
|
|
388
|
-
this.isModifierKeyDown = false;
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// state
|
|
394
|
-
let firstLoad = true;
|
|
395
|
-
/** @type {any} */
|
|
396
|
-
let loadTimeout;
|
|
397
|
-
let styleVersion = 0;
|
|
398
|
-
|
|
399
|
-
/** @type {Array<{ readonly message: any, transfer?: ArrayBuffer[] }>} */
|
|
400
|
-
let pendingMessages = [];
|
|
401
|
-
|
|
402
|
-
const initData = {
|
|
403
|
-
/** @type {number | undefined} */
|
|
404
|
-
initialScrollProgress: undefined,
|
|
405
|
-
|
|
406
|
-
/** @type {{ [key: string]: string } | undefined} */
|
|
407
|
-
styles: undefined,
|
|
408
|
-
|
|
409
|
-
/** @type {string | undefined} */
|
|
410
|
-
activeTheme: undefined,
|
|
411
|
-
|
|
412
|
-
/** @type {string | undefined} */
|
|
413
|
-
themeId: undefined,
|
|
414
|
-
|
|
415
|
-
/** @type {string | undefined} */
|
|
416
|
-
themeLabel: undefined,
|
|
417
|
-
|
|
418
|
-
/** @type {boolean} */
|
|
419
|
-
screenReader: false,
|
|
420
|
-
|
|
421
|
-
/** @type {boolean} */
|
|
422
|
-
reduceMotion: false,
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
if (!disableServiceWorker) {
|
|
426
|
-
hostMessaging.onMessage('did-load-resource', (_event, data) => {
|
|
427
|
-
assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-resource', data }, data.data?.buffer ? [data.data.buffer] : []);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
hostMessaging.onMessage('did-load-localhost', (_event, data) => {
|
|
431
|
-
assertIsDefined(navigator.serviceWorker.controller).postMessage({ channel: 'did-load-localhost', data });
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
navigator.serviceWorker.addEventListener('message', event => {
|
|
435
|
-
switch (event.data.channel) {
|
|
436
|
-
case 'load-resource':
|
|
437
|
-
case 'load-localhost':
|
|
438
|
-
hostMessaging.postMessage(event.data.channel, event.data);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @param {HTMLDocument?} document
|
|
446
|
-
* @param {HTMLElement?} body
|
|
447
|
-
*/
|
|
448
|
-
const applyStyles = (document, body) => {
|
|
449
|
-
if (!document) {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
if (body) {
|
|
454
|
-
body.classList.remove('vscode-light', 'vscode-dark', 'vscode-high-contrast', 'vscode-high-contrast-light', 'vscode-reduce-motion', 'vscode-using-screen-reader');
|
|
455
|
-
|
|
456
|
-
if (initData.activeTheme) {
|
|
457
|
-
body.classList.add(initData.activeTheme);
|
|
458
|
-
if (initData.activeTheme === 'vscode-high-contrast-light') {
|
|
459
|
-
// backwards compatibility
|
|
460
|
-
body.classList.add('vscode-high-contrast');
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
if (initData.reduceMotion) {
|
|
465
|
-
body.classList.add('vscode-reduce-motion');
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (initData.screenReader) {
|
|
469
|
-
body.classList.add('vscode-using-screen-reader');
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
body.dataset.vscodeThemeKind = initData.activeTheme;
|
|
473
|
-
/** @deprecated data-vscode-theme-name will be removed, use data-vscode-theme-id instead */
|
|
474
|
-
body.dataset.vscodeThemeName = initData.themeLabel || '';
|
|
475
|
-
body.dataset.vscodeThemeId = initData.themeId || '';
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (initData.styles) {
|
|
479
|
-
const documentStyle = document.documentElement.style;
|
|
480
|
-
|
|
481
|
-
// Remove stale properties
|
|
482
|
-
for (let i = documentStyle.length - 1; i >= 0; i--) {
|
|
483
|
-
const property = documentStyle[i];
|
|
484
|
-
|
|
485
|
-
// Don't remove properties that the webview might have added separately
|
|
486
|
-
if (property && property.startsWith('--vscode-')) {
|
|
487
|
-
documentStyle.removeProperty(property);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
// Re-add new properties
|
|
492
|
-
for (const [variable, value] of Object.entries(initData.styles)) {
|
|
493
|
-
documentStyle.setProperty(`--${variable}`, value);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* @param {MouseEvent} event
|
|
500
|
-
*/
|
|
501
|
-
const handleInnerClick = (event) => {
|
|
502
|
-
if (!event?.view?.document) {
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
const baseElement = event.view.document.querySelector('base');
|
|
507
|
-
|
|
508
|
-
for (const pathElement of event.composedPath()) {
|
|
509
|
-
/** @type {any} */
|
|
510
|
-
const node = pathElement;
|
|
511
|
-
if (node.tagName && node.tagName.toLowerCase() === 'a' && node.href) {
|
|
512
|
-
if (node.getAttribute('href') === '#') {
|
|
513
|
-
event.view.scrollTo(0, 0);
|
|
514
|
-
} else if (node.hash && (node.getAttribute('href') === node.hash || (baseElement && node.href === baseElement.href + node.hash))) {
|
|
515
|
-
const fragment = node.hash.slice(1);
|
|
516
|
-
const decodedFragment = decodeURIComponent(fragment);
|
|
517
|
-
const scrollTarget = event.view.document.getElementById(fragment) ?? event.view.document.getElementById(decodedFragment);
|
|
518
|
-
if (scrollTarget) {
|
|
519
|
-
scrollTarget.scrollIntoView();
|
|
520
|
-
} else if (decodedFragment.toLowerCase() === 'top') {
|
|
521
|
-
event.view.scrollTo(0, 0);
|
|
522
|
-
}
|
|
523
|
-
} else {
|
|
524
|
-
hostMessaging.postMessage('did-click-link', { uri: node.href.baseVal || node.href });
|
|
525
|
-
}
|
|
526
|
-
event.preventDefault();
|
|
527
|
-
return;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @param {MouseEvent} event
|
|
534
|
-
*/
|
|
535
|
-
const handleAuxClick = (event) => {
|
|
536
|
-
// Prevent middle clicks opening a broken link in the browser
|
|
537
|
-
if (!event?.view?.document) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (event.button === 1) {
|
|
542
|
-
for (const pathElement of event.composedPath()) {
|
|
543
|
-
/** @type {any} */
|
|
544
|
-
const node = pathElement;
|
|
545
|
-
if (node.tagName && node.tagName.toLowerCase() === 'a' && node.href) {
|
|
546
|
-
event.preventDefault();
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
/**
|
|
554
|
-
* @param {KeyboardEvent} e
|
|
555
|
-
*/
|
|
556
|
-
const handleInnerKeydown = (e) => {
|
|
557
|
-
// If the keypress would trigger a browser event, such as copy or paste,
|
|
558
|
-
// make sure we block the browser from dispatching it. Instead VS Code
|
|
559
|
-
// handles these events and will dispatch a copy/paste back to the webview
|
|
560
|
-
// if needed
|
|
561
|
-
if (isUndoRedo(e) || isPrint(e) || isFindEvent(e) || isSaveEvent(e)) {
|
|
562
|
-
e.preventDefault();
|
|
563
|
-
} else if (isCopyPasteOrCut(e)) {
|
|
564
|
-
if (onElectron) {
|
|
565
|
-
e.preventDefault();
|
|
566
|
-
} else {
|
|
567
|
-
return; // let the browser handle this
|
|
568
|
-
}
|
|
569
|
-
} else if (!onElectron && (isCloseTab(e) || isNewWindow(e))) {
|
|
570
|
-
// Prevent Ctrl+W closing window / Ctrl+N opening new window in PWA.
|
|
571
|
-
// (No effect in a regular browser tab.)
|
|
572
|
-
e.preventDefault();
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
hostMessaging.postMessage('did-keydown', {
|
|
576
|
-
key: e.key,
|
|
577
|
-
keyCode: e.keyCode,
|
|
578
|
-
code: e.code,
|
|
579
|
-
shiftKey: e.shiftKey,
|
|
580
|
-
altKey: e.altKey,
|
|
581
|
-
ctrlKey: e.ctrlKey,
|
|
582
|
-
metaKey: e.metaKey,
|
|
583
|
-
repeat: e.repeat
|
|
584
|
-
});
|
|
585
|
-
};
|
|
586
|
-
/**
|
|
587
|
-
* @param {KeyboardEvent} e
|
|
588
|
-
*/
|
|
589
|
-
const handleInnerKeyup = (e) => {
|
|
590
|
-
hostMessaging.postMessage('did-keyup', {
|
|
591
|
-
key: e.key,
|
|
592
|
-
keyCode: e.keyCode,
|
|
593
|
-
code: e.code,
|
|
594
|
-
shiftKey: e.shiftKey,
|
|
595
|
-
altKey: e.altKey,
|
|
596
|
-
ctrlKey: e.ctrlKey,
|
|
597
|
-
metaKey: e.metaKey,
|
|
598
|
-
repeat: e.repeat
|
|
599
|
-
});
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* @param {KeyboardEvent} e
|
|
604
|
-
* @return {boolean}
|
|
605
|
-
*/
|
|
606
|
-
function isCopyPasteOrCut(e) {
|
|
607
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
608
|
-
// 45: keyCode of "Insert"
|
|
609
|
-
const shiftInsert = e.shiftKey && e.keyCode === 45;
|
|
610
|
-
// 67, 86, 88: keyCode of "C", "V", "X"
|
|
611
|
-
return (hasMeta && [67, 86, 88].includes(e.keyCode)) || shiftInsert;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* @param {KeyboardEvent} e
|
|
616
|
-
* @return {boolean}
|
|
617
|
-
*/
|
|
618
|
-
function isUndoRedo(e) {
|
|
619
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
620
|
-
// 90, 89: keyCode of "Z", "Y"
|
|
621
|
-
return hasMeta && [90, 89].includes(e.keyCode);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* @param {KeyboardEvent} e
|
|
626
|
-
* @return {boolean}
|
|
627
|
-
*/
|
|
628
|
-
function isPrint(e) {
|
|
629
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
630
|
-
// 80: keyCode of "P"
|
|
631
|
-
return hasMeta && e.keyCode === 80;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* @param {KeyboardEvent} e
|
|
636
|
-
* @return {boolean}
|
|
637
|
-
*/
|
|
638
|
-
function isFindEvent(e) {
|
|
639
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
640
|
-
// 70: keyCode of "F"
|
|
641
|
-
return hasMeta && e.keyCode === 70;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* @param {KeyboardEvent} e
|
|
646
|
-
* @return {boolean}
|
|
647
|
-
*/
|
|
648
|
-
function isSaveEvent(e) {
|
|
649
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
650
|
-
// 83: keyCode of "S"
|
|
651
|
-
return hasMeta && e.keyCode === 83;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* @param {KeyboardEvent} e
|
|
656
|
-
* @return {boolean}
|
|
657
|
-
*/
|
|
658
|
-
function isCloseTab(e) {
|
|
659
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
660
|
-
// 87: keyCode of "W"
|
|
661
|
-
return hasMeta && e.keyCode === 87;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* @param {KeyboardEvent} e
|
|
666
|
-
* @return {boolean}
|
|
667
|
-
*/
|
|
668
|
-
function isNewWindow(e) {
|
|
669
|
-
const hasMeta = e.ctrlKey || e.metaKey;
|
|
670
|
-
// 78: keyCode of "N"
|
|
671
|
-
return hasMeta && e.keyCode === 78;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
let isHandlingScroll = false;
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* @param {WheelEvent} event
|
|
678
|
-
*/
|
|
679
|
-
const handleWheel = (event) => {
|
|
680
|
-
if (isHandlingScroll) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
hostMessaging.postMessage('did-scroll-wheel', {
|
|
685
|
-
deltaMode: event.deltaMode,
|
|
686
|
-
deltaX: event.deltaX,
|
|
687
|
-
deltaY: event.deltaY,
|
|
688
|
-
deltaZ: event.deltaZ,
|
|
689
|
-
detail: event.detail,
|
|
690
|
-
type: event.type
|
|
691
|
-
});
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* @param {Event} event
|
|
696
|
-
*/
|
|
697
|
-
const handleInnerScroll = (event) => {
|
|
698
|
-
if (isHandlingScroll) {
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
const target = /** @type {HTMLDocument | null} */ (event.target);
|
|
703
|
-
const currentTarget = /** @type {Window | null} */ (event.currentTarget);
|
|
704
|
-
if (!currentTarget || !target?.body) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
const progress = currentTarget.scrollY / target.body.clientHeight;
|
|
709
|
-
if (isNaN(progress)) {
|
|
710
|
-
return;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
isHandlingScroll = true;
|
|
714
|
-
window.requestAnimationFrame(() => {
|
|
715
|
-
try {
|
|
716
|
-
hostMessaging.postMessage('did-scroll', { scrollYPercentage: progress });
|
|
717
|
-
} catch (e) {
|
|
718
|
-
// noop
|
|
719
|
-
}
|
|
720
|
-
isHandlingScroll = false;
|
|
721
|
-
});
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
function handleInnerDragStartEvent(/** @type {DragEvent} */ e) {
|
|
725
|
-
if (e.defaultPrevented) {
|
|
726
|
-
// Extension code has already handled this event
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
if (!e.dataTransfer || e.shiftKey) {
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// Only handle drags from outside editor for now
|
|
735
|
-
if (e.dataTransfer.items.length && Array.prototype.every.call(e.dataTransfer.items, item => item.kind === 'file')) {
|
|
736
|
-
hostMessaging.postMessage('drag-start', undefined);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* @param {() => void} callback
|
|
742
|
-
*/
|
|
743
|
-
function onDomReady(callback) {
|
|
744
|
-
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
745
|
-
callback();
|
|
746
|
-
} else {
|
|
747
|
-
document.addEventListener('DOMContentLoaded', callback);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
function areServiceWorkersEnabled() {
|
|
752
|
-
try {
|
|
753
|
-
return !!navigator.serviceWorker;
|
|
754
|
-
} catch (e) {
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* @param {import('../webviewMessages').UpdateContentEvent} data
|
|
761
|
-
* @return {string}
|
|
762
|
-
*/
|
|
763
|
-
function toContentHtml(data) {
|
|
764
|
-
const options = data.options;
|
|
765
|
-
const text = data.contents;
|
|
766
|
-
const newDocument = new DOMParser().parseFromString(text, 'text/html');
|
|
767
|
-
|
|
768
|
-
newDocument.querySelectorAll('a').forEach(a => {
|
|
769
|
-
if (!a.title) {
|
|
770
|
-
const href = a.getAttribute('href');
|
|
771
|
-
if (typeof href === 'string') {
|
|
772
|
-
a.title = href;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
// Set default aria role
|
|
778
|
-
if (!newDocument.body.hasAttribute('role')) {
|
|
779
|
-
newDocument.body.setAttribute('role', 'document');
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
// Inject default script
|
|
783
|
-
if (options.allowScripts) {
|
|
784
|
-
const defaultScript = newDocument.createElement('script');
|
|
785
|
-
defaultScript.id = '_vscodeApiScript';
|
|
786
|
-
defaultScript.textContent = getVsCodeApiScript(options.allowMultipleAPIAcquire, data.state);
|
|
787
|
-
newDocument.head.prepend(defaultScript);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
// Inject default styles
|
|
791
|
-
newDocument.head.prepend(defaultStyles.cloneNode(true));
|
|
792
|
-
|
|
793
|
-
applyStyles(newDocument, newDocument.body);
|
|
794
|
-
|
|
795
|
-
// Strip out unsupported http-equiv tags
|
|
796
|
-
for (const metaElement of Array.from(newDocument.querySelectorAll('meta'))) {
|
|
797
|
-
const httpEquiv = metaElement.getAttribute('http-equiv');
|
|
798
|
-
if (httpEquiv && !/^(content-security-policy|default-style|content-type)$/i.test(httpEquiv)) {
|
|
799
|
-
console.warn(`Removing unsupported meta http-equiv: ${httpEquiv}`);
|
|
800
|
-
metaElement.remove();
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// Check for CSP
|
|
805
|
-
const csp = newDocument.querySelector('meta[http-equiv="Content-Security-Policy"]');
|
|
806
|
-
if (!csp) {
|
|
807
|
-
hostMessaging.postMessage('no-csp-found', undefined);
|
|
808
|
-
} else {
|
|
809
|
-
try {
|
|
810
|
-
// Attempt to rewrite CSPs that hardcode old-style resource endpoint
|
|
811
|
-
const cspContent = csp.getAttribute('content');
|
|
812
|
-
if (cspContent) {
|
|
813
|
-
const newCsp = cspContent.replace(/(vscode-webview-resource|vscode-resource):(?=(\s|;|$))/g, data.cspSource);
|
|
814
|
-
csp.setAttribute('content', newCsp);
|
|
815
|
-
}
|
|
816
|
-
} catch (e) {
|
|
817
|
-
console.error(`Could not rewrite csp: ${e}`);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
// set DOCTYPE for newDocument explicitly as DOMParser.parseFromString strips it off
|
|
822
|
-
// and DOCTYPE is needed in the iframe to ensure that the user agent stylesheet is correctly overridden
|
|
823
|
-
return '<!DOCTYPE html>\n' + newDocument.documentElement.outerHTML;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
// Also forward events before the contents of the webview have loaded
|
|
827
|
-
window.addEventListener('keydown', handleInnerKeydown);
|
|
828
|
-
window.addEventListener('keyup', handleInnerKeyup);
|
|
829
|
-
window.addEventListener('dragenter', handleInnerDragStartEvent);
|
|
830
|
-
window.addEventListener('dragover', handleInnerDragStartEvent);
|
|
831
|
-
|
|
832
|
-
onDomReady(() => {
|
|
833
|
-
if (!document.body) {
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
hostMessaging.onMessage('styles', (_event, data) => {
|
|
838
|
-
++styleVersion;
|
|
839
|
-
|
|
840
|
-
initData.styles = data.styles;
|
|
841
|
-
initData.activeTheme = data.activeTheme;
|
|
842
|
-
initData.themeLabel = data.themeLabel;
|
|
843
|
-
initData.themeId = data.themeId;
|
|
844
|
-
initData.reduceMotion = data.reduceMotion;
|
|
845
|
-
initData.screenReader = data.screenReader;
|
|
846
|
-
|
|
847
|
-
const target = getActiveFrame();
|
|
848
|
-
if (!target) {
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
if (target.contentDocument) {
|
|
853
|
-
applyStyles(target.contentDocument, target.contentDocument.body);
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
// propagate focus
|
|
858
|
-
hostMessaging.onMessage('focus', () => {
|
|
859
|
-
const activeFrame = getActiveFrame();
|
|
860
|
-
if (!activeFrame || !activeFrame.contentWindow) {
|
|
861
|
-
// Focus the top level webview instead
|
|
862
|
-
window.focus();
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
if (document.activeElement === activeFrame) {
|
|
867
|
-
// We are already focused on the iframe (or one of its children) so no need
|
|
868
|
-
// to refocus.
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
activeFrame.contentWindow.focus();
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// update iframe-contents
|
|
876
|
-
let updateId = 0;
|
|
877
|
-
hostMessaging.onMessage('content', async (_event, /** @type {import('../webviewMessages').UpdateContentEvent} */ data) => {
|
|
878
|
-
const currentUpdateId = ++updateId;
|
|
879
|
-
try {
|
|
880
|
-
await workerReady;
|
|
881
|
-
} catch (e) {
|
|
882
|
-
console.error(`Webview fatal error: ${e}`);
|
|
883
|
-
hostMessaging.postMessage('fatal-error', { message: e + '' });
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
if (currentUpdateId !== updateId) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
const options = data.options;
|
|
892
|
-
const newDocument = toContentHtml(data);
|
|
893
|
-
|
|
894
|
-
const initialStyleVersion = styleVersion;
|
|
895
|
-
|
|
896
|
-
const frame = getActiveFrame();
|
|
897
|
-
const wasFirstLoad = firstLoad;
|
|
898
|
-
// keep current scrollY around and use later
|
|
899
|
-
/** @type {(body: HTMLElement, window: Window) => void} */
|
|
900
|
-
let setInitialScrollPosition;
|
|
901
|
-
if (firstLoad) {
|
|
902
|
-
firstLoad = false;
|
|
903
|
-
setInitialScrollPosition = (body, window) => {
|
|
904
|
-
if (typeof initData.initialScrollProgress === 'number' && !isNaN(initData.initialScrollProgress)) {
|
|
905
|
-
if (window.scrollY === 0) {
|
|
906
|
-
window.scroll(0, body.clientHeight * initData.initialScrollProgress);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
} else {
|
|
911
|
-
const scrollY = frame && frame.contentDocument && frame.contentDocument.body ? assertIsDefined(frame.contentWindow).scrollY : 0;
|
|
912
|
-
setInitialScrollPosition = (body, window) => {
|
|
913
|
-
if (window.scrollY === 0) {
|
|
914
|
-
window.scroll(0, scrollY);
|
|
915
|
-
}
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Clean up old pending frames and set current one as new one
|
|
920
|
-
const previousPendingFrame = getPendingFrame();
|
|
921
|
-
if (previousPendingFrame) {
|
|
922
|
-
previousPendingFrame.setAttribute('id', '');
|
|
923
|
-
document.body.removeChild(previousPendingFrame);
|
|
924
|
-
}
|
|
925
|
-
if (!wasFirstLoad) {
|
|
926
|
-
pendingMessages = [];
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
const newFrame = document.createElement('iframe');
|
|
930
|
-
newFrame.title = data.title;
|
|
931
|
-
newFrame.setAttribute('id', 'pending-frame');
|
|
932
|
-
newFrame.setAttribute('frameborder', '0');
|
|
933
|
-
|
|
934
|
-
const sandboxRules = new Set(['allow-same-origin', 'allow-pointer-lock']);
|
|
935
|
-
if (options.allowScripts) {
|
|
936
|
-
sandboxRules.add('allow-scripts');
|
|
937
|
-
sandboxRules.add('allow-downloads');
|
|
938
|
-
}
|
|
939
|
-
if (options.allowForms) {
|
|
940
|
-
sandboxRules.add('allow-forms');
|
|
941
|
-
}
|
|
942
|
-
newFrame.setAttribute('sandbox', Array.from(sandboxRules).join(' '));
|
|
943
|
-
|
|
944
|
-
const allowRules = ['cross-origin-isolated;', 'autoplay;'];
|
|
945
|
-
if (!isFirefox && options.allowScripts) {
|
|
946
|
-
allowRules.push('clipboard-read;', 'clipboard-write;');
|
|
947
|
-
}
|
|
948
|
-
newFrame.setAttribute('allow', allowRules.join(' '));
|
|
949
|
-
// We should just be able to use srcdoc, but I wasn't
|
|
950
|
-
// seeing the service worker applying properly.
|
|
951
|
-
// Fake load an empty on the correct origin and then write real html
|
|
952
|
-
// into it to get around this.
|
|
953
|
-
const fakeUrlParams = new URLSearchParams({ id: ID });
|
|
954
|
-
if (globalThis.crossOriginIsolated) {
|
|
955
|
-
fakeUrlParams.set('vscode-coi', '3'); /*COOP+COEP*/
|
|
956
|
-
}
|
|
957
|
-
newFrame.src = `${fakeHtmlUri}?${fakeUrlParams.toString()}`;
|
|
958
|
-
|
|
959
|
-
newFrame.style.cssText = 'display: block; margin: 0; overflow: hidden; position: absolute; width: 100%; height: 100%; visibility: hidden';
|
|
960
|
-
document.body.appendChild(newFrame);
|
|
961
|
-
|
|
962
|
-
newFrame.contentWindow.addEventListener('keydown', handleInnerKeydown);
|
|
963
|
-
newFrame.contentWindow.addEventListener('keyup', handleInnerKeyup);
|
|
964
|
-
|
|
965
|
-
/**
|
|
966
|
-
* @param {Document} contentDocument
|
|
967
|
-
*/
|
|
968
|
-
function onFrameLoaded(contentDocument) {
|
|
969
|
-
// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=978325
|
|
970
|
-
setTimeout(() => {
|
|
971
|
-
contentDocument.open();
|
|
972
|
-
contentDocument.write(newDocument);
|
|
973
|
-
contentDocument.close();
|
|
974
|
-
hookupOnLoadHandlers(newFrame);
|
|
975
|
-
|
|
976
|
-
if (initialStyleVersion !== styleVersion) {
|
|
977
|
-
applyStyles(contentDocument, contentDocument.body);
|
|
978
|
-
}
|
|
979
|
-
}, 0);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
if (!options.allowScripts && isSafari) {
|
|
983
|
-
// On Safari for iframes with scripts disabled, the `DOMContentLoaded` never seems to be fired: https://bugs.webkit.org/show_bug.cgi?id=33604
|
|
984
|
-
// Use polling instead.
|
|
985
|
-
const interval = setInterval(() => {
|
|
986
|
-
// If the frame is no longer mounted, loading has stopped
|
|
987
|
-
if (!newFrame.parentElement) {
|
|
988
|
-
clearInterval(interval);
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
const contentDocument = assertIsDefined(newFrame.contentDocument);
|
|
993
|
-
if (contentDocument.location.pathname.endsWith('/fake.html') && contentDocument.readyState !== 'loading') {
|
|
994
|
-
clearInterval(interval);
|
|
995
|
-
onFrameLoaded(contentDocument);
|
|
996
|
-
}
|
|
997
|
-
}, 10);
|
|
998
|
-
} else {
|
|
999
|
-
assertIsDefined(newFrame.contentWindow).addEventListener('DOMContentLoaded', e => {
|
|
1000
|
-
const contentDocument = e.target ? (/** @type {HTMLDocument} */ (e.target)) : undefined;
|
|
1001
|
-
onFrameLoaded(assertIsDefined(contentDocument));
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
/**
|
|
1006
|
-
* @param {Document} contentDocument
|
|
1007
|
-
* @param {Window} contentWindow
|
|
1008
|
-
*/
|
|
1009
|
-
const onLoad = (contentDocument, contentWindow) => {
|
|
1010
|
-
if (contentDocument && contentDocument.body) {
|
|
1011
|
-
// Workaround for https://github.com/microsoft/vscode/issues/12865
|
|
1012
|
-
// check new scrollY and reset if necessary
|
|
1013
|
-
setInitialScrollPosition(contentDocument.body, contentWindow);
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
const newFrame = getPendingFrame();
|
|
1017
|
-
if (newFrame && newFrame.contentDocument && newFrame.contentDocument === contentDocument) {
|
|
1018
|
-
const wasFocused = document.hasFocus();
|
|
1019
|
-
const oldActiveFrame = getActiveFrame();
|
|
1020
|
-
if (oldActiveFrame) {
|
|
1021
|
-
document.body.removeChild(oldActiveFrame);
|
|
1022
|
-
}
|
|
1023
|
-
// Styles may have changed since we created the element. Make sure we re-style
|
|
1024
|
-
if (initialStyleVersion !== styleVersion) {
|
|
1025
|
-
applyStyles(newFrame.contentDocument, newFrame.contentDocument.body);
|
|
1026
|
-
}
|
|
1027
|
-
newFrame.setAttribute('id', 'active-frame');
|
|
1028
|
-
newFrame.style.visibility = 'visible';
|
|
1029
|
-
|
|
1030
|
-
contentWindow.addEventListener('scroll', handleInnerScroll);
|
|
1031
|
-
contentWindow.addEventListener('wheel', handleWheel);
|
|
1032
|
-
|
|
1033
|
-
if (wasFocused) {
|
|
1034
|
-
contentWindow.focus();
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
pendingMessages.forEach((message) => {
|
|
1038
|
-
contentWindow.postMessage(message.message, window.origin, message.transfer);
|
|
1039
|
-
});
|
|
1040
|
-
pendingMessages = [];
|
|
1041
|
-
}
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
/**
|
|
1045
|
-
* @param {HTMLIFrameElement} newFrame
|
|
1046
|
-
*/
|
|
1047
|
-
function hookupOnLoadHandlers(newFrame) {
|
|
1048
|
-
clearTimeout(loadTimeout);
|
|
1049
|
-
loadTimeout = undefined;
|
|
1050
|
-
loadTimeout = setTimeout(() => {
|
|
1051
|
-
clearTimeout(loadTimeout);
|
|
1052
|
-
loadTimeout = undefined;
|
|
1053
|
-
onLoad(assertIsDefined(newFrame.contentDocument), assertIsDefined(newFrame.contentWindow));
|
|
1054
|
-
}, 200);
|
|
1055
|
-
|
|
1056
|
-
const contentWindow = assertIsDefined(newFrame.contentWindow);
|
|
1057
|
-
|
|
1058
|
-
contentWindow.addEventListener('load', function (e) {
|
|
1059
|
-
const contentDocument = /** @type {Document} */ (e.target);
|
|
1060
|
-
|
|
1061
|
-
if (loadTimeout) {
|
|
1062
|
-
clearTimeout(loadTimeout);
|
|
1063
|
-
loadTimeout = undefined;
|
|
1064
|
-
onLoad(contentDocument, this);
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
// Bubble out various events
|
|
1069
|
-
contentWindow.addEventListener('click', handleInnerClick);
|
|
1070
|
-
contentWindow.addEventListener('auxclick', handleAuxClick);
|
|
1071
|
-
contentWindow.addEventListener('keydown', handleInnerKeydown);
|
|
1072
|
-
contentWindow.addEventListener('keyup', handleInnerKeyup);
|
|
1073
|
-
contentWindow.addEventListener('contextmenu', e => {
|
|
1074
|
-
if (e.defaultPrevented) {
|
|
1075
|
-
// Extension code has already handled this event
|
|
1076
|
-
return;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
e.preventDefault();
|
|
1080
|
-
|
|
1081
|
-
/** @type { Record<string, boolean>} */
|
|
1082
|
-
let context = {};
|
|
1083
|
-
|
|
1084
|
-
/** @type {HTMLElement | null} */
|
|
1085
|
-
let el = e.target;
|
|
1086
|
-
while (true) {
|
|
1087
|
-
if (!el) {
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
// Search self/ancestors for the closest context data attribute
|
|
1092
|
-
el = el.closest('[data-vscode-context]');
|
|
1093
|
-
if (!el) {
|
|
1094
|
-
break;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
try {
|
|
1098
|
-
context = { ...JSON.parse(el.dataset.vscodeContext), ...context };
|
|
1099
|
-
} catch (e) {
|
|
1100
|
-
console.error(`Error parsing 'data-vscode-context' as json`, el, e);
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
el = el.parentElement;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
hostMessaging.postMessage('did-context-menu', {
|
|
1107
|
-
clientX: e.clientX,
|
|
1108
|
-
clientY: e.clientY,
|
|
1109
|
-
context: context
|
|
1110
|
-
});
|
|
1111
|
-
});
|
|
1112
|
-
|
|
1113
|
-
contentWindow.addEventListener('dragenter', handleInnerDragStartEvent);
|
|
1114
|
-
contentWindow.addEventListener('dragover', handleInnerDragStartEvent);
|
|
1115
|
-
|
|
1116
|
-
unloadMonitor.onIframeLoaded(newFrame);
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
|
|
1120
|
-
// propagate vscode-context-menu-visible class
|
|
1121
|
-
hostMessaging.onMessage('set-context-menu-visible', (_event, data) => {
|
|
1122
|
-
const target = getActiveFrame();
|
|
1123
|
-
if (target && target.contentDocument) {
|
|
1124
|
-
target.contentDocument.body.classList.toggle('vscode-context-menu-visible', data.visible);
|
|
1125
|
-
}
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
hostMessaging.onMessage('set-title', async (_event, data) => {
|
|
1129
|
-
const target = getActiveFrame();
|
|
1130
|
-
if (target) {
|
|
1131
|
-
target.title = data;
|
|
1132
|
-
}
|
|
1133
|
-
});
|
|
1134
|
-
|
|
1135
|
-
// Forward message to the embedded iframe
|
|
1136
|
-
hostMessaging.onMessage('message', (_event, data) => {
|
|
1137
|
-
const pending = getPendingFrame();
|
|
1138
|
-
if (!pending) {
|
|
1139
|
-
const target = getActiveFrame();
|
|
1140
|
-
if (target) {
|
|
1141
|
-
assertIsDefined(target.contentWindow).postMessage(data.message, window.origin, data.transfer);
|
|
1142
|
-
return;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
pendingMessages.push(data);
|
|
1146
|
-
});
|
|
1147
|
-
|
|
1148
|
-
hostMessaging.onMessage('initial-scroll-position', (_event, progress) => {
|
|
1149
|
-
initData.initialScrollProgress = progress;
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
|
-
hostMessaging.onMessage('execCommand', (_event, data) => {
|
|
1153
|
-
const target = getActiveFrame();
|
|
1154
|
-
if (!target) {
|
|
1155
|
-
return;
|
|
1156
|
-
}
|
|
1157
|
-
assertIsDefined(target.contentDocument).execCommand(data);
|
|
1158
|
-
});
|
|
1159
|
-
|
|
1160
|
-
/** @type {string | undefined} */
|
|
1161
|
-
let lastFindValue = undefined;
|
|
1162
|
-
|
|
1163
|
-
hostMessaging.onMessage('find', (_event, data) => {
|
|
1164
|
-
const target = getActiveFrame();
|
|
1165
|
-
if (!target) {
|
|
1166
|
-
return;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
if (!data.previous && lastFindValue !== data.value && target.contentWindow) {
|
|
1170
|
-
// Reset selection so we start search at the head of the last search
|
|
1171
|
-
const selection = target.contentWindow.getSelection();
|
|
1172
|
-
if (selection) {
|
|
1173
|
-
selection.collapse(selection.anchorNode);
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
lastFindValue = data.value;
|
|
1177
|
-
|
|
1178
|
-
const didFind = (/** @type {any} */ (target.contentWindow)).find(
|
|
1179
|
-
data.value,
|
|
1180
|
-
/* caseSensitive*/ false,
|
|
1181
|
-
/* backwards*/ data.previous,
|
|
1182
|
-
/* wrapAround*/ true,
|
|
1183
|
-
/* wholeWord */ false,
|
|
1184
|
-
/* searchInFrames*/ false,
|
|
1185
|
-
false);
|
|
1186
|
-
hostMessaging.postMessage('did-find', didFind);
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
hostMessaging.onMessage('find-stop', (_event, data) => {
|
|
1190
|
-
const target = getActiveFrame();
|
|
1191
|
-
if (!target) {
|
|
1192
|
-
return;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
lastFindValue = undefined;
|
|
1196
|
-
|
|
1197
|
-
if (!data.clearSelection && target.contentWindow) {
|
|
1198
|
-
const selection = target.contentWindow.getSelection();
|
|
1199
|
-
if (selection) {
|
|
1200
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
1201
|
-
selection.removeRange(selection.getRangeAt(i));
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
trackFocus({
|
|
1208
|
-
onFocus: () => hostMessaging.postMessage('did-focus', undefined),
|
|
1209
|
-
onBlur: () => hostMessaging.postMessage('did-blur', undefined)
|
|
1210
|
-
});
|
|
1211
|
-
|
|
1212
|
-
(/** @type {any} */ (window))[vscodePostMessageFuncName] = (/** @type {string} */ command, /** @type {any} */ data) => {
|
|
1213
|
-
switch (command) {
|
|
1214
|
-
case 'onmessage':
|
|
1215
|
-
case 'do-update-state':
|
|
1216
|
-
hostMessaging.postMessage(command, data);
|
|
1217
|
-
break;
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
|
|
1221
|
-
hostMessaging.signalReady();
|
|
1222
|
-
});
|
|
1223
|
-
</script>
|
|
1224
|
-
</body>
|
|
1225
|
-
|
|
1226
|
-
</html>
|