@01.software/sdk 0.4.1 → 0.4.3-dev.1774320821495

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/Flow/index.tsx","../../src/ui/Flow/types.ts","../../src/ui/Flow/built-in-node-types.ts","../../src/ui/Flow/built-in-edge-types.ts","../../src/ui/Flow/useFlow.ts","../../src/core/query/query-keys.ts","../../src/ui/Flow/useFlowData.ts","../../src/ui/Flow/utils.ts"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {\n ReactFlow,\n ReactFlowProvider,\n Background,\n Controls,\n MiniMap,\n MarkerType,\n useReactFlow,\n type NodeTypes,\n type NodeProps,\n type Edge,\n} from '@xyflow/react'\nimport type {\n CanvasData,\n DynamicNodeData,\n DynamicNodeSlotProps,\n EdgeSlotProps,\n EdgeTypeDef,\n FlowBounds,\n FlowEdge,\n FlowNode,\n FlowViewport,\n FrameNodeData,\n FrameNodeSlotProps,\n NodeTypeDef,\n NodeTypeFieldDef,\n NodeWrapperSlotProps,\n} from './types'\n\nexport type {\n CanvasData,\n DynamicNodeSlotProps,\n FlowNode,\n FlowEdge,\n FlowViewport,\n FlowNodePosition,\n FlowNodeData,\n DynamicNodeData,\n FrameNodeData,\n NodeTypeDef,\n NodeTypeFieldDef,\n EdgeTypeDef,\n FrameNodeSlotProps,\n EdgeSlotProps,\n NodeWrapperSlotProps,\n FlowBounds,\n} from './types'\nexport { isDynamicNode, isFrameNode } from './types'\nexport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nexport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\nexport { useFlow } from './useFlow'\nexport type { SDKClient, UseFlowOptions, UseFlowResult } from './useFlow'\nexport { useFlowData } from './useFlowData'\nexport type { UseFlowDataOptions, UseFlowDataResult } from './useFlowData'\nexport { getNodeBounds, getFrames } from './utils'\n\n// ── Helpers ──\n\nfunction sanitizeUrl(url: string | undefined): string | undefined {\n if (!url) return url\n try {\n const parsed = new URL(url)\n if (parsed.protocol === 'http:' || parsed.protocol === 'https:') return url\n return undefined\n } catch {\n return undefined\n }\n}\n\nfunction toMarkerType(value: string): MarkerType | undefined {\n if (value === 'arrow') return MarkerType.Arrow\n if (value === 'arrowclosed') return MarkerType.ArrowClosed\n return undefined\n}\n\n// ── Field renderer (type-aware, matching console style) ──\n\nfunction renderFieldValue(\n key: string,\n val: unknown,\n fieldDef?: NodeTypeFieldDef,\n): React.ReactNode {\n if (val == null || val === '') return null\n\n const fieldType = fieldDef?.fieldType\n\n // Image field — image only, no decoration\n if (\n fieldType === 'image' ||\n (typeof val === 'object' && val !== null && 'url' in val)\n ) {\n const imgUrl =\n typeof val === 'string' ? val : (val as { url?: string })?.url\n const safeUrl = sanitizeUrl(imgUrl)\n if (!safeUrl) return null\n return (\n <img\n key={key}\n src={safeUrl}\n alt=\"\"\n draggable={false}\n style={{ flex: 1, minHeight: 0, width: '100%', objectFit: 'contain' }}\n />\n )\n }\n\n // All other fields — text only\n return (\n <div\n key={key}\n style={{\n fontSize: 11,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n overflow: 'hidden',\n flexShrink: 0,\n }}\n >\n {String(val)}\n </div>\n )\n}\n\n// ── Default dynamic node renderer (no typeDef) ──\n\nfunction DefaultDynamicNode({ data }: NodeProps) {\n const d = data as unknown as DynamicNodeData\n return (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {d.fields &&\n Object.entries(d.fields)\n .filter(([, v]) => v != null && v !== '')\n .map(([key, val]) => renderFieldValue(key, val))}\n </div>\n )\n}\n\n// ── Enhanced dynamic node renderer (with NodeTypeDef) ──\n\nfunction EnhancedDynamicNode({\n data,\n typeDef,\n}: {\n data: DynamicNodeData\n typeDef: NodeTypeDef\n}) {\n return (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {typeDef.fields.map((f) => {\n const val = data.fields[f.name]\n if (val == null || val === '') return null\n return renderFieldValue(f.name, val, f)\n })}\n </div>\n )\n}\n\n// ── Default frame node renderer ──\n\nfunction DefaultFrameNode({ data }: NodeProps) {\n const d = data as unknown as FrameNodeData\n const baseColor = d.color ?? 'rgba(128,128,128,0.15)'\n const padding = d.padding ?? 20\n const borderStyle = d.borderStyle ?? 'dashed'\n const opacity = d.opacity ?? 0.15\n\n // Apply opacity to rgba colors\n const bgColor = (() => {\n const m = baseColor.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/)\n if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`\n return baseColor\n })()\n\n return (\n <div\n style={{\n backgroundColor: bgColor,\n padding,\n width: '100%',\n height: '100%',\n border:\n borderStyle === 'none'\n ? 'none'\n : `2px ${borderStyle} rgba(128,128,128,0.3)`,\n }}\n >\n <div\n style={{\n fontSize: 11,\n fontWeight: 600,\n color: 'rgba(128,128,128,0.6)',\n userSelect: 'none',\n }}\n >\n {d.label}\n </div>\n </div>\n )\n}\n\n// ── Node types builder ──\n\nfunction createNodeTypes(\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>,\n nodeTypeDefsMap?: Map<string, NodeTypeDef>,\n frameRenderer?: React.ComponentType<FrameNodeSlotProps>,\n nodeWrapper?: React.ComponentType<NodeWrapperSlotProps>,\n renderNode?: (props: DynamicNodeSlotProps, defaultRender: React.ReactElement) => React.ReactElement | null,\n): NodeTypes {\n const types: NodeTypes = {} as NodeTypes\n\n // Dynamic node type\n types.dynamic = ((props: NodeProps) => {\n const d = props.data as unknown as DynamicNodeData\n const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug)\n const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug]\n\n let content: React.ReactElement\n if (CustomRenderer) {\n content = (\n <CustomRenderer\n id={props.id}\n nodeTypeSlug={d.nodeTypeSlug}\n label={d.label}\n fields={d.fields}\n nodeTypeDef={typeDef}\n />\n )\n } else if (typeDef) {\n content = <EnhancedDynamicNode data={d} typeDef={typeDef} />\n } else {\n content = <DefaultDynamicNode {...props} />\n }\n\n // S5: renderNode global callback\n if (renderNode) {\n const slotProps: DynamicNodeSlotProps = {\n id: props.id,\n nodeTypeSlug: d.nodeTypeSlug,\n label: d.label,\n fields: d.fields,\n nodeTypeDef: typeDef,\n }\n const result = renderNode(slotProps, content)\n if (result !== null) content = result\n }\n\n // S3: nodeWrapper\n if (nodeWrapper) {\n const Wrapper = nodeWrapper\n content = (\n <Wrapper\n id={props.id}\n nodeTypeSlug={d.nodeTypeSlug}\n label={d.label}\n selected={props.selected}\n nodeTypeDef={typeDef}\n >\n {content}\n </Wrapper>\n )\n }\n\n return content\n }) as NodeTypes[string]\n\n // S1: Frame node type — custom or default\n types.frame = frameRenderer\n ? (((props: NodeProps) => {\n const d = props.data as unknown as FrameNodeData\n const Renderer = frameRenderer\n return (\n <Renderer\n id={props.id}\n label={d.label}\n color={d.color}\n padding={d.padding}\n borderStyle={d.borderStyle}\n opacity={d.opacity}\n />\n )\n }) as NodeTypes[string])\n : (DefaultFrameNode as NodeTypes[string])\n\n return types\n}\n\n// S2: Edge types builder\n\nfunction createEdgeTypes(\n edgeRenderers?: Record<string, React.ComponentType<EdgeSlotProps>>,\n edgeTypeDefsMap?: Map<string, EdgeTypeDef>,\n): Record<string, React.ComponentType<EdgeSlotProps>> | undefined {\n if (!edgeRenderers || Object.keys(edgeRenderers).length === 0) return undefined\n const types: Record<string, React.ComponentType<EdgeSlotProps>> = {}\n for (const [slug, Renderer] of Object.entries(edgeRenderers)) {\n types[slug] = ((props: Record<string, unknown>) => {\n const def = edgeTypeDefsMap?.get(slug)\n return (\n <Renderer\n id={props.id as string}\n edgeTypeSlug={slug}\n source={props.source as string}\n target={props.target as string}\n label={props.label as string | undefined}\n fields={(props.data as Record<string, unknown> | undefined)?.fields as Record<string, unknown> | undefined}\n edgeTypeDef={def}\n style={props.style as React.CSSProperties | undefined}\n />\n )\n }) as unknown as React.ComponentType<EdgeSlotProps>\n }\n return types\n}\n\n// S8: FocusHandler — must be inside ReactFlowProvider\n\nfunction FocusHandler({\n bounds,\n padding,\n animation,\n}: {\n bounds: FlowBounds\n padding: number\n animation: boolean | number\n}) {\n const { fitBounds } = useReactFlow()\n const boundsKey = `${bounds.x},${bounds.y},${bounds.width},${bounds.height}`\n const boundsRef = React.useRef(bounds)\n boundsRef.current = bounds\n React.useEffect(() => {\n const duration =\n animation === true ? 300 : typeof animation === 'number' ? animation : 0\n fitBounds(boundsRef.current, { padding, duration })\n }, [boundsKey, padding, animation, fitBounds])\n return null\n}\n\n// ── Edge style resolver ──\n\nconst EDGE_TYPE_MAP: Record<string, string> = {\n step: 'step',\n smoothstep: 'smoothstep',\n bezier: 'default',\n default: 'default',\n}\n\nfunction applyEdgeStyles(\n edges: FlowEdge[],\n edgeTypeDefsMap?: Map<string, EdgeTypeDef>,\n): Edge[] {\n if (!edgeTypeDefsMap?.size) return edges as unknown as Edge[]\n\n return edges.map((edge) => {\n const slug = edge.edgeTypeSlug\n if (!slug) return edge as unknown as Edge\n\n const def = edgeTypeDefsMap.get(slug)\n if (!def) return edge as unknown as Edge\n\n const styled: Edge = { ...(edge as unknown as Edge) }\n\n // Edge type (line style) — canvas value takes precedence\n if (!styled.type && def.lineStyle) {\n styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? 'default'\n }\n\n // Visual style — canvas style merged with def as fallback\n styled.style = {\n ...(def.color ? { stroke: def.color } : undefined),\n ...(def.strokeWidth ? { strokeWidth: def.strokeWidth } : undefined),\n ...edge.style,\n }\n\n // Animation — canvas value takes precedence\n if (styled.animated == null && def.animated) styled.animated = true\n\n // Markers — canvas value takes precedence over def\n if (!styled.markerStart) {\n const startType = toMarkerType(def.markerStart)\n if (startType) {\n styled.markerStart = {\n type: startType,\n ...(def.color ? { color: def.color } : undefined),\n }\n }\n }\n if (!styled.markerEnd) {\n const endType = toMarkerType(def.markerEnd)\n if (endType) {\n styled.markerEnd = {\n type: endType,\n ...(def.color ? { color: def.color } : undefined),\n }\n }\n }\n\n return styled\n })\n}\n\n// ── FlowRenderer ──\n\n/**\n * Renders a Flow canvas in read-only mode.\n *\n * Requires `@xyflow/react` peer dependency and its CSS:\n * ```ts\n * import '@xyflow/react/dist/style.css'\n * ```\n */\nexport interface FlowRendererProps {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData\n /** Container className */\n className?: string\n /** Container style */\n style?: React.CSSProperties\n /** Custom renderers by node type slug (e.g., `{ 'product-card': MyProductCard }`) */\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>\n /** Node type definitions for enhanced rendering (field-type-aware display) */\n nodeTypeDefs?: NodeTypeDef[]\n /** Edge type definitions for styled edges (color, stroke, markers, animation) */\n edgeTypeDefs?: EdgeTypeDef[]\n /** Show background pattern (default: false) */\n background?: boolean\n /** Allow user interaction - pan, zoom (default: false for read-only display) */\n interactive?: boolean\n /** Fit view on mount (default: true) */\n fitView?: boolean\n /** Called when a node is clicked */\n onNodeClick?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when an edge is clicked */\n onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void\n /** S1: Custom frame node renderer. Should be a stable reference (memoize or define outside render). */\n frameRenderer?: React.ComponentType<FrameNodeSlotProps>\n /** S2: Custom edge renderers by edge type slug. Should be a stable reference (memoize or define outside render). */\n edgeRenderers?: Record<string, React.ComponentType<EdgeSlotProps>>\n /** S3: Wraps every dynamic node's rendered content. Should be a stable reference (memoize or define outside render). */\n nodeWrapper?: React.ComponentType<NodeWrapperSlotProps>\n /** S4: Show controls (default: false) */\n controls?: boolean\n /** S4: Show minimap (default: false) */\n minimap?: boolean\n /** S4: Custom minimap node color function */\n minimapNodeColor?: (node: FlowNode) => string\n /** S4: Additional children rendered inside ReactFlow */\n children?: React.ReactNode\n /** S5: Global override for all dynamic nodes. Should be a stable reference (memoize or define outside render). */\n renderNode?: (props: DynamicNodeSlotProps, defaultRender: React.ReactElement) => React.ReactElement | null\n /** S6: Called when viewport changes (pan/zoom) */\n onViewportChange?: (viewport: FlowViewport) => void\n /** S6: Default viewport (used when fitView is false) */\n defaultViewport?: FlowViewport\n /** S8: Focus on specific bounds */\n bounds?: FlowBounds\n /** S8: Padding for focus bounds (default: 0.1) */\n focusPadding?: number\n /** S8: Animate focus transition (true=300ms, number=custom ms, false=instant) */\n focusAnimation?: boolean | number\n}\n\nexport function FlowRenderer({\n data,\n className,\n style,\n nodeRenderers,\n nodeTypeDefs,\n edgeTypeDefs,\n background = false,\n interactive = false,\n fitView = true,\n onNodeClick,\n onEdgeClick,\n frameRenderer,\n edgeRenderers,\n nodeWrapper,\n controls,\n minimap,\n minimapNodeColor,\n children,\n renderNode,\n onViewportChange,\n defaultViewport: defaultViewportProp,\n bounds,\n focusPadding,\n focusAnimation,\n}: FlowRendererProps) {\n const nodeTypeDefsMap = React.useMemo(() => {\n if (!nodeTypeDefs?.length) return undefined\n return new Map(nodeTypeDefs.map((d) => [d.slug, d]))\n }, [nodeTypeDefs])\n\n const edgeTypeDefsMap = React.useMemo(() => {\n if (!edgeTypeDefs?.length) return undefined\n return new Map(edgeTypeDefs.map((d) => [d.slug, d]))\n }, [edgeTypeDefs])\n\n const nodeTypes = React.useMemo(\n () => createNodeTypes(nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode),\n [nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode],\n )\n\n // S2: Custom edge types\n const customEdgeTypes = React.useMemo(\n () => createEdgeTypes(edgeRenderers, edgeTypeDefsMap),\n [edgeRenderers, edgeTypeDefsMap],\n )\n\n const styledEdges = React.useMemo(() => {\n let edges = applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap)\n // When custom edge renderers exist, set edge type to slug for matching\n if (edgeRenderers) {\n edges = edges.map((edge) => {\n const slug = (edge as unknown as FlowEdge).edgeTypeSlug\n if (slug && edgeRenderers[slug]) {\n return { ...edge, type: slug }\n }\n return edge\n })\n }\n return edges\n }, [data?.edges, edgeTypeDefsMap, edgeRenderers])\n\n if (!data) return null\n\n const resolvedDefaultViewport =\n defaultViewportProp ?? (!fitView && data.viewport ? data.viewport : undefined)\n\n return (\n <ReactFlowProvider>\n <div\n className={className}\n style={{ width: '100%', height: '100%', ...style }}\n >\n <ReactFlow\n nodes={\n (data.nodes ?? []) as unknown as Parameters<\n typeof ReactFlow\n >[0]['nodes']\n }\n edges={styledEdges}\n nodeTypes={nodeTypes}\n edgeTypes={customEdgeTypes as Parameters<typeof ReactFlow>[0]['edgeTypes']}\n defaultViewport={resolvedDefaultViewport}\n fitView={fitView}\n onNodeClick={\n onNodeClick as Parameters<typeof ReactFlow>[0]['onNodeClick']\n }\n onEdgeClick={\n onEdgeClick as Parameters<typeof ReactFlow>[0]['onEdgeClick']\n }\n onMoveEnd={\n onViewportChange\n ? ((_: unknown, vp: { x: number; y: number; zoom: number }) => {\n onViewportChange(vp)\n }) as Parameters<typeof ReactFlow>[0]['onMoveEnd']\n : undefined\n }\n nodesDraggable={interactive ? undefined : false}\n nodesConnectable={false}\n elementsSelectable={interactive || !!onNodeClick || !!onEdgeClick}\n panOnDrag={interactive}\n zoomOnScroll={interactive}\n zoomOnPinch={interactive}\n zoomOnDoubleClick={false}\n >\n {background && <Background />}\n {controls && <Controls />}\n {minimap && (\n <MiniMap\n nodeColor={\n minimapNodeColor as Parameters<typeof MiniMap>[0]['nodeColor']\n }\n />\n )}\n {bounds && (\n <FocusHandler\n bounds={bounds}\n padding={focusPadding ?? 0.1}\n animation={focusAnimation ?? true}\n />\n )}\n {children}\n </ReactFlow>\n </div>\n </ReactFlowProvider>\n )\n}\n","import type React from 'react'\n\n// ── Dynamic node data ──\n\nexport interface DynamicNodeData {\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n}\n\nexport type FlowNodeData = DynamicNodeData & Record<string, unknown>\n\n// ── Canvas types (mirrors @xyflow/react but standalone) ──\n\nexport interface FlowNodePosition {\n x: number\n y: number\n}\n\nexport interface FlowNode {\n id: string\n type?: string\n position: FlowNodePosition\n data: FlowNodeData\n style?: React.CSSProperties\n width?: number\n height?: number\n measured?: { width?: number; height?: number }\n draggable?: boolean\n selectable?: boolean\n [key: string]: unknown\n}\n\nexport interface FlowEdge {\n id: string\n source: string\n target: string\n sourceHandle?: string | null\n targetHandle?: string | null\n type?: string\n style?: React.CSSProperties\n animated?: boolean\n markerStart?: unknown\n markerEnd?: unknown\n edgeTypeSlug?: string\n fields?: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport interface FlowViewport {\n x: number\n y: number\n zoom: number\n}\n\nexport interface CanvasData {\n nodes: FlowNode[]\n edges: FlowEdge[]\n viewport: FlowViewport\n}\n\n// ── Node type definitions (mirrors console's NodeTypeDef) ──\n\nexport interface NodeTypeFieldDef {\n name: string\n label: string\n fieldType:\n | 'text'\n | 'textarea'\n | 'number'\n | 'url'\n | 'color'\n | 'image'\n | 'select'\n | 'toggle'\n options?: { label: string; value: string }[]\n defaultValue?: string\n required?: boolean\n}\n\nexport interface NodeTypeDef {\n slug: string\n name: string\n color: string\n defaultSize: { width: number; height: number }\n fields: NodeTypeFieldDef[]\n transparentBackground?: boolean\n}\n\n// ── Edge type definitions (mirrors console's EdgeTypeDef) ──\n\nexport interface EdgeTypeDef {\n slug: string\n name: string\n color: string\n strokeWidth: number\n animated: boolean\n lineStyle: string\n markerStart: string\n markerEnd: string\n fields: NodeTypeFieldDef[]\n}\n\n// ── Type guards ──\n\nexport function isDynamicNode(\n node: FlowNode,\n): node is FlowNode & { data: DynamicNodeData } {\n return node.type === 'dynamic'\n}\n\nexport function isFrameNode(\n node: FlowNode,\n): node is FlowNode & { data: FrameNodeData } {\n return node.type === 'frame'\n}\n\n// ── Component slot props ──\n\nexport interface DynamicNodeSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n nodeTypeDef?: NodeTypeDef\n}\n\n// ── Frame node data ──\n\nexport interface FrameNodeData {\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n}\n\n// S1: Frame renderer slot\nexport interface FrameNodeSlotProps {\n id: string\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n children?: React.ReactNode\n}\n\n// S2: Edge renderer slot\nexport interface EdgeSlotProps {\n id: string\n edgeTypeSlug?: string\n source: string\n target: string\n label?: string\n fields?: Record<string, unknown>\n edgeTypeDef?: EdgeTypeDef\n style?: React.CSSProperties\n}\n\n// S3: Node wrapper slot\nexport interface NodeWrapperSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n selected?: boolean\n nodeTypeDef?: NodeTypeDef\n children: React.ReactNode\n}\n\n// S8: Viewport focus\nexport interface FlowBounds {\n x: number\n y: number\n width: number\n height: number\n}\n","import type { NodeTypeDef } from './types'\n\nexport const BUILT_IN_NODE_TYPES: NodeTypeDef[] = [\n {\n slug: 'text',\n name: 'Text',\n color: '#e5e7eb',\n defaultSize: { width: 200, height: 200 },\n fields: [{ name: 'body', label: 'Body', fieldType: 'textarea' }],\n },\n {\n slug: 'image',\n name: 'Image',\n color: '#e5e7eb',\n transparentBackground: true,\n defaultSize: { width: 200, height: 200 },\n fields: [\n { name: 'image', label: 'Image', fieldType: 'image' },\n { name: 'alt', label: 'Alt Text', fieldType: 'text' },\n { name: 'caption', label: 'Caption', fieldType: 'text' },\n ],\n },\n]\n","import type { EdgeTypeDef } from './types'\n\nexport const BUILT_IN_EDGE_TYPES: EdgeTypeDef[] = [\n {\n slug: 'default',\n name: 'Default',\n color: '',\n strokeWidth: 2,\n animated: false,\n lineStyle: 'default',\n markerStart: 'none',\n markerEnd: 'arrow',\n fields: [],\n },\n]\n","'use client'\n\nimport { useQuery, type QueryClient } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport type { CanvasData, NodeTypeDef, EdgeTypeDef } from './types'\nimport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nimport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\nimport { collectionKeys } from '../../core/query/query-keys'\n\n// ── Client interface ──\n// Structurally compatible with both BrowserClient and ServerClient.\n// Lists only the collections useFlow actually queries so the generic\n// `from<T extends PublicCollection>` on the real clients satisfies this.\n\ntype FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFn = (...args: any[]) => any\n\nexport interface SDKClient {\n from(collection: FlowCollection): {\n find: AnyFn\n findById: AnyFn\n }\n queryClient: QueryClient\n}\n\n// ── Options & Result ──\n\nexport interface UseFlowOptions {\n /** SDK client instance (BrowserClient or ServerClient) */\n client: SDKClient\n /** Flow slug (URL-friendly identifier) */\n slug?: string\n /** Flow document ID (UUID) */\n id?: string\n /** Enable/disable data fetching (default: true) */\n enabled?: boolean\n}\n\nexport interface UseFlowResult {\n data: CanvasData | undefined\n nodeTypeDefs: NodeTypeDef[]\n edgeTypeDefs: EdgeTypeDef[]\n flow: Record<string, unknown> | undefined\n isLoading: boolean\n error: Error | null\n}\n\n// ── Helpers ──\n\nfunction toNodeTypeDef(doc: Record<string, unknown>): NodeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? '#e5e7eb'),\n defaultSize: (doc.defaultSize as NodeTypeDef['defaultSize']) ?? {\n width: 200,\n height: 200,\n },\n fields: Array.isArray(doc.fields)\n ? (doc.fields as NodeTypeDef['fields'])\n : [],\n transparentBackground: Boolean(doc.transparentBackground),\n }\n}\n\nfunction toEdgeTypeDef(doc: Record<string, unknown>): EdgeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? ''),\n strokeWidth: (doc.strokeWidth as number) ?? 2,\n animated: (doc.animated as boolean) ?? false,\n lineStyle: String(doc.lineStyle ?? 'default'),\n markerStart: String(doc.markerStart ?? 'none'),\n markerEnd: String(doc.markerEnd ?? 'arrow'),\n fields: Array.isArray(doc.fields)\n ? (doc.fields as EdgeTypeDef['fields'])\n : [],\n }\n}\n\n// ── Hook ──\n\nexport function useFlow(options: UseFlowOptions): UseFlowResult {\n const { client, slug, id, enabled = true } = options\n const hasIdentifier = !!(slug || id)\n const identifier = id ?? slug ?? ''\n\n // Fetch flow document\n const flowQuery = useQuery<Record<string, unknown>>(\n {\n queryKey: collectionKeys('flows').detail(identifier),\n queryFn: async () => {\n if (id) {\n return client.from('flows').findById(id)\n }\n const result = await client.from('flows').find({\n where: { slug: { equals: slug } },\n limit: 1,\n })\n const doc = result.docs[0]\n if (!doc) throw new Error(`Flow not found: ${slug}`)\n return doc\n },\n enabled: enabled && hasIdentifier,\n },\n client.queryClient,\n )\n\n // Fetch tenant's custom node types\n const nodeTypesQuery = useQuery<Record<string, unknown>[]>(\n {\n queryKey: collectionKeys('flow-node-types').lists(),\n queryFn: async () => {\n const result = await client.from('flow-node-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n },\n client.queryClient,\n )\n\n // Fetch tenant's custom edge types\n const edgeTypesQuery = useQuery<Record<string, unknown>[]>(\n {\n queryKey: collectionKeys('flow-edge-types').lists(),\n queryFn: async () => {\n const result = await client.from('flow-edge-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n },\n client.queryClient,\n )\n\n // Merge built-in + API node types\n const nodeTypeDefs = useMemo<NodeTypeDef[]>(() => {\n const apiDefs = (nodeTypesQuery.data ?? []).map(toNodeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_NODE_TYPES, ...customDefs]\n }, [nodeTypesQuery.data])\n\n // Merge built-in + API edge types\n const edgeTypeDefs = useMemo<EdgeTypeDef[]>(() => {\n const apiDefs = (edgeTypesQuery.data ?? []).map(toEdgeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_EDGE_TYPES, ...customDefs]\n }, [edgeTypesQuery.data])\n\n const flow = flowQuery.data\n const canvas = flow?.canvas as CanvasData | undefined\n\n return {\n data: canvas,\n nodeTypeDefs,\n edgeTypeDefs,\n flow,\n isLoading:\n flowQuery.isLoading ||\n nodeTypesQuery.isLoading ||\n edgeTypesQuery.isLoading,\n error:\n (flowQuery.error as Error | null) ??\n (nodeTypesQuery.error as Error | null) ??\n (edgeTypesQuery.error as Error | null),\n }\n}\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n","import { useMemo } from 'react'\nimport type { CanvasData, FlowNode, NodeTypeDef, EdgeTypeDef } from './types'\nimport type { Edge } from '@xyflow/react'\nimport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nimport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\n\n// ── Options & Result ──\n\nexport interface UseFlowDataOptions {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData | undefined\n /** Node type definitions (defaults to built-in types) */\n nodeTypeDefs?: NodeTypeDef[]\n /** Edge type definitions (defaults to built-in types) */\n edgeTypeDefs?: EdgeTypeDef[]\n}\n\nexport interface UseFlowDataResult {\n /** Nodes from canvas data */\n nodes: FlowNode[]\n /** Edges from canvas data (typed for @xyflow/react) */\n edges: Edge[]\n /** Map of node type slug to definition */\n nodeTypeDefsMap: Map<string, NodeTypeDef>\n /** Map of edge type slug to definition */\n edgeTypeDefsMap: Map<string, EdgeTypeDef>\n}\n\n/**\n * Pure data transformation hook — extracts nodes, edges, and type definition\n * maps from canvas data without any rendering. Useful for headless usage\n * (custom layouts, analytics, server-side processing).\n */\nexport function useFlowData(options: UseFlowDataOptions): UseFlowDataResult {\n const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } =\n options\n\n const nodeTypeDefsMap = useMemo(() => {\n const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES\n return new Map(allDefs.map((d) => [d.slug, d]))\n }, [inputNodeDefs])\n\n const edgeTypeDefsMap = useMemo(() => {\n const allDefs = inputEdgeDefs ?? BUILT_IN_EDGE_TYPES\n return new Map(allDefs.map((d) => [d.slug, d]))\n }, [inputEdgeDefs])\n\n const nodes = useMemo(() => data?.nodes ?? [], [data?.nodes])\n const edges = useMemo(() => (data?.edges ?? []) as unknown as Edge[], [data?.edges])\n\n return {\n nodes,\n edges,\n nodeTypeDefsMap,\n edgeTypeDefsMap,\n }\n}\n","import type { FlowNode, FlowBounds } from './types'\n\n/**\n * Calculate bounding box for given node IDs.\n * Pure function — usable in SSR, server components, or outside React.\n */\nexport function getNodeBounds(\n nodes: FlowNode[],\n nodeIds: string[],\n): FlowBounds | undefined {\n const idSet = new Set(nodeIds)\n const targetNodes = nodes.filter((n) => idSet.has(n.id))\n if (targetNodes.length === 0) return undefined\n\n // Build parent map for absolute position calculation\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n function getAbsolutePosition(node: FlowNode): { x: number; y: number } {\n let x = node.position.x\n let y = node.position.y\n let current = node\n const visited = new Set<string>([node.id])\n while (current.parentId as string | undefined) {\n const parentId = current.parentId as string\n if (visited.has(parentId)) break\n const parent = nodeMap.get(parentId)\n if (!parent) break\n visited.add(parent.id)\n x += parent.position.x\n y += parent.position.y\n current = parent\n }\n return { x, y }\n }\n\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n\n for (const node of targetNodes) {\n const abs = getAbsolutePosition(node)\n const w =\n (node.style?.width as number) ??\n node.measured?.width ??\n node.width ??\n 200\n const h =\n (node.style?.height as number) ??\n node.measured?.height ??\n node.height ??\n 200\n minX = Math.min(minX, abs.x)\n minY = Math.min(minY, abs.y)\n maxX = Math.max(maxX, abs.x + w)\n maxY = Math.max(maxY, abs.y + h)\n }\n\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\n/**\n * Get all frame nodes with their bounds.\n * Sorted by position (top-left to bottom-right).\n * Builds a single nodeMap to compute absolute positions (O(F) instead of O(F*N)).\n */\nexport function getFrames(\n nodes: FlowNode[],\n): Array<{ id: string; label: string; bounds: FlowBounds }> {\n const frames = nodes.filter((n) => n.type === 'frame')\n if (frames.length === 0) return []\n\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n function getAbsolutePosition(node: FlowNode): { x: number; y: number } {\n let x = node.position.x\n let y = node.position.y\n let current = node\n const visited = new Set<string>([node.id])\n while (current.parentId as string | undefined) {\n const parentId = current.parentId as string\n if (visited.has(parentId)) break\n const parent = nodeMap.get(parentId)\n if (!parent) break\n visited.add(parent.id)\n x += parent.position.x\n y += parent.position.y\n current = parent\n }\n return { x, y }\n }\n\n return frames\n .map((f) => {\n const data = f.data as { label?: string }\n const abs = getAbsolutePosition(f)\n const w = (f.style?.width as number) ?? f.measured?.width ?? f.width ?? 200\n const h = (f.style?.height as number) ?? f.measured?.height ?? f.height ?? 200\n return { id: f.id, label: data.label ?? '', bounds: { x: abs.x, y: abs.y, width: w, height: h } }\n })\n .sort((a, b) => a.bounds.y - b.bounds.y || a.bounds.x - b.bounds.x)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB,IAAAA,gBAWO;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QACX,cAAc;AAAA,QACd,aAAa;AAAA,QACb,mBAAmB;AAAA;AAAA,MAElB,cAAc,8BAAAA,QAAA,cAAC,8BAAW;AAAA,MAC1B,YAAY,8BAAAA,QAAA,cAAC,4BAAS;AAAA,MACtB,WACC,8BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC,WACE;AAAA;AAAA,MAEJ;AAAA,MAED,UACC,8BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,SAAS,sCAAgB;AAAA,UACzB,WAAW,0CAAkB;AAAA;AAAA,MAC/B;AAAA,MAED;AAAA,IACH;AAAA,EACF,CACF;AAEJ;","names":["import_react","_a","import_react","React","_a"]}
1
+ {"version":3,"sources":["../../src/ui/Flow/index.tsx","../../src/ui/Flow/types.ts","../../src/ui/Flow/built-in-node-types.ts","../../src/ui/Flow/built-in-edge-types.ts","../../src/ui/Flow/useFlow.ts","../../src/core/query/query-keys.ts","../../src/ui/Flow/useFlowData.ts","../../src/ui/Flow/utils.ts","../../src/ui/Flow/template-compiler.ts"],"sourcesContent":["'use client'\n\nimport React from 'react'\nimport {\n ReactFlow,\n ReactFlowProvider,\n Background,\n Controls,\n MiniMap,\n MarkerType,\n useReactFlow,\n type NodeTypes,\n type NodeProps,\n type Edge,\n} from '@xyflow/react'\nimport type {\n CanvasData,\n DynamicNodeData,\n DynamicNodeSlotProps,\n EdgeSlotProps,\n EdgeTypeDef,\n FlowBounds,\n FlowEdge,\n FlowNode,\n FlowViewport,\n FrameNodeData,\n FrameNodeSlotProps,\n NodeTypeDef,\n NodeTypeFieldDef,\n NodeWrapperSlotProps,\n} from './types'\n\nexport type {\n CanvasData,\n DynamicNodeSlotProps,\n FlowNode,\n FlowEdge,\n FlowViewport,\n FlowNodePosition,\n FlowNodeData,\n DynamicNodeData,\n FrameNodeData,\n NodeTypeDef,\n NodeTypeFieldDef,\n EdgeTypeDef,\n FrameNodeSlotProps,\n EdgeSlotProps,\n NodeWrapperSlotProps,\n FlowBounds,\n} from './types'\nexport { isDynamicNode, isFrameNode } from './types'\nexport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nexport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\nexport { useFlow } from './useFlow'\nexport type { SDKClient, UseFlowOptions, UseFlowResult } from './useFlow'\nexport { useFlowData } from './useFlowData'\nexport type { UseFlowDataOptions, UseFlowDataResult } from './useFlowData'\nexport { getNodeBounds, getFrames, getFrameData } from './utils'\nexport type { FrameData } from './utils'\nexport { compileTemplate, clearTemplateCache } from './template-compiler'\nexport type { CodeComponentProps } from './template-compiler'\n\nimport { compileTemplate } from './template-compiler'\n\n// ── Helpers ──\n\nfunction sanitizeUrl(url: string | undefined): string | undefined {\n if (!url) return url\n try {\n const parsed = new URL(url)\n if (parsed.protocol === 'http:' || parsed.protocol === 'https:') return url\n return undefined\n } catch {\n return undefined\n }\n}\n\nfunction toMarkerType(value: string): MarkerType | undefined {\n if (value === 'arrow') return MarkerType.Arrow\n if (value === 'arrowclosed') return MarkerType.ArrowClosed\n return undefined\n}\n\n// ── Field renderer (type-aware, matching console style) ──\n\nfunction renderFieldValue(\n key: string,\n val: unknown,\n fieldDef?: NodeTypeFieldDef,\n): React.ReactNode {\n if (val == null || val === '') return null\n\n const fieldType = fieldDef?.fieldType\n\n // Image field — image only, no decoration\n if (\n fieldType === 'image' ||\n (typeof val === 'object' && val !== null && 'url' in val)\n ) {\n const imgUrl =\n typeof val === 'string' ? val : (val as { url?: string })?.url\n const safeUrl = sanitizeUrl(imgUrl)\n if (!safeUrl) return null\n return (\n <img\n key={key}\n src={safeUrl}\n alt=\"\"\n draggable={false}\n style={{ flex: 1, minHeight: 0, width: '100%', objectFit: 'contain' }}\n />\n )\n }\n\n // All other fields — text only\n return (\n <div\n key={key}\n style={{\n fontSize: 11,\n whiteSpace: 'pre-wrap',\n wordBreak: 'break-word',\n overflow: 'hidden',\n flexShrink: 0,\n }}\n >\n {String(val)}\n </div>\n )\n}\n\n// ── Default dynamic node renderer (no typeDef) ──\n\nfunction DefaultDynamicNode({ data }: NodeProps) {\n const d = data as unknown as DynamicNodeData\n return (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {d.fields &&\n Object.entries(d.fields)\n .filter(([, v]) => v != null && v !== '')\n .map(([key, val]) => renderFieldValue(key, val))}\n </div>\n )\n}\n\n// ── Template error boundary ──\n\nclass TemplateErrorBoundary extends React.Component<\n { resetKey?: string; children: React.ReactNode },\n { error: Error | null }\n> {\n state: { error: Error | null } = { error: null }\n static getDerivedStateFromError(error: Error) {\n return { error }\n }\n componentDidUpdate(prevProps: { resetKey?: string }) {\n if (prevProps.resetKey !== this.props.resetKey && this.state.error) {\n this.setState({ error: null })\n }\n }\n render() {\n if (this.state.error) {\n return (\n <div style={{ padding: 8, fontSize: 11, color: '#ef4444' }}>\n <strong>Render error</strong>\n <pre style={{ fontSize: 10, whiteSpace: 'pre-wrap' }}>\n {this.state.error.message}\n </pre>\n </div>\n )\n }\n return this.props.children\n }\n}\n\n// ── Enhanced dynamic node renderer (with NodeTypeDef) ──\n\nfunction EnhancedDynamicNode({\n data,\n typeDef,\n width,\n height,\n}: {\n data: DynamicNodeData\n typeDef: NodeTypeDef\n width?: number\n height?: number\n}) {\n // Tier 2: Custom template rendering\n if (typeDef.template) {\n const Component = compileTemplate(typeDef.template, typeDef.slug)\n if (Component) {\n return (\n <div\n className={`flow-node flow-node--${typeDef.slug}${typeDef.transparentBackground ? ' flow-node--transparent-bg' : ''}`}\n style={{\n width: '100%',\n height: '100%',\n }}\n >\n <TemplateErrorBoundary resetKey={typeDef.template}>\n <Component\n fields={data.fields}\n label={data.label}\n color={typeDef.color}\n nodeTypeSlug={typeDef.slug}\n width={width ?? typeDef.defaultSize.width}\n height={height ?? typeDef.defaultSize.height}\n />\n </TemplateErrorBoundary>\n </div>\n )\n }\n }\n\n // Tier 1: Default field rendering\n return (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n {typeDef.fields.map((f) => {\n const val = data.fields[f.name]\n if (val == null || val === '') return null\n return renderFieldValue(f.name, val, f)\n })}\n </div>\n )\n}\n\n// ── Default frame node renderer ──\n\nfunction DefaultFrameNode({ data }: NodeProps) {\n const d = data as unknown as FrameNodeData\n const baseColor = d.color ?? 'rgba(128,128,128,0.15)'\n const padding = d.padding ?? 20\n const borderStyle = d.borderStyle ?? 'dashed'\n const opacity = d.opacity ?? 0.15\n\n // Apply opacity to rgba colors\n const bgColor = (() => {\n const m = baseColor.match(/rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/)\n if (m) return `rgba(${m[1]},${m[2]},${m[3]},${opacity})`\n return baseColor\n })()\n\n return (\n <div\n style={{\n backgroundColor: bgColor,\n padding,\n width: '100%',\n height: '100%',\n border:\n borderStyle === 'none'\n ? 'none'\n : `2px ${borderStyle} rgba(128,128,128,0.3)`,\n }}\n >\n <div\n style={{\n fontSize: 11,\n fontWeight: 600,\n color: 'rgba(128,128,128,0.6)',\n userSelect: 'none',\n }}\n >\n {d.label}\n </div>\n </div>\n )\n}\n\n// ── Node types builder ──\n\nfunction createNodeTypes(\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>,\n nodeTypeDefsMap?: Map<string, NodeTypeDef>,\n frameRenderer?: React.ComponentType<FrameNodeSlotProps>,\n nodeWrapper?: React.ComponentType<NodeWrapperSlotProps>,\n renderNode?: (\n props: DynamicNodeSlotProps,\n defaultRender: React.ReactElement,\n ) => React.ReactElement | null,\n): NodeTypes {\n const types: NodeTypes = {} as NodeTypes\n\n // Dynamic node type\n types.dynamic = ((props: NodeProps) => {\n const d = props.data as unknown as DynamicNodeData\n const typeDef = nodeTypeDefsMap?.get(d.nodeTypeSlug)\n const CustomRenderer = nodeRenderers?.[d.nodeTypeSlug]\n\n let content: React.ReactElement\n if (CustomRenderer) {\n content = (\n <CustomRenderer\n id={props.id}\n nodeTypeSlug={d.nodeTypeSlug}\n label={d.label}\n fields={d.fields}\n nodeTypeDef={typeDef}\n />\n )\n } else if (typeDef) {\n content = (\n <EnhancedDynamicNode\n data={d}\n typeDef={typeDef}\n width={props.width}\n height={props.height}\n />\n )\n } else {\n content = <DefaultDynamicNode {...props} />\n }\n\n // S5: renderNode global callback\n if (renderNode) {\n const slotProps: DynamicNodeSlotProps = {\n id: props.id,\n nodeTypeSlug: d.nodeTypeSlug,\n label: d.label,\n fields: d.fields,\n nodeTypeDef: typeDef,\n }\n const result = renderNode(slotProps, content)\n if (result !== null) content = result\n }\n\n // S3: nodeWrapper\n if (nodeWrapper) {\n const Wrapper = nodeWrapper\n content = (\n <Wrapper\n id={props.id}\n nodeTypeSlug={d.nodeTypeSlug}\n label={d.label}\n selected={props.selected}\n nodeTypeDef={typeDef}\n >\n {content}\n </Wrapper>\n )\n }\n\n return content\n }) as NodeTypes[string]\n\n // S1: Frame node type — custom or default\n types.frame = frameRenderer\n ? (((props: NodeProps) => {\n const d = props.data as unknown as FrameNodeData\n const Renderer = frameRenderer\n return (\n <Renderer\n id={props.id}\n label={d.label}\n color={d.color}\n padding={d.padding}\n borderStyle={d.borderStyle}\n opacity={d.opacity}\n />\n )\n }) as NodeTypes[string])\n : (DefaultFrameNode as NodeTypes[string])\n\n return types\n}\n\n// S2: Edge types builder\n\nfunction createEdgeTypes(\n edgeRenderers?: Record<string, React.ComponentType<EdgeSlotProps>>,\n edgeTypeDefsMap?: Map<string, EdgeTypeDef>,\n): Record<string, React.ComponentType<EdgeSlotProps>> | undefined {\n if (!edgeRenderers || Object.keys(edgeRenderers).length === 0)\n return undefined\n const types: Record<string, React.ComponentType<EdgeSlotProps>> = {}\n for (const [slug, Renderer] of Object.entries(edgeRenderers)) {\n types[slug] = ((props: Record<string, unknown>) => {\n const def = edgeTypeDefsMap?.get(slug)\n return (\n <Renderer\n id={props.id as string}\n edgeTypeSlug={slug}\n source={props.source as string}\n target={props.target as string}\n label={props.label as string | undefined}\n fields={\n (props.data as Record<string, unknown> | undefined)?.fields as\n | Record<string, unknown>\n | undefined\n }\n edgeTypeDef={def}\n style={props.style as React.CSSProperties | undefined}\n />\n )\n }) as unknown as React.ComponentType<EdgeSlotProps>\n }\n return types\n}\n\n// S8: FocusHandler — must be inside ReactFlowProvider\n\n// Match d3-zoom's translateExtent clamping so the initial viewport\n// is identical to what the user sees after the first drag.\nfunction clampViewport(\n vp: { x: number; y: number; zoom: number },\n cw: number,\n ch: number,\n extent: [[number, number], [number, number]],\n): { x: number; y: number; zoom: number } {\n const left = -vp.x / vp.zoom\n const right = (cw - vp.x) / vp.zoom\n const top = -vp.y / vp.zoom\n const bottom = (ch - vp.y) / vp.zoom\n\n const dx0 = left - extent[0][0]\n const dx1 = right - extent[1][0]\n const dy0 = top - extent[0][1]\n const dy1 = bottom - extent[1][1]\n\n const cx =\n dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1)\n const cy =\n dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)\n\n if (cx === 0 && cy === 0) return vp\n return { x: vp.x + cx * vp.zoom, y: vp.y + cy * vp.zoom, zoom: vp.zoom }\n}\n\nfunction FocusHandler({\n bounds,\n padding,\n animation,\n mode,\n responsive,\n extent,\n}: {\n bounds: FlowBounds\n padding: number\n animation: boolean | number\n mode: 'contain' | 'cover'\n responsive: boolean\n extent?: [[number, number], [number, number]]\n}) {\n const { setViewport } = useReactFlow()\n const containerRef = React.useRef<HTMLDivElement>(null)\n const boundsKey = `${bounds.x},${bounds.y},${bounds.width},${bounds.height}`\n const boundsRef = React.useRef(bounds)\n boundsRef.current = bounds\n const [containerSize, setContainerSize] = React.useState({ w: 0, h: 0 })\n const prevBoundsKeyRef = React.useRef<string | null>(null)\n const prevSizeRef = React.useRef({ w: 0, h: 0 })\n\n // Track container size via ResizeObserver\n React.useEffect(() => {\n const el = containerRef.current\n if (!el) return\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0]\n if (!entry) return\n const { width, height } = entry.contentRect\n setContainerSize({ w: width, h: height })\n })\n observer.observe(el)\n return () => observer.disconnect()\n }, [])\n\n React.useEffect(() => {\n if (containerSize.w === 0 || containerSize.h === 0) return\n\n const prevKey = prevBoundsKeyRef.current\n const prevSize = prevSizeRef.current\n prevBoundsKeyRef.current = boundsKey\n prevSizeRef.current = { w: containerSize.w, h: containerSize.h }\n\n // Determine trigger: bounds change vs resize-only\n const isBoundsChange = prevKey !== boundsKey\n const isResizeOnly =\n !isBoundsChange &&\n (prevSize.w !== containerSize.w || prevSize.h !== containerSize.h)\n const isInitial = prevKey === null\n\n // Skip resize-triggered re-fit if responsiveFit is disabled\n if (isResizeOnly && !responsive) return\n\n // Animate on initial + bounds change; instant on resize\n const duration =\n isInitial || isBoundsChange\n ? animation === true\n ? 300\n : typeof animation === 'number'\n ? animation\n : 0\n : 0\n\n const b = boundsRef.current\n const padX = padding * b.width\n const padY = padding * b.height\n const bw = b.width + padX * 2\n const bh = b.height + padY * 2\n\n if (bw === 0 || bh === 0) return\n\n // contain: fit inside viewport, cover: fill viewport (may crop)\n const zoomFn = mode === 'cover' ? Math.max : Math.min\n const zoom = zoomFn(containerSize.w / bw, containerSize.h / bh)\n const cx = b.x + b.width / 2\n const cy = b.y + b.height / 2\n const x = containerSize.w / 2 - cx * zoom\n const y = containerSize.h / 2 - cy * zoom\n\n let vp = { x, y, zoom }\n if (extent) {\n vp = clampViewport(vp, containerSize.w, containerSize.h, extent)\n }\n setViewport(vp, { duration })\n }, [\n boundsKey,\n padding,\n animation,\n mode,\n responsive,\n containerSize.w,\n containerSize.h,\n extent,\n setViewport,\n ])\n\n // Measurement div — always rendered to track container size\n return (\n <div\n ref={containerRef}\n style={{\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n visibility: 'hidden',\n }}\n />\n )\n}\n\n// ── Edge style resolver ──\n\nconst EDGE_TYPE_MAP: Record<string, string> = {\n step: 'step',\n smoothstep: 'smoothstep',\n bezier: 'default',\n default: 'default',\n}\n\nfunction applyEdgeStyles(\n edges: FlowEdge[],\n edgeTypeDefsMap?: Map<string, EdgeTypeDef>,\n): Edge[] {\n if (!edgeTypeDefsMap?.size) return edges as unknown as Edge[]\n\n return edges.map((edge) => {\n const slug = edge.edgeTypeSlug\n if (!slug) return edge as unknown as Edge\n\n const def = edgeTypeDefsMap.get(slug)\n if (!def) return edge as unknown as Edge\n\n const styled: Edge = { ...(edge as unknown as Edge) }\n\n // Edge type (line style) — canvas value takes precedence\n if (!styled.type && def.lineStyle) {\n styled.type = EDGE_TYPE_MAP[def.lineStyle] ?? 'default'\n }\n\n // Visual style — canvas style merged with def as fallback\n styled.style = {\n ...(def.color ? { stroke: def.color } : undefined),\n ...(def.strokeWidth ? { strokeWidth: def.strokeWidth } : undefined),\n ...edge.style,\n }\n\n // Animation — canvas value takes precedence\n if (styled.animated == null && def.animated) styled.animated = true\n\n // Markers — canvas value takes precedence over def\n if (!styled.markerStart) {\n const startType = toMarkerType(def.markerStart)\n if (startType) {\n styled.markerStart = {\n type: startType,\n ...(def.color ? { color: def.color } : undefined),\n }\n }\n }\n if (!styled.markerEnd) {\n const endType = toMarkerType(def.markerEnd)\n if (endType) {\n styled.markerEnd = {\n type: endType,\n ...(def.color ? { color: def.color } : undefined),\n }\n }\n }\n\n return styled\n })\n}\n\n// ── FlowRenderer ──\n\n/**\n * Renders a Flow canvas in read-only mode.\n *\n * Requires `@xyflow/react` peer dependency and its CSS:\n * ```ts\n * import '@xyflow/react/dist/style.css'\n * ```\n */\nexport interface FlowRendererProps {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData\n /** Container className */\n className?: string\n /** Container style */\n style?: React.CSSProperties\n /** Custom renderers by node type slug (e.g., `{ 'product-card': MyProductCard }`) */\n nodeRenderers?: Record<string, React.ComponentType<DynamicNodeSlotProps>>\n /** Node type definitions for enhanced rendering (field-type-aware display) */\n nodeTypeDefs?: NodeTypeDef[]\n /** Edge type definitions for styled edges (color, stroke, markers, animation) */\n edgeTypeDefs?: EdgeTypeDef[]\n /** Show background pattern (default: false) */\n background?: boolean\n /** Allow user interaction - pan, zoom (default: false for read-only display) */\n interactive?: boolean\n /** Fit view on mount (default: true) */\n fitView?: boolean\n /** Called when a node is clicked */\n onNodeClick?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when a node is double-clicked */\n onNodeDoubleClick?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called on node right-click / context menu */\n onNodeContextMenu?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when mouse enters a node */\n onNodeMouseEnter?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when mouse leaves a node */\n onNodeMouseLeave?: (event: React.MouseEvent, node: FlowNode) => void\n /** Called when an edge is clicked */\n onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void\n /** S1: Custom frame node renderer. Should be a stable reference (memoize or define outside render). */\n frameRenderer?: React.ComponentType<FrameNodeSlotProps>\n /** S2: Custom edge renderers by edge type slug. Should be a stable reference (memoize or define outside render). */\n edgeRenderers?: Record<string, React.ComponentType<EdgeSlotProps>>\n /** S3: Wraps every dynamic node's rendered content. Should be a stable reference (memoize or define outside render). */\n nodeWrapper?: React.ComponentType<NodeWrapperSlotProps>\n /** S4: Show controls (default: false) */\n controls?: boolean\n /** S4: Show minimap (default: false) */\n minimap?: boolean\n /** S4: Custom minimap node color function */\n minimapNodeColor?: (node: FlowNode) => string\n /** S4: Additional children rendered inside ReactFlow */\n children?: React.ReactNode\n /** S5: Global override for all dynamic nodes. Should be a stable reference (memoize or define outside render). */\n renderNode?: (\n props: DynamicNodeSlotProps,\n defaultRender: React.ReactElement,\n ) => React.ReactElement | null\n /** S6: Called when viewport changes (pan/zoom) */\n onViewportChange?: (viewport: FlowViewport) => void\n /** S6: Default viewport (used when fitView is false) */\n defaultViewport?: FlowViewport\n /** S8: Focus on specific bounds (used for initial viewport fit). */\n bounds?: FlowBounds\n /** S8: Separate bounds for panning/zoom restriction. When set, overrides bounds-based translateExtent. Useful when fitBounds (content) differs from clampBounds (frame area). */\n clampBounds?: FlowBounds\n /** S8: Padding for focus bounds (default: 0.1) */\n focusPadding?: number\n /** S8: Animate focus transition (true=300ms, number=custom ms, false=instant) */\n focusAnimation?: boolean | number\n /** S8: Focus mode — \"contain\" fits entire bounds (may have margins), \"cover\" fills viewport (may crop). Default: \"contain\" */\n focusMode?: 'contain' | 'cover'\n /** Re-fit viewport on container resize (default: true when bounds is set) */\n responsiveFit?: boolean\n /** Override translateExtent directly. When set, overrides the automatic bounds-based panning restriction. */\n translateExtent?: [[number, number], [number, number]]\n}\n\nexport function FlowRenderer({\n data,\n className,\n style,\n nodeRenderers,\n nodeTypeDefs,\n edgeTypeDefs,\n background = false,\n interactive = false,\n fitView = true,\n onNodeClick,\n onNodeDoubleClick,\n onNodeContextMenu,\n onNodeMouseEnter,\n onNodeMouseLeave,\n onEdgeClick,\n frameRenderer,\n edgeRenderers,\n nodeWrapper,\n controls,\n minimap,\n minimapNodeColor,\n children,\n renderNode,\n onViewportChange,\n defaultViewport: defaultViewportProp,\n bounds,\n clampBounds,\n focusPadding,\n focusAnimation,\n focusMode = 'contain',\n responsiveFit,\n translateExtent: translateExtentProp,\n}: FlowRendererProps) {\n const nodeTypeDefsMap = React.useMemo(() => {\n if (!nodeTypeDefs?.length) return undefined\n return new Map(nodeTypeDefs.map((d) => [d.slug, d]))\n }, [nodeTypeDefs])\n\n const edgeTypeDefsMap = React.useMemo(() => {\n if (!edgeTypeDefs?.length) return undefined\n return new Map(edgeTypeDefs.map((d) => [d.slug, d]))\n }, [edgeTypeDefs])\n\n const nodeTypes = React.useMemo(\n () =>\n createNodeTypes(\n nodeRenderers,\n nodeTypeDefsMap,\n frameRenderer,\n nodeWrapper,\n renderNode,\n ),\n [nodeRenderers, nodeTypeDefsMap, frameRenderer, nodeWrapper, renderNode],\n )\n\n // S2: Custom edge types\n const customEdgeTypes = React.useMemo(\n () => createEdgeTypes(edgeRenderers, edgeTypeDefsMap),\n [edgeRenderers, edgeTypeDefsMap],\n )\n\n // Merge all customCSS from node type definitions\n const mergedCSS = React.useMemo(() => {\n if (!nodeTypeDefs?.length) return ''\n return nodeTypeDefs\n .filter((d) => d.customCSS)\n .map((d) => d.customCSS)\n .join('\\n')\n }, [nodeTypeDefs])\n\n const styledEdges = React.useMemo(() => {\n let edges = applyEdgeStyles(data?.edges ?? [], edgeTypeDefsMap)\n // When custom edge renderers exist, set edge type to slug for matching\n if (edgeRenderers) {\n edges = edges.map((edge) => {\n const slug = (edge as unknown as FlowEdge).edgeTypeSlug\n if (slug && edgeRenderers[slug]) {\n return { ...edge, type: slug }\n }\n return edge\n })\n }\n return edges\n }, [data?.edges, edgeTypeDefsMap, edgeRenderers])\n\n // Panning restriction: explicit prop > clampBounds (no padding) > bounds (with padding)\n const translateExtent = React.useMemo(() => {\n if (translateExtentProp) return translateExtentProp\n const es = clampBounds ?? bounds\n if (!es) return undefined\n const ep = clampBounds ? 0 : (focusPadding ?? 0.1)\n return [\n [es.x - ep * es.width, es.y - ep * es.height],\n [es.x + es.width * (1 + ep), es.y + es.height * (1 + ep)],\n ] as [[number, number], [number, number]]\n }, [translateExtentProp, clampBounds, bounds, focusPadding])\n\n if (!data) return null\n\n const resolvedDefaultViewport =\n defaultViewportProp ??\n (!fitView && data.viewport ? data.viewport : undefined)\n\n return (\n <ReactFlowProvider>\n <div\n className={className}\n style={{\n width: '100%',\n height: '100%',\n background: 'transparent',\n ...style,\n }}\n >\n <ReactFlow\n nodes={\n (data.nodes ?? []) as unknown as Parameters<\n typeof ReactFlow\n >[0]['nodes']\n }\n edges={styledEdges}\n nodeTypes={nodeTypes}\n edgeTypes={\n customEdgeTypes as Parameters<typeof ReactFlow>[0]['edgeTypes']\n }\n defaultViewport={resolvedDefaultViewport}\n fitView={bounds ? false : fitView}\n translateExtent={translateExtent}\n onNodeClick={\n onNodeClick as Parameters<typeof ReactFlow>[0]['onNodeClick']\n }\n onNodeDoubleClick={\n onNodeDoubleClick as Parameters<\n typeof ReactFlow\n >[0]['onNodeDoubleClick']\n }\n onNodeContextMenu={\n onNodeContextMenu as Parameters<\n typeof ReactFlow\n >[0]['onNodeContextMenu']\n }\n onNodeMouseEnter={\n onNodeMouseEnter as Parameters<\n typeof ReactFlow\n >[0]['onNodeMouseEnter']\n }\n onNodeMouseLeave={\n onNodeMouseLeave as Parameters<\n typeof ReactFlow\n >[0]['onNodeMouseLeave']\n }\n onEdgeClick={\n onEdgeClick as Parameters<typeof ReactFlow>[0]['onEdgeClick']\n }\n onMoveEnd={\n onViewportChange\n ? (((_: unknown, vp: { x: number; y: number; zoom: number }) => {\n onViewportChange(vp)\n }) as Parameters<typeof ReactFlow>[0]['onMoveEnd'])\n : undefined\n }\n nodesDraggable={interactive}\n nodesConnectable={false}\n elementsSelectable={\n interactive ||\n !!onNodeClick ||\n !!onNodeDoubleClick ||\n !!onEdgeClick\n }\n panOnDrag={interactive}\n zoomOnScroll={interactive}\n zoomOnPinch={interactive}\n zoomOnDoubleClick={false}\n proOptions={{ hideAttribution: true }}\n >\n {mergedCSS && (\n <style dangerouslySetInnerHTML={{ __html: mergedCSS }} />\n )}\n {background && <Background />}\n {controls && <Controls />}\n {minimap && (\n <MiniMap\n nodeColor={\n minimapNodeColor as Parameters<typeof MiniMap>[0]['nodeColor']\n }\n />\n )}\n {bounds && (\n <FocusHandler\n bounds={bounds}\n padding={focusPadding ?? 0.1}\n animation={focusAnimation ?? true}\n mode={focusMode}\n responsive={responsiveFit ?? true}\n extent={translateExtent}\n />\n )}\n {children}\n </ReactFlow>\n </div>\n </ReactFlowProvider>\n )\n}\n","import type React from 'react'\n\n// ── Dynamic node data ──\n\nexport interface DynamicNodeData {\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n}\n\nexport type FlowNodeData = (DynamicNodeData | FrameNodeData) &\n Record<string, unknown>\n\n// ── Canvas types (mirrors @xyflow/react but standalone) ──\n\nexport interface FlowNodePosition {\n x: number\n y: number\n}\n\nexport interface FlowNode {\n id: string\n type?: string\n position: FlowNodePosition\n data: FlowNodeData\n parentId?: string\n style?: React.CSSProperties\n width?: number\n height?: number\n measured?: { width?: number; height?: number }\n draggable?: boolean\n selectable?: boolean\n [key: string]: unknown\n}\n\nexport interface FlowEdge {\n id: string\n source: string\n target: string\n sourceHandle?: string | null\n targetHandle?: string | null\n type?: string\n style?: React.CSSProperties\n animated?: boolean\n markerStart?: unknown\n markerEnd?: unknown\n edgeTypeSlug?: string\n fields?: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport interface FlowViewport {\n x: number\n y: number\n zoom: number\n}\n\nexport interface CanvasData {\n nodes: FlowNode[]\n edges: FlowEdge[]\n viewport: FlowViewport\n}\n\n// ── Node type definitions (mirrors console's NodeTypeDef) ──\n\nexport interface NodeTypeFieldDef {\n name: string\n label: string\n fieldType:\n | 'text'\n | 'textarea'\n | 'number'\n | 'url'\n | 'color'\n | 'image'\n | 'select'\n | 'toggle'\n options?: { label: string; value: string }[]\n defaultValue?: string\n required?: boolean\n}\n\nexport interface NodeTypeDef {\n slug: string\n name: string\n color: string\n defaultSize: { width: number; height: number }\n fields: NodeTypeFieldDef[]\n transparentBackground?: boolean\n template?: string | null\n customCSS?: string | null\n}\n\n// ── Edge type definitions (mirrors console's EdgeTypeDef) ──\n\nexport interface EdgeTypeDef {\n slug: string\n name: string\n color: string\n strokeWidth: number\n animated: boolean\n lineStyle: string\n markerStart: string\n markerEnd: string\n fields: NodeTypeFieldDef[]\n}\n\n// ── Type guards ──\n\nexport function isDynamicNode(\n node: FlowNode,\n): node is FlowNode & { data: DynamicNodeData } {\n return node.type === 'dynamic'\n}\n\nexport function isFrameNode(\n node: FlowNode,\n): node is FlowNode & { data: FrameNodeData } {\n return node.type === 'frame'\n}\n\n// ── Component slot props ──\n\nexport interface DynamicNodeSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n fields: Record<string, unknown>\n nodeTypeDef?: NodeTypeDef\n}\n\n// ── Frame node data ──\n\nexport interface FrameNodeData {\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n}\n\n// S1: Frame renderer slot\nexport interface FrameNodeSlotProps {\n id: string\n label: string\n color?: string\n padding?: number\n borderStyle?: 'dashed' | 'solid' | 'none'\n opacity?: number\n children?: React.ReactNode\n}\n\n// S2: Edge renderer slot\nexport interface EdgeSlotProps {\n id: string\n edgeTypeSlug?: string\n source: string\n target: string\n label?: string\n fields?: Record<string, unknown>\n edgeTypeDef?: EdgeTypeDef\n style?: React.CSSProperties\n}\n\n// S3: Node wrapper slot\nexport interface NodeWrapperSlotProps {\n id: string\n nodeTypeSlug: string\n label: string\n selected?: boolean\n nodeTypeDef?: NodeTypeDef\n children: React.ReactNode\n}\n\n// S8: Viewport focus\nexport interface FlowBounds {\n x: number\n y: number\n width: number\n height: number\n}\n","import type { NodeTypeDef } from './types'\n\nexport const BUILT_IN_NODE_TYPES: NodeTypeDef[] = [\n {\n slug: 'text',\n name: 'Text',\n color: '#e5e7eb',\n defaultSize: { width: 200, height: 200 },\n fields: [{ name: 'body', label: 'Body', fieldType: 'textarea' }],\n },\n {\n slug: 'image',\n name: 'Image',\n color: '#e5e7eb',\n transparentBackground: true,\n defaultSize: { width: 200, height: 200 },\n fields: [\n { name: 'image', label: 'Image', fieldType: 'image' },\n { name: 'alt', label: 'Alt Text', fieldType: 'text' },\n { name: 'caption', label: 'Caption', fieldType: 'text' },\n ],\n },\n]\n","import type { EdgeTypeDef } from './types'\n\nexport const BUILT_IN_EDGE_TYPES: EdgeTypeDef[] = [\n {\n slug: 'default',\n name: 'Default',\n color: '',\n strokeWidth: 2,\n animated: false,\n lineStyle: 'default',\n markerStart: 'none',\n markerEnd: 'arrow',\n fields: [],\n },\n]\n","'use client'\n\nimport { useQuery, type QueryClient } from '@tanstack/react-query'\nimport { useMemo } from 'react'\nimport type { CanvasData, NodeTypeDef, EdgeTypeDef } from './types'\nimport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nimport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\nimport { collectionKeys } from '../../core/query/query-keys'\n\n// ── Client interface ──\n// Structurally compatible with both BrowserClient and ServerClient.\n// Lists only the collections useFlow actually queries so the generic\n// `from<T extends PublicCollection>` on the real clients satisfies this.\n\ntype FlowCollection = 'flows' | 'flow-node-types' | 'flow-edge-types'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFn = (...args: any[]) => any\n\nexport interface SDKClient {\n from(collection: FlowCollection): {\n find: AnyFn\n findById: AnyFn\n }\n queryClient: QueryClient\n}\n\n// ── Options & Result ──\n\nexport interface UseFlowOptions {\n /** SDK client instance (BrowserClient or ServerClient) */\n client: SDKClient\n /** Flow slug (URL-friendly identifier) */\n slug?: string\n /** Flow document ID (UUID) */\n id?: string\n /** Enable/disable data fetching (default: true) */\n enabled?: boolean\n}\n\nexport interface UseFlowResult {\n data: CanvasData | undefined\n nodeTypeDefs: NodeTypeDef[]\n edgeTypeDefs: EdgeTypeDef[]\n flow: Record<string, unknown> | undefined\n isLoading: boolean\n error: Error | null\n}\n\n// ── Helpers ──\n\nfunction toNodeTypeDef(doc: Record<string, unknown>): NodeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? '#e5e7eb'),\n defaultSize: (doc.defaultSize as NodeTypeDef['defaultSize']) ?? {\n width: 200,\n height: 200,\n },\n fields: Array.isArray(doc.fields)\n ? (doc.fields as NodeTypeDef['fields'])\n : [],\n transparentBackground: Boolean(doc.transparentBackground),\n template: (doc.template as string) ?? null,\n customCSS: (doc.customCSS as string) ?? null,\n }\n}\n\nfunction toEdgeTypeDef(doc: Record<string, unknown>): EdgeTypeDef {\n return {\n slug: String(doc.slug ?? ''),\n name: String(doc.title ?? ''),\n color: String(doc.color ?? ''),\n strokeWidth: (doc.strokeWidth as number) ?? 2,\n animated: (doc.animated as boolean) ?? false,\n lineStyle: String(doc.lineStyle ?? 'default'),\n markerStart: String(doc.markerStart ?? 'none'),\n markerEnd: String(doc.markerEnd ?? 'arrow'),\n fields: Array.isArray(doc.fields)\n ? (doc.fields as EdgeTypeDef['fields'])\n : [],\n }\n}\n\n// ── Hook ──\n\nexport function useFlow(options: UseFlowOptions): UseFlowResult {\n const { client, slug, id, enabled = true } = options\n const hasIdentifier = !!(slug || id)\n const identifier = id ?? slug ?? ''\n\n // Fetch flow document\n const flowQuery = useQuery<Record<string, unknown>>(\n {\n queryKey: collectionKeys('flows').detail(identifier),\n queryFn: async () => {\n if (id) {\n return client.from('flows').findById(id)\n }\n const result = await client.from('flows').find({\n where: { slug: { equals: slug } },\n limit: 1,\n })\n const doc = result.docs[0]\n if (!doc) throw new Error(`Flow not found: ${slug}`)\n return doc\n },\n enabled: enabled && hasIdentifier,\n },\n client.queryClient,\n )\n\n // Fetch tenant's custom node types\n const nodeTypesQuery = useQuery<Record<string, unknown>[]>(\n {\n queryKey: collectionKeys('flow-node-types').lists(),\n queryFn: async () => {\n const result = await client.from('flow-node-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n },\n client.queryClient,\n )\n\n // Fetch tenant's custom edge types\n const edgeTypesQuery = useQuery<Record<string, unknown>[]>(\n {\n queryKey: collectionKeys('flow-edge-types').lists(),\n queryFn: async () => {\n const result = await client.from('flow-edge-types').find({ limit: 100 })\n return result.docs\n },\n enabled,\n },\n client.queryClient,\n )\n\n // Merge built-in + API node types\n const nodeTypeDefs = useMemo<NodeTypeDef[]>(() => {\n const apiDefs = (nodeTypesQuery.data ?? []).map(toNodeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_NODE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_NODE_TYPES, ...customDefs]\n }, [nodeTypesQuery.data])\n\n // Merge built-in + API edge types\n const edgeTypeDefs = useMemo<EdgeTypeDef[]>(() => {\n const apiDefs = (edgeTypesQuery.data ?? []).map(toEdgeTypeDef)\n const builtInSlugs = new Set(BUILT_IN_EDGE_TYPES.map((t) => t.slug))\n const customDefs = apiDefs.filter((d) => !builtInSlugs.has(d.slug))\n return [...BUILT_IN_EDGE_TYPES, ...customDefs]\n }, [edgeTypesQuery.data])\n\n const flow = flowQuery.data\n const canvas = flow?.canvas as CanvasData | undefined\n\n return {\n data: canvas,\n nodeTypeDefs,\n edgeTypeDefs,\n flow,\n isLoading:\n flowQuery.isLoading ||\n nodeTypesQuery.isLoading ||\n edgeTypesQuery.isLoading,\n error:\n (flowQuery.error as Error | null) ??\n (nodeTypesQuery.error as Error | null) ??\n (edgeTypesQuery.error as Error | null),\n }\n}\n","import type { PublicCollection, ApiQueryOptions } from '../client/types'\n\nexport function collectionKeys<T extends PublicCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>) =>\n [collection, 'infinite', options] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n","import { useMemo } from 'react'\nimport type { CanvasData, FlowNode, NodeTypeDef, EdgeTypeDef } from './types'\nimport type { Edge } from '@xyflow/react'\nimport { BUILT_IN_NODE_TYPES } from './built-in-node-types'\nimport { BUILT_IN_EDGE_TYPES } from './built-in-edge-types'\n\n// ── Options & Result ──\n\nexport interface UseFlowDataOptions {\n /** Canvas data from Flow document's `canvas` field */\n data: CanvasData | undefined\n /** Node type definitions (defaults to built-in types) */\n nodeTypeDefs?: NodeTypeDef[]\n /** Edge type definitions (defaults to built-in types) */\n edgeTypeDefs?: EdgeTypeDef[]\n}\n\nexport interface UseFlowDataResult {\n /** Nodes from canvas data */\n nodes: FlowNode[]\n /** Edges from canvas data (typed for @xyflow/react) */\n edges: Edge[]\n /** Map of node type slug to definition */\n nodeTypeDefsMap: Map<string, NodeTypeDef>\n /** Map of edge type slug to definition */\n edgeTypeDefsMap: Map<string, EdgeTypeDef>\n}\n\n/**\n * Pure data transformation hook — extracts nodes, edges, and type definition\n * maps from canvas data without any rendering. Useful for headless usage\n * (custom layouts, analytics, server-side processing).\n */\nexport function useFlowData(options: UseFlowDataOptions): UseFlowDataResult {\n const { data, nodeTypeDefs: inputNodeDefs, edgeTypeDefs: inputEdgeDefs } =\n options\n\n const nodeTypeDefsMap = useMemo(() => {\n const allDefs = inputNodeDefs ?? BUILT_IN_NODE_TYPES\n return new Map(allDefs.map((d) => [d.slug, d]))\n }, [inputNodeDefs])\n\n const edgeTypeDefsMap = useMemo(() => {\n const allDefs = inputEdgeDefs ?? BUILT_IN_EDGE_TYPES\n return new Map(allDefs.map((d) => [d.slug, d]))\n }, [inputEdgeDefs])\n\n const nodes = useMemo(() => data?.nodes ?? [], [data?.nodes])\n const edges = useMemo(() => (data?.edges ?? []) as unknown as Edge[], [data?.edges])\n\n return {\n nodes,\n edges,\n nodeTypeDefsMap,\n edgeTypeDefsMap,\n }\n}\n","import type { FlowNode, FlowEdge, FlowBounds, CanvasData } from './types'\n\n// ── Shared helpers ──\n\nfunction getNodeSize(node: FlowNode): { width: number; height: number } {\n return {\n width:\n (node.style?.width as number) ??\n node.measured?.width ??\n node.width ??\n 200,\n height:\n (node.style?.height as number) ??\n node.measured?.height ??\n node.height ??\n 200,\n }\n}\n\nfunction getAbsolutePosition(\n node: FlowNode,\n nodeMap: Map<string, FlowNode>,\n): { x: number; y: number } {\n let x = node.position.x\n let y = node.position.y\n let current = node\n const visited = new Set<string>([node.id])\n while (current.parentId) {\n const parentId = current.parentId\n if (visited.has(parentId)) break\n const parent = nodeMap.get(parentId)\n if (!parent) break\n visited.add(parent.id)\n x += parent.position.x\n y += parent.position.y\n current = parent\n }\n return { x, y }\n}\n\n/** Collect a node and all its descendants (BFS with index pointer to avoid O(Q²) shift). */\nfunction collectDescendants(\n nodes: FlowNode[],\n rootId: string,\n): Set<string> {\n const result = new Set<string>([rootId])\n const queue = [rootId]\n let i = 0\n while (i < queue.length) {\n const current = queue[i++]\n for (const n of nodes) {\n if (n.parentId === current && !result.has(n.id)) {\n result.add(n.id)\n queue.push(n.id)\n }\n }\n }\n return result\n}\n\n// ── Public utilities ──\n\n/**\n * Calculate bounding box for given node IDs.\n * Pure function — usable in SSR, server components, or outside React.\n */\nexport function getNodeBounds(\n nodes: FlowNode[],\n nodeIds: string[],\n): FlowBounds | undefined {\n const idSet = new Set(nodeIds)\n const targetNodes = nodes.filter((n) => idSet.has(n.id))\n if (targetNodes.length === 0) return undefined\n\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n\n for (const node of targetNodes) {\n const abs = getAbsolutePosition(node, nodeMap)\n const { width: w, height: h } = getNodeSize(node)\n minX = Math.min(minX, abs.x)\n minY = Math.min(minY, abs.y)\n maxX = Math.max(maxX, abs.x + w)\n maxY = Math.max(maxY, abs.y + h)\n }\n\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n\n/**\n * Get all frame nodes with their bounds.\n * Sorted by position (top-left to bottom-right).\n */\nexport function getFrames(\n nodes: FlowNode[],\n): Array<{ id: string; label: string; bounds: FlowBounds }> {\n const frames = nodes.filter((n) => n.type === 'frame')\n if (frames.length === 0) return []\n\n const nodeMap = new Map(nodes.map((n) => [n.id, n]))\n\n return frames\n .map((f) => {\n const data = f.data as { label?: string }\n const abs = getAbsolutePosition(f, nodeMap)\n const { width: w, height: h } = getNodeSize(f)\n return {\n id: f.id,\n label: data.label ?? '',\n bounds: { x: abs.x, y: abs.y, width: w, height: h },\n }\n })\n .sort((a, b) => a.bounds.y - b.bounds.y || a.bounds.x - b.bounds.x)\n}\n\n/** Result of getFrameData — contains filtered canvas + dual bounds. */\nexport interface FrameData {\n /** Canvas data containing only the frame's descendants (nodes have draggable: false). */\n data: CanvasData\n /** Bounding box of child content nodes — use for initial viewport fit (centering). */\n fitBounds: FlowBounds\n /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */\n clampBounds: FlowBounds\n /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */\n bounds: FlowBounds\n}\n\n/**\n * Extract a frame's descendants and related edges from canvas data.\n * Recursively collects all nested children (supports nested frames).\n * Returns undefined if frameId is not found or is not a frame node.\n *\n * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.\n * The frame node itself is included (use `frameRenderer={() => null}` to hide it).\n *\n * Returns dual bounds:\n * - `fitBounds`: child content bounding box (for centering the viewport)\n * - `clampBounds`: frame area bounding box (for panning restriction)\n */\nexport function getFrameData(\n data: CanvasData,\n frameId: string,\n): FrameData | undefined {\n const frame = data.nodes.find((n) => n.id === frameId)\n if (!frame || frame.type !== 'frame') return undefined\n\n // Recursively collect frame + all descendants\n const descendantIds = collectDescendants(data.nodes, frameId)\n const childNodes = data.nodes\n .filter((n) => descendantIds.has(n.id))\n .map((n) => ({ ...n, draggable: false }))\n\n // Keep only edges where both source and target are within the frame\n const childEdges = data.edges.filter(\n (e: FlowEdge) => descendantIds.has(e.source) && descendantIds.has(e.target),\n )\n\n // clampBounds: frame's own bounding box (for panning restriction)\n const frameBounds = getNodeBounds(data.nodes, [frameId])\n const { width: w, height: h } = getNodeSize(frame)\n const clampBounds: FlowBounds = frameBounds ?? {\n x: frame.position.x,\n y: frame.position.y,\n width: w,\n height: h,\n }\n\n // fitBounds: child content bounding box (for centering)\n const contentNodeIds = childNodes\n .filter((n) => n.id !== frameId)\n .map((n) => n.id)\n const contentBounds = contentNodeIds.length > 0\n ? getNodeBounds(data.nodes, contentNodeIds)\n : undefined\n const fitBounds = contentBounds ?? clampBounds\n\n return {\n data: {\n nodes: childNodes,\n edges: childEdges,\n viewport: data.viewport,\n },\n fitBounds,\n clampBounds,\n bounds: clampBounds,\n }\n}\n","'use client'\n\nimport React from 'react'\nimport { transform } from 'sucrase'\n\nexport interface CodeComponentProps {\n fields: Record<string, unknown>\n label: string\n color: string\n nodeTypeSlug: string\n width: number\n height: number\n}\n\nconst MAX_CACHE_SIZE = 100\nconst componentCache = new Map<string, React.FC<CodeComponentProps>>()\n\nfunction hashCode(str: string): string {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i)\n hash = ((hash << 5) - hash + char) | 0\n }\n return hash.toString(36)\n}\n\nconst BLOCKED_PATTERNS = [\n /\\bdocument\\s*\\./,\n /\\bwindow\\s*\\./,\n /\\bwindow\\s*\\[/,\n /\\bglobalThis\\s*\\./,\n /\\bfetch\\s*\\(/,\n /\\bXMLHttpRequest/,\n /\\beval\\s*\\(/,\n /\\bFunction\\s*\\(/,\n /\\bimport\\s*\\(/,\n /\\blocalStorage/,\n /\\bsessionStorage/,\n /\\bcookie/,\n /\\bpostMessage\\s*\\(/,\n /\\blocation\\s*[.=]/,\n /\\bnavigator\\s*\\./,\n /\\bsetTimeout\\s*\\(/,\n /\\bsetInterval\\s*\\(/,\n /\\bsetImmediate\\s*\\(/,\n /\\brequire\\s*\\(/,\n]\n\nfunction validateTemplateCode(code: string): boolean {\n return !BLOCKED_PATTERNS.some((pattern) => pattern.test(code))\n}\n\nexport function compileTemplate(\n code: string,\n slug: string,\n): React.FC<CodeComponentProps> | null {\n const cacheKey = `${slug}:${hashCode(code)}`\n\n if (componentCache.has(cacheKey)) {\n const cached = componentCache.get(cacheKey)!\n componentCache.delete(cacheKey)\n componentCache.set(cacheKey, cached)\n return cached\n }\n\n if (!validateTemplateCode(code)) {\n console.warn(`[flow] Template \"${slug}\" contains blocked patterns`)\n return null\n }\n\n try {\n const { code: jsCode } = transform(code, {\n transforms: ['typescript', 'jsx', 'imports'],\n jsxRuntime: 'classic',\n jsxPragma: 'React.createElement',\n jsxFragmentPragma: 'React.Fragment',\n })\n\n // Shadow dangerous globals to neutralize blocklist bypasses\n const factory = new Function(\n 'React',\n `\n var window = undefined;\n var document = undefined;\n var globalThis = undefined;\n var setTimeout = undefined;\n var setInterval = undefined;\n var setImmediate = undefined;\n var fetch = undefined;\n var XMLHttpRequest = undefined;\n var navigator = undefined;\n var location = undefined;\n var exports = {};\n var module = { exports: exports };\n ${jsCode}\n return module.exports.default || module.exports;\n `,\n )\n\n const Component = factory(React)\n if (typeof Component !== 'function') return null\n\n if (componentCache.size >= MAX_CACHE_SIZE) {\n const oldestKey = componentCache.keys().next().value\n if (oldestKey) componentCache.delete(oldestKey)\n }\n\n componentCache.set(cacheKey, Component)\n return Component\n } catch (e) {\n console.warn(`[flow] Failed to compile template for \"${slug}\":`, e)\n return null\n }\n}\n\nexport function clearTemplateCache(): void {\n componentCache.clear()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB,IAAAA,gBAWO;;;AC+FA,SAAS,cACd,MAC8C;AAC9C,SAAO,KAAK,SAAS;AACvB;AAEO,SAAS,YACd,MAC4C;AAC5C,SAAO,KAAK,SAAS;AACvB;;;ACrHO,IAAM,sBAAqC;AAAA,EAChD;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ,CAAC,EAAE,MAAM,QAAQ,OAAO,QAAQ,WAAW,WAAW,CAAC;AAAA,EACjE;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,uBAAuB;AAAA,IACvB,aAAa,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,IACvC,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,OAAO,SAAS,WAAW,QAAQ;AAAA,MACpD,EAAE,MAAM,OAAO,OAAO,YAAY,WA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AAA,UACC,WACE;AAAA;AAAA,MAEJ;AAAA,MAED,UACC,8BAAAA,QAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,SAAS,sCAAgB;AAAA,UACzB,WAAW,0CAAkB;AAAA,UAC7B,MAAM;AAAA,UACN,YAAY,wCAAiB;AAAA,UAC7B,QAAQ;AAAA;AAAA,MACV;AAAA,MAED;AAAA,IACH;AAAA,EACF,CACF;AAEJ;","names":["import_react","_a","import_react","import_react","React","React","_a"]}
@@ -7,7 +7,7 @@ interface DynamicNodeData {
7
7
  label: string;
8
8
  fields: Record<string, unknown>;
9
9
  }
10
- type FlowNodeData = DynamicNodeData & Record<string, unknown>;
10
+ type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
11
11
  interface FlowNodePosition {
12
12
  x: number;
13
13
  y: number;
@@ -17,6 +17,7 @@ interface FlowNode {
17
17
  type?: string;
18
18
  position: FlowNodePosition;
19
19
  data: FlowNodeData;
20
+ parentId?: string;
20
21
  style?: React.CSSProperties;
21
22
  width?: number;
22
23
  height?: number;
@@ -74,6 +75,8 @@ interface NodeTypeDef {
74
75
  };
75
76
  fields: NodeTypeFieldDef[];
76
77
  transparentBackground?: boolean;
78
+ template?: string | null;
79
+ customCSS?: string | null;
77
80
  }
78
81
  interface EdgeTypeDef {
79
82
  slug: string;
@@ -206,13 +209,47 @@ declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds
206
209
  /**
207
210
  * Get all frame nodes with their bounds.
208
211
  * Sorted by position (top-left to bottom-right).
209
- * Builds a single nodeMap to compute absolute positions (O(F) instead of O(F*N)).
210
212
  */
211
213
  declare function getFrames(nodes: FlowNode[]): Array<{
212
214
  id: string;
213
215
  label: string;
214
216
  bounds: FlowBounds;
215
217
  }>;
218
+ /** Result of getFrameData — contains filtered canvas + dual bounds. */
219
+ interface FrameData {
220
+ /** Canvas data containing only the frame's descendants (nodes have draggable: false). */
221
+ data: CanvasData;
222
+ /** Bounding box of child content nodes — use for initial viewport fit (centering). */
223
+ fitBounds: FlowBounds;
224
+ /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
225
+ clampBounds: FlowBounds;
226
+ /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
227
+ bounds: FlowBounds;
228
+ }
229
+ /**
230
+ * Extract a frame's descendants and related edges from canvas data.
231
+ * Recursively collects all nested children (supports nested frames).
232
+ * Returns undefined if frameId is not found or is not a frame node.
233
+ *
234
+ * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
235
+ * The frame node itself is included (use `frameRenderer={() => null}` to hide it).
236
+ *
237
+ * Returns dual bounds:
238
+ * - `fitBounds`: child content bounding box (for centering the viewport)
239
+ * - `clampBounds`: frame area bounding box (for panning restriction)
240
+ */
241
+ declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
242
+
243
+ interface CodeComponentProps {
244
+ fields: Record<string, unknown>;
245
+ label: string;
246
+ color: string;
247
+ nodeTypeSlug: string;
248
+ width: number;
249
+ height: number;
250
+ }
251
+ declare function compileTemplate(code: string, slug: string): React.FC<CodeComponentProps> | null;
252
+ declare function clearTemplateCache(): void;
216
253
 
217
254
  /**
218
255
  * Renders a Flow canvas in read-only mode.
@@ -243,6 +280,14 @@ interface FlowRendererProps {
243
280
  fitView?: boolean;
244
281
  /** Called when a node is clicked */
245
282
  onNodeClick?: (event: React.MouseEvent, node: FlowNode) => void;
283
+ /** Called when a node is double-clicked */
284
+ onNodeDoubleClick?: (event: React.MouseEvent, node: FlowNode) => void;
285
+ /** Called on node right-click / context menu */
286
+ onNodeContextMenu?: (event: React.MouseEvent, node: FlowNode) => void;
287
+ /** Called when mouse enters a node */
288
+ onNodeMouseEnter?: (event: React.MouseEvent, node: FlowNode) => void;
289
+ /** Called when mouse leaves a node */
290
+ onNodeMouseLeave?: (event: React.MouseEvent, node: FlowNode) => void;
246
291
  /** Called when an edge is clicked */
247
292
  onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void;
248
293
  /** S1: Custom frame node renderer. Should be a stable reference (memoize or define outside render). */
@@ -265,13 +310,21 @@ interface FlowRendererProps {
265
310
  onViewportChange?: (viewport: FlowViewport) => void;
266
311
  /** S6: Default viewport (used when fitView is false) */
267
312
  defaultViewport?: FlowViewport;
268
- /** S8: Focus on specific bounds */
313
+ /** S8: Focus on specific bounds (used for initial viewport fit). */
269
314
  bounds?: FlowBounds;
315
+ /** S8: Separate bounds for panning/zoom restriction. When set, overrides bounds-based translateExtent. Useful when fitBounds (content) differs from clampBounds (frame area). */
316
+ clampBounds?: FlowBounds;
270
317
  /** S8: Padding for focus bounds (default: 0.1) */
271
318
  focusPadding?: number;
272
319
  /** S8: Animate focus transition (true=300ms, number=custom ms, false=instant) */
273
320
  focusAnimation?: boolean | number;
321
+ /** S8: Focus mode — "contain" fits entire bounds (may have margins), "cover" fills viewport (may crop). Default: "contain" */
322
+ focusMode?: 'contain' | 'cover';
323
+ /** Re-fit viewport on container resize (default: true when bounds is set) */
324
+ responsiveFit?: boolean;
325
+ /** Override translateExtent directly. When set, overrides the automatic bounds-based panning restriction. */
326
+ translateExtent?: [[number, number], [number, number]];
274
327
  }
275
- declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, focusPadding, focusAnimation, }: FlowRendererProps): React.JSX.Element | null;
328
+ declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, clampBounds, focusPadding, focusAnimation, focusMode, responsiveFit, translateExtent: translateExtentProp, }: FlowRendererProps): React.JSX.Element | null;
276
329
 
