@parallelworks/ui 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -6
- package/dist/ai/adapter/memoryStore.d.ts +8 -0
- package/dist/ai/adapter/memoryStore.js +152 -0
- package/dist/ai/adapter/mock/index.d.ts +2 -0
- package/dist/ai/adapter/mock/index.js +3 -0
- package/dist/ai/adapter/mock/mockAdapter.d.ts +4 -0
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.d.ts +9 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.d.ts +3 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.d.ts +6 -0
- package/dist/ai/adapter/openai/index.js +6 -0
- package/dist/ai/adapter/openai/openaiAdapter.d.ts +9 -0
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.d.ts +4 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.d.ts +24 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/ai/adapter/openai/wire.d.ts +40 -0
- package/dist/ai/adapter/types.d.ts +131 -0
- package/dist/ai/adapter/types.js +11 -0
- package/dist/ai/agent/classifier.d.ts +2 -0
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.d.ts +35 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.d.ts +6 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/index.d.ts +6 -0
- package/dist/ai/agent/permissions.d.ts +11 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.d.ts +18 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.d.ts +38 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/ai.css +325 -0
- package/dist/ai/components/AllocationSelector.d.ts +4 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.d.ts +1 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.d.ts +24 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.d.ts +1 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.d.ts +8 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.d.ts +3 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.d.ts +45 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.d.ts +5 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.d.ts +24 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.d.ts +35 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.d.ts +5 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.d.ts +3 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.d.ts +18 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.d.ts +16 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.d.ts +5 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.d.ts +6 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.d.ts +11 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.d.ts +28 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.d.ts +21 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.d.ts +54 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.d.ts +11 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.d.ts +4 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.d.ts +66 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.d.ts +5 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.d.ts +114 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.d.ts +47 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.d.ts +1 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.d.ts +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.d.ts +3 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.d.ts +11 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.d.ts +14 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.d.ts +12 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.d.ts +34 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.d.ts +40 -0
- package/dist/ai/index.js +44 -0
- package/dist/ai/strings.d.ts +167 -0
- package/dist/ai/strings.js +175 -0
- package/dist/ai/types.d.ts +236 -0
- package/dist/ai/ui/Avatar.d.ts +8 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.d.ts +31 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.d.ts +8 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.d.ts +21 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/buttons.d.ts +1 -0
- package/dist/ai/ui/codeBreaks.d.ts +16 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.d.ts +1 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.d.ts +81 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.d.ts +4 -0
- package/dist/ai/utils.js +23 -0
- package/dist/assets/{editor.worker-CuBRIwi-.js → editor.worker-BmHUIVG4.js} +194 -163
- package/dist/assets/{json.worker-8ytS02vz.js → json.worker-D8bJ92nw.js} +384 -338
- package/dist/assets/{yaml.worker-DJC-VUcv.js → yaml.worker-C4gyGAko.js} +15657 -13823
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.d.ts +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/components/ConfirmModal.js +74 -0
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/CreateModal-BY6DLmur.js → components/CreateModal.js} +10 -189
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.d.ts +1 -1
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/components/Indicator.d.ts +2 -2
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.d.ts +1 -1
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MarkdownImpl.d.ts +1 -1
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/components/Provider.d.ts +16 -65
- package/dist/{chunks/Provider-Ghua9PkN.js → components/Provider.js} +54 -20
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.d.ts +1 -1
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.d.ts +1 -1
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-4OHjdKdO.js → components/Table.js} +7 -5
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-Crxo_eU_.js → components/Tooltip.js} +6 -4
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/components/focus.d.ts +2 -0
- package/dist/components/focus.js +7 -0
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.d.ts +12 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/duration.d.ts +3 -0
- package/dist/duration.js +17 -0
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/editor/Monaco.d.ts +1 -20
- package/dist/editor/Monaco.js +112 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/index.js +7 -2
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.d.ts +5 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/engine.d.ts +98 -0
- package/dist/file-explorer/FileExplorer.d.ts +11 -2
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.d.ts +1 -1
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/file-explorer/FilePreview/CodePreviewEditor.d.ts +1 -1
- package/dist/{chunks/CodePreviewEditor-4lx3kE-w.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.d.ts +1 -1
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.d.ts +1 -1
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.d.ts +4 -4
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.d.ts +3 -3
- package/dist/file-explorer/index.js +7 -5705
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/types.d.ts +6 -1
- package/dist/file-explorer/lib/utils.d.ts +1 -3
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.d.ts +1 -1
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.d.ts +2 -2
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.d.ts +1 -1
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.d.ts +4 -21
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.d.ts +11 -12
- package/dist/form/index.js +18 -2445
- package/dist/form/lib.d.ts +6 -1
- package/dist/{chunks/FieldWrapper-Bef01EWO.js → form/lib.js} +5 -104
- package/dist/form/types/fieldComponentTypes.d.ts +3 -2
- package/dist/form/types/fieldTypes.d.ts +6 -20
- package/dist/form/useParsedOpts.d.ts +1 -1
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/{slurmDuration.d.ts → duration.d.ts} +2 -2
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/{workflow/index.js → graph/DependencyGraph.js} +76 -1163
- package/dist/graph/JobSummary.js +104 -0
- package/dist/{workflow → graph}/MatrixGroup.d.ts +2 -2
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/{workflow → graph}/index.d.ts +1 -1
- package/dist/graph/index.js +2 -0
- package/dist/{workflow → graph}/types.d.ts +3 -3
- package/dist/graph/types.js +6 -0
- package/dist/icons.d.ts +20 -21
- package/dist/index.d.ts +38 -40
- package/dist/index.js +47 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.d.ts +1 -1
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.d.ts +2 -2
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +350 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.d.ts +9 -9
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/logviewer/LogViewer.d.ts +1 -1
- package/dist/logviewer/LogViewer.js +750 -0
- package/dist/logviewer/index.d.ts +1 -0
- package/dist/logviewer/index.js +3 -742
- package/dist/logviewer/segments.d.ts +9 -0
- package/dist/logviewer/segments.js +80 -0
- package/dist/styles/fonts.css +4 -4
- package/dist/styles/theme.css +6 -4
- package/dist/styles.css +1 -1
- package/dist/theme/index.js +2 -2
- package/package.json +38 -14
- package/LICENSE +0 -202
- package/dist/chunks/Monaco-C1POOdVv.js +0 -1046
- package/dist/chunks/PageHeader-l49p1nM9.js +0 -690
- package/dist/chunks/SwitchToggle-CHPP8uZQ.js +0 -755
- package/dist/chunks/editor-9_uVtUyy.js +0 -347
- package/dist/chunks/list-qrojZZNv.js +0 -1411
- package/dist/editor/usesGitlab.d.ts +0 -97
- package/dist/form/Fields/BucketReadOnlyField.d.ts +0 -7
- package/dist/form/types/workflow-schema.d.ts +0 -1145
- package/dist/form/utils/pwResolver.d.ts +0 -18
- package/dist/{chunks/MarkdownImpl-Bq4QhrtA.js → components/MarkdownImpl.js} +1 -1
- /package/dist/{workflow → graph}/AnnotationBanner.d.ts +0 -0
- /package/dist/{workflow → graph}/Collapse.d.ts +0 -0
- /package/dist/{workflow → graph}/DependencyGraph.d.ts +0 -0
- /package/dist/{workflow → graph}/JobSummary.d.ts +0 -0
- /package/dist/{workflow → graph}/Reveal.d.ts +0 -0
- /package/dist/{workflow → graph}/TreeView.d.ts +0 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { useStrings } from "../../components/Provider.js";
|
|
2
|
+
import { DownloadFileIcon, FileIcon, LockIcon, MusicIcon, ZipIcon } from "../../icons.js";
|
|
3
|
+
import { positionKeys, withPositionKeys } from "../../components/keys.js";
|
|
4
|
+
import Loader from "../../components/Loader.js";
|
|
5
|
+
import Markdown from "../../components/Markdown.js";
|
|
6
|
+
import { formatFileSize, getFileExtension } from "../lib/utils.js";
|
|
7
|
+
import { CODE_PREVIEW_MAX_BYTES, CODE_PREVIEW_MAX_LINES, PDF_PREVIEW_MAX_BYTES, TABULAR_PREVIEW_MAX_BYTES, getMonacoLanguage } from "./previewType.js";
|
|
8
|
+
import { CorsIssuePreview } from "../helpers.js";
|
|
9
|
+
import { joinSource, parseDelimited, parseNotebook, stripAnsi } from "./parse.js";
|
|
10
|
+
import { countLines } from "./readCappedBytes.js";
|
|
11
|
+
import { useObjectBlobUrl } from "./useObjectBlobUrl.js";
|
|
12
|
+
import { useObjectText } from "./useObjectText.js";
|
|
13
|
+
import cx from "classnames";
|
|
14
|
+
import { Suspense, lazy, useCallback, useMemo, useState } from "react";
|
|
15
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
//#region src/file-explorer/FilePreview/Viewer.tsx
|
|
17
|
+
var CodePreviewEditor = lazy(() => import("./CodePreviewEditor.js"));
|
|
18
|
+
var PREVIEW_MARKDOWN_CONTROLS = {
|
|
19
|
+
table: { fullscreen: false },
|
|
20
|
+
mermaid: { fullscreen: false }
|
|
21
|
+
};
|
|
22
|
+
function FilePreviewViewer({ node, kind, url, urlLoading, urlError, zoom = 100, onDownload, storage = null }) {
|
|
23
|
+
const t = useStrings().fileExplorer;
|
|
24
|
+
const [reloadNonce, setReloadNonce] = useState(0);
|
|
25
|
+
const onCorsRetry = useCallback(async (opts) => {
|
|
26
|
+
if (opts?.silent) {
|
|
27
|
+
if (!url) return { corsError: true };
|
|
28
|
+
try {
|
|
29
|
+
(await fetch(url)).body?.cancel().catch(() => {});
|
|
30
|
+
return { corsError: false };
|
|
31
|
+
} catch {
|
|
32
|
+
return { corsError: true };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setReloadNonce((n) => n + 1);
|
|
36
|
+
return { corsError: false };
|
|
37
|
+
}, [url]);
|
|
38
|
+
if (urlError) return /* @__PURE__ */ jsx(NotPreviewable, {
|
|
39
|
+
icon: /* @__PURE__ */ jsx(FileIcon, { className: "h-9 w-9 theme-muted-text" }),
|
|
40
|
+
title: t.preview.errorTitle,
|
|
41
|
+
message: urlError,
|
|
42
|
+
onDownload
|
|
43
|
+
});
|
|
44
|
+
if (kind === "archive") return /* @__PURE__ */ jsx(NotPreviewable, {
|
|
45
|
+
icon: /* @__PURE__ */ jsx(ZipIcon, { className: "h-9 w-9 text-(--theme-link)" }),
|
|
46
|
+
title: t.preview.archiveTitle,
|
|
47
|
+
message: t.preview.archiveMessage,
|
|
48
|
+
onDownload
|
|
49
|
+
});
|
|
50
|
+
if (kind === "unsupported") return /* @__PURE__ */ jsx(NotPreviewable, {
|
|
51
|
+
icon: /* @__PURE__ */ jsx(FileIcon, { className: "h-9 w-9 theme-muted-text" }),
|
|
52
|
+
title: t.preview.unsupportedTitle,
|
|
53
|
+
message: t.preview.unsupportedMessage,
|
|
54
|
+
onDownload
|
|
55
|
+
});
|
|
56
|
+
if (urlLoading || !url) return /* @__PURE__ */ jsx("div", {
|
|
57
|
+
className: "flex h-full w-full items-center justify-center",
|
|
58
|
+
children: /* @__PURE__ */ jsx(Loader, {
|
|
59
|
+
size: 40,
|
|
60
|
+
text: t.preview.loading
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
switch (kind) {
|
|
64
|
+
case "image": return /* @__PURE__ */ jsx(ImageView, {
|
|
65
|
+
node,
|
|
66
|
+
url,
|
|
67
|
+
zoom,
|
|
68
|
+
onDownload
|
|
69
|
+
});
|
|
70
|
+
case "video": return /* @__PURE__ */ jsx(VideoView, {
|
|
71
|
+
node,
|
|
72
|
+
url,
|
|
73
|
+
onDownload
|
|
74
|
+
});
|
|
75
|
+
case "audio": return /* @__PURE__ */ jsx(AudioView, {
|
|
76
|
+
node,
|
|
77
|
+
url,
|
|
78
|
+
onDownload
|
|
79
|
+
});
|
|
80
|
+
case "pdf": return /* @__PURE__ */ jsx(PdfView, {
|
|
81
|
+
node,
|
|
82
|
+
url,
|
|
83
|
+
onDownload,
|
|
84
|
+
storage,
|
|
85
|
+
onCorsRetry
|
|
86
|
+
}, reloadNonce);
|
|
87
|
+
case "code": return /* @__PURE__ */ jsx(CodeView, {
|
|
88
|
+
node,
|
|
89
|
+
url,
|
|
90
|
+
onDownload,
|
|
91
|
+
storage,
|
|
92
|
+
onCorsRetry
|
|
93
|
+
}, reloadNonce);
|
|
94
|
+
case "csv": return /* @__PURE__ */ jsx(CsvView, {
|
|
95
|
+
node,
|
|
96
|
+
url,
|
|
97
|
+
onDownload,
|
|
98
|
+
storage,
|
|
99
|
+
onCorsRetry
|
|
100
|
+
}, reloadNonce);
|
|
101
|
+
case "notebook": return /* @__PURE__ */ jsx(NotebookView, {
|
|
102
|
+
node,
|
|
103
|
+
url,
|
|
104
|
+
onDownload,
|
|
105
|
+
storage,
|
|
106
|
+
onCorsRetry
|
|
107
|
+
}, reloadNonce);
|
|
108
|
+
default: return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function ImageView({ node, url, zoom, onDownload }) {
|
|
112
|
+
const [hasError, setHasError] = useState(false);
|
|
113
|
+
if (hasError) return /* @__PURE__ */ jsx(PreviewError, { onDownload });
|
|
114
|
+
const fit = zoom === 100;
|
|
115
|
+
return /* @__PURE__ */ jsx("div", {
|
|
116
|
+
className: "flex h-full w-full items-center justify-center overflow-auto bg-(--theme-app-bg) p-4",
|
|
117
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
118
|
+
src: url,
|
|
119
|
+
alt: node.name,
|
|
120
|
+
className: cx("block rounded-md shadow-lg", fit && "object-contain"),
|
|
121
|
+
style: fit ? {
|
|
122
|
+
maxWidth: "100%",
|
|
123
|
+
maxHeight: "100%"
|
|
124
|
+
} : {
|
|
125
|
+
width: `${zoom}%`,
|
|
126
|
+
maxWidth: "none"
|
|
127
|
+
},
|
|
128
|
+
onError: () => setHasError(true)
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function VideoView({ node, url, onDownload }) {
|
|
133
|
+
const [hasError, setHasError] = useState(false);
|
|
134
|
+
if (hasError) return /* @__PURE__ */ jsx(PreviewError, { onDownload });
|
|
135
|
+
return /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: "h-full w-full bg-black",
|
|
137
|
+
children: /* @__PURE__ */ jsx("video", {
|
|
138
|
+
src: url,
|
|
139
|
+
controls: true,
|
|
140
|
+
className: "h-full w-full object-contain",
|
|
141
|
+
"aria-label": node.name,
|
|
142
|
+
onError: () => setHasError(true)
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function AudioView({ node, url, onDownload }) {
|
|
147
|
+
const [hasError, setHasError] = useState(false);
|
|
148
|
+
if (hasError) return /* @__PURE__ */ jsx(PreviewError, { onDownload });
|
|
149
|
+
return /* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: "flex h-full w-full items-center justify-center p-6",
|
|
151
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "flex w-full max-w-xl flex-col items-center gap-6",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: "flex h-28 w-28 items-center justify-center rounded-2xl bg-linear-to-br from-(--theme-element) to-(--theme-link) shadow-lg",
|
|
156
|
+
children: /* @__PURE__ */ jsx(MusicIcon, { className: "h-12 w-12 text-white" })
|
|
157
|
+
}),
|
|
158
|
+
/* @__PURE__ */ jsxs("div", {
|
|
159
|
+
className: "text-center",
|
|
160
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
161
|
+
className: "break-all font-medium",
|
|
162
|
+
children: node.name
|
|
163
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
164
|
+
className: "mt-0.5 text-xs theme-muted-text",
|
|
165
|
+
children: [node.contentType, typeof node.size === "number" && ` · ${formatFileSize(node.size)}`]
|
|
166
|
+
})]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ jsx("audio", {
|
|
169
|
+
src: url,
|
|
170
|
+
controls: true,
|
|
171
|
+
className: "w-full",
|
|
172
|
+
"aria-label": node.name,
|
|
173
|
+
onError: () => setHasError(true)
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
function PreviewError({ onDownload }) {
|
|
180
|
+
const t = useStrings().fileExplorer;
|
|
181
|
+
return /* @__PURE__ */ jsx(NotPreviewable, {
|
|
182
|
+
icon: /* @__PURE__ */ jsx(FileIcon, { className: "h-9 w-9 theme-muted-text" }),
|
|
183
|
+
title: t.preview.errorTitle,
|
|
184
|
+
message: t.preview.previewError,
|
|
185
|
+
onDownload
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function PdfView({ node, url, onDownload, storage, onCorsRetry }) {
|
|
189
|
+
const { blobUrl, loading, error, tooLarge, corsError } = useObjectBlobUrl(url, {
|
|
190
|
+
enabled: true,
|
|
191
|
+
maxBytes: PDF_PREVIEW_MAX_BYTES,
|
|
192
|
+
knownSize: node.size,
|
|
193
|
+
mimeType: "application/pdf",
|
|
194
|
+
cacheKey: node.path
|
|
195
|
+
});
|
|
196
|
+
return /* @__PURE__ */ jsx(PreviewFetchState, {
|
|
197
|
+
loading,
|
|
198
|
+
tooLarge,
|
|
199
|
+
error,
|
|
200
|
+
corsError,
|
|
201
|
+
storage,
|
|
202
|
+
onCorsRetry,
|
|
203
|
+
onDownload,
|
|
204
|
+
children: blobUrl ? /* @__PURE__ */ jsx("iframe", {
|
|
205
|
+
src: blobUrl,
|
|
206
|
+
title: node.name,
|
|
207
|
+
className: "h-full w-full border-0 bg-(--theme-app-bg)"
|
|
208
|
+
}) : null
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function CodeView({ node, url, onDownload, storage, onCorsRetry }) {
|
|
212
|
+
const t = useStrings().fileExplorer;
|
|
213
|
+
const language = getMonacoLanguage(node);
|
|
214
|
+
const [tail, setTail] = useState(false);
|
|
215
|
+
const { text, loading, error, tooLarge, truncated, corsError } = useObjectText(url, {
|
|
216
|
+
enabled: true,
|
|
217
|
+
maxBytes: CODE_PREVIEW_MAX_BYTES,
|
|
218
|
+
maxLines: CODE_PREVIEW_MAX_LINES,
|
|
219
|
+
knownSize: node.size,
|
|
220
|
+
cacheKey: node.path,
|
|
221
|
+
tail
|
|
222
|
+
});
|
|
223
|
+
const shownLines = useMemo(() => countLines(text ?? ""), [text]);
|
|
224
|
+
const canToggle = truncated || tail;
|
|
225
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
226
|
+
className: "flex h-full w-full flex-col bg-(--theme-app-bg)",
|
|
227
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: "flex shrink-0 items-center gap-2 border-b theme-border px-3.5 py-2",
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ jsx("span", {
|
|
231
|
+
className: "truncate font-mono text-xs theme-muted-text",
|
|
232
|
+
children: node.name
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
235
|
+
truncated && text !== null && /* @__PURE__ */ jsx("span", {
|
|
236
|
+
className: "shrink-0 font-mono text-[11px] theme-muted-text",
|
|
237
|
+
children: tail ? t.preview.lastLines(shownLines) : t.preview.firstLines(shownLines)
|
|
238
|
+
}),
|
|
239
|
+
canToggle && /* @__PURE__ */ jsxs("div", {
|
|
240
|
+
className: "inline-flex shrink-0 overflow-hidden rounded-full border theme-border text-[11px]",
|
|
241
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
className: cx("cursor-pointer px-2 py-0.5", tail ? "theme-muted-text theme-hover" : "theme-element"),
|
|
244
|
+
onClick: () => setTail(false),
|
|
245
|
+
children: t.preview.head
|
|
246
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
247
|
+
type: "button",
|
|
248
|
+
className: cx("cursor-pointer px-2 py-0.5", tail ? "theme-element" : "theme-muted-text theme-hover"),
|
|
249
|
+
onClick: () => setTail(true),
|
|
250
|
+
children: t.preview.tail
|
|
251
|
+
})]
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ jsxs("span", {
|
|
254
|
+
className: "inline-flex shrink-0 items-center gap-1 rounded-full border theme-border px-2 py-0.5 text-[11px] theme-muted-text",
|
|
255
|
+
children: [/* @__PURE__ */ jsx(LockIcon, { className: "h-2.5 w-2.5" }), t.readOnly]
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
259
|
+
className: "min-h-0 flex-1 overflow-hidden",
|
|
260
|
+
children: /* @__PURE__ */ jsx(PreviewFetchState, {
|
|
261
|
+
loading,
|
|
262
|
+
tooLarge,
|
|
263
|
+
error,
|
|
264
|
+
corsError,
|
|
265
|
+
storage,
|
|
266
|
+
onCorsRetry,
|
|
267
|
+
onDownload,
|
|
268
|
+
children: language === "markdown" ? /* @__PURE__ */ jsx("div", {
|
|
269
|
+
className: "h-full overflow-auto px-5 py-4",
|
|
270
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
271
|
+
controls: PREVIEW_MARKDOWN_CONTROLS,
|
|
272
|
+
children: text ?? ""
|
|
273
|
+
})
|
|
274
|
+
}) : /* @__PURE__ */ jsx(Suspense, {
|
|
275
|
+
fallback: /* @__PURE__ */ jsx(PreviewLoading, {}),
|
|
276
|
+
children: /* @__PURE__ */ jsx(CodePreviewEditor, {
|
|
277
|
+
value: text ?? "",
|
|
278
|
+
language
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
})]
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/** Wrap code in a fenced block for the markdown renderer, using a fence long
|
|
286
|
+
* enough to survive backtick runs inside the content. */
|
|
287
|
+
function toFencedCode(text, language) {
|
|
288
|
+
const longestRun = (text.match(/`+/g) ?? []).reduce((max, run) => Math.max(max, run.length), 0);
|
|
289
|
+
const fence = "`".repeat(Math.max(3, longestRun + 1));
|
|
290
|
+
return `${fence}${language}\n${text}\n${fence}`;
|
|
291
|
+
}
|
|
292
|
+
function CsvView({ node, url, onDownload, storage, onCorsRetry }) {
|
|
293
|
+
const { text, loading, error, tooLarge, corsError } = useObjectText(url, {
|
|
294
|
+
enabled: true,
|
|
295
|
+
maxBytes: TABULAR_PREVIEW_MAX_BYTES,
|
|
296
|
+
maxLines: 502,
|
|
297
|
+
knownSize: node.size,
|
|
298
|
+
cacheKey: node.path
|
|
299
|
+
});
|
|
300
|
+
return /* @__PURE__ */ jsx(PreviewFetchState, {
|
|
301
|
+
loading,
|
|
302
|
+
tooLarge,
|
|
303
|
+
error,
|
|
304
|
+
corsError,
|
|
305
|
+
storage,
|
|
306
|
+
onCorsRetry,
|
|
307
|
+
onDownload,
|
|
308
|
+
children: /* @__PURE__ */ jsx(CsvTable, {
|
|
309
|
+
node,
|
|
310
|
+
text: text ?? ""
|
|
311
|
+
})
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function CsvTable({ node, text }) {
|
|
315
|
+
const t = useStrings().fileExplorer;
|
|
316
|
+
const delimiter = getFileExtension(node.name) === "tsv" ? " " : ",";
|
|
317
|
+
const rows = parseDelimited(text, delimiter, 502);
|
|
318
|
+
const header = rows[0] ?? [];
|
|
319
|
+
const body = rows.slice(1);
|
|
320
|
+
const shown = body.slice(0, 500);
|
|
321
|
+
const truncated = body.length > 500;
|
|
322
|
+
const columnCount = Math.max(header.length, ...shown.map((r) => r.length));
|
|
323
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
324
|
+
className: "flex h-full w-full flex-col bg-(--theme-app-bg)",
|
|
325
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
326
|
+
className: "min-h-0 flex-1 overflow-auto",
|
|
327
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
328
|
+
className: "w-full border-collapse font-mono text-xs",
|
|
329
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
330
|
+
className: "sticky top-0 bg-(--theme-panel-bg)",
|
|
331
|
+
children: [/* @__PURE__ */ jsx("th", {
|
|
332
|
+
className: "w-11 border-b theme-border px-3.5 py-2 text-right font-semibold theme-muted-text",
|
|
333
|
+
children: "#"
|
|
334
|
+
}), positionKeys(columnCount, "column").map((key, i) => /* @__PURE__ */ jsx("th", {
|
|
335
|
+
className: "border-b theme-border px-3.5 py-2 text-left font-semibold",
|
|
336
|
+
children: header[i] ?? ""
|
|
337
|
+
}, key))]
|
|
338
|
+
}) }), /* @__PURE__ */ jsx("tbody", { children: withPositionKeys(shown, "row").map(({ key, item: row }, r) => /* @__PURE__ */ jsxs("tr", {
|
|
339
|
+
className: cx(r % 2 === 1 && "bg-(--theme-panel-bg)/50"),
|
|
340
|
+
children: [/* @__PURE__ */ jsx("td", {
|
|
341
|
+
className: "px-3.5 py-1.5 text-right theme-muted-text",
|
|
342
|
+
children: r + 1
|
|
343
|
+
}), positionKeys(columnCount, "cell").map((cellKey, c) => /* @__PURE__ */ jsx("td", {
|
|
344
|
+
className: "px-3.5 py-1.5",
|
|
345
|
+
children: row[c] ?? ""
|
|
346
|
+
}, cellKey))]
|
|
347
|
+
}, key)) })]
|
|
348
|
+
})
|
|
349
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
350
|
+
className: "shrink-0 border-t theme-border px-3.5 py-1.5 font-mono text-[11px] theme-muted-text",
|
|
351
|
+
children: truncated ? t.preview.csvFirstRows(shown.length, columnCount) : t.preview.csvRows(body.length, columnCount)
|
|
352
|
+
})]
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function NotebookView({ node, url, onDownload, storage, onCorsRetry }) {
|
|
356
|
+
const { text, loading, error, tooLarge, corsError } = useObjectText(url, {
|
|
357
|
+
enabled: true,
|
|
358
|
+
maxBytes: TABULAR_PREVIEW_MAX_BYTES,
|
|
359
|
+
knownSize: node.size,
|
|
360
|
+
cacheKey: node.path
|
|
361
|
+
});
|
|
362
|
+
return /* @__PURE__ */ jsx(PreviewFetchState, {
|
|
363
|
+
loading,
|
|
364
|
+
tooLarge,
|
|
365
|
+
error,
|
|
366
|
+
corsError,
|
|
367
|
+
storage,
|
|
368
|
+
onCorsRetry,
|
|
369
|
+
onDownload,
|
|
370
|
+
children: /* @__PURE__ */ jsx(NotebookBody, {
|
|
371
|
+
text: text ?? "",
|
|
372
|
+
onDownload
|
|
373
|
+
})
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function NotebookBody({ text, onDownload }) {
|
|
377
|
+
const t = useStrings().fileExplorer;
|
|
378
|
+
const notebook = parseNotebook(text);
|
|
379
|
+
if (!notebook) return /* @__PURE__ */ jsx(InlineError, {
|
|
380
|
+
message: t.preview.notebookParseError,
|
|
381
|
+
onDownload
|
|
382
|
+
});
|
|
383
|
+
return /* @__PURE__ */ jsx("div", {
|
|
384
|
+
className: "h-full w-full overflow-auto bg-(--theme-app-bg) p-4",
|
|
385
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
386
|
+
className: "mx-auto flex max-w-4xl flex-col gap-3",
|
|
387
|
+
children: withPositionKeys(notebook.cells, "cell").map(({ key, item: cell }) => {
|
|
388
|
+
const source = joinSource(cell.source);
|
|
389
|
+
if (cell.cell_type === "markdown") return /* @__PURE__ */ jsx("div", {
|
|
390
|
+
className: "rounded-lg border theme-border px-4 py-3",
|
|
391
|
+
children: /* @__PURE__ */ jsx(Markdown, {
|
|
392
|
+
controls: PREVIEW_MARKDOWN_CONTROLS,
|
|
393
|
+
children: source
|
|
394
|
+
})
|
|
395
|
+
}, key);
|
|
396
|
+
if (cell.cell_type === "code") return /* @__PURE__ */ jsxs("div", {
|
|
397
|
+
className: "flex gap-2",
|
|
398
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
399
|
+
className: "w-14 shrink-0 pt-3 font-mono text-[11px] theme-muted-text",
|
|
400
|
+
children: typeof cell.execution_count === "number" ? `In [${cell.execution_count}]:` : "In [ ]:"
|
|
401
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
402
|
+
className: "min-w-0 flex-1",
|
|
403
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
404
|
+
className: "rounded-lg border theme-border px-1 py-1 text-xs",
|
|
405
|
+
children: /* @__PURE__ */ jsx(Markdown, { children: toFencedCode(source, "python") })
|
|
406
|
+
}), withPositionKeys(cell.outputs ?? [], "output").map(({ key: outputKey, item: output }) => /* @__PURE__ */ jsx(NotebookOutputView, { output }, outputKey))]
|
|
407
|
+
})]
|
|
408
|
+
}, key);
|
|
409
|
+
return null;
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function NotebookOutputView({ output }) {
|
|
415
|
+
const t = useStrings().fileExplorer;
|
|
416
|
+
const [imgError, setImgError] = useState(false);
|
|
417
|
+
const png = output.data?.["image/png"];
|
|
418
|
+
if ((typeof png === "string" || Array.isArray(png)) && !imgError) return /* @__PURE__ */ jsx("div", {
|
|
419
|
+
className: "mt-2 rounded-lg bg-white p-3",
|
|
420
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
421
|
+
src: `data:image/png;base64,${joinSource(png)}`,
|
|
422
|
+
alt: t.preview.notebookOutput,
|
|
423
|
+
className: "max-w-full",
|
|
424
|
+
onError: () => setImgError(true)
|
|
425
|
+
})
|
|
426
|
+
});
|
|
427
|
+
if (output.output_type === "stream") return /* @__PURE__ */ jsx("pre", {
|
|
428
|
+
className: "mt-2 overflow-auto rounded-lg bg-(--theme-panel-bg) px-3 py-2 font-mono text-[11px] theme-muted-text",
|
|
429
|
+
children: joinSource(output.text)
|
|
430
|
+
});
|
|
431
|
+
if (output.output_type === "error") return /* @__PURE__ */ jsx("pre", {
|
|
432
|
+
className: "mt-2 overflow-auto rounded-lg bg-red-500/15 px-3 py-2 font-mono text-[11px] text-red-500",
|
|
433
|
+
children: stripAnsi((output.traceback ?? []).join("\n"))
|
|
434
|
+
});
|
|
435
|
+
const plain = output.data?.["text/plain"];
|
|
436
|
+
if (plain !== void 0) return /* @__PURE__ */ jsx("pre", {
|
|
437
|
+
className: "mt-2 overflow-auto rounded-lg bg-(--theme-panel-bg) px-3 py-2 font-mono text-[11px]",
|
|
438
|
+
children: joinSource(plain)
|
|
439
|
+
});
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
442
|
+
function PreviewLoading() {
|
|
443
|
+
return /* @__PURE__ */ jsx("div", {
|
|
444
|
+
className: "flex h-full items-center justify-center",
|
|
445
|
+
children: /* @__PURE__ */ jsx(Loader, { size: 36 })
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function PreviewFetchState({ loading, tooLarge, error, corsError, storage, onCorsRetry, onDownload, children }) {
|
|
449
|
+
if (loading) return /* @__PURE__ */ jsx(PreviewLoading, {});
|
|
450
|
+
if (corsError) return /* @__PURE__ */ jsx("div", {
|
|
451
|
+
className: "flex h-full w-full items-center justify-center p-6",
|
|
452
|
+
children: /* @__PURE__ */ jsx(CorsIssuePreview, {
|
|
453
|
+
selectedStorage: storage,
|
|
454
|
+
onRefresh: onCorsRetry
|
|
455
|
+
})
|
|
456
|
+
});
|
|
457
|
+
if (tooLarge) return /* @__PURE__ */ jsx(TooLargeInline, { onDownload });
|
|
458
|
+
if (error) return /* @__PURE__ */ jsx(PreviewError, { onDownload });
|
|
459
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
460
|
+
}
|
|
461
|
+
function NotPreviewable({ icon, title, message, onDownload }) {
|
|
462
|
+
const t = useStrings().fileExplorer;
|
|
463
|
+
return /* @__PURE__ */ jsx("div", {
|
|
464
|
+
className: "flex h-full w-full items-center justify-center p-6",
|
|
465
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
466
|
+
className: "flex max-w-md flex-col items-center gap-4 text-center",
|
|
467
|
+
children: [
|
|
468
|
+
/* @__PURE__ */ jsx("div", {
|
|
469
|
+
className: "flex h-18 w-18 items-center justify-center rounded-2xl theme-muted-panel",
|
|
470
|
+
children: icon
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
473
|
+
className: "font-semibold",
|
|
474
|
+
children: title
|
|
475
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
476
|
+
className: "mt-1 text-sm theme-muted-text",
|
|
477
|
+
children: message
|
|
478
|
+
})] }),
|
|
479
|
+
onDownload && /* @__PURE__ */ jsxs("button", {
|
|
480
|
+
type: "button",
|
|
481
|
+
className: "btn btn-info cursor-pointer",
|
|
482
|
+
onClick: onDownload,
|
|
483
|
+
children: [/* @__PURE__ */ jsx(DownloadFileIcon, { className: "mr-2 h-4 w-4" }), t.preview.downloadInstead]
|
|
484
|
+
})
|
|
485
|
+
]
|
|
486
|
+
})
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function TooLargeInline({ onDownload }) {
|
|
490
|
+
const t = useStrings().fileExplorer;
|
|
491
|
+
return /* @__PURE__ */ jsx("div", {
|
|
492
|
+
className: "flex h-full items-center justify-center p-6",
|
|
493
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
494
|
+
className: "flex max-w-md flex-col items-center gap-3 text-center",
|
|
495
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
496
|
+
className: "text-sm theme-muted-text",
|
|
497
|
+
children: t.preview.tooLarge
|
|
498
|
+
}), onDownload && /* @__PURE__ */ jsxs("button", {
|
|
499
|
+
type: "button",
|
|
500
|
+
className: "btn btn-info cursor-pointer",
|
|
501
|
+
onClick: onDownload,
|
|
502
|
+
children: [/* @__PURE__ */ jsx(DownloadFileIcon, { className: "mr-2 h-4 w-4" }), t.preview.downloadInstead]
|
|
503
|
+
})]
|
|
504
|
+
})
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function InlineError({ message, onDownload }) {
|
|
508
|
+
const t = useStrings().fileExplorer;
|
|
509
|
+
return /* @__PURE__ */ jsx("div", {
|
|
510
|
+
className: "flex h-full items-center justify-center p-6",
|
|
511
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
512
|
+
className: "flex max-w-md flex-col items-center gap-3 text-center",
|
|
513
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
514
|
+
className: "text-sm theme-muted-text",
|
|
515
|
+
children: message
|
|
516
|
+
}), onDownload && /* @__PURE__ */ jsxs("button", {
|
|
517
|
+
type: "button",
|
|
518
|
+
className: "btn btn-neutral cursor-pointer",
|
|
519
|
+
onClick: onDownload,
|
|
520
|
+
children: [/* @__PURE__ */ jsx(DownloadFileIcon, { className: "mr-2 h-4 w-4" }), t.preview.downloadInstead]
|
|
521
|
+
})]
|
|
522
|
+
})
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
export { FilePreviewViewer };
|