/** * VariableView — flat list of all variable key-value pairs. * * Hovering a value shows a popup with: * - Declaration expression (if any), styled distinctly * - Active tag modifiers: #tag +N (from $source) */ import { Component, For, createMemo, Show, createSignal } from "solid-js"; import { useJournalStream } from "../stores/journalStream"; import { useJournalCompletions } from "./completions"; import { getMods, getDeclExpr } from "./var-reactivity"; export const VariableView: Component = () => { const stream = useJournalStream(); const comp = useJournalCompletions(); const values = createMemo(() => stream.variables); /** Runtime engine diagnostics (bad declarations / modifiers). */ const diagnostics = createMemo(() => comp.diagnostics()); /** Flat list of all variables */ const items = createMemo(() => { const vars = values(); return Object.entries(vars).map(([key, value]) => ({ key, value, isTag: value.startsWith("#"), })); }); const hasAnyData = () => comp.data.declarations.length > 0 || Object.keys(values()).length > 0; return (
0}>
变量求值有 {diagnostics().length} 个问题
    {(d) => (
  • {d.message}
  • )}
暂无变量定义。在文档中使用 ```yaml role=declare 代码块定义变量。

} >
{(item) => ( )}
); }; // --------------------------------------------------------------------------- // VariableRow — single row with hover popup // --------------------------------------------------------------------------- const VariableRow: Component<{ key: string; value: string; isTag: boolean; }> = (props) => { const [hovered, setHovered] = createSignal(false); const declExpr = createMemo(() => getDeclExpr(props.key)); const mods = createMemo(() => getMods(props.key)); const hasPopup = () => !!declExpr() || mods().length > 0; return (
setHovered(true)} onMouseLeave={() => setHovered(false)} > {props.key} {props.value} {/* Hover popup */}
{/* Declaration expression */}
expr: {declExpr()}
{/* Tag modifiers */} 0}>
{(mod) => (
{mod.tag} +{mod.value} (from {mod.source})
)}
); }; export default VariableView;