symbiote-ui 0.3.0-alpha.4
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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/canvas/AutoLayout.js +731 -0
- package/canvas/Breadcrumb/Breadcrumb.css.js +75 -0
- package/canvas/Breadcrumb/Breadcrumb.js +96 -0
- package/canvas/Breadcrumb/Breadcrumb.tpl.js +7 -0
- package/canvas/CanvasConnectionRenderer.js +971 -0
- package/canvas/CanvasGraph/CanvasGraph.css.js +29 -0
- package/canvas/CanvasGraph/CanvasGraph.js +1697 -0
- package/canvas/CanvasGraph/CanvasGraphDrawState.js +280 -0
- package/canvas/CanvasGraph/CanvasGraphGeometry.js +194 -0
- package/canvas/CanvasViewport.js +550 -0
- package/canvas/ConnectionRenderer.js +1283 -0
- package/canvas/FlowSimulator.js +326 -0
- package/canvas/ForceLayout.js +226 -0
- package/canvas/ForceWorker.js +1303 -0
- package/canvas/FrameManager.js +223 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.css.js +136 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.js +129 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.tpl.js +12 -0
- package/canvas/GraphTabs/GraphTabs.css.js +101 -0
- package/canvas/GraphTabs/GraphTabs.js +189 -0
- package/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/canvas/LODManager.js +88 -0
- package/canvas/Minimap/Minimap.css.js +73 -0
- package/canvas/Minimap/Minimap.js +210 -0
- package/canvas/Minimap/Minimap.tpl.js +7 -0
- package/canvas/NodeCanvas/NodeCanvas.css.js +398 -0
- package/canvas/NodeCanvas/NodeCanvas.js +1499 -0
- package/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/canvas/NodeSearch/NodeSearch.js +140 -0
- package/canvas/NodeSearch/NodeSearch.tpl.js +25 -0
- package/canvas/NodeViewManager.js +748 -0
- package/canvas/PcbRouteDiagnostics.js +463 -0
- package/canvas/PcbRouter.js +1127 -0
- package/canvas/PinExpansion.js +134 -0
- package/canvas/PseudoConnection.js +84 -0
- package/canvas/SelectionSync.js +163 -0
- package/canvas/SubgraphManager.js +203 -0
- package/canvas/SubgraphRouter.js +452 -0
- package/canvas/ViewportActions.js +473 -0
- package/canvas/graph-explorer.js +339 -0
- package/canvas/graph-layout.js +148 -0
- package/canvas/graph-model.js +68 -0
- package/canvas/html-in-canvas.js +202 -0
- package/canvas/project-graph-builder.js +440 -0
- package/canvas/project-graph-model.js +183 -0
- package/chat/ChatComposer/ChatComposer.css.js +652 -0
- package/chat/ChatComposer/ChatComposer.js +304 -0
- package/chat/ChatList/ChatList.css.js +102 -0
- package/chat/ChatList/ChatList.js +99 -0
- package/chat/ChatList/ChatList.tpl.js +20 -0
- package/chat/ChatListItem/ChatListItem.css.js +117 -0
- package/chat/ChatListItem/ChatListItem.js +32 -0
- package/chat/ChatListItem/ChatListItem.tpl.js +17 -0
- package/chat/ChatMessageItem/ChatMessageItem.css.js +628 -0
- package/chat/ChatMessageItem/ChatMessageItem.js +156 -0
- package/chat/ChatSidebar/ChatSidebar.css.js +150 -0
- package/chat/ChatSidebar/ChatSidebar.js +230 -0
- package/chat/ChatSidebar/ChatSidebar.tpl.js +18 -0
- package/chat/ChatSidebar/constants.js +11 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.css.js +445 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.js +304 -0
- package/chat/ChatTranscript/ChatTranscript.css.js +90 -0
- package/chat/ChatTranscript/ChatTranscript.js +244 -0
- package/chat/chat-context.js +123 -0
- package/chat/message-model.js +156 -0
- package/cli.js +20 -0
- package/control/Button/Button.css.js +93 -0
- package/control/Button/Button.js +78 -0
- package/control/Button/Button.tpl.js +3 -0
- package/control/Field/Field.css.js +91 -0
- package/control/Field/Field.js +17 -0
- package/control/Field/Field.tpl.js +3 -0
- package/core/Connection.js +47 -0
- package/core/Editor.js +449 -0
- package/core/Frame.js +33 -0
- package/core/GraphMermaid.js +348 -0
- package/core/GraphText.js +228 -0
- package/core/Node.js +145 -0
- package/core/Portal.js +106 -0
- package/core/Socket.js +187 -0
- package/core/SubgraphNode.js +121 -0
- package/core/base-path.js +55 -0
- package/core/dom-utils.js +14 -0
- package/core/index.js +18 -0
- package/core/local-cache.js +26 -0
- package/core/state-sync.js +227 -0
- package/custom-elements.json +6380 -0
- package/discover.js +240 -0
- package/display/Badge/Badge.css.js +44 -0
- package/display/Badge/Badge.js +17 -0
- package/display/Badge/Badge.tpl.js +3 -0
- package/display/Banner/Banner.css.js +61 -0
- package/display/Banner/Banner.js +17 -0
- package/display/Banner/Banner.tpl.js +3 -0
- package/display/CodeBlock/CodeBlock.css.js +194 -0
- package/display/CodeBlock/CodeBlock.js +220 -0
- package/display/CodeBlock/CodeBlock.tpl.js +11 -0
- package/display/DataTable/DataTable.css.js +101 -0
- package/display/DataTable/DataTable.js +136 -0
- package/display/DataTable/DataTable.tpl.js +13 -0
- package/display/EmptyState/EmptyState.css.js +33 -0
- package/display/EmptyState/EmptyState.js +17 -0
- package/display/EmptyState/EmptyState.tpl.js +3 -0
- package/display/EventFeed/EventFeed.css.js +145 -0
- package/display/EventFeed/EventFeed.js +64 -0
- package/display/EventFeed/EventFeed.tpl.js +14 -0
- package/display/EventFeed/EventFeedItem.js +116 -0
- package/display/EventFeed/EventFeedItem.tpl.js +22 -0
- package/display/LoadingOverlay/LoadingOverlay.css.js +91 -0
- package/display/LoadingOverlay/LoadingOverlay.js +48 -0
- package/display/LoadingOverlay/LoadingOverlay.tpl.js +12 -0
- package/display/Metric/Metric.css.js +60 -0
- package/display/Metric/Metric.js +17 -0
- package/display/Metric/Metric.tpl.js +6 -0
- package/display/OutputGraphPreview/OutputGraphPreview.css.js +122 -0
- package/display/OutputGraphPreview/OutputGraphPreview.js +89 -0
- package/display/OutputGraphPreview/OutputGraphPreview.tpl.js +13 -0
- package/display/OutputListPreview/OutputListPreview.css.js +109 -0
- package/display/OutputListPreview/OutputListPreview.js +77 -0
- package/display/OutputListPreview/OutputListPreview.tpl.js +13 -0
- package/display/SourceEditor/SourceEditor.css.js +39 -0
- package/display/SourceEditor/SourceEditor.js +129 -0
- package/display/SourceEditor/SourceEditor.tpl.js +10 -0
- package/display/SourceViewer/SourceViewer.css.js +80 -0
- package/display/SourceViewer/SourceViewer.js +418 -0
- package/display/SourceViewer/SourceViewer.tpl.js +17 -0
- package/display/StatusRibbon/StatusRibbon.css.js +73 -0
- package/display/StatusRibbon/StatusRibbon.js +87 -0
- package/display/StatusRibbon/StatusRibbon.tpl.js +7 -0
- package/display/event-feed-adapter.js +72 -0
- package/display/format-utils.js +29 -0
- package/display/highlight.js +659 -0
- package/display/icons.js +37 -0
- package/display/markdown-formatter.js +60 -0
- package/display/network-approval-page.js +487 -0
- package/display/output-preview.js +261 -0
- package/effects/CellBg/CellBg.css.js +33 -0
- package/effects/CellBg/CellBg.js +410 -0
- package/effects/CellBg/CellBg.tpl.js +5 -0
- package/graph/canvas-adapter.js +223 -0
- package/graph/graph-algorithms.js +31 -0
- package/graph/index.js +46 -0
- package/graph/model.js +176 -0
- package/graph/project-graph-build.js +66 -0
- package/graph/project-graph-metadata.js +253 -0
- package/graph/project-package.js +128 -0
- package/graph/project-runtime.js +116 -0
- package/graph/project-transaction.js +284 -0
- package/graph/skeleton-utils.js +84 -0
- package/graph/theme-contract.js +36 -0
- package/graph/transaction-parser.js +56 -0
- package/icons/MaterialSymbols.js +69 -0
- package/icons/material-symbols-outlined-400.ttf +0 -0
- package/icons/material-symbols.css +24 -0
- package/index.js +95 -0
- package/inspector/InspectorPanel/InspectorPanel.css.js +375 -0
- package/inspector/InspectorPanel/InspectorPanel.js +368 -0
- package/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/inspector/TemplatePreview/TemplatePreview.js +145 -0
- package/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/interactions/ConnectFlow.js +304 -0
- package/interactions/Drag.js +104 -0
- package/interactions/Selector.js +133 -0
- package/interactions/SnapGrid.js +66 -0
- package/interactions/Zoom.js +139 -0
- package/layout/ActionZone/ActionZone.css.js +88 -0
- package/layout/ActionZone/ActionZone.js +261 -0
- package/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/layout/CrossLayoutPortalBridge/CrossLayoutPortalBridge.js +255 -0
- package/layout/Layout/Layout.css.js +91 -0
- package/layout/Layout/Layout.js +637 -0
- package/layout/Layout/Layout.tpl.js +27 -0
- package/layout/LayoutNode/LayoutNode.css.js +302 -0
- package/layout/LayoutNode/LayoutNode.js +509 -0
- package/layout/LayoutNode/LayoutNode.tpl.js +39 -0
- package/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/layout/LayoutRouter/LayoutRouter.js +274 -0
- package/layout/LayoutRouter/SectionRegistry.js +135 -0
- package/layout/LayoutRouter/routerSync.js +250 -0
- package/layout/LayoutSidebar/LayoutSidebar.css.js +411 -0
- package/layout/LayoutSidebar/LayoutSidebar.js +368 -0
- package/layout/LayoutSidebar/LayoutSidebar.tpl.js +26 -0
- package/layout/LayoutSidebar/SidebarSection.css.js +20 -0
- package/layout/LayoutSidebar/SidebarSection.js +184 -0
- package/layout/LayoutSidebar/SidebarSection.tpl.js +22 -0
- package/layout/LayoutTree.js +373 -0
- package/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/layout/PanelMenu/PanelMenu.js +95 -0
- package/layout/PanelMenu/PanelMenu.tpl.js +17 -0
- package/layout/ProjectTabs/ProjectTabs.css.js +188 -0
- package/layout/ProjectTabs/ProjectTabs.js +77 -0
- package/layout/ProjectTabs/ProjectTabs.tpl.js +15 -0
- package/layout/index.js +40 -0
- package/list/ListDetailShell/ListDetailShell.css.js +128 -0
- package/list/ListDetailShell/ListDetailShell.js +72 -0
- package/list/ListDetailShell/ListDetailShell.tpl.js +36 -0
- package/list/ListItem/ListItem.css.js +111 -0
- package/list/ListItem/ListItem.js +66 -0
- package/list/ListItem/ListItem.tpl.js +18 -0
- package/locale/index.js +503 -0
- package/manifest/component-registry.js +2446 -0
- package/manifest/graph-schema.js +285 -0
- package/manifest/index.js +6 -0
- package/manifest/project-schema-catalog.js +246 -0
- package/manifest/rule-catalog.js +201 -0
- package/manifest/theme-catalog.js +2149 -0
- package/manifest/ui-schema-catalog.js +334 -0
- package/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/menu/ContextMenu/ContextMenu.js +82 -0
- package/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/navigation/QuickOpen/QuickOpen.css.js +92 -0
- package/navigation/QuickOpen/QuickOpen.js +185 -0
- package/navigation/QuickOpen/QuickOpen.tpl.js +15 -0
- package/navigation/quick-open-utils.js +101 -0
- package/node/CtrlItem/CtrlItem.css.js +41 -0
- package/node/CtrlItem/CtrlItem.js +24 -0
- package/node/CtrlItem/CtrlItem.tpl.js +17 -0
- package/node/GraphFrame/GraphFrame.css.js +66 -0
- package/node/GraphFrame/GraphFrame.js +32 -0
- package/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/node/GraphNode/GraphNode.css.js +815 -0
- package/node/GraphNode/GraphNode.js +173 -0
- package/node/GraphNode/GraphNode.tpl.js +33 -0
- package/node/NodeCallout/NodeCallout.css.js +91 -0
- package/node/NodeCallout/NodeCallout.js +281 -0
- package/node/NodeCallout/NodeCallout.tpl.js +8 -0
- package/node/NodeSocket/NodeSocket.css.js +68 -0
- package/node/NodeSocket/NodeSocket.js +26 -0
- package/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/node/PortItem/PortItem.css.js +93 -0
- package/node/PortItem/PortItem.js +87 -0
- package/node/PortItem/PortItem.tpl.js +10 -0
- package/package.json +165 -0
- package/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/palette/PaletteBrowser/PaletteBrowser.js +152 -0
- package/palette/PaletteBrowser/PaletteBrowser.tpl.js +23 -0
- package/plugins/History.js +408 -0
- package/plugins/Readonly.js +60 -0
- package/rules/symbiote-3x.json +170 -0
- package/schemas/component-descriptor-v1.json +91 -0
- package/schemas/component-descriptor-v2.json +145 -0
- package/schemas/graph-model-v1.json +179 -0
- package/schemas/graph-v1.json +91 -0
- package/schemas/project-package-v1.json +102 -0
- package/schemas/project-transaction-v1.json +114 -0
- package/schemas/runtime-ui-v1.json +80 -0
- package/schemas/theme-rule-block-v1.json +73 -0
- package/shapes/CircleShape.js +79 -0
- package/shapes/CommentShape.js +35 -0
- package/shapes/DiamondShape.js +130 -0
- package/shapes/NodeShape.js +79 -0
- package/shapes/PillShape.js +91 -0
- package/shapes/RectShape.js +84 -0
- package/shapes/SVGShape.js +525 -0
- package/shapes/index.js +63 -0
- package/surface/Card/Card.css.js +57 -0
- package/surface/Card/Card.js +17 -0
- package/surface/Card/Card.tpl.js +3 -0
- package/themes/Palette.js +30 -0
- package/themes/Skin.js +113 -0
- package/themes/Theme.js +82 -0
- package/themes/carbon.js +135 -0
- package/themes/dark.js +140 -0
- package/themes/default-dark.js +714 -0
- package/themes/default-provider.css +635 -0
- package/themes/default-provider.js +718 -0
- package/themes/ebook.js +136 -0
- package/themes/grey.js +137 -0
- package/themes/light.js +139 -0
- package/themes/neon.js +138 -0
- package/themes/pcb.js +273 -0
- package/themes/synthwave.js +138 -0
- package/tokens/base.json +29 -0
- package/tokens/themes/carbon.json +11 -0
- package/tokens/themes/dark.json +12 -0
- package/tokens/themes/default-dark.json +1543 -0
- package/tokens/themes/default-provider.json +1543 -0
- package/tokens/themes/ebook.json +11 -0
- package/tokens/themes/grey.json +11 -0
- package/tokens/themes/light.json +12 -0
- package/tokens/themes/neon.json +11 -0
- package/tokens/themes/pcb.json +11 -0
- package/tokens/themes/synthwave.json +11 -0
- package/toolbar/QuickToolbar/QuickToolbar.css.js +152 -0
- package/toolbar/QuickToolbar/QuickToolbar.js +529 -0
- package/toolbar/QuickToolbar/QuickToolbar.tpl.js +34 -0
- package/tree/TreePanel/TreePanel.css.js +112 -0
- package/tree/TreePanel/TreePanel.js +147 -0
- package/tree/TreePanel/TreePanel.tpl.js +18 -0
- package/tree/TreeView/TreeView.css.js +122 -0
- package/tree/TreeView/TreeView.js +365 -0
- package/tree/TreeView/TreeView.tpl.js +10 -0
- package/ui/dialogs.js +221 -0
- package/ui/host-adapters.js +114 -0
- package/ui/index.js +660 -0
- package/ui/locale.js +50 -0
- package/ui/overlay-stack.js +89 -0
- package/ui/shared-styles.js +26 -0
- package/webmcp.js +37 -0
- package/xr/deep-graph.js +646 -0
- package/xr/emulation.js +198 -0
- package/xr/gesture.js +228 -0
- package/xr/html-canvas-renderer.js +472 -0
- package/xr/index.js +15 -0
- package/xr/layout-projection.js +1046 -0
- package/xr/panel-frame.js +128 -0
- package/xr/panel-host.js +267 -0
- package/xr/pointer.js +258 -0
- package/xr/scene-controller.js +242 -0
- package/xr/spatial-scene.js +212 -0
- package/xr/theme-bridge.js +105 -0
- package/xr/three-webxr-adapter.js +3439 -0
- package/xr/webgl-layer-renderer.js +419 -0
- package/xr/webxr.js +679 -0
- package/xr/workbench.js +516 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import Symbiote from "@symbiotejs/symbiote";
|
|
2
|
+
import "../CodeBlock/CodeBlock.js";
|
|
3
|
+
import template from "./SourceViewer.tpl.js";
|
|
4
|
+
import css from "./SourceViewer.css.js";
|
|
5
|
+
import { translate } from "../../locale/index.js";
|
|
6
|
+
|
|
7
|
+
const EXT_LANG = {
|
|
8
|
+
".md": "md",
|
|
9
|
+
".markdown": "md",
|
|
10
|
+
".sql": "sql",
|
|
11
|
+
".json": "json",
|
|
12
|
+
".css": "css",
|
|
13
|
+
".html": "html",
|
|
14
|
+
".htm": "html",
|
|
15
|
+
".xml": "xml",
|
|
16
|
+
".yaml": "yaml",
|
|
17
|
+
".yml": "yaml",
|
|
18
|
+
".toml": "toml",
|
|
19
|
+
".sh": "sh",
|
|
20
|
+
".bash": "bash",
|
|
21
|
+
".env": "env",
|
|
22
|
+
".ini": "ini",
|
|
23
|
+
".conf": "conf",
|
|
24
|
+
".cfg": "cfg",
|
|
25
|
+
".txt": "plain",
|
|
26
|
+
".csv": "csv",
|
|
27
|
+
".gitignore": "plain",
|
|
28
|
+
".dockerignore": "plain",
|
|
29
|
+
".editorconfig": "plain",
|
|
30
|
+
".py": "python",
|
|
31
|
+
".pyw": "python",
|
|
32
|
+
".pyi": "python",
|
|
33
|
+
".rb": "ruby",
|
|
34
|
+
".rake": "ruby",
|
|
35
|
+
".gemspec": "ruby",
|
|
36
|
+
".go": "go",
|
|
37
|
+
".rs": "rust",
|
|
38
|
+
".java": "java",
|
|
39
|
+
".kt": "kotlin",
|
|
40
|
+
".kts": "kotlin",
|
|
41
|
+
".swift": "swift",
|
|
42
|
+
".c": "c",
|
|
43
|
+
".h": "c",
|
|
44
|
+
".cpp": "c",
|
|
45
|
+
".hpp": "c",
|
|
46
|
+
".cc": "c",
|
|
47
|
+
".cxx": "c",
|
|
48
|
+
".hh": "c",
|
|
49
|
+
".cs": "csharp",
|
|
50
|
+
".php": "php",
|
|
51
|
+
".phtml": "php",
|
|
52
|
+
".dart": "dart",
|
|
53
|
+
".lua": "lua",
|
|
54
|
+
".ts": "typescript",
|
|
55
|
+
".tsx": "typescript",
|
|
56
|
+
".graphql": "graphql",
|
|
57
|
+
".gql": "graphql",
|
|
58
|
+
".prisma": "prisma",
|
|
59
|
+
".dockerfile": "dockerfile",
|
|
60
|
+
".r": "plain",
|
|
61
|
+
".scala": "java",
|
|
62
|
+
".groovy": "java",
|
|
63
|
+
".gradle": "java",
|
|
64
|
+
".png": "image",
|
|
65
|
+
".jpg": "image",
|
|
66
|
+
".jpeg": "image",
|
|
67
|
+
".gif": "image",
|
|
68
|
+
".svg": "image",
|
|
69
|
+
".webp": "image",
|
|
70
|
+
".bmp": "image",
|
|
71
|
+
".ico": "image",
|
|
72
|
+
".pdf": "binary",
|
|
73
|
+
".zip": "binary",
|
|
74
|
+
".tar": "binary",
|
|
75
|
+
".gz": "binary",
|
|
76
|
+
".woff": "binary",
|
|
77
|
+
".woff2": "binary",
|
|
78
|
+
".ttf": "binary",
|
|
79
|
+
".eot": "binary",
|
|
80
|
+
".mp3": "binary",
|
|
81
|
+
".mp4": "binary",
|
|
82
|
+
".wav": "binary",
|
|
83
|
+
".avi": "binary",
|
|
84
|
+
".mov": "binary",
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const FILE_LIKE_BASENAMES = new Set([
|
|
88
|
+
"Dockerfile",
|
|
89
|
+
"Makefile",
|
|
90
|
+
"Procfile",
|
|
91
|
+
"LICENSE",
|
|
92
|
+
"README",
|
|
93
|
+
"CHANGELOG",
|
|
94
|
+
"Gemfile",
|
|
95
|
+
"Rakefile",
|
|
96
|
+
"Vagrantfile",
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
function emit(el, type, detail = {}) {
|
|
100
|
+
el.dispatchEvent(new CustomEvent(type, { bubbles: true, composed: true, detail }));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function normalizeDirectoryPath(path) {
|
|
104
|
+
return String(path || "").replace(/^\.\//, "").replace(/\/$/, "");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getSourceLanguage(path) {
|
|
108
|
+
if (!path) return "js";
|
|
109
|
+
const base = path.split("/").pop() || "";
|
|
110
|
+
const dot = path.lastIndexOf(".");
|
|
111
|
+
if (dot >= 0) {
|
|
112
|
+
const ext = EXT_LANG[path.substring(dot).toLowerCase()];
|
|
113
|
+
if (ext) return ext;
|
|
114
|
+
}
|
|
115
|
+
if (base === "Dockerfile") return "dockerfile";
|
|
116
|
+
if (["Makefile", "Procfile", "LICENSE", "README", "CHANGELOG"].some((name) => base.startsWith(name))) {
|
|
117
|
+
return "plain";
|
|
118
|
+
}
|
|
119
|
+
return dot < 0 ? "plain" : "js";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function isDirectoryLikePath(path, directoryIndex = null) {
|
|
123
|
+
if (!path) return false;
|
|
124
|
+
const norm = normalizeDirectoryPath(path);
|
|
125
|
+
const base = norm.split("/").pop() || "";
|
|
126
|
+
const pathLooksLikeDir = path.endsWith("/") || (!path.includes(".") && !FILE_LIKE_BASENAMES.has(base));
|
|
127
|
+
if (pathLooksLikeDir) return true;
|
|
128
|
+
if (!directoryIndex) return false;
|
|
129
|
+
|
|
130
|
+
const directories = Array.isArray(directoryIndex.directories)
|
|
131
|
+
? directoryIndex.directories
|
|
132
|
+
: [];
|
|
133
|
+
for (const dir of directories) {
|
|
134
|
+
const normalized = normalizeDirectoryPath(dir);
|
|
135
|
+
if (normalized === norm || normalized.startsWith(`${norm}/`)) return true;
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function buildDirectoryInfo(path, directoryInfo = null) {
|
|
141
|
+
const norm = normalizeDirectoryPath(path);
|
|
142
|
+
const lines = [`Directory: ${norm || "."}`, "-".repeat(60), ""];
|
|
143
|
+
if (!directoryInfo) {
|
|
144
|
+
lines.push("Directory metadata is not available.");
|
|
145
|
+
return lines.join("\n");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const subdirectories = Array.from(directoryInfo.subdirectories || []).map(String).filter(Boolean).sort();
|
|
149
|
+
const directFiles = Array.from(directoryInfo.files || []).map(String).filter(Boolean).sort();
|
|
150
|
+
const fileTypes = directoryInfo.fileTypes && typeof directoryInfo.fileTypes === "object"
|
|
151
|
+
? directoryInfo.fileTypes
|
|
152
|
+
: {};
|
|
153
|
+
|
|
154
|
+
if (subdirectories.length > 0) {
|
|
155
|
+
lines.push(`Subdirectories (${subdirectories.length}):`);
|
|
156
|
+
for (const dir of subdirectories) lines.push(` - ${dir}/`);
|
|
157
|
+
lines.push("");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (directFiles.length > 0) {
|
|
161
|
+
lines.push(`Files (${directFiles.length}):`);
|
|
162
|
+
for (const file of directFiles) lines.push(` - ${file}`);
|
|
163
|
+
lines.push("");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const sortedExt = Object.entries(fileTypes).sort((a, b) => b[1] - a[1]);
|
|
167
|
+
if (sortedExt.length > 0) {
|
|
168
|
+
lines.push("File types:");
|
|
169
|
+
for (const [ext, count] of sortedExt) {
|
|
170
|
+
const bar = "#".repeat(Math.min(count, 30));
|
|
171
|
+
lines.push(` ${ext.padEnd(12)} ${String(count).padStart(4)} ${bar}`);
|
|
172
|
+
}
|
|
173
|
+
lines.push("");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
lines.push("-".repeat(60));
|
|
177
|
+
const totalFiles = Number.isFinite(directoryInfo.totalFiles) ? directoryInfo.totalFiles : directFiles.length;
|
|
178
|
+
const totalSubdirectories = Number.isFinite(directoryInfo.totalSubdirectories)
|
|
179
|
+
? directoryInfo.totalSubdirectories
|
|
180
|
+
: subdirectories.length;
|
|
181
|
+
lines.push(`Total: ${totalFiles} files across ${totalSubdirectories} subdirectories`);
|
|
182
|
+
|
|
183
|
+
if (directoryInfo.symbolCount > 0) {
|
|
184
|
+
lines.push(`Symbols: ${directoryInfo.symbolCount} exported nodes in this directory`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return lines.join("\n");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export class SourceViewer extends Symbiote {
|
|
191
|
+
init$ = {
|
|
192
|
+
filename: "Select a file",
|
|
193
|
+
hasFile: false,
|
|
194
|
+
viewMode: "source",
|
|
195
|
+
modeLabel: "source",
|
|
196
|
+
statsText: "",
|
|
197
|
+
showToggle: false,
|
|
198
|
+
showGraphAction: true,
|
|
199
|
+
showGraphTitle: translate('sourceViewer.showInGraph'),
|
|
200
|
+
toggleModeTitle: translate('sourceViewer.toggleViewMode'),
|
|
201
|
+
graphLabel: translate('sourceViewer.graphLabel'),
|
|
202
|
+
toggleIcon: "compress",
|
|
203
|
+
onShowGraph: () => emit(this, "source-viewer-show-graph", { path: this._currentPath }),
|
|
204
|
+
onToggleMode: () => this.toggleMode(),
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
_currentPath = null;
|
|
208
|
+
_fileData = null;
|
|
209
|
+
_baseStatsText = "";
|
|
210
|
+
_transformStatsText = "";
|
|
211
|
+
_transformCache = null;
|
|
212
|
+
_loadingTransform = false;
|
|
213
|
+
_isReadable = true;
|
|
214
|
+
_transformSource = null;
|
|
215
|
+
|
|
216
|
+
renderCallback() {
|
|
217
|
+
this.sub("hasFile", (value) => {
|
|
218
|
+
this.toggleAttribute("has-file", value);
|
|
219
|
+
});
|
|
220
|
+
this.sub("viewMode", (mode) => {
|
|
221
|
+
const lang = this._fileData?.lang || getSourceLanguage(this._currentPath);
|
|
222
|
+
this.toggleAttribute("mode-raw", mode !== "source");
|
|
223
|
+
if (lang === "md") {
|
|
224
|
+
this.$.modeLabel = mode === "rendered" ? "rendered" : "source";
|
|
225
|
+
this.$.toggleIcon = mode === "rendered" ? "article" : "code";
|
|
226
|
+
} else {
|
|
227
|
+
this.$.modeLabel = mode === "source" ? "source" : this._isReadable ? "compact" : "expanded";
|
|
228
|
+
this.$.toggleIcon = this._isReadable ? "compress" : "open_in_full";
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getCodeBlock() {
|
|
234
|
+
return this.querySelector("code-block");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
setImageApiBase(base) {
|
|
238
|
+
this.getCodeBlock()?.setImageApiBase(base);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
showEmpty(filename = "Select a file") {
|
|
242
|
+
this.$.filename = filename;
|
|
243
|
+
this.$.hasFile = false;
|
|
244
|
+
this.$.statsText = "";
|
|
245
|
+
this.$.showToggle = false;
|
|
246
|
+
this._currentPath = null;
|
|
247
|
+
this._fileData = null;
|
|
248
|
+
this._transformSource = null;
|
|
249
|
+
this.getCodeBlock()?.clearDiagnostics?.();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
showDirectory(path, text) {
|
|
253
|
+
this._showPlain(path, text, "directory");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
showBinary(path, text = `// Binary file: ${path}\n// Cannot display binary content`) {
|
|
257
|
+
this._showPlain(path, text, "binary");
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
showError(path, error) {
|
|
261
|
+
const message = error instanceof Error ? error.message : String(error || "Unknown error");
|
|
262
|
+
this._showPlain(path, `// Error: ${message}`, "error");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
showImage(path) {
|
|
266
|
+
this._resetForPath(path);
|
|
267
|
+
this.setImageApiBase(this.getAttribute("image-api-base") || "");
|
|
268
|
+
const codeBlock = this.getCodeBlock();
|
|
269
|
+
if (codeBlock) {
|
|
270
|
+
codeBlock.$.lang = "image";
|
|
271
|
+
codeBlock.setBasePath(path);
|
|
272
|
+
codeBlock.$.code = path;
|
|
273
|
+
}
|
|
274
|
+
this.$.viewMode = "rendered";
|
|
275
|
+
this.$.modeLabel = "image";
|
|
276
|
+
this.$.showToggle = false;
|
|
277
|
+
this.$.hasFile = true;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
showFile(options = {}) {
|
|
281
|
+
const path = options.path || "";
|
|
282
|
+
const lang = options.lang || getSourceLanguage(path);
|
|
283
|
+
const raw = options.raw ?? options.code ?? "";
|
|
284
|
+
this._resetForPath(path);
|
|
285
|
+
this._isReadable = options.isReadable !== false;
|
|
286
|
+
this._baseStatsText = options.statsText || "";
|
|
287
|
+
this._transformSource = typeof options.transform === "function" ? options.transform : null;
|
|
288
|
+
this._fileData = { raw, lang };
|
|
289
|
+
this.$.statsText = this._baseStatsText;
|
|
290
|
+
|
|
291
|
+
const codeBlock = this.getCodeBlock();
|
|
292
|
+
if (lang === "md" || lang === "markdown") {
|
|
293
|
+
this.$.viewMode = "rendered";
|
|
294
|
+
this.$.modeLabel = "rendered";
|
|
295
|
+
this.$.showToggle = true;
|
|
296
|
+
if (codeBlock) {
|
|
297
|
+
codeBlock.$.lang = "md";
|
|
298
|
+
codeBlock.setBasePath(path);
|
|
299
|
+
codeBlock.$.code = raw;
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
this.$.viewMode = "source";
|
|
303
|
+
this.$.modeLabel = "source";
|
|
304
|
+
this.$.showToggle = Boolean(this._transformSource);
|
|
305
|
+
if (codeBlock) {
|
|
306
|
+
codeBlock.$.lang = lang;
|
|
307
|
+
codeBlock.$.code = raw;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
this.$.hasFile = true;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async toggleMode() {
|
|
314
|
+
if (!this._fileData) return;
|
|
315
|
+
const lang = this._fileData.lang;
|
|
316
|
+
if (lang === "md" || lang === "markdown") {
|
|
317
|
+
this.$.viewMode = this.$.viewMode === "rendered" ? "source" : "rendered";
|
|
318
|
+
await this._showCurrentMode();
|
|
319
|
+
emit(this, "source-viewer-toggle-mode", { path: this._currentPath, mode: this.$.viewMode });
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
this.$.viewMode = this.$.viewMode === "source" ? "transformed" : "source";
|
|
323
|
+
await this._showCurrentMode();
|
|
324
|
+
emit(this, "source-viewer-toggle-mode", { path: this._currentPath, mode: this.$.viewMode });
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async _showCurrentMode() {
|
|
328
|
+
const codeBlock = this.getCodeBlock();
|
|
329
|
+
if (!this._fileData || !codeBlock) return;
|
|
330
|
+
const lang = this._fileData.lang;
|
|
331
|
+
|
|
332
|
+
if (lang === "md" || lang === "markdown") {
|
|
333
|
+
if (this.$.viewMode === "rendered") {
|
|
334
|
+
codeBlock.$.lang = "md";
|
|
335
|
+
codeBlock.setBasePath(this._currentPath);
|
|
336
|
+
} else {
|
|
337
|
+
codeBlock.$.lang = "plain";
|
|
338
|
+
}
|
|
339
|
+
codeBlock.$.code = this._fileData.raw;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
codeBlock.$.lang = lang;
|
|
344
|
+
if (this.$.viewMode !== "transformed") {
|
|
345
|
+
this.$.statsText = this._baseStatsText;
|
|
346
|
+
codeBlock.$.code = this._fileData.raw;
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (this._transformCache) {
|
|
351
|
+
codeBlock.$.code = this._transformCache;
|
|
352
|
+
if (this._transformStatsText) this.$.statsText = this._transformStatsText;
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (!this._transformSource || this._loadingTransform) return;
|
|
356
|
+
|
|
357
|
+
this._loadingTransform = true;
|
|
358
|
+
codeBlock.$.code = this._isReadable ? "// Compressing..." : "// Expanding...";
|
|
359
|
+
try {
|
|
360
|
+
const result = await this._transformSource({
|
|
361
|
+
path: this._currentPath,
|
|
362
|
+
lang,
|
|
363
|
+
isReadable: this._isReadable,
|
|
364
|
+
source: this._fileData.raw,
|
|
365
|
+
});
|
|
366
|
+
this._transformCache = result?.code || (this._isReadable ? "// Compression unavailable" : "// Expand unavailable");
|
|
367
|
+
this._transformStatsText = result?.statsText || "";
|
|
368
|
+
if (this._transformStatsText) this.$.statsText = this._transformStatsText;
|
|
369
|
+
codeBlock.$.code = this._transformCache;
|
|
370
|
+
} catch {
|
|
371
|
+
codeBlock.$.code = this._isReadable ? "// Compression failed" : "// Expand failed";
|
|
372
|
+
} finally {
|
|
373
|
+
this._loadingTransform = false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
_showPlain(path, text, label) {
|
|
378
|
+
this._resetForPath(path);
|
|
379
|
+
const codeBlock = this.getCodeBlock();
|
|
380
|
+
if (codeBlock) {
|
|
381
|
+
codeBlock.$.lang = "plain";
|
|
382
|
+
codeBlock.$.code = text;
|
|
383
|
+
}
|
|
384
|
+
this.$.viewMode = "source";
|
|
385
|
+
this.$.modeLabel = label;
|
|
386
|
+
this.$.showToggle = false;
|
|
387
|
+
this.$.hasFile = true;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
_resetForPath(path) {
|
|
391
|
+
this.$.filename = path || "Select a file";
|
|
392
|
+
this.$.hasFile = false;
|
|
393
|
+
this.$.statsText = "";
|
|
394
|
+
this._baseStatsText = "";
|
|
395
|
+
this._transformStatsText = "";
|
|
396
|
+
this._transformCache = null;
|
|
397
|
+
this._loadingTransform = false;
|
|
398
|
+
this._currentPath = path;
|
|
399
|
+
this._fileData = null;
|
|
400
|
+
this.getCodeBlock()?.clearDiagnostics?.();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
scrollToLine(line) {
|
|
404
|
+
this.getCodeBlock()?.scrollToLine?.(line);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
setDiagnostics(messages) {
|
|
408
|
+
this.getCodeBlock()?.setDiagnostics?.(messages);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
clearDiagnostics() {
|
|
412
|
+
this.getCodeBlock()?.clearDiagnostics?.();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
SourceViewer.template = template;
|
|
417
|
+
SourceViewer.rootStyles = css;
|
|
418
|
+
SourceViewer.reg("source-viewer");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default `
|
|
2
|
+
<div class="sv-header">
|
|
3
|
+
<span class="sv-filename" bind="textContent: filename"></span>
|
|
4
|
+
<div class="sv-controls">
|
|
5
|
+
<span class="sv-stats" bind="textContent: statsText"></span>
|
|
6
|
+
<button class="sv-action" bind="onclick: onShowGraph; hidden: !showGraphAction; title: showGraphTitle">
|
|
7
|
+
<span class="material-symbols-outlined icon-sm">account_tree</span>
|
|
8
|
+
<span class="sv-action-label" bind="textContent: graphLabel"></span>
|
|
9
|
+
</button>
|
|
10
|
+
<button class="sv-action" bind="onclick: onToggleMode; hidden: !showToggle; title: toggleModeTitle">
|
|
11
|
+
<span class="material-symbols-outlined icon-sm" bind="textContent: toggleIcon"></span>
|
|
12
|
+
<span class="sv-action-label" bind="textContent: modeLabel"></span>
|
|
13
|
+
</button>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<code-block></code-block>
|
|
17
|
+
`;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default `
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
sn-status-ribbon {
|
|
7
|
+
position: fixed;
|
|
8
|
+
bottom: 20px;
|
|
9
|
+
left: 50%;
|
|
10
|
+
transform: translateX(-50%) translateY(20px);
|
|
11
|
+
z-index: 9999;
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
opacity: 0;
|
|
14
|
+
transition: opacity 0.4s ease, transform 0.4s ease;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
sn-status-ribbon[visible] {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
transform: translateX(-50%) translateY(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.fr-inner {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 10px;
|
|
26
|
+
padding: 8px 20px;
|
|
27
|
+
border-radius: 24px;
|
|
28
|
+
background: var(--sn-bg-overlay);
|
|
29
|
+
backdrop-filter: blur(16px);
|
|
30
|
+
-webkit-backdrop-filter: blur(16px);
|
|
31
|
+
border: 1px solid var(--sn-cat-server);
|
|
32
|
+
box-shadow: var(--sn-shadow-lg), var(--sn-accent-glow);
|
|
33
|
+
font-family: var(--sn-font-ui);
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
color: var(--sn-text);
|
|
37
|
+
white-space: nowrap;
|
|
38
|
+
max-width: 500px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.fr-icon {
|
|
42
|
+
font-family: 'Material Symbols Outlined';
|
|
43
|
+
font-size: 16px;
|
|
44
|
+
color: var(--sn-cat-server);
|
|
45
|
+
animation: fr-pulse 2s ease-in-out infinite;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.fr-text {
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
text-overflow: ellipsis;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.fr-dots::after {
|
|
54
|
+
content: '...';
|
|
55
|
+
animation: fr-dots 1.5s steps(3) infinite;
|
|
56
|
+
display: inline-block;
|
|
57
|
+
width: 16px;
|
|
58
|
+
text-align: left;
|
|
59
|
+
color: var(--sn-text-dim);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@keyframes fr-pulse {
|
|
63
|
+
0%, 100% { opacity: 1; }
|
|
64
|
+
50% { opacity: 0.5; }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@keyframes fr-dots {
|
|
68
|
+
0% { content: ''; }
|
|
69
|
+
33% { content: '.'; }
|
|
70
|
+
66% { content: '..'; }
|
|
71
|
+
100% { content: '...'; }
|
|
72
|
+
}
|
|
73
|
+
`
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Symbiote from '@symbiotejs/symbiote'
|
|
2
|
+
import template from './StatusRibbon.tpl.js'
|
|
3
|
+
import css from './StatusRibbon.css.js'
|
|
4
|
+
|
|
5
|
+
export class StatusRibbon extends Symbiote {
|
|
6
|
+
init$ = {
|
|
7
|
+
statusText: '',
|
|
8
|
+
visible: false,
|
|
9
|
+
statusEvent: 'follow-status-changed',
|
|
10
|
+
stateEvent: 'follow-state-changed',
|
|
11
|
+
fadeTimeout: 4000
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_fadeTimer = null
|
|
15
|
+
_eventTarget = null
|
|
16
|
+
|
|
17
|
+
initCallback() {
|
|
18
|
+
this._eventTarget = window
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
renderCallback() {
|
|
22
|
+
this.sub('visible', (v) => {
|
|
23
|
+
this.toggleAttribute('visible', v)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const statusHandler = (e) => {
|
|
27
|
+
const text = e.detail?.text || ''
|
|
28
|
+
if (!text) {
|
|
29
|
+
this.$.visible = false
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
this.$.statusText = text
|
|
33
|
+
this.$.visible = true
|
|
34
|
+
|
|
35
|
+
if (this._fadeTimer) clearTimeout(this._fadeTimer)
|
|
36
|
+
this._fadeTimer = setTimeout(() => {
|
|
37
|
+
this.$.visible = false
|
|
38
|
+
}, this.$.fadeTimeout)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const stateHandler = (e) => {
|
|
42
|
+
if (!e.detail?.enabled) {
|
|
43
|
+
this.$.visible = false
|
|
44
|
+
this.$.statusText = ''
|
|
45
|
+
if (this._fadeTimer) {
|
|
46
|
+
clearTimeout(this._fadeTimer)
|
|
47
|
+
this._fadeTimer = null
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.sub('statusEvent', (evtName) => {
|
|
53
|
+
if (this._statusCleanup) this._statusCleanup()
|
|
54
|
+
const target = this.eventTarget || window
|
|
55
|
+
target.addEventListener(evtName, statusHandler)
|
|
56
|
+
this._statusCleanup = () => target.removeEventListener(evtName, statusHandler)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
this.sub('stateEvent', (evtName) => {
|
|
60
|
+
if (this._stateCleanup) this._stateCleanup()
|
|
61
|
+
const target = this.eventTarget || window
|
|
62
|
+
target.addEventListener(evtName, stateHandler)
|
|
63
|
+
this._stateCleanup = () => target.removeEventListener(evtName, stateHandler)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set eventTarget(target) {
|
|
68
|
+
this._eventTarget = target
|
|
69
|
+
this.$.statusEvent = this.$.statusEvent
|
|
70
|
+
this.$.stateEvent = this.$.stateEvent
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get eventTarget() {
|
|
74
|
+
return this._eventTarget
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
destroyCallback() {
|
|
78
|
+
if (this._statusCleanup) this._statusCleanup()
|
|
79
|
+
if (this._stateCleanup) this._stateCleanup()
|
|
80
|
+
if (this._fadeTimer) clearTimeout(this._fadeTimer)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
StatusRibbon.template = template
|
|
85
|
+
StatusRibbon.rootStyles = css
|
|
86
|
+
|
|
87
|
+
StatusRibbon.reg('sn-status-ribbon')
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export function createEventFeedAdapter(options = {}) {
|
|
2
|
+
const codeTools = new Set(options.codeTools || [])
|
|
3
|
+
const graphTools = new Set(options.graphTools || [])
|
|
4
|
+
const listTools = new Set(options.listTools || [])
|
|
5
|
+
|
|
6
|
+
function parseOutput(output) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(output)
|
|
9
|
+
} catch {
|
|
10
|
+
return output
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function toPreviewGraph(data) {
|
|
15
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) return data
|
|
16
|
+
if (Array.isArray(data.nodes)) return data
|
|
17
|
+
|
|
18
|
+
let nodeMap = data.n && typeof data.n === 'object' ? data.n : {}
|
|
19
|
+
let nodes = Object.entries(nodeMap).map(([id, node]) => ({
|
|
20
|
+
id,
|
|
21
|
+
label: node?.label || node?.name || node?.title || id,
|
|
22
|
+
kind: node?.kind || node?.type || 'node',
|
|
23
|
+
description: node?.description || node?.summary || '',
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
let edges = Array.isArray(data.e) ? data.e.map((edge, index) => ({
|
|
27
|
+
id: edge.id || `edge-${index + 1}`,
|
|
28
|
+
source: edge.source || edge.from || edge.a || '',
|
|
29
|
+
target: edge.target || edge.to || edge.b || '',
|
|
30
|
+
label: edge.label || edge.name || '',
|
|
31
|
+
kind: edge.kind || edge.type || 'edge',
|
|
32
|
+
})) : []
|
|
33
|
+
|
|
34
|
+
return { nodes, edges }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function buildPreview(event) {
|
|
38
|
+
if (event.type === 'tool_call') return { type: 'empty' }
|
|
39
|
+
if (event.success === false || !event.output) {
|
|
40
|
+
return { type: 'error', value: event.output || 'Error' }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let output = String(event.output ?? '')
|
|
44
|
+
let data = parseOutput(output)
|
|
45
|
+
|
|
46
|
+
if (codeTools.has(event.tool)) return { type: 'code', value: output, lang: 'plain' }
|
|
47
|
+
if (graphTools.has(event.tool)) return { type: 'graph', value: toPreviewGraph(data), title: 'Graph output' }
|
|
48
|
+
if (listTools.has(event.tool)) return { type: 'list', value: data, title: 'List output' }
|
|
49
|
+
return { type: 'raw', value: output }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function toToolEventFeedItem(event) {
|
|
53
|
+
return {
|
|
54
|
+
direction: event.type === 'tool_call' ? 'call' : 'result',
|
|
55
|
+
tool: event.tool,
|
|
56
|
+
timestamp: event.ts,
|
|
57
|
+
durationText: event.duration_ms ? `${event.duration_ms}ms` : '',
|
|
58
|
+
success: event.success !== false,
|
|
59
|
+
args: event.args || {},
|
|
60
|
+
preview: buildPreview(event),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function toToolEventFeedItems(events) {
|
|
65
|
+
return Array.isArray(events) ? events.map(toToolEventFeedItem) : []
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
toToolEventFeedItem,
|
|
70
|
+
toToolEventFeedItems
|
|
71
|
+
}
|
|
72
|
+
}
|