diagram-contracts 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +27 -26
- package/dist/diagram-contracts.browser.mjs +23 -23
- package/dist/index.mjs +23 -23
- package/dist/interactive.mjs +19 -19
- package/package.json +1 -2
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: 1.0.
|
|
8
|
-
var CONTRACT_JSON_STR = '{\n "cli_contracts": "0.1.0",\n "info": {\n "title": "diagram-contracts",\n "version": "1.0.1",\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: 1.0.2\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": "1.0.2",\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) {
|
|
@@ -1096,12 +1096,12 @@ function styleAttrs(styles) {
|
|
|
1096
1096
|
if (styles.fill != null) parts.push(`fill="${escXml(styles.fill)}"`);
|
|
1097
1097
|
else parts.push('fill="none"');
|
|
1098
1098
|
if (styles.stroke != null) parts.push(`stroke="${escXml(styles.stroke)}"`);
|
|
1099
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
1099
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
1100
1100
|
if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
1101
1101
|
const da = STROKE_DASHARRAY[String(styles.strokeStyle)];
|
|
1102
1102
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
1103
1103
|
}
|
|
1104
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
1104
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
1105
1105
|
return parts.join(" ");
|
|
1106
1106
|
}
|
|
1107
1107
|
function pts(coords) {
|
|
@@ -3310,7 +3310,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
3310
3310
|
specifier: useMatch[1].trim()
|
|
3311
3311
|
};
|
|
3312
3312
|
}
|
|
3313
|
-
const bindMatch = body.match(/^bind\s+(
|
|
3313
|
+
const bindMatch = body.match(/^bind\s+(\S(?:.*?\S)??)\s*=\s*(.+)$/);
|
|
3314
3314
|
if (bindMatch) {
|
|
3315
3315
|
const selector = parseSelector(bindMatch[1].trim());
|
|
3316
3316
|
if (!selector) return null;
|
|
@@ -3402,7 +3402,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
3402
3402
|
function parseSelector(raw) {
|
|
3403
3403
|
const s = raw.trim();
|
|
3404
3404
|
if (s === "*") return { kind: "all" };
|
|
3405
|
-
const subgraphMatch = s.match(/^subgraph\(\s*(
|
|
3405
|
+
const subgraphMatch = s.match(/^subgraph\(\s*(\S(?:.*?\S)??|(?=.)\s)\s*\)$/);
|
|
3406
3406
|
if (subgraphMatch) {
|
|
3407
3407
|
return { kind: "subgraph", ref: subgraphMatch[1] };
|
|
3408
3408
|
}
|
|
@@ -3426,7 +3426,7 @@ function parseComponentCall(raw) {
|
|
|
3426
3426
|
const s = raw.trim();
|
|
3427
3427
|
const bare = s.match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
3428
3428
|
if (bare) return { component: bare[1], props: [] };
|
|
3429
|
-
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*(
|
|
3429
|
+
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*((?:\S(?:.*?\S)??)?)\s*\)$/);
|
|
3430
3430
|
if (!call) return null;
|
|
3431
3431
|
const component = call[1];
|
|
3432
3432
|
const props = [];
|
|
@@ -5766,10 +5766,10 @@ function renderMarkerDef(def, size) {
|
|
|
5766
5766
|
const common = `id="${def.id}" markerWidth="${size}" markerHeight="${size}" refX="${size}" refY="${half}" orient="auto-start-reverse"`;
|
|
5767
5767
|
if (def.shape === "circle") {
|
|
5768
5768
|
const r = half * 0.8;
|
|
5769
|
-
const fillAttr2 = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
5769
|
+
const fillAttr2 = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
5770
5770
|
return `<marker ${common}><circle cx="${half}" cy="${half}" r="${r}" ${fillAttr2}/></marker>`;
|
|
5771
5771
|
}
|
|
5772
|
-
const fillAttr = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
5772
|
+
const fillAttr = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
5773
5773
|
if (scale === 1) {
|
|
5774
5774
|
return `<marker ${common}><path d="${def.path}" ${fillAttr}/></marker>`;
|
|
5775
5775
|
}
|
|
@@ -5823,17 +5823,17 @@ function renderConnector(node) {
|
|
|
5823
5823
|
const strokeColor = connectorStroke(styles);
|
|
5824
5824
|
const parts = [`d="${d}"`];
|
|
5825
5825
|
parts.push('fill="none"');
|
|
5826
|
-
parts.push(`stroke="${strokeColor}"`);
|
|
5827
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
5826
|
+
parts.push(`stroke="${escXml(strokeColor)}"`);
|
|
5827
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
5828
5828
|
else parts.push(`stroke-width="${RENDER_DEFAULTS.connector.strokeWidth}"`);
|
|
5829
5829
|
if (styles.strokeDasharray != null) {
|
|
5830
|
-
parts.push(`stroke-dasharray="${styles.strokeDasharray}"`);
|
|
5830
|
+
parts.push(`stroke-dasharray="${escXml(styles.strokeDasharray)}"`);
|
|
5831
5831
|
} else if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
5832
5832
|
const da = STROKE_DASHARRAY2[String(styles.strokeStyle)];
|
|
5833
5833
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
5834
5834
|
}
|
|
5835
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
5836
|
-
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${marker.id})"`);
|
|
5835
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
5836
|
+
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${escXml(marker.id)})"`);
|
|
5837
5837
|
return `<path ${parts.join(" ")}/>`;
|
|
5838
5838
|
}
|
|
5839
5839
|
|
|
@@ -5852,13 +5852,13 @@ function renderText(node) {
|
|
|
5852
5852
|
const fallbackBaseline = node.worldRect.y + node.worldRect.height / 2 + fontSize * RENDER_DEFAULTS.text.capHeightFactor / 2;
|
|
5853
5853
|
const startY = node.textBaseline ?? fallbackBaseline;
|
|
5854
5854
|
const attrs = [`text-anchor="${anchor}"`];
|
|
5855
|
-
if (styles.foreground != null) attrs.push(`fill="${styles.foreground}"`);
|
|
5855
|
+
if (styles.foreground != null) attrs.push(`fill="${escXml(styles.foreground)}"`);
|
|
5856
5856
|
else attrs.push('fill="#000"');
|
|
5857
|
-
if (styles.fontSize != null) attrs.push(`font-size="${styles.fontSize}"`);
|
|
5857
|
+
if (styles.fontSize != null) attrs.push(`font-size="${escXml(styles.fontSize)}"`);
|
|
5858
5858
|
if (styles.fontWeight != null && styles.fontWeight !== "regular") {
|
|
5859
|
-
attrs.push(`font-weight="${styles.fontWeight}"`);
|
|
5859
|
+
attrs.push(`font-weight="${escXml(styles.fontWeight)}"`);
|
|
5860
5860
|
}
|
|
5861
|
-
if (styles.fontFamily != null) attrs.push(`font-family="${styles.fontFamily}"`);
|
|
5861
|
+
if (styles.fontFamily != null) attrs.push(`font-family="${escXml(styles.fontFamily)}"`);
|
|
5862
5862
|
const tspans = lines.map((line, i) => {
|
|
5863
5863
|
const dy = i === 0 ? 0 : lineHeight;
|
|
5864
5864
|
return `<tspan x="${tx}" dy="${dy}">${escXml(line)}</tspan>`;
|
|
@@ -5901,7 +5901,7 @@ function connectorLabel(node) {
|
|
|
5901
5901
|
const r = node.worldRect;
|
|
5902
5902
|
const bg = node.styles.background != null ? String(node.styles.background) : RENDER_DEFAULTS.connectorLabel.background;
|
|
5903
5903
|
const pad = 2;
|
|
5904
|
-
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${bg}"/>`;
|
|
5904
|
+
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${escXml(bg)}"/>`;
|
|
5905
5905
|
return `${rect}${text}`;
|
|
5906
5906
|
}
|
|
5907
5907
|
function image(node, fit) {
|
|
@@ -5949,8 +5949,8 @@ function drawNode(node, parent, ctx) {
|
|
|
5949
5949
|
const outline = `x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="${rx}" ry="${rx}"`;
|
|
5950
5950
|
return {
|
|
5951
5951
|
clip: `<rect ${outline}/>`,
|
|
5952
|
-
body: `<rect ${outline} fill="${tableFill}"/>`,
|
|
5953
|
-
frame: `<rect ${outline} fill="none" stroke="${borderStroke}" stroke-width="${borderSw}"/>`
|
|
5952
|
+
body: `<rect ${outline} fill="${escXml(tableFill)}"/>`,
|
|
5953
|
+
frame: `<rect ${outline} fill="none" stroke="${escXml(borderStroke)}" stroke-width="${borderSw}"/>`
|
|
5954
5954
|
};
|
|
5955
5955
|
}
|
|
5956
5956
|
case "box": {
|
|
@@ -5968,14 +5968,14 @@ function drawNode(node, parent, ctx) {
|
|
|
5968
5968
|
const stroke = node.styles.stroke ?? RENDER_DEFAULTS.divider.stroke;
|
|
5969
5969
|
const sw = node.styles.strokeWidth ?? RENDER_DEFAULTS.divider.strokeWidth;
|
|
5970
5970
|
return {
|
|
5971
|
-
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${stroke}" stroke-width="${sw}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${stroke}" stroke-width="${sw}"/>`
|
|
5971
|
+
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>`
|
|
5972
5972
|
};
|
|
5973
5973
|
}
|
|
5974
5974
|
case "cell": {
|
|
5975
5975
|
const cellFill = node.styles.fill ?? RENDER_DEFAULTS.cell.fill;
|
|
5976
5976
|
const cellStroke = node.styles.stroke ?? RENDER_DEFAULTS.cell.stroke;
|
|
5977
5977
|
const cellSw = node.styles.strokeWidth ?? RENDER_DEFAULTS.cell.strokeWidth;
|
|
5978
|
-
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${cellFill}" stroke="${cellStroke}" stroke-width="${cellSw}"/>` };
|
|
5978
|
+
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${escXml(cellFill)}" stroke="${escXml(cellStroke)}" stroke-width="${escXml(cellSw)}"/>` };
|
|
5979
5979
|
}
|
|
5980
5980
|
case "image":
|
|
5981
5981
|
return { body: image(node, String(node.styles.fit ?? RENDER_DEFAULTS.image.fit)) };
|
|
@@ -6049,7 +6049,7 @@ function assertDrawable(artifact, interactive) {
|
|
|
6049
6049
|
}
|
|
6050
6050
|
function renderBackground(artifact) {
|
|
6051
6051
|
const vb = artifact.viewBox;
|
|
6052
|
-
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${artifact.background}"/>` : "";
|
|
6052
|
+
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${escXml(artifact.background)}"/>` : "";
|
|
6053
6053
|
}
|
|
6054
6054
|
function renderSvg(artifact, options) {
|
|
6055
6055
|
const interactive = options?.interactive === true;
|
|
@@ -6075,7 +6075,7 @@ function renderSvg(artifact, options) {
|
|
|
6075
6075
|
const defaultDefs = renderArrowMarkers();
|
|
6076
6076
|
const defs = markers.size > 0 ? defaultDefs.replace("</defs>", [...markers.values()].join("\n") + "\n</defs>") : defaultDefs;
|
|
6077
6077
|
return [
|
|
6078
|
-
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${artifact.fontFamily}"` : ""}>`,
|
|
6078
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${escXml(artifact.fontFamily)}"` : ""}>`,
|
|
6079
6079
|
defs,
|
|
6080
6080
|
body.join("\n"),
|
|
6081
6081
|
"</svg>"
|
|
@@ -7358,7 +7358,8 @@ function createOpenTypeMeasurer(fontFiles, options) {
|
|
|
7358
7358
|
for (const { weight, path } of fontFiles) {
|
|
7359
7359
|
try {
|
|
7360
7360
|
const buf = readFileSync3(path);
|
|
7361
|
-
const
|
|
7361
|
+
const bytes = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
7362
|
+
const font = parse(bytes, { lowMemory: true });
|
|
7362
7363
|
measurer.addFont(weight, font);
|
|
7363
7364
|
} catch (e) {
|
|
7364
7365
|
if (strict) {
|
|
@@ -229,7 +229,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
229
229
|
specifier: useMatch[1].trim()
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
|
-
const bindMatch = body.match(/^bind\s+(
|
|
232
|
+
const bindMatch = body.match(/^bind\s+(\S(?:.*?\S)??)\s*=\s*(.+)$/);
|
|
233
233
|
if (bindMatch) {
|
|
234
234
|
const selector = parseSelector(bindMatch[1].trim());
|
|
235
235
|
if (!selector) return null;
|
|
@@ -321,7 +321,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
321
321
|
function parseSelector(raw) {
|
|
322
322
|
const s = raw.trim();
|
|
323
323
|
if (s === "*") return { kind: "all" };
|
|
324
|
-
const subgraphMatch = s.match(/^subgraph\(\s*(
|
|
324
|
+
const subgraphMatch = s.match(/^subgraph\(\s*(\S(?:.*?\S)??|(?=.)\s)\s*\)$/);
|
|
325
325
|
if (subgraphMatch) {
|
|
326
326
|
return { kind: "subgraph", ref: subgraphMatch[1] };
|
|
327
327
|
}
|
|
@@ -345,7 +345,7 @@ function parseComponentCall(raw) {
|
|
|
345
345
|
const s = raw.trim();
|
|
346
346
|
const bare = s.match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
347
347
|
if (bare) return { component: bare[1], props: [] };
|
|
348
|
-
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*(
|
|
348
|
+
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*((?:\S(?:.*?\S)??)?)\s*\)$/);
|
|
349
349
|
if (!call) return null;
|
|
350
350
|
const component = call[1];
|
|
351
351
|
const props = [];
|
|
@@ -3864,12 +3864,12 @@ function styleAttrs(styles) {
|
|
|
3864
3864
|
if (styles.fill != null) parts.push(`fill="${escXml(styles.fill)}"`);
|
|
3865
3865
|
else parts.push('fill="none"');
|
|
3866
3866
|
if (styles.stroke != null) parts.push(`stroke="${escXml(styles.stroke)}"`);
|
|
3867
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
3867
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
3868
3868
|
if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
3869
3869
|
const da = STROKE_DASHARRAY[String(styles.strokeStyle)];
|
|
3870
3870
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
3871
3871
|
}
|
|
3872
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
3872
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
3873
3873
|
return parts.join(" ");
|
|
3874
3874
|
}
|
|
3875
3875
|
function pts(coords) {
|
|
@@ -27918,10 +27918,10 @@ function renderMarkerDef(def, size) {
|
|
|
27918
27918
|
const common = `id="${def.id}" markerWidth="${size}" markerHeight="${size}" refX="${size}" refY="${half}" orient="auto-start-reverse"`;
|
|
27919
27919
|
if (def.shape === "circle") {
|
|
27920
27920
|
const r = half * 0.8;
|
|
27921
|
-
const fillAttr2 = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
27921
|
+
const fillAttr2 = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
27922
27922
|
return `<marker ${common}><circle cx="${half}" cy="${half}" r="${r}" ${fillAttr2}/></marker>`;
|
|
27923
27923
|
}
|
|
27924
|
-
const fillAttr = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
27924
|
+
const fillAttr = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
27925
27925
|
if (scale === 1) {
|
|
27926
27926
|
return `<marker ${common}><path d="${def.path}" ${fillAttr}/></marker>`;
|
|
27927
27927
|
}
|
|
@@ -27975,17 +27975,17 @@ function renderConnector(node2) {
|
|
|
27975
27975
|
const strokeColor = connectorStroke(styles);
|
|
27976
27976
|
const parts = [`d="${d}"`];
|
|
27977
27977
|
parts.push('fill="none"');
|
|
27978
|
-
parts.push(`stroke="${strokeColor}"`);
|
|
27979
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
27978
|
+
parts.push(`stroke="${escXml(strokeColor)}"`);
|
|
27979
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
27980
27980
|
else parts.push(`stroke-width="${RENDER_DEFAULTS.connector.strokeWidth}"`);
|
|
27981
27981
|
if (styles.strokeDasharray != null) {
|
|
27982
|
-
parts.push(`stroke-dasharray="${styles.strokeDasharray}"`);
|
|
27982
|
+
parts.push(`stroke-dasharray="${escXml(styles.strokeDasharray)}"`);
|
|
27983
27983
|
} else if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
27984
27984
|
const da = STROKE_DASHARRAY2[String(styles.strokeStyle)];
|
|
27985
27985
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
27986
27986
|
}
|
|
27987
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
27988
|
-
for (const marker of connectorMarkers(node2)) parts.push(`${marker.attr}="url(#${marker.id})"`);
|
|
27987
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
27988
|
+
for (const marker of connectorMarkers(node2)) parts.push(`${marker.attr}="url(#${escXml(marker.id)})"`);
|
|
27989
27989
|
return `<path ${parts.join(" ")}/>`;
|
|
27990
27990
|
}
|
|
27991
27991
|
|
|
@@ -28004,13 +28004,13 @@ function renderText(node2) {
|
|
|
28004
28004
|
const fallbackBaseline = node2.worldRect.y + node2.worldRect.height / 2 + fontSize * RENDER_DEFAULTS.text.capHeightFactor / 2;
|
|
28005
28005
|
const startY = node2.textBaseline ?? fallbackBaseline;
|
|
28006
28006
|
const attrs = [`text-anchor="${anchor2}"`];
|
|
28007
|
-
if (styles.foreground != null) attrs.push(`fill="${styles.foreground}"`);
|
|
28007
|
+
if (styles.foreground != null) attrs.push(`fill="${escXml(styles.foreground)}"`);
|
|
28008
28008
|
else attrs.push('fill="#000"');
|
|
28009
|
-
if (styles.fontSize != null) attrs.push(`font-size="${styles.fontSize}"`);
|
|
28009
|
+
if (styles.fontSize != null) attrs.push(`font-size="${escXml(styles.fontSize)}"`);
|
|
28010
28010
|
if (styles.fontWeight != null && styles.fontWeight !== "regular") {
|
|
28011
|
-
attrs.push(`font-weight="${styles.fontWeight}"`);
|
|
28011
|
+
attrs.push(`font-weight="${escXml(styles.fontWeight)}"`);
|
|
28012
28012
|
}
|
|
28013
|
-
if (styles.fontFamily != null) attrs.push(`font-family="${styles.fontFamily}"`);
|
|
28013
|
+
if (styles.fontFamily != null) attrs.push(`font-family="${escXml(styles.fontFamily)}"`);
|
|
28014
28014
|
const tspans = lines.map((line, i) => {
|
|
28015
28015
|
const dy = i === 0 ? 0 : lineHeight;
|
|
28016
28016
|
return `<tspan x="${tx}" dy="${dy}">${escXml(line)}</tspan>`;
|
|
@@ -28053,7 +28053,7 @@ function connectorLabel(node2) {
|
|
|
28053
28053
|
const r = node2.worldRect;
|
|
28054
28054
|
const bg = node2.styles.background != null ? String(node2.styles.background) : RENDER_DEFAULTS.connectorLabel.background;
|
|
28055
28055
|
const pad = 2;
|
|
28056
|
-
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${bg}"/>`;
|
|
28056
|
+
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${escXml(bg)}"/>`;
|
|
28057
28057
|
return `${rect}${text}`;
|
|
28058
28058
|
}
|
|
28059
28059
|
function image(node2, fit) {
|
|
@@ -28101,8 +28101,8 @@ function drawNode(node2, parent, ctx) {
|
|
|
28101
28101
|
const outline = `x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="${rx}" ry="${rx}"`;
|
|
28102
28102
|
return {
|
|
28103
28103
|
clip: `<rect ${outline}/>`,
|
|
28104
|
-
body: `<rect ${outline} fill="${tableFill}"/>`,
|
|
28105
|
-
frame: `<rect ${outline} fill="none" stroke="${borderStroke}" stroke-width="${borderSw}"/>`
|
|
28104
|
+
body: `<rect ${outline} fill="${escXml(tableFill)}"/>`,
|
|
28105
|
+
frame: `<rect ${outline} fill="none" stroke="${escXml(borderStroke)}" stroke-width="${borderSw}"/>`
|
|
28106
28106
|
};
|
|
28107
28107
|
}
|
|
28108
28108
|
case "box": {
|
|
@@ -28120,14 +28120,14 @@ function drawNode(node2, parent, ctx) {
|
|
|
28120
28120
|
const stroke = node2.styles.stroke ?? RENDER_DEFAULTS.divider.stroke;
|
|
28121
28121
|
const sw = node2.styles.strokeWidth ?? RENDER_DEFAULTS.divider.strokeWidth;
|
|
28122
28122
|
return {
|
|
28123
|
-
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${stroke}" stroke-width="${sw}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${stroke}" stroke-width="${sw}"/>`
|
|
28123
|
+
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>`
|
|
28124
28124
|
};
|
|
28125
28125
|
}
|
|
28126
28126
|
case "cell": {
|
|
28127
28127
|
const cellFill = node2.styles.fill ?? RENDER_DEFAULTS.cell.fill;
|
|
28128
28128
|
const cellStroke = node2.styles.stroke ?? RENDER_DEFAULTS.cell.stroke;
|
|
28129
28129
|
const cellSw = node2.styles.strokeWidth ?? RENDER_DEFAULTS.cell.strokeWidth;
|
|
28130
|
-
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${cellFill}" stroke="${cellStroke}" stroke-width="${cellSw}"/>` };
|
|
28130
|
+
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${escXml(cellFill)}" stroke="${escXml(cellStroke)}" stroke-width="${escXml(cellSw)}"/>` };
|
|
28131
28131
|
}
|
|
28132
28132
|
case "image":
|
|
28133
28133
|
return { body: image(node2, String(node2.styles.fit ?? RENDER_DEFAULTS.image.fit)) };
|
|
@@ -28201,7 +28201,7 @@ function assertDrawable(artifact, interactive) {
|
|
|
28201
28201
|
}
|
|
28202
28202
|
function renderBackground(artifact) {
|
|
28203
28203
|
const vb = artifact.viewBox;
|
|
28204
|
-
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${artifact.background}"/>` : "";
|
|
28204
|
+
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${escXml(artifact.background)}"/>` : "";
|
|
28205
28205
|
}
|
|
28206
28206
|
function renderSvg(artifact, options) {
|
|
28207
28207
|
const interactive = options?.interactive === true;
|
|
@@ -28227,7 +28227,7 @@ function renderSvg(artifact, options) {
|
|
|
28227
28227
|
const defaultDefs = renderArrowMarkers();
|
|
28228
28228
|
const defs = markers.size > 0 ? defaultDefs.replace("</defs>", [...markers.values()].join("\n") + "\n</defs>") : defaultDefs;
|
|
28229
28229
|
return [
|
|
28230
|
-
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${artifact.fontFamily}"` : ""}>`,
|
|
28230
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${escXml(artifact.fontFamily)}"` : ""}>`,
|
|
28231
28231
|
defs,
|
|
28232
28232
|
body.join("\n"),
|
|
28233
28233
|
"</svg>"
|
package/dist/index.mjs
CHANGED
|
@@ -874,12 +874,12 @@ function styleAttrs(styles) {
|
|
|
874
874
|
if (styles.fill != null) parts.push(`fill="${escXml(styles.fill)}"`);
|
|
875
875
|
else parts.push('fill="none"');
|
|
876
876
|
if (styles.stroke != null) parts.push(`stroke="${escXml(styles.stroke)}"`);
|
|
877
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
877
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
878
878
|
if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
879
879
|
const da = STROKE_DASHARRAY[String(styles.strokeStyle)];
|
|
880
880
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
881
881
|
}
|
|
882
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
882
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
883
883
|
return parts.join(" ");
|
|
884
884
|
}
|
|
885
885
|
function pts(coords) {
|
|
@@ -3085,7 +3085,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
3085
3085
|
specifier: useMatch[1].trim()
|
|
3086
3086
|
};
|
|
3087
3087
|
}
|
|
3088
|
-
const bindMatch = body.match(/^bind\s+(
|
|
3088
|
+
const bindMatch = body.match(/^bind\s+(\S(?:.*?\S)??)\s*=\s*(.+)$/);
|
|
3089
3089
|
if (bindMatch) {
|
|
3090
3090
|
const selector = parseSelector(bindMatch[1].trim());
|
|
3091
3091
|
if (!selector) return null;
|
|
@@ -3177,7 +3177,7 @@ function parseCommentDirective(trimmed, raw, lineNum) {
|
|
|
3177
3177
|
function parseSelector(raw) {
|
|
3178
3178
|
const s = raw.trim();
|
|
3179
3179
|
if (s === "*") return { kind: "all" };
|
|
3180
|
-
const subgraphMatch = s.match(/^subgraph\(\s*(
|
|
3180
|
+
const subgraphMatch = s.match(/^subgraph\(\s*(\S(?:.*?\S)??|(?=.)\s)\s*\)$/);
|
|
3181
3181
|
if (subgraphMatch) {
|
|
3182
3182
|
return { kind: "subgraph", ref: subgraphMatch[1] };
|
|
3183
3183
|
}
|
|
@@ -3201,7 +3201,7 @@ function parseComponentCall(raw) {
|
|
|
3201
3201
|
const s = raw.trim();
|
|
3202
3202
|
const bare = s.match(/^([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
3203
3203
|
if (bare) return { component: bare[1], props: [] };
|
|
3204
|
-
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*(
|
|
3204
|
+
const call = s.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(\s*((?:\S(?:.*?\S)??)?)\s*\)$/);
|
|
3205
3205
|
if (!call) return null;
|
|
3206
3206
|
const component = call[1];
|
|
3207
3207
|
const props = [];
|
|
@@ -5560,10 +5560,10 @@ function renderMarkerDef(def, size) {
|
|
|
5560
5560
|
const common = `id="${def.id}" markerWidth="${size}" markerHeight="${size}" refX="${size}" refY="${half}" orient="auto-start-reverse"`;
|
|
5561
5561
|
if (def.shape === "circle") {
|
|
5562
5562
|
const r = half * 0.8;
|
|
5563
|
-
const fillAttr2 = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
5563
|
+
const fillAttr2 = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
5564
5564
|
return `<marker ${common}><circle cx="${half}" cy="${half}" r="${r}" ${fillAttr2}/></marker>`;
|
|
5565
5565
|
}
|
|
5566
|
-
const fillAttr = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
5566
|
+
const fillAttr = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
5567
5567
|
if (scale === 1) {
|
|
5568
5568
|
return `<marker ${common}><path d="${def.path}" ${fillAttr}/></marker>`;
|
|
5569
5569
|
}
|
|
@@ -5617,17 +5617,17 @@ function renderConnector(node) {
|
|
|
5617
5617
|
const strokeColor = connectorStroke(styles);
|
|
5618
5618
|
const parts = [`d="${d}"`];
|
|
5619
5619
|
parts.push('fill="none"');
|
|
5620
|
-
parts.push(`stroke="${strokeColor}"`);
|
|
5621
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
5620
|
+
parts.push(`stroke="${escXml(strokeColor)}"`);
|
|
5621
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
5622
5622
|
else parts.push(`stroke-width="${RENDER_DEFAULTS.connector.strokeWidth}"`);
|
|
5623
5623
|
if (styles.strokeDasharray != null) {
|
|
5624
|
-
parts.push(`stroke-dasharray="${styles.strokeDasharray}"`);
|
|
5624
|
+
parts.push(`stroke-dasharray="${escXml(styles.strokeDasharray)}"`);
|
|
5625
5625
|
} else if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
5626
5626
|
const da = STROKE_DASHARRAY2[String(styles.strokeStyle)];
|
|
5627
5627
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
5628
5628
|
}
|
|
5629
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
5630
|
-
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${marker.id})"`);
|
|
5629
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
5630
|
+
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${escXml(marker.id)})"`);
|
|
5631
5631
|
return `<path ${parts.join(" ")}/>`;
|
|
5632
5632
|
}
|
|
5633
5633
|
|
|
@@ -5646,13 +5646,13 @@ function renderText(node) {
|
|
|
5646
5646
|
const fallbackBaseline = node.worldRect.y + node.worldRect.height / 2 + fontSize * RENDER_DEFAULTS.text.capHeightFactor / 2;
|
|
5647
5647
|
const startY = node.textBaseline ?? fallbackBaseline;
|
|
5648
5648
|
const attrs = [`text-anchor="${anchor}"`];
|
|
5649
|
-
if (styles.foreground != null) attrs.push(`fill="${styles.foreground}"`);
|
|
5649
|
+
if (styles.foreground != null) attrs.push(`fill="${escXml(styles.foreground)}"`);
|
|
5650
5650
|
else attrs.push('fill="#000"');
|
|
5651
|
-
if (styles.fontSize != null) attrs.push(`font-size="${styles.fontSize}"`);
|
|
5651
|
+
if (styles.fontSize != null) attrs.push(`font-size="${escXml(styles.fontSize)}"`);
|
|
5652
5652
|
if (styles.fontWeight != null && styles.fontWeight !== "regular") {
|
|
5653
|
-
attrs.push(`font-weight="${styles.fontWeight}"`);
|
|
5653
|
+
attrs.push(`font-weight="${escXml(styles.fontWeight)}"`);
|
|
5654
5654
|
}
|
|
5655
|
-
if (styles.fontFamily != null) attrs.push(`font-family="${styles.fontFamily}"`);
|
|
5655
|
+
if (styles.fontFamily != null) attrs.push(`font-family="${escXml(styles.fontFamily)}"`);
|
|
5656
5656
|
const tspans = lines.map((line, i) => {
|
|
5657
5657
|
const dy = i === 0 ? 0 : lineHeight;
|
|
5658
5658
|
return `<tspan x="${tx}" dy="${dy}">${escXml(line)}</tspan>`;
|
|
@@ -5695,7 +5695,7 @@ function connectorLabel(node) {
|
|
|
5695
5695
|
const r = node.worldRect;
|
|
5696
5696
|
const bg = node.styles.background != null ? String(node.styles.background) : RENDER_DEFAULTS.connectorLabel.background;
|
|
5697
5697
|
const pad = 2;
|
|
5698
|
-
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${bg}"/>`;
|
|
5698
|
+
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${escXml(bg)}"/>`;
|
|
5699
5699
|
return `${rect}${text}`;
|
|
5700
5700
|
}
|
|
5701
5701
|
function image(node, fit) {
|
|
@@ -5743,8 +5743,8 @@ function drawNode(node, parent, ctx) {
|
|
|
5743
5743
|
const outline = `x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="${rx}" ry="${rx}"`;
|
|
5744
5744
|
return {
|
|
5745
5745
|
clip: `<rect ${outline}/>`,
|
|
5746
|
-
body: `<rect ${outline} fill="${tableFill}"/>`,
|
|
5747
|
-
frame: `<rect ${outline} fill="none" stroke="${borderStroke}" stroke-width="${borderSw}"/>`
|
|
5746
|
+
body: `<rect ${outline} fill="${escXml(tableFill)}"/>`,
|
|
5747
|
+
frame: `<rect ${outline} fill="none" stroke="${escXml(borderStroke)}" stroke-width="${borderSw}"/>`
|
|
5748
5748
|
};
|
|
5749
5749
|
}
|
|
5750
5750
|
case "box": {
|
|
@@ -5762,14 +5762,14 @@ function drawNode(node, parent, ctx) {
|
|
|
5762
5762
|
const stroke = node.styles.stroke ?? RENDER_DEFAULTS.divider.stroke;
|
|
5763
5763
|
const sw = node.styles.strokeWidth ?? RENDER_DEFAULTS.divider.strokeWidth;
|
|
5764
5764
|
return {
|
|
5765
|
-
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${stroke}" stroke-width="${sw}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${stroke}" stroke-width="${sw}"/>`
|
|
5765
|
+
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>`
|
|
5766
5766
|
};
|
|
5767
5767
|
}
|
|
5768
5768
|
case "cell": {
|
|
5769
5769
|
const cellFill = node.styles.fill ?? RENDER_DEFAULTS.cell.fill;
|
|
5770
5770
|
const cellStroke = node.styles.stroke ?? RENDER_DEFAULTS.cell.stroke;
|
|
5771
5771
|
const cellSw = node.styles.strokeWidth ?? RENDER_DEFAULTS.cell.strokeWidth;
|
|
5772
|
-
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${cellFill}" stroke="${cellStroke}" stroke-width="${cellSw}"/>` };
|
|
5772
|
+
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${escXml(cellFill)}" stroke="${escXml(cellStroke)}" stroke-width="${escXml(cellSw)}"/>` };
|
|
5773
5773
|
}
|
|
5774
5774
|
case "image":
|
|
5775
5775
|
return { body: image(node, String(node.styles.fit ?? RENDER_DEFAULTS.image.fit)) };
|
|
@@ -5843,7 +5843,7 @@ function assertDrawable(artifact, interactive) {
|
|
|
5843
5843
|
}
|
|
5844
5844
|
function renderBackground(artifact) {
|
|
5845
5845
|
const vb = artifact.viewBox;
|
|
5846
|
-
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${artifact.background}"/>` : "";
|
|
5846
|
+
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${escXml(artifact.background)}"/>` : "";
|
|
5847
5847
|
}
|
|
5848
5848
|
function renderSvg(artifact, options) {
|
|
5849
5849
|
const interactive = options?.interactive === true;
|
|
@@ -5869,7 +5869,7 @@ function renderSvg(artifact, options) {
|
|
|
5869
5869
|
const defaultDefs = renderArrowMarkers();
|
|
5870
5870
|
const defs = markers.size > 0 ? defaultDefs.replace("</defs>", [...markers.values()].join("\n") + "\n</defs>") : defaultDefs;
|
|
5871
5871
|
return [
|
|
5872
|
-
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${artifact.fontFamily}"` : ""}>`,
|
|
5872
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${vb.x} ${vb.y} ${vb.width} ${vb.height}" width="${vb.width}" height="${vb.height}"${artifact.fontFamily ? ` font-family="${escXml(artifact.fontFamily)}"` : ""}>`,
|
|
5873
5873
|
defs,
|
|
5874
5874
|
body.join("\n"),
|
|
5875
5875
|
"</svg>"
|
package/dist/interactive.mjs
CHANGED
|
@@ -998,12 +998,12 @@ function styleAttrs(styles) {
|
|
|
998
998
|
if (styles.fill != null) parts.push(`fill="${escXml(styles.fill)}"`);
|
|
999
999
|
else parts.push('fill="none"');
|
|
1000
1000
|
if (styles.stroke != null) parts.push(`stroke="${escXml(styles.stroke)}"`);
|
|
1001
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
1001
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
1002
1002
|
if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
1003
1003
|
const da = STROKE_DASHARRAY[String(styles.strokeStyle)];
|
|
1004
1004
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
1005
1005
|
}
|
|
1006
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
1006
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
1007
1007
|
return parts.join(" ");
|
|
1008
1008
|
}
|
|
1009
1009
|
function pts(coords) {
|
|
@@ -4477,10 +4477,10 @@ function renderMarkerDef(def, size) {
|
|
|
4477
4477
|
const common = `id="${def.id}" markerWidth="${size}" markerHeight="${size}" refX="${size}" refY="${half}" orient="auto-start-reverse"`;
|
|
4478
4478
|
if (def.shape === "circle") {
|
|
4479
4479
|
const r = half * 0.8;
|
|
4480
|
-
const fillAttr2 = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
4480
|
+
const fillAttr2 = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
4481
4481
|
return `<marker ${common}><circle cx="${half}" cy="${half}" r="${r}" ${fillAttr2}/></marker>`;
|
|
4482
4482
|
}
|
|
4483
|
-
const fillAttr = def.fill ? `fill="${def.color}"` : `fill="none" stroke="${def.color}" stroke-width="1"`;
|
|
4483
|
+
const fillAttr = def.fill ? `fill="${escXml(def.color)}"` : `fill="none" stroke="${escXml(def.color)}" stroke-width="1"`;
|
|
4484
4484
|
if (scale === 1) {
|
|
4485
4485
|
return `<marker ${common}><path d="${def.path}" ${fillAttr}/></marker>`;
|
|
4486
4486
|
}
|
|
@@ -4530,17 +4530,17 @@ function renderConnector(node) {
|
|
|
4530
4530
|
const strokeColor = connectorStroke(styles);
|
|
4531
4531
|
const parts = [`d="${d}"`];
|
|
4532
4532
|
parts.push('fill="none"');
|
|
4533
|
-
parts.push(`stroke="${strokeColor}"`);
|
|
4534
|
-
if (styles.strokeWidth != null) parts.push(`stroke-width="${styles.strokeWidth}"`);
|
|
4533
|
+
parts.push(`stroke="${escXml(strokeColor)}"`);
|
|
4534
|
+
if (styles.strokeWidth != null) parts.push(`stroke-width="${escXml(styles.strokeWidth)}"`);
|
|
4535
4535
|
else parts.push(`stroke-width="${RENDER_DEFAULTS.connector.strokeWidth}"`);
|
|
4536
4536
|
if (styles.strokeDasharray != null) {
|
|
4537
|
-
parts.push(`stroke-dasharray="${styles.strokeDasharray}"`);
|
|
4537
|
+
parts.push(`stroke-dasharray="${escXml(styles.strokeDasharray)}"`);
|
|
4538
4538
|
} else if (styles.strokeStyle != null && styles.strokeStyle !== "solid") {
|
|
4539
4539
|
const da = STROKE_DASHARRAY2[String(styles.strokeStyle)];
|
|
4540
4540
|
if (da) parts.push(`stroke-dasharray="${da}"`);
|
|
4541
4541
|
}
|
|
4542
|
-
if (styles.opacity != null) parts.push(`opacity="${styles.opacity}"`);
|
|
4543
|
-
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${marker.id})"`);
|
|
4542
|
+
if (styles.opacity != null) parts.push(`opacity="${escXml(styles.opacity)}"`);
|
|
4543
|
+
for (const marker of connectorMarkers(node)) parts.push(`${marker.attr}="url(#${escXml(marker.id)})"`);
|
|
4544
4544
|
return `<path ${parts.join(" ")}/>`;
|
|
4545
4545
|
}
|
|
4546
4546
|
|
|
@@ -4559,13 +4559,13 @@ function renderText(node) {
|
|
|
4559
4559
|
const fallbackBaseline = node.worldRect.y + node.worldRect.height / 2 + fontSize * RENDER_DEFAULTS.text.capHeightFactor / 2;
|
|
4560
4560
|
const startY = node.textBaseline ?? fallbackBaseline;
|
|
4561
4561
|
const attrs = [`text-anchor="${anchor}"`];
|
|
4562
|
-
if (styles.foreground != null) attrs.push(`fill="${styles.foreground}"`);
|
|
4562
|
+
if (styles.foreground != null) attrs.push(`fill="${escXml(styles.foreground)}"`);
|
|
4563
4563
|
else attrs.push('fill="#000"');
|
|
4564
|
-
if (styles.fontSize != null) attrs.push(`font-size="${styles.fontSize}"`);
|
|
4564
|
+
if (styles.fontSize != null) attrs.push(`font-size="${escXml(styles.fontSize)}"`);
|
|
4565
4565
|
if (styles.fontWeight != null && styles.fontWeight !== "regular") {
|
|
4566
|
-
attrs.push(`font-weight="${styles.fontWeight}"`);
|
|
4566
|
+
attrs.push(`font-weight="${escXml(styles.fontWeight)}"`);
|
|
4567
4567
|
}
|
|
4568
|
-
if (styles.fontFamily != null) attrs.push(`font-family="${styles.fontFamily}"`);
|
|
4568
|
+
if (styles.fontFamily != null) attrs.push(`font-family="${escXml(styles.fontFamily)}"`);
|
|
4569
4569
|
const tspans = lines.map((line, i) => {
|
|
4570
4570
|
const dy = i === 0 ? 0 : lineHeight;
|
|
4571
4571
|
return `<tspan x="${tx}" dy="${dy}">${escXml(line)}</tspan>`;
|
|
@@ -4608,7 +4608,7 @@ function connectorLabel(node) {
|
|
|
4608
4608
|
const r = node.worldRect;
|
|
4609
4609
|
const bg = node.styles.background != null ? String(node.styles.background) : RENDER_DEFAULTS.connectorLabel.background;
|
|
4610
4610
|
const pad = 2;
|
|
4611
|
-
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${bg}"/>`;
|
|
4611
|
+
const rect = bg === "none" ? "" : `<rect x="${r.x - pad}" y="${r.y - pad}" width="${r.width + pad * 2}" height="${r.height + pad * 2}" fill="${escXml(bg)}"/>`;
|
|
4612
4612
|
return `${rect}${text}`;
|
|
4613
4613
|
}
|
|
4614
4614
|
function image(node, fit) {
|
|
@@ -4656,8 +4656,8 @@ function drawNode(node, parent, ctx) {
|
|
|
4656
4656
|
const outline2 = `x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="${rx}" ry="${rx}"`;
|
|
4657
4657
|
return {
|
|
4658
4658
|
clip: `<rect ${outline2}/>`,
|
|
4659
|
-
body: `<rect ${outline2} fill="${tableFill}"/>`,
|
|
4660
|
-
frame: `<rect ${outline2} fill="none" stroke="${borderStroke}" stroke-width="${borderSw}"/>`
|
|
4659
|
+
body: `<rect ${outline2} fill="${escXml(tableFill)}"/>`,
|
|
4660
|
+
frame: `<rect ${outline2} fill="none" stroke="${escXml(borderStroke)}" stroke-width="${borderSw}"/>`
|
|
4661
4661
|
};
|
|
4662
4662
|
}
|
|
4663
4663
|
case "box": {
|
|
@@ -4675,14 +4675,14 @@ function drawNode(node, parent, ctx) {
|
|
|
4675
4675
|
const stroke = node.styles.stroke ?? RENDER_DEFAULTS.divider.stroke;
|
|
4676
4676
|
const sw = node.styles.strokeWidth ?? RENDER_DEFAULTS.divider.strokeWidth;
|
|
4677
4677
|
return {
|
|
4678
|
-
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${stroke}" stroke-width="${sw}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${stroke}" stroke-width="${sw}"/>`
|
|
4678
|
+
body: r.width >= r.height ? `<line x1="${r.x}" y1="${r.y}" x2="${r.x + r.width}" y2="${r.y}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>` : `<line x1="${r.x}" y1="${r.y}" x2="${r.x}" y2="${r.y + r.height}" stroke="${escXml(stroke)}" stroke-width="${escXml(sw)}"/>`
|
|
4679
4679
|
};
|
|
4680
4680
|
}
|
|
4681
4681
|
case "cell": {
|
|
4682
4682
|
const cellFill = node.styles.fill ?? RENDER_DEFAULTS.cell.fill;
|
|
4683
4683
|
const cellStroke = node.styles.stroke ?? RENDER_DEFAULTS.cell.stroke;
|
|
4684
4684
|
const cellSw = node.styles.strokeWidth ?? RENDER_DEFAULTS.cell.strokeWidth;
|
|
4685
|
-
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${cellFill}" stroke="${cellStroke}" stroke-width="${cellSw}"/>` };
|
|
4685
|
+
return { body: `<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" fill="${escXml(cellFill)}" stroke="${escXml(cellStroke)}" stroke-width="${escXml(cellSw)}"/>` };
|
|
4686
4686
|
}
|
|
4687
4687
|
case "image":
|
|
4688
4688
|
return { body: image(node, String(node.styles.fit ?? RENDER_DEFAULTS.image.fit)) };
|
|
@@ -4754,7 +4754,7 @@ function assertDrawable(artifact, interactive) {
|
|
|
4754
4754
|
}
|
|
4755
4755
|
function renderBackground(artifact) {
|
|
4756
4756
|
const vb = artifact.viewBox;
|
|
4757
|
-
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${artifact.background}"/>` : "";
|
|
4757
|
+
return artifact.background != null ? `<rect x="${vb.x}" y="${vb.y}" width="${vb.width}" height="${vb.height}" fill="${escXml(artifact.background)}"/>` : "";
|
|
4758
4758
|
}
|
|
4759
4759
|
|
|
4760
4760
|
// src/pipeline.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diagram-contracts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rule Catalog driven layout runtime — compile diagrams to deterministic SVG from Draw TSX, Draw Text, or Layout IR",
|
|
6
6
|
"keywords": [
|
|
@@ -100,7 +100,6 @@
|
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@size-limit/file": "^11.0.0",
|
|
103
|
-
"@types/js-yaml": "^4.0.9",
|
|
104
103
|
"@types/node": "^26.0.0",
|
|
105
104
|
"aws-icons": "^3.3.0",
|
|
106
105
|
"cli-contracts": "^0.34.6",
|