diagram-contracts 0.2.6 → 0.2.8

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/cli.mjs CHANGED
@@ -4,8 +4,8 @@
4
4
  import { Command } from "commander";
5
5
 
6
6
  // src/generated/contract.ts
7
- var CONTRACT_YAML = "cli_contracts: 0.1.0\n\ninfo:\n title: diagram-contracts\n version: 0.2.6\n description: Convert Layout IR to SVG.\n\ncommand_sets:\n diagram-contracts:\n summary: DSL-to-SVG diagram tool.\n\n # Parent-group descriptions for the nested subcommand groups (spec #62 /\n # #71). cli-contracts@0.33.15 emits these as `.description(...)` on the\n # generated `program.command(<group>)`, so the group help lines live in the\n # contract SSoT rather than in hand-written cli.ts (cli-contracts#77).\n groups:\n components:\n description: Component Pack tooling.\n icons:\n description: Icon provider tooling.\n\n commands:\n render:\n summary: Render Layout IR to SVG.\n description: Reads Layout IR JSON from a file or stdin and outputs SVG. A .md/.markdown file input renders each ```draw / ```mermaid fenced block to its own SVG (spec \xA78, stretch); with -o, per-block files (out.svg -> out.1.svg, out.2.svg, ...); without -o, blocks concatenate to stdout separated by <!-- draw-block N --> comments.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file (or Draw Text / .draw.tsx / .md source). Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output SVG file. Writes to stdout if omitted.\n schema:\n type: string\n - name: theme\n description: Theme YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: tokens\n description: Tokens YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: font-file\n description: Font file(s) for text measurement (.woff/.ttf/.otf). Comma-separated entries, each a path or <weight>=<path> (e.g. \"400=inter.woff,700=inter-bold.woff\"). Overrides font-family based resolution.\n schema:\n type: string\n - name: config\n description: draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: SVG rendered successfully.\n '1':\n description: IR validation error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n convert:\n summary: Eject Draw Text to Draw TSX (spec \xA78.1).\n description: Parses a Draw Text source to the Draw DSL tree (post-bind, pre-expansion) and serializes it as readable Draw TSX. The output compiled via the TSX path renders byte-identical SVG to rendering the Draw Text source directly.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input Draw Text file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output .draw.tsx file. Writes to stdout if omitted.\n schema:\n type: string\n - name: config\n description: draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: Draw TSX emitted successfully.\n '1':\n description: Parse / bind diagnostic error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n validate:\n summary: Validate Layout IR JSON.\n description: Validates IR JSON against the schema without rendering.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: IR is valid.\n stdout:\n format: text\n '1':\n description: Validation error.\n stderr:\n format: text\n\n ir:\n summary: Output normalized IR or resolved artifact as JSON.\n description: Reads Layout IR JSON input and outputs the normalized IR or resolved layout artifact.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output JSON file. Writes to stdout if omitted.\n schema:\n type: string\n - name: theme\n description: Theme YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: tokens\n description: Tokens YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: stage\n aliases: [s]\n description: Output stage.\n schema:\n type: string\n enum: [normalized, artifact]\n default: artifact\n exits:\n '0':\n description: Success.\n '1':\n description: IR validation error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n # Nested subcommands (`<group> <verb>`, spec #62 / #71). The map key uses\n # dot notation, which cli-contracts splits into an invocation path\n # (`components build`) and a camelCase handler name (`componentsBuild`).\n components.build:\n summary: Build a Component Pack from a .draw.tsx entry.\n arguments:\n - name: entry\n index: 0\n required: true\n description: Entry .draw.tsx file whose exported/imported components are packed.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output pack JSON file. Writes to stdout if omitted.\n schema:\n type: string\n - name: icons\n description: Comma-separated qualified icon names to embed offline (e.g. aws:ecs,aws:rds). Explicit list only \u2014 no template scan. A name that does not resolve at build time is an error.\n schema:\n type: string\n exits:\n '0':\n description: Component Pack built successfully.\n '1':\n description: Extraction / icon-resolution diagnostic error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n icons.export:\n summary: Export built-in provider icons as static SVG files.\n arguments:\n - name: provider\n index: 0\n required: true\n description: Icon provider (e.g. aws).\n schema:\n type: string\n options:\n - name: names\n description: Comma-separated icon short names to export (e.g. ecs,rds,vpc-group).\n schema:\n type: string\n - name: output\n aliases: [o]\n description: Output directory (created if missing).\n schema:\n type: string\n exits:\n '0':\n description: Icons exported successfully.\n '1':\n description: Icon-resolution error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n";
8
- var CONTRACT_JSON_STR = '{\n "cli_contracts": "0.1.0",\n "info": {\n "title": "diagram-contracts",\n "version": "0.2.6",\n "description": "Convert Layout IR to SVG."\n },\n "command_sets": {\n "diagram-contracts": {\n "summary": "DSL-to-SVG diagram tool.",\n "groups": {\n "components": {\n "description": "Component Pack tooling."\n },\n "icons": {\n "description": "Icon provider tooling."\n }\n },\n "commands": {\n "render": {\n "summary": "Render Layout IR to SVG.",\n "description": "Reads Layout IR JSON from a file or stdin and outputs SVG. A .md/.markdown file input renders each ```draw / ```mermaid fenced block to its own SVG (spec \xA78, stretch); with -o, per-block files (out.svg -> out.1.svg, out.2.svg, ...); without -o, blocks concatenate to stdout separated by <!-- draw-block N --> comments.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file (or Draw Text / .draw.tsx / .md source). Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output SVG file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "theme",\n "description": "Theme YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "tokens",\n "description": "Tokens YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "font-file",\n "description": "Font file(s) for text measurement (.woff/.ttf/.otf). Comma-separated entries, each a path or <weight>=<path> (e.g. \\"400=inter.woff,700=inter-bold.woff\\"). Overrides font-family based resolution.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "config",\n "description": "draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "SVG rendered successfully."\n },\n "1": {\n "description": "IR validation error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "convert": {\n "summary": "Eject Draw Text to Draw TSX (spec \xA78.1).",\n "description": "Parses a Draw Text source to the Draw DSL tree (post-bind, pre-expansion) and serializes it as readable Draw TSX. The output compiled via the TSX path renders byte-identical SVG to rendering the Draw Text source directly.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input Draw Text file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output .draw.tsx file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "config",\n "description": "draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Draw TSX emitted successfully."\n },\n "1": {\n "description": "Parse / bind diagnostic error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "validate": {\n "summary": "Validate Layout IR JSON.",\n "description": "Validates IR JSON against the schema without rendering.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "IR is valid.",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Validation error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "ir": {\n "summary": "Output normalized IR or resolved artifact as JSON.",\n "description": "Reads Layout IR JSON input and outputs the normalized IR or resolved layout artifact.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output JSON file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "theme",\n "description": "Theme YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "tokens",\n "description": "Tokens YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "stage",\n "aliases": [\n "s"\n ],\n "description": "Output stage.",\n "schema": {\n "type": "string",\n "enum": [\n "normalized",\n "artifact"\n ],\n "default": "artifact"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Success."\n },\n "1": {\n "description": "IR validation error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "components.build": {\n "summary": "Build a Component Pack from a .draw.tsx entry.",\n "arguments": [\n {\n "name": "entry",\n "index": 0,\n "required": true,\n "description": "Entry .draw.tsx file whose exported/imported components are packed.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output pack JSON file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "icons",\n "description": "Comma-separated qualified icon names to embed offline (e.g. aws:ecs,aws:rds). Explicit list only \u2014 no template scan. A name that does not resolve at build time is an error.",\n "schema": {\n "type": "string"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Component Pack built successfully."\n },\n "1": {\n "description": "Extraction / icon-resolution diagnostic error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "icons.export": {\n "summary": "Export built-in provider icons as static SVG files.",\n "arguments": [\n {\n "name": "provider",\n "index": 0,\n "required": true,\n "description": "Icon provider (e.g. aws).",\n "schema": {\n "type": "string"\n }\n }\n ],\n "options": [\n {\n "name": "names",\n "description": "Comma-separated icon short names to export (e.g. ecs,rds,vpc-group).",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output directory (created if missing).",\n "schema": {\n "type": "string"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Icons exported successfully."\n },\n "1": {\n "description": "Icon-resolution error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n }\n }\n }\n }\n}';
7
+ var CONTRACT_YAML = "cli_contracts: 0.1.0\n\ninfo:\n title: diagram-contracts\n version: 0.2.8\n description: Convert Layout IR to SVG.\n\ncommand_sets:\n diagram-contracts:\n summary: DSL-to-SVG diagram tool.\n\n # Parent-group descriptions for the nested subcommand groups (spec #62 /\n # #71). cli-contracts@0.33.15 emits these as `.description(...)` on the\n # generated `program.command(<group>)`, so the group help lines live in the\n # contract SSoT rather than in hand-written cli.ts (cli-contracts#77).\n groups:\n components:\n description: Component Pack tooling.\n icons:\n description: Icon provider tooling.\n\n commands:\n render:\n summary: Render Layout IR to SVG.\n description: Reads Layout IR JSON from a file or stdin and outputs SVG. A .md/.markdown file input renders each ```draw / ```mermaid fenced block to its own SVG (spec \xA78, stretch); with -o, per-block files (out.svg -> out.1.svg, out.2.svg, ...); without -o, blocks concatenate to stdout separated by <!-- draw-block N --> comments.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file (or Draw Text / .draw.tsx / .md source). Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output SVG file. Writes to stdout if omitted.\n schema:\n type: string\n - name: theme\n description: Theme YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: tokens\n description: Tokens YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: font-file\n description: Font file(s) for text measurement (.woff/.ttf/.otf). Comma-separated entries, each a path or <weight>=<path> (e.g. \"400=inter.woff,700=inter-bold.woff\"). Overrides font-family based resolution.\n schema:\n type: string\n - name: config\n description: draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: SVG rendered successfully.\n '1':\n description: IR validation error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n convert:\n summary: Eject Draw Text to Draw TSX (spec \xA78.1).\n description: Parses a Draw Text source to the Draw DSL tree (post-bind, pre-expansion) and serializes it as readable Draw TSX. The output compiled via the TSX path renders byte-identical SVG to rendering the Draw Text source directly.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input Draw Text file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output .draw.tsx file. Writes to stdout if omitted.\n schema:\n type: string\n - name: config\n description: draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: Draw TSX emitted successfully.\n '1':\n description: Parse / bind diagnostic error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n validate:\n summary: Validate Layout IR JSON.\n description: Validates IR JSON against the schema without rendering.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n exits:\n '0':\n description: IR is valid.\n stdout:\n format: text\n '1':\n description: Validation error.\n stderr:\n format: text\n\n ir:\n summary: Output normalized IR or resolved artifact as JSON.\n description: Reads Layout IR JSON input and outputs the normalized IR or resolved layout artifact.\n arguments:\n - name: input\n index: 0\n required: false\n description: Input IR JSON file. Reads from stdin if omitted.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output JSON file. Writes to stdout if omitted.\n schema:\n type: string\n - name: theme\n description: Theme YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: tokens\n description: Tokens YAML file path.\n schema:\n type: string\n file:\n mode: read\n exists: true\n - name: stage\n aliases: [s]\n description: Output stage.\n schema:\n type: string\n enum: [normalized, artifact]\n default: artifact\n exits:\n '0':\n description: Success.\n '1':\n description: IR validation error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n # Nested subcommands (`<group> <verb>`, spec #62 / #71). The map key uses\n # dot notation, which cli-contracts splits into an invocation path\n # (`components build`) and a camelCase handler name (`componentsBuild`).\n components.build:\n summary: Build a Component Pack from a .draw.tsx entry.\n arguments:\n - name: entry\n index: 0\n required: true\n description: Entry .draw.tsx file whose exported/imported components are packed.\n schema:\n type: string\n file:\n mode: read\n exists: true\n options:\n - name: output\n aliases: [o]\n description: Output pack JSON file. Writes to stdout if omitted.\n schema:\n type: string\n - name: icons\n description: Comma-separated qualified icon names to embed offline (e.g. aws:ecs,aws:rds). Explicit list only \u2014 no template scan. A name that does not resolve at build time is an error.\n schema:\n type: string\n exits:\n '0':\n description: Component Pack built successfully.\n '1':\n description: Extraction / icon-resolution diagnostic error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n\n icons.export:\n summary: Export built-in provider icons as static SVG files.\n arguments:\n - name: provider\n index: 0\n required: true\n description: Icon provider (e.g. aws).\n schema:\n type: string\n options:\n - name: names\n description: Comma-separated icon short names to export (e.g. ecs,rds,vpc-group).\n schema:\n type: string\n - name: output\n aliases: [o]\n description: Output directory (created if missing).\n schema:\n type: string\n exits:\n '0':\n description: Icons exported successfully.\n '1':\n description: Icon-resolution error.\n stderr:\n format: text\n '2':\n description: File I/O error.\n stderr:\n format: text\n";
8
+ var CONTRACT_JSON_STR = '{\n "cli_contracts": "0.1.0",\n "info": {\n "title": "diagram-contracts",\n "version": "0.2.8",\n "description": "Convert Layout IR to SVG."\n },\n "command_sets": {\n "diagram-contracts": {\n "summary": "DSL-to-SVG diagram tool.",\n "groups": {\n "components": {\n "description": "Component Pack tooling."\n },\n "icons": {\n "description": "Icon provider tooling."\n }\n },\n "commands": {\n "render": {\n "summary": "Render Layout IR to SVG.",\n "description": "Reads Layout IR JSON from a file or stdin and outputs SVG. A .md/.markdown file input renders each ```draw / ```mermaid fenced block to its own SVG (spec \xA78, stretch); with -o, per-block files (out.svg -> out.1.svg, out.2.svg, ...); without -o, blocks concatenate to stdout separated by <!-- draw-block N --> comments.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file (or Draw Text / .draw.tsx / .md source). Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output SVG file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "theme",\n "description": "Theme YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "tokens",\n "description": "Tokens YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "font-file",\n "description": "Font file(s) for text measurement (.woff/.ttf/.otf). Comma-separated entries, each a path or <weight>=<path> (e.g. \\"400=inter.woff,700=inter-bold.woff\\"). Overrides font-family based resolution.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "config",\n "description": "draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "SVG rendered successfully."\n },\n "1": {\n "description": "IR validation error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "convert": {\n "summary": "Eject Draw Text to Draw TSX (spec \xA78.1).",\n "description": "Parses a Draw Text source to the Draw DSL tree (post-bind, pre-expansion) and serializes it as readable Draw TSX. The output compiled via the TSX path renders byte-identical SVG to rendering the Draw Text source directly.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input Draw Text file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output .draw.tsx file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "config",\n "description": "draw.config.yaml file (project-level bindings/props/doc/theme + icon providers, spec \xA75). Merged under inline %%@ directives.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Draw TSX emitted successfully."\n },\n "1": {\n "description": "Parse / bind diagnostic error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "validate": {\n "summary": "Validate Layout IR JSON.",\n "description": "Validates IR JSON against the schema without rendering.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "exits": {\n "0": {\n "description": "IR is valid.",\n "stdout": {\n "format": "text"\n }\n },\n "1": {\n "description": "Validation error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "ir": {\n "summary": "Output normalized IR or resolved artifact as JSON.",\n "description": "Reads Layout IR JSON input and outputs the normalized IR or resolved layout artifact.",\n "arguments": [\n {\n "name": "input",\n "index": 0,\n "required": false,\n "description": "Input IR JSON file. Reads from stdin if omitted.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output JSON file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "theme",\n "description": "Theme YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "tokens",\n "description": "Tokens YAML file path.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n },\n {\n "name": "stage",\n "aliases": [\n "s"\n ],\n "description": "Output stage.",\n "schema": {\n "type": "string",\n "enum": [\n "normalized",\n "artifact"\n ],\n "default": "artifact"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Success."\n },\n "1": {\n "description": "IR validation error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "components.build": {\n "summary": "Build a Component Pack from a .draw.tsx entry.",\n "arguments": [\n {\n "name": "entry",\n "index": 0,\n "required": true,\n "description": "Entry .draw.tsx file whose exported/imported components are packed.",\n "schema": {\n "type": "string"\n },\n "file": {\n "mode": "read",\n "exists": true\n }\n }\n ],\n "options": [\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output pack JSON file. Writes to stdout if omitted.",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "icons",\n "description": "Comma-separated qualified icon names to embed offline (e.g. aws:ecs,aws:rds). Explicit list only \u2014 no template scan. A name that does not resolve at build time is an error.",\n "schema": {\n "type": "string"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Component Pack built successfully."\n },\n "1": {\n "description": "Extraction / icon-resolution diagnostic error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n },\n "icons.export": {\n "summary": "Export built-in provider icons as static SVG files.",\n "arguments": [\n {\n "name": "provider",\n "index": 0,\n "required": true,\n "description": "Icon provider (e.g. aws).",\n "schema": {\n "type": "string"\n }\n }\n ],\n "options": [\n {\n "name": "names",\n "description": "Comma-separated icon short names to export (e.g. ecs,rds,vpc-group).",\n "schema": {\n "type": "string"\n }\n },\n {\n "name": "output",\n "aliases": [\n "o"\n ],\n "description": "Output directory (created if missing).",\n "schema": {\n "type": "string"\n }\n }\n ],\n "exits": {\n "0": {\n "description": "Icons exported successfully."\n },\n "1": {\n "description": "Icon-resolution error.",\n "stderr": {\n "format": "text"\n }\n },\n "2": {\n "description": "File I/O error.",\n "stderr": {\n "format": "text"\n }\n }\n }\n }\n }\n }\n }\n}';
9
9
 
