@mcp-b/react-components 0.14.2 → 0.16.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/dist/AgentActivity-BNUNrP9O.d.ts +36 -0
- package/dist/{AgentChat-DQkqt82e.d.ts → AgentChat-CrlpbvQJ.d.ts} +58 -6
- package/dist/{CodeBlock-DUh9WOGo.d.ts → CodeBlock-BRajW4QU.d.ts} +1 -1
- package/dist/{CodeBlock-BUFXG8HW.js → CodeBlock-BmB4Xaqq.js} +15 -4
- package/dist/{FileTree-mpEIcfzA.js → FileTree-CkVbIMWV.js} +82 -89
- package/dist/Message-BkMdE3bS.js +375 -0
- package/dist/{ModelSelector-CPCpFAUt.js → ModelSelector-SlJNgwKY.js} +2 -2
- package/dist/{PromptInput-ClNqBiIw.d.ts → PromptInput-BWTuXMOD.d.ts} +123 -5
- package/dist/ResponsiveSidebarShell-Dd9DCcBT.d.ts +67 -0
- package/dist/{Select-Dl_vF_Bt.d.ts → Select-BeEsefzh.d.ts} +12 -2
- package/dist/{ThinkChat-BPcehdbP.js → ThinkChat-CzC-zNGA.js} +24 -36
- package/dist/{ThinkChatActivity-BmwuIigx.d.ts → ThinkChatActivity-BFQnb2ct.d.ts} +3 -10
- package/dist/ThinkChatActivitySummary-BPmu9a-c.d.ts +39 -0
- package/dist/{ThinkChatToolParts-CDEjqS6A.d.ts → ThinkChatToolParts-CSzVwMXf.d.ts} +13 -3
- package/dist/ThinkExecutionRun-ChhWhOoU.d.ts +30 -0
- package/dist/Toggle-CAAlNl-M.d.ts +69 -0
- package/dist/ToggleGroup-8hPv-b69.d.ts +73 -0
- package/dist/Workspace-D39LxGvP.d.ts +62 -0
- package/dist/WorkspaceFile-DOZkPwzu.d.ts +106 -0
- package/dist/WorkspaceFileView-rSN_yT0L.js +744 -0
- package/dist/WorkspaceLink-DIPbXrUM.js +337 -0
- package/dist/WorkspaceLink-DK1DWMHe.d.ts +89 -0
- package/dist/components/Activity.d.ts +27 -1
- package/dist/components/Activity.js +33 -15
- package/dist/components/AgentActivity.d.ts +2 -0
- package/dist/components/AgentActivity.js +45 -0
- package/dist/components/AgentActivityPreview.d.ts +46 -0
- package/dist/components/AgentActivityPreview.js +94 -0
- package/dist/components/AgentAttention.d.ts +73 -0
- package/dist/components/AgentAttention.js +85 -0
- package/dist/components/AgentChat.d.ts +2 -2
- package/dist/components/AgentChat.js +224 -200
- package/dist/components/AgentChatMessageEditor.d.ts +29 -0
- package/dist/components/AgentChatMessageEditor.js +92 -0
- package/dist/components/AgentChatTurnError.d.ts +17 -0
- package/dist/components/AgentChatTurnError.js +40 -0
- package/dist/components/AgentConnection.d.ts +12 -17
- package/dist/components/AgentConnection.js +99 -91
- package/dist/components/AppFrame.d.ts +24 -0
- package/dist/components/AppFrame.js +25 -0
- package/dist/components/AppTopBar.d.ts +71 -0
- package/dist/components/AppTopBar.js +82 -0
- package/dist/components/Artifact.js +1 -1
- package/dist/components/BrowserLiveView.js +1 -1
- package/dist/components/BrowserReplay.js +1 -1
- package/dist/components/BrowserRunPanel.js +1 -1
- package/dist/components/Card.d.ts +3 -0
- package/dist/components/Card.js +2 -1
- package/dist/components/ChainOfThought.d.ts +1 -1
- package/dist/components/ChainOfThought.js +1 -1
- package/dist/components/ChatGptSignInScreen.js +2 -2
- package/dist/components/Checkbox.js +5 -13
- package/dist/components/CheckboxGroup.d.ts +58 -2
- package/dist/components/CheckboxGroup.js +59 -1
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeBlock.js +1 -1
- package/dist/components/CodexModelSelector.js +1 -1
- package/dist/components/Commit.js +2 -2
- package/dist/components/ContextMenu.js +1 -1
- package/dist/components/Conversation.js +1 -1
- package/dist/components/DescriptionList.d.ts +12 -0
- package/dist/components/DescriptionList.js +11 -0
- package/dist/components/DescriptionListParts.d.ts +37 -0
- package/dist/components/DescriptionListParts.js +35 -0
- package/dist/components/EnvironmentVariables.js +2 -2
- package/dist/components/Fieldset.d.ts +13 -1
- package/dist/components/Fieldset.js +11 -2
- package/dist/components/FileTree.js +1 -1
- package/dist/components/IconButton.d.ts +33 -0
- package/dist/components/IconButton.js +27 -0
- package/dist/components/McpConnectionRequest.d.ts +44 -0
- package/dist/components/McpConnectionRequest.js +122 -0
- package/dist/components/McpServerPicker.d.ts +48 -23
- package/dist/components/McpServerPicker.js +238 -189
- package/dist/components/Menubar.js +1 -1
- package/dist/components/Message.d.ts +1 -0
- package/dist/components/Message.js +1 -285
- package/dist/components/MessageScroller.js +1 -1
- package/dist/components/ModelSelector.js +1 -1
- package/dist/components/Pricing.d.ts +37 -0
- package/dist/components/Pricing.js +17 -0
- package/dist/components/PricingBillingToggle.d.ts +23 -0
- package/dist/components/PricingBillingToggle.js +86 -0
- package/dist/components/PricingConfirmationDialog.d.ts +25 -0
- package/dist/components/PricingConfirmationDialog.js +57 -0
- package/dist/components/PricingFAQ.d.ts +18 -0
- package/dist/components/PricingFAQ.js +27 -0
- package/dist/components/PricingPage.d.ts +2 -38
- package/dist/components/PricingPage.js +39 -359
- package/dist/components/PricingPlanCard.d.ts +22 -0
- package/dist/components/PricingPlanCard.js +109 -0
- package/dist/components/PricingUsageCalculator.d.ts +22 -0
- package/dist/components/PricingUsageCalculator.js +96 -0
- package/dist/components/PromptInput.d.ts +2 -2
- package/dist/components/PromptInput.js +210 -15
- package/dist/components/Queue.js +1 -1
- package/dist/components/Reasoning.d.ts +2 -1
- package/dist/components/Reasoning.js +14 -29
- package/dist/components/ResizableSidePanel.d.ts +57 -0
- package/dist/components/ResizableSidePanel.js +151 -0
- package/dist/components/ResponsiveSidebarShell.d.ts +2 -0
- package/dist/components/ResponsiveSidebarShell.js +129 -0
- package/dist/components/Select.d.ts +2 -2
- package/dist/components/Select.js +11 -2
- package/dist/components/Slider.d.ts +13 -1
- package/dist/components/Slider.js +11 -0
- package/dist/components/Sources.js +1 -1
- package/dist/components/Stepper.d.ts +4 -0
- package/dist/components/Stepper.js +5 -3
- package/dist/components/SubagentRun.d.ts +18 -19
- package/dist/components/SubagentRun.js +25 -18
- package/dist/components/SubagentRunIndicator.d.ts +22 -0
- package/dist/components/SubagentRunIndicator.js +33 -0
- package/dist/components/SubagentRunList.d.ts +25 -0
- package/dist/components/SubagentRunList.js +26 -0
- package/dist/components/SubagentRunSelector.d.ts +47 -0
- package/dist/components/SubagentRunSelector.js +55 -0
- package/dist/components/Task.js +1 -1
- package/dist/components/Terminal.js +2 -2
- package/dist/components/TestResults.js +1 -1
- package/dist/components/Textarea.d.ts +21 -0
- package/dist/components/Textarea.js +19 -0
- package/dist/components/ThemeModeControl.d.ts +24 -0
- package/dist/components/ThemeModeControl.js +52 -0
- package/dist/components/ThemeProvider.d.ts +38 -0
- package/dist/components/ThemeProvider.js +80 -0
- package/dist/components/ThinkChat.d.ts +29 -6
- package/dist/components/ThinkChat.js +7 -4
- package/dist/components/ThinkChatActivity.d.ts +3 -2
- package/dist/components/ThinkChatActivity.js +12 -318
- package/dist/components/ThinkChatActivitySummary.d.ts +2 -0
- package/dist/components/ThinkChatActivitySummary.js +421 -0
- package/dist/components/ThinkChatToolPanels.d.ts +7 -5
- package/dist/components/ThinkChatToolPanels.js +70 -8
- package/dist/components/ThinkChatToolParts.d.ts +2 -2
- package/dist/components/ThinkChatToolParts.js +36 -10
- package/dist/components/ThinkExecutionDetail.d.ts +20 -0
- package/dist/components/ThinkExecutionDetail.js +80 -0
- package/dist/components/ThinkExecutionRun.d.ts +2 -0
- package/dist/components/ThinkExecutionRun.js +72 -0
- package/dist/components/ThinkExecutionStatus.d.ts +22 -0
- package/dist/components/ThinkExecutionStatus.js +36 -0
- package/dist/components/ThinkExecutionWorkbench.d.ts +7 -0
- package/dist/components/ThinkExecutionWorkbench.js +69 -225
- package/dist/components/ThinkFullApp.d.ts +58 -14
- package/dist/components/ThinkFullApp.js +154 -160
- package/dist/components/ThinkFullAppViewSwitch.d.ts +31 -0
- package/dist/components/ThinkFullAppViewSwitch.js +34 -0
- package/dist/components/ThinkRoutine.d.ts +36 -0
- package/dist/components/ThinkRoutine.js +15 -0
- package/dist/components/ThinkRoutineBrowser.d.ts +25 -0
- package/dist/components/ThinkRoutineBrowser.js +156 -0
- package/dist/components/ThinkRoutineDetail.d.ts +24 -0
- package/dist/components/ThinkRoutineDetail.js +102 -0
- package/dist/components/ThinkRoutineForm.d.ts +32 -0
- package/dist/components/ThinkRoutineForm.js +151 -0
- package/dist/components/ThinkRoutineLibrary.d.ts +74 -0
- package/dist/components/ThinkRoutineLibrary.js +178 -0
- package/dist/components/ThinkRoutineRuns.d.ts +24 -0
- package/dist/components/ThinkRoutineRuns.js +68 -0
- package/dist/components/ThinkThreadPicker.d.ts +18 -1
- package/dist/components/ThinkThreadPicker.js +51 -5
- package/dist/components/ThinkThreadShell.d.ts +12 -9
- package/dist/components/ThinkThreadShell.js +17 -137
- package/dist/components/Toggle.d.ts +1 -68
- package/dist/components/ToggleGroup.d.ts +1 -72
- package/dist/components/Tooltip.d.ts +3 -1
- package/dist/components/Tooltip.js +4 -2
- package/dist/components/WebPreview.js +1 -1
- package/dist/components/Workspace.d.ts +2 -0
- package/dist/components/Workspace.js +424 -0
- package/dist/components/WorkspaceBrowser.d.ts +32 -0
- package/dist/components/WorkspaceBrowser.js +103 -0
- package/dist/components/WorkspaceExplorer.d.ts +12 -79
- package/dist/components/WorkspaceExplorer.js +116 -330
- package/dist/components/WorkspaceFile.d.ts +2 -0
- package/dist/components/WorkspaceFile.js +195 -0
- package/dist/components/WorkspaceFileView.d.ts +26 -0
- package/dist/components/WorkspaceFileView.js +2 -0
- package/dist/components/WorkspaceHeader.d.ts +35 -0
- package/dist/components/WorkspaceHeader.js +51 -0
- package/dist/components/WorkspaceLink.d.ts +2 -0
- package/dist/components/WorkspaceLink.js +2 -0
- package/dist/components/icons.d.ts +2 -2
- package/dist/components/icons.js +2 -2
- package/dist/{copy-button-DUMLYdsk.js → copy-button-Dejn5heL.js} +1 -1
- package/dist/icons-CpfUer49.js +85 -0
- package/dist/{icons-CUCz_Sft.d.ts → icons-GQd1xF4e.d.ts} +51 -1
- package/dist/styles/activity-header.css +75 -0
- package/dist/styles/activity.css +49 -63
- package/dist/styles/agent-activity-preview-overlay.css +80 -0
- package/dist/styles/agent-activity-preview.css +233 -0
- package/dist/styles/agent-attention.css +128 -0
- package/dist/styles/agent-chat.css +133 -4
- package/dist/styles/agent-connection.css +9 -9
- package/dist/styles/alert-dialog.css +11 -11
- package/dist/styles/app-frame.css +15 -0
- package/dist/styles/app-top-bar.css +102 -0
- package/dist/styles/avatar.css +0 -1
- package/dist/styles/browser-control-overlay.css +184 -0
- package/dist/styles/card.css +29 -8
- package/dist/styles/chain-of-thought.css +5 -5
- package/dist/styles/checkbox-group.css +69 -0
- package/dist/styles/codex-model-selector.css +3 -3
- package/dist/styles/combobox.css +2 -1
- package/dist/styles/context-menu.css +1 -1
- package/dist/styles/description-list.css +50 -0
- package/dist/styles/dialog.css +11 -11
- package/dist/styles/field.css +14 -14
- package/dist/styles/fieldset.css +15 -4
- package/dist/styles/index.css +14 -2
- package/dist/styles/mcp-connection-request.css +60 -0
- package/dist/styles/mcp-server-picker.css +96 -68
- package/dist/styles/menu.css +1 -1
- package/dist/styles/message.css +4 -43
- package/dist/styles/model-selector.css +18 -12
- package/dist/styles/popover.css +9 -9
- package/dist/styles/preview-card.css +1 -1
- package/dist/styles/pricing-page.css +21 -27
- package/dist/styles/prompt-input.css +225 -32
- package/dist/styles/reasoning.css +1 -55
- package/dist/styles/recipes.css +50 -24
- package/dist/styles/resizable-side-panel.css +66 -0
- package/dist/styles/responsive-sidebar-shell.css +169 -0
- package/dist/styles/select.css +13 -3
- package/dist/styles/sources.css +6 -6
- package/dist/styles/stepper.css +13 -0
- package/dist/styles/streamdown.css +0 -4
- package/dist/styles/subagent-run.css +59 -42
- package/dist/styles/task.css +17 -10
- package/dist/styles/test-results.css +17 -10
- package/dist/styles/textarea.css +20 -0
- package/dist/styles/theme-mode-control.css +72 -0
- package/dist/styles/think-execution-status.css +49 -0
- package/dist/styles/think-execution-workbench.css +16 -80
- package/dist/styles/think-full-app.css +143 -128
- package/dist/styles/think-routine-library.css +491 -0
- package/dist/styles/think-thread-picker.css +47 -3
- package/dist/styles/toast.css +6 -6
- package/dist/styles/toggle-group.css +7 -0
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/workspace-explorer.css +516 -64
- package/dist/utils/mcp-server-catalog.d.ts +82 -78
- package/dist/utils/mcp-server-catalog.js +64 -41
- package/dist/utils/structured-code.d.ts +1 -1
- package/dist/utils/theme.d.ts +22 -0
- package/dist/utils/theme.js +55 -0
- package/package.json +34 -28
- package/dist/icons-Ba9THQKz.js +0 -64
- package/dist/styles/think-resize-handle.css +0 -33
- package/dist/styles/think-thread-shell.css +0 -219
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
import { g as EyeIcon, m as DownloadIcon, o as CheckIcon, q as WarningIcon, u as CodeIcon, w as MaximizeIcon } from "./icons-CpfUer49.js";
|
|
2
|
+
import { c as useWorkspaceNavigationContext, s as useWorkspaceNavigationRestoration } from "./WorkspaceLink-DIPbXrUM.js";
|
|
3
|
+
import { f as MessageResponse, m as createWorkspaceRehypePlugins } from "./Message-BkMdE3bS.js";
|
|
4
|
+
import { a as CodeBlockCopyButton, i as CodeBlockContent, r as CodeBlockContainer, t as CodeBlock } from "./CodeBlock-BmB4Xaqq.js";
|
|
5
|
+
import { AppTopBar } from "./components/AppTopBar.js";
|
|
6
|
+
import { WorkspaceHeader } from "./components/WorkspaceHeader.js";
|
|
7
|
+
import { inferWorkspaceLanguage, inferWorkspaceMedia, isWorkspaceMarkdownPath, isWorkspaceSkillPath, parseWorkspaceSkill } from "./components/WorkspaceFile.js";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { defaultRehypePlugins } from "streamdown";
|
|
11
|
+
import rehypeSlug from "rehype-slug";
|
|
12
|
+
import Lightbox from "yet-another-react-lightbox";
|
|
13
|
+
import Fullscreen from "yet-another-react-lightbox/plugins/fullscreen";
|
|
14
|
+
import Zoom from "yet-another-react-lightbox/plugins/zoom";
|
|
15
|
+
//#region src/components/_internal/workspace-media-preview.tsx
|
|
16
|
+
const lightboxPlugins = [Zoom, Fullscreen];
|
|
17
|
+
const allowedAssetProtocols = /* @__PURE__ */ new Set([
|
|
18
|
+
"http:",
|
|
19
|
+
"https:",
|
|
20
|
+
"blob:"
|
|
21
|
+
]);
|
|
22
|
+
const SVG_MIME_TYPE = "image/svg+xml";
|
|
23
|
+
const lightboxThemeProperties = [
|
|
24
|
+
"--sigvelo-color-surface",
|
|
25
|
+
"--sigvelo-color-text",
|
|
26
|
+
"--sigvelo-color-text-muted",
|
|
27
|
+
"--sigvelo-color-neutral-border-subtle",
|
|
28
|
+
"--sigvelo-border-style",
|
|
29
|
+
"--sigvelo-border-width",
|
|
30
|
+
"--sigvelo-spacing-1",
|
|
31
|
+
"--sigvelo-spacing-2",
|
|
32
|
+
"--sigvelo-radius-md",
|
|
33
|
+
"--sigvelo-focus-ring",
|
|
34
|
+
"--sigvelo-focus-offset"
|
|
35
|
+
];
|
|
36
|
+
function safeAssetUrl(value) {
|
|
37
|
+
if (!value?.trim()) return null;
|
|
38
|
+
try {
|
|
39
|
+
const parsed = new URL(value, "https://workspace.invalid/");
|
|
40
|
+
return allowedAssetProtocols.has(parsed.protocol) ? value : null;
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function toBlobPart(data) {
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
function resolveLightboxTheme(element) {
|
|
49
|
+
const computedStyle = getComputedStyle(element);
|
|
50
|
+
return {
|
|
51
|
+
colorScheme: computedStyle.colorScheme,
|
|
52
|
+
...Object.fromEntries(lightboxThemeProperties.map((property) => [property, computedStyle.getPropertyValue(property)]))
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Create component-owned object URLs for bytes and revoke them on replacement. */
|
|
56
|
+
function useWorkspaceAssetUrl(asset, mimeType) {
|
|
57
|
+
const [objectUrl, setObjectUrl] = React.useState(null);
|
|
58
|
+
const assetTokensRef = React.useRef(/* @__PURE__ */ new WeakMap());
|
|
59
|
+
const nextAssetTokenRef = React.useRef(0);
|
|
60
|
+
let assetToken = null;
|
|
61
|
+
if (asset?.kind === "data") {
|
|
62
|
+
assetToken = assetTokensRef.current.get(asset) ?? null;
|
|
63
|
+
if (assetToken === null) {
|
|
64
|
+
assetToken = nextAssetTokenRef.current + 1;
|
|
65
|
+
nextAssetTokenRef.current = assetToken;
|
|
66
|
+
assetTokensRef.current.set(asset, assetToken);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
if (!asset || asset.kind !== "data" || assetToken === null) {
|
|
71
|
+
setObjectUrl(null);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (typeof URL === "undefined" || typeof URL.createObjectURL !== "function" || typeof Blob === "undefined") {
|
|
75
|
+
setObjectUrl({
|
|
76
|
+
token: assetToken,
|
|
77
|
+
url: null,
|
|
78
|
+
downloadUrl: null,
|
|
79
|
+
error: "This browser cannot prepare a local preview."
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
let url = null;
|
|
84
|
+
let downloadUrl = null;
|
|
85
|
+
try {
|
|
86
|
+
const previewBlob = new Blob([toBlobPart(asset.data)], { type: mimeType });
|
|
87
|
+
url = URL.createObjectURL(previewBlob);
|
|
88
|
+
downloadUrl = mimeType === SVG_MIME_TYPE ? URL.createObjectURL(new Blob([previewBlob], { type: "application/octet-stream" })) : url;
|
|
89
|
+
setObjectUrl({
|
|
90
|
+
token: assetToken,
|
|
91
|
+
url,
|
|
92
|
+
downloadUrl,
|
|
93
|
+
error: null
|
|
94
|
+
});
|
|
95
|
+
} catch {
|
|
96
|
+
if (url) URL.revokeObjectURL(url);
|
|
97
|
+
if (downloadUrl && downloadUrl !== url) URL.revokeObjectURL(downloadUrl);
|
|
98
|
+
setObjectUrl({
|
|
99
|
+
token: assetToken,
|
|
100
|
+
url: null,
|
|
101
|
+
downloadUrl: null,
|
|
102
|
+
error: "This file could not be prepared for preview."
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return () => {
|
|
107
|
+
if (url) URL.revokeObjectURL(url);
|
|
108
|
+
if (downloadUrl && downloadUrl !== url) URL.revokeObjectURL(downloadUrl);
|
|
109
|
+
};
|
|
110
|
+
}, [
|
|
111
|
+
asset,
|
|
112
|
+
assetToken,
|
|
113
|
+
mimeType
|
|
114
|
+
]);
|
|
115
|
+
if (!asset) return {
|
|
116
|
+
url: null,
|
|
117
|
+
downloadUrl: null,
|
|
118
|
+
error: null
|
|
119
|
+
};
|
|
120
|
+
if (asset.kind === "url") {
|
|
121
|
+
const url = safeAssetUrl(asset.url);
|
|
122
|
+
return {
|
|
123
|
+
url,
|
|
124
|
+
downloadUrl: safeAssetUrl(asset.downloadUrl),
|
|
125
|
+
error: url ? null : "The host returned an unsupported asset URL."
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (assetToken === null || objectUrl?.token !== assetToken) return {
|
|
129
|
+
url: null,
|
|
130
|
+
downloadUrl: null,
|
|
131
|
+
error: null
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
url: objectUrl.url,
|
|
135
|
+
downloadUrl: objectUrl.downloadUrl,
|
|
136
|
+
error: objectUrl.error
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function WorkspaceAssetActions({ fileName, url, downloadUrl, allowOpen = true }) {
|
|
140
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [allowOpen ? /* @__PURE__ */ jsx(AppTopBar.Button, {
|
|
141
|
+
label: `Open ${fileName} in a new tab`,
|
|
142
|
+
nativeButton: false,
|
|
143
|
+
render: /* @__PURE__ */ jsx("a", {
|
|
144
|
+
href: url,
|
|
145
|
+
target: "_blank",
|
|
146
|
+
rel: "noreferrer"
|
|
147
|
+
}),
|
|
148
|
+
children: /* @__PURE__ */ jsx(MaximizeIcon, { "aria-hidden": "true" })
|
|
149
|
+
}) : null, downloadUrl ? /* @__PURE__ */ jsx(AppTopBar.Button, {
|
|
150
|
+
label: `Download ${fileName}`,
|
|
151
|
+
nativeButton: false,
|
|
152
|
+
render: /* @__PURE__ */ jsx("a", {
|
|
153
|
+
href: downloadUrl,
|
|
154
|
+
download: fileName,
|
|
155
|
+
rel: "noreferrer"
|
|
156
|
+
}),
|
|
157
|
+
children: /* @__PURE__ */ jsx(DownloadIcon, { "aria-hidden": "true" })
|
|
158
|
+
}) : null] });
|
|
159
|
+
}
|
|
160
|
+
function formatBytes(size) {
|
|
161
|
+
if (size < 1024) return `${size} ${size === 1 ? "byte" : "bytes"}`;
|
|
162
|
+
const units = [
|
|
163
|
+
"KB",
|
|
164
|
+
"MB",
|
|
165
|
+
"GB",
|
|
166
|
+
"TB"
|
|
167
|
+
];
|
|
168
|
+
let value = size / 1024;
|
|
169
|
+
let unit = units[0];
|
|
170
|
+
for (let index = 1; index < units.length && value >= 1024; index += 1) {
|
|
171
|
+
value /= 1024;
|
|
172
|
+
unit = units[index];
|
|
173
|
+
}
|
|
174
|
+
return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)} ${unit}`;
|
|
175
|
+
}
|
|
176
|
+
function formatDuration(duration) {
|
|
177
|
+
const seconds = Math.max(0, Math.round(duration));
|
|
178
|
+
const hours = Math.floor(seconds / 3600);
|
|
179
|
+
const minutes = Math.floor(seconds % 3600 / 60);
|
|
180
|
+
const remainder = seconds % 60;
|
|
181
|
+
return hours > 0 ? `${hours}:${String(minutes).padStart(2, "0")}:${String(remainder).padStart(2, "0")}` : `${minutes}:${String(remainder).padStart(2, "0")}`;
|
|
182
|
+
}
|
|
183
|
+
function WorkspaceMediaDetails({ mimeType, size, dimensions, dimensionsPending = false, duration, durationPending = false, transcriptUrl }) {
|
|
184
|
+
const dimensionValue = dimensionsPending ? "Loading…" : dimensions ? `${dimensions.width} × ${dimensions.height} px` : null;
|
|
185
|
+
const durationValue = durationPending ? "Loading…" : duration !== void 0 && duration !== null ? formatDuration(duration) : null;
|
|
186
|
+
return /* @__PURE__ */ jsxs("figcaption", {
|
|
187
|
+
className: "workspace-explorer__media-caption",
|
|
188
|
+
children: [/* @__PURE__ */ jsxs("dl", {
|
|
189
|
+
className: "workspace-explorer__media-details",
|
|
190
|
+
children: [
|
|
191
|
+
dimensionValue ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Dimensions" }), /* @__PURE__ */ jsx("dd", { children: dimensionValue })] }) : null,
|
|
192
|
+
durationValue ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Duration" }), /* @__PURE__ */ jsx("dd", { children: durationValue })] }) : null,
|
|
193
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Type" }), /* @__PURE__ */ jsx("dd", { children: mimeType })] }),
|
|
194
|
+
size !== void 0 ? /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("dt", { children: "Size" }), /* @__PURE__ */ jsx("dd", { children: formatBytes(size) })] }) : null
|
|
195
|
+
]
|
|
196
|
+
}), transcriptUrl ? /* @__PURE__ */ jsx("a", {
|
|
197
|
+
className: "workspace-explorer__media-transcript",
|
|
198
|
+
href: transcriptUrl,
|
|
199
|
+
target: "_blank",
|
|
200
|
+
rel: "noreferrer",
|
|
201
|
+
children: "Open transcript"
|
|
202
|
+
}) : null]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function safeTracks(tracks) {
|
|
206
|
+
return tracks?.filter((track) => safeAssetUrl(track.src)) ?? [];
|
|
207
|
+
}
|
|
208
|
+
function WorkspaceMediaError({ active, children }) {
|
|
209
|
+
return /* @__PURE__ */ jsx("div", {
|
|
210
|
+
className: "workspace-explorer__media-error",
|
|
211
|
+
role: "status",
|
|
212
|
+
"aria-live": "polite",
|
|
213
|
+
"aria-atomic": "true",
|
|
214
|
+
children: active ? children : null
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function WorkspaceImagePreview({ asset, fileName, media, url }) {
|
|
218
|
+
const [open, setOpen] = React.useState(false);
|
|
219
|
+
const [dimensions, setDimensions] = React.useState(null);
|
|
220
|
+
const [hasLoaded, setHasLoaded] = React.useState(false);
|
|
221
|
+
const [loadFailed, setLoadFailed] = React.useState(false);
|
|
222
|
+
const figureRef = React.useRef(null);
|
|
223
|
+
const [lightboxTheme, setLightboxTheme] = React.useState();
|
|
224
|
+
React.useEffect(() => {
|
|
225
|
+
setDimensions(null);
|
|
226
|
+
setHasLoaded(false);
|
|
227
|
+
setLoadFailed(false);
|
|
228
|
+
setOpen(false);
|
|
229
|
+
}, [url]);
|
|
230
|
+
const alt = asset.alt?.trim() || fileName;
|
|
231
|
+
const slide = {
|
|
232
|
+
src: url,
|
|
233
|
+
alt,
|
|
234
|
+
width: dimensions?.width,
|
|
235
|
+
height: dimensions?.height
|
|
236
|
+
};
|
|
237
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
238
|
+
ref: figureRef,
|
|
239
|
+
className: "workspace-explorer__media-figure workspace-explorer__media-figure--image",
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsxs("div", {
|
|
242
|
+
className: "workspace-explorer__media-stage",
|
|
243
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
244
|
+
className: "workspace-explorer__image-trigger",
|
|
245
|
+
type: "button",
|
|
246
|
+
"aria-label": loadFailed ? `${fileName} image preview unavailable` : `Open ${fileName} image viewer`,
|
|
247
|
+
"aria-disabled": loadFailed || void 0,
|
|
248
|
+
onClick: () => {
|
|
249
|
+
if (!loadFailed) {
|
|
250
|
+
if (figureRef.current) setLightboxTheme(resolveLightboxTheme(figureRef.current));
|
|
251
|
+
setOpen(true);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
children: loadFailed ? /* @__PURE__ */ jsx("span", {
|
|
255
|
+
className: "workspace-explorer__media-error",
|
|
256
|
+
"aria-hidden": "true",
|
|
257
|
+
children: "This image could not be decoded by the browser."
|
|
258
|
+
}) : /* @__PURE__ */ jsx("img", {
|
|
259
|
+
className: "workspace-explorer__image",
|
|
260
|
+
src: url,
|
|
261
|
+
alt,
|
|
262
|
+
role: "img",
|
|
263
|
+
width: dimensions?.width,
|
|
264
|
+
height: dimensions?.height,
|
|
265
|
+
onLoad: (event) => {
|
|
266
|
+
const { naturalWidth: width, naturalHeight: height } = event.currentTarget;
|
|
267
|
+
setHasLoaded(true);
|
|
268
|
+
setDimensions(width > 0 && height > 0 ? {
|
|
269
|
+
width,
|
|
270
|
+
height
|
|
271
|
+
} : null);
|
|
272
|
+
},
|
|
273
|
+
onError: () => setLoadFailed(true)
|
|
274
|
+
})
|
|
275
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
276
|
+
className: "workspace-explorer__visually-hidden",
|
|
277
|
+
role: "status",
|
|
278
|
+
"aria-live": "polite",
|
|
279
|
+
"aria-atomic": "true",
|
|
280
|
+
children: loadFailed ? `The ${fileName} image preview could not be decoded.` : null
|
|
281
|
+
})]
|
|
282
|
+
}),
|
|
283
|
+
/* @__PURE__ */ jsx(Lightbox, {
|
|
284
|
+
className: "workspace-media-lightbox",
|
|
285
|
+
open,
|
|
286
|
+
close: () => setOpen(false),
|
|
287
|
+
slides: [slide],
|
|
288
|
+
plugins: lightboxPlugins,
|
|
289
|
+
labels: { Lightbox: `${fileName} image viewer` },
|
|
290
|
+
carousel: {
|
|
291
|
+
finite: true,
|
|
292
|
+
imageFit: "contain"
|
|
293
|
+
},
|
|
294
|
+
controller: {
|
|
295
|
+
closeOnBackdropClick: true,
|
|
296
|
+
disableSwipeNavigation: true
|
|
297
|
+
},
|
|
298
|
+
render: {
|
|
299
|
+
buttonPrev: () => null,
|
|
300
|
+
buttonNext: () => null
|
|
301
|
+
},
|
|
302
|
+
styles: { root: lightboxTheme },
|
|
303
|
+
zoom: { scrollToZoom: true }
|
|
304
|
+
}),
|
|
305
|
+
/* @__PURE__ */ jsx(WorkspaceMediaDetails, {
|
|
306
|
+
mimeType: media.mimeType,
|
|
307
|
+
size: asset.size,
|
|
308
|
+
dimensions,
|
|
309
|
+
dimensionsPending: !loadFailed && !hasLoaded
|
|
310
|
+
})
|
|
311
|
+
]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function WorkspacePdfPreview({ asset, fileName, media, url, downloadUrl }) {
|
|
315
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
316
|
+
className: "workspace-explorer__media-figure workspace-explorer__media-figure--document",
|
|
317
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
318
|
+
className: "workspace-explorer__media-stage",
|
|
319
|
+
children: /* @__PURE__ */ jsx("object", {
|
|
320
|
+
className: "workspace-explorer__pdf",
|
|
321
|
+
data: url,
|
|
322
|
+
type: "application/pdf",
|
|
323
|
+
"aria-label": `PDF preview: ${fileName}`,
|
|
324
|
+
children: /* @__PURE__ */ jsxs("p", {
|
|
325
|
+
className: "workspace-explorer__media-fallback",
|
|
326
|
+
children: [
|
|
327
|
+
"PDF preview is unavailable.",
|
|
328
|
+
" ",
|
|
329
|
+
/* @__PURE__ */ jsxs("a", {
|
|
330
|
+
href: url,
|
|
331
|
+
target: "_blank",
|
|
332
|
+
rel: "noreferrer",
|
|
333
|
+
children: ["Open ", fileName]
|
|
334
|
+
}),
|
|
335
|
+
downloadUrl ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
336
|
+
" ",
|
|
337
|
+
"or",
|
|
338
|
+
" ",
|
|
339
|
+
/* @__PURE__ */ jsx("a", {
|
|
340
|
+
href: downloadUrl,
|
|
341
|
+
download: fileName,
|
|
342
|
+
children: "download it"
|
|
343
|
+
})
|
|
344
|
+
] }) : null,
|
|
345
|
+
"."
|
|
346
|
+
]
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
}), /* @__PURE__ */ jsx(WorkspaceMediaDetails, {
|
|
350
|
+
mimeType: media.mimeType,
|
|
351
|
+
size: asset.size
|
|
352
|
+
})]
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function WorkspaceAudioPreview({ asset, fileName, media, url }) {
|
|
356
|
+
const [duration, setDuration] = React.useState(null);
|
|
357
|
+
const [metadataLoaded, setMetadataLoaded] = React.useState(false);
|
|
358
|
+
const [loadFailed, setLoadFailed] = React.useState(false);
|
|
359
|
+
const tracks = safeTracks(asset.tracks);
|
|
360
|
+
const transcriptUrl = safeAssetUrl(asset.transcriptUrl);
|
|
361
|
+
React.useEffect(() => {
|
|
362
|
+
setDuration(null);
|
|
363
|
+
setMetadataLoaded(false);
|
|
364
|
+
setLoadFailed(false);
|
|
365
|
+
}, [url]);
|
|
366
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
367
|
+
className: "workspace-explorer__media-figure workspace-explorer__media-figure--audio",
|
|
368
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
369
|
+
className: "workspace-explorer__media-stage",
|
|
370
|
+
children: [/* @__PURE__ */ jsxs("audio", {
|
|
371
|
+
className: "workspace-explorer__audio",
|
|
372
|
+
controls: true,
|
|
373
|
+
preload: "metadata",
|
|
374
|
+
crossOrigin: asset.crossOrigin,
|
|
375
|
+
"aria-label": `Audio preview: ${fileName}`,
|
|
376
|
+
onLoadedMetadata: (event) => {
|
|
377
|
+
const nextDuration = event.currentTarget.duration;
|
|
378
|
+
setMetadataLoaded(true);
|
|
379
|
+
setDuration(Number.isFinite(nextDuration) ? nextDuration : null);
|
|
380
|
+
},
|
|
381
|
+
onError: () => setLoadFailed(true),
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ jsx("source", {
|
|
384
|
+
src: url,
|
|
385
|
+
type: media.mimeType
|
|
386
|
+
}),
|
|
387
|
+
tracks.map((track) => /* @__PURE__ */ jsx("track", {
|
|
388
|
+
src: track.src,
|
|
389
|
+
kind: track.kind,
|
|
390
|
+
srcLang: track.srcLang,
|
|
391
|
+
label: track.label,
|
|
392
|
+
default: track.default
|
|
393
|
+
}, `${track.kind}:${track.srcLang}:${track.src}`)),
|
|
394
|
+
/* @__PURE__ */ jsxs("a", {
|
|
395
|
+
href: url,
|
|
396
|
+
children: ["Open ", fileName]
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
}, url), /* @__PURE__ */ jsx(WorkspaceMediaError, {
|
|
400
|
+
active: loadFailed,
|
|
401
|
+
children: "This audio format could not be played by the browser."
|
|
402
|
+
})]
|
|
403
|
+
}), /* @__PURE__ */ jsx(WorkspaceMediaDetails, {
|
|
404
|
+
mimeType: media.mimeType,
|
|
405
|
+
size: asset.size,
|
|
406
|
+
duration,
|
|
407
|
+
durationPending: !loadFailed && !metadataLoaded,
|
|
408
|
+
transcriptUrl
|
|
409
|
+
})]
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function WorkspaceVideoPreview({ asset, fileName, media, url }) {
|
|
413
|
+
const [duration, setDuration] = React.useState(null);
|
|
414
|
+
const [dimensions, setDimensions] = React.useState(null);
|
|
415
|
+
const [metadataLoaded, setMetadataLoaded] = React.useState(false);
|
|
416
|
+
const [loadFailed, setLoadFailed] = React.useState(false);
|
|
417
|
+
const tracks = safeTracks(asset.tracks);
|
|
418
|
+
const posterUrl = safeAssetUrl(asset.posterUrl) ?? void 0;
|
|
419
|
+
const transcriptUrl = safeAssetUrl(asset.transcriptUrl);
|
|
420
|
+
React.useEffect(() => {
|
|
421
|
+
setDuration(null);
|
|
422
|
+
setDimensions(null);
|
|
423
|
+
setMetadataLoaded(false);
|
|
424
|
+
setLoadFailed(false);
|
|
425
|
+
}, [url]);
|
|
426
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
427
|
+
className: "workspace-explorer__media-figure workspace-explorer__media-figure--video",
|
|
428
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
429
|
+
className: "workspace-explorer__media-stage",
|
|
430
|
+
children: [/* @__PURE__ */ jsxs("video", {
|
|
431
|
+
className: "workspace-explorer__video",
|
|
432
|
+
controls: true,
|
|
433
|
+
preload: "metadata",
|
|
434
|
+
playsInline: true,
|
|
435
|
+
crossOrigin: asset.crossOrigin,
|
|
436
|
+
poster: posterUrl,
|
|
437
|
+
width: dimensions?.width,
|
|
438
|
+
height: dimensions?.height,
|
|
439
|
+
"aria-label": `Video preview: ${fileName}`,
|
|
440
|
+
onLoadedMetadata: (event) => {
|
|
441
|
+
const video = event.currentTarget;
|
|
442
|
+
setMetadataLoaded(true);
|
|
443
|
+
setDuration(Number.isFinite(video.duration) ? video.duration : null);
|
|
444
|
+
setDimensions(video.videoWidth > 0 && video.videoHeight > 0 ? {
|
|
445
|
+
width: video.videoWidth,
|
|
446
|
+
height: video.videoHeight
|
|
447
|
+
} : null);
|
|
448
|
+
},
|
|
449
|
+
onError: () => setLoadFailed(true),
|
|
450
|
+
children: [
|
|
451
|
+
/* @__PURE__ */ jsx("source", {
|
|
452
|
+
src: url,
|
|
453
|
+
type: media.mimeType
|
|
454
|
+
}),
|
|
455
|
+
tracks.map((track) => /* @__PURE__ */ jsx("track", {
|
|
456
|
+
src: track.src,
|
|
457
|
+
kind: track.kind,
|
|
458
|
+
srcLang: track.srcLang,
|
|
459
|
+
label: track.label,
|
|
460
|
+
default: track.default
|
|
461
|
+
}, `${track.kind}:${track.srcLang}:${track.src}`)),
|
|
462
|
+
/* @__PURE__ */ jsxs("a", {
|
|
463
|
+
href: url,
|
|
464
|
+
children: ["Open ", fileName]
|
|
465
|
+
})
|
|
466
|
+
]
|
|
467
|
+
}, url), /* @__PURE__ */ jsx(WorkspaceMediaError, {
|
|
468
|
+
active: loadFailed,
|
|
469
|
+
children: "This video format could not be played by the browser."
|
|
470
|
+
})]
|
|
471
|
+
}), /* @__PURE__ */ jsx(WorkspaceMediaDetails, {
|
|
472
|
+
mimeType: media.mimeType,
|
|
473
|
+
size: asset.size,
|
|
474
|
+
dimensions,
|
|
475
|
+
dimensionsPending: !loadFailed && !metadataLoaded,
|
|
476
|
+
duration,
|
|
477
|
+
durationPending: !loadFailed && !metadataLoaded,
|
|
478
|
+
transcriptUrl
|
|
479
|
+
})]
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
/** Finished workspace preview surface for one resolved media asset. */
|
|
483
|
+
function WorkspaceMediaPreview(props) {
|
|
484
|
+
const { onScroll } = props;
|
|
485
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
486
|
+
className: "workspace-explorer__media-scroll",
|
|
487
|
+
"data-workspace-focus-target": "",
|
|
488
|
+
"data-workspace-scroll": "",
|
|
489
|
+
onScroll,
|
|
490
|
+
tabIndex: -1,
|
|
491
|
+
children: [
|
|
492
|
+
props.media.kind === "image" ? /* @__PURE__ */ jsx(WorkspaceImagePreview, { ...props }) : null,
|
|
493
|
+
props.media.kind === "pdf" ? /* @__PURE__ */ jsx(WorkspacePdfPreview, { ...props }) : null,
|
|
494
|
+
props.media.kind === "audio" ? /* @__PURE__ */ jsx(WorkspaceAudioPreview, { ...props }) : null,
|
|
495
|
+
props.media.kind === "video" ? /* @__PURE__ */ jsx(WorkspaceVideoPreview, { ...props }) : null
|
|
496
|
+
]
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/components/WorkspaceFileView.tsx
|
|
501
|
+
function createFileViewRehypePlugins(workspace) {
|
|
502
|
+
return [...workspace ? createWorkspaceRehypePlugins(workspace.root, workspace.base) : Object.values(defaultRehypePlugins), rehypeSlug];
|
|
503
|
+
}
|
|
504
|
+
function createWorkspaceHeading(tag, prefix) {
|
|
505
|
+
const level = tag.slice(1);
|
|
506
|
+
return function WorkspaceHeading({ id, node: _node, ...props }) {
|
|
507
|
+
const fragment = typeof id === "string" ? id : void 0;
|
|
508
|
+
return React.createElement(tag, {
|
|
509
|
+
...props,
|
|
510
|
+
id: fragment ? `${prefix}-${fragment}` : void 0,
|
|
511
|
+
"data-streamdown": `heading-${level}`,
|
|
512
|
+
"data-workspace-fragment": fragment
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/** Full-boundary workspace file preview composed from CodeBlock and AppTopBar. */
|
|
517
|
+
function WorkspaceFileView({ file, path, isLoading, isRefreshing, leading, actions, onRefresh }) {
|
|
518
|
+
const [markdownView, setMarkdownView] = React.useState("preview");
|
|
519
|
+
const isMarkdown = isWorkspaceMarkdownPath(path);
|
|
520
|
+
const workspaceNavigation = useWorkspaceNavigationContext();
|
|
521
|
+
const restoration = useWorkspaceNavigationRestoration();
|
|
522
|
+
const currentEntry = workspaceNavigation?.navigation.current;
|
|
523
|
+
const currentDestination = currentEntry?.destination;
|
|
524
|
+
const fragment = currentDestination?.kind === "file" && currentDestination.path === path ? currentDestination.fragment : null;
|
|
525
|
+
const entryKey = currentEntry?.key ?? null;
|
|
526
|
+
const fileViewRef = React.useRef(null);
|
|
527
|
+
const scrollRef = React.useRef(null);
|
|
528
|
+
const handledFocusRequestRef = React.useRef(null);
|
|
529
|
+
const headingPrefix = React.useId().replaceAll(":", "");
|
|
530
|
+
const workspaceRehypePlugins = React.useMemo(() => createFileViewRehypePlugins(workspaceNavigation), [
|
|
531
|
+
workspaceNavigation?.base.kind,
|
|
532
|
+
workspaceNavigation?.base.path,
|
|
533
|
+
workspaceNavigation?.root
|
|
534
|
+
]);
|
|
535
|
+
const media = inferWorkspaceMedia(path, file?.asset?.mimeType ?? file?.info?.mimeType);
|
|
536
|
+
const assetUrl = useWorkspaceAssetUrl(file?.asset, media?.mimeType ?? "application/octet-stream");
|
|
537
|
+
const isPreparingAsset = Boolean(file?.asset && !assetUrl.url && !assetUrl.error);
|
|
538
|
+
const handleScroll = React.useCallback((event) => {
|
|
539
|
+
if (entryKey) restoration?.recordScroll(entryKey, event.currentTarget.scrollTop);
|
|
540
|
+
}, [entryKey, restoration]);
|
|
541
|
+
const markdownComponents = React.useMemo(() => ({
|
|
542
|
+
h1: createWorkspaceHeading("h1", headingPrefix),
|
|
543
|
+
h2: createWorkspaceHeading("h2", headingPrefix),
|
|
544
|
+
h3: createWorkspaceHeading("h3", headingPrefix),
|
|
545
|
+
h4: createWorkspaceHeading("h4", headingPrefix),
|
|
546
|
+
h5: createWorkspaceHeading("h5", headingPrefix),
|
|
547
|
+
h6: createWorkspaceHeading("h6", headingPrefix)
|
|
548
|
+
}), [headingPrefix]);
|
|
549
|
+
React.useEffect(() => {
|
|
550
|
+
setMarkdownView("preview");
|
|
551
|
+
}, [path]);
|
|
552
|
+
React.useEffect(() => {
|
|
553
|
+
if (!entryKey || isLoading || isPreparingAsset || !file) return;
|
|
554
|
+
const focusRequest = JSON.stringify([
|
|
555
|
+
entryKey,
|
|
556
|
+
path,
|
|
557
|
+
fragment
|
|
558
|
+
]);
|
|
559
|
+
if (handledFocusRequestRef.current === focusRequest) return;
|
|
560
|
+
const surface = fileViewRef.current;
|
|
561
|
+
if (!surface) return;
|
|
562
|
+
const saved = restoration?.get(entryKey);
|
|
563
|
+
const scrollSurface = surface.querySelector("[data-workspace-scroll]");
|
|
564
|
+
if (saved?.scrollTop !== void 0 && scrollSurface) scrollSurface.scrollTop = saved.scrollTop;
|
|
565
|
+
let target = null;
|
|
566
|
+
const focusDestination = saved?.focusDestination;
|
|
567
|
+
if (focusDestination && saved.focusScope !== "file") {
|
|
568
|
+
handledFocusRequestRef.current = focusRequest;
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (focusDestination?.kind === "file") target = [...surface.querySelectorAll("[data-workspace-link=\"file\"]")].find((candidate) => candidate.dataset.workspacePath === focusDestination.path && (candidate.dataset.workspaceDestinationFragment || null) === focusDestination.fragment) ?? null;
|
|
572
|
+
if (!target && fragment) target = [...surface.querySelectorAll("[data-workspace-fragment]")].find((candidate) => candidate.dataset.workspaceFragment === fragment) ?? null;
|
|
573
|
+
target ??= surface.querySelector("[data-streamdown=\"heading-1\"]");
|
|
574
|
+
target ??= surface.querySelector("[data-workspace-file-heading]");
|
|
575
|
+
target ??= surface.querySelector("[data-workspace-focus-target]");
|
|
576
|
+
target ??= surface.querySelector("article");
|
|
577
|
+
if (!target) return;
|
|
578
|
+
if (!target.matches("a, button, input, select, textarea")) target.tabIndex = -1;
|
|
579
|
+
if (saved?.scrollTop === void 0 && !saved?.focusDestination) target.scrollIntoView({ block: "start" });
|
|
580
|
+
target.focus({ preventScroll: true });
|
|
581
|
+
handledFocusRequestRef.current = focusRequest;
|
|
582
|
+
}, [
|
|
583
|
+
entryKey,
|
|
584
|
+
file,
|
|
585
|
+
fragment,
|
|
586
|
+
isLoading,
|
|
587
|
+
isPreparingAsset,
|
|
588
|
+
path,
|
|
589
|
+
restoration
|
|
590
|
+
]);
|
|
591
|
+
const assetActions = file?.asset && assetUrl.url ? /* @__PURE__ */ jsx(WorkspaceAssetActions, {
|
|
592
|
+
fileName: file.name,
|
|
593
|
+
url: assetUrl.url,
|
|
594
|
+
downloadUrl: assetUrl.downloadUrl,
|
|
595
|
+
allowOpen: media?.mimeType !== "image/svg+xml"
|
|
596
|
+
}) : null;
|
|
597
|
+
const headerProps = {
|
|
598
|
+
path,
|
|
599
|
+
leading,
|
|
600
|
+
actions: isMarkdown ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
601
|
+
actions,
|
|
602
|
+
assetActions,
|
|
603
|
+
/* @__PURE__ */ jsx(AppTopBar.Button, {
|
|
604
|
+
label: "Preview Markdown",
|
|
605
|
+
"aria-pressed": markdownView === "preview",
|
|
606
|
+
onClick: () => setMarkdownView("preview"),
|
|
607
|
+
children: /* @__PURE__ */ jsx(EyeIcon, { "aria-hidden": "true" })
|
|
608
|
+
}),
|
|
609
|
+
/* @__PURE__ */ jsx(AppTopBar.Button, {
|
|
610
|
+
label: "View Markdown source",
|
|
611
|
+
"aria-pressed": markdownView === "source",
|
|
612
|
+
onClick: () => setMarkdownView("source"),
|
|
613
|
+
children: /* @__PURE__ */ jsx(CodeIcon, { "aria-hidden": "true" })
|
|
614
|
+
})
|
|
615
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [actions, assetActions] }),
|
|
616
|
+
isRefreshing,
|
|
617
|
+
onBack: workspaceNavigation?.navigation.canGoBack ? () => workspaceNavigation.navigation.goBack() : void 0,
|
|
618
|
+
onForward: workspaceNavigation?.navigation.canGoForward ? () => workspaceNavigation.navigation.goForward() : void 0,
|
|
619
|
+
onRefresh
|
|
620
|
+
};
|
|
621
|
+
if (isLoading || !file || file.error || assetUrl.error || isPreparingAsset || file.asset && !media || !file.asset && (file.content === null || file.content.length === 0)) {
|
|
622
|
+
let message = "File preview is unavailable.";
|
|
623
|
+
let role;
|
|
624
|
+
if (isLoading) message = "Loading file...";
|
|
625
|
+
else if (file?.error) {
|
|
626
|
+
message = `Could not preview this file: ${file.error}`;
|
|
627
|
+
role = "alert";
|
|
628
|
+
} else if (assetUrl.error) {
|
|
629
|
+
message = `Could not preview this file: ${assetUrl.error}`;
|
|
630
|
+
role = "alert";
|
|
631
|
+
} else if (isPreparingAsset) message = "Preparing file preview...";
|
|
632
|
+
else if (file?.asset && !media) message = "This media type is not supported.";
|
|
633
|
+
else if (media && file?.asset === null) message = "This workspace source did not provide preview data for this file.";
|
|
634
|
+
else if (file?.content === null) message = "This file has no text preview.";
|
|
635
|
+
else if (file?.content.length === 0) message = "This file is empty.";
|
|
636
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
637
|
+
ref: fileViewRef,
|
|
638
|
+
className: "workspace-explorer__file",
|
|
639
|
+
"data-workspace-restoration-scope": "file",
|
|
640
|
+
children: [/* @__PURE__ */ jsx(WorkspaceHeader, { ...headerProps }), /* @__PURE__ */ jsx("div", {
|
|
641
|
+
className: "workspace-explorer__empty",
|
|
642
|
+
"data-workspace-focus-target": "",
|
|
643
|
+
role,
|
|
644
|
+
children: message
|
|
645
|
+
})]
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
if (file.asset && media && assetUrl.url) return /* @__PURE__ */ jsxs("div", {
|
|
649
|
+
ref: fileViewRef,
|
|
650
|
+
className: "workspace-explorer__file",
|
|
651
|
+
"data-workspace-restoration-scope": "file",
|
|
652
|
+
children: [/* @__PURE__ */ jsx(WorkspaceHeader, { ...headerProps }), /* @__PURE__ */ jsx(WorkspaceMediaPreview, {
|
|
653
|
+
asset: file.asset,
|
|
654
|
+
fileName: file.name,
|
|
655
|
+
media,
|
|
656
|
+
url: assetUrl.url,
|
|
657
|
+
downloadUrl: assetUrl.downloadUrl,
|
|
658
|
+
onScroll: handleScroll
|
|
659
|
+
})]
|
|
660
|
+
});
|
|
661
|
+
if (file.content === null) return null;
|
|
662
|
+
if (isMarkdown && markdownView === "preview") {
|
|
663
|
+
const skill = isWorkspaceSkillPath(file.path) ? parseWorkspaceSkill(file.content) : null;
|
|
664
|
+
const response = /* @__PURE__ */ jsx(MessageResponse, {
|
|
665
|
+
className: "workspace-explorer__markdown-content",
|
|
666
|
+
components: markdownComponents,
|
|
667
|
+
mode: "static",
|
|
668
|
+
rehypePlugins: workspaceRehypePlugins,
|
|
669
|
+
children: skill?.parsed?.body ?? file.content
|
|
670
|
+
}, path);
|
|
671
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
672
|
+
ref: fileViewRef,
|
|
673
|
+
className: "workspace-explorer__file",
|
|
674
|
+
"data-workspace-restoration-scope": "file",
|
|
675
|
+
children: [/* @__PURE__ */ jsx(WorkspaceHeader, { ...headerProps }), /* @__PURE__ */ jsx("div", {
|
|
676
|
+
ref: scrollRef,
|
|
677
|
+
className: "workspace-explorer__markdown-scroll",
|
|
678
|
+
"data-workspace-scroll": "",
|
|
679
|
+
onScroll: handleScroll,
|
|
680
|
+
children: /* @__PURE__ */ jsxs("article", {
|
|
681
|
+
className: "workspace-explorer__markdown",
|
|
682
|
+
children: [skill ? /* @__PURE__ */ jsxs("header", {
|
|
683
|
+
className: "workspace-explorer__skill",
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ jsx("div", {
|
|
686
|
+
className: "workspace-explorer__skill-kicker",
|
|
687
|
+
children: "Agent Skill"
|
|
688
|
+
}),
|
|
689
|
+
skill.parsed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
690
|
+
/* @__PURE__ */ jsx("p", {
|
|
691
|
+
className: "workspace-explorer__skill-name",
|
|
692
|
+
children: skill.parsed.properties.name
|
|
693
|
+
}),
|
|
694
|
+
/* @__PURE__ */ jsx("p", {
|
|
695
|
+
className: "workspace-explorer__skill-description",
|
|
696
|
+
children: skill.parsed.properties.description
|
|
697
|
+
}),
|
|
698
|
+
/* @__PURE__ */ jsxs("dl", {
|
|
699
|
+
className: "workspace-explorer__skill-metadata",
|
|
700
|
+
children: [skill.parsed.properties.compatibility ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: "Compatibility" }), /* @__PURE__ */ jsx("dd", { children: skill.parsed.properties.compatibility })] }) : null, skill.parsed.properties.allowedTools ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", { children: "Allowed tools" }), /* @__PURE__ */ jsx("dd", { children: skill.parsed.properties.allowedTools })] }) : null]
|
|
701
|
+
})
|
|
702
|
+
] }) : null,
|
|
703
|
+
/* @__PURE__ */ jsxs("div", {
|
|
704
|
+
className: "workspace-explorer__skill-status",
|
|
705
|
+
"data-invalid": skill.validationErrors.length > 0 ? "" : void 0,
|
|
706
|
+
children: [skill.validationErrors.length > 0 ? /* @__PURE__ */ jsx(WarningIcon, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(CheckIcon, { "aria-hidden": "true" }), skill.validationErrors.length > 0 ? `${skill.validationErrors.length.toLocaleString()} validation ${skill.validationErrors.length === 1 ? "issue" : "issues"}` : "Valid Agent Skill"]
|
|
707
|
+
}),
|
|
708
|
+
skill.validationErrors.length > 0 ? /* @__PURE__ */ jsx("ul", {
|
|
709
|
+
className: "workspace-explorer__skill-errors",
|
|
710
|
+
children: skill.validationErrors.map((error) => /* @__PURE__ */ jsx("li", { children: error }, error))
|
|
711
|
+
}) : null
|
|
712
|
+
]
|
|
713
|
+
}) : null, response]
|
|
714
|
+
})
|
|
715
|
+
})]
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
return /* @__PURE__ */ jsx("div", {
|
|
719
|
+
ref: fileViewRef,
|
|
720
|
+
className: "workspace-explorer__file",
|
|
721
|
+
"data-workspace-restoration-scope": "file",
|
|
722
|
+
children: /* @__PURE__ */ jsxs(CodeBlock, {
|
|
723
|
+
className: "workspace-explorer__code",
|
|
724
|
+
code: file.content,
|
|
725
|
+
"data-workspace-focus-target": "",
|
|
726
|
+
language: inferWorkspaceLanguage(file.path),
|
|
727
|
+
showLineNumbers: true,
|
|
728
|
+
children: [/* @__PURE__ */ jsx(WorkspaceHeader, {
|
|
729
|
+
...headerProps,
|
|
730
|
+
copyAction: /* @__PURE__ */ jsx(CodeBlockCopyButton, {
|
|
731
|
+
size: "icon-sm",
|
|
732
|
+
nativeButton: true,
|
|
733
|
+
render: /* @__PURE__ */ jsx(AppTopBar.Control, {})
|
|
734
|
+
})
|
|
735
|
+
}), /* @__PURE__ */ jsx(CodeBlockContainer, {
|
|
736
|
+
"data-workspace-scroll": "",
|
|
737
|
+
onScroll: handleScroll,
|
|
738
|
+
children: /* @__PURE__ */ jsx(CodeBlockContent, {})
|
|
739
|
+
})]
|
|
740
|
+
})
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
//#endregion
|
|
744
|
+
export { WorkspaceFileView as t };
|