@pipelex/mthds-ui 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FHRUYFGV.js → chunk-ILX53OYM.js} +374 -98
- package/dist/chunk-ILX53OYM.js.map +1 -0
- package/dist/chunk-L24K3TZU.js +1 -0
- package/dist/graph/index.d.ts +62 -7
- package/dist/graph/index.js +20 -4
- package/dist/graph/react/detail/DetailPanel.css +82 -79
- package/dist/graph/react/graph-core.css +153 -76
- package/dist/graph/react/index.css +129 -160
- package/dist/graph/react/index.css.map +1 -1
- package/dist/graph/react/index.d.ts +23 -2
- package/dist/graph/react/index.js +258 -155
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/stuff/StuffViewer.css +38 -11
- package/dist/graph/react/viewer/GraphToolbar.css +22 -24
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -4
- package/dist/standalone/graph-standalone.html +304 -199
- package/dist/standalone/graph-viewer.css +295 -190
- package/dist/standalone/graph-viewer.js +9 -9
- package/dist/{types-C7rr1Egj.d.ts → types-DJTrDxjV.d.ts} +29 -10
- package/package.json +3 -1
- package/dist/chunk-FHRUYFGV.js.map +0 -1
- package/dist/chunk-IZ4FH2WM.js +0 -1
- /package/dist/{chunk-IZ4FH2WM.js.map → chunk-L24K3TZU.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/types.ts","../src/graph/validateGraphSpec.ts","../src/graph/graphAnalysis.ts","../src/graph/pipeCardPayload.ts","../src/graph/graphBuilders.ts","../src/graph/graphFolds.ts","../src/graph/elkGraphBuilder.ts","../src/graph/graphLayout.ts","../src/graph/graphControllers.ts","../src/graph/graphConfig.ts"],"sourcesContent":["// ─── Pipe type taxonomy ─────────────────────────────────────────────────────\n// Operators perform work; controllers orchestrate other pipes.\n\nexport type PipeOperatorType =\n | \"PipeLLM\"\n | \"PipeExtract\"\n | \"PipeCompose\"\n | \"PipeImgGen\"\n | \"PipeSearch\"\n | \"PipeFunc\";\n\nexport type PipeControllerType = \"PipeSequence\" | \"PipeParallel\" | \"PipeCondition\" | \"PipeBatch\";\n\nexport type PipeType = PipeOperatorType | PipeControllerType;\n\n// Presence map over the full `PipeType` union — typed as `Record<PipeType, true>`\n// so adding a pipe class to the union without listing it here is a compile\n// error. `KNOWN_PIPE_TYPES` derives its keys from this map, keeping the runtime\n// check the validator performs in sync with the type.\nconst PIPE_TYPE_PRESENCE: Record<PipeType, true> = {\n PipeLLM: true,\n PipeExtract: true,\n PipeCompose: true,\n PipeImgGen: true,\n PipeSearch: true,\n PipeFunc: true,\n PipeSequence: true,\n PipeParallel: true,\n PipeCondition: true,\n PipeBatch: true,\n};\n\n/** Every pipe class name pipelex emits as `pipe_type`. Used by validateGraphSpec. */\nexport const KNOWN_PIPE_TYPES: ReadonlySet<string> = new Set(Object.keys(PIPE_TYPE_PRESENCE));\n\nexport type PipeStatus = \"succeeded\" | \"failed\" | \"running\" | \"scheduled\" | \"skipped\" | \"canceled\";\n\n// ─── Node type constants ────────────────────────────────────────────────────\n// Used by graphBuilders and consumed by ReactFlow custom node registration.\n\nexport const NODE_TYPE_PIPE_CARD = \"pipeCard\" as const;\nexport const NODE_TYPE_STUFF = \"default\" as const;\nexport const NODE_TYPE_CONTROLLER = \"controllerGroup\" as const;\n\n// ─── Stuff node ID helpers ──────────────────────────────────────────────────\n// Stuff (data) nodes use a \"stuff_<digest>\" convention throughout the graph.\n\nexport const STUFF_ID_PREFIX = \"stuff_\";\n\nexport function stuffNodeId(digest: string): string {\n return STUFF_ID_PREFIX + digest;\n}\n\nexport function isStuffNodeId(id: string): boolean {\n return id.startsWith(STUFF_ID_PREFIX);\n}\n\nexport function stuffDigestFromId(id: string): string {\n return id.slice(STUFF_ID_PREFIX.length);\n}\n\n// ─── GraphSpec types (from pipelex-agent --view output) ─────────────────────\n\nexport interface GraphSpecNodeIoItem {\n name: string;\n digest?: string;\n concept?: string;\n content_type?: string;\n preview?: string;\n size?: number;\n data?: unknown;\n data_text?: string;\n data_html?: string;\n extra?: Record<string, unknown>;\n}\n\nexport interface GraphSpecNodeIo {\n inputs: GraphSpecNodeIoItem[];\n outputs: GraphSpecNodeIoItem[];\n}\n\nexport type NodeKind =\n | \"pipe_call\"\n | \"controller\"\n | \"operator\"\n | \"input\"\n | \"output\"\n | \"artifact\"\n | \"error\";\n\nexport interface GraphSpecNodeTiming {\n started_at: string;\n ended_at: string;\n duration: number;\n}\n\nexport interface GraphSpecNodeError {\n error_type: string;\n message: string;\n stack?: string;\n}\n\nexport interface GraphSpecNode {\n id: string;\n kind: NodeKind;\n pipe_code?: string;\n pipe_type: PipeType;\n description?: string;\n domain_code?: string;\n status: PipeStatus;\n timing?: GraphSpecNodeTiming;\n io: GraphSpecNodeIo;\n error?: GraphSpecNodeError;\n tags?: Record<string, string>;\n metrics?: Record<string, number>;\n execution_data?: Record<string, unknown>;\n}\n\n/**\n * A pipe-call node — the only node kind a real pipelex run emits. Narrowed\n * from `GraphSpecNode` for code paths that only ever render pipe-call nodes,\n * where `pipe_code` is guaranteed (validateGraphSpec enforces this).\n */\nexport type PipeCallNode = GraphSpecNode & {\n kind: \"controller\" | \"operator\";\n pipe_code: string;\n pipe_type: PipeType;\n};\n\nexport type GraphSpecEdgeKind =\n | \"contains\"\n | \"data\"\n | \"control\"\n | \"selected_outcome\"\n | \"batch_item\"\n | \"batch_aggregate\"\n | \"parallel_combine\";\n\nexport interface GraphSpecEdge {\n id: string;\n source: string;\n target: string;\n kind: GraphSpecEdgeKind;\n label?: string;\n source_stuff_digest?: string;\n target_stuff_digest?: string;\n meta?: Record<string, unknown>;\n}\n\n// ─── Concept and Pipe registry types ───────────────────────────────────────\n// Serialized from Python Concept and PipeAbstract instances via model_dump().\n\nexport interface ConceptInfo {\n code: string;\n domain_code: string;\n description: string;\n structure_class_name: string;\n refines: string | null;\n json_schema?: Record<string, unknown>;\n}\n\nexport interface StuffSpecInfo {\n concept: ConceptInfo;\n multiplicity: number | boolean | null;\n}\n\n// ─── Template blueprint (shared by LLM prompts, Search, Compose, ImgGen) ───\n\nexport interface TemplateBlueprint {\n template: string;\n templating_style: string | null;\n category: string;\n extra_context: Record<string, unknown> | null;\n}\n\n// ─── Sub-pipe (used by Sequence, Parallel, Batch) ──────────────────────\n\nexport interface SubPipeSpec {\n pipe_code: string;\n output_name: string | null;\n output_multiplicity: string | number | boolean | null;\n batch_params: { input_list_stuff_name: string; input_item_stuff_name: string } | null;\n}\n\n// ─── PipeAbstract base (common to all pipe types) ──────────────────────\n\nexport interface PipeBlueprintBase {\n type: PipeType;\n pipe_category: \"PipeOperator\" | \"PipeController\";\n code: string;\n domain_code: string;\n description: string;\n inputs: Record<string, StuffSpecInfo>;\n output: StuffSpecInfo;\n}\n\n// ─── Operator blueprints ───────────────────────────────────────────────\n\nexport interface PipeLLMBlueprint extends PipeBlueprintBase {\n type: \"PipeLLM\";\n llm_prompt_spec: {\n templating_style: string | null;\n system_prompt_blueprint: TemplateBlueprint | null;\n prompt_blueprint: TemplateBlueprint | null;\n user_image_references: unknown[] | null;\n user_document_references: unknown[] | null;\n system_image_references: unknown[] | null;\n system_document_references: unknown[] | null;\n };\n llm_choices: { for_text: string | null; for_object: string | null } | null;\n structuring_method: string | null;\n output_multiplicity: string | number | null;\n}\n\nexport interface PipeImgGenBlueprint extends PipeBlueprintBase {\n type: \"PipeImgGen\";\n img_gen_prompt_blueprint: {\n prompt_blueprint: TemplateBlueprint | null;\n negative_prompt_blueprint: TemplateBlueprint | null;\n image_references: unknown[] | null;\n };\n img_gen_choice: string | null;\n aspect_ratio: string | null;\n is_raw: boolean | null;\n seed: number | string | null;\n background: string | null;\n output_format: string | null;\n output_multiplicity: number;\n}\n\n/**\n * A single field in a PipeCompose construct blueprint. Mirrors the\n * `ConstructFieldBlueprint` Pydantic model in pipelex. Exactly one of\n * `fixed_value` / `from_path` / `template` / `nested` is populated, matching\n * the `method` discriminator.\n *\n * - `fixed` → `fixed_value` holds a literal (string, number, bool, list)\n * - `from_var` → `from_path` holds a dotted path into working memory,\n * optionally with a `list_to_dict_keyed_by` modifier\n * - `template` → `template` holds a Jinja2 template string (per-field)\n * - `nested` → `nested` holds a recursive construct blueprint for building\n * nested structured content\n */\nexport interface PipeComposeConstructField {\n method: \"from_var\" | \"fixed\" | \"template\" | \"nested\";\n fixed_value?: unknown;\n from_path?: string | null;\n template?: string | null;\n nested?: PipeComposeConstructBlueprint | null;\n list_to_dict_keyed_by?: string | null;\n}\n\n/**\n * A PipeCompose construct blueprint, parsed from `[pipe.X.construct]` in MTHDS.\n * Mirrors the `ConstructBlueprint` Pydantic model in pipelex.\n */\nexport interface PipeComposeConstructBlueprint {\n fields: Record<string, PipeComposeConstructField>;\n}\n\n/**\n * Per-field record of how each field was built at runtime, emitted by\n * `PipeCompose._run_construct_mode` in pipelex via `execution_data.fields`.\n *\n * - `method` → which composition method was used (mirrors `ConstructFieldMethod`)\n * - `rendered` → present only for `template` fields, holds the Jinja2 output\n *\n * Nested fields record only their method; their sub-fields are not surfaced.\n */\nexport interface FieldResolution {\n method: \"from_var\" | \"fixed\" | \"template\" | \"nested\";\n rendered?: string;\n}\n\nexport interface PipeComposeBlueprint extends PipeBlueprintBase {\n type: \"PipeCompose\";\n /** Legacy monolithic template. Null when construct_blueprint is used instead. */\n template: string | null;\n templating_style: string | null;\n category: string;\n extra_context: Record<string, unknown> | null;\n /** Field-level construct form (e.g. `[pipe.X.construct]` in MTHDS). */\n construct_blueprint: PipeComposeConstructBlueprint | null;\n}\n\nexport interface PipeExtractBlueprint extends PipeBlueprintBase {\n type: \"PipeExtract\";\n extract_choice: string | null;\n should_caption_images: boolean;\n max_page_images: number | null;\n should_include_page_views: boolean;\n page_views_dpi: number | null;\n render_js: boolean | null;\n include_raw_html: boolean | null;\n image_stuff_name: string | null;\n document_stuff_name: string;\n}\n\nexport interface PipeSearchBlueprint extends PipeBlueprintBase {\n type: \"PipeSearch\";\n search_choice: string | null;\n prompt_blueprint: TemplateBlueprint;\n include_images_override: boolean | null;\n max_results_override: number | null;\n from_date: string | null;\n to_date: string | null;\n include_domains: string[] | null;\n exclude_domains: string[] | null;\n is_structured_output: boolean;\n}\n\nexport interface PipeFuncBlueprint extends PipeBlueprintBase {\n type: \"PipeFunc\";\n}\n\n// ─── Controller blueprints ─────────────────────────────────────────────\n\nexport interface PipeSequenceBlueprint extends PipeBlueprintBase {\n type: \"PipeSequence\";\n sequential_sub_pipes: SubPipeSpec[];\n}\n\nexport interface PipeParallelBlueprint extends PipeBlueprintBase {\n type: \"PipeParallel\";\n parallel_sub_pipes: SubPipeSpec[];\n add_each_output: boolean;\n combined_output: string | null;\n}\n\nexport interface PipeConditionBlueprint extends PipeBlueprintBase {\n type: \"PipeCondition\";\n expression: string;\n outcome_map: Record<string, string>;\n default_outcome: string;\n add_alias_from_expression_to: string | null;\n}\n\nexport interface PipeBatchBlueprint extends PipeBlueprintBase {\n type: \"PipeBatch\";\n branch_pipe_code: string;\n batch_params: { input_list_stuff_name: string; input_item_stuff_name: string };\n}\n\nexport type PipeBlueprintUnion =\n | PipeLLMBlueprint\n | PipeImgGenBlueprint\n | PipeComposeBlueprint\n | PipeExtractBlueprint\n | PipeSearchBlueprint\n | PipeFuncBlueprint\n | PipeSequenceBlueprint\n | PipeParallelBlueprint\n | PipeConditionBlueprint\n | PipeBatchBlueprint;\n\n// ─── GraphSpec top-level ───────────────────────────────────────────────────\n\nexport interface GraphSpec {\n graph_id?: string;\n created_at?: string;\n pipeline_ref?: { domain?: string; main_pipe?: string; entrypoint?: string };\n nodes: GraphSpecNode[];\n edges: GraphSpecEdge[];\n meta?: Record<string, unknown>;\n pipe_registry?: Record<string, PipeBlueprintUnion>;\n concept_registry?: Record<string, ConceptInfo>;\n}\n\n// ─── Dataflow analysis result ───────────────────────────────────────────────\n\nexport interface DataflowAnalysis {\n readonly stuffRegistry: Readonly<\n Record<string, { name: string; concept?: string; contentType?: string }>\n >;\n readonly stuffProducers: Readonly<Record<string, string>>;\n readonly stuffConsumers: Readonly<Record<string, readonly string[]>>;\n readonly controllerNodeIds: ReadonlySet<string>;\n readonly childNodeIds: ReadonlySet<string>;\n readonly containmentTree: Readonly<Record<string, readonly string[]>>;\n}\n\n// ─── Graph configuration ────────────────────────────────────────────────────\n\nexport const GRAPH_DIRECTION = {\n TB: \"TB\",\n BT: \"BT\",\n LR: \"LR\",\n RL: \"RL\",\n} as const;\n\nexport type GraphDirection = (typeof GRAPH_DIRECTION)[keyof typeof GRAPH_DIRECTION];\n\nexport const EDGE_TYPE = {\n /** Bezier curve — ReactFlow v12 renamed this type from \"bezier\" to \"default\". */\n DEFAULT: \"default\",\n STEP: \"step\",\n STRAIGHT: \"straight\",\n SMOOTH_STEP: \"smoothstep\",\n} as const;\n\nexport type EdgeType = (typeof EDGE_TYPE)[keyof typeof EDGE_TYPE];\n\nexport const FOLD_MODE = {\n /** Every pipe controller folded into a single pipe card. */\n FOLDED: \"folded\",\n /** Every pipe controller expanded as a group wrapper. */\n EXPANDED: \"expanded\",\n /** Renderer decides — reserved for future heuristics; currently behaves like EXPANDED. */\n AUTO: \"auto\",\n} as const;\n\nexport type FoldMode = (typeof FOLD_MODE)[keyof typeof FOLD_MODE];\n\nexport const GRAPH_THEME = {\n DARK: \"dark\",\n LIGHT: \"light\",\n} as const;\n\nexport type GraphTheme = (typeof GRAPH_THEME)[keyof typeof GRAPH_THEME];\n\nexport interface GraphConfig {\n direction?: GraphDirection;\n showControllers?: boolean;\n foldMode?: FoldMode;\n theme?: GraphTheme;\n nodesep?: number;\n ranksep?: number;\n edgeType?: EdgeType;\n initialZoom?: number | null;\n panToTop?: boolean;\n paletteColors?: Record<string, string>;\n}\n\n// ─── Label descriptors ──────────────────────────────────────────────────────\n// Plain objects, no React dependency. GraphViewer maps these to React elements.\n\nexport type LabelDescriptor =\n | { kind: \"pipe\"; label: string; isFailed: boolean }\n | { kind: \"stuff\"; label: string; concept: string };\n\n// ─── Fold toggle options ────────────────────────────────────────────────────\n// Passed by UI click handlers so the orchestrator can decide whether the\n// toggle should propagate to \"cousin\" controllers (other instances of the\n// same pipe) or affect only the clicked one.\n\nexport interface FoldToggleOptions {\n /**\n * When `true`, the toggle applies only to the clicked controller — its\n * cousins (other controller nodes sharing the same `pipe_code`) are left\n * untouched. Wired to the alt/option modifier key in the click handlers.\n */\n soloMode?: boolean;\n}\n\n// ─── Pipe card payload ──────────────────────────────────────────────────────\n// Built by graphBuilders, consumed by PipeCardNode in the React layer.\n\nexport interface PipeCardPayload {\n pipeCode: string;\n pipeType: PipeType;\n description?: string;\n status: PipeStatus;\n inputs: { name: string; concept: string }[];\n outputs: { name: string; concept: string }[];\n /** Layout direction — injected by the layout engine */\n direction?: \"LR\" | \"TB\";\n /** When set, the card renders an unfold button that invokes this callback. */\n onExpand?: (options?: FoldToggleOptions) => void;\n}\n\n// ─── Graph node data ────────────────────────────────────────────────────────\n// Extends Record<string, unknown> for ReactFlow's Node<T> generic parameter.\n\nexport type StuffRole = \"input\" | \"output\";\n\nexport interface GraphNodeData extends Record<string, unknown> {\n labelDescriptor?: LabelDescriptor;\n label?: unknown;\n nodeData?: GraphSpecNode;\n isPipe: boolean;\n isStuff: boolean;\n isController?: boolean;\n labelText: string;\n pipeCode?: string;\n pipeType?: PipeType;\n pipeCardData?: PipeCardPayload;\n /** For stuff nodes: \"input\" (no producer), \"output\" (no consumer), or undefined (intermediate). */\n stuffRole?: StuffRole;\n /** For stuff nodes: the digest used to build the node ID. */\n stuffDigest?: string;\n}\n\n// ─── Graph node / edge / data ───────────────────────────────────────────────\n\nexport interface GraphNode {\n id: string;\n type: string;\n data: GraphNodeData;\n position: { x: number; y: number };\n style?: Record<string, string | number>;\n sourcePosition?: \"top\" | \"bottom\" | \"left\" | \"right\";\n targetPosition?: \"top\" | \"bottom\" | \"left\" | \"right\";\n parentId?: string;\n extent?: \"parent\";\n selected?: boolean;\n}\n\nexport interface GraphEdge {\n id: string;\n source: string;\n target: string;\n type: string;\n animated?: boolean;\n label?: string;\n labelStyle?: Record<string, string | number>;\n labelBgStyle?: Record<string, string | number>;\n labelBgPadding?: [number, number];\n labelBgBorderRadius?: number;\n style?: Record<string, string | number>;\n markerEnd?: { type: string; color: string };\n _batchEdge?: boolean;\n _crossGroup?: boolean;\n}\n\nexport interface GraphData {\n nodes: GraphNode[];\n edges: GraphEdge[];\n}\n\n// ─── Layout ─────────────────────────────────────────────────────────────────\n\nexport interface LayoutConfig {\n nodesep?: number;\n ranksep?: number;\n}\n\n// Controller padding constants (shared between layout and controller modules)\nexport const CONTROLLER_PADDING_X = 40;\nexport const CONTROLLER_PADDING_TOP = 48;\nexport const CONTROLLER_PADDING_BOTTOM = 20;\n\n// Default marker type string (avoids ReactFlow dependency in pure modules)\nexport const ARROW_CLOSED_MARKER = \"arrowclosed\";\n\n// ─── Node dimension helpers ─────────────────────────────────────────────────\n// Extract dimensions from style. Used by buildControllerNodes.\n// NOT used by getLayoutedElements, which estimates dimensions before styles exist.\n\nexport function nodeWidth(n: GraphNode): number {\n const raw = n.style?.width;\n if (raw == null) return 200;\n const w = typeof raw === \"number\" ? raw : parseFloat(raw);\n return isNaN(w) || w <= 0 ? 200 : w;\n}\n\nexport function nodeHeight(n: GraphNode): number {\n const raw = n.style?.height;\n if (raw != null) {\n const h = typeof raw === \"number\" ? raw : parseFloat(raw);\n if (!isNaN(h) && h > 0) return h;\n }\n return n.data?.isStuff ? 60 : 70;\n}\n","/**\n * Single boundary validator for GraphSpec JSON.\n *\n * `validateGraphSpec()` runs once when a spec is loaded from an untyped source\n * (embedded JSON, library consumer input). After it returns, internal code\n * trusts the data and uses the strict types in `types.ts` — no inline\n * defensive checks scattered across modules.\n *\n * The pipelex runtime guarantees specific fields are always present and\n * non-null. This validator enforces those guarantees and fails loudly when\n * they are violated, instead of hiding upstream bugs behind fabricated values.\n *\n * Note: `validateGraphSpec` normalizes the input **in place** — see its doc\n * comment.\n */\nimport type {\n GraphSpec,\n GraphSpecEdgeKind,\n GraphSpecNode,\n PipeCallNode,\n PipeStatus,\n} from \"./types\";\nimport { KNOWN_PIPE_TYPES } from \"./types\";\n\n/**\n * Thrown by `validateGraphSpec` when a spec violates a pipelex runtime\n * guarantee. `path` points at the offending location (e.g.\n * `nodes[3].io.inputs[0].name`) and `name` is the stable, greppable\n * `\"GraphSpecValidationError\"`.\n */\nexport class GraphSpecValidationError extends Error {\n readonly path: string;\n\n constructor(path: string, detail: string) {\n const location = path === \"\" ? \"<root>\" : path;\n super(`GraphSpec validation failed at ${location}: ${detail}`);\n this.name = \"GraphSpecValidationError\";\n this.path = path;\n }\n}\n\nconst PIPE_STATUSES: ReadonlySet<string> = new Set<PipeStatus>([\n \"succeeded\",\n \"failed\",\n \"running\",\n \"scheduled\",\n \"skipped\",\n \"canceled\",\n]);\n\nconst EDGE_KINDS: ReadonlySet<string> = new Set<GraphSpecEdgeKind>([\n \"contains\",\n \"data\",\n \"control\",\n \"selected_outcome\",\n \"batch_item\",\n \"batch_aggregate\",\n \"parallel_combine\",\n]);\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction describe(value: unknown): string {\n if (value === null) return \"null\";\n if (value === undefined) return \"undefined\";\n if (Array.isArray(value)) return \"an array\";\n return `a ${typeof value}`;\n}\n\nfunction fail(path: string, detail: string): never {\n throw new GraphSpecValidationError(path, detail);\n}\n\nfunction requireNonEmptyString(value: unknown, path: string): string {\n if (typeof value !== \"string\" || value.length === 0) {\n fail(path, `expected a non-empty string, got ${describe(value)}`);\n }\n return value;\n}\n\nfunction validateIoItem(item: unknown, path: string): void {\n if (!isPlainObject(item)) {\n fail(path, `expected an object, got ${describe(item)}`);\n }\n // `name` is guaranteed by pipelex; `concept` and `digest` stay tolerant.\n requireNonEmptyString(item.name, `${path}.name`);\n}\n\nfunction validateNode(node: unknown, path: string): void {\n if (!isPlainObject(node)) {\n fail(path, `expected an object, got ${describe(node)}`);\n }\n\n requireNonEmptyString(node.id, `${path}.id`);\n\n // Every node a real pipelex run serializes is a pipe-call node\n // (`kind` is \"controller\" or \"operator\"). The other `NodeKind` values exist\n // in the enum only for the mermaid renderer and never reach a graphspec.json\n // — a spec carrying one is malformed or wrong-version, so reject it.\n if (node.kind !== \"controller\" && node.kind !== \"operator\") {\n fail(\n `${path}.kind`,\n `expected \"controller\" or \"operator\" — a real pipelex run emits only ` +\n `pipe-call nodes, got ${JSON.stringify(node.kind)}`,\n );\n }\n\n if (typeof node.status !== \"string\" || !PIPE_STATUSES.has(node.status)) {\n fail(\n `${path}.status`,\n `expected one of ${[...PIPE_STATUSES].join(\", \")}, got ${JSON.stringify(node.status)}`,\n );\n }\n\n requireNonEmptyString(node.pipe_code, `${path}.pipe_code`);\n const pipeType = requireNonEmptyString(node.pipe_type, `${path}.pipe_type`);\n if (!KNOWN_PIPE_TYPES.has(pipeType)) {\n fail(\n `${path}.pipe_type`,\n `unrecognized pipe class \"${pipeType}\" — add it to PipeOperatorType ` +\n `or PipeControllerType in types.ts`,\n );\n }\n requireNonEmptyString(node.description, `${path}.description`);\n requireNonEmptyString(node.domain_code, `${path}.domain_code`);\n\n // `io` is always emitted by pipelex; tolerate an absent key (the pipelex\n // model defaults it) by normalizing to an empty shape.\n let io = node.io;\n if (io === undefined) {\n io = { inputs: [], outputs: [] };\n node.io = io;\n }\n if (!isPlainObject(io)) {\n fail(`${path}.io`, `expected an object, got ${describe(io)}`);\n }\n if (io.inputs === undefined) {\n io.inputs = [];\n } else if (!Array.isArray(io.inputs)) {\n fail(`${path}.io.inputs`, `expected an array, got ${describe(io.inputs)}`);\n }\n if (io.outputs === undefined) {\n io.outputs = [];\n } else if (!Array.isArray(io.outputs)) {\n fail(`${path}.io.outputs`, `expected an array, got ${describe(io.outputs)}`);\n }\n (io.inputs as unknown[]).forEach((item, j) => validateIoItem(item, `${path}.io.inputs[${j}]`));\n (io.outputs as unknown[]).forEach((item, j) => validateIoItem(item, `${path}.io.outputs[${j}]`));\n}\n\nfunction validateEdge(edge: unknown, path: string): void {\n if (!isPlainObject(edge)) {\n fail(path, `expected an object, got ${describe(edge)}`);\n }\n requireNonEmptyString(edge.id, `${path}.id`);\n requireNonEmptyString(edge.source, `${path}.source`);\n requireNonEmptyString(edge.target, `${path}.target`);\n if (typeof edge.kind !== \"string\" || !EDGE_KINDS.has(edge.kind)) {\n fail(\n `${path}.kind`,\n `expected one of ${[...EDGE_KINDS].join(\", \")}, got ${JSON.stringify(edge.kind)}`,\n );\n }\n}\n\n/**\n * Validate a raw, untyped value as a `GraphSpec`. Throws\n * `GraphSpecValidationError` on the first violation.\n *\n * **Mutates the input in place:** on success it returns the *same* object\n * (typed as `GraphSpec`), and where a node has no `io` key it writes\n * `io = { inputs: [], outputs: [] }` (and fills absent `io.inputs` /\n * `io.outputs` arrays) directly onto the passed-in object. Pass a fresh\n * parse result (e.g. straight from `JSON.parse`) — do not pass a frozen or\n * externally shared object.\n */\nexport function validateGraphSpec(raw: unknown): GraphSpec {\n if (!isPlainObject(raw)) {\n fail(\"\", `expected a GraphSpec object, got ${describe(raw)}`);\n }\n\n if (!Array.isArray(raw.nodes)) {\n fail(\"nodes\", `expected an array, got ${describe(raw.nodes)}`);\n }\n if (!Array.isArray(raw.edges)) {\n fail(\"edges\", `expected an array, got ${describe(raw.edges)}`);\n }\n\n if (!isPlainObject(raw.meta)) {\n fail(\"meta\", `expected an object, got ${describe(raw.meta)}`);\n }\n if (raw.meta.format !== \"mthds\") {\n fail(\n \"meta.format\",\n `expected \"mthds\" (this does not look like pipelex GraphSpec JSON), ` +\n `got ${JSON.stringify(raw.meta.format)}`,\n );\n }\n\n // `pipe_registry` / `concept_registry` are gated by the pipelex\n // `data_inclusion` flag — legitimately absent, and minimally `{}`.\n if (raw.pipe_registry !== undefined && !isPlainObject(raw.pipe_registry)) {\n fail(\"pipe_registry\", `expected an object when present, got ${describe(raw.pipe_registry)}`);\n }\n if (raw.concept_registry !== undefined && !isPlainObject(raw.concept_registry)) {\n fail(\n \"concept_registry\",\n `expected an object when present, got ${describe(raw.concept_registry)}`,\n );\n }\n\n raw.nodes.forEach((node, i) => validateNode(node, `nodes[${i}]`));\n raw.edges.forEach((edge, i) => validateEdge(edge, `edges[${i}]`));\n\n return raw as unknown as GraphSpec;\n}\n\n/**\n * Narrow a `GraphSpecNode` to a `PipeCallNode` at an internal trust boundary,\n * throwing `GraphSpecValidationError` when the node is not a well-formed\n * pipe-call node.\n *\n * Graph-topology analysis (`buildGraph` and friends) identifies a node as a\n * pipe by its edges, not by re-checking `kind`/`pipe_code`. When the spec has\n * been through `validateGraphSpec` this always holds — but library consumers\n * may call `buildGraph` directly. This guard turns that gap into a loud,\n * greppable failure instead of a bare `TypeError` on a missing `pipe_code`.\n */\nexport function asPipeCallNode(node: GraphSpecNode, path = \"node\"): PipeCallNode {\n if (node.kind !== \"controller\" && node.kind !== \"operator\") {\n fail(\n `${path}.kind`,\n `expected a pipe-call node (\"controller\" or \"operator\"), ` +\n `got ${JSON.stringify(node.kind)}`,\n );\n }\n requireNonEmptyString(node.pipe_code, `${path}.pipe_code`);\n return node as PipeCallNode;\n}\n","import type { GraphSpec, DataflowAnalysis, PipeBlueprintUnion, ConceptInfo } from \"./types\";\n\nexport function buildDataflowAnalysis(graphspec: GraphSpec | null): DataflowAnalysis | null {\n if (!graphspec) return null;\n\n const stuffRegistry: Record<string, { name: string; concept?: string; contentType?: string }> =\n {};\n const stuffProducers: Record<string, string> = {};\n const stuffConsumers: Record<string, string[]> = {};\n const containmentTree: Record<string, string[]> = {};\n const childNodeIds = new Set<string>();\n\n // Build containment tree from edges\n for (const edge of graphspec.edges) {\n if (edge.kind === \"contains\") {\n if (!containmentTree[edge.source]) containmentTree[edge.source] = [];\n containmentTree[edge.source].push(edge.target);\n childNodeIds.add(edge.target);\n }\n }\n\n // Controller IDs are nodes that have children\n const controllerNodeIds = new Set<string>(Object.keys(containmentTree));\n\n // Register stuffs from all nodes; track producers/consumers from operators only\n for (const node of graphspec.nodes) {\n const nodeIo = node.io;\n const isController = controllerNodeIds.has(node.id);\n\n // Register outputs\n for (const output of nodeIo.outputs) {\n if (output.digest && !stuffRegistry[output.digest]) {\n stuffRegistry[output.digest] = {\n name: output.name,\n concept: output.concept,\n contentType: output.content_type,\n };\n }\n if (output.digest && !isController) {\n stuffProducers[output.digest] = node.id;\n }\n }\n\n // Register inputs\n for (const input of nodeIo.inputs) {\n if (input.digest && !stuffRegistry[input.digest]) {\n stuffRegistry[input.digest] = {\n name: input.name,\n concept: input.concept,\n contentType: input.content_type,\n };\n }\n if (input.digest && !isController) {\n if (!stuffConsumers[input.digest]) stuffConsumers[input.digest] = [];\n stuffConsumers[input.digest].push(node.id);\n }\n }\n }\n\n return {\n stuffRegistry,\n stuffProducers,\n stuffConsumers,\n controllerNodeIds,\n childNodeIds,\n containmentTree,\n };\n}\n\n/**\n * Build a map from node id -> controller id for all nodes that belong to a controller.\n * Includes both direct children (operators) and stuff nodes assigned to controllers.\n *\n * Stuff nodes are placed at the lowest controller level where they connect producers\n * to consumers. A stuff node produced inside controller C is promoted to C's parent\n * if none of its consumers are inside C (output flows outward).\n */\nexport function buildChildToControllerMap(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n): Record<string, string> {\n const childToController: Record<string, string> = {};\n\n // Direct children from containment tree\n for (const [ctrlId, children] of Object.entries(analysis.containmentTree)) {\n for (const childId of children) {\n childToController[childId] = ctrlId;\n }\n }\n\n // Stuff nodes produced by operators inside controllers\n for (const [digest, producerId] of Object.entries(analysis.stuffProducers)) {\n const stuffId = \"stuff_\" + digest;\n const ctrlId = childToController[producerId];\n if (ctrlId) {\n childToController[stuffId] = ctrlId;\n }\n }\n\n // Stuff produced by controllers themselves -> assign to parent controller\n for (const node of graphspec.nodes) {\n if (!analysis.controllerNodeIds.has(node.id)) continue;\n const parentCtrlId = childToController[node.id];\n if (!parentCtrlId) continue;\n for (const output of node.io.outputs) {\n if (!output.digest) continue;\n const stuffId = \"stuff_\" + output.digest;\n if (!childToController[stuffId]) {\n childToController[stuffId] = parentCtrlId;\n }\n }\n }\n\n // Batch item stuff (fan-out) -> assign to the PipeBatch controller\n for (const edge of graphspec.edges) {\n if (edge.kind === \"batch_item\" && edge.target_stuff_digest) {\n const stuffId = \"stuff_\" + edge.target_stuff_digest;\n // edge.source is the PipeBatch controller node\n if (analysis.controllerNodeIds.has(edge.source)) {\n childToController[stuffId] = edge.source;\n }\n }\n }\n\n // ─── Promote stuff nodes whose consumers are all outside their controller ──\n // Stuff involved in stuff-to-stuff edges (batch/parallel) should not be promoted\n // when they have no operator consumers — they're intermediate batch/parallel data.\n const stuffInStuffEdges = new Set<string>();\n for (const edge of graphspec.edges) {\n if (\n edge.kind === \"batch_item\" ||\n edge.kind === \"batch_aggregate\" ||\n edge.kind === \"parallel_combine\"\n ) {\n if (edge.source_stuff_digest) stuffInStuffEdges.add(edge.source_stuff_digest);\n if (edge.target_stuff_digest) stuffInStuffEdges.add(edge.target_stuff_digest);\n }\n }\n\n const stuffPrefix = \"stuff_\";\n const stuffEntries = Object.keys(childToController).filter((id) => id.startsWith(stuffPrefix));\n\n for (const stuffId of stuffEntries) {\n const digest = stuffId.slice(stuffPrefix.length);\n let assignedCtrl: string | undefined = childToController[stuffId];\n if (!assignedCtrl) continue;\n\n const consumers = analysis.stuffConsumers[digest] || [];\n\n if (consumers.length === 0) {\n // No operator consumers — promote to root only if this is a pure final output\n // (not involved in batch/parallel stuff-to-stuff edges)\n if (!stuffInStuffEdges.has(digest)) {\n delete childToController[stuffId];\n }\n continue;\n }\n\n // Has consumers — promote until we find a level where at least one consumer is inside\n while (assignedCtrl) {\n const ctrl = assignedCtrl;\n const hasConsumerInside = consumers.some((consumerId) =>\n isDescendantOf(consumerId, ctrl, childToController),\n );\n if (hasConsumerInside) break;\n\n const parentCtrl: string | undefined = childToController[assignedCtrl];\n if (parentCtrl) {\n childToController[stuffId] = parentCtrl;\n assignedCtrl = parentCtrl;\n } else {\n delete childToController[stuffId];\n assignedCtrl = undefined;\n }\n }\n }\n\n return childToController;\n}\n\n/** Check if nodeId is a descendant of ancestorCtrlId in the containment hierarchy. */\nfunction isDescendantOf(\n nodeId: string,\n ancestorCtrlId: string,\n childToController: Record<string, string>,\n): boolean {\n let current = childToController[nodeId];\n while (current) {\n if (current === ancestorCtrlId) return true;\n current = childToController[current];\n }\n return false;\n}\n\n// ─── Registry lookup helpers ───────────────────────────────────────────────\n\nexport function getPipeBlueprint(spec: GraphSpec, pipeRef: string): PipeBlueprintUnion | undefined {\n return spec.pipe_registry?.[pipeRef];\n}\n\nexport function getConceptInfo(spec: GraphSpec, conceptRef: string): ConceptInfo | undefined {\n return spec.concept_registry?.[conceptRef];\n}\n\nexport function resolveConceptRef(spec: GraphSpec, codeOrRef: string): ConceptInfo | undefined {\n if (!spec.concept_registry) return undefined;\n // Direct lookup first (e.g., \"test_domain.Summary\")\n const direct = spec.concept_registry[codeOrRef];\n if (direct) return direct;\n // Search by code (e.g., \"Summary\" matches \"test_domain.Summary\")\n for (const info of Object.values(spec.concept_registry)) {\n if (info.code === codeOrRef) return info;\n }\n return undefined;\n}\n","import type { PipeCallNode, PipeCardPayload } from \"./types\";\n\n/**\n * Build a PipeCardPayload from a pipe-call node.\n *\n * `validateGraphSpec` guarantees the pipe-call node's `pipe_code`, `pipe_type`,\n * `description`, `status`, and `io` are present and well-formed, so this\n * function reads them directly with no fallback synthesis.\n */\nexport function buildPipeCardPayload(node: PipeCallNode): PipeCardPayload {\n return {\n pipeCode: node.pipe_code,\n pipeType: node.pipe_type,\n description: node.description,\n status: node.status,\n inputs: node.io.inputs.map((i) => ({ name: i.name, concept: i.concept ?? \"\" })),\n outputs: node.io.outputs.map((o) => ({ name: o.name, concept: o.concept ?? \"\" })),\n };\n}\n","import type { GraphSpec, DataflowAnalysis, GraphNode, GraphEdge, GraphData } from \"./types\";\nimport { ARROW_CLOSED_MARKER, NODE_TYPE_PIPE_CARD, NODE_TYPE_STUFF, stuffNodeId } from \"./types\";\nimport { buildDataflowAnalysis, buildChildToControllerMap } from \"./graphAnalysis\";\nimport { asPipeCallNode } from \"./validateGraphSpec\";\nimport { buildPipeCardPayload } from \"./pipeCardPayload\";\n\nconst STUFF_CHAR_WIDTH_PX = 7;\nconst STUFF_LABEL_PADDING = 48;\nconst MIN_STUFF_WIDTH = 140;\n\n/**\n * Build dataflow graph from GraphSpec. Creates pipe nodes + stuff (data) nodes +\n * producer/consumer edges. Returns label descriptors (not React elements).\n */\nexport function buildDataflowGraph(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n edgeType: string,\n): GraphData {\n const nodes: GraphNode[] = [];\n const edges: GraphEdge[] = [];\n\n // Find participating pipes (those that produce or consume data)\n const participatingPipes = new Set<string>();\n for (const producer of Object.values(analysis.stuffProducers)) {\n participatingPipes.add(producer);\n }\n for (const consumers of Object.values(analysis.stuffConsumers)) {\n for (const consumer of consumers) {\n participatingPipes.add(consumer);\n }\n }\n\n // Create pipe nodes (only those that participate in data flow)\n for (const node of graphspec.nodes) {\n if (!participatingPipes.has(node.id)) continue;\n // A participating pipe is always a pipe-call node; this guard turns a\n // malformed spec into a loud, greppable error rather than a bare TypeError.\n const pipeNode = asPipeCallNode(node, `nodes[${node.id}]`);\n\n const isFailed = pipeNode.status === \"failed\";\n const label = pipeNode.pipe_code;\n const pipeCardData = buildPipeCardPayload(pipeNode);\n\n nodes.push({\n id: pipeNode.id,\n type: NODE_TYPE_PIPE_CARD,\n data: {\n labelDescriptor: { kind: \"pipe\", label, isFailed },\n nodeData: pipeNode,\n isPipe: true,\n isStuff: false,\n labelText: label,\n pipeCode: pipeCardData.pipeCode,\n pipeType: pipeNode.pipe_type,\n pipeCardData,\n },\n position: { x: 0, y: 0 },\n });\n }\n\n // Create stuff (data) nodes\n for (const [digest, stuffInfo] of Object.entries(analysis.stuffRegistry)) {\n const stuffId = stuffNodeId(digest);\n const label = stuffInfo.name;\n const concept = stuffInfo.concept || \"\";\n const textWidth =\n Math.max(label.length, concept.length) * STUFF_CHAR_WIDTH_PX + STUFF_LABEL_PADDING;\n const stuffWidth = Math.max(MIN_STUFF_WIDTH, textWidth);\n\n // Classify: input (no producer), output (no consumer), or intermediate\n const isInput = !analysis.stuffProducers[digest];\n const isOutput = !isInput && !analysis.stuffConsumers[digest]?.length;\n const stuffRole = isInput ? (\"input\" as const) : isOutput ? (\"output\" as const) : undefined;\n\n const borderColor = isInput\n ? \"var(--color-stuff-input-border, #50FA7B)\"\n : isOutput\n ? \"var(--color-stuff-output-border, #a78bfa)\"\n : \"var(--color-stuff-border)\";\n\n nodes.push({\n id: stuffId,\n type: NODE_TYPE_STUFF,\n data: {\n labelDescriptor: { kind: \"stuff\", label, concept },\n isStuff: true,\n isPipe: false,\n labelText: label,\n stuffRole,\n stuffDigest: digest,\n },\n position: { x: 0, y: 0 },\n style: {\n background: \"var(--color-stuff-bg)\",\n border: `2px solid ${borderColor}`,\n borderRadius: \"999px\",\n padding: \"0\",\n width: stuffWidth + \"px\",\n boxShadow: \"var(--shadow-md)\",\n },\n });\n }\n\n // Create edges: producer -> stuff\n let edgeId = 0;\n for (const [digest, producerNodeId] of Object.entries(analysis.stuffProducers)) {\n const stuffId = stuffNodeId(digest);\n edges.push({\n id: \"edge_\" + edgeId++,\n source: producerNodeId,\n target: stuffId,\n type: edgeType,\n animated: false,\n style: { stroke: \"var(--color-edge)\", strokeWidth: 2 },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-edge)\",\n },\n });\n }\n\n // Create edges: stuff -> consumer\n for (const [digest, consumers] of Object.entries(analysis.stuffConsumers)) {\n const stuffId = stuffNodeId(digest);\n for (const consumerNodeId of consumers) {\n edges.push({\n id: \"edge_\" + edgeId++,\n source: stuffId,\n target: consumerNodeId,\n type: edgeType,\n animated: false,\n style: { stroke: \"var(--color-edge)\", strokeWidth: 2 },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-edge)\",\n },\n });\n }\n }\n\n // Create PARALLEL_COMBINE edges from GraphSpec\n for (const edge of graphspec.edges) {\n if (edge.kind !== \"parallel_combine\") continue;\n if (!edge.source_stuff_digest || !edge.target_stuff_digest) continue;\n if (\n !analysis.stuffRegistry[edge.source_stuff_digest] ||\n !analysis.stuffRegistry[edge.target_stuff_digest]\n )\n continue;\n const sourceId = stuffNodeId(edge.source_stuff_digest);\n const targetId = stuffNodeId(edge.target_stuff_digest);\n\n edges.push({\n id: edge.id,\n source: sourceId,\n target: targetId,\n type: \"smoothstep\",\n animated: false,\n style: {\n stroke: \"var(--color-parallel-combine)\",\n strokeWidth: 2,\n strokeDasharray: \"5,5\",\n },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-parallel-combine)\",\n },\n });\n }\n\n // Create BATCH_ITEM and BATCH_AGGREGATE edges (data-centric mode: stuff -> stuff)\n for (const edge of graphspec.edges) {\n if (edge.kind !== \"batch_item\" && edge.kind !== \"batch_aggregate\") continue;\n\n if (!edge.source_stuff_digest || !edge.target_stuff_digest) continue;\n if (\n !analysis.stuffRegistry[edge.source_stuff_digest] ||\n !analysis.stuffRegistry[edge.target_stuff_digest]\n )\n continue;\n const sourceId = stuffNodeId(edge.source_stuff_digest);\n const targetId = stuffNodeId(edge.target_stuff_digest);\n const isBatchItem = edge.kind === \"batch_item\";\n\n edges.push({\n id: edge.id,\n source: sourceId,\n target: targetId,\n type: edgeType,\n animated: false,\n _batchEdge: true,\n label: edge.label || \"\",\n labelStyle: {\n fontSize: \"10px\",\n fontFamily: \"var(--font-mono)\",\n fill: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n },\n labelBgStyle: { fill: \"var(--color-bg)\", fillOpacity: 0.9 },\n style: {\n stroke: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n strokeWidth: 2,\n strokeDasharray: \"5,5\",\n },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n },\n });\n }\n\n // Mark edges that cross between different sibling controller groups\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n // and assign per-class edge types for better routing\n for (const edge of edges) {\n const srcCtrl = childToCtrl[edge.source] || null;\n const tgtCtrl = childToCtrl[edge.target] || null;\n if (srcCtrl && tgtCtrl && srcCtrl !== tgtCtrl) {\n edge._crossGroup = true;\n // Keep bezier for long-distance cross-group edges (natural curves look better)\n // but visually de-emphasize to reduce spaghetti effect\n edge.style = {\n ...edge.style,\n strokeWidth: 1.5,\n opacity: 0.65,\n };\n }\n }\n\n // Batch edges: keep bezier but visually differentiate\n for (const edge of edges) {\n if (edge._batchEdge) {\n edge.style = {\n ...edge.style,\n opacity: 0.7,\n };\n }\n }\n\n return { nodes, edges };\n}\n\n/**\n * Build graph from GraphSpec using dataflow mode.\n * Returns the built graph data and analysis.\n */\nexport function buildGraph(\n graphspec: GraphSpec | null,\n edgeType: string,\n): { graphData: GraphData; analysis: DataflowAnalysis | null } {\n if (graphspec) {\n const analysis = buildDataflowAnalysis(graphspec);\n if (\n analysis &&\n (Object.keys(analysis.stuffProducers).length > 0 ||\n Object.keys(analysis.stuffConsumers).length > 0)\n ) {\n return { graphData: buildDataflowGraph(graphspec, analysis, edgeType), analysis };\n }\n }\n return { graphData: { nodes: [], edges: [] }, analysis: null };\n}\n","import type {\n DataflowAnalysis,\n FoldToggleOptions,\n GraphData,\n GraphEdge,\n GraphNode,\n GraphSpec,\n GraphSpecNode,\n} from \"./types\";\nimport {\n ARROW_CLOSED_MARKER,\n NODE_TYPE_PIPE_CARD,\n isStuffNodeId,\n stuffDigestFromId,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\nimport { asPipeCallNode } from \"./validateGraphSpec\";\nimport { buildPipeCardPayload } from \"./pipeCardPayload\";\n\n/**\n * Find every controller that shares the same `pipe_code` as `controllerId` —\n * the \"cousins\" of the clicked controller (other instances of the same pipe,\n * possibly living in different branches of the graph).\n *\n * The result always includes `controllerId` itself. If the controller has no\n * `pipe_code` or no cousins exist, returns a singleton set.\n *\n * Used by GraphViewer to mirror fold/expand actions across all instances of a\n * pipe — the default behavior — while alt/option-click bypasses cousin lookup\n * and toggles only the clicked controller.\n */\nexport function findCousinControllers(\n controllerId: string,\n graphspec: GraphSpec,\n controllerNodeIds: ReadonlySet<string>,\n): Set<string> {\n const result = new Set<string>([controllerId]);\n const clicked = graphspec.nodes.find((n) => n.id === controllerId);\n const pipeCode = clicked?.pipe_code;\n if (!pipeCode) return result;\n for (const node of graphspec.nodes) {\n if (node.pipe_code !== pipeCode) continue;\n if (!controllerNodeIds.has(node.id)) continue;\n result.add(node.id);\n }\n return result;\n}\n\n/**\n * Walk the containment chain from `nodeId` upward, returning the ordered list of\n * ancestor controller IDs from immediate parent → root.\n */\nexport function buildContainmentChain(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n): string[] {\n const chain: string[] = [];\n let current: string | undefined = childToCtrl[nodeId];\n const seen = new Set<string>();\n while (current && !seen.has(current)) {\n chain.push(current);\n seen.add(current);\n current = childToCtrl[current];\n }\n return chain;\n}\n\n/**\n * Find the **outermost** (closest to root) ancestor of `nodeId` whose ID is in\n * `foldedSet`. Returns `null` if no ancestor is folded.\n */\nexport function outermostFoldedAncestor(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n foldedSet: ReadonlySet<string>,\n): string | null {\n const chain = buildContainmentChain(nodeId, childToCtrl);\n let outermost: string | null = null;\n for (const ancestorId of chain) {\n if (foldedSet.has(ancestorId)) outermost = ancestorId;\n }\n return outermost;\n}\n\n/**\n * Effective ID after folding: returns the outermost folded ancestor if one\n * exists; otherwise the node itself.\n */\nfunction effectiveId(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n foldedSet: ReadonlySet<string>,\n): string {\n return outermostFoldedAncestor(nodeId, childToCtrl, foldedSet) ?? nodeId;\n}\n\nfunction findSpecNode(graphspec: GraphSpec, id: string): GraphSpecNode | undefined {\n return graphspec.nodes.find((n) => n.id === id);\n}\n\n/**\n * Apply the fold transformation to a dataflow graph.\n *\n * For each controller in `foldedSet` that is not itself inside another folded\n * controller (outermost-wins): emit a single `pipe-card` node carrying the\n * controller's payload, and rewrite/dedup edges so the controller card replaces\n * its hidden descendants.\n *\n * The function is pure — inputs are not mutated; a fresh `{ nodes, edges,\n * analysis }` is returned.\n */\nexport function applyFolds(\n graphData: GraphData,\n analysis: DataflowAnalysis,\n graphspec: GraphSpec,\n foldedSet: ReadonlySet<string>,\n onToggleFold?: (controllerId: string, options?: FoldToggleOptions) => void,\n): { nodes: GraphNode[]; edges: GraphEdge[]; analysis: DataflowAnalysis } {\n if (foldedSet.size === 0) {\n return { nodes: graphData.nodes, edges: graphData.edges, analysis };\n }\n\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n\n // ─── Promote declared-output stuffs out of folded controllers ───────────\n // A folded controller's pipe-card represents the controller as a whole, and\n // its declared outputs are external data flowing out of it. If a stuff node\n // currently lives inside a folded controller that declares it as an output,\n // moving the stuff outside lets the folded card connect to it just like\n // before the fold. Without this, the stuff would be hidden alongside the\n // controller's internals, and the output edge would collapse to a self-loop.\n const outputDeclarers: Map<string, Set<string>> = new Map();\n for (const controllerId of foldedSet) {\n const ctrlNode = findSpecNode(graphspec, controllerId);\n const outputs = ctrlNode?.io?.outputs;\n if (!outputs) continue;\n for (const output of outputs) {\n if (!output.digest) continue;\n let set = outputDeclarers.get(output.digest);\n if (!set) {\n set = new Set();\n outputDeclarers.set(output.digest, set);\n }\n set.add(controllerId);\n }\n }\n\n if (outputDeclarers.size > 0) {\n for (const node of graphData.nodes) {\n if (!isStuffNodeId(node.id)) continue;\n const declarers = outputDeclarers.get(stuffDigestFromId(node.id));\n if (!declarers) continue;\n\n // Walk the chain to find the outermost folded ancestor that declares this\n // stuff as one of its outputs. Reparenting to that ancestor's parent\n // (which may itself be folded or root) ensures the stuff escapes the fold.\n let current: string | undefined = childToCtrl[node.id];\n let outermostDeclarer: string | null = null;\n const seen = new Set<string>();\n while (current && !seen.has(current)) {\n seen.add(current);\n if (declarers.has(current)) outermostDeclarer = current;\n current = childToCtrl[current];\n }\n if (!outermostDeclarer) continue;\n\n const newParent = childToCtrl[outermostDeclarer];\n if (newParent) {\n childToCtrl[node.id] = newParent;\n } else {\n delete childToCtrl[node.id];\n }\n }\n }\n\n // ─── Filter visible nodes ───────────────────────────────────────────────\n // Drop any node whose outermost folded ancestor is non-null (it's hidden\n // inside a folded controller).\n const visibleNodes: GraphNode[] = [];\n for (const node of graphData.nodes) {\n if (outermostFoldedAncestor(node.id, childToCtrl, foldedSet)) continue;\n visibleNodes.push(node);\n }\n\n // ─── Emit pipe-card nodes for outermost-folded controllers ──────────────\n for (const folded of foldedSet) {\n // Skip if this folded controller is itself inside another folded ancestor.\n if (outermostFoldedAncestor(folded, childToCtrl, foldedSet)) continue;\n const specNode = findSpecNode(graphspec, folded);\n if (!specNode) continue; // unknown ID — silently ignore\n\n // A folded controller is a pipe-call node; guard the narrowing so a\n // malformed spec fails loudly instead of producing an undefined pipeCode.\n const payload = buildPipeCardPayload(asPipeCallNode(specNode, folded));\n if (onToggleFold) {\n payload.onExpand = (options?: FoldToggleOptions) => onToggleFold(folded, options);\n }\n\n const cardNode: GraphNode = {\n id: folded,\n type: NODE_TYPE_PIPE_CARD,\n data: {\n labelDescriptor: {\n kind: \"pipe\",\n label: payload.pipeCode,\n isFailed: payload.status === \"failed\",\n },\n nodeData: specNode,\n isPipe: false,\n isStuff: false,\n isController: true,\n labelText: payload.pipeCode,\n pipeCode: payload.pipeCode,\n pipeType: specNode.pipe_type,\n pipeCardData: payload,\n },\n position: { x: 0, y: 0 },\n };\n visibleNodes.push(cardNode);\n }\n\n // ─── Build updated analysis ─────────────────────────────────────────────\n // Drop folded controllers and any controller that lives inside a folded\n // outermost ancestor.\n const updatedControllerIds = new Set<string>();\n for (const ctrlId of analysis.controllerNodeIds) {\n if (foldedSet.has(ctrlId)) continue;\n if (outermostFoldedAncestor(ctrlId, childToCtrl, foldedSet)) continue;\n updatedControllerIds.add(ctrlId);\n }\n\n // containmentTree: only keep entries for surviving controllers; filter their\n // children to drop hidden ones (children whose outermost folded ancestor is\n // a different controller). Children that are the folded controllers themselves\n // should remain as children (they now render as pipe-card leaves).\n const updatedContainmentTree: Record<string, string[]> = {};\n for (const ctrlId of updatedControllerIds) {\n const originalChildren = analysis.containmentTree[ctrlId] ?? [];\n const survivors: string[] = [];\n for (const childId of originalChildren) {\n const outer = outermostFoldedAncestor(childId, childToCtrl, foldedSet);\n // If the child has a folded outermost ancestor that is NOT itself, drop.\n // If the child IS the folded outermost (childId is in foldedSet), keep —\n // it will appear as a pipe-card child of this controller.\n if (outer && outer !== childId) continue;\n survivors.push(childId);\n }\n updatedContainmentTree[ctrlId] = survivors;\n }\n\n // childNodeIds: rebuild from the updated containment tree.\n const updatedChildNodeIds = new Set<string>();\n for (const children of Object.values(updatedContainmentTree)) {\n for (const child of children) updatedChildNodeIds.add(child);\n }\n\n // Rewrite stuffProducers/stuffConsumers so any reference to an operator hidden\n // by a fold is replaced with its outermost folded ancestor — mirroring the\n // edge-endpoint rewrite below. Without this, buildChildToControllerMap's\n // promotion loop loses the consumer/producer trail and stuff nodes get\n // ejected to the root level when their parent controller's sibling is folded.\n const updatedStuffProducers: Record<string, string> = {};\n for (const [digest, producerId] of Object.entries(analysis.stuffProducers)) {\n updatedStuffProducers[digest] = effectiveId(producerId, childToCtrl, foldedSet);\n }\n\n const updatedStuffConsumers: Record<string, string[]> = {};\n for (const [digest, consumers] of Object.entries(analysis.stuffConsumers)) {\n const seen = new Set<string>();\n for (const consumerId of consumers) {\n seen.add(effectiveId(consumerId, childToCtrl, foldedSet));\n }\n updatedStuffConsumers[digest] = [...seen];\n }\n\n const updatedAnalysis: DataflowAnalysis = {\n stuffRegistry: analysis.stuffRegistry,\n stuffProducers: updatedStuffProducers,\n stuffConsumers: updatedStuffConsumers,\n controllerNodeIds: updatedControllerIds,\n childNodeIds: updatedChildNodeIds,\n containmentTree: updatedContainmentTree,\n };\n\n // ─── Rewrite edges ──────────────────────────────────────────────────────\n // Each surviving endpoint is replaced by its effective (outermost-folded)\n // ancestor or itself. Drop self-loops. Dedup by (newSrc, newDst, bucket).\n const dedupMap = new Map<string, GraphEdge>();\n for (const edge of graphData.edges) {\n const newSrc = effectiveId(edge.source, childToCtrl, foldedSet);\n const newDst = effectiveId(edge.target, childToCtrl, foldedSet);\n if (newSrc === newDst) continue;\n const bucket = edge._batchEdge ? \"batch\" : \"data\";\n const key = `${newSrc}->${newDst}|${bucket}`;\n if (dedupMap.has(key)) continue;\n // Clone the edge with rewritten endpoints; drop the stale _crossGroup flag\n // (recomputed below against folded containment).\n const cloned: GraphEdge = {\n ...edge,\n source: newSrc,\n target: newDst,\n id: edge.id,\n };\n // Batch edges carry per-item indices like \"[0]\", \"[1]\" in their labels.\n // Once a fold collapses many of these into a single edge (or hides the\n // per-item target), the surviving index is misleading — generalize to \"[N]\".\n if (edge._batchEdge && (newSrc !== edge.source || newDst !== edge.target)) {\n cloned.label = \"[N]\";\n }\n delete cloned._crossGroup;\n dedupMap.set(key, cloned);\n }\n\n // Recompute _crossGroup against the folded containment. Build a fresh\n // childToCtrl from the updated analysis so the classification reflects the\n // post-fold node graph (folded controllers no longer have children).\n const foldedChildToCtrl = buildChildToControllerMap(\n {\n ...graphspec,\n // Mask out the contains edges for folded outermost controllers — they no\n // longer logically contain anything after folding.\n edges: graphspec.edges.filter((e) => {\n if (e.kind !== \"contains\") return true;\n return updatedControllerIds.has(e.source);\n }),\n },\n updatedAnalysis,\n );\n\n const rewrittenEdges: GraphEdge[] = [];\n for (const edge of dedupMap.values()) {\n const srcCtrl = foldedChildToCtrl[edge.source] || null;\n const tgtCtrl = foldedChildToCtrl[edge.target] || null;\n if (srcCtrl && tgtCtrl && srcCtrl !== tgtCtrl) {\n edge._crossGroup = true;\n edge.style = {\n ...edge.style,\n strokeWidth: 1.5,\n opacity: 0.65,\n };\n } else if (edge.style && (edge.style.opacity === 0.65 || edge.style.strokeWidth === 1.5)) {\n // Edge no longer crosses sibling groups — reset the de-emphasized style.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { opacity: _opacity, strokeWidth: _strokeWidth, ...rest } = edge.style;\n edge.style = { ...rest, strokeWidth: 2 };\n if (!edge.markerEnd) {\n edge.markerEnd = { type: ARROW_CLOSED_MARKER, color: \"var(--color-edge)\" };\n }\n }\n rewrittenEdges.push(edge);\n }\n\n return { nodes: visibleNodes, edges: rewrittenEdges, analysis: updatedAnalysis };\n}\n","import type { ElkNode, ElkPort, ElkExtendedEdge, LayoutOptions } from \"elkjs/lib/elk-api\";\nimport type {\n GraphNode,\n GraphEdge,\n GraphSpec,\n DataflowAnalysis,\n LayoutConfig,\n GraphDirection,\n} from \"./types\";\nimport {\n NODE_TYPE_PIPE_CARD,\n CONTROLLER_PADDING_X,\n CONTROLLER_PADDING_TOP,\n CONTROLLER_PADDING_BOTTOM,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\n\n// ─── Direction mapping ──────────────────────────────────────────────────────\n\nfunction elkDirection(direction: GraphDirection): string {\n switch (direction) {\n case \"LR\":\n return \"RIGHT\";\n case \"RL\":\n return \"LEFT\";\n case \"BT\":\n return \"UP\";\n default:\n return \"DOWN\"; // TB\n }\n}\n\n// ─── Port helpers ───────────────────────────────────────────────────────────\n\nconst INPUT_PORT_SUFFIX = \"_in\";\nconst OUTPUT_PORT_SUFFIX = \"_out\";\n\nexport function inputPortId(nodeId: string): string {\n return nodeId + INPUT_PORT_SUFFIX;\n}\n\nexport function outputPortId(nodeId: string): string {\n return nodeId + OUTPUT_PORT_SUFFIX;\n}\n\nfunction makePorts(nodeId: string, dims: NodeDimensions, direction: GraphDirection): ElkPort[] {\n // Port sides must match the flow direction so ELK computes edge attachment\n // on the same side that ReactFlow renders handles.\n // LR: input=WEST, output=EAST | RL: input=EAST, output=WEST\n // TB: input=NORTH, output=SOUTH | BT: input=SOUTH, output=NORTH\n const portSides: Record<GraphDirection, { inSide: string; outSide: string }> = {\n LR: { inSide: \"WEST\", outSide: \"EAST\" },\n RL: { inSide: \"EAST\", outSide: \"WEST\" },\n TB: { inSide: \"NORTH\", outSide: \"SOUTH\" },\n BT: { inSide: \"SOUTH\", outSide: \"NORTH\" },\n };\n const { inSide, outSide } = portSides[direction];\n\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n // Pin ports at the exact center of each side so ELK computes layout\n // with the same edge attachment point that ReactFlow will render.\n const inX = isHorizontal ? (direction === \"LR\" ? 0 : dims.width) : dims.width / 2;\n const inY = isHorizontal ? dims.height / 2 : direction === \"TB\" ? 0 : dims.height;\n const outX = isHorizontal ? (direction === \"LR\" ? dims.width : 0) : dims.width / 2;\n const outY = isHorizontal ? dims.height / 2 : direction === \"TB\" ? dims.height : 0;\n\n return [\n {\n id: inputPortId(nodeId),\n x: inX,\n y: inY,\n width: 1,\n height: 1,\n layoutOptions: { \"elk.port.side\": inSide },\n },\n {\n id: outputPortId(nodeId),\n x: outX,\n y: outY,\n width: 1,\n height: 1,\n layoutOptions: { \"elk.port.side\": outSide },\n },\n ];\n}\n\n// ─── Node dimension estimation ──────────────────────────────────────────────\n// ELK needs dimensions upfront to compute layout.\n\ninterface NodeDimensions {\n width: number;\n height: number;\n}\n\n// ─── Pipe card layout constants (keep in sync with graph-core.css) ──────────\n// If you change these, update the matching rules in graph-core.css.\nconst PIPE_CARD_HEIGHT_CAP = 320;\n\n// Horizontal padding (12 + 12 = 24) + vertical padding (12 + 12 = 24)\nconst PIPE_CARD_PADDING_X = 28; // padding-left + padding-right (14 + 14)\nconst PIPE_CARD_PADDING_Y = 24; // padding-top + padding-bottom (12 + 12)\nconst PIPE_CARD_GAP = 8; // gap between flex children (header / description / io sections)\n\n// Header:\n// - TB: single row with badge + code + status (~22px)\n// - LR: badge/status row + pipe code on its own line below + flex gap (~50px)\nconst PIPE_CARD_HEADER_HEIGHT_TB = 22;\nconst PIPE_CARD_HEADER_HEIGHT_LR = 50;\n\n// Description: 11.5px font × 1.4 line-height ≈ 16.1px per line\nconst PIPE_CARD_DESC_LINE_HEIGHT = 16;\nconst PIPE_CARD_DESC_MAX_LINES_LR = 3;\n\n// I/O section heights (label + first row of pills)\nconst PIPE_CARD_IO_SECTION_HEIGHT_LR = 38; // stacked: label on top, pills below\nconst PIPE_CARD_IO_SECTION_HEIGHT_TB = 30; // inline: label on left, pills on right\nconst PIPE_CARD_IO_EXTRA_ROW_HEIGHT = 22; // each additional wrapping row of pills\n\n// Pill dimension caps (keep in sync with .pipe-card--tb .pipe-card-io-pill-name/concept max-width)\nconst PIPE_CARD_PILL_NAME_MAX_WIDTH = 140;\nconst PIPE_CARD_PILL_CONCEPT_MAX_WIDTH = 100;\nconst PIPE_CARD_PILL_CHROME_WIDTH = 17; // pill padding (10) + name/concept gap (3) + inter-pill gap (4)\nconst PIPE_CARD_IO_LABEL_WIDTH_TB = 58; // min-width 52 + gap 6\n\n// Character width estimates for Inter font\nconst CHAR_WIDTH_DESC = 5.5; // 11.5px font\nconst CHAR_WIDTH_PILL_NAME = 5.0; // 10px font (pill-name)\nconst CHAR_WIDTH_PILL_CONCEPT = 4.5; // 9px font (pill-concept)\n\nconst MAX_VISIBLE_INPUTS = 4;\n\n/** Estimate how many lines the description will wrap to, given direction + text length. */\nfunction estimateDescriptionLines(\n description: string,\n isHorizontal: boolean,\n cardWidth: number,\n): number {\n if (!description) return 0;\n if (!isHorizontal) return 1; // TB always clamps to 1 line (CSS handles ellipsis)\n const textWidth = cardWidth - PIPE_CARD_PADDING_X;\n const charsPerLine = Math.max(1, Math.floor(textWidth / CHAR_WIDTH_DESC));\n const neededLines = Math.ceil(description.length / charsPerLine);\n return Math.min(PIPE_CARD_DESC_MAX_LINES_LR, Math.max(1, neededLines));\n}\n\n/** Estimate the rendered width of a single pill in TB mode. */\nfunction estimateTbPillWidth(name: string, concept: string): number {\n const nameWidth = Math.min(\n PIPE_CARD_PILL_NAME_MAX_WIDTH,\n Math.ceil(name.length * CHAR_WIDTH_PILL_NAME),\n );\n const conceptWidth = Math.min(\n PIPE_CARD_PILL_CONCEPT_MAX_WIDTH,\n Math.ceil(concept.length * CHAR_WIDTH_PILL_CONCEPT),\n );\n return nameWidth + conceptWidth + PIPE_CARD_PILL_CHROME_WIDTH;\n}\n\n/** Count how many wrapping rows a set of pills will occupy in TB mode.\n * Uses a simple first-fit bin-packing against the available pill area width.\n */\nfunction countTbPillRows(\n pills: readonly { name: string; concept: string }[],\n cardWidth: number,\n): number {\n if (pills.length === 0) return 0;\n const availableWidth = cardWidth - PIPE_CARD_PADDING_X - PIPE_CARD_IO_LABEL_WIDTH_TB;\n let rows = 1;\n let currentRowWidth = 0;\n for (const pill of pills) {\n const pillWidth = estimateTbPillWidth(pill.name, pill.concept);\n if (currentRowWidth === 0) {\n currentRowWidth = pillWidth;\n continue;\n }\n if (currentRowWidth + pillWidth <= availableWidth) {\n currentRowWidth += pillWidth;\n } else {\n rows += 1;\n currentRowWidth = pillWidth;\n }\n }\n return rows;\n}\n\nexport function estimateNodeDimensions(node: GraphNode, isHorizontal: boolean): NodeDimensions {\n const nodeData = node.data || {};\n const isStuff = nodeData.isStuff;\n const labelText = nodeData.labelText || \"\";\n const isPipeCard = node.type === NODE_TYPE_PIPE_CARD;\n\n const pipeCardMinWidth = isHorizontal ? 180 : 280;\n const pipeCardMaxWidth = isHorizontal ? 240 : 400;\n // Stuff nodes are visually aligned with pipe cards — they must never be wider\n // than the pipe card max for the current direction, otherwise the graph looks\n // lopsided (a 400px stuff node next to a 240px pipe card in LR mode).\n const estimatedWidth = Math.max(180, Math.min(pipeCardMaxWidth, labelText.length * 8 + 60));\n\n let width: number;\n if (isStuff) {\n width = Math.max(180, estimatedWidth);\n } else if (isPipeCard && nodeData.pipeCardData) {\n width = pipeCardMaxWidth;\n } else {\n width = Math.max(isPipeCard ? pipeCardMinWidth : 200, estimatedWidth);\n }\n\n let height: number;\n if (isStuff) {\n height = 60;\n } else if (isPipeCard && nodeData.pipeCardData) {\n const pcd = nodeData.pipeCardData;\n const inputs = pcd.inputs ?? [];\n const outputs = pcd.outputs ?? [];\n const description = pcd.description || nodeData.nodeData?.description || \"\";\n\n // Header\n let total =\n PIPE_CARD_PADDING_Y +\n (isHorizontal ? PIPE_CARD_HEADER_HEIGHT_LR : PIPE_CARD_HEADER_HEIGHT_TB);\n\n // Description: actual lines needed\n const descLines = estimateDescriptionLines(description, isHorizontal, width);\n if (descLines > 0) {\n total += PIPE_CARD_GAP + descLines * PIPE_CARD_DESC_LINE_HEIGHT;\n }\n\n // Inputs — cap visible to MAX_VISIBLE_INPUTS (rest collapses behind \"+N more\")\n const visibleInputs = inputs.slice(0, MAX_VISIBLE_INPUTS);\n if (visibleInputs.length > 0) {\n total += PIPE_CARD_GAP;\n if (isHorizontal) {\n // LR: one pill per row, always stacked\n total +=\n PIPE_CARD_IO_SECTION_HEIGHT_LR +\n (visibleInputs.length - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n } else {\n // TB: bin-pack pills horizontally, each extra row adds height\n const rows = countTbPillRows(visibleInputs, width);\n total += PIPE_CARD_IO_SECTION_HEIGHT_TB + (rows - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n }\n }\n\n // Outputs — same logic as inputs\n if (outputs.length > 0) {\n total += PIPE_CARD_GAP;\n if (isHorizontal) {\n total +=\n PIPE_CARD_IO_SECTION_HEIGHT_LR + (outputs.length - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n } else {\n const rows = countTbPillRows(outputs, width);\n total += PIPE_CARD_IO_SECTION_HEIGHT_TB + (rows - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n }\n }\n\n height = Math.min(PIPE_CARD_HEIGHT_CAP, total);\n } else {\n height = isPipeCard ? 120 : 70;\n }\n\n return { width, height };\n}\n\n// ─── Controller nesting depth ───────────────────────────────────────────────\n\nfunction computeDepths(\n controllerNodeIds: ReadonlySet<string>,\n containmentTree: Readonly<Record<string, readonly string[]>>,\n): Record<string, number> {\n const depthCache: Record<string, number> = {};\n const visiting = new Set<string>();\n\n function getDepth(ctrlId: string): number {\n if (depthCache[ctrlId] !== undefined) return depthCache[ctrlId];\n if (visiting.has(ctrlId)) return 0;\n visiting.add(ctrlId);\n const children = containmentTree[ctrlId] || [];\n let maxChildDepth = -1;\n for (const childId of children) {\n if (controllerNodeIds.has(childId)) {\n maxChildDepth = Math.max(maxChildDepth, getDepth(childId));\n }\n }\n visiting.delete(ctrlId);\n depthCache[ctrlId] = maxChildDepth + 1;\n return depthCache[ctrlId];\n }\n\n for (const id of controllerNodeIds) getDepth(id);\n return depthCache;\n}\n\n// ─── Leaf node builder ──────────────────────────────────────────────────────\n\nfunction makeLeafNode(nodeId: string, dims: NodeDimensions, direction: GraphDirection): ElkNode {\n return {\n id: nodeId,\n width: dims.width,\n height: dims.height,\n ports: makePorts(nodeId, dims, direction),\n layoutOptions: {\n \"elk.portConstraints\": \"FIXED_POS\",\n },\n };\n}\n\n// ─── Build ELK graph ────────────────────────────────────────────────────────\n\nexport function buildElkGraph(\n nodes: GraphNode[],\n edges: GraphEdge[],\n graphspec: GraphSpec | null,\n analysis: DataflowAnalysis | null,\n direction: GraphDirection,\n layoutConfig?: LayoutConfig,\n): { elkGraph: ElkNode; dimensionMap: Record<string, NodeDimensions> } {\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n const nodesep = layoutConfig?.nodesep ?? 80;\n const ranksep = layoutConfig?.ranksep ?? 70;\n const elkDir = elkDirection(direction);\n\n const edgeNodeSpacing = \"30\";\n\n const rootLayoutOptions: LayoutOptions = {\n \"elk.algorithm\": \"layered\",\n \"elk.direction\": elkDir,\n \"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n \"elk.spacing.nodeNode\": String(nodesep),\n \"elk.layered.spacing.nodeNodeBetweenLayers\": String(ranksep),\n \"elk.spacing.edgeNode\": edgeNodeSpacing,\n \"elk.spacing.edgeEdge\": \"20\",\n \"elk.layered.spacing.edgeNodeBetweenLayers\": edgeNodeSpacing,\n \"elk.layered.spacing.edgeEdgeBetweenLayers\": \"15\",\n \"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n };\n\n // Fast path: no hierarchy info → flat layout\n if (!graphspec || !analysis || analysis.controllerNodeIds.size === 0) {\n const dimensionMap: Record<string, NodeDimensions> = {};\n const elkChildren: ElkNode[] = nodes.map((node) => {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n return makeLeafNode(node.id, dims, direction);\n });\n\n const elkEdges: ElkExtendedEdge[] = edges.map((edge) => ({\n id: edge.id,\n sources: [outputPortId(edge.source)],\n targets: [inputPortId(edge.target)],\n }));\n\n return {\n elkGraph: {\n id: \"root\",\n layoutOptions: rootLayoutOptions,\n children: elkChildren,\n edges: elkEdges,\n },\n dimensionMap,\n };\n }\n\n // Hierarchical layout: build tree from containment analysis\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n const depths = computeDepths(analysis.controllerNodeIds, analysis.containmentTree);\n const dimensionMap: Record<string, NodeDimensions> = {};\n\n // Create a map from node ID to its ELK leaf node\n const nodeById = new Map<string, GraphNode>();\n for (const node of nodes) nodeById.set(node.id, node);\n\n // Build controller compound nodes (bottom-up: leaf controllers first)\n const controllerElkNodes: Record<string, ElkNode> = {};\n const controllerIds = Array.from(analysis.controllerNodeIds);\n controllerIds.sort((a, b) => (depths[a] ?? 0) - (depths[b] ?? 0));\n\n for (const ctrlId of controllerIds) {\n const depth = depths[ctrlId] ?? 0;\n const depthScale = 1 + depth * 0.15;\n const padX = Math.round(CONTROLLER_PADDING_X * depthScale);\n const padTop = Math.round(CONTROLLER_PADDING_TOP * depthScale);\n const padBottom = Math.round(CONTROLLER_PADDING_BOTTOM * depthScale);\n\n const ctrlLayoutOptions: LayoutOptions = {\n \"elk.padding\": `[top=${padTop},left=${padX},bottom=${padBottom},right=${padX}]`,\n \"elk.spacing.nodeNode\": String(nodesep),\n \"elk.layered.spacing.nodeNodeBetweenLayers\": String(ranksep),\n \"elk.spacing.edgeNode\": edgeNodeSpacing,\n \"elk.layered.spacing.edgeNodeBetweenLayers\": edgeNodeSpacing,\n };\n\n const children: ElkNode[] = [];\n const directChildren = analysis.containmentTree[ctrlId] || [];\n\n for (const childId of directChildren) {\n if (analysis.controllerNodeIds.has(childId)) {\n // Child is a controller — use its already-built compound node\n const childElk = controllerElkNodes[childId];\n if (childElk) children.push(childElk);\n } else {\n // Child is an operator — create leaf node with ports\n const graphNode = nodeById.get(childId);\n if (graphNode) {\n const dims = estimateNodeDimensions(graphNode, isHorizontal);\n dimensionMap[childId] = dims;\n children.push(makeLeafNode(childId, dims, direction));\n }\n }\n }\n\n // Add stuff nodes that belong to this controller\n for (const node of nodes) {\n if (node.data.isStuff && childToCtrl[node.id] === ctrlId) {\n if (!children.some((c) => c.id === node.id)) {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n children.push(makeLeafNode(node.id, dims, direction));\n }\n }\n }\n\n controllerElkNodes[ctrlId] = {\n id: ctrlId,\n layoutOptions: ctrlLayoutOptions,\n children,\n };\n }\n\n // Build root children: top-level controllers + loose nodes\n const rootChildren: ElkNode[] = [];\n\n // Add top-level controllers (those not contained by another controller)\n for (const ctrlId of controllerIds) {\n if (!childToCtrl[ctrlId]) {\n const elkNode = controllerElkNodes[ctrlId];\n if (elkNode) rootChildren.push(elkNode);\n }\n }\n\n // Add loose nodes (not inside any controller and not controllers themselves)\n for (const node of nodes) {\n if (!childToCtrl[node.id] && !analysis.controllerNodeIds.has(node.id)) {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n rootChildren.push(makeLeafNode(node.id, dims, direction));\n }\n }\n\n // All edges at root level — INCLUDE_CHILDREN handles cross-hierarchy routing\n const nodeIdSet = new Set(nodes.map((n) => n.id));\n const elkEdges: ElkExtendedEdge[] = edges\n .filter((e) => nodeIdSet.has(e.source) && nodeIdSet.has(e.target))\n .map((edge) => ({\n id: edge.id,\n sources: [outputPortId(edge.source)],\n targets: [inputPortId(edge.target)],\n }));\n\n return {\n elkGraph: {\n id: \"root\",\n layoutOptions: rootLayoutOptions,\n children: rootChildren,\n edges: elkEdges,\n },\n dimensionMap,\n };\n}\n\n// ─── Extract absolute positions from ELK output ────────────────────────────\n\nexport interface ElkPositionResult {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport function extractAbsolutePositions(elkResult: ElkNode): Record<string, ElkPositionResult> {\n const positions: Record<string, ElkPositionResult> = {};\n\n function walk(node: ElkNode, parentX: number, parentY: number) {\n const absX = parentX + (node.x ?? 0);\n const absY = parentY + (node.y ?? 0);\n\n if (node.id !== \"root\") {\n positions[node.id] = {\n x: absX,\n y: absY,\n width: node.width ?? 0,\n height: node.height ?? 0,\n };\n }\n\n for (const child of node.children ?? []) {\n walk(child, absX, absY);\n }\n }\n\n walk(elkResult, 0, 0);\n return positions;\n}\n","import ELK from \"elkjs/lib/elk.bundled.js\";\nimport type {\n GraphNode,\n GraphEdge,\n GraphSpec,\n DataflowAnalysis,\n LayoutConfig,\n GraphDirection,\n} from \"./types\";\nimport { buildElkGraph, extractAbsolutePositions, estimateNodeDimensions } from \"./elkGraphBuilder\";\nimport type { ElkPositionResult } from \"./elkGraphBuilder\";\n\n// Cache ELK instance at module level to avoid repeated WASM initialization\nlet elkInstance: InstanceType<typeof ELK> | null = null;\nfunction getElk(): InstanceType<typeof ELK> {\n if (!elkInstance) elkInstance = new ELK();\n return elkInstance;\n}\n\nexport interface LayoutResult {\n nodes: GraphNode[];\n edges: GraphEdge[];\n /** ELK-computed positions/sizes for controller compound nodes. */\n controllerPositions: Record<string, ElkPositionResult>;\n}\n\nexport async function getLayoutedElements(\n nodes: GraphNode[],\n edges: GraphEdge[],\n direction: GraphDirection,\n layoutConfig?: LayoutConfig,\n graphspec?: GraphSpec | null,\n analysis?: DataflowAnalysis | null,\n): Promise<LayoutResult> {\n if (nodes.length === 0) return { nodes: [], edges, controllerPositions: {} };\n\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n\n const { elkGraph, dimensionMap } = buildElkGraph(\n nodes,\n edges,\n graphspec ?? null,\n analysis ?? null,\n direction,\n layoutConfig,\n );\n\n const layoutResult = await getElk().layout(elkGraph);\n const positions = extractAbsolutePositions(layoutResult);\n\n // Extract controller positions from ELK output\n const controllerPositions: Record<string, ElkPositionResult> = {};\n if (analysis) {\n for (const ctrlId of analysis.controllerNodeIds) {\n if (positions[ctrlId]) {\n controllerPositions[ctrlId] = positions[ctrlId];\n }\n }\n }\n\n const result = nodes.map((node) => {\n const pos = positions[node.id];\n const dims = dimensionMap[node.id] ?? estimateNodeDimensions(node, isHorizontal);\n\n const width = dims.width;\n const height = dims.height;\n\n // Inject direction into pipeCardData so the card component can adjust orientation\n const pipeCardData = node.data.pipeCardData;\n const cardDirection = isHorizontal ? (\"LR\" as const) : (\"TB\" as const);\n const updatedPipeCardData = pipeCardData\n ? { ...pipeCardData, direction: cardDirection }\n : undefined;\n\n return {\n ...node,\n data: {\n ...node.data,\n _estimatedWidth: width,\n _estimatedHeight: height,\n pipeCardData: updatedPipeCardData,\n },\n // Lock the ReactFlow node wrapper to the exact dimensions ELK used for layout.\n // This ensures ReactFlow's Handle (centered on the DOM element) matches\n // the port position ELK computed (centered on the estimated dimensions).\n style: {\n ...node.style,\n width: width + \"px\",\n height: height + \"px\",\n },\n position: {\n x: pos ? pos.x : 0,\n y: pos ? pos.y : 0,\n },\n sourcePosition: (isHorizontal\n ? direction === \"LR\"\n ? \"right\"\n : \"left\"\n : direction === \"TB\"\n ? \"bottom\"\n : \"top\") as GraphNode[\"sourcePosition\"],\n targetPosition: (isHorizontal\n ? direction === \"LR\"\n ? \"left\"\n : \"right\"\n : direction === \"TB\"\n ? \"top\"\n : \"bottom\") as GraphNode[\"targetPosition\"],\n };\n });\n\n return { nodes: result, edges, controllerPositions };\n}\n","import type {\n GraphSpec,\n DataflowAnalysis,\n FoldToggleOptions,\n GraphNode,\n GraphEdge,\n PipeCallNode,\n PipeType,\n} from \"./types\";\nimport {\n CONTROLLER_PADDING_X,\n CONTROLLER_PADDING_TOP,\n CONTROLLER_PADDING_BOTTOM,\n NODE_TYPE_CONTROLLER,\n nodeWidth,\n nodeHeight,\n isStuffNodeId,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\nimport { asPipeCallNode, GraphSpecValidationError } from \"./validateGraphSpec\";\n\n/** Max visible children before a parallel/batch controller auto-collapses. */\nexport const MAX_VISIBLE_CONTROLLER_CHILDREN = 5;\n\n/**\n * Collect all descendant node IDs of a controller (recursive).\n */\nfunction getDescendants(\n controllerId: string,\n containmentTree: Readonly<Record<string, readonly string[]>>,\n controllerNodeIds: ReadonlySet<string>,\n): Set<string> {\n const result = new Set<string>();\n const stack = [controllerId];\n while (stack.length > 0) {\n const id = stack.pop()!;\n for (const childId of containmentTree[id] || []) {\n result.add(childId);\n if (controllerNodeIds.has(childId)) stack.push(childId);\n }\n }\n return result;\n}\n\n/** Position and size for a controller, as computed by the layout engine. */\nexport interface ControllerRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Build controller group nodes that wrap child operators/stuff nodes.\n *\n * When `controllerPositions` is provided (from ELK layout), uses those exact\n * positions/sizes instead of recomputing from child bounding boxes. This ensures\n * controller containers match the layout engine's spacing and edge routing.\n *\n * **Side effect:** mutates `layoutedNodes` entries to set `parentId`, `extent`,\n * and convert positions to parent-relative coordinates.\n */\nexport function buildControllerNodes(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n layoutedNodes: GraphNode[],\n controllerPositions?: Record<string, ControllerRect>,\n): GraphNode[] {\n const nodeById: Record<string, GraphNode> = {};\n for (const n of layoutedNodes) {\n nodeById[n.id] = n;\n }\n\n // A controller node is a pipe-call node; the guard makes a malformed spec\n // fail loudly here rather than surfacing later as an undefined pipe_code.\n const controllerInfo: Record<string, PipeCallNode> = {};\n for (const node of graphspec.nodes) {\n if (analysis.controllerNodeIds.has(node.id)) {\n controllerInfo[node.id] = asPipeCallNode(node, `nodes[${node.id}]`);\n }\n }\n\n const depthCache: Record<string, number> = {};\n const depthVisiting = new Set<string>();\n function getDepth(controllerId: string): number {\n if (depthCache[controllerId] !== undefined) return depthCache[controllerId];\n if (depthVisiting.has(controllerId)) {\n throw new Error(\n `Cycle detected in containment tree: controller \"${controllerId}\" is part of a containment cycle`,\n );\n }\n depthVisiting.add(controllerId);\n const children = analysis.containmentTree[controllerId] || [];\n let maxChildDepth = -1;\n for (const childId of children) {\n if (analysis.controllerNodeIds.has(childId)) {\n maxChildDepth = Math.max(maxChildDepth, getDepth(childId));\n }\n }\n depthVisiting.delete(controllerId);\n depthCache[controllerId] = maxChildDepth + 1;\n return depthCache[controllerId];\n }\n\n const childToController = buildChildToControllerMap(graphspec, analysis);\n const controllerStuffChildren: Record<string, string[]> = {};\n for (const [nodeId, ctrlId] of Object.entries(childToController)) {\n if (!isStuffNodeId(nodeId)) continue;\n if (!nodeById[nodeId]) continue;\n if (!controllerStuffChildren[ctrlId]) controllerStuffChildren[ctrlId] = [];\n controllerStuffChildren[ctrlId].push(nodeId);\n }\n\n const controllerIds = Array.from(analysis.controllerNodeIds);\n for (const id of controllerIds) getDepth(id);\n controllerIds.sort((a, b) => depthCache[a] - depthCache[b]);\n\n const controllerNodes: GraphNode[] = [];\n const childToParent: Record<string, string> = {};\n\n for (const controllerId of controllerIds) {\n const directChildren = analysis.containmentTree[controllerId] || [];\n const renderedChildren = directChildren.filter((cid) => nodeById[cid]);\n const stuffChildren = controllerStuffChildren[controllerId] || [];\n const allChildren = [...renderedChildren, ...stuffChildren];\n\n if (allChildren.length === 0) continue;\n\n let groupX: number, groupY: number, groupW: number, groupH: number;\n\n const elkPos = controllerPositions?.[controllerId];\n if (elkPos) {\n // Use ELK's computed position and size — accounts for edge routing and spacing\n groupX = elkPos.x;\n groupY = elkPos.y;\n groupW = elkPos.width;\n groupH = elkPos.height;\n } else {\n // Fallback: compute bounding box from child positions\n let minX = Infinity,\n minY = Infinity,\n maxX = -Infinity,\n maxY = -Infinity;\n for (const childId of allChildren) {\n const child = nodeById[childId];\n const pos = child.position;\n const w = nodeWidth(child);\n const h = nodeHeight(child);\n minX = Math.min(minX, pos.x);\n minY = Math.min(minY, pos.y);\n maxX = Math.max(maxX, pos.x + w);\n maxY = Math.max(maxY, pos.y + h);\n }\n\n const depth = depthCache[controllerId] ?? 0;\n const depthScale = 1 + depth * 0.15;\n const padX = Math.round(CONTROLLER_PADDING_X * depthScale);\n const padTop = Math.round(CONTROLLER_PADDING_TOP * depthScale);\n const padBottom = Math.round(CONTROLLER_PADDING_BOTTOM * depthScale);\n\n groupX = minX - padX;\n groupY = minY - padTop;\n groupW = maxX - minX + 2 * padX;\n groupH = maxY - minY + padTop + padBottom;\n }\n\n const info = controllerInfo[controllerId];\n if (!info) {\n // controllerId comes from a `contains` edge source with no matching node.\n throw new GraphSpecValidationError(\n `nodes[${controllerId}]`,\n `controller \"${controllerId}\" is referenced by a \"contains\" edge but ` +\n `has no corresponding node in graphspec.nodes`,\n );\n }\n const pipeCode = info.pipe_code;\n const groupNode: GraphNode = {\n id: controllerId,\n type: NODE_TYPE_CONTROLLER,\n data: {\n label: pipeCode,\n pipeType: info.pipe_type,\n isController: true,\n isPipe: false,\n isStuff: false,\n pipeCode: pipeCode,\n labelText: pipeCode,\n },\n position: { x: groupX, y: groupY },\n style: {\n width: groupW + \"px\",\n height: groupH + \"px\",\n padding: \"0\",\n },\n };\n\n controllerNodes.push(groupNode);\n nodeById[controllerId] = groupNode;\n\n for (const childId of allChildren) {\n childToParent[childId] = controllerId;\n }\n }\n\n // Convert child positions to parent-relative and set parentId\n for (const [childId, parentId] of Object.entries(childToParent)) {\n const child = nodeById[childId];\n const parent = nodeById[parentId];\n if (!child || !parent) continue;\n child.position = {\n x: child.position.x - parent.position.x,\n y: child.position.y - parent.position.y,\n };\n child.parentId = parentId;\n child.extent = \"parent\";\n }\n\n return controllerNodes;\n}\n\n/**\n * Apply controller containers to layouted nodes if showControllers is enabled.\n *\n * When `expandedControllers` is provided, PipeParallel/PipeBatch controllers with\n * more than MAX_VISIBLE_CONTROLLER_CHILDREN children are auto-collapsed unless the\n * controller ID is in the expanded set.\n */\nexport function applyControllers(\n layoutedNodes: GraphNode[],\n layoutedEdges: GraphEdge[],\n graphspec: GraphSpec | null,\n analysis: DataflowAnalysis | null,\n showControllers: boolean,\n expandedControllers?: ReadonlySet<string>,\n onToggleCollapse?: (controllerId: string) => void,\n controllerPositions?: Record<string, ControllerRect>,\n onToggleFold?: (controllerId: string, options?: FoldToggleOptions) => void,\n): { nodes: GraphNode[]; edges: GraphEdge[] } {\n if (!showControllers || !analysis || !graphspec) {\n return { nodes: layoutedNodes, edges: layoutedEdges };\n }\n\n // ─── Compute child counts and effective collapse state ─────────────────\n const childCounts: Record<string, number> = {};\n const collapsedSet = new Set<string>();\n\n const controllerTypeMap: Record<string, PipeType> = {};\n for (const node of graphspec.nodes) {\n if (analysis.controllerNodeIds.has(node.id)) {\n controllerTypeMap[node.id] = node.pipe_type;\n }\n }\n\n for (const ctrlId of analysis.controllerNodeIds) {\n const directChildren = analysis.containmentTree[ctrlId] || [];\n childCounts[ctrlId] = directChildren.length;\n const pipeType = controllerTypeMap[ctrlId];\n const isCollapsible = pipeType === \"PipeParallel\" || pipeType === \"PipeBatch\";\n if (\n isCollapsible &&\n directChildren.length > MAX_VISIBLE_CONTROLLER_CHILDREN &&\n !expandedControllers?.has(ctrlId)\n ) {\n collapsedSet.add(ctrlId);\n }\n }\n\n // ─── Filter hidden children for collapsed controllers ──────────────────\n let filteredNodes = layoutedNodes;\n let filteredEdges = layoutedEdges;\n\n if (collapsedSet.size > 0) {\n const hiddenNodes = new Set<string>();\n\n for (const ctrlId of collapsedSet) {\n const directChildren = analysis.containmentTree[ctrlId] || [];\n const toHide = directChildren.slice(MAX_VISIBLE_CONTROLLER_CHILDREN);\n for (const childId of toHide) {\n hiddenNodes.add(childId);\n if (analysis.controllerNodeIds.has(childId)) {\n for (const d of getDescendants(\n childId,\n analysis.containmentTree,\n analysis.controllerNodeIds,\n )) {\n hiddenNodes.add(d);\n }\n }\n }\n }\n\n // Also hide stuff nodes inside collapsed controllers that have no visible\n // pipe connection. We ignore stuff-to-stuff edges (batch_item/batch_aggregate)\n // because those would keep orphaned branch stuff nodes alive.\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n for (const node of layoutedNodes) {\n if (!isStuffNodeId(node.id) || hiddenNodes.has(node.id)) continue;\n const ctrlId = childToCtrl[node.id];\n if (!ctrlId || (!collapsedSet.has(ctrlId) && !hiddenNodes.has(ctrlId))) continue;\n const pipeEdges = layoutedEdges.filter((e) => {\n if (e.source !== node.id && e.target !== node.id) return false;\n const other = e.source === node.id ? e.target : e.source;\n return !isStuffNodeId(other); // only pipe connections\n });\n if (\n pipeEdges.length === 0 ||\n pipeEdges.every((e) => {\n const other = e.source === node.id ? e.target : e.source;\n return hiddenNodes.has(other);\n })\n ) {\n hiddenNodes.add(node.id);\n }\n }\n\n filteredNodes = layoutedNodes.filter((n) => !hiddenNodes.has(n.id));\n filteredEdges = layoutedEdges.filter(\n (e) => !hiddenNodes.has(e.source) && !hiddenNodes.has(e.target),\n );\n }\n\n // ─── Build controller group nodes from visible children ────────────────\n const controllerNodes = buildControllerNodes(\n graphspec,\n analysis,\n filteredNodes,\n controllerPositions,\n );\n if (controllerNodes.length === 0) {\n return { nodes: filteredNodes, edges: filteredEdges };\n }\n\n // Inject collapse + fold metadata into controller node data\n for (const cn of controllerNodes) {\n const count = childCounts[cn.id] ?? 0;\n const isCollapsed = collapsedSet.has(cn.id);\n cn.data.childCount = count;\n cn.data.isCollapsed = isCollapsed;\n if (onToggleCollapse) {\n const id = cn.id;\n cn.data.onToggleCollapse = () => onToggleCollapse(id);\n }\n if (onToggleFold) {\n const id = cn.id;\n cn.data.onToggleFold = (options?: FoldToggleOptions) => onToggleFold(id, options);\n }\n }\n\n const allNodes = [...controllerNodes, ...filteredNodes];\n\n // Sort: ReactFlow requires parent group nodes before their children.\n const nodeMap: Record<string, GraphNode> = {};\n for (const n of allNodes) nodeMap[n.id] = n;\n const depthOf: Record<string, number> = {};\n const depthVisiting = new Set<string>();\n function getContainmentDepth(id: string): number {\n if (depthOf[id] !== undefined) return depthOf[id];\n if (depthVisiting.has(id)) {\n throw new Error(\n `Cycle detected in node parent chain: node \"${id}\" references itself as an ancestor`,\n );\n }\n depthVisiting.add(id);\n const n = nodeMap[id];\n depthOf[id] = n && n.parentId ? 1 + getContainmentDepth(n.parentId) : 0;\n depthVisiting.delete(id);\n return depthOf[id];\n }\n for (const n of allNodes) getContainmentDepth(n.id);\n allNodes.sort((a, b) => depthOf[a.id] - depthOf[b.id]);\n\n return { nodes: allNodes, edges: filteredEdges };\n}\n","import type { GraphConfig, GraphTheme } from \"./types\";\nimport { EDGE_TYPE, FOLD_MODE, GRAPH_THEME } from \"./types\";\n\n/**\n * Semantic design tokens consumed by every component CSS file.\n *\n * Component CSS **must never** hardcode raw hex/rgba values. Reference these\n * tokens via `var(--token-name)`. A new theme is just a new set of values.\n * A new component picks up theming for free as long as it only uses tokens.\n *\n * Categories:\n * surface-* → backgrounds (page, panels, pills, glass overlays)\n * border-* → borders, dividers\n * text-* → foreground text\n * shadow-* → drop shadows\n * focus-ring → focus outline\n * color-* → domain-semantic colors (pipe accents, edges, status); kept\n * separate because they're meaningful in both themes (a pipe is\n * still red), only the *value* shifts for contrast.\n */\nconst FONT_TOKENS: Record<string, string> = {\n \"--font-sans\": '\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\n \"--font-mono\": '\"JetBrains Mono\", \"Monaco\", \"Menlo\", monospace',\n};\n\nexport const DARK_PALETTE_COLORS: Record<string, string> = {\n ...FONT_TOKENS,\n\n // Surfaces\n \"--surface-page\": \"#0a0a0a\",\n \"--surface-panel\": \"#111118\",\n \"--surface-overlay\": \"rgba(17, 17, 24, 0.8)\",\n \"--surface-overlay-hover\": \"rgba(30, 30, 40, 0.9)\",\n \"--surface-overlay-disabled\": \"rgba(17, 17, 24, 0.6)\",\n \"--surface-elevated\": \"rgba(255, 255, 255, 0.06)\",\n \"--surface-elevated-hover\": \"rgba(255, 255, 255, 0.1)\",\n \"--surface-sunken\": \"rgba(255, 255, 255, 0.03)\",\n \"--surface-pill\": \"rgba(255, 255, 255, 0.06)\",\n \"--surface-pill-border\": \"rgba(255, 255, 255, 0.08)\",\n\n // Borders\n \"--border-subtle\": \"rgba(255, 255, 255, 0.06)\",\n \"--border-default\": \"rgba(255, 255, 255, 0.1)\",\n \"--border-strong\": \"rgba(255, 255, 255, 0.18)\",\n \"--border-dashed\": \"rgba(255, 255, 255, 0.15)\",\n\n // Text\n \"--text-primary\": \"#f8fafc\",\n \"--text-default\": \"#e2e8f0\",\n \"--text-secondary\": \"#cbd5e1\",\n \"--text-muted\": \"#94a3b8\",\n \"--text-dim\": \"#64748b\",\n \"--text-on-accent\": \"#0e0e0e\",\n\n // Effects\n \"--shadow-sm\": \"0 2px 8px rgba(0, 0, 0, 0.4)\",\n \"--shadow-md\": \"0 4px 16px rgba(0, 0, 0, 0.6)\",\n \"--shadow-lg\": \"0 8px 24px rgba(0, 0, 0, 0.5)\",\n \"--focus-ring\": \"rgba(59, 130, 246, 0.6)\",\n\n // Domain-semantic colors (graph nodes/edges)\n \"--color-pipe\": \"#ff6b6b\",\n \"--color-pipe-bg\": \"rgba(224,108,117,0.18)\",\n \"--color-pipe-text\": \"#ffffff\",\n \"--color-stuff\": \"#4ECDC4\",\n \"--color-stuff-bg\": \"rgba(78,205,196,0.12)\",\n \"--color-stuff-border\": \"#9ddcfd\",\n \"--color-stuff-text\": \"#98FB98\",\n \"--color-stuff-text-dim\": \"#9ddcfd\",\n \"--color-edge\": \"#FFFACD\",\n \"--color-batch-item\": \"#bd93f9\",\n \"--color-batch-aggregate\": \"#50fa7b\",\n \"--color-parallel-combine\": \"#d6a4ff\",\n \"--color-success\": \"#50FA7B\",\n \"--color-success-bg\": \"rgba(80,250,123,0.15)\",\n \"--color-error\": \"#FF5555\",\n \"--color-error-bg\": \"rgba(255,85,85,0.15)\",\n \"--color-error-border\": \"rgba(255,85,85,0.2)\",\n \"--color-accent\": \"#8BE9FD\",\n \"--color-accent-strong\": \"#3b82f6\",\n \"--color-warning\": \"#FFB86C\",\n\n // Controller-group palette (tinted borders/backgrounds per controller type)\n \"--ctrl-sequence-border\": \"rgba(148, 163, 184, 0.25)\",\n \"--ctrl-sequence-bg\": \"rgba(148, 163, 184, 0.03)\",\n \"--ctrl-sequence-text\": \"#94a3b8\",\n \"--ctrl-parallel-border\": \"rgba(139, 233, 253, 0.35)\",\n \"--ctrl-parallel-bg\": \"rgba(139, 233, 253, 0.03)\",\n \"--ctrl-parallel-text\": \"#8be9fd\",\n \"--ctrl-condition-border\": \"rgba(251, 191, 36, 0.35)\",\n \"--ctrl-condition-bg\": \"rgba(251, 191, 36, 0.03)\",\n \"--ctrl-condition-text\": \"#fbbf24\",\n \"--ctrl-batch-border\": \"rgba(167, 139, 250, 0.35)\",\n \"--ctrl-batch-bg\": \"rgba(167, 139, 250, 0.03)\",\n \"--ctrl-batch-text\": \"#a78bfa\",\n \"--ctrl-folded-bg\": \"rgba(148, 163, 184, 0.25)\",\n \"--ctrl-folded-border\": \"rgba(148, 163, 184, 0.4)\",\n\n // Legacy aliases — kept so existing inline styles in graph builders keep\n // working until they're migrated. New code should use the semantic tokens.\n \"--color-bg\": \"#0a0a0a\",\n \"--color-bg-dots\": \"rgba(255, 255, 255, 0.35)\",\n \"--color-text-muted\": \"#94a3b8\",\n \"--color-controller-text\": \"#94a3b8\",\n};\n\nexport const LIGHT_PALETTE_COLORS: Record<string, string> = {\n ...FONT_TOKENS,\n\n // Surfaces — chart stays a soft off-white, panels slightly cooler\n \"--surface-page\": \"#f8fafc\",\n \"--surface-panel\": \"#ffffff\",\n \"--surface-overlay\": \"rgba(255, 255, 255, 0.92)\",\n \"--surface-overlay-hover\": \"rgba(241, 245, 249, 0.96)\",\n \"--surface-overlay-disabled\": \"rgba(255, 255, 255, 0.7)\",\n \"--surface-elevated\": \"rgba(15, 23, 42, 0.05)\",\n \"--surface-elevated-hover\": \"rgba(15, 23, 42, 0.09)\",\n \"--surface-sunken\": \"rgba(15, 23, 42, 0.03)\",\n \"--surface-pill\": \"rgba(15, 23, 42, 0.05)\",\n \"--surface-pill-border\": \"rgba(15, 23, 42, 0.1)\",\n\n // Borders\n \"--border-subtle\": \"rgba(15, 23, 42, 0.08)\",\n \"--border-default\": \"rgba(15, 23, 42, 0.12)\",\n \"--border-strong\": \"rgba(15, 23, 42, 0.22)\",\n \"--border-dashed\": \"rgba(15, 23, 42, 0.18)\",\n\n // Text\n \"--text-primary\": \"#020617\",\n \"--text-default\": \"#0f172a\",\n \"--text-secondary\": \"#1e293b\",\n \"--text-muted\": \"#475569\",\n \"--text-dim\": \"#64748b\",\n \"--text-on-accent\": \"#ffffff\",\n\n // Effects\n \"--shadow-sm\": \"0 2px 8px rgba(15, 23, 42, 0.08)\",\n \"--shadow-md\": \"0 4px 16px rgba(15, 23, 42, 0.14)\",\n \"--shadow-lg\": \"0 8px 24px rgba(15, 23, 42, 0.15)\",\n \"--focus-ring\": \"rgba(2, 132, 199, 0.5)\",\n\n // Domain-semantic colors — darker for contrast on light backgrounds\n \"--color-pipe\": \"#dc2626\",\n \"--color-pipe-bg\": \"rgba(220, 38, 38, 0.1)\",\n \"--color-pipe-text\": \"#ffffff\",\n \"--color-stuff\": \"#0891b2\",\n \"--color-stuff-bg\": \"rgba(8, 145, 178, 0.08)\",\n \"--color-stuff-border\": \"#0e7490\",\n \"--color-stuff-text\": \"#0f172a\",\n \"--color-stuff-text-dim\": \"#475569\",\n \"--color-edge\": \"#64748b\",\n \"--color-batch-item\": \"#7c3aed\",\n \"--color-batch-aggregate\": \"#15803d\",\n \"--color-parallel-combine\": \"#6d28d9\",\n \"--color-success\": \"#15803d\",\n \"--color-success-bg\": \"rgba(21, 128, 61, 0.12)\",\n \"--color-error\": \"#dc2626\",\n \"--color-error-bg\": \"rgba(220, 38, 38, 0.1)\",\n \"--color-error-border\": \"rgba(220, 38, 38, 0.25)\",\n \"--color-accent\": \"#0284c7\",\n \"--color-accent-strong\": \"#0284c7\",\n \"--color-warning\": \"#d97706\",\n\n // Controller-group palette\n \"--ctrl-sequence-border\": \"rgba(71, 85, 105, 0.3)\",\n \"--ctrl-sequence-bg\": \"rgba(71, 85, 105, 0.04)\",\n \"--ctrl-sequence-text\": \"#475569\",\n \"--ctrl-parallel-border\": \"rgba(8, 145, 178, 0.4)\",\n \"--ctrl-parallel-bg\": \"rgba(8, 145, 178, 0.05)\",\n \"--ctrl-parallel-text\": \"#0e7490\",\n \"--ctrl-condition-border\": \"rgba(217, 119, 6, 0.4)\",\n \"--ctrl-condition-bg\": \"rgba(217, 119, 6, 0.05)\",\n \"--ctrl-condition-text\": \"#b45309\",\n \"--ctrl-batch-border\": \"rgba(124, 58, 237, 0.4)\",\n \"--ctrl-batch-bg\": \"rgba(124, 58, 237, 0.05)\",\n \"--ctrl-batch-text\": \"#6d28d9\",\n \"--ctrl-folded-bg\": \"rgba(71, 85, 105, 0.18)\",\n \"--ctrl-folded-border\": \"rgba(71, 85, 105, 0.35)\",\n\n // Legacy aliases\n \"--color-bg\": \"#f8fafc\",\n \"--color-bg-dots\": \"rgba(15, 23, 42, 0.18)\",\n \"--color-text-muted\": \"#475569\",\n \"--color-controller-text\": \"#475569\",\n};\n\nexport function getPaletteForTheme(theme: GraphTheme): Record<string, string> {\n return theme === GRAPH_THEME.LIGHT ? LIGHT_PALETTE_COLORS : DARK_PALETTE_COLORS;\n}\n\nexport const DEFAULT_GRAPH_CONFIG: GraphConfig = {\n direction: \"LR\",\n showControllers: false,\n foldMode: FOLD_MODE.EXPANDED,\n theme: GRAPH_THEME.DARK,\n nodesep: 50,\n ranksep: 100,\n edgeType: EDGE_TYPE.DEFAULT,\n initialZoom: null,\n panToTop: true,\n // `paletteColors` intentionally omitted from the default. The viewer derives\n // the palette from the active `theme`. Consumers only set `paletteColors` to\n // override specific tokens (sparse merge on top of the theme palette).\n};\n\nexport function getPaletteColors(): Record<string, string> {\n return DARK_PALETTE_COLORS;\n}\n"],"mappings":";;;;;;;AAmBA,IAAM,qBAA6C;AAAA,EACjD,SAAS;AAAA,EACT,aAAa;AAAA,EACb,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,cAAc;AAAA,EACd,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AACb;AAGO,IAAM,mBAAwC,IAAI,IAAI,OAAO,KAAK,kBAAkB,CAAC;AAOrF,IAAM,sBAAsB;AAC5B,IAAM,kBAAkB;AACxB,IAAM,uBAAuB;AAK7B,IAAM,kBAAkB;AAExB,SAAS,YAAY,QAAwB;AAClD,SAAO,kBAAkB;AAC3B;AAEO,SAAS,cAAc,IAAqB;AACjD,SAAO,GAAG,WAAW,eAAe;AACtC;AAEO,SAAS,kBAAkB,IAAoB;AACpD,SAAO,GAAG,MAAM,gBAAgB,MAAM;AACxC;AAoUO,IAAM,kBAAkB;AAAA,EAC7B,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAIO,IAAM,YAAY;AAAA;AAAA,EAEvB,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,aAAa;AACf;AAIO,IAAM,YAAY;AAAA;AAAA,EAEvB,QAAQ;AAAA;AAAA,EAER,UAAU;AAAA;AAAA,EAEV,MAAM;AACR;AAIO,IAAM,cAAc;AAAA,EACzB,MAAM;AAAA,EACN,OAAO;AACT;AAyHO,IAAM,uBAAuB;AAC7B,IAAM,yBAAyB;AAC/B,IAAM,4BAA4B;AAGlC,IAAM,sBAAsB;AAM5B,SAAS,UAAU,GAAsB;AApiBhD;AAqiBE,QAAM,OAAM,OAAE,UAAF,mBAAS;AACrB,MAAI,OAAO,KAAM,QAAO;AACxB,QAAM,IAAI,OAAO,QAAQ,WAAW,MAAM,WAAW,GAAG;AACxD,SA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;AAAA,EACjB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA;AAAA,EAGnB,0BAA0B;AAAA,EAC1B,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,EAC1B,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,uBAAuB;AAAA,EACvB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA;AAAA,EAGxB,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,sBAAsB;AAAA,EACtB,2BAA2B;AAC7B;AAEO,SAAS,mBAAmB,OAA2C;AAC5E,SAAO,UAAU,YAAY,QAAQ,uBAAuB;AAC9D;AAEO,IAAM,uBAAoC;AAAA,EAC/C,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,UAAU,UAAU;AAAA,EACpB,OAAO,YAAY;AAAA,EACnB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU,UAAU;AAAA,EACpB,aAAa;AAAA,EACb,UAAU;AAAA;AAAA;AAAA;AAIZ;AAEO,SAAS,mBAA2C;AACzD,SAAO;AACT;","names":["dimensionMap","elkEdges","_a","_b"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-L24K3TZU.js.map
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
import { c as GraphSpec, D as DataflowAnalysis, C as ConceptInfo,
|
|
2
|
-
export { A as ARROW_CLOSED_MARKER,
|
|
1
|
+
import { j as GraphSpecNode, m as PipeCallNode, c as GraphSpec, D as DataflowAnalysis, C as ConceptInfo, n as PipeBlueprintUnion, o as GraphData, p as PipeCardPayload, h as FoldToggleOptions, b as GraphNode, a as GraphEdge, e as GraphDirection, q as LayoutConfig, d as GraphConfig, f as GraphTheme } from '../types-DJTrDxjV.js';
|
|
2
|
+
export { A as ARROW_CLOSED_MARKER, r as CONTROLLER_PADDING_BOTTOM, s as CONTROLLER_PADDING_TOP, t as CONTROLLER_PADDING_X, E as EDGE_TYPE, u as EdgeType, v as FOLD_MODE, w as FieldResolution, F as FoldMode, x as GRAPH_DIRECTION, y as GRAPH_THEME, G as GraphNodeData, z as GraphSpecEdge, B as GraphSpecEdgeKind, H as GraphSpecNodeError, I as GraphSpecNodeIo, k as GraphSpecNodeIoItem, J as GraphSpecNodeTiming, K as KNOWN_PIPE_TYPES, L as LabelDescriptor, N as NODE_TYPE_CONTROLLER, M as NODE_TYPE_PIPE_CARD, O as NODE_TYPE_STUFF, Q as NodeKind, R as PipeBatchBlueprint, S as PipeBlueprintBase, T as PipeComposeBlueprint, U as PipeComposeConstructBlueprint, V as PipeComposeConstructField, W as PipeConditionBlueprint, g as PipeControllerType, X as PipeExtractBlueprint, Y as PipeFuncBlueprint, Z as PipeImgGenBlueprint, _ as PipeLLMBlueprint, l as PipeOperatorType, $ as PipeParallelBlueprint, a0 as PipeSearchBlueprint, a1 as PipeSequenceBlueprint, P as PipeStatus, i as PipeType, a2 as STUFF_ID_PREFIX, a3 as StuffRole, a4 as StuffSpecInfo, a5 as SubPipeSpec, a6 as TemplateBlueprint, a7 as isStuffNodeId, a8 as nodeHeight, a9 as nodeWidth, aa as stuffDigestFromId, ab as stuffNodeId } from '../types-DJTrDxjV.js';
|
|
3
3
|
import { ElkNode } from 'elkjs/lib/elk-api';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Single boundary validator for GraphSpec JSON.
|
|
7
|
+
*
|
|
8
|
+
* `validateGraphSpec()` runs once when a spec is loaded from an untyped source
|
|
9
|
+
* (embedded JSON, library consumer input). After it returns, internal code
|
|
10
|
+
* trusts the data and uses the strict types in `types.ts` — no inline
|
|
11
|
+
* defensive checks scattered across modules.
|
|
12
|
+
*
|
|
13
|
+
* The pipelex runtime guarantees specific fields are always present and
|
|
14
|
+
* non-null. This validator enforces those guarantees and fails loudly when
|
|
15
|
+
* they are violated, instead of hiding upstream bugs behind fabricated values.
|
|
16
|
+
*
|
|
17
|
+
* Note: `validateGraphSpec` normalizes the input **in place** — see its doc
|
|
18
|
+
* comment.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Thrown by `validateGraphSpec` when a spec violates a pipelex runtime
|
|
23
|
+
* guarantee. `path` points at the offending location (e.g.
|
|
24
|
+
* `nodes[3].io.inputs[0].name`) and `name` is the stable, greppable
|
|
25
|
+
* `"GraphSpecValidationError"`.
|
|
26
|
+
*/
|
|
27
|
+
declare class GraphSpecValidationError extends Error {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
constructor(path: string, detail: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate a raw, untyped value as a `GraphSpec`. Throws
|
|
33
|
+
* `GraphSpecValidationError` on the first violation.
|
|
34
|
+
*
|
|
35
|
+
* **Mutates the input in place:** on success it returns the *same* object
|
|
36
|
+
* (typed as `GraphSpec`), and where a node has no `io` key it writes
|
|
37
|
+
* `io = { inputs: [], outputs: [] }` (and fills absent `io.inputs` /
|
|
38
|
+
* `io.outputs` arrays) directly onto the passed-in object. Pass a fresh
|
|
39
|
+
* parse result (e.g. straight from `JSON.parse`) — do not pass a frozen or
|
|
40
|
+
* externally shared object.
|
|
41
|
+
*/
|
|
42
|
+
declare function validateGraphSpec(raw: unknown): GraphSpec;
|
|
43
|
+
/**
|
|
44
|
+
* Narrow a `GraphSpecNode` to a `PipeCallNode` at an internal trust boundary,
|
|
45
|
+
* throwing `GraphSpecValidationError` when the node is not a well-formed
|
|
46
|
+
* pipe-call node.
|
|
47
|
+
*
|
|
48
|
+
* Graph-topology analysis (`buildGraph` and friends) identifies a node as a
|
|
49
|
+
* pipe by its edges, not by re-checking `kind`/`pipe_code`. When the spec has
|
|
50
|
+
* been through `validateGraphSpec` this always holds — but library consumers
|
|
51
|
+
* may call `buildGraph` directly. This guard turns that gap into a loud,
|
|
52
|
+
* greppable failure instead of a bare `TypeError` on a missing `pipe_code`.
|
|
53
|
+
*/
|
|
54
|
+
declare function asPipeCallNode(node: GraphSpecNode, path?: string): PipeCallNode;
|
|
55
|
+
|
|
5
56
|
declare function buildDataflowAnalysis(graphspec: GraphSpec | null): DataflowAnalysis | null;
|
|
6
57
|
/**
|
|
7
58
|
* Build a map from node id -> controller id for all nodes that belong to a controller.
|
|
@@ -31,12 +82,13 @@ declare function buildGraph(graphspec: GraphSpec | null, edgeType: string): {
|
|
|
31
82
|
};
|
|
32
83
|
|
|
33
84
|
/**
|
|
34
|
-
* Build a PipeCardPayload from a
|
|
85
|
+
* Build a PipeCardPayload from a pipe-call node.
|
|
35
86
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
87
|
+
* `validateGraphSpec` guarantees the pipe-call node's `pipe_code`, `pipe_type`,
|
|
88
|
+
* `description`, `status`, and `io` are present and well-formed, so this
|
|
89
|
+
* function reads them directly with no fallback synthesis.
|
|
38
90
|
*/
|
|
39
|
-
declare function buildPipeCardPayload(node:
|
|
91
|
+
declare function buildPipeCardPayload(node: PipeCallNode): PipeCardPayload;
|
|
40
92
|
|
|
41
93
|
/**
|
|
42
94
|
* Find every controller that shares the same `pipe_code` as `controllerId` —
|
|
@@ -137,7 +189,10 @@ declare function applyControllers(layoutedNodes: GraphNode[], layoutedEdges: Gra
|
|
|
137
189
|
edges: GraphEdge[];
|
|
138
190
|
};
|
|
139
191
|
|
|
192
|
+
declare const DARK_PALETTE_COLORS: Record<string, string>;
|
|
193
|
+
declare const LIGHT_PALETTE_COLORS: Record<string, string>;
|
|
194
|
+
declare function getPaletteForTheme(theme: GraphTheme): Record<string, string>;
|
|
140
195
|
declare const DEFAULT_GRAPH_CONFIG: GraphConfig;
|
|
141
196
|
declare function getPaletteColors(): Record<string, string>;
|
|
142
197
|
|
|
143
|
-
export { ConceptInfo, type ControllerRect, DEFAULT_GRAPH_CONFIG, DataflowAnalysis, type ElkPositionResult, FoldToggleOptions, GraphConfig, GraphData, GraphDirection, GraphEdge, GraphNode, GraphSpec, GraphSpecNode, LayoutConfig, type LayoutResult, MAX_VISIBLE_CONTROLLER_CHILDREN, PipeBlueprintUnion, PipeCardPayload, applyControllers, applyFolds, buildChildToControllerMap, buildContainmentChain, buildControllerNodes, buildDataflowAnalysis, buildDataflowGraph, buildElkGraph, buildGraph, buildPipeCardPayload, estimateNodeDimensions, extractAbsolutePositions, findCousinControllers, getConceptInfo, getLayoutedElements, getPaletteColors, getPipeBlueprint, inputPortId, outermostFoldedAncestor, outputPortId, resolveConceptRef };
|
|
198
|
+
export { ConceptInfo, type ControllerRect, DARK_PALETTE_COLORS, DEFAULT_GRAPH_CONFIG, DataflowAnalysis, type ElkPositionResult, FoldToggleOptions, GraphConfig, GraphData, GraphDirection, GraphEdge, GraphNode, GraphSpec, GraphSpecNode, GraphSpecValidationError, GraphTheme, LIGHT_PALETTE_COLORS, LayoutConfig, type LayoutResult, MAX_VISIBLE_CONTROLLER_CHILDREN, PipeBlueprintUnion, PipeCallNode, PipeCardPayload, applyControllers, applyFolds, asPipeCallNode, buildChildToControllerMap, buildContainmentChain, buildControllerNodes, buildDataflowAnalysis, buildDataflowGraph, buildElkGraph, buildGraph, buildPipeCardPayload, estimateNodeDimensions, extractAbsolutePositions, findCousinControllers, getConceptInfo, getLayoutedElements, getPaletteColors, getPaletteForTheme, getPipeBlueprint, inputPortId, outermostFoldedAncestor, outputPortId, resolveConceptRef, validateGraphSpec };
|
package/dist/graph/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-L24K3TZU.js";
|
|
2
2
|
import {
|
|
3
3
|
ARROW_CLOSED_MARKER,
|
|
4
4
|
CONTROLLER_PADDING_BOTTOM,
|
|
5
5
|
CONTROLLER_PADDING_TOP,
|
|
6
6
|
CONTROLLER_PADDING_X,
|
|
7
|
+
DARK_PALETTE_COLORS,
|
|
7
8
|
DEFAULT_GRAPH_CONFIG,
|
|
8
9
|
EDGE_TYPE,
|
|
9
10
|
FOLD_MODE,
|
|
10
11
|
GRAPH_DIRECTION,
|
|
12
|
+
GRAPH_THEME,
|
|
13
|
+
GraphSpecValidationError,
|
|
14
|
+
KNOWN_PIPE_TYPES,
|
|
15
|
+
LIGHT_PALETTE_COLORS,
|
|
11
16
|
MAX_VISIBLE_CONTROLLER_CHILDREN,
|
|
12
17
|
NODE_TYPE_CONTROLLER,
|
|
13
18
|
NODE_TYPE_PIPE_CARD,
|
|
@@ -15,6 +20,7 @@ import {
|
|
|
15
20
|
STUFF_ID_PREFIX,
|
|
16
21
|
applyControllers,
|
|
17
22
|
applyFolds,
|
|
23
|
+
asPipeCallNode,
|
|
18
24
|
buildChildToControllerMap,
|
|
19
25
|
buildContainmentChain,
|
|
20
26
|
buildControllerNodes,
|
|
@@ -29,6 +35,7 @@ import {
|
|
|
29
35
|
getConceptInfo,
|
|
30
36
|
getLayoutedElements,
|
|
31
37
|
getPaletteColors,
|
|
38
|
+
getPaletteForTheme,
|
|
32
39
|
getPipeBlueprint,
|
|
33
40
|
inputPortId,
|
|
34
41
|
isStuffNodeId,
|
|
@@ -38,18 +45,24 @@ import {
|
|
|
38
45
|
outputPortId,
|
|
39
46
|
resolveConceptRef,
|
|
40
47
|
stuffDigestFromId,
|
|
41
|
-
stuffNodeId
|
|
42
|
-
|
|
48
|
+
stuffNodeId,
|
|
49
|
+
validateGraphSpec
|
|
50
|
+
} from "../chunk-ILX53OYM.js";
|
|
43
51
|
import "../chunk-2NMEKWO5.js";
|
|
44
52
|
export {
|
|
45
53
|
ARROW_CLOSED_MARKER,
|
|
46
54
|
CONTROLLER_PADDING_BOTTOM,
|
|
47
55
|
CONTROLLER_PADDING_TOP,
|
|
48
56
|
CONTROLLER_PADDING_X,
|
|
57
|
+
DARK_PALETTE_COLORS,
|
|
49
58
|
DEFAULT_GRAPH_CONFIG,
|
|
50
59
|
EDGE_TYPE,
|
|
51
60
|
FOLD_MODE,
|
|
52
61
|
GRAPH_DIRECTION,
|
|
62
|
+
GRAPH_THEME,
|
|
63
|
+
GraphSpecValidationError,
|
|
64
|
+
KNOWN_PIPE_TYPES,
|
|
65
|
+
LIGHT_PALETTE_COLORS,
|
|
53
66
|
MAX_VISIBLE_CONTROLLER_CHILDREN,
|
|
54
67
|
NODE_TYPE_CONTROLLER,
|
|
55
68
|
NODE_TYPE_PIPE_CARD,
|
|
@@ -57,6 +70,7 @@ export {
|
|
|
57
70
|
STUFF_ID_PREFIX,
|
|
58
71
|
applyControllers,
|
|
59
72
|
applyFolds,
|
|
73
|
+
asPipeCallNode,
|
|
60
74
|
buildChildToControllerMap,
|
|
61
75
|
buildContainmentChain,
|
|
62
76
|
buildControllerNodes,
|
|
@@ -71,6 +85,7 @@ export {
|
|
|
71
85
|
getConceptInfo,
|
|
72
86
|
getLayoutedElements,
|
|
73
87
|
getPaletteColors,
|
|
88
|
+
getPaletteForTheme,
|
|
74
89
|
getPipeBlueprint,
|
|
75
90
|
inputPortId,
|
|
76
91
|
isStuffNodeId,
|
|
@@ -80,6 +95,7 @@ export {
|
|
|
80
95
|
outputPortId,
|
|
81
96
|
resolveConceptRef,
|
|
82
97
|
stuffDigestFromId,
|
|
83
|
-
stuffNodeId
|
|
98
|
+
stuffNodeId,
|
|
99
|
+
validateGraphSpec
|
|
84
100
|
};
|
|
85
101
|
//# sourceMappingURL=index.js.map
|