diagram-contracts 0.2.6 → 0.2.7

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.7\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.7",\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) {
@@ -284,6 +284,14 @@ var ELEMENT_CATALOG = {
284
284
  "box",
285
285
  "group",
286
286
  "table",
287
+ "row",
288
+ "cell",
289
+ "divider",
290
+ "text",
291
+ "label",
292
+ "image",
293
+ "icon",
294
+ "svgAsset",
287
295
  "connector",
288
296
  "alignConstraint",
289
297
  "equalizeWidth",
@@ -569,7 +577,7 @@ var ELEMENT_CATALOG = {
569
577
  "opacity",
570
578
  "variant"
571
579
  ],
572
- children: { kind: "list", items: ["label"] },
580
+ children: { kind: "list", items: ["label", "text"] },
573
581
  notes: "Child Labels are annotation text rendered at the connector midpoint. Label.textPosition is reserved (planned, not implemented)"
574
582
  },
575
583
  // ── constraint ────────────────────────────────────────────────────────
@@ -614,6 +622,10 @@ var ELEMENT_CATALOG = {
614
622
  notes: "targets array order is source order. axis: vertical = top-to-bottom, horizontal = left-to-right"
615
623
  }
616
624
  };
625
+ function hasOwnRect(kind) {
626
+ const category = ELEMENT_CATALOG[kind].category;
627
+ return category !== "connector" && category !== "constraint";
628
+ }
617
629
 
618
630
  // src/ir/index.ts
619
631
  import { z } from "zod";