277
- export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeSlotProps, type EdgeTypeDef, type FlowBounds, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type FrameNodeSlotProps, type NodeTypeDef, type NodeTypeFieldDef, type NodeWrapperSlotProps, type SDKClient, type UseFlowDataOptions, type UseFlowDataResult, type UseFlowOptions, type UseFlowResult, getFrames, getNodeBounds, isDynamicNode, isFrameNode, useFlow, useFlowData };
330
+ export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type CodeComponentProps, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeSlotProps, type EdgeTypeDef, type FlowBounds, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameData, type FrameNodeData, type FrameNodeSlotProps, type NodeTypeDef, type NodeTypeFieldDef, type NodeWrapperSlotProps, type SDKClient, type UseFlowDataOptions, type UseFlowDataResult, type UseFlowOptions, type UseFlowResult, clearTemplateCache, compileTemplate, getFrameData, getFrames, getNodeBounds, isDynamicNode, isFrameNode, useFlow, useFlowData };
package/dist/ui/flow.d.ts CHANGED
@@ -7,7 +7,7 @@ interface DynamicNodeData {
7
7
  label: string;
8
8
  fields: Record<string, unknown>;
9
9
  }
10
- type FlowNodeData = DynamicNodeData & Record<string, unknown>;
10
+ type FlowNodeData = (DynamicNodeData | FrameNodeData) & Record<string, unknown>;
11
11
  interface FlowNodePosition {
12
12
  x: number;
13
13
  y: number;
@@ -17,6 +17,7 @@ interface FlowNode {
17
17
  type?: string;
18
18
  position: FlowNodePosition;
19
19
  data: FlowNodeData;
20
+ parentId?: string;
20
21
  style?: React.CSSProperties;
21
22
  width?: number;
22
23
  height?: number;
@@ -74,6 +75,8 @@ interface NodeTypeDef {
74
75
  };
75
76
  fields: NodeTypeFieldDef[];
76
77
  transparentBackground?: boolean;
78
+ template?: string | null;
79
+ customCSS?: string | null;
77
80
  }
78
81
  interface EdgeTypeDef {
79
82
  slug: string;
@@ -206,13 +209,47 @@ declare function getNodeBounds(nodes: FlowNode[], nodeIds: string[]): FlowBounds
206
209
  /**
207
210
  * Get all frame nodes with their bounds.
208
211
  * Sorted by position (top-left to bottom-right).
209
- * Builds a single nodeMap to compute absolute positions (O(F) instead of O(F*N)).
210
212
  */
211
213
  declare function getFrames(nodes: FlowNode[]): Array<{
212
214
  id: string;
213
215
  label: string;
214
216
  bounds: FlowBounds;
215
217
  }>;
218
+ /** Result of getFrameData — contains filtered canvas + dual bounds. */
219
+ interface FrameData {
220
+ /** Canvas data containing only the frame's descendants (nodes have draggable: false). */
221
+ data: CanvasData;
222
+ /** Bounding box of child content nodes — use for initial viewport fit (centering). */
223
+ fitBounds: FlowBounds;
224
+ /** Bounding box of the frame itself — use for panning/zoom restriction (clamp). */
225
+ clampBounds: FlowBounds;
226
+ /** @deprecated Use fitBounds instead. Alias for clampBounds for backward compatibility. */
227
+ bounds: FlowBounds;
228
+ }
229
+ /**
230
+ * Extract a frame's descendants and related edges from canvas data.
231
+ * Recursively collects all nested children (supports nested frames).
232
+ * Returns undefined if frameId is not found or is not a frame node.
233
+ *
234
+ * Child nodes are marked `draggable: false` to prevent interfering with canvas panning.
235
+ * The frame node itself is included (use `frameRenderer={() => null}` to hide it).
236
+ *
237
+ * Returns dual bounds:
238
+ * - `fitBounds`: child content bounding box (for centering the viewport)
239
+ * - `clampBounds`: frame area bounding box (for panning restriction)
240
+ */
241
+ declare function getFrameData(data: CanvasData, frameId: string): FrameData | undefined;
242
+
243
+ interface CodeComponentProps {
244
+ fields: Record<string, unknown>;
245
+ label: string;
246
+ color: string;
247
+ nodeTypeSlug: string;
248
+ width: number;
249
+ height: number;
250
+ }
251
+ declare function compileTemplate(code: string, slug: string): React.FC<CodeComponentProps> | null;
252
+ declare function clearTemplateCache(): void;
216
253
 
217
254
  /**
218
255
  * Renders a Flow canvas in read-only mode.
@@ -243,6 +280,14 @@ interface FlowRendererProps {
243
280
  fitView?: boolean;
244
281
  /** Called when a node is clicked */
245
282
  onNodeClick?: (event: React.MouseEvent, node: FlowNode) => void;
283
+ /** Called when a node is double-clicked */
284
+ onNodeDoubleClick?: (event: React.MouseEvent, node: FlowNode) => void;
285
+ /** Called on node right-click / context menu */
286
+ onNodeContextMenu?: (event: React.MouseEvent, node: FlowNode) => void;
287
+ /** Called when mouse enters a node */
288
+ onNodeMouseEnter?: (event: React.MouseEvent, node: FlowNode) => void;
289
+ /** Called when mouse leaves a node */
290
+ onNodeMouseLeave?: (event: React.MouseEvent, node: FlowNode) => void;
246
291
  /** Called when an edge is clicked */
247
292
  onEdgeClick?: (event: React.MouseEvent, edge: FlowEdge) => void;
248
293
  /** S1: Custom frame node renderer. Should be a stable reference (memoize or define outside render). */
@@ -265,13 +310,21 @@ interface FlowRendererProps {
265
310
  onViewportChange?: (viewport: FlowViewport) => void;
266
311
  /** S6: Default viewport (used when fitView is false) */
267
312
  defaultViewport?: FlowViewport;
268
- /** S8: Focus on specific bounds */
313
+ /** S8: Focus on specific bounds (used for initial viewport fit). */
269
314
  bounds?: FlowBounds;
315
+ /** S8: Separate bounds for panning/zoom restriction. When set, overrides bounds-based translateExtent. Useful when fitBounds (content) differs from clampBounds (frame area). */
316
+ clampBounds?: FlowBounds;
270
317
  /** S8: Padding for focus bounds (default: 0.1) */
271
318
  focusPadding?: number;
272
319
  /** S8: Animate focus transition (true=300ms, number=custom ms, false=instant) */
273
320
  focusAnimation?: boolean | number;
321
+ /** S8: Focus mode — "contain" fits entire bounds (may have margins), "cover" fills viewport (may crop). Default: "contain" */
322
+ focusMode?: 'contain' | 'cover';
323
+ /** Re-fit viewport on container resize (default: true when bounds is set) */
324
+ responsiveFit?: boolean;
325
+ /** Override translateExtent directly. When set, overrides the automatic bounds-based panning restriction. */
326
+ translateExtent?: [[number, number], [number, number]];
274
327
  }
275
- declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, focusPadding, focusAnimation, }: FlowRendererProps): React.JSX.Element | null;
328
+ declare function FlowRenderer({ data, className, style, nodeRenderers, nodeTypeDefs, edgeTypeDefs, background, interactive, fitView, onNodeClick, onNodeDoubleClick, onNodeContextMenu, onNodeMouseEnter, onNodeMouseLeave, onEdgeClick, frameRenderer, edgeRenderers, nodeWrapper, controls, minimap, minimapNodeColor, children, renderNode, onViewportChange, defaultViewport: defaultViewportProp, bounds, clampBounds, focusPadding, focusAnimation, focusMode, responsiveFit, translateExtent: translateExtentProp, }: FlowRendererProps): React.JSX.Element | null;
276
329
 
