@codingame/monaco-vscode-api 1.85.0 → 1.85.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +957 -950
- package/package.json +6 -6
- 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/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- 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/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/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/terminal/browser/terminal.js +4 -1
- 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/layout/browser/layoutService.js +15 -1
- 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/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
|
@@ -0,0 +1,1591 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { getWindow } from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
4
|
+
import { DeferredPromise, runWhenGlobalIdle } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
5
|
+
import { decodeBase64 } from 'monaco-editor/esm/vs/base/common/buffer.js';
|
|
6
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
7
|
+
import { getExtensionForMimeType } from 'monaco-editor/esm/vs/base/common/mime.js';
|
|
8
|
+
import { Schemas, FileAccess, matchesScheme, matchesSomeScheme } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
9
|
+
import { equals } from 'monaco-editor/esm/vs/base/common/objects.js';
|
|
10
|
+
import * as path from 'monaco-editor/esm/vs/base/common/path.js';
|
|
11
|
+
import { isWeb, isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
12
|
+
import { dirname, isEqual, extname, joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
13
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
14
|
+
import * as UUID from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
15
|
+
import { TokenizationRegistry } from 'monaco-editor/esm/vs/editor/common/languages.js';
|
|
16
|
+
import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
|
|
17
|
+
import { generateTokensCSSForColorMap } from 'monaco-editor/esm/vs/editor/common/languages/supports/tokenization.js';
|
|
18
|
+
import { tokenizeToString } from 'monaco-editor/esm/vs/editor/common/languages/textToHtmlTokenizer.js';
|
|
19
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
20
|
+
import { MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
21
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
22
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
23
|
+
import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
|
|
24
|
+
import '../../../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
25
|
+
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
26
|
+
import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
|
|
27
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
28
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
29
|
+
import { editorFindMatch, editorFindMatchHighlight } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
30
|
+
import { Themable, IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
31
|
+
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
32
|
+
import { IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
|
|
33
|
+
import { CellEditState } from '../../notebookBrowser.js';
|
|
34
|
+
import { NOTEBOOK_WEBVIEW_BOUNDARY } from '../notebookCellList.js';
|
|
35
|
+
import { preloadsScriptStr } from './webviewPreloads.js';
|
|
36
|
+
import { transformWebviewThemeVars } from './webviewThemeMapping.js';
|
|
37
|
+
import { MarkupCellViewModel } from '../../viewModel/markupCellViewModel.js';
|
|
38
|
+
import { CellUri } from '../../../common/notebookCommon.js';
|
|
39
|
+
import { INotebookLoggingService } from '../../../common/notebookLoggingService.js';
|
|
40
|
+
import { INotebookService } from '../../../common/notebookService.js';
|
|
41
|
+
import { WebviewOriginStore, IWebviewService } from '../../../../webview/browser/webview.js';
|
|
42
|
+
import { WebviewWindowDragMonitor } from '../../../../webview/browser/webviewWindowDragMonitor.js';
|
|
43
|
+
import { webviewGenericCspSource, asWebviewUri } from '../../../../webview/common/webview.js';
|
|
44
|
+
import { IEditorGroupsService } from '../../../../../services/editor/common/editorGroupsService.js';
|
|
45
|
+
import { IWorkbenchEnvironmentService } from '../../../../../services/environment/common/environmentService.js';
|
|
46
|
+
import { IPathService } from '../../../../../services/path/common/pathService.js';
|
|
47
|
+
import { IFileDialogService } from '../../../../../../platform/dialogs/common/dialogs.js';
|
|
48
|
+
var BackLayerWebView_1;
|
|
49
|
+
const LINE_COLUMN_REGEX = /:([\d]+)(?::([\d]+))?$/;
|
|
50
|
+
const LineQueryRegex = /line=(\d+)$/;
|
|
51
|
+
const FRAGMENT_REGEX = /^(.*)#([^#]*)$/;
|
|
52
|
+
let BackLayerWebView = class BackLayerWebView extends Themable {
|
|
53
|
+
static { BackLayerWebView_1 = this; }
|
|
54
|
+
static getOriginStore(storageService) {
|
|
55
|
+
this._originStore ??= ( new WebviewOriginStore('notebook.backlayerWebview.origins', storageService));
|
|
56
|
+
return this._originStore;
|
|
57
|
+
}
|
|
58
|
+
constructor(notebookEditor, id, notebookViewType, documentUri, options, rendererMessaging, webviewService, openerService, notebookService, contextService, environmentService, fileDialogService, fileService, contextMenuService, contextKeyService, workspaceTrustManagementService, configurationService, languageService, workspaceContextService, editorGroupService, storageService, pathService, notebookLogService, themeService, telemetryService) {
|
|
59
|
+
super(themeService);
|
|
60
|
+
this.notebookEditor = notebookEditor;
|
|
61
|
+
this.id = id;
|
|
62
|
+
this.notebookViewType = notebookViewType;
|
|
63
|
+
this.documentUri = documentUri;
|
|
64
|
+
this.options = options;
|
|
65
|
+
this.rendererMessaging = rendererMessaging;
|
|
66
|
+
this.webviewService = webviewService;
|
|
67
|
+
this.openerService = openerService;
|
|
68
|
+
this.notebookService = notebookService;
|
|
69
|
+
this.contextService = contextService;
|
|
70
|
+
this.environmentService = environmentService;
|
|
71
|
+
this.fileDialogService = fileDialogService;
|
|
72
|
+
this.fileService = fileService;
|
|
73
|
+
this.contextMenuService = contextMenuService;
|
|
74
|
+
this.contextKeyService = contextKeyService;
|
|
75
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
76
|
+
this.configurationService = configurationService;
|
|
77
|
+
this.languageService = languageService;
|
|
78
|
+
this.workspaceContextService = workspaceContextService;
|
|
79
|
+
this.editorGroupService = editorGroupService;
|
|
80
|
+
this.storageService = storageService;
|
|
81
|
+
this.pathService = pathService;
|
|
82
|
+
this.notebookLogService = notebookLogService;
|
|
83
|
+
this.telemetryService = telemetryService;
|
|
84
|
+
this.webview = undefined;
|
|
85
|
+
this.insetMapping = ( new Map());
|
|
86
|
+
this.pendingWebviewIdleCreationRequest = ( new Map());
|
|
87
|
+
this.pendingWebviewIdleInsetMapping = ( new Map());
|
|
88
|
+
this.reversedPendingWebviewIdleInsetMapping = ( new Map());
|
|
89
|
+
this.markupPreviewMapping = ( new Map());
|
|
90
|
+
this.hiddenInsetMapping = ( new Set());
|
|
91
|
+
this.reversedInsetMapping = ( new Map());
|
|
92
|
+
this.localResourceRootsCache = undefined;
|
|
93
|
+
this._onMessage = this._register(( new Emitter()));
|
|
94
|
+
this._preloadsCache = ( new Set());
|
|
95
|
+
this.onMessage = this._onMessage.event;
|
|
96
|
+
this._disposed = false;
|
|
97
|
+
this.firstInit = true;
|
|
98
|
+
this.nonce = UUID.generateUuid();
|
|
99
|
+
this._logRendererDebugMessage('Creating backlayer webview for notebook');
|
|
100
|
+
this.element = document.createElement('div');
|
|
101
|
+
this.element.style.height = '1400px';
|
|
102
|
+
this.element.style.position = 'absolute';
|
|
103
|
+
if (rendererMessaging) {
|
|
104
|
+
this._register(rendererMessaging);
|
|
105
|
+
rendererMessaging.receiveMessageHandler = (rendererId, message) => {
|
|
106
|
+
if (!this.webview || this._disposed) {
|
|
107
|
+
return Promise.resolve(false);
|
|
108
|
+
}
|
|
109
|
+
this._sendMessageToWebview({
|
|
110
|
+
__vscode_notebook_message: true,
|
|
111
|
+
type: 'customRendererMessage',
|
|
112
|
+
rendererId: rendererId,
|
|
113
|
+
message: message
|
|
114
|
+
});
|
|
115
|
+
return Promise.resolve(true);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
this._register(workspaceTrustManagementService.onDidChangeTrust(e => {
|
|
119
|
+
const baseUrl = this.asWebviewUri(this.getNotebookBaseUri(), undefined);
|
|
120
|
+
const htmlContent = this.generateContent(( baseUrl.toString()));
|
|
121
|
+
this.webview?.setHtml(htmlContent);
|
|
122
|
+
}));
|
|
123
|
+
this._register(TokenizationRegistry.onDidChange(() => {
|
|
124
|
+
this._sendMessageToWebview({
|
|
125
|
+
type: 'tokenizedStylesChanged',
|
|
126
|
+
css: getTokenizationCss(),
|
|
127
|
+
});
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
updateOptions(options) {
|
|
131
|
+
this.options = options;
|
|
132
|
+
this._updateStyles();
|
|
133
|
+
this._updateOptions();
|
|
134
|
+
}
|
|
135
|
+
_logRendererDebugMessage(msg) {
|
|
136
|
+
this.notebookLogService.debug('BacklayerWebview', `${this.documentUri} (${this.id}) - ${msg}`);
|
|
137
|
+
}
|
|
138
|
+
_updateStyles() {
|
|
139
|
+
this._sendMessageToWebview({
|
|
140
|
+
type: 'notebookStyles',
|
|
141
|
+
styles: this._generateStyles()
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
_updateOptions() {
|
|
145
|
+
this._sendMessageToWebview({
|
|
146
|
+
type: 'notebookOptions',
|
|
147
|
+
options: {
|
|
148
|
+
dragAndDropEnabled: this.options.dragAndDropEnabled
|
|
149
|
+
},
|
|
150
|
+
renderOptions: {
|
|
151
|
+
lineLimit: this.options.outputLineLimit,
|
|
152
|
+
outputScrolling: this.options.outputScrolling,
|
|
153
|
+
outputWordWrap: this.options.outputWordWrap
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
_generateStyles() {
|
|
158
|
+
return {
|
|
159
|
+
'notebook-output-left-margin': `${this.options.leftMargin + this.options.runGutter}px`,
|
|
160
|
+
'notebook-output-width': `calc(100% - ${this.options.leftMargin + this.options.rightMargin + this.options.runGutter}px)`,
|
|
161
|
+
'notebook-output-node-padding': `${this.options.outputNodePadding}px`,
|
|
162
|
+
'notebook-run-gutter': `${this.options.runGutter}px`,
|
|
163
|
+
'notebook-preview-node-padding': `${this.options.previewNodePadding}px`,
|
|
164
|
+
'notebook-markdown-left-margin': `${this.options.markdownLeftMargin}px`,
|
|
165
|
+
'notebook-output-node-left-padding': `${this.options.outputNodeLeftPadding}px`,
|
|
166
|
+
'notebook-markdown-min-height': `${this.options.previewNodePadding * 2}px`,
|
|
167
|
+
'notebook-markup-font-size': typeof this.options.markupFontSize === 'number' && this.options.markupFontSize > 0 ? `${this.options.markupFontSize}px` : `calc(${this.options.fontSize}px * 1.2)`,
|
|
168
|
+
'notebook-cell-output-font-size': `${this.options.outputFontSize || this.options.fontSize}px`,
|
|
169
|
+
'notebook-cell-output-line-height': `${this.options.outputLineHeight}px`,
|
|
170
|
+
'notebook-cell-output-max-height': `${this.options.outputLineHeight * this.options.outputLineLimit}px`,
|
|
171
|
+
'notebook-cell-output-font-family': this.options.outputFontFamily || this.options.fontFamily,
|
|
172
|
+
'notebook-cell-markup-empty-content': ( nls.localizeWithPath(
|
|
173
|
+
'vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView',
|
|
174
|
+
'notebook.emptyMarkdownPlaceholder',
|
|
175
|
+
"Empty markdown cell, double-click or press enter to edit."
|
|
176
|
+
)),
|
|
177
|
+
'notebook-cell-renderer-not-found-error': ( nls.localizeWithPath('vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView', {
|
|
178
|
+
key: 'notebook.error.rendererNotFound',
|
|
179
|
+
comment: ['$0 is a placeholder for the mime type']
|
|
180
|
+
}, "No renderer found for '$0'")),
|
|
181
|
+
'notebook-cell-renderer-fallbacks-exhausted': ( nls.localizeWithPath('vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView', {
|
|
182
|
+
key: 'notebook.error.rendererFallbacksExhausted',
|
|
183
|
+
comment: ['$0 is a placeholder for the mime type']
|
|
184
|
+
}, "Could not render content for '$0'")),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
generateContent(baseUrl) {
|
|
188
|
+
const renderersData = this.getRendererData();
|
|
189
|
+
const preloadsData = this.getStaticPreloadsData();
|
|
190
|
+
const renderOptions = {
|
|
191
|
+
lineLimit: this.options.outputLineLimit,
|
|
192
|
+
outputScrolling: this.options.outputScrolling,
|
|
193
|
+
outputWordWrap: this.options.outputWordWrap
|
|
194
|
+
};
|
|
195
|
+
const preloadScript = preloadsScriptStr({
|
|
196
|
+
...this.options,
|
|
197
|
+
tokenizationCss: getTokenizationCss(),
|
|
198
|
+
}, { dragAndDropEnabled: this.options.dragAndDropEnabled }, renderOptions, renderersData, preloadsData, this.workspaceTrustManagementService.isWorkspaceTrusted(), this.nonce);
|
|
199
|
+
const enableCsp = this.configurationService.getValue('notebook.experimental.enableCsp');
|
|
200
|
+
const currentHighlight = this.getColor(editorFindMatch);
|
|
201
|
+
const findMatchHighlight = this.getColor(editorFindMatchHighlight);
|
|
202
|
+
return `
|
|
203
|
+
<html lang="en">
|
|
204
|
+
<head>
|
|
205
|
+
<meta charset="UTF-8">
|
|
206
|
+
<base href="${baseUrl}/" />
|
|
207
|
+
${enableCsp ?
|
|
208
|
+
`<meta http-equiv="Content-Security-Policy" content="
|
|
209
|
+
default-src 'none';
|
|
210
|
+
script-src ${webviewGenericCspSource} 'unsafe-inline' 'unsafe-eval';
|
|
211
|
+
style-src ${webviewGenericCspSource} 'unsafe-inline';
|
|
212
|
+
img-src ${webviewGenericCspSource} https: http: data:;
|
|
213
|
+
font-src ${webviewGenericCspSource} https:;
|
|
214
|
+
connect-src https:;
|
|
215
|
+
child-src https: data:;
|
|
216
|
+
">` : ''}
|
|
217
|
+
<style nonce="${this.nonce}">
|
|
218
|
+
::highlight(find-highlight) {
|
|
219
|
+
background-color: var(--vscode-editor-findMatchBackground, ${findMatchHighlight});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
::highlight(current-find-highlight) {
|
|
223
|
+
background-color: var(--vscode-editor-findMatchHighlightBackground, ${currentHighlight});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
#container .cell_container {
|
|
227
|
+
width: 100%;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#container .output_container {
|
|
231
|
+
width: 100%;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
#container > div > div > div.output {
|
|
235
|
+
font-size: var(--notebook-cell-output-font-size);
|
|
236
|
+
width: var(--notebook-output-width);
|
|
237
|
+
margin-left: var(--notebook-output-left-margin);
|
|
238
|
+
background-color: var(--theme-notebook-output-background);
|
|
239
|
+
padding-top: var(--notebook-output-node-padding);
|
|
240
|
+
padding-right: var(--notebook-output-node-padding);
|
|
241
|
+
padding-bottom: var(--notebook-output-node-padding);
|
|
242
|
+
padding-left: var(--notebook-output-node-left-padding);
|
|
243
|
+
box-sizing: border-box;
|
|
244
|
+
border-top: none;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* markdown */
|
|
248
|
+
#container div.preview {
|
|
249
|
+
width: 100%;
|
|
250
|
+
padding-right: var(--notebook-preview-node-padding);
|
|
251
|
+
padding-left: var(--notebook-markdown-left-margin);
|
|
252
|
+
padding-top: var(--notebook-preview-node-padding);
|
|
253
|
+
padding-bottom: var(--notebook-preview-node-padding);
|
|
254
|
+
|
|
255
|
+
box-sizing: border-box;
|
|
256
|
+
white-space: nowrap;
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
white-space: initial;
|
|
259
|
+
|
|
260
|
+
font-size: var(--notebook-markup-font-size);
|
|
261
|
+
color: var(--theme-ui-foreground);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#container div.preview.draggable {
|
|
265
|
+
user-select: none;
|
|
266
|
+
-webkit-user-select: none;
|
|
267
|
+
-ms-user-select: none;
|
|
268
|
+
cursor: grab;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
#container div.preview.selected {
|
|
272
|
+
background: var(--theme-notebook-cell-selected-background);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
#container div.preview.dragging {
|
|
276
|
+
background-color: var(--theme-background);
|
|
277
|
+
opacity: 0.5 !important;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.monaco-workbench.vs-dark .notebookOverlay .cell.markdown .latex img,
|
|
281
|
+
.monaco-workbench.vs-dark .notebookOverlay .cell.markdown .latex-block img {
|
|
282
|
+
filter: brightness(0) invert(1)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#container .markup > div.nb-symbolHighlight {
|
|
286
|
+
background-color: var(--theme-notebook-symbol-highlight-background);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#container > div.nb-cellDeleted .output_container {
|
|
290
|
+
background-color: var(--theme-notebook-diff-removed-background);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
#container > div.nb-cellAdded .output_container {
|
|
294
|
+
background-color: var(--theme-notebook-diff-inserted-background);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
#container > div > div:not(.preview) > div {
|
|
298
|
+
overflow-x: auto;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#container .no-renderer-error {
|
|
302
|
+
color: var(--vscode-editorError-foreground);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
body {
|
|
306
|
+
padding: 0px;
|
|
307
|
+
height: 100%;
|
|
308
|
+
width: 100%;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
table, thead, tr, th, td, tbody {
|
|
312
|
+
border: none !important;
|
|
313
|
+
border-color: transparent;
|
|
314
|
+
border-spacing: 0;
|
|
315
|
+
border-collapse: collapse;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
table, th, tr {
|
|
319
|
+
vertical-align: middle;
|
|
320
|
+
text-align: right;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
thead {
|
|
324
|
+
font-weight: bold;
|
|
325
|
+
background-color: rgba(130, 130, 130, 0.16);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
th, td {
|
|
329
|
+
padding: 4px 8px;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
tr:nth-child(even) {
|
|
333
|
+
background-color: rgba(130, 130, 130, 0.08);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
tbody th {
|
|
337
|
+
font-weight: normal;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.find-match {
|
|
341
|
+
background-color: var(--vscode-editor-findMatchHighlightBackground);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.current-find-match {
|
|
345
|
+
background-color: var(--vscode-editor-findMatchBackground);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#_defaultColorPalatte {
|
|
349
|
+
color: var(--vscode-editor-findMatchHighlightBackground);
|
|
350
|
+
background-color: var(--vscode-editor-findMatchBackground);
|
|
351
|
+
}
|
|
352
|
+
</style>
|
|
353
|
+
</head>
|
|
354
|
+
<body style="overflow: hidden;">
|
|
355
|
+
<div id='findStart' tabIndex=-1></div>
|
|
356
|
+
<div id='container' class="widgetarea" style="position: absolute;width:100%;top: 0px"></div>
|
|
357
|
+
<div id="_defaultColorPalatte"></div>
|
|
358
|
+
<script type="module">${preloadScript}</script>
|
|
359
|
+
</body>
|
|
360
|
+
</html>`;
|
|
361
|
+
}
|
|
362
|
+
getRendererData() {
|
|
363
|
+
return ( this.notebookService.getRenderers().map((renderer) => {
|
|
364
|
+
const entrypoint = {
|
|
365
|
+
extends: renderer.entrypoint.extends,
|
|
366
|
+
path: ( this.asWebviewUri(renderer.entrypoint.path, renderer.extensionLocation).toString())
|
|
367
|
+
};
|
|
368
|
+
return {
|
|
369
|
+
id: renderer.id,
|
|
370
|
+
entrypoint,
|
|
371
|
+
mimeTypes: renderer.mimeTypes,
|
|
372
|
+
messaging: renderer.messaging !== "never" ,
|
|
373
|
+
isBuiltin: renderer.isBuiltin
|
|
374
|
+
};
|
|
375
|
+
}));
|
|
376
|
+
}
|
|
377
|
+
getStaticPreloadsData() {
|
|
378
|
+
return Array.from(this.notebookService.getStaticPreloads(this.notebookViewType), preload => {
|
|
379
|
+
return { entrypoint: ( ( this.asWebviewUri(preload.entrypoint, preload.extensionLocation).toString()).toString()) };
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
asWebviewUri(uri, fromExtension) {
|
|
383
|
+
return asWebviewUri(uri, fromExtension?.scheme === Schemas.vscodeRemote ? { isRemote: true, authority: fromExtension.authority } : undefined);
|
|
384
|
+
}
|
|
385
|
+
postKernelMessage(message) {
|
|
386
|
+
this._sendMessageToWebview({
|
|
387
|
+
__vscode_notebook_message: true,
|
|
388
|
+
type: 'customKernelMessage',
|
|
389
|
+
message,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
resolveOutputId(id) {
|
|
393
|
+
const output = this.reversedInsetMapping.get(id);
|
|
394
|
+
if (!output) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const cellInfo = this.insetMapping.get(output).cellInfo;
|
|
398
|
+
return { cellInfo, output };
|
|
399
|
+
}
|
|
400
|
+
isResolved() {
|
|
401
|
+
return !!this.webview;
|
|
402
|
+
}
|
|
403
|
+
createWebview() {
|
|
404
|
+
const baseUrl = this.asWebviewUri(this.getNotebookBaseUri(), undefined);
|
|
405
|
+
const htmlContent = this.generateContent(( baseUrl.toString()));
|
|
406
|
+
return this._initialize(htmlContent);
|
|
407
|
+
}
|
|
408
|
+
getNotebookBaseUri() {
|
|
409
|
+
if (this.documentUri.scheme === Schemas.untitled) {
|
|
410
|
+
const folder = this.workspaceContextService.getWorkspaceFolder(this.documentUri);
|
|
411
|
+
if (folder) {
|
|
412
|
+
return folder.uri;
|
|
413
|
+
}
|
|
414
|
+
const folders = this.workspaceContextService.getWorkspace().folders;
|
|
415
|
+
if (folders.length) {
|
|
416
|
+
return folders[0].uri;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return dirname(this.documentUri);
|
|
420
|
+
}
|
|
421
|
+
getBuiltinLocalResourceRoots() {
|
|
422
|
+
if (!this.documentUri.path.toLowerCase().endsWith('.ipynb')) {
|
|
423
|
+
return [];
|
|
424
|
+
}
|
|
425
|
+
if (isWeb) {
|
|
426
|
+
return [];
|
|
427
|
+
}
|
|
428
|
+
return [
|
|
429
|
+
dirname(( FileAccess.asFileUri('vs/loader.js'))),
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
_initialize(content) {
|
|
433
|
+
if (!getWindow(this.element).document.body.contains(this.element)) {
|
|
434
|
+
throw new Error('Element is already detached from the DOM tree');
|
|
435
|
+
}
|
|
436
|
+
this.webview = this._createInset(this.webviewService, content);
|
|
437
|
+
this.webview.mountTo(this.element);
|
|
438
|
+
this._register(this.webview);
|
|
439
|
+
this._register(( new WebviewWindowDragMonitor(() => this.webview)));
|
|
440
|
+
const initializePromise = ( new DeferredPromise());
|
|
441
|
+
this._register(this.webview.onFatalError(e => {
|
|
442
|
+
initializePromise.error(( new Error(`Could not initialize webview: ${e.message}}`)));
|
|
443
|
+
}));
|
|
444
|
+
this._register(this.webview.onMessage(async (message) => {
|
|
445
|
+
const data = message.message;
|
|
446
|
+
if (this._disposed) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (!data.__vscode_notebook_message) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
switch (data.type) {
|
|
453
|
+
case 'initialized': {
|
|
454
|
+
initializePromise.complete();
|
|
455
|
+
this.initializeWebViewState();
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
case 'initializedMarkup': {
|
|
459
|
+
if (this.initializeMarkupPromise?.requestId === data.requestId) {
|
|
460
|
+
this.initializeMarkupPromise?.p.complete();
|
|
461
|
+
this.initializeMarkupPromise = undefined;
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
case 'dimension': {
|
|
466
|
+
for (const update of data.updates) {
|
|
467
|
+
const height = update.height;
|
|
468
|
+
if (update.isOutput) {
|
|
469
|
+
const resolvedResult = this.resolveOutputId(update.id);
|
|
470
|
+
if (resolvedResult) {
|
|
471
|
+
const { cellInfo, output } = resolvedResult;
|
|
472
|
+
this.notebookEditor.updateOutputHeight(cellInfo, output, height, !!update.init, 'webview#dimension');
|
|
473
|
+
this.notebookEditor.scheduleOutputHeightAck(cellInfo, update.id, height);
|
|
474
|
+
}
|
|
475
|
+
else if (update.init) {
|
|
476
|
+
const outputRequest = this.reversedPendingWebviewIdleInsetMapping.get(update.id);
|
|
477
|
+
if (outputRequest) {
|
|
478
|
+
const inset = this.pendingWebviewIdleInsetMapping.get(outputRequest);
|
|
479
|
+
this.pendingWebviewIdleCreationRequest.delete(outputRequest);
|
|
480
|
+
this.pendingWebviewIdleCreationRequest.delete(outputRequest);
|
|
481
|
+
const cellInfo = inset.cellInfo;
|
|
482
|
+
this.reversedInsetMapping.set(update.id, outputRequest);
|
|
483
|
+
this.insetMapping.set(outputRequest, inset);
|
|
484
|
+
this.notebookEditor.updateOutputHeight(cellInfo, outputRequest, height, !!update.init, 'webview#dimension');
|
|
485
|
+
this.notebookEditor.scheduleOutputHeightAck(cellInfo, update.id, height);
|
|
486
|
+
}
|
|
487
|
+
this.reversedPendingWebviewIdleInsetMapping.delete(update.id);
|
|
488
|
+
}
|
|
489
|
+
{
|
|
490
|
+
if (!update.init) {
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const output = this.reversedInsetMapping.get(update.id);
|
|
494
|
+
if (!output) {
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
const inset = this.insetMapping.get(output);
|
|
498
|
+
inset.initialized = true;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
this.notebookEditor.updateMarkupCellHeight(update.id, height, !!update.init);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
case 'mouseenter': {
|
|
508
|
+
const resolvedResult = this.resolveOutputId(data.id);
|
|
509
|
+
if (resolvedResult) {
|
|
510
|
+
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
|
|
511
|
+
if (latestCell) {
|
|
512
|
+
latestCell.outputIsHovered = true;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
case 'mouseleave': {
|
|
518
|
+
const resolvedResult = this.resolveOutputId(data.id);
|
|
519
|
+
if (resolvedResult) {
|
|
520
|
+
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
|
|
521
|
+
if (latestCell) {
|
|
522
|
+
latestCell.outputIsHovered = false;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
case 'outputFocus': {
|
|
528
|
+
const resolvedResult = this.resolveOutputId(data.id);
|
|
529
|
+
if (resolvedResult) {
|
|
530
|
+
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
|
|
531
|
+
if (latestCell) {
|
|
532
|
+
latestCell.outputIsFocused = true;
|
|
533
|
+
this.notebookEditor.focusNotebookCell(latestCell, 'output', { skipReveal: true });
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
case 'outputBlur': {
|
|
539
|
+
const resolvedResult = this.resolveOutputId(data.id);
|
|
540
|
+
if (resolvedResult) {
|
|
541
|
+
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
|
|
542
|
+
if (latestCell) {
|
|
543
|
+
latestCell.outputIsFocused = false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
break;
|
|
547
|
+
}
|
|
548
|
+
case 'scroll-ack': {
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
case 'scroll-to-reveal': {
|
|
552
|
+
this.notebookEditor.setScrollTop(data.scrollTop - NOTEBOOK_WEBVIEW_BOUNDARY);
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
case 'did-scroll-wheel': {
|
|
556
|
+
this.notebookEditor.triggerScroll({
|
|
557
|
+
...data.payload,
|
|
558
|
+
preventDefault: () => { },
|
|
559
|
+
stopPropagation: () => { }
|
|
560
|
+
});
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
case 'focus-editor': {
|
|
564
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
565
|
+
if (cell) {
|
|
566
|
+
if (data.focusNext) {
|
|
567
|
+
this.notebookEditor.focusNextNotebookCell(cell, 'editor');
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
await this.notebookEditor.focusNotebookCell(cell, 'editor');
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
case 'clicked-data-url': {
|
|
576
|
+
this._onDidClickDataLink(data);
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
case 'clicked-link': {
|
|
580
|
+
if (matchesScheme(data.href, Schemas.command)) {
|
|
581
|
+
const uri = ( URI.parse(data.href));
|
|
582
|
+
if (uri.path === 'workbench.action.openLargeOutput') {
|
|
583
|
+
const outputId = uri.query;
|
|
584
|
+
const group = this.editorGroupService.activeGroup;
|
|
585
|
+
if (group) {
|
|
586
|
+
if (group.activeEditor) {
|
|
587
|
+
group.pinEditor(group.activeEditor);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
this.openerService.open(CellUri.generateCellOutputUri(this.documentUri, outputId));
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (uri.path === 'cellOutput.enableScrolling') {
|
|
594
|
+
const outputId = uri.query;
|
|
595
|
+
const cell = this.reversedInsetMapping.get(outputId);
|
|
596
|
+
if (cell) {
|
|
597
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', { id: 'notebook.cell.toggleOutputScrolling', from: 'inlineLink' });
|
|
598
|
+
cell.cellViewModel.outputsViewModels.forEach((vm) => {
|
|
599
|
+
if (vm.model.metadata) {
|
|
600
|
+
vm.model.metadata['scrollable'] = true;
|
|
601
|
+
vm.resetRenderer();
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
this.openerService.open(data.href, {
|
|
608
|
+
fromUserGesture: true,
|
|
609
|
+
fromWorkspace: true,
|
|
610
|
+
allowCommands: [
|
|
611
|
+
'github-issues.authNow',
|
|
612
|
+
'workbench.extensions.search',
|
|
613
|
+
'workbench.action.openSettings',
|
|
614
|
+
'_notebook.selectKernel',
|
|
615
|
+
'jupyter.viewOutput'
|
|
616
|
+
],
|
|
617
|
+
});
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
if (matchesSomeScheme(data.href, Schemas.http, Schemas.https, Schemas.mailto)) {
|
|
621
|
+
this.openerService.open(data.href, { fromUserGesture: true, fromWorkspace: true });
|
|
622
|
+
}
|
|
623
|
+
else if (matchesScheme(data.href, Schemas.vscodeNotebookCell)) {
|
|
624
|
+
const uri = ( URI.parse(data.href));
|
|
625
|
+
await this._handleNotebookCellResource(uri);
|
|
626
|
+
}
|
|
627
|
+
else if (!/^[\w\-]+:/.test(data.href)) {
|
|
628
|
+
await this._handleResourceOpening(tryDecodeURIComponent(data.href));
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
if (path.isAbsolute(data.href)) {
|
|
632
|
+
this._openUri(URI.file(data.href));
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
this._openUri(( URI.parse(data.href)));
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
case 'customKernelMessage': {
|
|
641
|
+
this._onMessage.fire({ message: data.message });
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
case 'customRendererMessage': {
|
|
645
|
+
this.rendererMessaging?.postMessage(data.rendererId, data.message);
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
case 'clickMarkupCell': {
|
|
649
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
650
|
+
if (cell) {
|
|
651
|
+
if (data.shiftKey || (isMacintosh ? data.metaKey : data.ctrlKey)) {
|
|
652
|
+
this.notebookEditor.toggleNotebookCellSelection(cell, data.shiftKey);
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
await this.notebookEditor.focusNotebookCell(cell, 'container', { skipReveal: true });
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
case 'contextMenuMarkupCell': {
|
|
661
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
662
|
+
if (cell) {
|
|
663
|
+
await this.notebookEditor.focusNotebookCell(cell, 'container', { skipReveal: true });
|
|
664
|
+
const webviewRect = this.element.getBoundingClientRect();
|
|
665
|
+
this.contextMenuService.showContextMenu({
|
|
666
|
+
menuId: MenuId.NotebookCellTitle,
|
|
667
|
+
contextKeyService: this.contextKeyService,
|
|
668
|
+
getAnchor: () => ({
|
|
669
|
+
x: webviewRect.x + data.clientX,
|
|
670
|
+
y: webviewRect.y + data.clientY
|
|
671
|
+
})
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
break;
|
|
675
|
+
}
|
|
676
|
+
case 'toggleMarkupPreview': {
|
|
677
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
678
|
+
if (cell && !this.notebookEditor.creationOptions.isReadOnly) {
|
|
679
|
+
this.notebookEditor.setMarkupCellEditState(data.cellId, CellEditState.Editing);
|
|
680
|
+
await this.notebookEditor.focusNotebookCell(cell, 'editor', { skipReveal: true });
|
|
681
|
+
}
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
case 'mouseEnterMarkupCell': {
|
|
685
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
686
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
687
|
+
cell.cellIsHovered = true;
|
|
688
|
+
}
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
case 'mouseLeaveMarkupCell': {
|
|
692
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
693
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
694
|
+
cell.cellIsHovered = false;
|
|
695
|
+
}
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
case 'cell-drag-start': {
|
|
699
|
+
this.notebookEditor.didStartDragMarkupCell(data.cellId, data);
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
case 'cell-drag': {
|
|
703
|
+
this.notebookEditor.didDragMarkupCell(data.cellId, data);
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
case 'cell-drop': {
|
|
707
|
+
this.notebookEditor.didDropMarkupCell(data.cellId, {
|
|
708
|
+
dragOffsetY: data.dragOffsetY,
|
|
709
|
+
ctrlKey: data.ctrlKey,
|
|
710
|
+
altKey: data.altKey,
|
|
711
|
+
});
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
case 'cell-drag-end': {
|
|
715
|
+
this.notebookEditor.didEndDragMarkupCell(data.cellId);
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
case 'renderedMarkup': {
|
|
719
|
+
const cell = this.notebookEditor.getCellById(data.cellId);
|
|
720
|
+
if (cell instanceof MarkupCellViewModel) {
|
|
721
|
+
cell.renderedHtml = data.html;
|
|
722
|
+
}
|
|
723
|
+
this._handleHighlightCodeBlock(data.codeBlocks);
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
case 'renderedCellOutput': {
|
|
727
|
+
this._handleHighlightCodeBlock(data.codeBlocks);
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
case 'outputResized': {
|
|
731
|
+
this.notebookEditor.didResizeOutput(data.cellId);
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
case 'getOutputItem': {
|
|
735
|
+
const resolvedResult = this.resolveOutputId(data.outputId);
|
|
736
|
+
const output = resolvedResult?.output.model.outputs.find(output => output.mime === data.mime);
|
|
737
|
+
this._sendMessageToWebview({
|
|
738
|
+
type: 'returnOutputItem',
|
|
739
|
+
requestId: data.requestId,
|
|
740
|
+
output: output ? { mime: output.mime, valueBytes: output.data.buffer } : undefined,
|
|
741
|
+
});
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
744
|
+
case 'logRendererDebugMessage': {
|
|
745
|
+
this._logRendererDebugMessage(`${data.message}${data.data ? ' ' + JSON.stringify(data.data, null, 4) : ''}`);
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
case 'notebookPerformanceMessage': {
|
|
749
|
+
this.notebookEditor.updatePerformanceMetadata(data.cellId, data.executionId, data.duration, data.rendererId);
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
case 'outputInputFocus': {
|
|
753
|
+
this.notebookEditor.didFocusOutputInputChange(data.inputFocused);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}));
|
|
757
|
+
return initializePromise.p;
|
|
758
|
+
}
|
|
759
|
+
_handleNotebookCellResource(uri) {
|
|
760
|
+
const notebookResource = uri.path.length > 0 ? uri : this.documentUri;
|
|
761
|
+
const lineMatch = /(?:^|&)line=([^&]+)/.exec(uri.query);
|
|
762
|
+
let editorOptions = undefined;
|
|
763
|
+
if (lineMatch) {
|
|
764
|
+
const parsedLineNumber = parseInt(lineMatch[1], 10);
|
|
765
|
+
if (!isNaN(parsedLineNumber)) {
|
|
766
|
+
const lineNumber = parsedLineNumber;
|
|
767
|
+
editorOptions = {
|
|
768
|
+
selection: { startLineNumber: lineNumber, startColumn: 1 }
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
const executionMatch = /(?:^|&)execution_count=([^&]+)/.exec(uri.query);
|
|
773
|
+
if (executionMatch) {
|
|
774
|
+
const executionCount = parseInt(executionMatch[1], 10);
|
|
775
|
+
if (!isNaN(executionCount)) {
|
|
776
|
+
const notebookModel = this.notebookService.getNotebookTextModel(notebookResource);
|
|
777
|
+
const cell = notebookModel?.cells.slice().reverse().find(cell => {
|
|
778
|
+
return cell.internalMetadata.executionOrder === executionCount;
|
|
779
|
+
});
|
|
780
|
+
if (cell?.uri) {
|
|
781
|
+
return this.openerService.open(cell.uri, {
|
|
782
|
+
fromUserGesture: true,
|
|
783
|
+
fromWorkspace: true,
|
|
784
|
+
editorOptions: editorOptions
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
const fragmentLineMatch = /\?line=(\d+)$/.exec(uri.fragment);
|
|
790
|
+
if (fragmentLineMatch) {
|
|
791
|
+
const parsedLineNumber = parseInt(fragmentLineMatch[1], 10);
|
|
792
|
+
if (!isNaN(parsedLineNumber)) {
|
|
793
|
+
const lineNumber = parsedLineNumber + 1;
|
|
794
|
+
const fragment = uri.fragment.substring(0, fragmentLineMatch.index);
|
|
795
|
+
const editorOptions = {
|
|
796
|
+
selection: { startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }
|
|
797
|
+
};
|
|
798
|
+
return this.openerService.open(notebookResource.with({ fragment }), {
|
|
799
|
+
fromUserGesture: true,
|
|
800
|
+
fromWorkspace: true,
|
|
801
|
+
editorOptions: editorOptions
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return this.openerService.open(notebookResource, { fromUserGesture: true, fromWorkspace: true });
|
|
806
|
+
}
|
|
807
|
+
async _handleResourceOpening(href) {
|
|
808
|
+
let linkToOpen = undefined;
|
|
809
|
+
let fragment = undefined;
|
|
810
|
+
const hrefWithFragment = FRAGMENT_REGEX.exec(href);
|
|
811
|
+
if (hrefWithFragment) {
|
|
812
|
+
href = hrefWithFragment[1];
|
|
813
|
+
fragment = hrefWithFragment[2];
|
|
814
|
+
}
|
|
815
|
+
if (href.startsWith('/')) {
|
|
816
|
+
linkToOpen = await this.pathService.fileURI(href);
|
|
817
|
+
const folders = this.workspaceContextService.getWorkspace().folders;
|
|
818
|
+
if (folders.length) {
|
|
819
|
+
linkToOpen = linkToOpen.with({
|
|
820
|
+
scheme: folders[0].uri.scheme,
|
|
821
|
+
authority: folders[0].uri.authority
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
else if (href.startsWith('~')) {
|
|
826
|
+
const userHome = await this.pathService.userHome();
|
|
827
|
+
if (userHome) {
|
|
828
|
+
linkToOpen = URI.joinPath(userHome, href.substring(2));
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
if (this.documentUri.scheme === Schemas.untitled) {
|
|
833
|
+
const folders = this.workspaceContextService.getWorkspace().folders;
|
|
834
|
+
if (!folders.length) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
linkToOpen = URI.joinPath(folders[0].uri, href);
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
linkToOpen = URI.joinPath(dirname(this.documentUri), href);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (linkToOpen) {
|
|
844
|
+
if (fragment) {
|
|
845
|
+
linkToOpen = linkToOpen.with({ fragment });
|
|
846
|
+
}
|
|
847
|
+
this._openUri(linkToOpen);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
_openUri(uri) {
|
|
851
|
+
let lineNumber = undefined;
|
|
852
|
+
let column = undefined;
|
|
853
|
+
const lineCol = LINE_COLUMN_REGEX.exec(uri.path);
|
|
854
|
+
if (lineCol) {
|
|
855
|
+
uri = uri.with({
|
|
856
|
+
path: uri.path.slice(0, lineCol.index),
|
|
857
|
+
fragment: `L${lineCol[0].slice(1)}`
|
|
858
|
+
});
|
|
859
|
+
lineNumber = parseInt(lineCol[1], 10);
|
|
860
|
+
column = parseInt(lineCol[2], 10);
|
|
861
|
+
}
|
|
862
|
+
const lineMatch = LineQueryRegex.exec(uri.query);
|
|
863
|
+
if (lineMatch) {
|
|
864
|
+
const parsedLineNumber = parseInt(lineMatch[1], 10);
|
|
865
|
+
if (!isNaN(parsedLineNumber)) {
|
|
866
|
+
lineNumber = parsedLineNumber + 1;
|
|
867
|
+
column = 1;
|
|
868
|
+
uri = uri.with({ fragment: `L${lineNumber}` });
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
uri = uri.with({
|
|
872
|
+
query: null
|
|
873
|
+
});
|
|
874
|
+
let match = undefined;
|
|
875
|
+
for (const group of this.editorGroupService.groups) {
|
|
876
|
+
const editorInput = group.editors.find(editor => editor.resource && isEqual(editor.resource, uri, true));
|
|
877
|
+
if (editorInput) {
|
|
878
|
+
match = { group, editor: editorInput };
|
|
879
|
+
break;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
if (match) {
|
|
883
|
+
match.group.openEditor(match.editor, lineNumber !== undefined && column !== undefined ? { selection: { startLineNumber: lineNumber, startColumn: column } } : undefined);
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
this.openerService.open(uri, { fromUserGesture: true, fromWorkspace: true });
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
_handleHighlightCodeBlock(codeBlocks) {
|
|
890
|
+
for (const { id, value, lang } of codeBlocks) {
|
|
891
|
+
const languageId = this.languageService.getLanguageIdByLanguageName(lang);
|
|
892
|
+
if (!languageId) {
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
tokenizeToString(this.languageService, value, languageId).then((html) => {
|
|
896
|
+
if (this._disposed) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
this._sendMessageToWebview({
|
|
900
|
+
type: 'tokenizedCodeBlock',
|
|
901
|
+
html,
|
|
902
|
+
codeBlockId: id
|
|
903
|
+
});
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
async _onDidClickDataLink(event) {
|
|
908
|
+
if (typeof event.data !== 'string') {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
const [splitStart, splitData] = event.data.split(';base64,');
|
|
912
|
+
if (!splitData || !splitStart) {
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
const defaultDir = extname(this.documentUri) === '.interactive' ?
|
|
916
|
+
this.workspaceContextService.getWorkspace().folders[0]?.uri ?? (await this.fileDialogService.defaultFilePath()) :
|
|
917
|
+
dirname(this.documentUri);
|
|
918
|
+
let defaultName;
|
|
919
|
+
if (event.downloadName) {
|
|
920
|
+
defaultName = event.downloadName;
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
const mimeType = splitStart.replace(/^data:/, '');
|
|
924
|
+
const candidateExtension = mimeType && getExtensionForMimeType(mimeType);
|
|
925
|
+
defaultName = candidateExtension ? `download${candidateExtension}` : 'download';
|
|
926
|
+
}
|
|
927
|
+
const defaultUri = joinPath(defaultDir, defaultName);
|
|
928
|
+
const newFileUri = await this.fileDialogService.showSaveDialog({
|
|
929
|
+
defaultUri
|
|
930
|
+
});
|
|
931
|
+
if (!newFileUri) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const buff = decodeBase64(splitData);
|
|
935
|
+
await this.fileService.writeFile(newFileUri, buff);
|
|
936
|
+
await this.openerService.open(newFileUri);
|
|
937
|
+
}
|
|
938
|
+
_createInset(webviewService, content) {
|
|
939
|
+
this.localResourceRootsCache = this._getResourceRootsCache();
|
|
940
|
+
const webview = webviewService.createWebviewElement({
|
|
941
|
+
origin: BackLayerWebView_1.getOriginStore(this.storageService).getOrigin(this.notebookViewType, undefined),
|
|
942
|
+
title: ( nls.localizeWithPath(
|
|
943
|
+
'vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView',
|
|
944
|
+
'webview title',
|
|
945
|
+
"Notebook webview content"
|
|
946
|
+
)),
|
|
947
|
+
options: {
|
|
948
|
+
purpose: "notebookRenderer" ,
|
|
949
|
+
enableFindWidget: false,
|
|
950
|
+
transformCssVariables: transformWebviewThemeVars,
|
|
951
|
+
},
|
|
952
|
+
contentOptions: {
|
|
953
|
+
allowMultipleAPIAcquire: true,
|
|
954
|
+
allowScripts: true,
|
|
955
|
+
localResourceRoots: this.localResourceRootsCache,
|
|
956
|
+
},
|
|
957
|
+
extension: undefined,
|
|
958
|
+
providedViewType: 'notebook.output'
|
|
959
|
+
});
|
|
960
|
+
webview.setHtml(content);
|
|
961
|
+
webview.setContextKeyService(this.contextKeyService);
|
|
962
|
+
return webview;
|
|
963
|
+
}
|
|
964
|
+
_getResourceRootsCache() {
|
|
965
|
+
const workspaceFolders = ( this.contextService.getWorkspace().folders.map(x => x.uri));
|
|
966
|
+
const notebookDir = this.getNotebookBaseUri();
|
|
967
|
+
return [
|
|
968
|
+
this.notebookService.getNotebookProviderResourceRoots(),
|
|
969
|
+
( this.notebookService.getRenderers().map(x => dirname(x.entrypoint.path))),
|
|
970
|
+
...Array.from(this.notebookService.getStaticPreloads(this.notebookViewType), x => [
|
|
971
|
+
dirname(x.entrypoint),
|
|
972
|
+
...x.localResourceRoots,
|
|
973
|
+
]),
|
|
974
|
+
workspaceFolders,
|
|
975
|
+
notebookDir,
|
|
976
|
+
this.getBuiltinLocalResourceRoots()
|
|
977
|
+
].flat();
|
|
978
|
+
}
|
|
979
|
+
initializeWebViewState() {
|
|
980
|
+
this._preloadsCache.clear();
|
|
981
|
+
if (this._currentKernel) {
|
|
982
|
+
this._updatePreloadsFromKernel(this._currentKernel);
|
|
983
|
+
}
|
|
984
|
+
for (const [output, inset] of this.insetMapping.entries()) {
|
|
985
|
+
this._sendMessageToWebview({ ...inset.cachedCreation, initiallyHidden: ( this.hiddenInsetMapping.has(output)) });
|
|
986
|
+
}
|
|
987
|
+
if (this.initializeMarkupPromise?.isFirstInit) ;
|
|
988
|
+
else {
|
|
989
|
+
const mdCells = [...( this.markupPreviewMapping.values())];
|
|
990
|
+
this.markupPreviewMapping.clear();
|
|
991
|
+
this.initializeMarkup(mdCells);
|
|
992
|
+
}
|
|
993
|
+
this._updateStyles();
|
|
994
|
+
this._updateOptions();
|
|
995
|
+
}
|
|
996
|
+
shouldUpdateInset(cell, output, cellTop, outputOffset) {
|
|
997
|
+
if (this._disposed) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
if ('isOutputCollapsed' in cell && cell.isOutputCollapsed) {
|
|
1001
|
+
return false;
|
|
1002
|
+
}
|
|
1003
|
+
if (( this.hiddenInsetMapping.has(output))) {
|
|
1004
|
+
return true;
|
|
1005
|
+
}
|
|
1006
|
+
const outputCache = this.insetMapping.get(output);
|
|
1007
|
+
if (!outputCache) {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
if (outputOffset === outputCache.cachedCreation.outputOffset && cellTop === outputCache.cachedCreation.cellTop) {
|
|
1011
|
+
return false;
|
|
1012
|
+
}
|
|
1013
|
+
return true;
|
|
1014
|
+
}
|
|
1015
|
+
ackHeight(updates) {
|
|
1016
|
+
this._sendMessageToWebview({
|
|
1017
|
+
type: 'ack-dimension',
|
|
1018
|
+
updates
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
updateScrollTops(outputRequests, markupPreviews) {
|
|
1022
|
+
if (this._disposed) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const widgets = coalesce(( outputRequests.map((request) => {
|
|
1026
|
+
const outputCache = this.insetMapping.get(request.output);
|
|
1027
|
+
if (!outputCache) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
if (!request.forceDisplay && !this.shouldUpdateInset(request.cell, request.output, request.cellTop, request.outputOffset)) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
const id = outputCache.outputId;
|
|
1034
|
+
outputCache.cachedCreation.cellTop = request.cellTop;
|
|
1035
|
+
outputCache.cachedCreation.outputOffset = request.outputOffset;
|
|
1036
|
+
this.hiddenInsetMapping.delete(request.output);
|
|
1037
|
+
return {
|
|
1038
|
+
cellId: request.cell.id,
|
|
1039
|
+
outputId: id,
|
|
1040
|
+
cellTop: request.cellTop,
|
|
1041
|
+
outputOffset: request.outputOffset,
|
|
1042
|
+
forceDisplay: request.forceDisplay,
|
|
1043
|
+
};
|
|
1044
|
+
})));
|
|
1045
|
+
if (!widgets.length && !markupPreviews.length) {
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
this._sendMessageToWebview({
|
|
1049
|
+
type: 'view-scroll',
|
|
1050
|
+
widgets: widgets,
|
|
1051
|
+
markupCells: markupPreviews,
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
async createMarkupPreview(initialization) {
|
|
1055
|
+
if (this._disposed) {
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
if (( this.markupPreviewMapping.has(initialization.cellId))) {
|
|
1059
|
+
console.error('Trying to create markup preview that already exists');
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
this.markupPreviewMapping.set(initialization.cellId, initialization);
|
|
1063
|
+
this._sendMessageToWebview({
|
|
1064
|
+
type: 'createMarkupCell',
|
|
1065
|
+
cell: initialization
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
async showMarkupPreview(newContent) {
|
|
1069
|
+
if (this._disposed) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
const entry = this.markupPreviewMapping.get(newContent.cellId);
|
|
1073
|
+
if (!entry) {
|
|
1074
|
+
return this.createMarkupPreview(newContent);
|
|
1075
|
+
}
|
|
1076
|
+
const sameContent = newContent.content === entry.content;
|
|
1077
|
+
const sameMetadata = (equals(newContent.metadata, entry.metadata));
|
|
1078
|
+
if (!sameContent || !sameMetadata || !entry.visible) {
|
|
1079
|
+
this._sendMessageToWebview({
|
|
1080
|
+
type: 'showMarkupCell',
|
|
1081
|
+
id: newContent.cellId,
|
|
1082
|
+
handle: newContent.cellHandle,
|
|
1083
|
+
content: sameContent ? undefined : newContent.content,
|
|
1084
|
+
top: newContent.offset,
|
|
1085
|
+
metadata: sameMetadata ? undefined : newContent.metadata
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
entry.metadata = newContent.metadata;
|
|
1089
|
+
entry.content = newContent.content;
|
|
1090
|
+
entry.offset = newContent.offset;
|
|
1091
|
+
entry.visible = true;
|
|
1092
|
+
}
|
|
1093
|
+
async hideMarkupPreviews(cellIds) {
|
|
1094
|
+
if (this._disposed) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const cellsToHide = [];
|
|
1098
|
+
for (const cellId of cellIds) {
|
|
1099
|
+
const entry = this.markupPreviewMapping.get(cellId);
|
|
1100
|
+
if (entry) {
|
|
1101
|
+
if (entry.visible) {
|
|
1102
|
+
cellsToHide.push(cellId);
|
|
1103
|
+
entry.visible = false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (cellsToHide.length) {
|
|
1108
|
+
this._sendMessageToWebview({
|
|
1109
|
+
type: 'hideMarkupCells',
|
|
1110
|
+
ids: cellsToHide
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
async unhideMarkupPreviews(cellIds) {
|
|
1115
|
+
if (this._disposed) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const toUnhide = [];
|
|
1119
|
+
for (const cellId of cellIds) {
|
|
1120
|
+
const entry = this.markupPreviewMapping.get(cellId);
|
|
1121
|
+
if (entry) {
|
|
1122
|
+
if (!entry.visible) {
|
|
1123
|
+
entry.visible = true;
|
|
1124
|
+
toUnhide.push(cellId);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
console.error(`Trying to unhide a preview that does not exist: ${cellId}`);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
this._sendMessageToWebview({
|
|
1132
|
+
type: 'unhideMarkupCells',
|
|
1133
|
+
ids: toUnhide,
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
async deleteMarkupPreviews(cellIds) {
|
|
1137
|
+
if (this._disposed) {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
for (const id of cellIds) {
|
|
1141
|
+
if (!( this.markupPreviewMapping.has(id))) {
|
|
1142
|
+
console.error(`Trying to delete a preview that does not exist: ${id}`);
|
|
1143
|
+
}
|
|
1144
|
+
this.markupPreviewMapping.delete(id);
|
|
1145
|
+
}
|
|
1146
|
+
if (cellIds.length) {
|
|
1147
|
+
this._sendMessageToWebview({
|
|
1148
|
+
type: 'deleteMarkupCell',
|
|
1149
|
+
ids: cellIds
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
async updateMarkupPreviewSelections(selectedCellsIds) {
|
|
1154
|
+
if (this._disposed) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
this._sendMessageToWebview({
|
|
1158
|
+
type: 'updateSelectedMarkupCells',
|
|
1159
|
+
selectedCellIds: selectedCellsIds.filter(id => ( this.markupPreviewMapping.has(id))),
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
async initializeMarkup(cells) {
|
|
1163
|
+
if (this._disposed) {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
this.initializeMarkupPromise?.p.complete();
|
|
1167
|
+
const requestId = UUID.generateUuid();
|
|
1168
|
+
this.initializeMarkupPromise = { p: ( new DeferredPromise()), requestId, isFirstInit: this.firstInit };
|
|
1169
|
+
this.firstInit = false;
|
|
1170
|
+
for (const cell of cells) {
|
|
1171
|
+
this.markupPreviewMapping.set(cell.cellId, cell);
|
|
1172
|
+
}
|
|
1173
|
+
this._sendMessageToWebview({
|
|
1174
|
+
type: 'initializeMarkup',
|
|
1175
|
+
cells,
|
|
1176
|
+
requestId,
|
|
1177
|
+
});
|
|
1178
|
+
return this.initializeMarkupPromise.p.p;
|
|
1179
|
+
}
|
|
1180
|
+
_cachedInsetEqual(cachedInset, content) {
|
|
1181
|
+
if (content.type === 1 ) {
|
|
1182
|
+
return cachedInset.renderer?.id === content.renderer.id;
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
return cachedInset.cachedCreation.type === 'html';
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
requestCreateOutputWhenWebviewIdle(cellInfo, content, cellTop, offset) {
|
|
1189
|
+
if (this._disposed) {
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
if (( this.insetMapping.has(content.source))) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
if (( this.pendingWebviewIdleCreationRequest.has(content.source))) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
if (( this.pendingWebviewIdleInsetMapping.has(content.source))) {
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
this.pendingWebviewIdleCreationRequest.set(content.source, runWhenGlobalIdle(() => {
|
|
1202
|
+
const { message, renderer, transfer: transferable } = this._createOutputCreationMessage(cellInfo, content, cellTop, offset, true, true);
|
|
1203
|
+
this._sendMessageToWebview(message, transferable);
|
|
1204
|
+
this.pendingWebviewIdleInsetMapping.set(content.source, { outputId: message.outputId, versionId: content.source.model.versionId, cellInfo: cellInfo, renderer, cachedCreation: message });
|
|
1205
|
+
this.reversedPendingWebviewIdleInsetMapping.set(message.outputId, content.source);
|
|
1206
|
+
this.pendingWebviewIdleCreationRequest.delete(content.source);
|
|
1207
|
+
}));
|
|
1208
|
+
}
|
|
1209
|
+
createOutput(cellInfo, content, cellTop, offset) {
|
|
1210
|
+
if (this._disposed) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const cachedInset = this.insetMapping.get(content.source);
|
|
1214
|
+
this.pendingWebviewIdleCreationRequest.get(content.source)?.dispose();
|
|
1215
|
+
this.pendingWebviewIdleCreationRequest.delete(content.source);
|
|
1216
|
+
this.pendingWebviewIdleInsetMapping.delete(content.source);
|
|
1217
|
+
if (cachedInset) {
|
|
1218
|
+
this.reversedPendingWebviewIdleInsetMapping.delete(cachedInset.outputId);
|
|
1219
|
+
}
|
|
1220
|
+
if (cachedInset && this._cachedInsetEqual(cachedInset, content)) {
|
|
1221
|
+
this.hiddenInsetMapping.delete(content.source);
|
|
1222
|
+
this._sendMessageToWebview({
|
|
1223
|
+
type: 'showOutput',
|
|
1224
|
+
cellId: cachedInset.cellInfo.cellId,
|
|
1225
|
+
outputId: cachedInset.outputId,
|
|
1226
|
+
cellTop: cellTop,
|
|
1227
|
+
outputOffset: offset
|
|
1228
|
+
});
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
const { message, renderer, transfer: transferable } = this._createOutputCreationMessage(cellInfo, content, cellTop, offset, false, false);
|
|
1232
|
+
this._sendMessageToWebview(message, transferable);
|
|
1233
|
+
this.insetMapping.set(content.source, { outputId: message.outputId, versionId: content.source.model.versionId, cellInfo: cellInfo, renderer, cachedCreation: message });
|
|
1234
|
+
this.hiddenInsetMapping.delete(content.source);
|
|
1235
|
+
this.reversedInsetMapping.set(message.outputId, content.source);
|
|
1236
|
+
}
|
|
1237
|
+
createMetadata(output, mimeType) {
|
|
1238
|
+
if (mimeType.startsWith('image')) {
|
|
1239
|
+
const buffer = output.outputs.find(out => out.mime === 'text/plain')?.data.buffer;
|
|
1240
|
+
if (buffer?.length && buffer?.length > 0) {
|
|
1241
|
+
const altText = ( new TextDecoder()).decode(buffer);
|
|
1242
|
+
return { ...output.metadata, vscode_altText: altText };
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return output.metadata;
|
|
1246
|
+
}
|
|
1247
|
+
_createOutputCreationMessage(cellInfo, content, cellTop, offset, createOnIdle, initiallyHidden) {
|
|
1248
|
+
const messageBase = {
|
|
1249
|
+
type: 'html',
|
|
1250
|
+
executionId: cellInfo.executionId,
|
|
1251
|
+
cellId: cellInfo.cellId,
|
|
1252
|
+
cellTop: cellTop,
|
|
1253
|
+
outputOffset: offset,
|
|
1254
|
+
left: 0,
|
|
1255
|
+
requiredPreloads: [],
|
|
1256
|
+
createOnIdle: createOnIdle
|
|
1257
|
+
};
|
|
1258
|
+
const transfer = [];
|
|
1259
|
+
let message;
|
|
1260
|
+
let renderer;
|
|
1261
|
+
if (content.type === 1 ) {
|
|
1262
|
+
const output = content.source.model;
|
|
1263
|
+
renderer = content.renderer;
|
|
1264
|
+
const first = output.outputs.find(op => op.mime === content.mimeType);
|
|
1265
|
+
const metadata = this.createMetadata(output, content.mimeType);
|
|
1266
|
+
const valueBytes = copyBufferIfNeeded(first.data.buffer, transfer);
|
|
1267
|
+
message = {
|
|
1268
|
+
...messageBase,
|
|
1269
|
+
outputId: output.outputId,
|
|
1270
|
+
rendererId: content.renderer.id,
|
|
1271
|
+
content: {
|
|
1272
|
+
type: 1 ,
|
|
1273
|
+
outputId: output.outputId,
|
|
1274
|
+
metadata: metadata,
|
|
1275
|
+
output: {
|
|
1276
|
+
mime: first.mime,
|
|
1277
|
+
valueBytes,
|
|
1278
|
+
},
|
|
1279
|
+
allOutputs: ( output.outputs.map(output => ({ mime: output.mime }))),
|
|
1280
|
+
},
|
|
1281
|
+
initiallyHidden: initiallyHidden
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
message = {
|
|
1286
|
+
...messageBase,
|
|
1287
|
+
outputId: UUID.generateUuid(),
|
|
1288
|
+
content: {
|
|
1289
|
+
type: content.type,
|
|
1290
|
+
htmlContent: content.htmlContent,
|
|
1291
|
+
},
|
|
1292
|
+
initiallyHidden: initiallyHidden
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
return {
|
|
1296
|
+
message,
|
|
1297
|
+
renderer,
|
|
1298
|
+
transfer,
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
updateOutput(cellInfo, content, cellTop, offset) {
|
|
1302
|
+
if (this._disposed) {
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
if (!( this.insetMapping.has(content.source))) {
|
|
1306
|
+
this.createOutput(cellInfo, content, cellTop, offset);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const outputCache = this.insetMapping.get(content.source);
|
|
1310
|
+
if (outputCache.versionId === content.source.model.versionId) {
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
this.hiddenInsetMapping.delete(content.source);
|
|
1314
|
+
let updatedContent = undefined;
|
|
1315
|
+
const transfer = [];
|
|
1316
|
+
if (content.type === 1 ) {
|
|
1317
|
+
const output = content.source.model;
|
|
1318
|
+
const firstBuffer = output.outputs.find(op => op.mime === content.mimeType);
|
|
1319
|
+
const appenededData = output.appendedSinceVersion(outputCache.versionId, content.mimeType);
|
|
1320
|
+
const appended = appenededData ? { valueBytes: appenededData.buffer, previousVersion: outputCache.versionId } : undefined;
|
|
1321
|
+
const valueBytes = copyBufferIfNeeded(firstBuffer.data.buffer, transfer);
|
|
1322
|
+
updatedContent = {
|
|
1323
|
+
type: 1 ,
|
|
1324
|
+
outputId: outputCache.outputId,
|
|
1325
|
+
metadata: output.metadata,
|
|
1326
|
+
output: {
|
|
1327
|
+
mime: content.mimeType,
|
|
1328
|
+
valueBytes,
|
|
1329
|
+
appended: appended
|
|
1330
|
+
},
|
|
1331
|
+
allOutputs: ( output.outputs.map(output => ({ mime: output.mime })))
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
this._sendMessageToWebview({
|
|
1335
|
+
type: 'showOutput',
|
|
1336
|
+
cellId: outputCache.cellInfo.cellId,
|
|
1337
|
+
outputId: outputCache.outputId,
|
|
1338
|
+
cellTop: cellTop,
|
|
1339
|
+
outputOffset: offset,
|
|
1340
|
+
content: updatedContent
|
|
1341
|
+
}, transfer);
|
|
1342
|
+
outputCache.versionId = content.source.model.versionId;
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
async copyImage(output) {
|
|
1346
|
+
this._sendMessageToWebview({
|
|
1347
|
+
type: 'copyImage',
|
|
1348
|
+
outputId: output.model.outputId,
|
|
1349
|
+
altOutputId: output.model.alternativeOutputId
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
removeInsets(outputs) {
|
|
1353
|
+
if (this._disposed) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
for (const output of outputs) {
|
|
1357
|
+
const outputCache = this.insetMapping.get(output);
|
|
1358
|
+
if (!outputCache) {
|
|
1359
|
+
continue;
|
|
1360
|
+
}
|
|
1361
|
+
const id = outputCache.outputId;
|
|
1362
|
+
this._sendMessageToWebview({
|
|
1363
|
+
type: 'clearOutput',
|
|
1364
|
+
rendererId: outputCache.cachedCreation.rendererId,
|
|
1365
|
+
cellUri: ( outputCache.cellInfo.cellUri.toString()),
|
|
1366
|
+
outputId: id,
|
|
1367
|
+
cellId: outputCache.cellInfo.cellId
|
|
1368
|
+
});
|
|
1369
|
+
this.insetMapping.delete(output);
|
|
1370
|
+
this.pendingWebviewIdleCreationRequest.get(output)?.dispose();
|
|
1371
|
+
this.pendingWebviewIdleCreationRequest.delete(output);
|
|
1372
|
+
this.pendingWebviewIdleInsetMapping.delete(output);
|
|
1373
|
+
this.reversedPendingWebviewIdleInsetMapping.delete(id);
|
|
1374
|
+
this.reversedInsetMapping.delete(id);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
hideInset(output) {
|
|
1378
|
+
if (this._disposed) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
const outputCache = this.insetMapping.get(output);
|
|
1382
|
+
if (!outputCache) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
this.hiddenInsetMapping.add(output);
|
|
1386
|
+
this._sendMessageToWebview({
|
|
1387
|
+
type: 'hideOutput',
|
|
1388
|
+
outputId: outputCache.outputId,
|
|
1389
|
+
cellId: outputCache.cellInfo.cellId,
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
focusWebview() {
|
|
1393
|
+
if (this._disposed) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
this.webview?.focus();
|
|
1397
|
+
}
|
|
1398
|
+
focusOutput(cellOrOutputId, alternateId, viewFocused) {
|
|
1399
|
+
if (this._disposed) {
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
if (!viewFocused) {
|
|
1403
|
+
this.webview?.focus();
|
|
1404
|
+
}
|
|
1405
|
+
this._sendMessageToWebview({
|
|
1406
|
+
type: 'focus-output',
|
|
1407
|
+
cellOrOutputId: cellOrOutputId,
|
|
1408
|
+
alternateId: alternateId
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
async find(query, options) {
|
|
1412
|
+
if (query === '') {
|
|
1413
|
+
this._sendMessageToWebview({
|
|
1414
|
+
type: 'findStop',
|
|
1415
|
+
ownerID: options.ownerID
|
|
1416
|
+
});
|
|
1417
|
+
return [];
|
|
1418
|
+
}
|
|
1419
|
+
const p = ( new Promise(resolve => {
|
|
1420
|
+
const sub = this.webview?.onMessage(e => {
|
|
1421
|
+
if (e.message.type === 'didFind') {
|
|
1422
|
+
resolve(e.message.matches);
|
|
1423
|
+
sub?.dispose();
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
}));
|
|
1427
|
+
this._sendMessageToWebview({
|
|
1428
|
+
type: 'find',
|
|
1429
|
+
query: query,
|
|
1430
|
+
options
|
|
1431
|
+
});
|
|
1432
|
+
const ret = await p;
|
|
1433
|
+
return ret;
|
|
1434
|
+
}
|
|
1435
|
+
findStop(ownerID) {
|
|
1436
|
+
this._sendMessageToWebview({
|
|
1437
|
+
type: 'findStop',
|
|
1438
|
+
ownerID
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
async findHighlightCurrent(index, ownerID) {
|
|
1442
|
+
const p = ( new Promise(resolve => {
|
|
1443
|
+
const sub = this.webview?.onMessage(e => {
|
|
1444
|
+
if (e.message.type === 'didFindHighlightCurrent') {
|
|
1445
|
+
resolve(e.message.offset);
|
|
1446
|
+
sub?.dispose();
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
}));
|
|
1450
|
+
this._sendMessageToWebview({
|
|
1451
|
+
type: 'findHighlightCurrent',
|
|
1452
|
+
index,
|
|
1453
|
+
ownerID
|
|
1454
|
+
});
|
|
1455
|
+
const ret = await p;
|
|
1456
|
+
return ret;
|
|
1457
|
+
}
|
|
1458
|
+
async findUnHighlightCurrent(index, ownerID) {
|
|
1459
|
+
this._sendMessageToWebview({
|
|
1460
|
+
type: 'findUnHighlightCurrent',
|
|
1461
|
+
index,
|
|
1462
|
+
ownerID
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
deltaCellContainerClassNames(cellId, added, removed) {
|
|
1466
|
+
this._sendMessageToWebview({
|
|
1467
|
+
type: 'decorations',
|
|
1468
|
+
cellId,
|
|
1469
|
+
addedClassNames: added,
|
|
1470
|
+
removedClassNames: removed
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
updateOutputRenderers() {
|
|
1474
|
+
if (!this.webview) {
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const renderersData = this.getRendererData();
|
|
1478
|
+
this.localResourceRootsCache = this._getResourceRootsCache();
|
|
1479
|
+
const mixedResourceRoots = [
|
|
1480
|
+
...(this.localResourceRootsCache || []),
|
|
1481
|
+
...(this._currentKernel ? [this._currentKernel.localResourceRoot] : []),
|
|
1482
|
+
];
|
|
1483
|
+
this.webview.localResourcesRoot = mixedResourceRoots;
|
|
1484
|
+
this._sendMessageToWebview({
|
|
1485
|
+
type: 'updateRenderers',
|
|
1486
|
+
rendererData: renderersData
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
async updateKernelPreloads(kernel) {
|
|
1490
|
+
if (this._disposed || kernel === this._currentKernel) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
const previousKernel = this._currentKernel;
|
|
1494
|
+
this._currentKernel = kernel;
|
|
1495
|
+
if (previousKernel && previousKernel.preloadUris.length > 0) {
|
|
1496
|
+
this.webview?.reload();
|
|
1497
|
+
}
|
|
1498
|
+
else if (kernel) {
|
|
1499
|
+
this._updatePreloadsFromKernel(kernel);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
_updatePreloadsFromKernel(kernel) {
|
|
1503
|
+
const resources = [];
|
|
1504
|
+
for (const preload of kernel.preloadUris) {
|
|
1505
|
+
const uri = this.environmentService.isExtensionDevelopment && (preload.scheme === 'http' || preload.scheme === 'https')
|
|
1506
|
+
? preload : this.asWebviewUri(preload, undefined);
|
|
1507
|
+
if (!( this._preloadsCache.has(( uri.toString())))) {
|
|
1508
|
+
resources.push({ uri: ( uri.toString()), originalUri: ( preload.toString()) });
|
|
1509
|
+
this._preloadsCache.add(( uri.toString()));
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
if (!resources.length) {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
this._updatePreloads(resources);
|
|
1516
|
+
}
|
|
1517
|
+
_updatePreloads(resources) {
|
|
1518
|
+
if (!this.webview) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
const mixedResourceRoots = [
|
|
1522
|
+
...(this.localResourceRootsCache || []),
|
|
1523
|
+
...(this._currentKernel ? [this._currentKernel.localResourceRoot] : []),
|
|
1524
|
+
];
|
|
1525
|
+
this.webview.localResourcesRoot = mixedResourceRoots;
|
|
1526
|
+
this._sendMessageToWebview({
|
|
1527
|
+
type: 'preload',
|
|
1528
|
+
resources: resources,
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
_sendMessageToWebview(message, transfer) {
|
|
1532
|
+
if (this._disposed) {
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
this.webview?.postMessage(message, transfer);
|
|
1536
|
+
}
|
|
1537
|
+
dispose() {
|
|
1538
|
+
this._disposed = true;
|
|
1539
|
+
this.webview?.dispose();
|
|
1540
|
+
this.webview = undefined;
|
|
1541
|
+
this.notebookEditor = null;
|
|
1542
|
+
this.insetMapping.clear();
|
|
1543
|
+
this.pendingWebviewIdleCreationRequest.clear();
|
|
1544
|
+
super.dispose();
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
BackLayerWebView = BackLayerWebView_1 = ( __decorate([
|
|
1548
|
+
( __param(6, IWebviewService)),
|
|
1549
|
+
( __param(7, IOpenerService)),
|
|
1550
|
+
( __param(8, INotebookService)),
|
|
1551
|
+
( __param(9, IWorkspaceContextService)),
|
|
1552
|
+
( __param(10, IWorkbenchEnvironmentService)),
|
|
1553
|
+
( __param(11, IFileDialogService)),
|
|
1554
|
+
( __param(12, IFileService)),
|
|
1555
|
+
( __param(13, IContextMenuService)),
|
|
1556
|
+
( __param(14, IContextKeyService)),
|
|
1557
|
+
( __param(15, IWorkspaceTrustManagementService)),
|
|
1558
|
+
( __param(16, IConfigurationService)),
|
|
1559
|
+
( __param(17, ILanguageService)),
|
|
1560
|
+
( __param(18, IWorkspaceContextService)),
|
|
1561
|
+
( __param(19, IEditorGroupsService)),
|
|
1562
|
+
( __param(20, IStorageService)),
|
|
1563
|
+
( __param(21, IPathService)),
|
|
1564
|
+
( __param(22, INotebookLoggingService)),
|
|
1565
|
+
( __param(23, IThemeService)),
|
|
1566
|
+
( __param(24, ITelemetryService))
|
|
1567
|
+
], BackLayerWebView));
|
|
1568
|
+
function copyBufferIfNeeded(buffer, transfer) {
|
|
1569
|
+
if (buffer.byteLength === buffer.buffer.byteLength) {
|
|
1570
|
+
return buffer;
|
|
1571
|
+
}
|
|
1572
|
+
else {
|
|
1573
|
+
const valueBytes = ( new Uint8Array(buffer));
|
|
1574
|
+
transfer.push(valueBytes.buffer);
|
|
1575
|
+
return valueBytes;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
function getTokenizationCss() {
|
|
1579
|
+
const colorMap = TokenizationRegistry.getColorMap();
|
|
1580
|
+
const tokenizationCss = colorMap ? generateTokensCSSForColorMap(colorMap) : '';
|
|
1581
|
+
return tokenizationCss;
|
|
1582
|
+
}
|
|
1583
|
+
function tryDecodeURIComponent(uri) {
|
|
1584
|
+
try {
|
|
1585
|
+
return decodeURIComponent(uri);
|
|
1586
|
+
}
|
|
1587
|
+
catch {
|
|
1588
|
+
return uri;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
export { BackLayerWebView };
|