@agent-native/core 0.109.1 → 0.109.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +7 -0
- package/corpus/core/docs/content/integrations.mdx +87 -253
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/client/blocks/library/diagram.config.ts +10 -1
- package/corpus/core/src/client/blocks/library/diagram.tsx +9 -4
- package/corpus/core/src/deploy/build.ts +63 -3
- package/corpus/templates/clips/.agents/skills/dictate/SKILL.md +28 -5
- package/corpus/templates/clips/.agents/skills/meetings/SKILL.md +7 -0
- package/corpus/templates/clips/.agents/skills/recording/SKILL.md +23 -0
- package/corpus/templates/clips/AGENTS.md +10 -0
- package/corpus/templates/clips/actions/create-dictation.ts +29 -4
- package/corpus/templates/clips/actions/finalize-recording.ts +2 -4
- package/corpus/templates/clips/actions/get-recording-player-data.ts +16 -6
- package/corpus/templates/clips/actions/set-mobile-capture-state.ts +37 -0
- package/corpus/templates/clips/actions/update-dictation.ts +9 -1
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +13 -2
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +13 -2
- package/corpus/templates/clips/changelog/2026-07-17-capture-dictation-background-meeting-audio-and-camera-videos.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-17-delayed-upload-verification-keeps-local-backups-retryable.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +17 -0
- package/corpus/templates/clips/desktop/src/lib/processing-backup-recovery.ts +19 -0
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +60 -35
- package/corpus/templates/clips/desktop/src/lib/upload-verification.ts +12 -0
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +1 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +14 -0
- package/corpus/templates/clips/server/db/schema.ts +9 -1
- package/corpus/templates/clips/server/lib/builder-media-compression.ts +59 -7
- package/corpus/templates/clips/server/lib/media-verification-state.ts +17 -0
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +7 -0
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +22 -1
- package/corpus/templates/plan/changelog/2026-07-17-diagrams-can-opt-into-a-polished-clean-rendering-mode-withou.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +3 -0
- package/dist/client/blocks/library/diagram.config.d.ts +2 -0
- package/dist/client/blocks/library/diagram.config.d.ts.map +1 -1
- package/dist/client/blocks/library/diagram.config.js +8 -1
- package/dist/client/blocks/library/diagram.config.js.map +1 -1
- package/dist/client/blocks/library/diagram.d.ts.map +1 -1
- package/dist/client/blocks/library/diagram.js +9 -4
- package/dist/client/blocks/library/diagram.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts +3 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +45 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/secrets/routes.d.ts +9 -9
- package/docs/content/integrations.mdx +87 -253
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/diagram.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,KAAK,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;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KAAK,EAAC,MAAM,EACZ,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,UAAU,CAAC,GACzD,EACF,mBACE,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAC,4LAA4L,EACtM,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GACtD,IACE,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,8IAA8I,EACxJ,QAAQ,EAAE,CAAC,QAAQ,EACnB,OAAO,EAAE,iBAAiB,gCAGnB,IACD,CACX,IACG,CACP,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAc;IACnD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,aAAa;IACrB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,+EAA+E;IAC/E,wDAAwD;IACxD,WAAW,EAAE,OAAO;IACpB,KAAK,EAAE,SAAS;IAChB,WAAW,EACT,2PAA2P;IAC7P,6EAA6E;IAC7E,wDAAwD;IACxD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;CACrE,CAAC,CAAC","sourcesContent":["import {\n IconArrowsMaximize,\n IconScribble,\n IconShape2,\n IconX,\n} from \"@tabler/icons-react\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\n\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"../../components/ui/tooltip.js\";\nimport { cn } from \"../../utils.js\";\nimport { AiEditableFieldLabel } from \"../AiEditableField.js\";\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport { useBlockCopy } from \"./block-copy.js\";\nimport {\n diagramMdx,\n diagramSchema,\n type DiagramData,\n type DiagramEdge,\n type DiagramNode,\n} from \"./diagram.config.js\";\nimport {\n sanitizeDiagramHtml,\n sanitizeWireframeCss,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\nimport {\n RoughOverlay,\n toggleWireframeStyle,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\n\n/**\n * Read + Edit renderers for the shared `diagram` block — a flexible inline\n * architecture/code diagram. The preferred authoring path is a scoped, inert\n * HTML/SVG fragment that leans on `.diagram-*` primitives and `--wf-*` tokens;\n * a legacy positional / sequence node-graph path is kept for older/simple plans.\n * Lives in core so any app can register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original (mirrors the sibling `wireframe.tsx` port):\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes`; `useWireframeStyle()` reads the viewer's sketchy/clean\n * preference from the shared `plan-wireframe-style` localStorage key — both\n * from `./wireframe-kit.js`, so core stays plan-free and shadcn-free.\n * - HTML sanitize: the HTML/SVG fragment + CSS run through the app-injected\n * `ctx.sanitizeHtml` at the render point (defense-in-depth against stored\n * XSS). Without a sanitizer wired, the HTML path emits nothing — core never\n * injects unsanitized author HTML. The React-free `diagramSchema` already\n * rejects active markup before storage.\n * - The rough.js sketch overlay reuses the kit's shared `RoughOverlay`, scoped\n * with the diagram selector and `drawFrame={false}` (the same call the plan\n * `HtmlDiagram` made). The `.plan-diagram-frame` / `.diagram-*` / `data-rough`\n * class contract is preserved exactly so the theme-token CSS in core's\n * `blocks.css` styles it in any app.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment.\n */\n\n/* -------------------------------------------------------------------------- */\n/* HTML/SVG diagram path */\n/* -------------------------------------------------------------------------- */\n\n/** The rough-overlay selector for diagram bordered boxes (mirrors the plan). */\nconst DIAGRAM_ROUGH_SELECTOR =\n \"[data-rough],.diagram-panel,.diagram-node,.diagram-box,.diagram-pill,.diagram-card,[class*='card'],[class*='box'],[class*='panel'],[class*='pill'],[class*='chip'],[class*='badge'],hr\";\n\nfunction HtmlDiagram({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const style = useWireframeStyle();\n const showFrame = resolveVisualFrame(data.frame, ctx);\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n // Sanitize author HTML/CSS at the render point (defense-in-depth against\n // stored XSS). Self-contained in core via the shared block sanitizer (DOM-based\n // in the browser, regex fallback on the server) so diagrams render in any app\n // without the host wiring a sanitizer hook.\n const safeHtml = useMemo(() => sanitizeDiagramHtml(data.html), [data.html]);\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this diagram instance so global\n // selectors (body, *, .app-shell, :root) can't escape and restyle the page.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-diagram-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <div\n ref={ref}\n className={cn(\"plan-diagram-shell\", compact && \"plan-diagram-compact\")}\n >\n <div\n className=\"plan-diagram-frame\"\n dir={ctx.textDirection}\n data-theme={isDark ? \"dark\" : \"light\"}\n data-style={style}\n data-frame={showFrame ? \"show\" : \"hide\"}\n data-text-direction={ctx.textDirection}\n data-plan-diagram-scope={scopeId}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-diagram-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n <RoughOverlay\n scopeRef={ref}\n enabled={style === \"sketchy\"}\n drawFrame={showFrame}\n selector={DIAGRAM_ROUGH_SELECTOR}\n />\n {data.caption && !compact && (\n <p className=\"mt-3 text-sm leading-6 text-muted-foreground\">\n {data.caption}\n </p>\n )}\n </div>\n );\n}\n\nfunction resolveVisualFrame(\n frame: DiagramData[\"frame\"],\n ctx: BlockRenderContext,\n): boolean {\n const resolved =\n frame && frame !== \"auto\" ? frame : (ctx.visualFrame ?? \"show\");\n return resolved !== \"hide\";\n}\n\n/* -------------------------------------------------------------------------- */\n/* Legacy node-graph paths */\n/* -------------------------------------------------------------------------- */\n\nfunction clampDiagramPercent(value: number) {\n if (!Number.isFinite(value)) return 50;\n return Math.max(4, Math.min(96, value));\n}\n\nfunction hasPositionedDiagramNodes(data: DiagramData): boolean {\n return (data.nodes ?? []).some(\n (node) => typeof node.x === \"number\" && typeof node.y === \"number\",\n );\n}\n\nfunction orderDiagramNodes(\n nodes: DiagramNode[],\n edges: DiagramEdge[],\n): DiagramNode[] {\n if (nodes.length === 0) return [];\n const byId = new Map(nodes.map((node) => [node.id, node]));\n const indegree = new Map(nodes.map((node) => [node.id, 0]));\n for (const edge of edges) {\n if (byId.has(edge.from) && byId.has(edge.to)) {\n indegree.set(edge.to, (indegree.get(edge.to) ?? 0) + 1);\n }\n }\n const start = nodes.find((node) => (indegree.get(node.id) ?? 0) === 0);\n if (!start) return nodes;\n const ordered: DiagramNode[] = [];\n const seen = new Set<string>();\n let current: DiagramNode | undefined = start;\n while (current && !seen.has(current.id)) {\n const node: DiagramNode = current;\n ordered.push(node);\n seen.add(node.id);\n const next = edges.find((edge) => edge.from === node.id);\n current = next ? byId.get(next.to) : undefined;\n }\n for (const node of nodes) if (!seen.has(node.id)) ordered.push(node);\n return ordered;\n}\n\nfunction PositionedDiagram({\n data,\n compact,\n markerId,\n direction,\n showFrame,\n}: {\n data: DiagramData;\n compact?: boolean;\n markerId: string;\n direction?: BlockRenderContext[\"textDirection\"];\n showFrame: boolean;\n}) {\n const nodes = (data.nodes ?? []).map((node) => ({\n ...node,\n x: clampDiagramPercent(node.x ?? 50),\n y: clampDiagramPercent(node.y ?? 50),\n }));\n const edges = data.edges ?? [];\n const arrowId = `${markerId}-diagram-arrow`;\n const nodeWidth = compact ? 150 : 190;\n const rows = diagramRows(nodes, compact);\n const canvasHeight = diagramCanvasHeight(rows.length, compact);\n const canvasMinWidth = compact ? 560 : 720;\n const nodeWidthPct = compact ? 20 : 18;\n const nodeHeightPct = compact ? 14 : 18;\n const paddedViewBox = diagramViewBox(nodes, nodeWidthPct, nodeHeightPct);\n const xMargin = compact ? 13 : 14;\n const yMargin = compact ? 15 : 18;\n const displayNodes = nodes.map((node) => ({\n ...node,\n displayXBase: diagramPointPercent(\n node.x,\n paddedViewBox.x,\n paddedViewBox.width,\n xMargin,\n ),\n displayY: diagramRowPointPercent(node.y, rows, paddedViewBox, yMargin),\n }));\n const displayNodesForDirection = displayNodes.map((node) => ({\n ...node,\n displayX: direction === \"rtl\" ? 100 - node.displayXBase : node.displayXBase,\n }));\n const nodeByIdForDirection = new Map(\n displayNodesForDirection.map((node) => [node.id, node]),\n );\n\n return (\n <div\n className={cn(\n \"plan-sketch\",\n showFrame ? \"rounded-[16px] border border-border bg-muted p-5\" : \"p-0\",\n )}\n dir={direction}\n data-text-direction={direction}\n >\n <div\n className=\"overflow-auto rounded-xl border border-border bg-background\"\n style={{ minHeight: canvasHeight }}\n >\n <div\n className=\"relative\"\n style={{ minHeight: canvasHeight, minWidth: canvasMinWidth }}\n >\n <svg\n className=\"pointer-events-none absolute inset-0 z-0 h-full w-full\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n >\n <defs>\n <marker\n id={arrowId}\n viewBox=\"0 0 10 10\"\n refX=\"8\"\n refY=\"5\"\n markerWidth=\"5\"\n markerHeight=\"5\"\n orient=\"auto-start-reverse\"\n >\n <path\n d=\"M 0 0 L 10 5 L 0 10 z\"\n className=\"fill-muted-foreground\"\n />\n </marker>\n </defs>\n {edges.map((edge, index) => {\n const from = nodeByIdForDirection.get(edge.from);\n const to = nodeByIdForDirection.get(edge.to);\n if (!from || !to) return null;\n return (\n <line\n key={`${edge.from}-${edge.to}-${index}`}\n x1={from.displayX}\n y1={from.displayY}\n x2={to.displayX}\n y2={to.displayY}\n markerEnd={`url(#${arrowId})`}\n vectorEffect=\"non-scaling-stroke\"\n className=\"stroke-border\"\n strokeWidth={2}\n strokeDasharray={edge.label ? \"0\" : \"6 5\"}\n />\n );\n })}\n </svg>\n\n {!compact &&\n edges.map((edge, index) => {\n const from = nodeByIdForDirection.get(edge.from);\n const to = nodeByIdForDirection.get(edge.to);\n if (!edge.label || !from || !to) return null;\n return (\n <span\n key={`${edge.from}-${edge.to}-${index}-label`}\n className=\"absolute z-10 max-w-[130px] -translate-x-1/2 -translate-y-1/2 break-words rounded-full border border-border bg-background px-2 py-0.5 text-center text-[11px] font-semibold text-muted-foreground shadow-sm [overflow-wrap:anywhere]\"\n style={{\n left: `${(from.displayX + to.displayX) / 2}%`,\n top: `${(from.displayY + to.displayY) / 2}%`,\n }}\n >\n {edge.label}\n </span>\n );\n })}\n\n {displayNodesForDirection.map((node, index) => (\n <article\n key={node.id}\n className=\"absolute z-20 -translate-x-1/2 -translate-y-1/2 break-words rounded-xl border-2 border-border bg-background p-3 text-foreground shadow-sm [overflow-wrap:anywhere]\"\n style={{\n left: `${node.displayX}%`,\n top: `${node.displayY}%`,\n width: nodeWidth,\n }}\n >\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground\">\n {index + 1}\n </p>\n <h3 className=\"mt-2 text-base font-semibold leading-tight\">\n {node.label}\n </h3>\n {node.detail && !compact && (\n <p className=\"mt-2 text-xs leading-5 text-muted-foreground\">\n {node.detail}\n </p>\n )}\n </article>\n ))}\n </div>\n </div>\n {data.notes && data.notes.length > 0 && !compact && (\n <div className=\"mt-4 grid gap-2 border-t border-border pt-4 text-sm text-muted-foreground md:grid-cols-2\">\n {data.notes.map((note) => (\n <p key={note.id}>{note.text}</p>\n ))}\n </div>\n )}\n </div>\n );\n}\n\ntype DiagramViewBox = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nfunction diagramViewBox(\n nodes: Array<Pick<DiagramNode, \"x\" | \"y\">>,\n nodeWidthPct: number,\n nodeHeightPct: number,\n): DiagramViewBox {\n if (nodes.length === 0) return { x: 0, y: 0, width: 100, height: 100 };\n\n const halfWidth = nodeWidthPct / 2;\n const halfHeight = nodeHeightPct / 2;\n const left = Math.min(...nodes.map((node) => (node.x ?? 50) - halfWidth));\n const right = Math.max(...nodes.map((node) => (node.x ?? 50) + halfWidth));\n const top = Math.min(...nodes.map((node) => (node.y ?? 50) - halfHeight));\n const bottom = Math.max(...nodes.map((node) => (node.y ?? 50) + halfHeight));\n\n const x = Math.min(0, left);\n const y = Math.min(0, top);\n const width = Math.max(100, right) - x;\n const height = Math.max(100, bottom) - y;\n\n return { x, y, width, height };\n}\n\nfunction diagramPointPercent(\n value: number,\n viewBoxStart: number,\n viewBoxSize: number,\n margin = 0,\n): number {\n if (\n !Number.isFinite(value) ||\n !Number.isFinite(viewBoxSize) ||\n !viewBoxSize\n ) {\n return 50;\n }\n const percent = ((value - viewBoxStart) / viewBoxSize) * 100;\n return Math.min(100 - margin, Math.max(margin, percent));\n}\n\nfunction diagramRows(\n nodes: Array<Pick<DiagramNode, \"y\">>,\n compact?: boolean,\n): number[] {\n const rowGap = compact ? 8 : 10;\n return [...nodes]\n .sort((a, b) => (a.y ?? 50) - (b.y ?? 50))\n .reduce<number[]>((acc, node) => {\n const y = node.y ?? 50;\n const last = acc[acc.length - 1];\n if (last == null || Math.abs(y - last) >= rowGap) acc.push(y);\n return acc;\n }, []);\n}\n\nfunction diagramRowPointPercent(\n value: number,\n rows: number[],\n viewBox: DiagramViewBox,\n margin: number,\n): number {\n if (rows.length <= 2) {\n return diagramPointPercent(value, viewBox.y, viewBox.height, margin);\n }\n const closestIndex = rows.reduce((bestIndex, row, index) => {\n const bestDistance = Math.abs((rows[bestIndex] ?? 50) - value);\n return Math.abs(row - value) < bestDistance ? index : bestIndex;\n }, 0);\n const span = 100 - margin * 2;\n return margin + (span * closestIndex) / Math.max(1, rows.length - 1);\n}\n\nfunction diagramCanvasHeight(rows: number, compact?: boolean): number {\n const base = compact ? 280 : 430;\n if (rows <= 2) return base;\n return Math.max(base, rows * (compact ? 140 : 190) + (compact ? 80 : 120));\n}\n\nfunction SequenceDiagram({\n data,\n compact,\n direction,\n showFrame,\n}: {\n data: DiagramData;\n compact?: boolean;\n direction?: BlockRenderContext[\"textDirection\"];\n showFrame: boolean;\n}) {\n const edges = data.edges ?? [];\n const nodes = orderDiagramNodes(data.nodes ?? [], edges);\n if (nodes.length === 0) {\n return (\n <div className=\"rounded-[12px] border border-border bg-muted p-4 text-sm text-muted-foreground\">\n Diagram content is empty.\n </div>\n );\n }\n const visualNodes = direction === \"rtl\" ? [...nodes].reverse() : nodes;\n return (\n <div\n className={cn(\n \"plan-sketch\",\n showFrame ? \"rounded-[16px] border border-border bg-muted p-5\" : \"p-0\",\n )}\n dir={direction}\n data-text-direction={direction}\n >\n <div\n className={cn(\n \"flex gap-3 overflow-x-auto pb-2\",\n compact ? \"items-center\" : \"items-stretch\",\n )}\n >\n {visualNodes.map((node, index) => {\n const next = visualNodes[index + 1];\n const edge = next\n ? edges.find(\n (candidate) =>\n (candidate.from === node.id && candidate.to === next.id) ||\n (candidate.from === next.id && candidate.to === node.id),\n )\n : undefined;\n return (\n <div key={node.id} className=\"flex min-w-max items-center gap-3\">\n <article\n className={cn(\n \"w-[180px] rounded-xl border-2 border-border bg-background p-3 text-foreground\",\n compact && \"w-[150px]\",\n )}\n >\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground\">\n {index + 1}\n </p>\n <h3 className=\"mt-2 text-base font-semibold leading-tight\">\n {node.label}\n </h3>\n {node.detail && !compact && (\n <p className=\"mt-2 text-xs leading-5 text-muted-foreground\">\n {node.detail}\n </p>\n )}\n </article>\n {next && (\n <div className=\"grid min-w-[72px] justify-items-center gap-1 text-muted-foreground\">\n {edge?.label && (\n <span className=\"max-w-[96px] whitespace-normal break-words rounded-full border border-border px-2 py-0.5 text-center text-[11px] font-semibold [overflow-wrap:anywhere]\">\n {edge.label}\n </span>\n )}\n <span className=\"h-0.5 w-full rounded-full border-t-2 border-dashed border-border\" />\n </div>\n )}\n </div>\n );\n })}\n </div>\n {data.notes && data.notes.length > 0 && !compact && (\n <div className=\"mt-4 grid gap-2 border-t border-border pt-4 text-sm text-muted-foreground md:grid-cols-2\">\n {data.notes.map((note) => (\n <p key={note.id}>{note.text}</p>\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * The diagram body. Routes to the preferred HTML/SVG path (when `data.html` is\n * set) and otherwise to a legacy node-graph path (positioned canvas when nodes\n * carry x/y, else an ordered sequence). Used both inline and, scaled up, inside\n * the expand lightbox — so every variant (html/css, positioned, sequence)\n * enlarges through the same code path.\n */\nfunction DiagramBody({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const markerId = useId().replace(/:/g, \"\");\n const showFrame = resolveVisualFrame(data.frame, ctx);\n if (data.html?.trim()) {\n return <HtmlDiagram data={data} ctx={ctx} compact={compact} />;\n }\n if (hasPositionedDiagramNodes(data)) {\n return (\n <PositionedDiagram\n data={data}\n compact={compact}\n markerId={markerId}\n direction={ctx.textDirection}\n showFrame={showFrame}\n />\n );\n }\n return (\n <SequenceDiagram\n data={data}\n compact={compact}\n direction={ctx.textDirection}\n showFrame={showFrame}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Expand / lightbox */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Enlarge overlay for a rendered diagram. Mirrors the image lightbox contract\n * used by the composer's `ImagePreviewLightbox` (PromptComposer.tsx) so the\n * expand affordance feels identical to viewing an image full-size: a fixed\n * `bg-black/80` backdrop, Escape to close, click-the-backdrop to close, and a\n * top-right close button. Unlike the image variant this renders arbitrary\n * children (the diagram body re-rendered larger) rather than an `<img>`, since a\n * diagram is live HTML/SVG/node-graph markup, not an image URL.\n *\n * Exported so the separate Mermaid block (`MermaidBlock.tsx`, which renders its\n * diagram to an SVG through a different runtime) can reuse the exact same\n * lightbox contract — one expand affordance shared across both diagram types.\n */\nexport function DiagramLightbox({\n children,\n onClose,\n}: {\n children: React.ReactNode;\n onClose: () => void;\n}) {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"\";\n };\n }, [onClose]);\n\n return (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Diagram preview\"\n onClick={onClose}\n data-plan-interactive\n className=\"fixed inset-0 z-[300] flex items-center justify-center overflow-auto bg-black/80 p-6 cursor-zoom-out\"\n >\n <div\n onClick={(e) => e.stopPropagation()}\n className=\"max-h-full w-full max-w-5xl cursor-default overflow-auto rounded-md bg-background p-6 shadow-2xl\"\n >\n {children}\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close preview\"\n className=\"absolute right-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border border-white/30 bg-black/40 text-white hover:bg-black/60\"\n >\n <IconX className=\"h-4 w-4\" />\n </button>\n </div>\n );\n}\n\n/**\n * The diagram body plus a hover-revealed top-right \"expand\" button (like the\n * image attachment zoom). Opening the button re-renders the exact same\n * `DiagramBody` inside `DiagramLightbox` at a larger size, so html/css and\n * mermaid/legacy node-graph diagrams alike enlarge through one path. The inline\n * (non-expanded) render is otherwise unchanged.\n */\nfunction ExpandableDiagramBody({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const [expanded, setExpanded] = useState(false);\n const supportsStyleToggle = Boolean(data.html);\n const style = useWireframeStyle();\n const copy = useBlockCopy();\n const sketchy = style === \"sketchy\";\n const styleLabel = sketchy\n ? copy.switchToCleanDiagrams\n : copy.switchToHandDrawnDiagrams;\n const styleTooltip = sketchy\n ? copy.handDrawnDiagramsSwitch\n : copy.cleanDiagramsSwitch;\n return (\n <div className=\"group/diagram relative\">\n <DiagramBody data={data} ctx={ctx} compact={compact} />\n <TooltipProvider delayDuration={100} skipDelayDuration={0}>\n <div className=\"absolute right-2 top-2 z-10 flex items-center gap-1.5\">\n {supportsStyleToggle && (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n onClick={() => toggleWireframeStyle()}\n aria-label={styleLabel}\n aria-pressed={sketchy}\n className=\"an-diagram-style-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100\"\n >\n {sketchy ? (\n <IconScribble className=\"size-4\" />\n ) : (\n <IconShape2 className=\"size-4\" />\n )}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"left\">{styleTooltip}</TooltipContent>\n </Tooltip>\n )}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n onClick={() => setExpanded(true)}\n aria-label={copy.expandDiagram}\n className=\"an-diagram-expand-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100\"\n >\n <IconArrowsMaximize className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"left\">{copy.expandDiagram}</TooltipContent>\n </Tooltip>\n </div>\n </TooltipProvider>\n {expanded ? (\n <DiagramLightbox onClose={() => setExpanded(false)}>\n <DiagramBody data={data} ctx={ctx} />\n </DiagramLightbox>\n ) : null}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Read + Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer: the diagram body wrapped in the standard titled block. */\nexport function DiagramRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n compactVisuals,\n}: BlockReadProps<DiagramData>) {\n return (\n <section\n {...ltrCodeBlockProps}\n className=\"an-block plan-block\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <ExpandableDiagramBody data={data} ctx={ctx} compact={compactVisuals} />\n {summary && <p className=\"mt-5 text-muted-foreground\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Edit form (panel surface). The block can be an HTML/SVG fragment or a legacy\n * node/edge/note graph, so this exposes html/css/caption plus a collapsible\n * legacy node-graph JSON editor, each with an AI-edit affordance via\n * `ctx.renderAiFieldAction` (through `AiEditableFieldLabel`). `editSurface:\n * \"panel\"` means the registry renders the `Read` view with a corner edit button\n * that opens this form in the app-provided popover.\n */\nexport function DiagramEdit({\n data,\n onChange,\n editable,\n blockId,\n title,\n summary,\n ctx,\n}: BlockEditProps<DiagramData>) {\n const htmlId = useId();\n const cssId = useId();\n const captionId = useId();\n const legacyId = useId();\n const [html, setHtml] = useState(data.html ?? \"\");\n const [css, setCss] = useState(data.css ?? \"\");\n const [caption, setCaption] = useState(data.caption ?? \"\");\n const [legacyJson, setLegacyJson] = useState(() =>\n JSON.stringify(\n {\n nodes: data.nodes ?? [],\n edges: data.edges ?? [],\n notes: data.notes ?? [],\n },\n null,\n 2,\n ),\n );\n\n useEffect(() => {\n setHtml(data.html ?? \"\");\n setCss(data.css ?? \"\");\n setCaption(data.caption ?? \"\");\n setLegacyJson(\n JSON.stringify(\n {\n nodes: data.nodes ?? [],\n edges: data.edges ?? [],\n notes: data.notes ?? [],\n },\n null,\n 2,\n ),\n );\n }, [data]);\n\n const saveHtmlDiagram = () => {\n onChange({\n html: html.trim() || undefined,\n css: css.trim() || undefined,\n caption: caption.trim() || undefined,\n nodes: data.nodes,\n edges: data.edges,\n notes: data.notes,\n });\n };\n\n const saveLegacyDiagram = () => {\n const parsed = JSON.parse(legacyJson) as Pick<\n DiagramData,\n \"nodes\" | \"edges\" | \"notes\"\n >;\n onChange({\n ...data,\n nodes: parsed.nodes ?? [],\n edges: parsed.edges ?? [],\n notes: parsed.notes ?? [],\n });\n };\n\n const fieldAction = (\n field: \"HTML / SVG fragment\" | \"CSS\" | \"caption\" | \"legacy node graph JSON\",\n value: string,\n ) => ({\n blockId,\n blockType: \"diagram\",\n blockTitle: title,\n blockSummary: summary,\n fieldValue: value,\n draftScope: `block:diagram:${blockId}:${field.toLowerCase().replace(/[^a-z0-9]+/g, \"-\")}`,\n disabled: !editable,\n instructions:\n \"Update the plan with update-visual-plan using a targeted update-block content patch for this diagram block id. Preserve unrelated diagram fields unless the requested edit requires changing them. Keep diagram HTML/CSS on renderer-owned .diagram-* primitives and --wf-* tokens; do not introduce custom font-family or hard-coded hex/rgb/hsl colors.\",\n companionFields: [\n {\n label: \"HTML / SVG fragment\",\n value: html.trim() || \"(empty)\",\n language: \"html\",\n },\n { label: \"CSS\", value: css.trim() || \"(empty)\", language: \"css\" },\n {\n label: \"caption\",\n value: caption.trim() || \"(empty)\",\n language: \"text\",\n },\n ],\n });\n\n return (\n <div className=\"grid gap-4\" data-plan-interactive>\n <button\n type=\"button\"\n className=\"inline-flex h-8 w-fit items-center justify-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground disabled:opacity-50\"\n disabled={!editable}\n onClick={saveHtmlDiagram}\n >\n Save diagram\n </button>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={htmlId}\n label=\"HTML / SVG fragment\"\n ctx={ctx}\n action={fieldAction(\"HTML / SVG fragment\", html)}\n />\n <textarea\n id={htmlId}\n className=\"min-h-48 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={html}\n disabled={!editable}\n onChange={(event) => setHtml(event.target.value)}\n placeholder=\"<div class='diagram'>...</div>\"\n />\n </div>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={cssId}\n label=\"CSS\"\n ctx={ctx}\n action={fieldAction(\"CSS\", css)}\n />\n <textarea\n id={cssId}\n className=\"min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={css}\n disabled={!editable}\n onChange={(event) => setCss(event.target.value)}\n placeholder=\".diagram { display: grid; }\"\n />\n </div>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={captionId}\n label=\"Caption\"\n ctx={ctx}\n action={fieldAction(\"caption\", caption)}\n />\n <input\n id={captionId}\n className=\"h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={caption}\n disabled={!editable}\n onChange={(event) => setCaption(event.target.value)}\n />\n </div>\n {!data.html && (\n <details className=\"rounded-md border border-border p-3\">\n <summary className=\"cursor-pointer text-xs font-semibold text-muted-foreground\">\n Legacy node graph data\n </summary>\n <div className=\"group/field mt-3 grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={legacyId}\n label=\"JSON\"\n ctx={ctx}\n action={fieldAction(\"legacy node graph JSON\", legacyJson)}\n />\n <textarea\n id={legacyId}\n className=\"min-h-44 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={legacyJson}\n disabled={!editable}\n onChange={(event) => setLegacyJson(event.target.value)}\n />\n </div>\n <button\n type=\"button\"\n className=\"mt-3 inline-flex h-8 items-center justify-center rounded-md border border-input px-3 text-xs font-medium text-foreground disabled:opacity-50\"\n disabled={!editable}\n onClick={saveLegacyDiagram}\n >\n Save graph data\n </button>\n </details>\n )}\n </div>\n );\n}\n\n/** Full client spec for the shared `diagram` block (schema + MDX + Read/Edit). */\nexport const diagramBlock = defineBlock<DiagramData>({\n type: \"diagram\",\n schema: diagramSchema,\n mdx: diagramMdx,\n Read: DiagramRead,\n Edit: DiagramEdit,\n placement: [\"block\"],\n // Config-driven: the rendered diagram differs from its raw html/css source, so\n // edit from a corner button + panel rather than inline.\n editSurface: \"panel\",\n label: \"Diagram\",\n description:\n \"A flexible inline architecture/code diagram. Prefer html/css with SVG or semantic HTML for polished two-dimensional layouts; use .diagram-* primitives and --wf-* tokens for theme/sketch compatibility. Legacy nodes/edges are only for simple previews.\",\n // Seed the legacy fallback shape so a fresh block validates while agents can\n // replace it with html/css when layout quality matters.\n empty: () => ({ nodes: [{ id: \"n1\", label: \"Module\" }], edges: [] }),\n});\n"]}
|
|
1
|
+
{"version":3,"file":"diagram.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/diagram.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,KAAK,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EACL,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,aAAa,GAId,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,oBAAoB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,+BAA+B,aAC5C,KAAC,oBAAoB,IACnB,OAAO,EAAE,QAAQ,EACjB,KAAK,EAAC,MAAM,EACZ,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,WAAW,CAAC,wBAAwB,EAAE,UAAU,CAAC,GACzD,EACF,mBACE,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAC,4LAA4L,EACtM,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,CAAC,QAAQ,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GACtD,IACE,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,8IAA8I,EACxJ,QAAQ,EAAE,CAAC,QAAQ,EACnB,OAAO,EAAE,iBAAiB,gCAGnB,IACD,CACX,IACG,CACP,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAc;IACnD,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,aAAa;IACrB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,+EAA+E;IAC/E,wDAAwD;IACxD,WAAW,EAAE,OAAO;IACpB,KAAK,EAAE,SAAS;IAChB,WAAW,EACT,uSAAuS;IACzS,6EAA6E;IAC7E,wDAAwD;IACxD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;CACrE,CAAC,CAAC","sourcesContent":["import {\n IconArrowsMaximize,\n IconScribble,\n IconShape2,\n IconX,\n} from \"@tabler/icons-react\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\n\nimport {\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from \"../../components/ui/tooltip.js\";\nimport { cn } from \"../../utils.js\";\nimport { AiEditableFieldLabel } from \"../AiEditableField.js\";\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport { useBlockCopy } from \"./block-copy.js\";\nimport {\n diagramMdx,\n diagramSchema,\n type DiagramData,\n type DiagramEdge,\n type DiagramNode,\n} from \"./diagram.config.js\";\nimport {\n sanitizeDiagramHtml,\n sanitizeWireframeCss,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\nimport {\n RoughOverlay,\n toggleWireframeStyle,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\n\n/**\n * Read + Edit renderers for the shared `diagram` block — a flexible inline\n * architecture/code diagram. The preferred authoring path is a scoped, inert\n * HTML/SVG fragment that leans on `.diagram-*` primitives and `--wf-*` tokens;\n * a legacy positional / sequence node-graph path is kept for older/simple plans.\n * Lives in core so any app can register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original (mirrors the sibling `wireframe.tsx` port):\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes`; `useWireframeStyle()` reads the viewer's sketchy/clean\n * preference from the shared `plan-wireframe-style` localStorage key — both\n * from `./wireframe-kit.js`, so core stays plan-free and shadcn-free.\n * - HTML sanitize: the HTML/SVG fragment + CSS run through the app-injected\n * `ctx.sanitizeHtml` at the render point (defense-in-depth against stored\n * XSS). Without a sanitizer wired, the HTML path emits nothing — core never\n * injects unsanitized author HTML. The React-free `diagramSchema` already\n * rejects active markup before storage.\n * - The rough.js sketch overlay reuses the kit's shared `RoughOverlay`, scoped\n * with the diagram selector and `drawFrame={false}` (the same call the plan\n * `HtmlDiagram` made). The `.plan-diagram-frame` / `.diagram-*` / `data-rough`\n * class contract is preserved exactly so the theme-token CSS in core's\n * `blocks.css` styles it in any app.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment.\n */\n\n/* -------------------------------------------------------------------------- */\n/* HTML/SVG diagram path */\n/* -------------------------------------------------------------------------- */\n\n/** The rough-overlay selector for diagram bordered boxes (mirrors the plan). */\nconst DIAGRAM_ROUGH_SELECTOR =\n \"[data-rough],.diagram-panel,.diagram-node,.diagram-box,.diagram-pill,.diagram-card,[class*='card'],[class*='box'],[class*='panel'],[class*='pill'],[class*='chip'],[class*='badge'],hr\";\n\nfunction HtmlDiagram({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const preferredStyle = useWireframeStyle();\n const designMode = data.renderMode === \"design\";\n const style = designMode ? \"clean\" : preferredStyle;\n const showFrame = resolveVisualFrame(data.frame, ctx);\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n // Sanitize author HTML/CSS at the render point (defense-in-depth against\n // stored XSS). Self-contained in core via the shared block sanitizer (DOM-based\n // in the browser, regex fallback on the server) so diagrams render in any app\n // without the host wiring a sanitizer hook.\n const safeHtml = useMemo(() => sanitizeDiagramHtml(data.html), [data.html]);\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this diagram instance so global\n // selectors (body, *, .app-shell, :root) can't escape and restyle the page.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-diagram-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <div\n ref={ref}\n className={cn(\"plan-diagram-shell\", compact && \"plan-diagram-compact\")}\n >\n <div\n className=\"plan-diagram-frame\"\n dir={ctx.textDirection}\n data-theme={isDark ? \"dark\" : \"light\"}\n data-style={style}\n data-frame={showFrame ? \"show\" : \"hide\"}\n data-text-direction={ctx.textDirection}\n data-plan-diagram-scope={scopeId}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-diagram-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n <RoughOverlay\n scopeRef={ref}\n enabled={!designMode && style === \"sketchy\"}\n drawFrame={showFrame}\n selector={DIAGRAM_ROUGH_SELECTOR}\n />\n {data.caption && !compact && (\n <p className=\"mt-3 text-sm leading-6 text-muted-foreground\">\n {data.caption}\n </p>\n )}\n </div>\n );\n}\n\nfunction resolveVisualFrame(\n frame: DiagramData[\"frame\"],\n ctx: BlockRenderContext,\n): boolean {\n const resolved =\n frame && frame !== \"auto\" ? frame : (ctx.visualFrame ?? \"show\");\n return resolved !== \"hide\";\n}\n\n/* -------------------------------------------------------------------------- */\n/* Legacy node-graph paths */\n/* -------------------------------------------------------------------------- */\n\nfunction clampDiagramPercent(value: number) {\n if (!Number.isFinite(value)) return 50;\n return Math.max(4, Math.min(96, value));\n}\n\nfunction hasPositionedDiagramNodes(data: DiagramData): boolean {\n return (data.nodes ?? []).some(\n (node) => typeof node.x === \"number\" && typeof node.y === \"number\",\n );\n}\n\nfunction orderDiagramNodes(\n nodes: DiagramNode[],\n edges: DiagramEdge[],\n): DiagramNode[] {\n if (nodes.length === 0) return [];\n const byId = new Map(nodes.map((node) => [node.id, node]));\n const indegree = new Map(nodes.map((node) => [node.id, 0]));\n for (const edge of edges) {\n if (byId.has(edge.from) && byId.has(edge.to)) {\n indegree.set(edge.to, (indegree.get(edge.to) ?? 0) + 1);\n }\n }\n const start = nodes.find((node) => (indegree.get(node.id) ?? 0) === 0);\n if (!start) return nodes;\n const ordered: DiagramNode[] = [];\n const seen = new Set<string>();\n let current: DiagramNode | undefined = start;\n while (current && !seen.has(current.id)) {\n const node: DiagramNode = current;\n ordered.push(node);\n seen.add(node.id);\n const next = edges.find((edge) => edge.from === node.id);\n current = next ? byId.get(next.to) : undefined;\n }\n for (const node of nodes) if (!seen.has(node.id)) ordered.push(node);\n return ordered;\n}\n\nfunction PositionedDiagram({\n data,\n compact,\n markerId,\n direction,\n showFrame,\n}: {\n data: DiagramData;\n compact?: boolean;\n markerId: string;\n direction?: BlockRenderContext[\"textDirection\"];\n showFrame: boolean;\n}) {\n const nodes = (data.nodes ?? []).map((node) => ({\n ...node,\n x: clampDiagramPercent(node.x ?? 50),\n y: clampDiagramPercent(node.y ?? 50),\n }));\n const edges = data.edges ?? [];\n const arrowId = `${markerId}-diagram-arrow`;\n const nodeWidth = compact ? 150 : 190;\n const rows = diagramRows(nodes, compact);\n const canvasHeight = diagramCanvasHeight(rows.length, compact);\n const canvasMinWidth = compact ? 560 : 720;\n const nodeWidthPct = compact ? 20 : 18;\n const nodeHeightPct = compact ? 14 : 18;\n const paddedViewBox = diagramViewBox(nodes, nodeWidthPct, nodeHeightPct);\n const xMargin = compact ? 13 : 14;\n const yMargin = compact ? 15 : 18;\n const displayNodes = nodes.map((node) => ({\n ...node,\n displayXBase: diagramPointPercent(\n node.x,\n paddedViewBox.x,\n paddedViewBox.width,\n xMargin,\n ),\n displayY: diagramRowPointPercent(node.y, rows, paddedViewBox, yMargin),\n }));\n const displayNodesForDirection = displayNodes.map((node) => ({\n ...node,\n displayX: direction === \"rtl\" ? 100 - node.displayXBase : node.displayXBase,\n }));\n const nodeByIdForDirection = new Map(\n displayNodesForDirection.map((node) => [node.id, node]),\n );\n\n return (\n <div\n className={cn(\n \"plan-sketch\",\n showFrame ? \"rounded-[16px] border border-border bg-muted p-5\" : \"p-0\",\n )}\n dir={direction}\n data-text-direction={direction}\n >\n <div\n className=\"overflow-auto rounded-xl border border-border bg-background\"\n style={{ minHeight: canvasHeight }}\n >\n <div\n className=\"relative\"\n style={{ minHeight: canvasHeight, minWidth: canvasMinWidth }}\n >\n <svg\n className=\"pointer-events-none absolute inset-0 z-0 h-full w-full\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"none\"\n aria-hidden=\"true\"\n >\n <defs>\n <marker\n id={arrowId}\n viewBox=\"0 0 10 10\"\n refX=\"8\"\n refY=\"5\"\n markerWidth=\"5\"\n markerHeight=\"5\"\n orient=\"auto-start-reverse\"\n >\n <path\n d=\"M 0 0 L 10 5 L 0 10 z\"\n className=\"fill-muted-foreground\"\n />\n </marker>\n </defs>\n {edges.map((edge, index) => {\n const from = nodeByIdForDirection.get(edge.from);\n const to = nodeByIdForDirection.get(edge.to);\n if (!from || !to) return null;\n return (\n <line\n key={`${edge.from}-${edge.to}-${index}`}\n x1={from.displayX}\n y1={from.displayY}\n x2={to.displayX}\n y2={to.displayY}\n markerEnd={`url(#${arrowId})`}\n vectorEffect=\"non-scaling-stroke\"\n className=\"stroke-border\"\n strokeWidth={2}\n strokeDasharray={edge.label ? \"0\" : \"6 5\"}\n />\n );\n })}\n </svg>\n\n {!compact &&\n edges.map((edge, index) => {\n const from = nodeByIdForDirection.get(edge.from);\n const to = nodeByIdForDirection.get(edge.to);\n if (!edge.label || !from || !to) return null;\n return (\n <span\n key={`${edge.from}-${edge.to}-${index}-label`}\n className=\"absolute z-10 max-w-[130px] -translate-x-1/2 -translate-y-1/2 break-words rounded-full border border-border bg-background px-2 py-0.5 text-center text-[11px] font-semibold text-muted-foreground shadow-sm [overflow-wrap:anywhere]\"\n style={{\n left: `${(from.displayX + to.displayX) / 2}%`,\n top: `${(from.displayY + to.displayY) / 2}%`,\n }}\n >\n {edge.label}\n </span>\n );\n })}\n\n {displayNodesForDirection.map((node, index) => (\n <article\n key={node.id}\n className=\"absolute z-20 -translate-x-1/2 -translate-y-1/2 break-words rounded-xl border-2 border-border bg-background p-3 text-foreground shadow-sm [overflow-wrap:anywhere]\"\n style={{\n left: `${node.displayX}%`,\n top: `${node.displayY}%`,\n width: nodeWidth,\n }}\n >\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground\">\n {index + 1}\n </p>\n <h3 className=\"mt-2 text-base font-semibold leading-tight\">\n {node.label}\n </h3>\n {node.detail && !compact && (\n <p className=\"mt-2 text-xs leading-5 text-muted-foreground\">\n {node.detail}\n </p>\n )}\n </article>\n ))}\n </div>\n </div>\n {data.notes && data.notes.length > 0 && !compact && (\n <div className=\"mt-4 grid gap-2 border-t border-border pt-4 text-sm text-muted-foreground md:grid-cols-2\">\n {data.notes.map((note) => (\n <p key={note.id}>{note.text}</p>\n ))}\n </div>\n )}\n </div>\n );\n}\n\ntype DiagramViewBox = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\nfunction diagramViewBox(\n nodes: Array<Pick<DiagramNode, \"x\" | \"y\">>,\n nodeWidthPct: number,\n nodeHeightPct: number,\n): DiagramViewBox {\n if (nodes.length === 0) return { x: 0, y: 0, width: 100, height: 100 };\n\n const halfWidth = nodeWidthPct / 2;\n const halfHeight = nodeHeightPct / 2;\n const left = Math.min(...nodes.map((node) => (node.x ?? 50) - halfWidth));\n const right = Math.max(...nodes.map((node) => (node.x ?? 50) + halfWidth));\n const top = Math.min(...nodes.map((node) => (node.y ?? 50) - halfHeight));\n const bottom = Math.max(...nodes.map((node) => (node.y ?? 50) + halfHeight));\n\n const x = Math.min(0, left);\n const y = Math.min(0, top);\n const width = Math.max(100, right) - x;\n const height = Math.max(100, bottom) - y;\n\n return { x, y, width, height };\n}\n\nfunction diagramPointPercent(\n value: number,\n viewBoxStart: number,\n viewBoxSize: number,\n margin = 0,\n): number {\n if (\n !Number.isFinite(value) ||\n !Number.isFinite(viewBoxSize) ||\n !viewBoxSize\n ) {\n return 50;\n }\n const percent = ((value - viewBoxStart) / viewBoxSize) * 100;\n return Math.min(100 - margin, Math.max(margin, percent));\n}\n\nfunction diagramRows(\n nodes: Array<Pick<DiagramNode, \"y\">>,\n compact?: boolean,\n): number[] {\n const rowGap = compact ? 8 : 10;\n return [...nodes]\n .sort((a, b) => (a.y ?? 50) - (b.y ?? 50))\n .reduce<number[]>((acc, node) => {\n const y = node.y ?? 50;\n const last = acc[acc.length - 1];\n if (last == null || Math.abs(y - last) >= rowGap) acc.push(y);\n return acc;\n }, []);\n}\n\nfunction diagramRowPointPercent(\n value: number,\n rows: number[],\n viewBox: DiagramViewBox,\n margin: number,\n): number {\n if (rows.length <= 2) {\n return diagramPointPercent(value, viewBox.y, viewBox.height, margin);\n }\n const closestIndex = rows.reduce((bestIndex, row, index) => {\n const bestDistance = Math.abs((rows[bestIndex] ?? 50) - value);\n return Math.abs(row - value) < bestDistance ? index : bestIndex;\n }, 0);\n const span = 100 - margin * 2;\n return margin + (span * closestIndex) / Math.max(1, rows.length - 1);\n}\n\nfunction diagramCanvasHeight(rows: number, compact?: boolean): number {\n const base = compact ? 280 : 430;\n if (rows <= 2) return base;\n return Math.max(base, rows * (compact ? 140 : 190) + (compact ? 80 : 120));\n}\n\nfunction SequenceDiagram({\n data,\n compact,\n direction,\n showFrame,\n}: {\n data: DiagramData;\n compact?: boolean;\n direction?: BlockRenderContext[\"textDirection\"];\n showFrame: boolean;\n}) {\n const edges = data.edges ?? [];\n const nodes = orderDiagramNodes(data.nodes ?? [], edges);\n if (nodes.length === 0) {\n return (\n <div className=\"rounded-[12px] border border-border bg-muted p-4 text-sm text-muted-foreground\">\n Diagram content is empty.\n </div>\n );\n }\n const visualNodes = direction === \"rtl\" ? [...nodes].reverse() : nodes;\n return (\n <div\n className={cn(\n \"plan-sketch\",\n showFrame ? \"rounded-[16px] border border-border bg-muted p-5\" : \"p-0\",\n )}\n dir={direction}\n data-text-direction={direction}\n >\n <div\n className={cn(\n \"flex gap-3 overflow-x-auto pb-2\",\n compact ? \"items-center\" : \"items-stretch\",\n )}\n >\n {visualNodes.map((node, index) => {\n const next = visualNodes[index + 1];\n const edge = next\n ? edges.find(\n (candidate) =>\n (candidate.from === node.id && candidate.to === next.id) ||\n (candidate.from === next.id && candidate.to === node.id),\n )\n : undefined;\n return (\n <div key={node.id} className=\"flex min-w-max items-center gap-3\">\n <article\n className={cn(\n \"w-[180px] rounded-xl border-2 border-border bg-background p-3 text-foreground\",\n compact && \"w-[150px]\",\n )}\n >\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground\">\n {index + 1}\n </p>\n <h3 className=\"mt-2 text-base font-semibold leading-tight\">\n {node.label}\n </h3>\n {node.detail && !compact && (\n <p className=\"mt-2 text-xs leading-5 text-muted-foreground\">\n {node.detail}\n </p>\n )}\n </article>\n {next && (\n <div className=\"grid min-w-[72px] justify-items-center gap-1 text-muted-foreground\">\n {edge?.label && (\n <span className=\"max-w-[96px] whitespace-normal break-words rounded-full border border-border px-2 py-0.5 text-center text-[11px] font-semibold [overflow-wrap:anywhere]\">\n {edge.label}\n </span>\n )}\n <span className=\"h-0.5 w-full rounded-full border-t-2 border-dashed border-border\" />\n </div>\n )}\n </div>\n );\n })}\n </div>\n {data.notes && data.notes.length > 0 && !compact && (\n <div className=\"mt-4 grid gap-2 border-t border-border pt-4 text-sm text-muted-foreground md:grid-cols-2\">\n {data.notes.map((note) => (\n <p key={note.id}>{note.text}</p>\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * The diagram body. Routes to the preferred HTML/SVG path (when `data.html` is\n * set) and otherwise to a legacy node-graph path (positioned canvas when nodes\n * carry x/y, else an ordered sequence). Used both inline and, scaled up, inside\n * the expand lightbox — so every variant (html/css, positioned, sequence)\n * enlarges through the same code path.\n */\nfunction DiagramBody({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const markerId = useId().replace(/:/g, \"\");\n const showFrame = resolveVisualFrame(data.frame, ctx);\n if (data.html?.trim()) {\n return <HtmlDiagram data={data} ctx={ctx} compact={compact} />;\n }\n if (hasPositionedDiagramNodes(data)) {\n return (\n <PositionedDiagram\n data={data}\n compact={compact}\n markerId={markerId}\n direction={ctx.textDirection}\n showFrame={showFrame}\n />\n );\n }\n return (\n <SequenceDiagram\n data={data}\n compact={compact}\n direction={ctx.textDirection}\n showFrame={showFrame}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Expand / lightbox */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Enlarge overlay for a rendered diagram. Mirrors the image lightbox contract\n * used by the composer's `ImagePreviewLightbox` (PromptComposer.tsx) so the\n * expand affordance feels identical to viewing an image full-size: a fixed\n * `bg-black/80` backdrop, Escape to close, click-the-backdrop to close, and a\n * top-right close button. Unlike the image variant this renders arbitrary\n * children (the diagram body re-rendered larger) rather than an `<img>`, since a\n * diagram is live HTML/SVG/node-graph markup, not an image URL.\n *\n * Exported so the separate Mermaid block (`MermaidBlock.tsx`, which renders its\n * diagram to an SVG through a different runtime) can reuse the exact same\n * lightbox contract — one expand affordance shared across both diagram types.\n */\nexport function DiagramLightbox({\n children,\n onClose,\n}: {\n children: React.ReactNode;\n onClose: () => void;\n}) {\n useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onClose();\n };\n document.addEventListener(\"keydown\", handler);\n document.body.style.overflow = \"hidden\";\n return () => {\n document.removeEventListener(\"keydown\", handler);\n document.body.style.overflow = \"\";\n };\n }, [onClose]);\n\n return (\n <div\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Diagram preview\"\n onClick={onClose}\n data-plan-interactive\n className=\"fixed inset-0 z-[300] flex items-center justify-center overflow-auto bg-black/80 p-6 cursor-zoom-out\"\n >\n <div\n onClick={(e) => e.stopPropagation()}\n className=\"max-h-full w-full max-w-5xl cursor-default overflow-auto rounded-md bg-background p-6 shadow-2xl\"\n >\n {children}\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close preview\"\n className=\"absolute right-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full border border-white/30 bg-black/40 text-white hover:bg-black/60\"\n >\n <IconX className=\"h-4 w-4\" />\n </button>\n </div>\n );\n}\n\n/**\n * The diagram body plus a hover-revealed top-right \"expand\" button (like the\n * image attachment zoom). Opening the button re-renders the exact same\n * `DiagramBody` inside `DiagramLightbox` at a larger size, so html/css and\n * mermaid/legacy node-graph diagrams alike enlarge through one path. The inline\n * (non-expanded) render is otherwise unchanged.\n */\nfunction ExpandableDiagramBody({\n data,\n ctx,\n compact,\n}: {\n data: DiagramData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const [expanded, setExpanded] = useState(false);\n const designMode = data.renderMode === \"design\";\n const supportsStyleToggle = Boolean(data.html) && !designMode;\n const style = useWireframeStyle();\n const copy = useBlockCopy();\n const sketchy = style === \"sketchy\";\n const styleLabel = sketchy\n ? copy.switchToCleanDiagrams\n : copy.switchToHandDrawnDiagrams;\n const styleTooltip = sketchy\n ? copy.handDrawnDiagramsSwitch\n : copy.cleanDiagramsSwitch;\n return (\n <div className=\"group/diagram relative\">\n <DiagramBody data={data} ctx={ctx} compact={compact} />\n <TooltipProvider delayDuration={100} skipDelayDuration={0}>\n <div className=\"absolute right-2 top-2 z-10 flex items-center gap-1.5\">\n {supportsStyleToggle && (\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n onClick={() => toggleWireframeStyle()}\n aria-label={styleLabel}\n aria-pressed={sketchy}\n className=\"an-diagram-style-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100\"\n >\n {sketchy ? (\n <IconScribble className=\"size-4\" />\n ) : (\n <IconShape2 className=\"size-4\" />\n )}\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"left\">{styleTooltip}</TooltipContent>\n </Tooltip>\n )}\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n data-plan-interactive\n onClick={() => setExpanded(true)}\n aria-label={copy.expandDiagram}\n className=\"an-diagram-expand-trigger flex size-7 items-center justify-center rounded-md border border-border/60 bg-background text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/diagram:opacity-100\"\n >\n <IconArrowsMaximize className=\"size-4\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"left\">{copy.expandDiagram}</TooltipContent>\n </Tooltip>\n </div>\n </TooltipProvider>\n {expanded ? (\n <DiagramLightbox onClose={() => setExpanded(false)}>\n <DiagramBody data={data} ctx={ctx} />\n </DiagramLightbox>\n ) : null}\n </div>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Read + Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer: the diagram body wrapped in the standard titled block. */\nexport function DiagramRead({\n data,\n blockId,\n title,\n summary,\n ctx,\n compactVisuals,\n}: BlockReadProps<DiagramData>) {\n return (\n <section\n {...ltrCodeBlockProps}\n className=\"an-block plan-block\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <ExpandableDiagramBody data={data} ctx={ctx} compact={compactVisuals} />\n {summary && <p className=\"mt-5 text-muted-foreground\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Edit form (panel surface). The block can be an HTML/SVG fragment or a legacy\n * node/edge/note graph, so this exposes html/css/caption plus a collapsible\n * legacy node-graph JSON editor, each with an AI-edit affordance via\n * `ctx.renderAiFieldAction` (through `AiEditableFieldLabel`). `editSurface:\n * \"panel\"` means the registry renders the `Read` view with a corner edit button\n * that opens this form in the app-provided popover.\n */\nexport function DiagramEdit({\n data,\n onChange,\n editable,\n blockId,\n title,\n summary,\n ctx,\n}: BlockEditProps<DiagramData>) {\n const htmlId = useId();\n const cssId = useId();\n const captionId = useId();\n const legacyId = useId();\n const [html, setHtml] = useState(data.html ?? \"\");\n const [css, setCss] = useState(data.css ?? \"\");\n const [caption, setCaption] = useState(data.caption ?? \"\");\n const [legacyJson, setLegacyJson] = useState(() =>\n JSON.stringify(\n {\n nodes: data.nodes ?? [],\n edges: data.edges ?? [],\n notes: data.notes ?? [],\n },\n null,\n 2,\n ),\n );\n\n useEffect(() => {\n setHtml(data.html ?? \"\");\n setCss(data.css ?? \"\");\n setCaption(data.caption ?? \"\");\n setLegacyJson(\n JSON.stringify(\n {\n nodes: data.nodes ?? [],\n edges: data.edges ?? [],\n notes: data.notes ?? [],\n },\n null,\n 2,\n ),\n );\n }, [data]);\n\n const saveHtmlDiagram = () => {\n onChange({\n html: html.trim() || undefined,\n css: css.trim() || undefined,\n renderMode: data.renderMode,\n caption: caption.trim() || undefined,\n frame: data.frame,\n nodes: data.nodes,\n edges: data.edges,\n notes: data.notes,\n });\n };\n\n const saveLegacyDiagram = () => {\n const parsed = JSON.parse(legacyJson) as Pick<\n DiagramData,\n \"nodes\" | \"edges\" | \"notes\"\n >;\n onChange({\n ...data,\n nodes: parsed.nodes ?? [],\n edges: parsed.edges ?? [],\n notes: parsed.notes ?? [],\n });\n };\n\n const fieldAction = (\n field: \"HTML / SVG fragment\" | \"CSS\" | \"caption\" | \"legacy node graph JSON\",\n value: string,\n ) => ({\n blockId,\n blockType: \"diagram\",\n blockTitle: title,\n blockSummary: summary,\n fieldValue: value,\n draftScope: `block:diagram:${blockId}:${field.toLowerCase().replace(/[^a-z0-9]+/g, \"-\")}`,\n disabled: !editable,\n instructions:\n \"Update the plan with update-visual-plan using a targeted update-block content patch for this diagram block id. Preserve unrelated diagram fields unless the requested edit requires changing them. Keep diagram HTML/CSS on renderer-owned .diagram-* primitives and --wf-* tokens; do not introduce custom font-family or hard-coded hex/rgb/hsl colors.\",\n companionFields: [\n {\n label: \"HTML / SVG fragment\",\n value: html.trim() || \"(empty)\",\n language: \"html\",\n },\n { label: \"CSS\", value: css.trim() || \"(empty)\", language: \"css\" },\n {\n label: \"caption\",\n value: caption.trim() || \"(empty)\",\n language: \"text\",\n },\n ],\n });\n\n return (\n <div className=\"grid gap-4\" data-plan-interactive>\n <button\n type=\"button\"\n className=\"inline-flex h-8 w-fit items-center justify-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground disabled:opacity-50\"\n disabled={!editable}\n onClick={saveHtmlDiagram}\n >\n Save diagram\n </button>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={htmlId}\n label=\"HTML / SVG fragment\"\n ctx={ctx}\n action={fieldAction(\"HTML / SVG fragment\", html)}\n />\n <textarea\n id={htmlId}\n className=\"min-h-48 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={html}\n disabled={!editable}\n onChange={(event) => setHtml(event.target.value)}\n placeholder=\"<div class='diagram'>...</div>\"\n />\n </div>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={cssId}\n label=\"CSS\"\n ctx={ctx}\n action={fieldAction(\"CSS\", css)}\n />\n <textarea\n id={cssId}\n className=\"min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={css}\n disabled={!editable}\n onChange={(event) => setCss(event.target.value)}\n placeholder=\".diagram { display: grid; }\"\n />\n </div>\n <div className=\"group/field grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={captionId}\n label=\"Caption\"\n ctx={ctx}\n action={fieldAction(\"caption\", caption)}\n />\n <input\n id={captionId}\n className=\"h-9 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={caption}\n disabled={!editable}\n onChange={(event) => setCaption(event.target.value)}\n />\n </div>\n {!data.html && (\n <details className=\"rounded-md border border-border p-3\">\n <summary className=\"cursor-pointer text-xs font-semibold text-muted-foreground\">\n Legacy node graph data\n </summary>\n <div className=\"group/field mt-3 grid gap-1.5\">\n <AiEditableFieldLabel\n htmlFor={legacyId}\n label=\"JSON\"\n ctx={ctx}\n action={fieldAction(\"legacy node graph JSON\", legacyJson)}\n />\n <textarea\n id={legacyId}\n className=\"min-h-44 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs leading-5 text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n value={legacyJson}\n disabled={!editable}\n onChange={(event) => setLegacyJson(event.target.value)}\n />\n </div>\n <button\n type=\"button\"\n className=\"mt-3 inline-flex h-8 items-center justify-center rounded-md border border-input px-3 text-xs font-medium text-foreground disabled:opacity-50\"\n disabled={!editable}\n onClick={saveLegacyDiagram}\n >\n Save graph data\n </button>\n </details>\n )}\n </div>\n );\n}\n\n/** Full client spec for the shared `diagram` block (schema + MDX + Read/Edit). */\nexport const diagramBlock = defineBlock<DiagramData>({\n type: \"diagram\",\n schema: diagramSchema,\n mdx: diagramMdx,\n Read: DiagramRead,\n Edit: DiagramEdit,\n placement: [\"block\"],\n // Config-driven: the rendered diagram differs from its raw html/css source, so\n // edit from a corner button + panel rather than inline.\n editSurface: \"panel\",\n label: \"Diagram\",\n description:\n \"A flexible inline architecture/code diagram. Prefer html/css with SVG or semantic HTML for polished two-dimensional layouts; use renderMode design for clean presentation or .diagram-* primitives and --wf-* tokens for theme/sketch compatibility. Legacy nodes/edges are only for simple previews.\",\n // Seed the legacy fallback shape so a fresh block validates while agents can\n // replace it with html/css when layout quality matters.\n empty: () => ({ nodes: [{ id: \"n1\", label: \"Module\" }], edges: [] }),\n});\n"]}
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
ok?: undefined;
|
|
17
16
|
error: string;
|
|
17
|
+
ok?: undefined;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
package/dist/deploy/build.d.ts
CHANGED
|
@@ -17,6 +17,9 @@ import { type WorkspaceCoreExports } from "./workspace-core.js";
|
|
|
17
17
|
export declare const NITRO_RUNTIME_IGNORE_PATTERNS: string[];
|
|
18
18
|
export declare const CLOUDFLARE_WORKER_ESBUILD_EXTERNALS: string[];
|
|
19
19
|
export declare const CLOUDFLARE_WORKER_STUB_MODULES: Record<string, string>;
|
|
20
|
+
export declare const CLOUDFLARE_WORKER_STUB_SUBPATH_MODULES: Record<string, string>;
|
|
21
|
+
export declare function cloudflareWorkerStubAliasArgs(stubDir: string): string[];
|
|
22
|
+
export declare function assertNoCloudflareWorkerStubDynamicImports(code: string, sourceName: string): void;
|
|
20
23
|
export declare const CLOUDFLARE_WORKER_NODE_BUILTIN_STUB_MODULES: Record<string, string>;
|
|
21
24
|
export interface GenerateWorkerEntryOptions {
|
|
22
25
|
includeReactRouterSsr?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAuCH,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,6BAA6B,UAiBzC,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAiB/C,CAAC;AACF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAuCH,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,6BAA6B,UAiBzC,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAiB/C,CAAC;AACF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyFjE,CAAC;AAEF,eAAO,MAAM,sCAAsC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQzE,CAAC;AA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ist/deploy/build.js
CHANGED
|
@@ -95,6 +95,14 @@ export const CLOUDFLARE_WORKER_STUB_MODULES = {
|
|
|
95
95
|
"export default { Resvg };",
|
|
96
96
|
"",
|
|
97
97
|
].join("\n"),
|
|
98
|
+
playwright: [
|
|
99
|
+
"const unavailable = async () => { throw new Error('playwright unavailable in Cloudflare Pages worker'); };",
|
|
100
|
+
"export const chromium = { launch: unavailable, connect: unavailable, connectOverCDP: unavailable };",
|
|
101
|
+
"export const firefox = { launch: unavailable, connect: unavailable };",
|
|
102
|
+
"export const webkit = { launch: unavailable, connect: unavailable };",
|
|
103
|
+
"export default { chromium, firefox, webkit };",
|
|
104
|
+
"",
|
|
105
|
+
].join("\n"),
|
|
98
106
|
"playwright-core": [
|
|
99
107
|
"const unavailable = async () => { throw new Error('playwright-core unavailable in Cloudflare Pages worker'); };",
|
|
100
108
|
"export const chromium = { launch: unavailable };",
|
|
@@ -139,6 +147,38 @@ export const CLOUDFLARE_WORKER_STUB_MODULES = {
|
|
|
139
147
|
"@excalidraw/excalidraw": "export default {}; export const MainMenu = {}; export const WelcomeScreen = {};\n",
|
|
140
148
|
"@excalidraw/mermaid-to-excalidraw": "export default async () => ({ elements: [], files: {} });\n",
|
|
141
149
|
};
|
|
150
|
+
export const CLOUDFLARE_WORKER_STUB_SUBPATH_MODULES = {
|
|
151
|
+
"pdf-parse/worker": [
|
|
152
|
+
"const unavailable = async () => { throw new Error('pdf-parse/worker unavailable in Cloudflare Pages worker'); };",
|
|
153
|
+
"export class CanvasFactory {}",
|
|
154
|
+
"export const getData = unavailable;",
|
|
155
|
+
"export default { CanvasFactory, getData };",
|
|
156
|
+
"",
|
|
157
|
+
].join("\n"),
|
|
158
|
+
};
|
|
159
|
+
export function cloudflareWorkerStubAliasArgs(stubDir) {
|
|
160
|
+
const subpathAliases = Object.keys(CLOUDFLARE_WORKER_STUB_SUBPATH_MODULES)
|
|
161
|
+
.sort((a, b) => b.length - a.length)
|
|
162
|
+
.map((mod) => `--alias:${mod}=${path.join(stubDir, `${mod.replace(/\//g, "__")}.js`)}`);
|
|
163
|
+
const packageAliases = Object.keys(CLOUDFLARE_WORKER_STUB_MODULES)
|
|
164
|
+
.sort((a, b) => b.length - a.length)
|
|
165
|
+
.map((mod) => `--alias:${mod}=${path.join(stubDir, mod, "index.js")}`);
|
|
166
|
+
return [...subpathAliases, ...packageAliases];
|
|
167
|
+
}
|
|
168
|
+
export function assertNoCloudflareWorkerStubDynamicImports(code, sourceName) {
|
|
169
|
+
const stubbedModules = [
|
|
170
|
+
...Object.keys(CLOUDFLARE_WORKER_STUB_SUBPATH_MODULES),
|
|
171
|
+
...Object.keys(CLOUDFLARE_WORKER_STUB_MODULES),
|
|
172
|
+
];
|
|
173
|
+
const pattern = stubbedModules
|
|
174
|
+
.sort((a, b) => b.length - a.length)
|
|
175
|
+
.map((moduleName) => moduleName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
176
|
+
.join("|");
|
|
177
|
+
const unresolvedImport = code.match(new RegExp(`\\bimport\\s*\\(\\s*(["'])(${pattern})\\1\\s*\\)`));
|
|
178
|
+
if (!unresolvedImport)
|
|
179
|
+
return;
|
|
180
|
+
throw new Error(`Cloudflare worker output ${sourceName} retained a dynamic import for stubbed module "${unresolvedImport[2]}". Use a literal import so the worker bundler can apply its fail-closed stub.`);
|
|
181
|
+
}
|
|
142
182
|
function cloudflareNodeBuiltinStubSource(moduleName, namedExports, overrides = []) {
|
|
143
183
|
const overridden = new Set(overrides.flatMap((source) => Array.from(source.matchAll(/\bexport const ([A-Za-z_$][\w$]*)/g)).map((match) => match[1])));
|
|
144
184
|
const exports = Array.from(new Set(namedExports))
|
|
@@ -1367,7 +1407,10 @@ async function buildCloudflarePages() {
|
|
|
1367
1407
|
fs.writeFileSync(path.join(modDir, "index.js"), source);
|
|
1368
1408
|
fs.writeFileSync(path.join(modDir, "package.json"), JSON.stringify({ name: mod, main: "index.js", type: "module" }));
|
|
1369
1409
|
}
|
|
1370
|
-
const
|
|
1410
|
+
for (const [mod, source] of Object.entries(CLOUDFLARE_WORKER_STUB_SUBPATH_MODULES)) {
|
|
1411
|
+
fs.writeFileSync(path.join(stubDir, `${mod.replace(/\//g, "__")}.js`), source);
|
|
1412
|
+
}
|
|
1413
|
+
const stubAliases = cloudflareWorkerStubAliasArgs(stubDir);
|
|
1371
1414
|
const nodeBuiltinStubDir = path.join(tmpDir, "node-builtin-stubs");
|
|
1372
1415
|
fs.mkdirSync(nodeBuiltinStubDir, { recursive: true });
|
|
1373
1416
|
const nodeBuiltinStubAliases = [];
|
|
@@ -1502,6 +1545,7 @@ async function buildCloudflarePages() {
|
|
|
1502
1545
|
const timerRestore = "if(__origSetInterval)globalThis.setInterval=__origSetInterval;";
|
|
1503
1546
|
code = code.replace(/async fetch\(request,\s*env,\s*ctx\)\s*\{/, (match) => match + timerRestore);
|
|
1504
1547
|
}
|
|
1548
|
+
assertNoCloudflareWorkerStubDynamicImports(code, jsFile);
|
|
1505
1549
|
fs.writeFileSync(jsFile, code);
|
|
1506
1550
|
}
|
|
1507
1551
|
// Report size
|