@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
|
@@ -0,0 +1,2155 @@
|
|
|
1
|
+
async function webviewPreloads(ctx) {
|
|
2
|
+
const $window = window;
|
|
3
|
+
const textEncoder = ( new TextEncoder());
|
|
4
|
+
const textDecoder = ( new TextDecoder());
|
|
5
|
+
let currentOptions = ctx.options;
|
|
6
|
+
const isWorkspaceTrusted = ctx.isWorkspaceTrusted;
|
|
7
|
+
let currentRenderOptions = ctx.renderOptions;
|
|
8
|
+
const settingChange = createEmitter();
|
|
9
|
+
const acquireVsCodeApi = globalThis.acquireVsCodeApi;
|
|
10
|
+
const vscode = acquireVsCodeApi();
|
|
11
|
+
delete globalThis.acquireVsCodeApi;
|
|
12
|
+
const tokenizationStyle = ( new CSSStyleSheet());
|
|
13
|
+
tokenizationStyle.replaceSync(ctx.style.tokenizationCss);
|
|
14
|
+
const runWhenIdle = (typeof requestIdleCallback !== 'function' || typeof cancelIdleCallback !== 'function')
|
|
15
|
+
? (runner) => {
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
if (disposed) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const end = Date.now() + 15;
|
|
21
|
+
runner(( Object.freeze({
|
|
22
|
+
didTimeout: true,
|
|
23
|
+
timeRemaining() {
|
|
24
|
+
return Math.max(0, end - Date.now());
|
|
25
|
+
}
|
|
26
|
+
})));
|
|
27
|
+
});
|
|
28
|
+
let disposed = false;
|
|
29
|
+
return {
|
|
30
|
+
dispose() {
|
|
31
|
+
if (disposed) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
disposed = true;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
: (runner, timeout) => {
|
|
39
|
+
const handle = requestIdleCallback(runner, typeof timeout === 'number' ? { timeout } : undefined);
|
|
40
|
+
let disposed = false;
|
|
41
|
+
return {
|
|
42
|
+
dispose() {
|
|
43
|
+
if (disposed) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
disposed = true;
|
|
47
|
+
cancelIdleCallback(handle);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const checkOutputInputFocus = () => {
|
|
52
|
+
const activeElement = $window.document.activeElement;
|
|
53
|
+
if (!activeElement) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') {
|
|
57
|
+
postNotebookMessage('outputInputFocus', { inputFocused: true });
|
|
58
|
+
activeElement.addEventListener('blur', () => {
|
|
59
|
+
postNotebookMessage('outputInputFocus', { inputFocused: false });
|
|
60
|
+
}, { once: true });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleInnerClick = (event) => {
|
|
64
|
+
if (!event || !event.view || !event.view.document) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let outputFocus = undefined;
|
|
68
|
+
for (const node of event.composedPath()) {
|
|
69
|
+
if (node instanceof HTMLElement && node.classList.contains('output')) {
|
|
70
|
+
outputFocus = {
|
|
71
|
+
id: node.id
|
|
72
|
+
};
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const node of event.composedPath()) {
|
|
77
|
+
if (node instanceof HTMLAnchorElement && node.href) {
|
|
78
|
+
if (node.href.startsWith('blob:')) {
|
|
79
|
+
if (outputFocus) {
|
|
80
|
+
postNotebookMessage('outputFocus', outputFocus);
|
|
81
|
+
}
|
|
82
|
+
handleBlobUrlClick(node.href, node.download);
|
|
83
|
+
}
|
|
84
|
+
else if (node.href.startsWith('data:')) {
|
|
85
|
+
if (outputFocus) {
|
|
86
|
+
postNotebookMessage('outputFocus', outputFocus);
|
|
87
|
+
}
|
|
88
|
+
handleDataUrl(node.href, node.download);
|
|
89
|
+
}
|
|
90
|
+
else if (node.getAttribute('href')?.trim().startsWith('#')) {
|
|
91
|
+
if (!node.hash) {
|
|
92
|
+
postNotebookMessage('scroll-to-reveal', { scrollTop: 0 });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const targetId = node.hash.substring(1);
|
|
96
|
+
let scrollTarget = event.view.document.getElementById(targetId);
|
|
97
|
+
if (!scrollTarget) {
|
|
98
|
+
for (const preview of event.view.document.querySelectorAll('.preview')) {
|
|
99
|
+
scrollTarget = preview.shadowRoot?.getElementById(targetId);
|
|
100
|
+
if (scrollTarget) {
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (scrollTarget) {
|
|
106
|
+
const scrollTop = scrollTarget.getBoundingClientRect().top + event.view.scrollY;
|
|
107
|
+
postNotebookMessage('scroll-to-reveal', { scrollTop });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const href = node.getAttribute('href');
|
|
113
|
+
if (href) {
|
|
114
|
+
if (href.startsWith('command:') && outputFocus) {
|
|
115
|
+
postNotebookMessage('outputFocus', outputFocus);
|
|
116
|
+
}
|
|
117
|
+
postNotebookMessage('clicked-link', { href });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
event.stopPropagation();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (outputFocus) {
|
|
126
|
+
postNotebookMessage('outputFocus', outputFocus);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const handleDataUrl = async (data, downloadName) => {
|
|
130
|
+
postNotebookMessage('clicked-data-url', {
|
|
131
|
+
data,
|
|
132
|
+
downloadName
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const handleBlobUrlClick = async (url, downloadName) => {
|
|
136
|
+
try {
|
|
137
|
+
const response = await fetch(url);
|
|
138
|
+
const blob = await response.blob();
|
|
139
|
+
const reader = ( new FileReader());
|
|
140
|
+
reader.addEventListener('load', () => {
|
|
141
|
+
handleDataUrl(reader.result, downloadName);
|
|
142
|
+
});
|
|
143
|
+
reader.readAsDataURL(blob);
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
console.error(e.message);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
$window.document.body.addEventListener('click', handleInnerClick);
|
|
150
|
+
$window.document.body.addEventListener('focusin', checkOutputInputFocus);
|
|
151
|
+
function createKernelContext() {
|
|
152
|
+
return ( Object.freeze({
|
|
153
|
+
onDidReceiveKernelMessage: onDidReceiveKernelMessage.event,
|
|
154
|
+
postKernelMessage: (data) => postNotebookMessage('customKernelMessage', { message: data }),
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
async function runKernelPreload(url) {
|
|
158
|
+
try {
|
|
159
|
+
return await activateModuleKernelPreload(url);
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
console.error(e);
|
|
163
|
+
throw e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function activateModuleKernelPreload(url) {
|
|
167
|
+
const module = await __import(url);
|
|
168
|
+
if (!module.activate) {
|
|
169
|
+
console.error(`Notebook preload '${url}' was expected to be a module but it does not export an 'activate' function`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
return module.activate(createKernelContext());
|
|
173
|
+
}
|
|
174
|
+
const dimensionUpdater = new (class {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.pending = ( new Map());
|
|
177
|
+
}
|
|
178
|
+
updateHeight(id, height, options) {
|
|
179
|
+
if (!this.pending.size) {
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
this.updateImmediately();
|
|
182
|
+
}, 0);
|
|
183
|
+
}
|
|
184
|
+
const update = this.pending.get(id);
|
|
185
|
+
if (update && update.isOutput) {
|
|
186
|
+
this.pending.set(id, {
|
|
187
|
+
id,
|
|
188
|
+
height,
|
|
189
|
+
init: update.init,
|
|
190
|
+
isOutput: update.isOutput,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
this.pending.set(id, {
|
|
195
|
+
id,
|
|
196
|
+
height,
|
|
197
|
+
...options,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
updateImmediately() {
|
|
202
|
+
if (!this.pending.size) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
postNotebookMessage('dimension', {
|
|
206
|
+
updates: Array.from(( this.pending.values()))
|
|
207
|
+
});
|
|
208
|
+
this.pending.clear();
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
const resizeObserver = new (class {
|
|
212
|
+
constructor() {
|
|
213
|
+
this._observedElements = ( new WeakMap());
|
|
214
|
+
this._observer = ( new ResizeObserver(entries => {
|
|
215
|
+
for (const entry of entries) {
|
|
216
|
+
if (!$window.document.body.contains(entry.target)) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const observedElementInfo = this._observedElements.get(entry.target);
|
|
220
|
+
if (!observedElementInfo) {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
this.postResizeMessage(observedElementInfo.cellId);
|
|
224
|
+
if (entry.target.id !== observedElementInfo.id) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (!entry.contentRect) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
if (!observedElementInfo.output) {
|
|
231
|
+
this.updateHeight(observedElementInfo, entry.target.offsetHeight);
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const newHeight = entry.contentRect.height;
|
|
235
|
+
const shouldUpdatePadding = (newHeight !== 0 && observedElementInfo.lastKnownPadding === 0) ||
|
|
236
|
+
(newHeight === 0 && observedElementInfo.lastKnownPadding !== 0);
|
|
237
|
+
if (shouldUpdatePadding) {
|
|
238
|
+
$window.requestAnimationFrame(() => {
|
|
239
|
+
if (newHeight !== 0) {
|
|
240
|
+
entry.target.style.padding = `${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodeLeftPadding}px`;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
entry.target.style.padding = `0px`;
|
|
244
|
+
}
|
|
245
|
+
this.updateHeight(observedElementInfo, entry.target.offsetHeight);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this.updateHeight(observedElementInfo, entry.target.offsetHeight);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
updateHeight(observedElementInfo, offsetHeight) {
|
|
255
|
+
if (observedElementInfo.lastKnownHeight !== offsetHeight) {
|
|
256
|
+
observedElementInfo.lastKnownHeight = offsetHeight;
|
|
257
|
+
dimensionUpdater.updateHeight(observedElementInfo.id, offsetHeight, {
|
|
258
|
+
isOutput: observedElementInfo.output
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
observe(container, id, output, cellId) {
|
|
263
|
+
if (( this._observedElements.has(container))) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
this._observedElements.set(container, { id, output, lastKnownPadding: ctx.style.outputNodePadding, lastKnownHeight: -1, cellId });
|
|
267
|
+
this._observer.observe(container);
|
|
268
|
+
}
|
|
269
|
+
postResizeMessage(cellId) {
|
|
270
|
+
clearTimeout(this._outputResizeTimer);
|
|
271
|
+
this._outputResizeTimer = setTimeout(() => {
|
|
272
|
+
postNotebookMessage('outputResized', {
|
|
273
|
+
cellId
|
|
274
|
+
});
|
|
275
|
+
}, 250);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
function scrollWillGoToParent(event) {
|
|
279
|
+
for (let node = event.target; node; node = node.parentNode) {
|
|
280
|
+
if (!(node instanceof Element) || node.id === 'container' || node.classList.contains('cell_container') || node.classList.contains('markup') || node.classList.contains('output_container')) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
if (event.deltaY < 0 && node.scrollTop > 0) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
if (event.deltaY > 0 && node.scrollTop + node.clientHeight < node.scrollHeight) {
|
|
287
|
+
if (node.scrollHeight - node.scrollTop - node.clientHeight < 2) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if ($window.getComputedStyle(node).overflowY === 'hidden' || $window.getComputedStyle(node).overflowY === 'visible') {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
const handleWheel = (event) => {
|
|
299
|
+
if (event.defaultPrevented || scrollWillGoToParent(event)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
postNotebookMessage('did-scroll-wheel', {
|
|
303
|
+
payload: {
|
|
304
|
+
deltaMode: event.deltaMode,
|
|
305
|
+
deltaX: event.deltaX,
|
|
306
|
+
deltaY: event.deltaY,
|
|
307
|
+
deltaZ: event.deltaZ,
|
|
308
|
+
wheelDelta: event.wheelDelta,
|
|
309
|
+
wheelDeltaX: event.wheelDeltaX,
|
|
310
|
+
wheelDeltaY: event.wheelDeltaY,
|
|
311
|
+
detail: event.detail,
|
|
312
|
+
shiftKey: event.shiftKey,
|
|
313
|
+
type: event.type
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
function focusFirstFocusableOrContainerInOutput(cellOrOutputId, alternateId) {
|
|
318
|
+
const cellOutputContainer = $window.document.getElementById(cellOrOutputId) ??
|
|
319
|
+
(alternateId ? $window.document.getElementById(alternateId) : undefined);
|
|
320
|
+
if (cellOutputContainer) {
|
|
321
|
+
if (cellOutputContainer.contains($window.document.activeElement)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
let focusableElement = cellOutputContainer.querySelector('[tabindex="0"], [href], button, input, option, select, textarea');
|
|
325
|
+
if (!focusableElement) {
|
|
326
|
+
focusableElement = cellOutputContainer;
|
|
327
|
+
focusableElement.tabIndex = -1;
|
|
328
|
+
}
|
|
329
|
+
focusableElement.focus();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function createFocusSink(cellId, focusNext) {
|
|
333
|
+
const element = document.createElement('div');
|
|
334
|
+
element.id = `focus-sink-${cellId}`;
|
|
335
|
+
element.tabIndex = 0;
|
|
336
|
+
element.addEventListener('focus', () => {
|
|
337
|
+
postNotebookMessage('focus-editor', {
|
|
338
|
+
cellId: cellId,
|
|
339
|
+
focusNext
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
return element;
|
|
343
|
+
}
|
|
344
|
+
function _internalHighlightRange(range, tagName = 'mark', attributes = {}) {
|
|
345
|
+
function _textNodesInRange(range) {
|
|
346
|
+
if (!range.startContainer.ownerDocument) {
|
|
347
|
+
return [];
|
|
348
|
+
}
|
|
349
|
+
if (range.startContainer.nodeType === Node.TEXT_NODE && range.startOffset > 0) {
|
|
350
|
+
const startContainer = range.startContainer;
|
|
351
|
+
const endOffset = range.endOffset;
|
|
352
|
+
const createdNode = startContainer.splitText(range.startOffset);
|
|
353
|
+
if (range.endContainer === startContainer) {
|
|
354
|
+
range.setEnd(createdNode, endOffset - range.startOffset);
|
|
355
|
+
}
|
|
356
|
+
range.setStart(createdNode, 0);
|
|
357
|
+
}
|
|
358
|
+
if (range.endContainer.nodeType === Node.TEXT_NODE
|
|
359
|
+
&& range.endOffset < range.endContainer.length) {
|
|
360
|
+
range.endContainer.splitText(range.endOffset);
|
|
361
|
+
}
|
|
362
|
+
const walker = range.startContainer.ownerDocument.createTreeWalker(range.commonAncestorContainer, NodeFilter.SHOW_TEXT, node => range.intersectsNode(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT);
|
|
363
|
+
walker.currentNode = range.startContainer;
|
|
364
|
+
const nodes = [];
|
|
365
|
+
if (walker.currentNode.nodeType === Node.TEXT_NODE) {
|
|
366
|
+
nodes.push(walker.currentNode);
|
|
367
|
+
}
|
|
368
|
+
while (walker.nextNode() && range.comparePoint(walker.currentNode, 0) !== 1) {
|
|
369
|
+
if (walker.currentNode.nodeType === Node.TEXT_NODE) {
|
|
370
|
+
nodes.push(walker.currentNode);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return nodes;
|
|
374
|
+
}
|
|
375
|
+
function wrapNodeInHighlight(node, tagName, attributes) {
|
|
376
|
+
const highlightElement = node.ownerDocument.createElement(tagName);
|
|
377
|
+
( Object.keys(attributes)).forEach(key => {
|
|
378
|
+
highlightElement.setAttribute(key, attributes[key]);
|
|
379
|
+
});
|
|
380
|
+
const tempRange = node.ownerDocument.createRange();
|
|
381
|
+
tempRange.selectNode(node);
|
|
382
|
+
tempRange.surroundContents(highlightElement);
|
|
383
|
+
return highlightElement;
|
|
384
|
+
}
|
|
385
|
+
if (range.collapsed) {
|
|
386
|
+
return {
|
|
387
|
+
remove: () => { },
|
|
388
|
+
update: () => { }
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const nodes = _textNodesInRange(range);
|
|
392
|
+
const highlightElements = [];
|
|
393
|
+
for (const nodeIdx in nodes) {
|
|
394
|
+
const highlightElement = wrapNodeInHighlight(nodes[nodeIdx], tagName, attributes);
|
|
395
|
+
highlightElements.push(highlightElement);
|
|
396
|
+
}
|
|
397
|
+
function _removeHighlight(highlightElement) {
|
|
398
|
+
if (highlightElement.childNodes.length === 1) {
|
|
399
|
+
highlightElement.parentNode?.replaceChild(highlightElement.firstChild, highlightElement);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
while (highlightElement.firstChild) {
|
|
403
|
+
highlightElement.parentNode?.insertBefore(highlightElement.firstChild, highlightElement);
|
|
404
|
+
}
|
|
405
|
+
highlightElement.remove();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function _removeHighlights() {
|
|
409
|
+
for (const highlightIdx in highlightElements) {
|
|
410
|
+
_removeHighlight(highlightElements[highlightIdx]);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function _updateHighlight(highlightElement, attributes = {}) {
|
|
414
|
+
( Object.keys(attributes)).forEach(key => {
|
|
415
|
+
highlightElement.setAttribute(key, attributes[key]);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function updateHighlights(attributes) {
|
|
419
|
+
for (const highlightIdx in highlightElements) {
|
|
420
|
+
_updateHighlight(highlightElements[highlightIdx], attributes);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
remove: _removeHighlights,
|
|
425
|
+
update: updateHighlights
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function selectRange(_range) {
|
|
429
|
+
const sel = $window.getSelection();
|
|
430
|
+
if (sel) {
|
|
431
|
+
try {
|
|
432
|
+
sel.removeAllRanges();
|
|
433
|
+
const r = document.createRange();
|
|
434
|
+
r.setStart(_range.startContainer, _range.startOffset);
|
|
435
|
+
r.setEnd(_range.endContainer, _range.endOffset);
|
|
436
|
+
sel.addRange(r);
|
|
437
|
+
}
|
|
438
|
+
catch (e) {
|
|
439
|
+
console.log(e);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
function highlightRange(range, useCustom, tagName = 'mark', attributes = {}) {
|
|
444
|
+
if (useCustom) {
|
|
445
|
+
const ret = _internalHighlightRange(range, tagName, attributes);
|
|
446
|
+
return {
|
|
447
|
+
range: range,
|
|
448
|
+
dispose: ret.remove,
|
|
449
|
+
update: (color, className) => {
|
|
450
|
+
if (className === undefined) {
|
|
451
|
+
ret.update({
|
|
452
|
+
'style': `background-color: ${color}`
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
ret.update({
|
|
457
|
+
'class': className
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
$window.document.execCommand('hiliteColor', false, matchColor);
|
|
465
|
+
const cloneRange = $window.getSelection().getRangeAt(0).cloneRange();
|
|
466
|
+
const _range = {
|
|
467
|
+
collapsed: cloneRange.collapsed,
|
|
468
|
+
commonAncestorContainer: cloneRange.commonAncestorContainer,
|
|
469
|
+
endContainer: cloneRange.endContainer,
|
|
470
|
+
endOffset: cloneRange.endOffset,
|
|
471
|
+
startContainer: cloneRange.startContainer,
|
|
472
|
+
startOffset: cloneRange.startOffset
|
|
473
|
+
};
|
|
474
|
+
return {
|
|
475
|
+
range: _range,
|
|
476
|
+
dispose: () => {
|
|
477
|
+
selectRange(_range);
|
|
478
|
+
try {
|
|
479
|
+
document.designMode = 'On';
|
|
480
|
+
$window.document.execCommand('removeFormat', false, undefined);
|
|
481
|
+
document.designMode = 'Off';
|
|
482
|
+
$window.getSelection()?.removeAllRanges();
|
|
483
|
+
}
|
|
484
|
+
catch (e) {
|
|
485
|
+
console.log(e);
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
update: (color, className) => {
|
|
489
|
+
selectRange(_range);
|
|
490
|
+
try {
|
|
491
|
+
document.designMode = 'On';
|
|
492
|
+
$window.document.execCommand('removeFormat', false, undefined);
|
|
493
|
+
$window.document.execCommand('hiliteColor', false, color);
|
|
494
|
+
document.designMode = 'Off';
|
|
495
|
+
$window.getSelection()?.removeAllRanges();
|
|
496
|
+
}
|
|
497
|
+
catch (e) {
|
|
498
|
+
console.log(e);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function createEmitter(listenerChange = () => undefined) {
|
|
505
|
+
const listeners = ( new Set());
|
|
506
|
+
return {
|
|
507
|
+
fire(data) {
|
|
508
|
+
for (const listener of [...listeners]) {
|
|
509
|
+
listener.fn.call(listener.thisArg, data);
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
event(fn, thisArg, disposables) {
|
|
513
|
+
const listenerObj = { fn, thisArg };
|
|
514
|
+
const disposable = {
|
|
515
|
+
dispose: () => {
|
|
516
|
+
listeners.delete(listenerObj);
|
|
517
|
+
listenerChange(listeners);
|
|
518
|
+
},
|
|
519
|
+
};
|
|
520
|
+
listeners.add(listenerObj);
|
|
521
|
+
listenerChange(listeners);
|
|
522
|
+
if (disposables instanceof Array) {
|
|
523
|
+
disposables.push(disposable);
|
|
524
|
+
}
|
|
525
|
+
else if (disposables) {
|
|
526
|
+
disposables.add(disposable);
|
|
527
|
+
}
|
|
528
|
+
return disposable;
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function showRenderError(errorText, outputNode, errors) {
|
|
533
|
+
outputNode.innerText = errorText;
|
|
534
|
+
const errList = document.createElement('ul');
|
|
535
|
+
for (const result of errors) {
|
|
536
|
+
console.error(result);
|
|
537
|
+
const item = document.createElement('li');
|
|
538
|
+
item.innerText = result.message;
|
|
539
|
+
errList.appendChild(item);
|
|
540
|
+
}
|
|
541
|
+
outputNode.appendChild(errList);
|
|
542
|
+
}
|
|
543
|
+
const outputItemRequests = new (class {
|
|
544
|
+
constructor() {
|
|
545
|
+
this._requestPool = 0;
|
|
546
|
+
this._requests = ( new Map());
|
|
547
|
+
}
|
|
548
|
+
getOutputItem(outputId, mime) {
|
|
549
|
+
const requestId = this._requestPool++;
|
|
550
|
+
let resolve;
|
|
551
|
+
const p = ( new Promise(r => resolve = r));
|
|
552
|
+
this._requests.set(requestId, { resolve: resolve });
|
|
553
|
+
postNotebookMessage('getOutputItem', { requestId, outputId, mime });
|
|
554
|
+
return p;
|
|
555
|
+
}
|
|
556
|
+
resolveOutputItem(requestId, output) {
|
|
557
|
+
const request = this._requests.get(requestId);
|
|
558
|
+
if (!request) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
this._requests.delete(requestId);
|
|
562
|
+
request.resolve(output);
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
let hasWarnedAboutAllOutputItemsProposal = false;
|
|
566
|
+
function createOutputItem(id, mime, metadata, valueBytes, allOutputItemData, appended) {
|
|
567
|
+
function create(id, mime, metadata, valueBytes, appended) {
|
|
568
|
+
return ( Object.freeze({
|
|
569
|
+
id,
|
|
570
|
+
mime,
|
|
571
|
+
metadata,
|
|
572
|
+
appendedText() {
|
|
573
|
+
if (appended) {
|
|
574
|
+
return textDecoder.decode(appended.valueBytes);
|
|
575
|
+
}
|
|
576
|
+
return undefined;
|
|
577
|
+
},
|
|
578
|
+
data() {
|
|
579
|
+
return valueBytes;
|
|
580
|
+
},
|
|
581
|
+
text() {
|
|
582
|
+
return textDecoder.decode(valueBytes);
|
|
583
|
+
},
|
|
584
|
+
json() {
|
|
585
|
+
return JSON.parse(this.text());
|
|
586
|
+
},
|
|
587
|
+
blob() {
|
|
588
|
+
return ( new Blob([valueBytes], { type: this.mime }));
|
|
589
|
+
},
|
|
590
|
+
get _allOutputItems() {
|
|
591
|
+
if (!hasWarnedAboutAllOutputItemsProposal) {
|
|
592
|
+
hasWarnedAboutAllOutputItemsProposal = true;
|
|
593
|
+
console.warn(`'_allOutputItems' is proposed API. DO NOT ship an extension that depends on it!`);
|
|
594
|
+
}
|
|
595
|
+
return allOutputItemList;
|
|
596
|
+
},
|
|
597
|
+
}));
|
|
598
|
+
}
|
|
599
|
+
const allOutputItemCache = ( new Map());
|
|
600
|
+
const allOutputItemList = ( Object.freeze(( allOutputItemData.map(outputItem => {
|
|
601
|
+
const mime = outputItem.mime;
|
|
602
|
+
return ( Object.freeze({
|
|
603
|
+
mime,
|
|
604
|
+
getItem() {
|
|
605
|
+
const existingTask = allOutputItemCache.get(mime);
|
|
606
|
+
if (existingTask) {
|
|
607
|
+
return existingTask;
|
|
608
|
+
}
|
|
609
|
+
const task = outputItemRequests.getOutputItem(id, mime).then(item => {
|
|
610
|
+
return item ? create(id, item.mime, metadata, item.valueBytes) : undefined;
|
|
611
|
+
});
|
|
612
|
+
allOutputItemCache.set(mime, task);
|
|
613
|
+
return task;
|
|
614
|
+
}
|
|
615
|
+
}));
|
|
616
|
+
}))));
|
|
617
|
+
const item = create(id, mime, metadata, valueBytes, appended);
|
|
618
|
+
allOutputItemCache.set(mime, Promise.resolve(item));
|
|
619
|
+
return item;
|
|
620
|
+
}
|
|
621
|
+
const onDidReceiveKernelMessage = createEmitter();
|
|
622
|
+
const ttPolicy = $window.trustedTypes?.createPolicy('notebookRenderer', {
|
|
623
|
+
createHTML: value => value,
|
|
624
|
+
createScript: value => value,
|
|
625
|
+
});
|
|
626
|
+
$window.addEventListener('wheel', handleWheel);
|
|
627
|
+
const matchColor = $window.getComputedStyle($window.document.getElementById('_defaultColorPalatte')).color;
|
|
628
|
+
const currentMatchColor = $window.getComputedStyle($window.document.getElementById('_defaultColorPalatte')).backgroundColor;
|
|
629
|
+
class JSHighlighter {
|
|
630
|
+
constructor() {
|
|
631
|
+
this._activeHighlightInfo = ( new Map());
|
|
632
|
+
}
|
|
633
|
+
addHighlights(matches, ownerID) {
|
|
634
|
+
for (let i = matches.length - 1; i >= 0; i--) {
|
|
635
|
+
const match = matches[i];
|
|
636
|
+
const ret = highlightRange(match.originalRange, true, 'mark', match.isShadow ? {
|
|
637
|
+
'style': 'background-color: ' + matchColor + ';',
|
|
638
|
+
} : {
|
|
639
|
+
'class': 'find-match'
|
|
640
|
+
});
|
|
641
|
+
match.highlightResult = ret;
|
|
642
|
+
}
|
|
643
|
+
const highlightInfo = {
|
|
644
|
+
matches,
|
|
645
|
+
currentMatchIndex: -1
|
|
646
|
+
};
|
|
647
|
+
this._activeHighlightInfo.set(ownerID, highlightInfo);
|
|
648
|
+
}
|
|
649
|
+
removeHighlights(ownerID) {
|
|
650
|
+
this._activeHighlightInfo.get(ownerID)?.matches.forEach(match => {
|
|
651
|
+
match.highlightResult?.dispose();
|
|
652
|
+
});
|
|
653
|
+
this._activeHighlightInfo.delete(ownerID);
|
|
654
|
+
}
|
|
655
|
+
highlightCurrentMatch(index, ownerID) {
|
|
656
|
+
const highlightInfo = this._activeHighlightInfo.get(ownerID);
|
|
657
|
+
if (!highlightInfo) {
|
|
658
|
+
console.error('Modified current highlight match before adding highlight list.');
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const oldMatch = highlightInfo.matches[highlightInfo.currentMatchIndex];
|
|
662
|
+
oldMatch?.highlightResult?.update(matchColor, oldMatch.isShadow ? undefined : 'find-match');
|
|
663
|
+
const match = highlightInfo.matches[index];
|
|
664
|
+
highlightInfo.currentMatchIndex = index;
|
|
665
|
+
const sel = $window.getSelection();
|
|
666
|
+
if (!!match && !!sel && match.highlightResult) {
|
|
667
|
+
let offset = 0;
|
|
668
|
+
try {
|
|
669
|
+
const outputOffset = $window.document.getElementById(match.id).getBoundingClientRect().top;
|
|
670
|
+
const tempRange = document.createRange();
|
|
671
|
+
tempRange.selectNode(match.highlightResult.range.startContainer);
|
|
672
|
+
match.highlightResult.range.startContainer.parentElement?.scrollIntoView({ behavior: 'auto', block: 'end', inline: 'nearest' });
|
|
673
|
+
const rangeOffset = tempRange.getBoundingClientRect().top;
|
|
674
|
+
tempRange.detach();
|
|
675
|
+
offset = rangeOffset - outputOffset;
|
|
676
|
+
}
|
|
677
|
+
catch (e) {
|
|
678
|
+
console.error(e);
|
|
679
|
+
}
|
|
680
|
+
match.highlightResult?.update(currentMatchColor, match.isShadow ? undefined : 'current-find-match');
|
|
681
|
+
$window.document.getSelection()?.removeAllRanges();
|
|
682
|
+
postNotebookMessage('didFindHighlightCurrent', {
|
|
683
|
+
offset
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
unHighlightCurrentMatch(index, ownerID) {
|
|
688
|
+
const highlightInfo = this._activeHighlightInfo.get(ownerID);
|
|
689
|
+
if (!highlightInfo) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const oldMatch = highlightInfo.matches[index];
|
|
693
|
+
if (oldMatch && oldMatch.highlightResult) {
|
|
694
|
+
oldMatch.highlightResult.update(matchColor, oldMatch.isShadow ? undefined : 'find-match');
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
dispose() {
|
|
698
|
+
$window.document.getSelection()?.removeAllRanges();
|
|
699
|
+
this._activeHighlightInfo.forEach(highlightInfo => {
|
|
700
|
+
highlightInfo.matches.forEach(match => {
|
|
701
|
+
match.highlightResult?.dispose();
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
class CSSHighlighter {
|
|
707
|
+
constructor() {
|
|
708
|
+
this._activeHighlightInfo = ( new Map());
|
|
709
|
+
this._matchesHighlight = ( new Highlight());
|
|
710
|
+
this._matchesHighlight.priority = 1;
|
|
711
|
+
this._currentMatchesHighlight = ( new Highlight());
|
|
712
|
+
this._currentMatchesHighlight.priority = 2;
|
|
713
|
+
CSS.highlights?.set(`find-highlight`, this._matchesHighlight);
|
|
714
|
+
CSS.highlights?.set(`current-find-highlight`, this._currentMatchesHighlight);
|
|
715
|
+
}
|
|
716
|
+
_refreshRegistry(updateMatchesHighlight = true) {
|
|
717
|
+
if (updateMatchesHighlight) {
|
|
718
|
+
this._matchesHighlight.clear();
|
|
719
|
+
}
|
|
720
|
+
this._currentMatchesHighlight.clear();
|
|
721
|
+
this._activeHighlightInfo.forEach((highlightInfo) => {
|
|
722
|
+
if (updateMatchesHighlight) {
|
|
723
|
+
for (let i = 0; i < highlightInfo.matches.length; i++) {
|
|
724
|
+
this._matchesHighlight.add(highlightInfo.matches[i].originalRange);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (highlightInfo.currentMatchIndex < highlightInfo.matches.length && highlightInfo.currentMatchIndex >= 0) {
|
|
728
|
+
this._currentMatchesHighlight.add(highlightInfo.matches[highlightInfo.currentMatchIndex].originalRange);
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
addHighlights(matches, ownerID) {
|
|
733
|
+
for (let i = 0; i < matches.length; i++) {
|
|
734
|
+
this._matchesHighlight.add(matches[i].originalRange);
|
|
735
|
+
}
|
|
736
|
+
const newEntry = {
|
|
737
|
+
matches,
|
|
738
|
+
currentMatchIndex: -1,
|
|
739
|
+
};
|
|
740
|
+
this._activeHighlightInfo.set(ownerID, newEntry);
|
|
741
|
+
}
|
|
742
|
+
highlightCurrentMatch(index, ownerID) {
|
|
743
|
+
const highlightInfo = this._activeHighlightInfo.get(ownerID);
|
|
744
|
+
if (!highlightInfo) {
|
|
745
|
+
console.error('Modified current highlight match before adding highlight list.');
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
highlightInfo.currentMatchIndex = index;
|
|
749
|
+
const match = highlightInfo.matches[index];
|
|
750
|
+
if (match) {
|
|
751
|
+
let offset = 0;
|
|
752
|
+
try {
|
|
753
|
+
const outputOffset = $window.document.getElementById(match.id).getBoundingClientRect().top;
|
|
754
|
+
match.originalRange.startContainer.parentElement?.scrollIntoView({ behavior: 'auto', block: 'end', inline: 'nearest' });
|
|
755
|
+
const rangeOffset = match.originalRange.getBoundingClientRect().top;
|
|
756
|
+
offset = rangeOffset - outputOffset;
|
|
757
|
+
postNotebookMessage('didFindHighlightCurrent', {
|
|
758
|
+
offset
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
catch (e) {
|
|
762
|
+
console.error(e);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
this._refreshRegistry(false);
|
|
766
|
+
}
|
|
767
|
+
unHighlightCurrentMatch(index, ownerID) {
|
|
768
|
+
const highlightInfo = this._activeHighlightInfo.get(ownerID);
|
|
769
|
+
if (!highlightInfo) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
highlightInfo.currentMatchIndex = -1;
|
|
773
|
+
}
|
|
774
|
+
removeHighlights(ownerID) {
|
|
775
|
+
this._activeHighlightInfo.delete(ownerID);
|
|
776
|
+
this._refreshRegistry();
|
|
777
|
+
}
|
|
778
|
+
dispose() {
|
|
779
|
+
$window.document.getSelection()?.removeAllRanges();
|
|
780
|
+
this._currentMatchesHighlight.clear();
|
|
781
|
+
this._matchesHighlight.clear();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
const _highlighter = (CSS.highlights) ? ( new CSSHighlighter()) : ( new JSHighlighter());
|
|
785
|
+
function extractSelectionLine(selection) {
|
|
786
|
+
const range = selection.getRangeAt(0);
|
|
787
|
+
const oldRange = range.cloneRange();
|
|
788
|
+
const captureLength = ( selection.toString()).length;
|
|
789
|
+
selection.collapseToStart();
|
|
790
|
+
selection.modify('move', 'backward', 'lineboundary');
|
|
791
|
+
selection.modify('extend', 'forward', 'lineboundary');
|
|
792
|
+
const line = ( selection.toString());
|
|
793
|
+
const rangeStart = getStartOffset(selection.getRangeAt(0), oldRange);
|
|
794
|
+
const lineRange = {
|
|
795
|
+
start: rangeStart,
|
|
796
|
+
end: rangeStart + captureLength,
|
|
797
|
+
};
|
|
798
|
+
selection.removeAllRanges();
|
|
799
|
+
selection.addRange(oldRange);
|
|
800
|
+
return { line, range: lineRange };
|
|
801
|
+
}
|
|
802
|
+
function getStartOffset(lineRange, originalRange) {
|
|
803
|
+
const firstCommonAncestor = findFirstCommonAncestor(lineRange.startContainer, originalRange.startContainer);
|
|
804
|
+
const selectionOffset = getSelectionOffsetRelativeTo(firstCommonAncestor, lineRange.startContainer) + lineRange.startOffset;
|
|
805
|
+
const textOffset = getSelectionOffsetRelativeTo(firstCommonAncestor, originalRange.startContainer) + originalRange.startOffset;
|
|
806
|
+
return textOffset - selectionOffset;
|
|
807
|
+
}
|
|
808
|
+
function findFirstCommonAncestor(nodeA, nodeB) {
|
|
809
|
+
const range = ( new Range());
|
|
810
|
+
range.setStart(nodeA, 0);
|
|
811
|
+
range.setEnd(nodeB, 0);
|
|
812
|
+
return range.commonAncestorContainer;
|
|
813
|
+
}
|
|
814
|
+
function getTextContentLength(node) {
|
|
815
|
+
let length = 0;
|
|
816
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
817
|
+
length += node.textContent?.length || 0;
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
for (const childNode of node.childNodes) {
|
|
821
|
+
length += getTextContentLength(childNode);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return length;
|
|
825
|
+
}
|
|
826
|
+
function getSelectionOffsetRelativeTo(parentElement, currentNode) {
|
|
827
|
+
if (!currentNode) {
|
|
828
|
+
return 0;
|
|
829
|
+
}
|
|
830
|
+
let offset = 0;
|
|
831
|
+
if (currentNode === parentElement || !parentElement.contains(currentNode)) {
|
|
832
|
+
return offset;
|
|
833
|
+
}
|
|
834
|
+
let prevSibling = currentNode.previousSibling;
|
|
835
|
+
while (prevSibling) {
|
|
836
|
+
offset += getTextContentLength(prevSibling);
|
|
837
|
+
prevSibling = prevSibling.previousSibling;
|
|
838
|
+
}
|
|
839
|
+
return offset + getSelectionOffsetRelativeTo(parentElement, currentNode.parentNode);
|
|
840
|
+
}
|
|
841
|
+
const find = (query, options) => {
|
|
842
|
+
let find = true;
|
|
843
|
+
const matches = [];
|
|
844
|
+
const range = document.createRange();
|
|
845
|
+
range.selectNodeContents($window.document.getElementById('findStart'));
|
|
846
|
+
const sel = $window.getSelection();
|
|
847
|
+
sel?.removeAllRanges();
|
|
848
|
+
sel?.addRange(range);
|
|
849
|
+
viewModel.toggleDragDropEnabled(false);
|
|
850
|
+
try {
|
|
851
|
+
document.designMode = 'On';
|
|
852
|
+
while (find && matches.length < 500) {
|
|
853
|
+
find = $window.find(query, !!options.caseSensitive,
|
|
854
|
+
false,
|
|
855
|
+
false,
|
|
856
|
+
!!options.wholeWord,
|
|
857
|
+
true, false);
|
|
858
|
+
if (find) {
|
|
859
|
+
const selection = $window.getSelection();
|
|
860
|
+
if (!selection) {
|
|
861
|
+
console.log('no selection');
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
if (options.includeMarkup && selection.rangeCount > 0 && selection.getRangeAt(0).startContainer.nodeType === 1
|
|
865
|
+
&& selection.getRangeAt(0).startContainer.classList.contains('markup')) {
|
|
866
|
+
const preview = selection.anchorNode?.firstChild;
|
|
867
|
+
const root = preview.shadowRoot;
|
|
868
|
+
const shadowSelection = root?.getSelection ? root?.getSelection() : null;
|
|
869
|
+
if (shadowSelection && shadowSelection.anchorNode) {
|
|
870
|
+
matches.push({
|
|
871
|
+
type: 'preview',
|
|
872
|
+
id: preview.id,
|
|
873
|
+
cellId: preview.id,
|
|
874
|
+
container: preview,
|
|
875
|
+
isShadow: true,
|
|
876
|
+
originalRange: shadowSelection.getRangeAt(0),
|
|
877
|
+
searchPreviewInfo: options.shouldGetSearchPreviewInfo ? extractSelectionLine(shadowSelection) : undefined,
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
if (options.includeOutput && selection.rangeCount > 0 && selection.getRangeAt(0).startContainer.nodeType === 1
|
|
882
|
+
&& selection.getRangeAt(0).startContainer.classList.contains('output_container')) {
|
|
883
|
+
const cellId = selection.getRangeAt(0).startContainer.parentElement.id;
|
|
884
|
+
const outputNode = selection.anchorNode?.firstChild;
|
|
885
|
+
const root = outputNode.shadowRoot;
|
|
886
|
+
const shadowSelection = root?.getSelection ? root?.getSelection() : null;
|
|
887
|
+
if (shadowSelection && shadowSelection.anchorNode) {
|
|
888
|
+
matches.push({
|
|
889
|
+
type: 'output',
|
|
890
|
+
id: outputNode.id,
|
|
891
|
+
cellId: cellId,
|
|
892
|
+
container: outputNode,
|
|
893
|
+
isShadow: true,
|
|
894
|
+
originalRange: shadowSelection.getRangeAt(0),
|
|
895
|
+
searchPreviewInfo: options.shouldGetSearchPreviewInfo ? extractSelectionLine(shadowSelection) : undefined,
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const anchorNode = selection.anchorNode?.parentElement;
|
|
900
|
+
if (anchorNode) {
|
|
901
|
+
const lastEl = matches.length ? matches[matches.length - 1] : null;
|
|
902
|
+
if (lastEl && lastEl.container.contains(anchorNode) && options.includeOutput) {
|
|
903
|
+
matches.push({
|
|
904
|
+
type: lastEl.type,
|
|
905
|
+
id: lastEl.id,
|
|
906
|
+
cellId: lastEl.cellId,
|
|
907
|
+
container: lastEl.container,
|
|
908
|
+
isShadow: false,
|
|
909
|
+
originalRange: selection.getRangeAt(0),
|
|
910
|
+
searchPreviewInfo: options.shouldGetSearchPreviewInfo ? extractSelectionLine(selection) : undefined,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
for (let node = anchorNode; node; node = node.parentElement) {
|
|
915
|
+
if (!(node instanceof Element)) {
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
if (node.classList.contains('output') && options.includeOutput) {
|
|
919
|
+
const cellId = node.parentElement?.parentElement?.id;
|
|
920
|
+
if (cellId) {
|
|
921
|
+
matches.push({
|
|
922
|
+
type: 'output',
|
|
923
|
+
id: node.id,
|
|
924
|
+
cellId: cellId,
|
|
925
|
+
container: node,
|
|
926
|
+
isShadow: false,
|
|
927
|
+
originalRange: selection.getRangeAt(0),
|
|
928
|
+
searchPreviewInfo: options.shouldGetSearchPreviewInfo ? extractSelectionLine(selection) : undefined,
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
if (node.id === 'container' || node === $window.document.body) {
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
catch (e) {
|
|
946
|
+
console.log(e);
|
|
947
|
+
}
|
|
948
|
+
_highlighter.addHighlights(matches, options.ownerID);
|
|
949
|
+
$window.document.getSelection()?.removeAllRanges();
|
|
950
|
+
viewModel.toggleDragDropEnabled(currentOptions.dragAndDropEnabled);
|
|
951
|
+
document.designMode = 'Off';
|
|
952
|
+
postNotebookMessage('didFind', {
|
|
953
|
+
matches: ( matches.map((match, index) => ({
|
|
954
|
+
type: match.type,
|
|
955
|
+
id: match.id,
|
|
956
|
+
cellId: match.cellId,
|
|
957
|
+
index,
|
|
958
|
+
searchPreviewInfo: match.searchPreviewInfo,
|
|
959
|
+
})))
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
const copyOutputImage = async (outputId, altOutputId, retries = 5) => {
|
|
963
|
+
if (!$window.document.hasFocus() && retries > 0) {
|
|
964
|
+
setTimeout(() => { copyOutputImage(outputId, altOutputId, retries - 1); }, 20);
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
const image = $window.document.getElementById(outputId)?.querySelector('img')
|
|
969
|
+
?? $window.document.getElementById(altOutputId)?.querySelector('img');
|
|
970
|
+
if (image) {
|
|
971
|
+
await navigator.clipboard.write([( new ClipboardItem({
|
|
972
|
+
'image/png': ( new Promise((resolve) => {
|
|
973
|
+
const canvas = document.createElement('canvas');
|
|
974
|
+
if (canvas !== null) {
|
|
975
|
+
canvas.width = image.naturalWidth;
|
|
976
|
+
canvas.height = image.naturalHeight;
|
|
977
|
+
const context = canvas.getContext('2d');
|
|
978
|
+
context?.drawImage(image, 0, 0);
|
|
979
|
+
}
|
|
980
|
+
canvas.toBlob((blob) => {
|
|
981
|
+
if (blob) {
|
|
982
|
+
resolve(blob);
|
|
983
|
+
}
|
|
984
|
+
canvas.remove();
|
|
985
|
+
}, 'image/png');
|
|
986
|
+
}))
|
|
987
|
+
}))]);
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
console.error('Could not find image element to copy for output with id', outputId);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
catch (e) {
|
|
994
|
+
console.error('Could not copy image:', e);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
$window.addEventListener('message', async (rawEvent) => {
|
|
998
|
+
const event = rawEvent;
|
|
999
|
+
switch (event.data.type) {
|
|
1000
|
+
case 'initializeMarkup': {
|
|
1001
|
+
try {
|
|
1002
|
+
await Promise.all(( event.data.cells.map(info => viewModel.ensureMarkupCell(info))));
|
|
1003
|
+
}
|
|
1004
|
+
finally {
|
|
1005
|
+
dimensionUpdater.updateImmediately();
|
|
1006
|
+
postNotebookMessage('initializedMarkup', { requestId: event.data.requestId });
|
|
1007
|
+
}
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case 'createMarkupCell':
|
|
1011
|
+
viewModel.ensureMarkupCell(event.data.cell);
|
|
1012
|
+
break;
|
|
1013
|
+
case 'showMarkupCell':
|
|
1014
|
+
viewModel.showMarkupCell(event.data.id, event.data.top, event.data.content, event.data.metadata);
|
|
1015
|
+
break;
|
|
1016
|
+
case 'hideMarkupCells':
|
|
1017
|
+
for (const id of event.data.ids) {
|
|
1018
|
+
viewModel.hideMarkupCell(id);
|
|
1019
|
+
}
|
|
1020
|
+
break;
|
|
1021
|
+
case 'unhideMarkupCells':
|
|
1022
|
+
for (const id of event.data.ids) {
|
|
1023
|
+
viewModel.unhideMarkupCell(id);
|
|
1024
|
+
}
|
|
1025
|
+
break;
|
|
1026
|
+
case 'deleteMarkupCell':
|
|
1027
|
+
for (const id of event.data.ids) {
|
|
1028
|
+
viewModel.deleteMarkupCell(id);
|
|
1029
|
+
}
|
|
1030
|
+
break;
|
|
1031
|
+
case 'updateSelectedMarkupCells':
|
|
1032
|
+
viewModel.updateSelectedCells(event.data.selectedCellIds);
|
|
1033
|
+
break;
|
|
1034
|
+
case 'html': {
|
|
1035
|
+
const data = event.data;
|
|
1036
|
+
if (data.createOnIdle) {
|
|
1037
|
+
outputRunner.enqueueIdle(data.outputId, signal => {
|
|
1038
|
+
return viewModel.renderOutputCell(data, signal);
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
else {
|
|
1042
|
+
outputRunner.enqueue(data.outputId, signal => {
|
|
1043
|
+
return viewModel.renderOutputCell(data, signal);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
1048
|
+
case 'view-scroll':
|
|
1049
|
+
{
|
|
1050
|
+
event.data.widgets.forEach(widget => {
|
|
1051
|
+
outputRunner.enqueue(widget.outputId, () => {
|
|
1052
|
+
viewModel.updateOutputsScroll([widget]);
|
|
1053
|
+
});
|
|
1054
|
+
});
|
|
1055
|
+
viewModel.updateMarkupScrolls(event.data.markupCells);
|
|
1056
|
+
break;
|
|
1057
|
+
}
|
|
1058
|
+
case 'clear':
|
|
1059
|
+
renderers.clearAll();
|
|
1060
|
+
viewModel.clearAll();
|
|
1061
|
+
$window.document.getElementById('container').innerText = '';
|
|
1062
|
+
break;
|
|
1063
|
+
case 'clearOutput': {
|
|
1064
|
+
const { cellId, rendererId, outputId } = event.data;
|
|
1065
|
+
outputRunner.cancelOutput(outputId);
|
|
1066
|
+
viewModel.clearOutput(cellId, outputId, rendererId);
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
1069
|
+
case 'hideOutput': {
|
|
1070
|
+
const { cellId, outputId } = event.data;
|
|
1071
|
+
outputRunner.enqueue(outputId, () => {
|
|
1072
|
+
viewModel.hideOutput(cellId);
|
|
1073
|
+
});
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
case 'showOutput': {
|
|
1077
|
+
const { outputId, cellTop, cellId, content } = event.data;
|
|
1078
|
+
outputRunner.enqueue(outputId, () => {
|
|
1079
|
+
viewModel.showOutput(cellId, outputId, cellTop);
|
|
1080
|
+
if (content) {
|
|
1081
|
+
viewModel.updateAndRerender(cellId, outputId, content);
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
case 'copyImage': {
|
|
1087
|
+
await copyOutputImage(event.data.outputId, event.data.altOutputId);
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
case 'ack-dimension': {
|
|
1091
|
+
for (const { cellId, outputId, height } of event.data.updates) {
|
|
1092
|
+
viewModel.updateOutputHeight(cellId, outputId, height);
|
|
1093
|
+
}
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
case 'preload': {
|
|
1097
|
+
const resources = event.data.resources;
|
|
1098
|
+
for (const { uri } of resources) {
|
|
1099
|
+
kernelPreloads.load(uri);
|
|
1100
|
+
}
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
case 'updateRenderers': {
|
|
1104
|
+
const { rendererData } = event.data;
|
|
1105
|
+
renderers.updateRendererData(rendererData);
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case 'focus-output':
|
|
1109
|
+
focusFirstFocusableOrContainerInOutput(event.data.cellOrOutputId, event.data.alternateId);
|
|
1110
|
+
break;
|
|
1111
|
+
case 'decorations': {
|
|
1112
|
+
let outputContainer = $window.document.getElementById(event.data.cellId);
|
|
1113
|
+
if (!outputContainer) {
|
|
1114
|
+
viewModel.ensureOutputCell(event.data.cellId, -100000, true);
|
|
1115
|
+
outputContainer = $window.document.getElementById(event.data.cellId);
|
|
1116
|
+
}
|
|
1117
|
+
outputContainer?.classList.add(...event.data.addedClassNames);
|
|
1118
|
+
outputContainer?.classList.remove(...event.data.removedClassNames);
|
|
1119
|
+
break;
|
|
1120
|
+
}
|
|
1121
|
+
case 'customKernelMessage':
|
|
1122
|
+
onDidReceiveKernelMessage.fire(event.data.message);
|
|
1123
|
+
break;
|
|
1124
|
+
case 'customRendererMessage':
|
|
1125
|
+
renderers.getRenderer(event.data.rendererId)?.receiveMessage(event.data.message);
|
|
1126
|
+
break;
|
|
1127
|
+
case 'notebookStyles': {
|
|
1128
|
+
const documentStyle = $window.document.documentElement.style;
|
|
1129
|
+
for (let i = documentStyle.length - 1; i >= 0; i--) {
|
|
1130
|
+
const property = documentStyle[i];
|
|
1131
|
+
if (property && property.startsWith('--notebook-')) {
|
|
1132
|
+
documentStyle.removeProperty(property);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
for (const [name, value] of Object.entries(event.data.styles)) {
|
|
1136
|
+
documentStyle.setProperty(`--${name}`, value);
|
|
1137
|
+
}
|
|
1138
|
+
break;
|
|
1139
|
+
}
|
|
1140
|
+
case 'notebookOptions':
|
|
1141
|
+
currentOptions = event.data.options;
|
|
1142
|
+
viewModel.toggleDragDropEnabled(currentOptions.dragAndDropEnabled);
|
|
1143
|
+
currentRenderOptions = event.data.renderOptions;
|
|
1144
|
+
settingChange.fire(currentRenderOptions);
|
|
1145
|
+
break;
|
|
1146
|
+
case 'tokenizedCodeBlock': {
|
|
1147
|
+
const { codeBlockId, html } = event.data;
|
|
1148
|
+
MarkdownCodeBlock.highlightCodeBlock(codeBlockId, html);
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
case 'tokenizedStylesChanged': {
|
|
1152
|
+
tokenizationStyle.replaceSync(event.data.css);
|
|
1153
|
+
break;
|
|
1154
|
+
}
|
|
1155
|
+
case 'find': {
|
|
1156
|
+
_highlighter.removeHighlights(event.data.options.ownerID);
|
|
1157
|
+
find(event.data.query, event.data.options);
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
case 'findHighlightCurrent': {
|
|
1161
|
+
_highlighter?.highlightCurrentMatch(event.data.index, event.data.ownerID);
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
case 'findUnHighlightCurrent': {
|
|
1165
|
+
_highlighter?.unHighlightCurrentMatch(event.data.index, event.data.ownerID);
|
|
1166
|
+
break;
|
|
1167
|
+
}
|
|
1168
|
+
case 'findStop': {
|
|
1169
|
+
_highlighter.removeHighlights(event.data.ownerID);
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
case 'returnOutputItem': {
|
|
1173
|
+
outputItemRequests.resolveOutputItem(event.data.requestId, event.data.output);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
const renderFallbackErrorName = 'vscode.fallbackToNextRenderer';
|
|
1178
|
+
class Renderer {
|
|
1179
|
+
constructor(data) {
|
|
1180
|
+
this.data = data;
|
|
1181
|
+
this._onMessageEvent = createEmitter();
|
|
1182
|
+
}
|
|
1183
|
+
receiveMessage(message) {
|
|
1184
|
+
this._onMessageEvent.fire(message);
|
|
1185
|
+
}
|
|
1186
|
+
async renderOutputItem(item, element, signal) {
|
|
1187
|
+
try {
|
|
1188
|
+
await this.load();
|
|
1189
|
+
}
|
|
1190
|
+
catch (e) {
|
|
1191
|
+
if (!signal.aborted) {
|
|
1192
|
+
showRenderError(`Error loading renderer '${this.data.id}'`, element, e instanceof Error ? [e] : []);
|
|
1193
|
+
}
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (!this._api) {
|
|
1197
|
+
if (!signal.aborted) {
|
|
1198
|
+
showRenderError(`Renderer '${this.data.id}' does not implement renderOutputItem`, element, []);
|
|
1199
|
+
}
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
try {
|
|
1203
|
+
const renderStart = performance.now();
|
|
1204
|
+
await this._api.renderOutputItem(item, element, signal);
|
|
1205
|
+
this.postDebugMessage('Rendered output item', { id: item.id, duration: `${performance.now() - renderStart}ms` });
|
|
1206
|
+
}
|
|
1207
|
+
catch (e) {
|
|
1208
|
+
if (signal.aborted) {
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (e instanceof Error && e.name === renderFallbackErrorName) {
|
|
1212
|
+
throw e;
|
|
1213
|
+
}
|
|
1214
|
+
showRenderError(`Error rendering output item using '${this.data.id}'`, element, e instanceof Error ? [e] : []);
|
|
1215
|
+
this.postDebugMessage('Rendering output item failed', { id: item.id, error: e + '' });
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
disposeOutputItem(id) {
|
|
1219
|
+
this._api?.disposeOutputItem?.(id);
|
|
1220
|
+
}
|
|
1221
|
+
createRendererContext() {
|
|
1222
|
+
const { id, messaging } = this.data;
|
|
1223
|
+
const context = {
|
|
1224
|
+
setState: newState => vscode.setState({ ...vscode.getState(), [id]: newState }),
|
|
1225
|
+
getState: () => {
|
|
1226
|
+
const state = vscode.getState();
|
|
1227
|
+
return typeof state === 'object' && state ? state[id] : undefined;
|
|
1228
|
+
},
|
|
1229
|
+
getRenderer: async (id) => {
|
|
1230
|
+
const renderer = renderers.getRenderer(id);
|
|
1231
|
+
if (!renderer) {
|
|
1232
|
+
return undefined;
|
|
1233
|
+
}
|
|
1234
|
+
if (renderer._api) {
|
|
1235
|
+
return renderer._api;
|
|
1236
|
+
}
|
|
1237
|
+
return renderer.load();
|
|
1238
|
+
},
|
|
1239
|
+
workspace: {
|
|
1240
|
+
get isTrusted() { return isWorkspaceTrusted; }
|
|
1241
|
+
},
|
|
1242
|
+
settings: {
|
|
1243
|
+
get lineLimit() { return currentRenderOptions.lineLimit; },
|
|
1244
|
+
get outputScrolling() { return currentRenderOptions.outputScrolling; },
|
|
1245
|
+
get outputWordWrap() { return currentRenderOptions.outputWordWrap; },
|
|
1246
|
+
},
|
|
1247
|
+
get onDidChangeSettings() { return settingChange.event; }
|
|
1248
|
+
};
|
|
1249
|
+
if (messaging) {
|
|
1250
|
+
context.onDidReceiveMessage = this._onMessageEvent.event;
|
|
1251
|
+
context.postMessage = message => postNotebookMessage('customRendererMessage', { rendererId: id, message });
|
|
1252
|
+
}
|
|
1253
|
+
return ( Object.freeze(context));
|
|
1254
|
+
}
|
|
1255
|
+
load() {
|
|
1256
|
+
this._loadPromise ??= this._load();
|
|
1257
|
+
return this._loadPromise;
|
|
1258
|
+
}
|
|
1259
|
+
async _load() {
|
|
1260
|
+
this.postDebugMessage('Start loading renderer');
|
|
1261
|
+
try {
|
|
1262
|
+
await kernelPreloads.waitForAllCurrent();
|
|
1263
|
+
const importStart = performance.now();
|
|
1264
|
+
const module = await __import(this.data.entrypoint.path);
|
|
1265
|
+
this.postDebugMessage('Imported renderer', { duration: `${performance.now() - importStart}ms` });
|
|
1266
|
+
if (!module) {
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
this._api = await module.activate(this.createRendererContext());
|
|
1270
|
+
this.postDebugMessage('Activated renderer', { duration: `${performance.now() - importStart}ms` });
|
|
1271
|
+
const dependantRenderers = ctx.rendererData
|
|
1272
|
+
.filter(d => d.entrypoint.extends === this.data.id);
|
|
1273
|
+
if (dependantRenderers.length) {
|
|
1274
|
+
this.postDebugMessage('Activating dependant renderers', { dependents: ( dependantRenderers.map(x => x.id)).join(', ') });
|
|
1275
|
+
}
|
|
1276
|
+
await Promise.all(( dependantRenderers.map(async (d) => {
|
|
1277
|
+
const renderer = renderers.getRenderer(d.id);
|
|
1278
|
+
if (!renderer) {
|
|
1279
|
+
throw new Error(`Could not find extending renderer: ${d.id}`);
|
|
1280
|
+
}
|
|
1281
|
+
try {
|
|
1282
|
+
return await renderer.load();
|
|
1283
|
+
}
|
|
1284
|
+
catch (e) {
|
|
1285
|
+
console.error(e);
|
|
1286
|
+
this.postDebugMessage('Activating dependant renderer failed', { dependent: d.id, error: e + '' });
|
|
1287
|
+
return undefined;
|
|
1288
|
+
}
|
|
1289
|
+
})));
|
|
1290
|
+
return this._api;
|
|
1291
|
+
}
|
|
1292
|
+
catch (e) {
|
|
1293
|
+
this.postDebugMessage('Loading renderer failed');
|
|
1294
|
+
throw e;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
postDebugMessage(msg, data) {
|
|
1298
|
+
postNotebookMessage('logRendererDebugMessage', {
|
|
1299
|
+
message: `[renderer ${this.data.id}] - ${msg}`,
|
|
1300
|
+
data
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const kernelPreloads = new (class {
|
|
1305
|
+
constructor() {
|
|
1306
|
+
this.preloads = ( new Map());
|
|
1307
|
+
}
|
|
1308
|
+
waitFor(uri) {
|
|
1309
|
+
return this.preloads.get(uri) || Promise.resolve(( new Error(`Preload not ready: ${uri}`)));
|
|
1310
|
+
}
|
|
1311
|
+
load(uri) {
|
|
1312
|
+
const promise = Promise.all([
|
|
1313
|
+
runKernelPreload(uri),
|
|
1314
|
+
this.waitForAllCurrent(),
|
|
1315
|
+
]);
|
|
1316
|
+
this.preloads.set(uri, promise);
|
|
1317
|
+
return promise;
|
|
1318
|
+
}
|
|
1319
|
+
waitForAllCurrent() {
|
|
1320
|
+
return Promise.all(( [...( this.preloads.values())].map(p => p.catch(err => err))));
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
const outputRunner = new (class {
|
|
1324
|
+
constructor() {
|
|
1325
|
+
this.outputs = ( new Map());
|
|
1326
|
+
this.pendingOutputCreationRequest = ( new Map());
|
|
1327
|
+
}
|
|
1328
|
+
enqueue(outputId, action) {
|
|
1329
|
+
this.pendingOutputCreationRequest.get(outputId)?.dispose();
|
|
1330
|
+
this.pendingOutputCreationRequest.delete(outputId);
|
|
1331
|
+
const record = this.outputs.get(outputId);
|
|
1332
|
+
if (!record) {
|
|
1333
|
+
const controller = ( new AbortController());
|
|
1334
|
+
this.outputs.set(outputId, { abort: controller, queue: ( new Promise(r => r(action(controller.signal)))) });
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
record.queue = record.queue.then(async (r) => {
|
|
1338
|
+
if (!record.abort.signal.aborted) {
|
|
1339
|
+
await action(record.abort.signal);
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
enqueueIdle(outputId, action) {
|
|
1345
|
+
this.pendingOutputCreationRequest.get(outputId)?.dispose();
|
|
1346
|
+
outputRunner.pendingOutputCreationRequest.set(outputId, runWhenIdle(() => {
|
|
1347
|
+
outputRunner.enqueue(outputId, action);
|
|
1348
|
+
outputRunner.pendingOutputCreationRequest.delete(outputId);
|
|
1349
|
+
}));
|
|
1350
|
+
}
|
|
1351
|
+
cancelAll() {
|
|
1352
|
+
this.pendingOutputCreationRequest.forEach(r => r.dispose());
|
|
1353
|
+
this.pendingOutputCreationRequest.clear();
|
|
1354
|
+
for (const { abort } of ( this.outputs.values())) {
|
|
1355
|
+
abort.abort();
|
|
1356
|
+
}
|
|
1357
|
+
this.outputs.clear();
|
|
1358
|
+
}
|
|
1359
|
+
cancelOutput(outputId) {
|
|
1360
|
+
this.pendingOutputCreationRequest.get(outputId)?.dispose();
|
|
1361
|
+
this.pendingOutputCreationRequest.delete(outputId);
|
|
1362
|
+
const output = this.outputs.get(outputId);
|
|
1363
|
+
if (output) {
|
|
1364
|
+
output.abort.abort();
|
|
1365
|
+
this.outputs.delete(outputId);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
const renderers = new (class {
|
|
1370
|
+
constructor() {
|
|
1371
|
+
this._renderers = ( new Map());
|
|
1372
|
+
for (const renderer of ctx.rendererData) {
|
|
1373
|
+
this.addRenderer(renderer);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
getRenderer(id) {
|
|
1377
|
+
return this._renderers.get(id);
|
|
1378
|
+
}
|
|
1379
|
+
rendererEqual(a, b) {
|
|
1380
|
+
if (a.id !== b.id || a.entrypoint.path !== b.entrypoint.path || a.entrypoint.extends !== b.entrypoint.extends || a.messaging !== b.messaging) {
|
|
1381
|
+
return false;
|
|
1382
|
+
}
|
|
1383
|
+
if (a.mimeTypes.length !== b.mimeTypes.length) {
|
|
1384
|
+
return false;
|
|
1385
|
+
}
|
|
1386
|
+
for (let i = 0; i < a.mimeTypes.length; i++) {
|
|
1387
|
+
if (a.mimeTypes[i] !== b.mimeTypes[i]) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
return true;
|
|
1392
|
+
}
|
|
1393
|
+
updateRendererData(rendererData) {
|
|
1394
|
+
const oldKeys = ( new Set(( this._renderers.keys())));
|
|
1395
|
+
const newKeys = ( new Set(( rendererData.map(d => d.id))));
|
|
1396
|
+
for (const renderer of rendererData) {
|
|
1397
|
+
const existing = this._renderers.get(renderer.id);
|
|
1398
|
+
if (existing && this.rendererEqual(existing.data, renderer)) {
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
this.addRenderer(renderer);
|
|
1402
|
+
}
|
|
1403
|
+
for (const key of oldKeys) {
|
|
1404
|
+
if (!( newKeys.has(key))) {
|
|
1405
|
+
this._renderers.delete(key);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
addRenderer(renderer) {
|
|
1410
|
+
this._renderers.set(renderer.id, ( new Renderer(renderer)));
|
|
1411
|
+
}
|
|
1412
|
+
clearAll() {
|
|
1413
|
+
outputRunner.cancelAll();
|
|
1414
|
+
for (const renderer of ( this._renderers.values())) {
|
|
1415
|
+
renderer.disposeOutputItem();
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
clearOutput(rendererId, outputId) {
|
|
1419
|
+
outputRunner.cancelOutput(outputId);
|
|
1420
|
+
this._renderers.get(rendererId)?.disposeOutputItem(outputId);
|
|
1421
|
+
}
|
|
1422
|
+
async render(item, preferredRendererId, element, signal) {
|
|
1423
|
+
const primaryRenderer = this.findRenderer(preferredRendererId, item);
|
|
1424
|
+
if (!primaryRenderer) {
|
|
1425
|
+
const errorMessage = ($window.document.documentElement.style.getPropertyValue('--notebook-cell-renderer-not-found-error') || '').replace('$0', () => item.mime);
|
|
1426
|
+
this.showRenderError(item, element, errorMessage);
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
if (!(await this._doRender(item, element, primaryRenderer, signal)).continue) {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
for (const additionalItemData of item._allOutputItems) {
|
|
1433
|
+
if (additionalItemData.mime === item.mime) {
|
|
1434
|
+
continue;
|
|
1435
|
+
}
|
|
1436
|
+
const additionalItem = await additionalItemData.getItem();
|
|
1437
|
+
if (signal.aborted) {
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
if (additionalItem) {
|
|
1441
|
+
const renderer = this.findRenderer(undefined, additionalItem);
|
|
1442
|
+
if (renderer) {
|
|
1443
|
+
if (!(await this._doRender(additionalItem, element, renderer, signal)).continue) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
const errorMessage = ($window.document.documentElement.style.getPropertyValue('--notebook-cell-renderer-fallbacks-exhausted') || '').replace('$0', () => item.mime);
|
|
1450
|
+
this.showRenderError(item, element, errorMessage);
|
|
1451
|
+
}
|
|
1452
|
+
async _doRender(item, element, renderer, signal) {
|
|
1453
|
+
try {
|
|
1454
|
+
await renderer.renderOutputItem(item, element, signal);
|
|
1455
|
+
return { continue: false };
|
|
1456
|
+
}
|
|
1457
|
+
catch (e) {
|
|
1458
|
+
if (signal.aborted) {
|
|
1459
|
+
return { continue: false };
|
|
1460
|
+
}
|
|
1461
|
+
if (e instanceof Error && e.name === renderFallbackErrorName) {
|
|
1462
|
+
return { continue: true };
|
|
1463
|
+
}
|
|
1464
|
+
else {
|
|
1465
|
+
throw e;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
findRenderer(preferredRendererId, info) {
|
|
1470
|
+
let renderer;
|
|
1471
|
+
if (typeof preferredRendererId === 'string') {
|
|
1472
|
+
renderer = Array.from(( this._renderers.values()))
|
|
1473
|
+
.find((renderer) => renderer.data.id === preferredRendererId);
|
|
1474
|
+
}
|
|
1475
|
+
else {
|
|
1476
|
+
const renderers = Array.from(( this._renderers.values()))
|
|
1477
|
+
.filter((renderer) => renderer.data.mimeTypes.includes(info.mime) && !renderer.data.entrypoint.extends);
|
|
1478
|
+
if (renderers.length) {
|
|
1479
|
+
renderers.sort((a, b) => +a.data.isBuiltin - +b.data.isBuiltin);
|
|
1480
|
+
renderer = renderers[0];
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
return renderer;
|
|
1484
|
+
}
|
|
1485
|
+
showRenderError(info, element, errorMessage) {
|
|
1486
|
+
const errorContainer = document.createElement('div');
|
|
1487
|
+
const error = document.createElement('div');
|
|
1488
|
+
error.className = 'no-renderer-error';
|
|
1489
|
+
error.innerText = errorMessage;
|
|
1490
|
+
const cellText = document.createElement('div');
|
|
1491
|
+
cellText.innerText = info.text();
|
|
1492
|
+
errorContainer.appendChild(error);
|
|
1493
|
+
errorContainer.appendChild(cellText);
|
|
1494
|
+
element.innerText = '';
|
|
1495
|
+
element.appendChild(errorContainer);
|
|
1496
|
+
}
|
|
1497
|
+
})();
|
|
1498
|
+
const viewModel = new (class ViewModel {
|
|
1499
|
+
constructor() {
|
|
1500
|
+
this._markupCells = ( new Map());
|
|
1501
|
+
this._outputCells = ( new Map());
|
|
1502
|
+
}
|
|
1503
|
+
clearAll() {
|
|
1504
|
+
for (const cell of ( this._markupCells.values())) {
|
|
1505
|
+
cell.dispose();
|
|
1506
|
+
}
|
|
1507
|
+
this._markupCells.clear();
|
|
1508
|
+
for (const output of ( this._outputCells.values())) {
|
|
1509
|
+
output.dispose();
|
|
1510
|
+
}
|
|
1511
|
+
this._outputCells.clear();
|
|
1512
|
+
}
|
|
1513
|
+
async createMarkupCell(init, top, visible) {
|
|
1514
|
+
const existing = this._markupCells.get(init.cellId);
|
|
1515
|
+
if (existing) {
|
|
1516
|
+
console.error(`Trying to create markup that already exists: ${init.cellId}`);
|
|
1517
|
+
return existing;
|
|
1518
|
+
}
|
|
1519
|
+
const cell = ( new MarkupCell(init.cellId, init.mime, init.content, top, init.metadata));
|
|
1520
|
+
cell.element.style.visibility = visible ? '' : 'hidden';
|
|
1521
|
+
this._markupCells.set(init.cellId, cell);
|
|
1522
|
+
await cell.ready;
|
|
1523
|
+
return cell;
|
|
1524
|
+
}
|
|
1525
|
+
async ensureMarkupCell(info) {
|
|
1526
|
+
let cell = this._markupCells.get(info.cellId);
|
|
1527
|
+
if (cell) {
|
|
1528
|
+
cell.element.style.visibility = info.visible ? '' : 'hidden';
|
|
1529
|
+
await cell.updateContentAndRender(info.content, info.metadata);
|
|
1530
|
+
}
|
|
1531
|
+
else {
|
|
1532
|
+
cell = await this.createMarkupCell(info, info.offset, info.visible);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
deleteMarkupCell(id) {
|
|
1536
|
+
const cell = this.getExpectedMarkupCell(id);
|
|
1537
|
+
if (cell) {
|
|
1538
|
+
cell.remove();
|
|
1539
|
+
cell.dispose();
|
|
1540
|
+
this._markupCells.delete(id);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
async updateMarkupContent(id, newContent, metadata) {
|
|
1544
|
+
const cell = this.getExpectedMarkupCell(id);
|
|
1545
|
+
await cell?.updateContentAndRender(newContent, metadata);
|
|
1546
|
+
}
|
|
1547
|
+
showMarkupCell(id, top, newContent, metadata) {
|
|
1548
|
+
const cell = this.getExpectedMarkupCell(id);
|
|
1549
|
+
cell?.show(top, newContent, metadata);
|
|
1550
|
+
}
|
|
1551
|
+
hideMarkupCell(id) {
|
|
1552
|
+
const cell = this.getExpectedMarkupCell(id);
|
|
1553
|
+
cell?.hide();
|
|
1554
|
+
}
|
|
1555
|
+
unhideMarkupCell(id) {
|
|
1556
|
+
const cell = this.getExpectedMarkupCell(id);
|
|
1557
|
+
cell?.unhide();
|
|
1558
|
+
}
|
|
1559
|
+
getExpectedMarkupCell(id) {
|
|
1560
|
+
const cell = this._markupCells.get(id);
|
|
1561
|
+
if (!cell) {
|
|
1562
|
+
console.log(`Could not find markup cell '${id}'`);
|
|
1563
|
+
return undefined;
|
|
1564
|
+
}
|
|
1565
|
+
return cell;
|
|
1566
|
+
}
|
|
1567
|
+
updateSelectedCells(selectedCellIds) {
|
|
1568
|
+
const selectedCellSet = ( new Set(selectedCellIds));
|
|
1569
|
+
for (const cell of ( this._markupCells.values())) {
|
|
1570
|
+
cell.setSelected(( selectedCellSet.has(cell.id)));
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
toggleDragDropEnabled(dragAndDropEnabled) {
|
|
1574
|
+
for (const cell of ( this._markupCells.values())) {
|
|
1575
|
+
cell.toggleDragDropEnabled(dragAndDropEnabled);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
updateMarkupScrolls(markupCells) {
|
|
1579
|
+
for (const { id, top } of markupCells) {
|
|
1580
|
+
const cell = this._markupCells.get(id);
|
|
1581
|
+
if (cell) {
|
|
1582
|
+
cell.element.style.top = `${top}px`;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
async renderOutputCell(data, signal) {
|
|
1587
|
+
const preloadErrors = await Promise.all(( data.requiredPreloads.map(p => kernelPreloads.waitFor(p.uri).then(() => undefined, err => err))));
|
|
1588
|
+
if (signal.aborted) {
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
const cellOutput = this.ensureOutputCell(data.cellId, data.cellTop, false);
|
|
1592
|
+
return cellOutput.renderOutputElement(data, preloadErrors, signal);
|
|
1593
|
+
}
|
|
1594
|
+
ensureOutputCell(cellId, cellTop, skipCellTopUpdateIfExist) {
|
|
1595
|
+
let cell = this._outputCells.get(cellId);
|
|
1596
|
+
const existed = !!cell;
|
|
1597
|
+
if (!cell) {
|
|
1598
|
+
cell = ( new OutputCell(cellId));
|
|
1599
|
+
this._outputCells.set(cellId, cell);
|
|
1600
|
+
}
|
|
1601
|
+
if (existed && skipCellTopUpdateIfExist) {
|
|
1602
|
+
return cell;
|
|
1603
|
+
}
|
|
1604
|
+
cell.element.style.top = cellTop + 'px';
|
|
1605
|
+
return cell;
|
|
1606
|
+
}
|
|
1607
|
+
clearOutput(cellId, outputId, rendererId) {
|
|
1608
|
+
const cell = this._outputCells.get(cellId);
|
|
1609
|
+
cell?.clearOutput(outputId, rendererId);
|
|
1610
|
+
}
|
|
1611
|
+
showOutput(cellId, outputId, top) {
|
|
1612
|
+
const cell = this._outputCells.get(cellId);
|
|
1613
|
+
cell?.show(outputId, top);
|
|
1614
|
+
}
|
|
1615
|
+
updateAndRerender(cellId, outputId, content) {
|
|
1616
|
+
const cell = this._outputCells.get(cellId);
|
|
1617
|
+
cell?.updateContentAndRerender(outputId, content);
|
|
1618
|
+
}
|
|
1619
|
+
hideOutput(cellId) {
|
|
1620
|
+
const cell = this._outputCells.get(cellId);
|
|
1621
|
+
cell?.hide();
|
|
1622
|
+
}
|
|
1623
|
+
updateOutputHeight(cellId, outputId, height) {
|
|
1624
|
+
const cell = this._outputCells.get(cellId);
|
|
1625
|
+
cell?.updateOutputHeight(outputId, height);
|
|
1626
|
+
}
|
|
1627
|
+
updateOutputsScroll(updates) {
|
|
1628
|
+
for (const request of updates) {
|
|
1629
|
+
const cell = this._outputCells.get(request.cellId);
|
|
1630
|
+
cell?.updateScroll(request);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
})();
|
|
1634
|
+
class MarkdownCodeBlock {
|
|
1635
|
+
static { this.pendingCodeBlocksToHighlight = ( new Map()); }
|
|
1636
|
+
static highlightCodeBlock(id, html) {
|
|
1637
|
+
const el = MarkdownCodeBlock.pendingCodeBlocksToHighlight.get(id);
|
|
1638
|
+
if (!el) {
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
const trustedHtml = ttPolicy?.createHTML(html) ?? html;
|
|
1642
|
+
el.innerHTML = trustedHtml;
|
|
1643
|
+
const root = el.getRootNode();
|
|
1644
|
+
if (root instanceof ShadowRoot) {
|
|
1645
|
+
if (!root.adoptedStyleSheets.includes(tokenizationStyle)) {
|
|
1646
|
+
root.adoptedStyleSheets.push(tokenizationStyle);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
static requestHighlightCodeBlock(root) {
|
|
1651
|
+
const codeBlocks = [];
|
|
1652
|
+
let i = 0;
|
|
1653
|
+
for (const el of root.querySelectorAll('.vscode-code-block')) {
|
|
1654
|
+
const lang = el.getAttribute('data-vscode-code-block-lang');
|
|
1655
|
+
if (el.textContent && lang) {
|
|
1656
|
+
const id = `${Date.now()}-${i++}`;
|
|
1657
|
+
codeBlocks.push({ value: el.textContent, lang: lang, id });
|
|
1658
|
+
MarkdownCodeBlock.pendingCodeBlocksToHighlight.set(id, el);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
return codeBlocks;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
class MarkupCell {
|
|
1665
|
+
constructor(id, mime, content, top, metadata) {
|
|
1666
|
+
this._isDisposed = false;
|
|
1667
|
+
const self = this;
|
|
1668
|
+
this.id = id;
|
|
1669
|
+
this._content = { value: content, version: 0, metadata: metadata };
|
|
1670
|
+
let resolve;
|
|
1671
|
+
let reject;
|
|
1672
|
+
this.ready = ( new Promise((res, rej) => {
|
|
1673
|
+
resolve = res;
|
|
1674
|
+
reject = rej;
|
|
1675
|
+
}));
|
|
1676
|
+
let cachedData;
|
|
1677
|
+
this.outputItem = ( Object.freeze({
|
|
1678
|
+
id,
|
|
1679
|
+
mime,
|
|
1680
|
+
get metadata() {
|
|
1681
|
+
return self._content.metadata;
|
|
1682
|
+
},
|
|
1683
|
+
text: () => {
|
|
1684
|
+
return this._content.value;
|
|
1685
|
+
},
|
|
1686
|
+
json: () => {
|
|
1687
|
+
return undefined;
|
|
1688
|
+
},
|
|
1689
|
+
data: () => {
|
|
1690
|
+
if (cachedData?.version === this._content.version) {
|
|
1691
|
+
return cachedData.value;
|
|
1692
|
+
}
|
|
1693
|
+
const data = textEncoder.encode(this._content.value);
|
|
1694
|
+
cachedData = { version: this._content.version, value: data };
|
|
1695
|
+
return data;
|
|
1696
|
+
},
|
|
1697
|
+
blob() {
|
|
1698
|
+
return ( new Blob([this.data()], { type: this.mime }));
|
|
1699
|
+
},
|
|
1700
|
+
_allOutputItems: [{
|
|
1701
|
+
mime,
|
|
1702
|
+
getItem: async () => this.outputItem,
|
|
1703
|
+
}]
|
|
1704
|
+
}));
|
|
1705
|
+
const root = $window.document.getElementById('container');
|
|
1706
|
+
const markupCell = document.createElement('div');
|
|
1707
|
+
markupCell.className = 'markup';
|
|
1708
|
+
markupCell.style.position = 'absolute';
|
|
1709
|
+
markupCell.style.width = '100%';
|
|
1710
|
+
this.element = document.createElement('div');
|
|
1711
|
+
this.element.id = this.id;
|
|
1712
|
+
this.element.classList.add('preview');
|
|
1713
|
+
this.element.style.position = 'absolute';
|
|
1714
|
+
this.element.style.top = top + 'px';
|
|
1715
|
+
this.toggleDragDropEnabled(currentOptions.dragAndDropEnabled);
|
|
1716
|
+
markupCell.appendChild(this.element);
|
|
1717
|
+
root.appendChild(markupCell);
|
|
1718
|
+
this.addEventListeners();
|
|
1719
|
+
this.updateContentAndRender(this._content.value, this._content.metadata).then(() => {
|
|
1720
|
+
if (!this._isDisposed) {
|
|
1721
|
+
resizeObserver.observe(this.element, this.id, false, this.id);
|
|
1722
|
+
}
|
|
1723
|
+
resolve();
|
|
1724
|
+
}, () => reject());
|
|
1725
|
+
}
|
|
1726
|
+
dispose() {
|
|
1727
|
+
this._isDisposed = true;
|
|
1728
|
+
this.renderTaskAbort?.abort();
|
|
1729
|
+
this.renderTaskAbort = undefined;
|
|
1730
|
+
}
|
|
1731
|
+
addEventListeners() {
|
|
1732
|
+
this.element.addEventListener('dblclick', () => {
|
|
1733
|
+
postNotebookMessage('toggleMarkupPreview', { cellId: this.id });
|
|
1734
|
+
});
|
|
1735
|
+
this.element.addEventListener('click', e => {
|
|
1736
|
+
postNotebookMessage('clickMarkupCell', {
|
|
1737
|
+
cellId: this.id,
|
|
1738
|
+
altKey: e.altKey,
|
|
1739
|
+
ctrlKey: e.ctrlKey,
|
|
1740
|
+
metaKey: e.metaKey,
|
|
1741
|
+
shiftKey: e.shiftKey,
|
|
1742
|
+
});
|
|
1743
|
+
});
|
|
1744
|
+
this.element.addEventListener('contextmenu', e => {
|
|
1745
|
+
postNotebookMessage('contextMenuMarkupCell', {
|
|
1746
|
+
cellId: this.id,
|
|
1747
|
+
clientX: e.clientX,
|
|
1748
|
+
clientY: e.clientY,
|
|
1749
|
+
});
|
|
1750
|
+
});
|
|
1751
|
+
this.element.addEventListener('mouseenter', () => {
|
|
1752
|
+
postNotebookMessage('mouseEnterMarkupCell', { cellId: this.id });
|
|
1753
|
+
});
|
|
1754
|
+
this.element.addEventListener('mouseleave', () => {
|
|
1755
|
+
postNotebookMessage('mouseLeaveMarkupCell', { cellId: this.id });
|
|
1756
|
+
});
|
|
1757
|
+
this.element.addEventListener('dragstart', e => {
|
|
1758
|
+
markupCellDragManager.startDrag(e, this.id);
|
|
1759
|
+
});
|
|
1760
|
+
this.element.addEventListener('drag', e => {
|
|
1761
|
+
markupCellDragManager.updateDrag(e, this.id);
|
|
1762
|
+
});
|
|
1763
|
+
this.element.addEventListener('dragend', e => {
|
|
1764
|
+
markupCellDragManager.endDrag(e, this.id);
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
async updateContentAndRender(newContent, metadata) {
|
|
1768
|
+
this._content = { value: newContent, version: this._content.version + 1, metadata };
|
|
1769
|
+
this.renderTaskAbort?.abort();
|
|
1770
|
+
const controller = ( new AbortController());
|
|
1771
|
+
this.renderTaskAbort = controller;
|
|
1772
|
+
try {
|
|
1773
|
+
await renderers.render(this.outputItem, undefined, this.element, this.renderTaskAbort.signal);
|
|
1774
|
+
}
|
|
1775
|
+
finally {
|
|
1776
|
+
if (this.renderTaskAbort === controller) {
|
|
1777
|
+
this.renderTaskAbort = undefined;
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
const root = (this.element.shadowRoot ?? this.element);
|
|
1781
|
+
const html = [];
|
|
1782
|
+
for (const child of root.children) {
|
|
1783
|
+
switch (child.tagName) {
|
|
1784
|
+
case 'LINK':
|
|
1785
|
+
case 'SCRIPT':
|
|
1786
|
+
case 'STYLE':
|
|
1787
|
+
break;
|
|
1788
|
+
default:
|
|
1789
|
+
html.push(child.outerHTML);
|
|
1790
|
+
break;
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
const codeBlocks = MarkdownCodeBlock.requestHighlightCodeBlock(root);
|
|
1794
|
+
postNotebookMessage('renderedMarkup', {
|
|
1795
|
+
cellId: this.id,
|
|
1796
|
+
html: html.join(''),
|
|
1797
|
+
codeBlocks
|
|
1798
|
+
});
|
|
1799
|
+
dimensionUpdater.updateHeight(this.id, this.element.offsetHeight, {
|
|
1800
|
+
isOutput: false
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
show(top, newContent, metadata) {
|
|
1804
|
+
this.element.style.visibility = '';
|
|
1805
|
+
this.element.style.top = `${top}px`;
|
|
1806
|
+
if (typeof newContent === 'string' || metadata) {
|
|
1807
|
+
this.updateContentAndRender(newContent ?? this._content.value, metadata ?? this._content.metadata);
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
this.updateMarkupDimensions();
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
hide() {
|
|
1814
|
+
this.element.style.visibility = 'hidden';
|
|
1815
|
+
}
|
|
1816
|
+
unhide() {
|
|
1817
|
+
this.element.style.visibility = '';
|
|
1818
|
+
this.updateMarkupDimensions();
|
|
1819
|
+
}
|
|
1820
|
+
remove() {
|
|
1821
|
+
this.element.remove();
|
|
1822
|
+
}
|
|
1823
|
+
async updateMarkupDimensions() {
|
|
1824
|
+
dimensionUpdater.updateHeight(this.id, this.element.offsetHeight, {
|
|
1825
|
+
isOutput: false
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
setSelected(selected) {
|
|
1829
|
+
this.element.classList.toggle('selected', selected);
|
|
1830
|
+
}
|
|
1831
|
+
toggleDragDropEnabled(enabled) {
|
|
1832
|
+
if (enabled) {
|
|
1833
|
+
this.element.classList.add('draggable');
|
|
1834
|
+
this.element.setAttribute('draggable', 'true');
|
|
1835
|
+
}
|
|
1836
|
+
else {
|
|
1837
|
+
this.element.classList.remove('draggable');
|
|
1838
|
+
this.element.removeAttribute('draggable');
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
class OutputCell {
|
|
1843
|
+
constructor(cellId) {
|
|
1844
|
+
this.outputElements = ( new Map());
|
|
1845
|
+
const container = $window.document.getElementById('container');
|
|
1846
|
+
const upperWrapperElement = createFocusSink(cellId);
|
|
1847
|
+
container.appendChild(upperWrapperElement);
|
|
1848
|
+
this.element = document.createElement('div');
|
|
1849
|
+
this.element.style.position = 'absolute';
|
|
1850
|
+
this.element.style.outline = '0';
|
|
1851
|
+
this.element.id = cellId;
|
|
1852
|
+
this.element.classList.add('cell_container');
|
|
1853
|
+
container.appendChild(this.element);
|
|
1854
|
+
this.element = this.element;
|
|
1855
|
+
const lowerWrapperElement = createFocusSink(cellId, true);
|
|
1856
|
+
container.appendChild(lowerWrapperElement);
|
|
1857
|
+
}
|
|
1858
|
+
dispose() {
|
|
1859
|
+
for (const output of ( this.outputElements.values())) {
|
|
1860
|
+
output.dispose();
|
|
1861
|
+
}
|
|
1862
|
+
this.outputElements.clear();
|
|
1863
|
+
}
|
|
1864
|
+
createOutputElement(data) {
|
|
1865
|
+
let outputContainer = this.outputElements.get(data.outputId);
|
|
1866
|
+
if (!outputContainer) {
|
|
1867
|
+
outputContainer = ( new OutputContainer(data.outputId));
|
|
1868
|
+
this.element.appendChild(outputContainer.element);
|
|
1869
|
+
this.outputElements.set(data.outputId, outputContainer);
|
|
1870
|
+
}
|
|
1871
|
+
return outputContainer.createOutputElement(data.outputId, data.outputOffset, data.left, data.cellId);
|
|
1872
|
+
}
|
|
1873
|
+
async renderOutputElement(data, preloadErrors, signal) {
|
|
1874
|
+
const startTime = Date.now();
|
|
1875
|
+
const outputElement = this.createOutputElement(data);
|
|
1876
|
+
await outputElement.render(data.content, data.rendererId, preloadErrors, signal);
|
|
1877
|
+
outputElement .element.style.visibility = data.initiallyHidden ? 'hidden' : '';
|
|
1878
|
+
if (!!data.executionId && !!data.rendererId) {
|
|
1879
|
+
postNotebookMessage('notebookPerformanceMessage', { cellId: data.cellId, executionId: data.executionId, duration: Date.now() - startTime, rendererId: data.rendererId });
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
clearOutput(outputId, rendererId) {
|
|
1883
|
+
const output = this.outputElements.get(outputId);
|
|
1884
|
+
output?.clear(rendererId);
|
|
1885
|
+
output?.dispose();
|
|
1886
|
+
this.outputElements.delete(outputId);
|
|
1887
|
+
}
|
|
1888
|
+
show(outputId, top) {
|
|
1889
|
+
const outputContainer = this.outputElements.get(outputId);
|
|
1890
|
+
if (!outputContainer) {
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
this.element.style.visibility = '';
|
|
1894
|
+
this.element.style.top = `${top}px`;
|
|
1895
|
+
dimensionUpdater.updateHeight(outputId, outputContainer.element.offsetHeight, {
|
|
1896
|
+
isOutput: true,
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
hide() {
|
|
1900
|
+
this.element.style.visibility = 'hidden';
|
|
1901
|
+
}
|
|
1902
|
+
updateContentAndRerender(outputId, content) {
|
|
1903
|
+
this.outputElements.get(outputId)?.updateContentAndRender(content);
|
|
1904
|
+
}
|
|
1905
|
+
updateOutputHeight(outputId, height) {
|
|
1906
|
+
this.outputElements.get(outputId)?.updateHeight(height);
|
|
1907
|
+
}
|
|
1908
|
+
updateScroll(request) {
|
|
1909
|
+
this.element.style.top = `${request.cellTop}px`;
|
|
1910
|
+
const outputElement = this.outputElements.get(request.outputId);
|
|
1911
|
+
if (outputElement) {
|
|
1912
|
+
outputElement.updateScroll(request.outputOffset);
|
|
1913
|
+
if (request.forceDisplay && outputElement.outputNode) {
|
|
1914
|
+
outputElement.outputNode.element.style.visibility = '';
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
if (request.forceDisplay) {
|
|
1918
|
+
this.element.style.visibility = '';
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
class OutputContainer {
|
|
1923
|
+
get outputNode() {
|
|
1924
|
+
return this._outputNode;
|
|
1925
|
+
}
|
|
1926
|
+
constructor(outputId) {
|
|
1927
|
+
this.outputId = outputId;
|
|
1928
|
+
this.element = document.createElement('div');
|
|
1929
|
+
this.element.classList.add('output_container');
|
|
1930
|
+
this.element.setAttribute('data-vscode-context', JSON.stringify({ 'preventDefaultContextMenuItems': true }));
|
|
1931
|
+
this.element.style.position = 'absolute';
|
|
1932
|
+
this.element.style.overflow = 'hidden';
|
|
1933
|
+
}
|
|
1934
|
+
dispose() {
|
|
1935
|
+
this._outputNode?.dispose();
|
|
1936
|
+
}
|
|
1937
|
+
clear(rendererId) {
|
|
1938
|
+
if (rendererId) {
|
|
1939
|
+
renderers.clearOutput(rendererId, this.outputId);
|
|
1940
|
+
}
|
|
1941
|
+
this.element.remove();
|
|
1942
|
+
}
|
|
1943
|
+
updateHeight(height) {
|
|
1944
|
+
this.element.style.maxHeight = `${height}px`;
|
|
1945
|
+
this.element.style.height = `${height}px`;
|
|
1946
|
+
}
|
|
1947
|
+
updateScroll(outputOffset) {
|
|
1948
|
+
this.element.style.top = `${outputOffset}px`;
|
|
1949
|
+
}
|
|
1950
|
+
createOutputElement(outputId, outputOffset, left, cellId) {
|
|
1951
|
+
this.element.innerText = '';
|
|
1952
|
+
this.element.style.maxHeight = '0px';
|
|
1953
|
+
this.element.style.top = `${outputOffset}px`;
|
|
1954
|
+
this._outputNode?.dispose();
|
|
1955
|
+
this._outputNode = ( new OutputElement(outputId, left, cellId));
|
|
1956
|
+
this.element.appendChild(this._outputNode.element);
|
|
1957
|
+
return this._outputNode;
|
|
1958
|
+
}
|
|
1959
|
+
updateContentAndRender(content) {
|
|
1960
|
+
this._outputNode?.updateAndRerender(content);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
vscode.postMessage({
|
|
1964
|
+
__vscode_notebook_message: true,
|
|
1965
|
+
type: 'initialized'
|
|
1966
|
+
});
|
|
1967
|
+
for (const preload of ctx.staticPreloadsData) {
|
|
1968
|
+
kernelPreloads.load(preload.entrypoint);
|
|
1969
|
+
}
|
|
1970
|
+
function postNotebookMessage(type, properties) {
|
|
1971
|
+
vscode.postMessage({
|
|
1972
|
+
__vscode_notebook_message: true,
|
|
1973
|
+
type,
|
|
1974
|
+
...properties
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
class OutputElement {
|
|
1978
|
+
constructor(outputId, left, cellId) {
|
|
1979
|
+
this.outputId = outputId;
|
|
1980
|
+
this.cellId = cellId;
|
|
1981
|
+
this.hasResizeObserver = false;
|
|
1982
|
+
this.element = document.createElement('div');
|
|
1983
|
+
this.element.id = outputId;
|
|
1984
|
+
this.element.classList.add('output');
|
|
1985
|
+
this.element.style.position = 'absolute';
|
|
1986
|
+
this.element.style.top = `0px`;
|
|
1987
|
+
this.element.style.left = left + 'px';
|
|
1988
|
+
this.element.style.padding = `${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodeLeftPadding}`;
|
|
1989
|
+
this.element.addEventListener('mouseenter', () => {
|
|
1990
|
+
postNotebookMessage('mouseenter', { id: outputId });
|
|
1991
|
+
});
|
|
1992
|
+
this.element.addEventListener('mouseleave', () => {
|
|
1993
|
+
postNotebookMessage('mouseleave', { id: outputId });
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
dispose() {
|
|
1997
|
+
this.renderTaskAbort?.abort();
|
|
1998
|
+
this.renderTaskAbort = undefined;
|
|
1999
|
+
}
|
|
2000
|
+
async render(content, preferredRendererId, preloadErrors, signal) {
|
|
2001
|
+
this.renderTaskAbort?.abort();
|
|
2002
|
+
this.renderTaskAbort = undefined;
|
|
2003
|
+
this._content = { preferredRendererId, preloadErrors };
|
|
2004
|
+
if (content.type === 0 ) {
|
|
2005
|
+
const trustedHtml = ttPolicy?.createHTML(content.htmlContent) ?? content.htmlContent;
|
|
2006
|
+
this.element.innerHTML = trustedHtml;
|
|
2007
|
+
}
|
|
2008
|
+
else if (( preloadErrors.some(e => e instanceof Error))) {
|
|
2009
|
+
const errors = preloadErrors.filter((e) => e instanceof Error);
|
|
2010
|
+
showRenderError(`Error loading preloads`, this.element, errors);
|
|
2011
|
+
}
|
|
2012
|
+
else {
|
|
2013
|
+
const item = createOutputItem(this.outputId, content.output.mime, content.metadata, content.output.valueBytes, content.allOutputs, content.output.appended);
|
|
2014
|
+
const controller = ( new AbortController());
|
|
2015
|
+
this.renderTaskAbort = controller;
|
|
2016
|
+
signal?.addEventListener('abort', () => controller.abort());
|
|
2017
|
+
try {
|
|
2018
|
+
await renderers.render(item, preferredRendererId, this.element, controller.signal);
|
|
2019
|
+
}
|
|
2020
|
+
finally {
|
|
2021
|
+
if (this.renderTaskAbort === controller) {
|
|
2022
|
+
this.renderTaskAbort = undefined;
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
if (!this.hasResizeObserver) {
|
|
2027
|
+
this.hasResizeObserver = true;
|
|
2028
|
+
resizeObserver.observe(this.element, this.outputId, true, this.cellId);
|
|
2029
|
+
}
|
|
2030
|
+
const offsetHeight = this.element.offsetHeight;
|
|
2031
|
+
const cps = document.defaultView.getComputedStyle(this.element);
|
|
2032
|
+
if (offsetHeight !== 0 && cps.padding === '0px') {
|
|
2033
|
+
dimensionUpdater.updateHeight(this.outputId, offsetHeight + ctx.style.outputNodePadding * 2, {
|
|
2034
|
+
isOutput: true,
|
|
2035
|
+
init: true,
|
|
2036
|
+
});
|
|
2037
|
+
this.element.style.padding = `${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodePadding}px ${ctx.style.outputNodeLeftPadding}`;
|
|
2038
|
+
}
|
|
2039
|
+
else {
|
|
2040
|
+
dimensionUpdater.updateHeight(this.outputId, this.element.offsetHeight, {
|
|
2041
|
+
isOutput: true,
|
|
2042
|
+
init: true,
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
const root = this.element.shadowRoot ?? this.element;
|
|
2046
|
+
const codeBlocks = MarkdownCodeBlock.requestHighlightCodeBlock(root);
|
|
2047
|
+
if (codeBlocks.length > 0) {
|
|
2048
|
+
postNotebookMessage('renderedCellOutput', {
|
|
2049
|
+
codeBlocks
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
updateAndRerender(content) {
|
|
2054
|
+
if (this._content) {
|
|
2055
|
+
this.render(content, this._content.preferredRendererId, this._content.preloadErrors);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
const markupCellDragManager = new (class MarkupCellDragManager {
|
|
2060
|
+
constructor() {
|
|
2061
|
+
$window.document.addEventListener('dragover', e => {
|
|
2062
|
+
e.preventDefault();
|
|
2063
|
+
});
|
|
2064
|
+
$window.document.addEventListener('drop', e => {
|
|
2065
|
+
e.preventDefault();
|
|
2066
|
+
const drag = this.currentDrag;
|
|
2067
|
+
if (!drag) {
|
|
2068
|
+
return;
|
|
2069
|
+
}
|
|
2070
|
+
this.currentDrag = undefined;
|
|
2071
|
+
postNotebookMessage('cell-drop', {
|
|
2072
|
+
cellId: drag.cellId,
|
|
2073
|
+
ctrlKey: e.ctrlKey,
|
|
2074
|
+
altKey: e.altKey,
|
|
2075
|
+
dragOffsetY: e.clientY,
|
|
2076
|
+
});
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
startDrag(e, cellId) {
|
|
2080
|
+
if (!e.dataTransfer) {
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
if (!currentOptions.dragAndDropEnabled) {
|
|
2084
|
+
return;
|
|
2085
|
+
}
|
|
2086
|
+
this.currentDrag = { cellId, clientY: e.clientY };
|
|
2087
|
+
const overlayZIndex = 9999;
|
|
2088
|
+
if (!this.dragOverlay) {
|
|
2089
|
+
this.dragOverlay = document.createElement('div');
|
|
2090
|
+
this.dragOverlay.style.position = 'absolute';
|
|
2091
|
+
this.dragOverlay.style.top = '0';
|
|
2092
|
+
this.dragOverlay.style.left = '0';
|
|
2093
|
+
this.dragOverlay.style.zIndex = `${overlayZIndex}`;
|
|
2094
|
+
this.dragOverlay.style.width = '100%';
|
|
2095
|
+
this.dragOverlay.style.height = '100%';
|
|
2096
|
+
this.dragOverlay.style.background = 'transparent';
|
|
2097
|
+
$window.document.body.appendChild(this.dragOverlay);
|
|
2098
|
+
}
|
|
2099
|
+
e.target.style.zIndex = `${overlayZIndex + 1}`;
|
|
2100
|
+
e.target.classList.add('dragging');
|
|
2101
|
+
postNotebookMessage('cell-drag-start', {
|
|
2102
|
+
cellId: cellId,
|
|
2103
|
+
dragOffsetY: e.clientY,
|
|
2104
|
+
});
|
|
2105
|
+
const trySendDragUpdate = () => {
|
|
2106
|
+
if (this.currentDrag?.cellId !== cellId) {
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
postNotebookMessage('cell-drag', {
|
|
2110
|
+
cellId: cellId,
|
|
2111
|
+
dragOffsetY: this.currentDrag.clientY,
|
|
2112
|
+
});
|
|
2113
|
+
$window.requestAnimationFrame(trySendDragUpdate);
|
|
2114
|
+
};
|
|
2115
|
+
$window.requestAnimationFrame(trySendDragUpdate);
|
|
2116
|
+
}
|
|
2117
|
+
updateDrag(e, cellId) {
|
|
2118
|
+
if (cellId !== this.currentDrag?.cellId) {
|
|
2119
|
+
this.currentDrag = undefined;
|
|
2120
|
+
}
|
|
2121
|
+
else {
|
|
2122
|
+
this.currentDrag = { cellId, clientY: e.clientY };
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
endDrag(e, cellId) {
|
|
2126
|
+
this.currentDrag = undefined;
|
|
2127
|
+
e.target.classList.remove('dragging');
|
|
2128
|
+
postNotebookMessage('cell-drag-end', {
|
|
2129
|
+
cellId: cellId
|
|
2130
|
+
});
|
|
2131
|
+
if (this.dragOverlay) {
|
|
2132
|
+
$window.document.body.removeChild(this.dragOverlay);
|
|
2133
|
+
this.dragOverlay = undefined;
|
|
2134
|
+
}
|
|
2135
|
+
e.target.style.zIndex = '';
|
|
2136
|
+
}
|
|
2137
|
+
})();
|
|
2138
|
+
}
|
|
2139
|
+
function preloadsScriptStr(styleValues, options, renderOptions, renderers, preloads, isWorkspaceTrusted, nonce) {
|
|
2140
|
+
const ctx = {
|
|
2141
|
+
style: styleValues,
|
|
2142
|
+
options,
|
|
2143
|
+
renderOptions,
|
|
2144
|
+
rendererData: renderers,
|
|
2145
|
+
staticPreloadsData: preloads,
|
|
2146
|
+
isWorkspaceTrusted,
|
|
2147
|
+
nonce,
|
|
2148
|
+
};
|
|
2149
|
+
return `
|
|
2150
|
+
const __import = (x) => import(x);
|
|
2151
|
+
(${webviewPreloads})(
|
|
2152
|
+
JSON.parse(decodeURIComponent("${encodeURIComponent(JSON.stringify(ctx))}"))
|
|
2153
|
+
)\n//# sourceURL=notebookWebviewPreloads.js\n`;
|
|
2154
|
+
}
|
|
2155
|
+
export { preloadsScriptStr };
|