10
10
  // src/generated/program.ts
11
11
  function createProgram(handlers2, version) {
@@ -31,10 +31,11 @@ function createProgram(handlers2, version) {
31
31
  __cmd_icons.command("export").description("Export built-in provider icons as static SVG files.").argument("<provider>", "Icon provider (e.g. aws).").option("--names <value>", "Comma-separated icon short names to export (e.g. ecs,rds,vpc-group).").option("-o, --output <value>", "Output directory (created if missing).").action(async (provider, opts, cmd) => {
32
32
  await handlers2.iconsExport(provider, opts, cmd.optsWithGlobals());
33
33
  });
34
- program2.command("extract").description("Extract contract specification for this CLI tool.").argument("[commands...]", "Command IDs to extract. Use dot notation.").option("-a, --all", "Extract all commands.", false).option("--include-meta", "Include extraction metadata.", true).option("-F, --format <format>", "Output format (yaml or json).", "yaml").action(async (commands, opts) => {
34
+ program2.command("extract").description("Extract contract specification for this CLI tool.").argument("[commands...]", "Command IDs to extract. Use dot notation.").option("-a, --all", "Extract all commands.", false).option("--include-meta", "Include extraction metadata.", true).option("--no-include-meta").option("-F, --format <format>", "Output format (yaml or json).", "yaml").action(async (commands, opts) => {
35
35
  if (commands.length === 0 && !opts.all) {
36
36
  process.stderr.write(JSON.stringify({ code: "INVALID_ARGS", message: "Specify command IDs or use --all" }) + "\n");
37
- process.exit(2);
37
+ process.exitCode = 2;
38
+ return;
38
39
  }
39
40
  const format = opts.format || "yaml";
40
41
  const doc = JSON.parse(CONTRACT_JSON_STR);
@@ -99,7 +100,7 @@ function createProgram(handlers2, version) {
99
100
  if (doc.components) filtered.components = doc.components;
100
101
  process.stdout.write(JSON.stringify(filtered, null, 2) + "\n");
101
102
  }
102
- process.exit(0);
103
+ process.exitCode = 0;
103
104
  });
104
105
  return program2;
105
106
  }
@@ -284,6 +285,14 @@ var ELEMENT_CATALOG = {
284
285
  "box",
285
286
  "group",
286
287
  "table",
288
+ "row",
289
+ "cell",
290
+ "divider",
291
+ "text",
292
+ "label",
293
+ "image",
294
+ "icon",
295
+ "svgAsset",
287
296
  "connector",
288
297
  "alignConstraint",
289
298
  "equalizeWidth",
@@ -569,7 +578,7 @@ var ELEMENT_CATALOG = {
569
578
  "opacity",
570
579
  "variant"
571
580
  ],
572
- children: { kind: "list", items: ["label"] },
581
+ children: { kind: "list", items: ["label", "text"] },
573
582
  notes: "Child Labels are annotation text rendered at the connector midpoint. Label.textPosition is reserved (planned, not implemented)"
574
583
  },
575
584
  // ── constraint ────────────────────────────────────────────────────────
@@ -614,6 +623,10 @@ var ELEMENT_CATALOG = {
614
623
  notes: "targets array order is source order. axis: vertical = top-to-bottom, horizontal = left-to-right"
615
624
  }
616
625
  };
626
+ function hasOwnRect(kind) {
627
+ const category = ELEMENT_CATALOG[kind].category;
628
+ return category !== "connector" && category !== "constraint";
629
+ }
617
630
 
618
631
  // src/ir/index.ts
619
632
  import { z } from "zod";
@@ -3717,7 +3730,14 @@ function deepCloneAndSubstitute(node, paramValues, compiledChildren, diagnostics
3717
3730
  function expandComponent(def, paramValues, compiledChildren, diagnostics, extraProps, id, idIsParam) {
3718
3731
  const expanded = deepCloneAndSubstitute(def.template, paramValues, compiledChildren, diagnostics, def.name);
3719
3732
  Object.assign(expanded.props, extraProps);
3720
- if (id && !idIsParam) expanded.id = id;
3733
+ if (!idIsParam) {
3734
+ if (typeof id === "string" && id !== "") {
3735
+ expanded.id = id;
3736
+ delete expanded.props["__idParam"];
3737
+ } else if (isParamRef(id) || isTemplateRef(id) || isExprRef(id)) {
3738
+ expanded.props["__idParam"] = id;
3739
+ }
3740
+ }
3721
3741
  return expanded;
3722
3742
  }
3723
3743
  function componentDefToJSON(def) {
@@ -3827,12 +3847,22 @@ function buildResolvedProps(bind, def, target, diagnostics) {
3827
3847
  continue;
3828
3848
  }
3829
3849
  const value = resolvePropValue(prop, target, bind.component, bind.line, diagnostics);
3850
+ if (prop.param === "id") {
3851
+ if (value !== void 0 && value !== target.id) {
3852
+ diagnostics.push({
3853
+ level: "error",
3854
+ message: `bind <${bind.component}>: the 'id' param cannot be mapped to ${JSON.stringify(value)} \u2014 it is always the node id ('${target.id}').`,
3855
+ path: `line:${bind.line}`
3856
+ });
3857
+ }
3858
+ continue;
3859
+ }
3830
3860
  if (value !== void 0) {
3831
3861
  resolved[prop.param] = value;
3832
3862
  mapped.add(prop.param);
3833
3863
  }
3834
3864
  }
3835
- if (def.paramNames.has("id") && !mapped.has("id")) {
3865
+ if (def.paramNames.has("id")) {
3836
3866
  resolved.id = target.id;
3837
3867
  }
3838
3868
  if (def.paramNames.has("label") && !mapped.has("label")) {
@@ -4792,8 +4822,7 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4792
4822
  const ctx = {
4793
4823
  diagnostics,
4794
4824
  registry,
4795
- paramNames: pNames,
4796
- expandingStack: /* @__PURE__ */ new Set()
4825
+ paramNames: pNames
4797
4826
  };
4798
4827
  const template = compileElement(jsx, ctx);
4799
4828
  if (template) {
@@ -4822,8 +4851,7 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4822
4851
  const ctx = {
4823
4852
  diagnostics,
4824
4853
  registry,
4825
- paramNames: pNames,
4826
- expandingStack: /* @__PURE__ */ new Set()
4854
+ paramNames: pNames
4827
4855
  };
4828
4856
  const template = compileElement(jsx, ctx);
4829
4857
  if (template) {
@@ -4837,17 +4865,8 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4837
4865
  return defs;
4838
4866
  }
4839
4867
  function expandComponentTag(tagName, props, childNodes, ctx) {
4840
- if (ctx.expandingStack.has(tagName)) {
4841
- ctx.diagnostics.push({
4842
- level: "error",
4843
- message: `Circular component reference: ${tagName}`,
4844
- path: tagName
4845
- });
4846
- return null;
4847
- }
4848
4868
  const def = ctx.registry.get(tagName);
4849
4869
  if (!def) return null;
4850
- ctx.expandingStack.add(tagName);
4851
4870
  const compiledChildren = [];
4852
4871
  if (childNodes) {
4853
4872
  for (const child of childNodes) {
@@ -4880,7 +4899,6 @@ function expandComponentTag(tagName, props, childNodes, ctx) {
4880
4899
  id,
4881
4900
  idIsParam
4882
4901
  );
4883
- ctx.expandingStack.delete(tagName);
4884
4902
  return expanded;
4885
4903
  }
4886
4904
  function resolveImports(sourceFile, resolveImport, diagnostics, fromFile, fileCache) {
@@ -5134,8 +5152,7 @@ function compileDrawTsx(source, options) {
5134
5152
  }
5135
5153
  const ctx = {
5136
5154
  diagnostics,
5137
- registry,
5138
- expandingStack: /* @__PURE__ */ new Set()
5155
+ registry
5139
5156
  };
5140
5157
  const ir = compileElement(root, ctx);
5141
5158
  const compiledIr = ir ?? { kind: "document", props: {} };
@@ -5315,32 +5332,39 @@ function kindToPascal(kind) {
5315
5332
  function normalize(ir, options) {
5316
5333
  const diagnostics = [];
5317
5334
  const result = structuredClone(ir);
5318
- const kindCounters = /* @__PURE__ */ new Map();
5319
- assignAutoIds(result, kindCounters);
5320
- checkDuplicateIds(result, diagnostics);
5335
+ const explicitIds = /* @__PURE__ */ new Map();
5336
+ collectIds(result, explicitIds, "root");
5337
+ assignAutoIds(result, /* @__PURE__ */ new Map(), explicitIds);
5338
+ const idLocations = /* @__PURE__ */ new Map();
5339
+ collectIds(result, idLocations, "root");
5340
+ checkDuplicateIds(idLocations, diagnostics);
5341
+ validateChildren(result, diagnostics, "root");
5321
5342
  applyThemeAndVariants(result, options.theme);
5322
5343
  resolveAllTokens(result, options.tokens, diagnostics, "root");
5323
5344
  validateEnumProps(result, diagnostics, "root");
5324
5345
  validateRangeProps(result, diagnostics, "root");
5325
5346
  const geometryRegistry = buildGeometryRegistry(result, diagnostics);
5326
- resolveGeometryReferences(result, geometryRegistry, diagnostics);
5347
+ const referable = /* @__PURE__ */ new Map();
5348
+ collectReferable(result, true, referable);
5349
+ resolveGeometryReferences(result, geometryRegistry, referable, diagnostics);
5327
5350
  return { ir: result, diagnostics, geometryRegistry };
5328
5351
  }
5329
- function assignAutoIds(node, counters) {
5352
+ function assignAutoIds(node, counters, explicitIds) {
5330
5353
  if (!node.id) {
5331
- const count = (counters.get(node.kind) ?? 0) + 1;
5354
+ let count = counters.get(node.kind) ?? 0;
5355
+ do {
5356
+ count += 1;
5357
+ } while (explicitIds.has(`${node.kind}_${count}`));
5332
5358
  counters.set(node.kind, count);
5333
5359
  node.id = `${node.kind}_${count}`;
5334
5360
  }
5335
5361
  if (node.children) {
5336
5362
  for (const child of node.children) {
5337
- assignAutoIds(child, counters);
5363
+ assignAutoIds(child, counters, explicitIds);
5338
5364
  }
5339
5365
  }
5340
5366
  }
5341
- function checkDuplicateIds(root, diagnostics) {
5342
- const idLocations = /* @__PURE__ */ new Map();
5343
- collectIds(root, idLocations, "root");
5367
+ function checkDuplicateIds(idLocations, diagnostics) {
5344
5368
  for (const [id, paths] of idLocations) {
5345
5369
  if (paths.length > 1) {
5346
5370
  diagnostics.push({
@@ -5366,6 +5390,24 @@ function collectIds(node, idLocations, path) {
5366
5390
  }
5367
5391
  }
5368
5392
  }
5393
+ function validateChildren(node, diagnostics, path) {
5394
+ if (!node.children) return;
5395
+ const allowed = ELEMENT_CATALOG[node.kind].children;
5396
+ for (let i = 0; i < node.children.length; i++) {
5397
+ const child = node.children[i];
5398
+ const childPath = `${path}.children[${i}]`;
5399
+ const ok = allowed.kind === "any" || allowed.kind === "list" && allowed.items.includes(child.kind);
5400
+ if (!ok) {
5401
+ const expected = allowed.kind === "list" ? `allowed children: ${allowed.items.join(", ")}` : allowed.kind === "text" ? "it takes text content only" : "it takes no children";
5402
+ diagnostics.push({
5403
+ level: "error",
5404
+ message: `${kindToPascal(child.kind)} '${child.id}' cannot be placed inside ${kindToPascal(node.kind)} '${node.id}' \u2014 ${expected}`,
5405
+ path: childPath
5406
+ });
5407
+ }
5408
+ validateChildren(child, diagnostics, childPath);
5409
+ }
5410
+ }
5369
5411
  function applyThemeAndVariants(node, theme) {
5370
5412
  const pascalKind = kindToPascal(node.kind);
5371
5413
  const explicitKeys = new Set(Object.keys(node.props));
@@ -5525,6 +5567,13 @@ function collectGeometryProps(node, registry, diagnostics) {
5525
5567
  }
5526
5568
  }
5527
5569
  }
5570
+ function collectReferable(node, parentHasRect, out) {
5571
+ const ownRect = parentHasRect && hasOwnRect(node.kind);
5572
+ if (node.id) out.set(node.id, ownRect);
5573
+ if (node.children) {
5574
+ for (const child of node.children) collectReferable(child, ownRect, out);
5575
+ }
5576
+ }
5528
5577
  function parseGeometryRef(ref) {
5529
5578
  const colonIdx = ref.indexOf(":");
5530
5579
  if (colonIdx === -1) return { nodeId: ref };
@@ -5543,20 +5592,33 @@ function resolveWithRole(nodeId, role, registry) {
5543
5592
  }
5544
5593
  return current;
5545
5594
  }
5546
- function resolveGeometryRef(ref, implicitRole, registry) {
5547
- const { nodeId, role } = parseGeometryRef(ref);
5548
- const effectiveRole = role ?? implicitRole;
5549
- if (!effectiveRole) return nodeId;
5550
- return resolveWithRole(nodeId, effectiveRole, registry);
5551
- }
5552
- function resolveGeometryReferences(node, registry, diagnostics) {
5595
+ function resolveGeometryReferences(node, registry, referable, diagnostics) {
5553
5596
  const kind = node.kind;
5597
+ const report = (prop, message) => {
5598
+ diagnostics.push({
5599
+ level: "error",
5600
+ message: `${kindToPascal(kind)} '${node.id}': ${message}`,
5601
+ path: `${node.id}.props.${prop}`
5602
+ });
5603
+ };
5604
+ const resolveRef = (ref, implicitRole, prop) => {
5605
+ const { nodeId, role } = parseGeometryRef(ref);
5606
+ const effectiveRole = role ?? implicitRole;
5607
+ const resolved = effectiveRole ? resolveWithRole(nodeId, effectiveRole, registry) : nodeId;
5608
+ const ownRect = referable.get(resolved);
5609
+ if (ownRect === void 0) {
5610
+ report(prop, `${prop} "${ref}" refers to an element that does not exist ('${resolved}')`);
5611
+ } else if (!ownRect) {
5612
+ report(prop, `${prop} "${ref}" refers to an element without a rectangle of its own ('${resolved}' \u2014 a connector, a connector's label or a constraint)`);
5613
+ }
5614
+ return resolved;
5615
+ };
5554
5616
  if (kind === "alignConstraint") {
5555
5617
  const targets = node.props.targets;
5556
5618
  if (targets) {
5557
5619
  const alignRefs = {};
5558
5620
  for (const t of targets) {
5559
- const resolved = resolveGeometryRef(t, "align", registry);
5621
+ const resolved = resolveRef(t, "align", "targets");
5560
5622
  if (resolved !== t) alignRefs[t] = resolved;
5561
5623
  }
5562
5624
  if (Object.keys(alignRefs).length > 0) {
@@ -5565,39 +5627,41 @@ function resolveGeometryReferences(node, registry, diagnostics) {
5565
5627
  }
5566
5628
  const anchor = node.props.anchor;
5567
5629
  if (anchor) {
5568
- const resolved = resolveGeometryRef(anchor, "align", registry);
5630
+ const resolved = resolveRef(anchor, "align", "anchor");
5569
5631
  if (resolved !== anchor) {
5570
5632
  node.props.alignRefs = { ...node.props.alignRefs ?? {}, [anchor]: resolved };
5571
5633
  }
5572
5634
  }
5635
+ const mover = node.props.mover;
5636
+ if (mover) {
5637
+ resolveRef(mover, void 0, "mover");
5638
+ }
5573
5639
  }
5574
5640
  if (kind === "connector") {
5575
- const from = node.props.from;
5576
- if (from) {
5577
- node.props.from = resolveGeometryRef(from, "connect", registry);
5578
- }
5579
- const to = node.props.to;
5580
- if (to) {
5581
- node.props.to = resolveGeometryRef(to, "connect", registry);
5641
+ for (const prop of ["from", "to"]) {
5642
+ const ref = node.props[prop];
5643
+ if (ref) {
5644
+ node.props[prop] = resolveRef(ref, "connect", prop);
5645
+ } else {
5646
+ report(prop, `'${prop}' is required \u2014 a connector runs between two elements`);
5647
+ }
5582
5648
  }
5583
5649
  }
5584
5650
  if (kind === "equalizeWidth" || kind === "equalizeHeight" || kind === "minGap" || kind === "keepInsideConstraint" || kind === "orderConstraint") {
5585
5651
  const targets = node.props.targets;
5586
5652
  if (targets) {
5587
- node.props.targets = targets.map(
5588
- (t) => resolveGeometryRef(t, void 0, registry)
5589
- );
5653
+ node.props.targets = targets.map((t) => resolveRef(t, void 0, "targets"));
5590
5654
  }
5591
5655
  }
5592
5656
  if (node.children) {
5593
5657
  for (const child of node.children) {
5594
- resolveGeometryReferences(child, registry, diagnostics);
5658
+ resolveGeometryReferences(child, registry, referable, diagnostics);
5595
5659
  }
5596
5660
  }
5597
5661
  }
5598
5662
 
5599
5663
  // src/artifact/index.ts
5600
- var CONNECTOR_LABEL_KINDS = /* @__PURE__ */ new Set(["label", "text"]);
5664
+ var CONNECTOR_LABEL_KINDS = new Set(ELEMENT_CATALOG.connector.children.items);
5601
5665
  function isConnectorLabelKind(kind) {
5602
5666
  return CONNECTOR_LABEL_KINDS.has(kind);
5603
5667
  }
@@ -5669,10 +5733,14 @@ function getDynamicMarkerDefs() {
5669
5733
  if (dynamicMarkerRegistry.size === 0) return "";
5670
5734
  return Array.from(dynamicMarkerRegistry.values()).join("\n");
5671
5735
  }
5736
+ function colorKey(color) {
5737
+ if (/^#[0-9a-fA-F]+$/.test(color)) return color.slice(1);
5738
+ if (/^[0-9a-zA-Z]+$/.test(color) && /[g-zG-Z]/.test(color)) return color;
5739
+ return "_" + color.replace(/[^a-zA-Z0-9]/g, (c) => `_${c.charCodeAt(0).toString(16)}_`);
5740
+ }
5672
5741
  function ensureColoredMarker(arrowType, arrowSize, color) {
5673
- const colorKey = color.replace(/[^a-zA-Z0-9]/g, "");
5674
5742
  const sizeKey = arrowSize === 1 ? "" : `-s${arrowSize}`;
5675
- const id = `marker-${arrowType}-${colorKey}${sizeKey}`;
5743
+ const id = `marker-${arrowType}-${colorKey(color)}${sizeKey}`;
5676
5744
  if (!dynamicMarkerRegistry.has(id)) {
5677
5745
  const template = MARKER_TEMPLATES.find((t) => t.type === arrowType);
5678
5746
  if (template) {
@@ -5845,9 +5913,6 @@ function renderNode(node) {
5845
5913
  }
5846
5914
  if (node.children) {
5847
5915
  for (const child of node.children) {
5848
- if (node.kind === "row" && child.kind === "cell" && node.styles.fill != null && child.styles.fill == null) {
5849
- child.styles.fill = node.styles.fill;
5850
- }
5851
5916
  const childSvg = renderNode(child);
5852
5917
  if (childSvg) parts.push(childSvg);
5853
5918
  }
@@ -6828,7 +6893,11 @@ function buildResolvedNode(graph, ir, parentWorldX, parentWorldY, diagnostics) {
6828
6893
  const children = [];
6829
6894
  for (const child of ir.children) {
6830
6895
  const childNode = buildResolvedNode(graph, child, worldRect.x, worldRect.y, diagnostics);
6831
- if (childNode) children.push(childNode);
6896
+ if (!childNode) continue;
6897
+ if (kind === "row" && childNode.kind === "cell" && styles.fill != null && childNode.styles.fill == null) {
6898
+ childNode.styles.fill = styles.fill;
6899
+ }
6900
+ children.push(childNode);
6832
6901
  }
6833
6902
  if (children.length > 0) {
6834
6903
  resolved.children = children;
@@ -6844,10 +6913,10 @@ var CONNECTOR_DEFAULTS = {
6844
6913
  };
6845
6914
  function fixConnectorPaths(nodes, _graph, ir) {
6846
6915
  const worldRectMap = /* @__PURE__ */ new Map();
6847
- collectWorldRects(nodes, worldRectMap);
6916
+ const connectors = [];
6917
+ collectWorldRects(nodes, worldRectMap, connectors);
6848
6918
  const connectorInfos = [];
6849
- for (const node of nodes) {
6850
- if (node.kind !== "connector") continue;
6919
+ for (const node of connectors) {
6851
6920
  const irNode = findIrNode(ir, node.id);
6852
6921
  if (!irNode) continue;
6853
6922
  const fromId = irNode.props.from;
@@ -6877,32 +6946,32 @@ function fixConnectorPaths(nodes, _graph, ir) {
6877
6946
  }
6878
6947
  const endpointPositions = /* @__PURE__ */ new Map();
6879
6948
  const edgeGroups = /* @__PURE__ */ new Map();
6880
- for (const info of connectorInfos) {
6881
- if (info.fromT !== void 0) {
6882
- const rect = worldRectMap.get(info.fromId);
6883
- endpointPositions.set(`${info.node.id}:from`, edgePoint(rect, info.fromEdge, info.fromT));
6949
+ for (const info2 of connectorInfos) {
6950
+ if (info2.fromT !== void 0) {
6951
+ const rect = worldRectMap.get(info2.fromId);
6952
+ endpointPositions.set(`${info2.node.id}:from`, edgePoint(rect, info2.fromEdge, info2.fromT));
6884
6953
  } else {
6885
- const fromKey = `${info.fromId}:${info.fromEdge}`;
6954
+ const fromKey = `${info2.fromId}:${info2.fromEdge}`;
6886
6955
  if (!edgeGroups.has(fromKey)) edgeGroups.set(fromKey, []);
6887
6956
  edgeGroups.get(fromKey).push({
6888
- nodeId: info.fromId,
6889
- edge: info.fromEdge,
6890
- anchor: info.fromAnchor,
6891
- connectorId: info.node.id,
6957
+ nodeId: info2.fromId,
6958
+ edge: info2.fromEdge,
6959
+ anchor: info2.fromAnchor,
6960
+ connectorId: info2.node.id,
6892
6961
  role: "from"
6893
6962
  });
6894
6963
  }
6895
- if (info.toT !== void 0) {
6896
- const rect = worldRectMap.get(info.toId);
6897
- endpointPositions.set(`${info.node.id}:to`, edgePoint(rect, info.toEdge, info.toT));
6964
+ if (info2.toT !== void 0) {
6965
+ const rect = worldRectMap.get(info2.toId);
6966
+ endpointPositions.set(`${info2.node.id}:to`, edgePoint(rect, info2.toEdge, info2.toT));
6898
6967
  } else {
6899
- const toKey = `${info.toId}:${info.toEdge}`;
6968
+ const toKey = `${info2.toId}:${info2.toEdge}`;
6900
6969
  if (!edgeGroups.has(toKey)) edgeGroups.set(toKey, []);
6901
6970
  edgeGroups.get(toKey).push({
6902
- nodeId: info.toId,
6903
- edge: info.toEdge,
6904
- anchor: info.toAnchor,
6905
- connectorId: info.node.id,
6971
+ nodeId: info2.toId,
6972
+ edge: info2.toEdge,
6973
+ anchor: info2.toAnchor,
6974
+ connectorId: info2.node.id,
6906
6975
  role: "to"
6907
6976
  });
6908
6977
  }
@@ -6930,20 +6999,20 @@ function fixConnectorPaths(nodes, _graph, ir) {
6930
6999
  endpointPositions.set(posKey, pos);
6931
7000
  }
6932
7001
  }
6933
- for (const info of connectorInfos) {
6934
- const from = endpointPositions.get(`${info.node.id}:from`);
6935
- const to = endpointPositions.get(`${info.node.id}:to`);
6936
- const route = info.irNode.props.route ?? CONNECTOR_DEFAULTS.route;
7002
+ for (const info2 of connectorInfos) {
7003
+ const from = endpointPositions.get(`${info2.node.id}:from`);
7004
+ const to = endpointPositions.get(`${info2.node.id}:to`);
7005
+ const route = info2.irNode.props.route ?? CONNECTOR_DEFAULTS.route;
6937
7006
  if (route === "orthogonal") {
6938
- const cr = Number(info.irNode.props.cornerRadius ?? CONNECTOR_DEFAULTS.cornerRadius);
6939
- info.node.connectorPath = buildOrthogonalPath(from, to, info.fromEdge, info.toEdge, cr, worldRectMap.get(info.fromId), worldRectMap.get(info.toId));
7007
+ const cr = Number(info2.irNode.props.cornerRadius ?? CONNECTOR_DEFAULTS.cornerRadius);
7008
+ info2.node.connectorPath = buildOrthogonalPath(from, to, info2.fromEdge, info2.toEdge, cr, worldRectMap.get(info2.fromId), worldRectMap.get(info2.toId));
6940
7009
  } else if (route === "curved") {
6941
- const curvature = Number(info.irNode.props.curvature ?? CONNECTOR_DEFAULTS.curvature);
6942
- info.node.connectorPath = buildCurvedPath(from, to, info.fromEdge, info.toEdge, curvature);
7010
+ const curvature = Number(info2.irNode.props.curvature ?? CONNECTOR_DEFAULTS.curvature);
7011
+ info2.node.connectorPath = buildCurvedPath(from, to, info2.fromEdge, info2.toEdge, curvature);
6943
7012
  } else {
6944
- info.node.connectorPath = `M ${from.x} ${from.y} L ${to.x} ${to.y}`;
7013
+ info2.node.connectorPath = `M ${from.x} ${from.y} L ${to.x} ${to.y}`;
6945
7014
  }
6946
- positionConnectorLabels(info.node, from, to);
7015
+ positionConnectorLabels(info2.node, from, to);
6947
7016
  }
6948
7017
  }
6949
7018
  function positionConnectorLabels(connector, from, to) {
@@ -7127,11 +7196,12 @@ function edgePoint(rect, edge, t) {
7127
7196
  return { x: rect.x + rect.width, y: rect.y + rect.height * t };
7128
7197
  }
7129
7198
  }
7130
- function collectWorldRects(nodes, map) {
7199
+ function collectWorldRects(nodes, map, connectors) {
7131
7200
  for (const node of nodes) {
7132
7201
  map.set(node.id, node.worldRect);
7202
+ if (node.kind === "connector") connectors.push(node);
7133
7203
  if (node.children) {
7134
- collectWorldRects(node.children, map);
7204
+ collectWorldRects(node.children, map, connectors);
7135
7205
  }
7136
7206
  }
7137
7207
  }
@@ -7631,6 +7701,10 @@ ${payload}`, void 0);
7631
7701
  return void process.exit(2);
7632
7702
  }
7633
7703
  }
7704
+ function layoutReportingDiagnostics(ir, tokens, theme) {
7705
+ const { artifact, diagnostics } = layout(ir, { tokens, theme });
7706
+ return reportDiagnostics(diagnostics) ? void 0 : artifact;
7707
+ }
7634
7708
  function renderSource(raw, baseDir, options) {
7635
7709
  const emit = options.emit ?? "svg";
7636
7710
  let config = {};
@@ -7729,8 +7803,8 @@ function renderSource(raw, baseDir, options) {
7729
7803
  const registry = buildCliIconRegistry(config.icons, baseDir);
7730
7804
  let svg;
7731
7805
  try {
7732
- const { artifact, diagnostics } = layout(ir, { tokens, theme });
7733
- if (reportDiagnostics(diagnostics)) {
7806
+ const artifact = layoutReportingDiagnostics(ir, tokens, theme);
7807
+ if (!artifact) {
7734
7808
  return { ok: false, code: 1 };
7735
7809
  }
7736
7810
  svg = renderSvg(artifact, { iconRegistry: registry });
@@ -7905,7 +7979,10 @@ async function handleValidate(input, _options, _parentOpts) {
7905
7979
  return void process.exit(2);
7906
7980
  }
7907
7981
  try {
7908
- parseIr(JSON.parse(raw));
7982
+ const ir = parseIr(JSON.parse(raw));
7983
+ if (!layoutReportingDiagnostics(ir, defaultTokens(), defaultTheme())) {
7984
+ return void process.exit(1);
7985
+ }
7909
7986
  } catch (e) {
7910
7987
  process.stderr.write(`Validation error: ${e.message}
7911
7988
  `);
@@ -8126,7 +8203,8 @@ var handlers = {
8126
8203
  componentsBuild: handleComponentsBuild,
8127
8204
  iconsExport: handleIconsExport
8128
8205
  };
8129
- var program = createProgram(handlers, "0.1.0");
8206
+ var { info } = JSON.parse(CONTRACT_JSON_STR);
8207
+ var program = createProgram(handlers, info.version);
8130
8208
  var renderCmd = program.commands.find((c) => c.name() === "render");
8131
8209
  if (renderCmd) {
8132
8210
  renderCmd.option(