277
- export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeSlotProps, type EdgeTypeDef, type FlowBounds, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameNodeData, type FrameNodeSlotProps, type NodeTypeDef, type NodeTypeFieldDef, type NodeWrapperSlotProps, type SDKClient, type UseFlowDataOptions, type UseFlowDataResult, type UseFlowOptions, type UseFlowResult, getFrames, getNodeBounds, isDynamicNode, isFrameNode, useFlow, useFlowData };
330
+ export { BUILT_IN_EDGE_TYPES, BUILT_IN_NODE_TYPES, type CanvasData, type CodeComponentProps, type DynamicNodeData, type DynamicNodeSlotProps, type EdgeSlotProps, type EdgeTypeDef, type FlowBounds, type FlowEdge, type FlowNode, type FlowNodeData, type FlowNodePosition, FlowRenderer, type FlowRendererProps, type FlowViewport, type FrameData, type FrameNodeData, type FrameNodeSlotProps, type NodeTypeDef, type NodeTypeFieldDef, type NodeWrapperSlotProps, type SDKClient, type UseFlowDataOptions, type UseFlowDataResult, type UseFlowOptions, type UseFlowResult, clearTemplateCache, compileTemplate, getFrameData, getFrames, getNodeBounds, isDynamicNode, isFrameNode, useFlow, useFlowData };