@@ -3717,7 +3729,14 @@ function deepCloneAndSubstitute(node, paramValues, compiledChildren, diagnostics
3717
3729
  function expandComponent(def, paramValues, compiledChildren, diagnostics, extraProps, id, idIsParam) {
3718
3730
  const expanded = deepCloneAndSubstitute(def.template, paramValues, compiledChildren, diagnostics, def.name);
3719
3731
  Object.assign(expanded.props, extraProps);
3720
- if (id && !idIsParam) expanded.id = id;
3732
+ if (!idIsParam) {
3733
+ if (typeof id === "string" && id !== "") {
3734
+ expanded.id = id;
3735
+ delete expanded.props["__idParam"];
3736
+ } else if (isParamRef(id) || isTemplateRef(id) || isExprRef(id)) {
3737
+ expanded.props["__idParam"] = id;
3738
+ }
3739
+ }
3721
3740
  return expanded;
3722
3741
  }
3723
3742
  function componentDefToJSON(def) {
@@ -3827,12 +3846,22 @@ function buildResolvedProps(bind, def, target, diagnostics) {
3827
3846
  continue;
3828
3847
  }
3829
3848
  const value = resolvePropValue(prop, target, bind.component, bind.line, diagnostics);
3849
+ if (prop.param === "id") {
3850
+ if (value !== void 0 && value !== target.id) {
3851
+ diagnostics.push({
3852
+ level: "error",
3853
+ message: `bind <${bind.component}>: the 'id' param cannot be mapped to ${JSON.stringify(value)} \u2014 it is always the node id ('${target.id}').`,
3854
+ path: `line:${bind.line}`
3855
+ });
3856
+ }
3857
+ continue;
3858
+ }
3830
3859
  if (value !== void 0) {
3831
3860
  resolved[prop.param] = value;
3832
3861
  mapped.add(prop.param);
3833
3862
  }
3834
3863
  }
3835
- if (def.paramNames.has("id") && !mapped.has("id")) {
3864
+ if (def.paramNames.has("id")) {
3836
3865
  resolved.id = target.id;
3837
3866
  }
3838
3867
  if (def.paramNames.has("label") && !mapped.has("label")) {
@@ -4792,8 +4821,7 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4792
4821
  const ctx = {
4793
4822
  diagnostics,
4794
4823
  registry,
4795
- paramNames: pNames,
4796
- expandingStack: /* @__PURE__ */ new Set()
4824
+ paramNames: pNames
4797
4825
  };
4798
4826
  const template = compileElement(jsx, ctx);
4799
4827
  if (template) {
@@ -4822,8 +4850,7 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4822
4850
  const ctx = {
4823
4851
  diagnostics,
4824
4852
  registry,
4825
- paramNames: pNames,
4826
- expandingStack: /* @__PURE__ */ new Set()
4853
+ paramNames: pNames
4827
4854
  };
4828
4855
  const template = compileElement(jsx, ctx);
4829
4856
  if (template) {
@@ -4837,17 +4864,8 @@ function extractComponentDefs(sourceFile, diagnostics, knownComponents) {
4837
4864
  return defs;
4838
4865
  }
4839
4866
  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
4867
  const def = ctx.registry.get(tagName);
4849
4868
  if (!def) return null;
4850
- ctx.expandingStack.add(tagName);
4851
4869
  const compiledChildren = [];
4852
4870
  if (childNodes) {
4853
4871
  for (const child of childNodes) {
@@ -4880,7 +4898,6 @@ function expandComponentTag(tagName, props, childNodes, ctx) {
4880
4898
  id,
4881
4899
  idIsParam
4882
4900
  );
4883
- ctx.expandingStack.delete(tagName);
4884
4901
  return expanded;
4885
4902
  }
4886
4903
  function resolveImports(sourceFile, resolveImport, diagnostics, fromFile, fileCache) {
@@ -5134,8 +5151,7 @@ function compileDrawTsx(source, options) {
5134
5151
  }
5135
5152
  const ctx = {
5136
5153
  diagnostics,
5137
- registry,
5138
- expandingStack: /* @__PURE__ */ new Set()
5154
+ registry
5139
5155
  };
5140
5156
  const ir = compileElement(root, ctx);
5141
5157
  const compiledIr = ir ?? { kind: "document", props: {} };
@@ -5315,32 +5331,39 @@ function kindToPascal(kind) {
5315
5331
  function normalize(ir, options) {
5316
5332
  const diagnostics = [];
5317
5333
  const result = structuredClone(ir);
5318
- const kindCounters = /* @__PURE__ */ new Map();
5319
- assignAutoIds(result, kindCounters);
5320
- checkDuplicateIds(result, diagnostics);
5334
+ const explicitIds = /* @__PURE__ */ new Map();
5335
+ collectIds(result, explicitIds, "root");
5336
+ assignAutoIds(result, /* @__PURE__ */ new Map(), explicitIds);
5337
+ const idLocations = /* @__PURE__ */ new Map();
5338
+ collectIds(result, idLocations, "root");
5339
+ checkDuplicateIds(idLocations, diagnostics);
5340
+ validateChildren(result, diagnostics, "root");
5321
5341
  applyThemeAndVariants(result, options.theme);
5322
5342
  resolveAllTokens(result, options.tokens, diagnostics, "root");
5323
5343
  validateEnumProps(result, diagnostics, "root");
5324
5344
  validateRangeProps(result, diagnostics, "root");
5325
5345
  const geometryRegistry = buildGeometryRegistry(result, diagnostics);
5326
- resolveGeometryReferences(result, geometryRegistry, diagnostics);
5346
+ const referable = /* @__PURE__ */ new Map();
5347
+ collectReferable(result, true, referable);
5348
+ resolveGeometryReferences(result, geometryRegistry, referable, diagnostics);
5327
5349
  return { ir: result, diagnostics, geometryRegistry };
5328
5350
  }
5329
- function assignAutoIds(node, counters) {
5351
+ function assignAutoIds(node, counters, explicitIds) {
5330
5352
  if (!node.id) {
5331
- const count = (counters.get(node.kind) ?? 0) + 1;
5353
+ let count = counters.get(node.kind) ?? 0;
5354
+ do {
5355
+ count += 1;
5356
+ } while (explicitIds.has(`${node.kind}_${count}`));
5332
5357
  counters.set(node.kind, count);
5333
5358
  node.id = `${node.kind}_${count}`;
5334
5359
  }
5335
5360
  if (node.children) {
5336
5361
  for (const child of node.children) {
5337
- assignAutoIds(child, counters);
5362
+ assignAutoIds(child, counters, explicitIds);
5338
5363
  }
5339
5364
  }
5340
5365
  }
5341
- function checkDuplicateIds(root, diagnostics) {
5342
- const idLocations = /* @__PURE__ */ new Map();
5343
- collectIds(root, idLocations, "root");
5366
+ function checkDuplicateIds(idLocations, diagnostics) {
5344
5367
  for (const [id, paths] of idLocations) {
5345
5368
  if (paths.length > 1) {
5346
5369
  diagnostics.push({
@@ -5366,6 +5389,24 @@ function collectIds(node, idLocations, path) {
5366
5389
  }
5367
5390
  }
5368
5391
  }
5392
+ function validateChildren(node, diagnostics, path) {
5393
+ if (!node.children) return;
5394
+ const allowed = ELEMENT_CATALOG[node.kind].children;
5395
+ for (let i = 0; i < node.children.length; i++) {
5396
+ const child = node.children[i];
5397
+ const childPath = `${path}.children[${i}]`;
5398
+ const ok = allowed.kind === "any" || allowed.kind === "list" && allowed.items.includes(child.kind);
5399
+ if (!ok) {
5400
+ const expected = allowed.kind === "list" ? `allowed children: ${allowed.items.join(", ")}` : allowed.kind === "text" ? "it takes text content only" : "it takes no children";
5401
+ diagnostics.push({
5402
+ level: "error",
5403
+ message: `${kindToPascal(child.kind)} '${child.id}' cannot be placed inside ${kindToPascal(node.kind)} '${node.id}' \u2014 ${expected}`,
5404
+ path: childPath
5405
+ });
5406
+ }
5407
+ validateChildren(child, diagnostics, childPath);
5408
+ }
5409
+ }
5369
5410
  function applyThemeAndVariants(node, theme) {
5370
5411
  const pascalKind = kindToPascal(node.kind);
5371
5412
  const explicitKeys = new Set(Object.keys(node.props));
@@ -5525,6 +5566,13 @@ function collectGeometryProps(node, registry, diagnostics) {
5525
5566
  }
5526
5567
  }
5527
5568
  }
5569
+ function collectReferable(node, parentHasRect, out) {
5570
+ const ownRect = parentHasRect && hasOwnRect(node.kind);
5571
+ if (node.id) out.set(node.id, ownRect);
5572
+ if (node.children) {
5573
+ for (const child of node.children) collectReferable(child, ownRect, out);
5574
+ }
5575
+ }
5528
5576
  function parseGeometryRef(ref) {
5529
5577
  const colonIdx = ref.indexOf(":");
5530
5578
  if (colonIdx === -1) return { nodeId: ref };
@@ -5543,20 +5591,33 @@ function resolveWithRole(nodeId, role, registry) {
5543
5591
  }
5544
5592
  return current;
5545
5593
  }
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) {
5594
+ function resolveGeometryReferences(node, registry, referable, diagnostics) {
5553
5595
  const kind = node.kind;
5596
+ const report = (prop, message) => {
5597
+ diagnostics.push({
5598
+ level: "error",
5599
+ message: `${kindToPascal(kind)} '${node.id}': ${message}`,
5600
+ path: `${node.id}.props.${prop}`
5601
+ });
5602
+ };
5603
+ const resolveRef = (ref, implicitRole, prop) => {
5604
+ const { nodeId, role } = parseGeometryRef(ref);
5605
+ const effectiveRole = role ?? implicitRole;
5606
+ const resolved = effectiveRole ? resolveWithRole(nodeId, effectiveRole, registry) : nodeId;
5607
+ const ownRect = referable.get(resolved);
5608
+ if (ownRect === void 0) {
5609
+ report(prop, `${prop} "${ref}" refers to an element that does not exist ('${resolved}')`);
5610
+ } else if (!ownRect) {
5611
+ 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)`);
5612
+ }
5613
+ return resolved;
5614
+ };
5554
5615
  if (kind === "alignConstraint") {
5555
5616
  const targets = node.props.targets;
5556
5617
  if (targets) {
5557
5618
  const alignRefs = {};
5558
5619
  for (const t of targets) {
5559
- const resolved = resolveGeometryRef(t, "align", registry);
5620
+ const resolved = resolveRef(t, "align", "targets");
5560
5621
  if (resolved !== t) alignRefs[t] = resolved;
5561
5622
  }
5562
5623
  if (Object.keys(alignRefs).length > 0) {
@@ -5565,39 +5626,41 @@ function resolveGeometryReferences(node, registry, diagnostics) {
5565
5626
  }
5566
5627
  const anchor = node.props.anchor;
5567
5628
  if (anchor) {
5568
- const resolved = resolveGeometryRef(anchor, "align", registry);
5629
+ const resolved = resolveRef(anchor, "align", "anchor");
5569
5630
  if (resolved !== anchor) {
5570
5631
  node.props.alignRefs = { ...node.props.alignRefs ?? {}, [anchor]: resolved };
5571
5632
  }
5572
5633
  }
5634
+ const mover = node.props.mover;
5635
+ if (mover) {
5636
+ resolveRef(mover, void 0, "mover");
5637
+ }
5573
5638
  }
5574
5639
  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);
5640
+ for (const prop of ["from", "to"]) {
5641
+ const ref = node.props[prop];
5642
+ if (ref) {
5643
+ node.props[prop] = resolveRef(ref, "connect", prop);
5644
+ } else {
5645
+ report(prop, `'${prop}' is required \u2014 a connector runs between two elements`);
5646
+ }
5582
5647
  }
5583
5648
  }
5584
5649
  if (kind === "equalizeWidth" || kind === "equalizeHeight" || kind === "minGap" || kind === "keepInsideConstraint" || kind === "orderConstraint") {
5585
5650
  const targets = node.props.targets;
5586
5651
  if (targets) {
5587
- node.props.targets = targets.map(
5588
- (t) => resolveGeometryRef(t, void 0, registry)
5589
- );
5652
+ node.props.targets = targets.map((t) => resolveRef(t, void 0, "targets"));
5590
5653
  }
5591
5654
  }
5592
5655
  if (node.children) {
5593
5656
  for (const child of node.children) {
5594
- resolveGeometryReferences(child, registry, diagnostics);
5657
+ resolveGeometryReferences(child, registry, referable, diagnostics);
5595
5658
  }
5596
5659
  }
5597
5660
  }
5598
5661
 
5599
5662
  // src/artifact/index.ts
5600
- var CONNECTOR_LABEL_KINDS = /* @__PURE__ */ new Set(["label", "text"]);
5663
+ var CONNECTOR_LABEL_KINDS = new Set(ELEMENT_CATALOG.connector.children.items);
5601
5664
  function isConnectorLabelKind(kind) {
5602
5665
  return CONNECTOR_LABEL_KINDS.has(kind);
5603
5666
  }
@@ -5669,10 +5732,14 @@ function getDynamicMarkerDefs() {
5669
5732
  if (dynamicMarkerRegistry.size === 0) return "";
5670
5733
  return Array.from(dynamicMarkerRegistry.values()).join("\n");
5671
5734
  }
5735
+ function colorKey(color) {
5736
+ if (/^#[0-9a-fA-F]+$/.test(color)) return color.slice(1);
5737
+ if (/^[0-9a-zA-Z]+$/.test(color) && /[g-zG-Z]/.test(color)) return color;
5738
+ return "_" + color.replace(/[^a-zA-Z0-9]/g, (c) => `_${c.charCodeAt(0).toString(16)}_`);
5739
+ }
5672
5740
  function ensureColoredMarker(arrowType, arrowSize, color) {
5673
- const colorKey = color.replace(/[^a-zA-Z0-9]/g, "");
5674
5741
  const sizeKey = arrowSize === 1 ? "" : `-s${arrowSize}`;
5675
- const id = `marker-${arrowType}-${colorKey}${sizeKey}`;
5742
+ const id = `marker-${arrowType}-${colorKey(color)}${sizeKey}`;
5676
5743
  if (!dynamicMarkerRegistry.has(id)) {
5677
5744
  const template = MARKER_TEMPLATES.find((t) => t.type === arrowType);
5678
5745
  if (template) {
@@ -5845,9 +5912,6 @@ function renderNode(node) {
5845
5912
  }
5846
5913
  if (node.children) {
5847
5914
  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
5915
  const childSvg = renderNode(child);
5852
5916
  if (childSvg) parts.push(childSvg);
5853
5917
  }
@@ -6828,7 +6892,11 @@ function buildResolvedNode(graph, ir, parentWorldX, parentWorldY, diagnostics) {
6828
6892
  const children = [];
6829
6893
  for (const child of ir.children) {
6830
6894
  const childNode = buildResolvedNode(graph, child, worldRect.x, worldRect.y, diagnostics);
6831
- if (childNode) children.push(childNode);
6895
+ if (!childNode) continue;
6896
+ if (kind === "row" && childNode.kind === "cell" && styles.fill != null && childNode.styles.fill == null) {
6897
+ childNode.styles.fill = styles.fill;
6898
+ }
6899
+ children.push(childNode);
6832
6900
  }
6833
6901
  if (children.length > 0) {
6834
6902
  resolved.children = children;
@@ -6844,10 +6912,10 @@ var CONNECTOR_DEFAULTS = {
6844
6912
  };
6845
6913
  function fixConnectorPaths(nodes, _graph, ir) {
6846
6914
  const worldRectMap = /* @__PURE__ */ new Map();
6847
- collectWorldRects(nodes, worldRectMap);
6915
+ const connectors = [];
6916
+ collectWorldRects(nodes, worldRectMap, connectors);
6848
6917
  const connectorInfos = [];
6849
- for (const node of nodes) {
6850
- if (node.kind !== "connector") continue;
6918
+ for (const node of connectors) {
6851
6919
  const irNode = findIrNode(ir, node.id);
6852
6920
  if (!irNode) continue;
6853
6921
  const fromId = irNode.props.from;
@@ -6877,32 +6945,32 @@ function fixConnectorPaths(nodes, _graph, ir) {
6877
6945
  }
6878
6946
  const endpointPositions = /* @__PURE__ */ new Map();
6879
6947
  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));
6948
+ for (const info2 of connectorInfos) {
6949
+ if (info2.fromT !== void 0) {
6950
+ const rect = worldRectMap.get(info2.fromId);
6951
+ endpointPositions.set(`${info2.node.id}:from`, edgePoint(rect, info2.fromEdge, info2.fromT));
6884
6952
  } else {
6885
- const fromKey = `${info.fromId}:${info.fromEdge}`;
6953
+ const fromKey = `${info2.fromId}:${info2.fromEdge}`;
6886
6954
  if (!edgeGroups.has(fromKey)) edgeGroups.set(fromKey, []);
6887
6955
  edgeGroups.get(fromKey).push({
6888
- nodeId: info.fromId,
6889
- edge: info.fromEdge,
6890
- anchor: info.fromAnchor,
6891
- connectorId: info.node.id,
6956
+ nodeId: info2.fromId,
6957
+ edge: info2.fromEdge,
6958
+ anchor: info2.fromAnchor,
6959
+ connectorId: info2.node.id,
6892
6960
  role: "from"
6893
6961
  });
6894
6962
  }
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));
6963
+ if (info2.toT !== void 0) {
6964
+ const rect = worldRectMap.get(info2.toId);
6965
+ endpointPositions.set(`${info2.node.id}:to`, edgePoint(rect, info2.toEdge, info2.toT));
6898
6966
  } else {
6899
- const toKey = `${info.toId}:${info.toEdge}`;
6967
+ const toKey = `${info2.toId}:${info2.toEdge}`;
6900
6968
  if (!edgeGroups.has(toKey)) edgeGroups.set(toKey, []);
6901
6969
  edgeGroups.get(toKey).push({
6902
- nodeId: info.toId,
6903
- edge: info.toEdge,
6904
- anchor: info.toAnchor,
6905
- connectorId: info.node.id,
6970
+ nodeId: info2.toId,
6971
+ edge: info2.toEdge,
6972
+ anchor: info2.toAnchor,
6973
+ connectorId: info2.node.id,
6906
6974
  role: "to"
6907
6975
  });
6908
6976
  }
@@ -6930,20 +6998,20 @@ function fixConnectorPaths(nodes, _graph, ir) {
6930
6998
  endpointPositions.set(posKey, pos);
6931
6999
  }
6932
7000
  }
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;
7001
+ for (const info2 of connectorInfos) {
7002
+ const from = endpointPositions.get(`${info2.node.id}:from`);
7003
+ const to = endpointPositions.get(`${info2.node.id}:to`);
7004
+ const route = info2.irNode.props.route ?? CONNECTOR_DEFAULTS.route;
6937
7005
  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));
7006
+ const cr = Number(info2.irNode.props.cornerRadius ?? CONNECTOR_DEFAULTS.cornerRadius);
7007
+ info2.node.connectorPath = buildOrthogonalPath(from, to, info2.fromEdge, info2.toEdge, cr, worldRectMap.get(info2.fromId), worldRectMap.get(info2.toId));
6940
7008
  } 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);
7009
+ const curvature = Number(info2.irNode.props.curvature ?? CONNECTOR_DEFAULTS.curvature);
7010
+ info2.node.connectorPath = buildCurvedPath(from, to, info2.fromEdge, info2.toEdge, curvature);
6943
7011
  } else {
6944
- info.node.connectorPath = `M ${from.x} ${from.y} L ${to.x} ${to.y}`;
7012
+ info2.node.connectorPath = `M ${from.x} ${from.y} L ${to.x} ${to.y}`;
6945
7013
  }
6946
- positionConnectorLabels(info.node, from, to);
7014
+ positionConnectorLabels(info2.node, from, to);
6947
7015
  }
6948
7016
  }
6949
7017
  function positionConnectorLabels(connector, from, to) {
@@ -7127,11 +7195,12 @@ function edgePoint(rect, edge, t) {
7127
7195
  return { x: rect.x + rect.width, y: rect.y + rect.height * t };
7128
7196
  }
7129
7197
  }
7130
- function collectWorldRects(nodes, map) {
7198
+ function collectWorldRects(nodes, map, connectors) {
7131
7199
  for (const node of nodes) {
7132
7200
  map.set(node.id, node.worldRect);
7201
+ if (node.kind === "connector") connectors.push(node);
7133
7202
  if (node.children) {
7134
- collectWorldRects(node.children, map);
7203
+ collectWorldRects(node.children, map, connectors);
7135
7204
  }
7136
7205
  }
7137
7206
  }
@@ -7631,6 +7700,10 @@ ${payload}`, void 0);
7631
7700
  return void process.exit(2);
7632
7701
  }
7633
7702
  }
7703
+ function layoutReportingDiagnostics(ir, tokens, theme) {
7704
+ const { artifact, diagnostics } = layout(ir, { tokens, theme });
7705
+ return reportDiagnostics(diagnostics) ? void 0 : artifact;
7706
+ }
7634
7707
  function renderSource(raw, baseDir, options) {
7635
7708
  const emit = options.emit ?? "svg";
7636
7709
  let config = {};
@@ -7729,8 +7802,8 @@ function renderSource(raw, baseDir, options) {
7729
7802
  const registry = buildCliIconRegistry(config.icons, baseDir);
7730
7803
  let svg;
7731
7804
  try {
7732
- const { artifact, diagnostics } = layout(ir, { tokens, theme });
7733
- if (reportDiagnostics(diagnostics)) {
7805
+ const artifact = layoutReportingDiagnostics(ir, tokens, theme);
7806
+ if (!artifact) {
7734
7807
  return { ok: false, code: 1 };
7735
7808
  }
7736
7809
  svg = renderSvg(artifact, { iconRegistry: registry });
@@ -7905,7 +7978,10 @@ async function handleValidate(input, _options, _parentOpts) {
7905
7978
  return void process.exit(2);
7906
7979
  }
7907
7980
  try {
7908
- parseIr(JSON.parse(raw));
7981
+ const ir = parseIr(JSON.parse(raw));
7982
+ if (!layoutReportingDiagnostics(ir, defaultTokens(), defaultTheme())) {
7983
+ return void process.exit(1);
7984
+ }
7909
7985
  } catch (e) {
7910
7986
  process.stderr.write(`Validation error: ${e.message}
7911
7987
  `);
@@ -8126,7 +8202,8 @@ var handlers = {
8126
8202
  componentsBuild: handleComponentsBuild,
8127
8203
  iconsExport: handleIconsExport
8128
8204
  };
8129
- var program = createProgram(handlers, "0.1.0");
8205
+ var { info } = JSON.parse(CONTRACT_JSON_STR);
8206
+ var program = createProgram(handlers, info.version);
8130
8207
  var renderCmd = program.commands.find((c) => c.name() === "render");
8131
8208
  if (renderCmd) {
8132
8209
  renderCmd.option(