schematex 0.9.12 → 0.9.14
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/ai/ai-sdk.cjs +16 -16
- package/dist/ai/ai-sdk.js +11 -11
- package/dist/ai/index.cjs +25 -25
- package/dist/ai/index.js +12 -12
- package/dist/browser.cjs +17 -17
- package/dist/browser.js +11 -11
- package/dist/{chunk-HEGDKO2E.cjs → chunk-24YHD4YI.cjs} +3 -2
- package/dist/chunk-24YHD4YI.cjs.map +1 -0
- package/dist/{chunk-6KW7XSUR.js → chunk-2PRNDY5I.js} +3 -3
- package/dist/{chunk-6KW7XSUR.js.map → chunk-2PRNDY5I.js.map} +1 -1
- package/dist/{chunk-NP7N3DZG.js → chunk-2ZHP4TXP.js} +3 -3
- package/dist/{chunk-NP7N3DZG.js.map → chunk-2ZHP4TXP.js.map} +1 -1
- package/dist/{chunk-32LOZTNP.js → chunk-37WDY4G4.js} +3 -2
- package/dist/chunk-37WDY4G4.js.map +1 -0
- package/dist/{chunk-3KRL2EGN.cjs → chunk-3TGOOZ36.cjs} +13 -6
- package/dist/chunk-3TGOOZ36.cjs.map +1 -0
- package/dist/{chunk-Q5MQLUOH.js → chunk-6GVFKOSH.js} +3 -3
- package/dist/{chunk-Q5MQLUOH.js.map → chunk-6GVFKOSH.js.map} +1 -1
- package/dist/{chunk-2KTQ75LN.js → chunk-6KRSBSNT.js} +12 -7
- package/dist/chunk-6KRSBSNT.js.map +1 -0
- package/dist/{chunk-246OJILS.cjs → chunk-7DQXFTA7.cjs} +4 -4
- package/dist/{chunk-246OJILS.cjs.map → chunk-7DQXFTA7.cjs.map} +1 -1
- package/dist/{chunk-YLG7S4SM.cjs → chunk-7ZABGRZZ.cjs} +5 -5
- package/dist/{chunk-YLG7S4SM.cjs.map → chunk-7ZABGRZZ.cjs.map} +1 -1
- package/dist/{chunk-YFPDZVB7.cjs → chunk-AQENURKO.cjs} +4 -4
- package/dist/{chunk-YFPDZVB7.cjs.map → chunk-AQENURKO.cjs.map} +1 -1
- package/dist/{chunk-OGF7QM74.cjs → chunk-AWUUGDN4.cjs} +4 -4
- package/dist/{chunk-OGF7QM74.cjs.map → chunk-AWUUGDN4.cjs.map} +1 -1
- package/dist/{chunk-ZRFKIERV.js → chunk-BGFKTJBZ.js} +3 -3
- package/dist/{chunk-ZRFKIERV.js.map → chunk-BGFKTJBZ.js.map} +1 -1
- package/dist/{chunk-F5RYWDWO.cjs → chunk-CYBBBBMZ.cjs} +4 -4
- package/dist/{chunk-F5RYWDWO.cjs.map → chunk-CYBBBBMZ.cjs.map} +1 -1
- package/dist/{chunk-QC2RICQ4.cjs → chunk-F3JYKM6M.cjs} +4 -4
- package/dist/{chunk-QC2RICQ4.cjs.map → chunk-F3JYKM6M.cjs.map} +1 -1
- package/dist/{chunk-NB7MFQCZ.js → chunk-HZTHSNUN.js} +3 -3
- package/dist/{chunk-NB7MFQCZ.js.map → chunk-HZTHSNUN.js.map} +1 -1
- package/dist/{chunk-W4UVDMUC.js → chunk-I7UYVCKH.js} +3 -3
- package/dist/{chunk-W4UVDMUC.js.map → chunk-I7UYVCKH.js.map} +1 -1
- package/dist/{chunk-HIWJMJJB.js → chunk-ITNCO3MZ.js} +3 -3
- package/dist/{chunk-HIWJMJJB.js.map → chunk-ITNCO3MZ.js.map} +1 -1
- package/dist/{chunk-JLLDJCLW.js → chunk-JG5CVYXC.js} +63 -15
- package/dist/{chunk-JLLDJCLW.js.map → chunk-JG5CVYXC.js.map} +1 -1
- package/dist/{chunk-AETIGJXP.js → chunk-KWY52MLQ.js} +3 -3
- package/dist/{chunk-AETIGJXP.js.map → chunk-KWY52MLQ.js.map} +1 -1
- package/dist/{chunk-DLXDR2E7.cjs → chunk-TIHHISCK.cjs} +4 -4
- package/dist/{chunk-DLXDR2E7.cjs.map → chunk-TIHHISCK.cjs.map} +1 -1
- package/dist/{chunk-GTCGATOL.cjs → chunk-US4QZ7J7.cjs} +4 -4
- package/dist/{chunk-GTCGATOL.cjs.map → chunk-US4QZ7J7.cjs.map} +1 -1
- package/dist/{chunk-MGMR6V6N.cjs → chunk-V5TY3N2W.cjs} +74 -26
- package/dist/chunk-V5TY3N2W.cjs.map +1 -0
- package/dist/diagrams/circuit/index.cjs +8 -8
- package/dist/diagrams/circuit/index.js +1 -1
- package/dist/diagrams/ecomap/index.cjs +7 -7
- package/dist/diagrams/ecomap/index.js +2 -2
- package/dist/diagrams/fishbone/index.cjs +8 -8
- package/dist/diagrams/fishbone/index.js +2 -2
- package/dist/diagrams/flowchart/index.cjs +8 -8
- package/dist/diagrams/flowchart/index.js +2 -2
- package/dist/diagrams/genogram/index.cjs +9 -9
- package/dist/diagrams/genogram/index.js +2 -2
- package/dist/diagrams/ladder/index.cjs +6 -6
- package/dist/diagrams/ladder/index.js +2 -2
- package/dist/diagrams/pedigree/index.cjs +7 -7
- package/dist/diagrams/pedigree/index.js +2 -2
- package/dist/diagrams/sld/index.cjs +8 -8
- package/dist/diagrams/sld/index.js +2 -2
- package/dist/index.cjs +60 -60
- package/dist/index.js +14 -14
- package/dist/react.cjs +11 -11
- package/dist/react.js +10 -10
- package/package.json +1 -1
- package/dist/chunk-2KTQ75LN.js.map +0 -1
- package/dist/chunk-32LOZTNP.js.map +0 -1
- package/dist/chunk-3KRL2EGN.cjs.map +0 -1
- package/dist/chunk-HEGDKO2E.cjs.map +0 -1
- package/dist/chunk-MGMR6V6N.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3TGOOZ36_cjs = require('./chunk-3TGOOZ36.cjs');
|
|
4
4
|
var chunkSBB6C4OP_cjs = require('./chunk-SBB6C4OP.cjs');
|
|
5
5
|
var chunk7OOUU6BL_cjs = require('./chunk-7OOUU6BL.cjs');
|
|
6
6
|
var chunkVHDSPI6A_cjs = require('./chunk-VHDSPI6A.cjs');
|
|
@@ -781,7 +781,7 @@ function renderLadder(ast, config) {
|
|
|
781
781
|
var ladder = {
|
|
782
782
|
type: "ladder",
|
|
783
783
|
detect(text2) {
|
|
784
|
-
const first =
|
|
784
|
+
const first = chunk3TGOOZ36_cjs.firstContentLine(text2)?.toLowerCase() ?? "";
|
|
785
785
|
return first.startsWith("ladder");
|
|
786
786
|
},
|
|
787
787
|
parse: parseLadderDSL,
|
|
@@ -795,5 +795,5 @@ exports.ladder = ladder;
|
|
|
795
795
|
exports.layoutLadder = layoutLadder;
|
|
796
796
|
exports.parseLadderDSL = parseLadderDSL;
|
|
797
797
|
exports.renderLadder = renderLadder;
|
|
798
|
-
//# sourceMappingURL=chunk-
|
|
799
|
-
//# sourceMappingURL=chunk-
|
|
798
|
+
//# sourceMappingURL=chunk-US4QZ7J7.cjs.map
|
|
799
|
+
//# sourceMappingURL=chunk-US4QZ7J7.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/diagrams/ladder/parser.ts","../src/diagrams/ladder/layout.ts","../src/diagrams/ladder/renderer.ts","../src/diagrams/ladder/index.ts"],"names":["didYouMean","text","title","matchQuotedTitle","el","w","h","slot","nx","ny","id","LINE_H","group","path","resolveIndustrialTheme","desc","svgRoot","firstContentLine"],"mappings":";;;;;;;;;AAeO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EAC1C,WAAA,CACE,OAAA,EACO,IAAA,EACA,MAAA,EACA,MAAA,EACP;AACA,IAAA,KAAA,CAAM,SAAS,MAAA,GAAY,CAAA,KAAA,EAAQ,IAAI,CAAA,EAAA,EAAK,OAAO,KAAK,OAAO,CAAA;AAJxD,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd;AAAA,EANS,IAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAKX,CA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CAAOA,OAAc,MAAA,EAAgB;AACnC,IAAA,MAAM,GAAA,GAAM,eAAeA,KAAI,CAAA;AAC/B,IAAA,OAAO,YAAA,CAAa,KAAK,MAAM,CAAA;AAAA,EACjC;AACF","file":"chunk-GTCGATOL.cjs","sourcesContent":["import type {\n LadderAST,\n LadderRung,\n LadderElement,\n LadderBranch,\n LadderContact,\n LadderCoil,\n LadderFunctionBlock,\n LadderContactType,\n LadderCoilType,\n LadderFBType,\n} from \"../../core/types\";\nimport { matchQuotedTitle } from \"../../core/quotes\";\nimport { didYouMean } from \"../../core/dsl-suggest\";\n\nexport class LadderParseError extends Error {\n constructor(\n message: string,\n public line?: number,\n public column?: number,\n public source?: string\n ) {\n super(line !== undefined ? `Line ${line}: ${message}` : message);\n this.name = \"LadderParseError\";\n }\n}\n\nconst CONTACT_TYPES = new Set<LadderContactType>([\"XIC\", \"XIO\", \"ONS\", \"OSF\"]);\n// IEC 61131-3 §6.7 coil types + Rockwell/Allen-Bradley extensions.\n// OTE/OTL/OTU/OTN — output energize / latch / unlatch / not (IEC + AB)\n// RES — counter / timer reset (AB convention; IEC writes `R` on\n// a reset rung). Visually a coil with `R` inscribed.\nconst COIL_TYPES = new Set<LadderCoilType>([\"OTE\", \"OTL\", \"OTU\", \"OTN\", \"RES\"]);\nconst FB_TYPES = new Set<LadderFBType>([\n \"TON\", \"TOFF\", \"TP\",\n \"CTU\", \"CTD\", \"CTUD\",\n \"ADD\", \"SUB\", \"MUL\", \"DIV\",\n \"MOV\",\n \"EQU\", \"NEQ\", \"GRT\", \"LES\", \"GEQ\", \"LEQ\",\n]);\n\nconst ALL_ELEMENT_TYPES: string[] = [\n ...CONTACT_TYPES,\n ...COIL_TYPES,\n ...FB_TYPES,\n];\n\n/** Split comma-separated args respecting quoted strings. */\nfunction splitArgs(s: string): string[] {\n const out: string[] = [];\n let cur = \"\";\n let inQuote = false;\n for (const ch of s) {\n if (ch === '\"') inQuote = !inQuote;\n if (ch === \",\" && !inQuote) {\n out.push(cur.trim());\n cur = \"\";\n } else {\n cur += ch;\n }\n }\n if (cur.trim()) out.push(cur.trim());\n return out;\n}\n\nfunction stripQuotes(v: string): string {\n const t = v.trim();\n if (t.startsWith('\"') && t.endsWith('\"')) return t.slice(1, -1);\n return t;\n}\n\n/**\n * Split an element line into op + inner-arg-string, walking paren depth and\n * respecting double-quoted regions. Replaces the old `^OP\\s*\\(([^)]*)\\)\\s*$`\n * regex which broke on quoted names that themselves contained parens — e.g.\n * `XIC(SENSOR, name=\"الحساس (صغير)\")` would terminate at the inner `)`.\n */\nfunction splitOpAndArgs(line: string): { op: string; inside: string } | null {\n const opMatch = line.match(/^([A-Z][A-Z0-9_]*)\\s*\\(/);\n if (!opMatch) return null;\n const op = opMatch[1]!;\n const start = opMatch[0]!.length;\n let depth = 1;\n let inQuote = false;\n let end = -1;\n for (let i = start; i < line.length; i++) {\n const ch = line[i]!;\n if (ch === '\"' && line[i - 1] !== \"\\\\\") {\n inQuote = !inQuote;\n continue;\n }\n if (inQuote) continue;\n if (ch === \"(\") depth++;\n else if (ch === \")\") {\n depth--;\n if (depth === 0) {\n end = i;\n break;\n }\n }\n }\n if (end < 0) return null;\n // Trailing chars after the closing `)` are only allowed if blank.\n if (line.slice(end + 1).trim() !== \"\") return null;\n return { op, inside: line.slice(start, end) };\n}\n\n/** Parse one element line, e.g. XIC(START), TON(T1, PT=5000), OTE(MOTOR). */\nfunction parseElement(line: string, lineNo: number): LadderElement {\n const m = splitOpAndArgs(line);\n if (!m) {\n throw new LadderParseError(`invalid element syntax: ${line}`, lineNo, undefined, line);\n }\n const op = m.op;\n const args = splitArgs(m.inside);\n if (args.length === 0 || !args[0]) {\n throw new LadderParseError(`element missing tag: ${line}`, lineNo, undefined, line);\n }\n const tag = args[0];\n\n if (CONTACT_TYPES.has(op as LadderContactType)) {\n const contact: LadderContact = {\n elementType: \"contact\",\n contactType: op as LadderContactType,\n tag,\n };\n // optional address as second positional or address=...\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const key = kv[1].toLowerCase();\n if (key === \"address\") contact.address = stripQuotes(kv[2]);\n else if (key === \"name\") contact.name = stripQuotes(kv[2]);\n } else {\n contact.address = stripQuotes(a);\n }\n }\n return contact;\n }\n\n if (COIL_TYPES.has(op as LadderCoilType)) {\n const coil: LadderCoil = {\n elementType: \"coil\",\n coilType: op as LadderCoilType,\n tag,\n };\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const key = kv[1].toLowerCase();\n if (key === \"address\") coil.address = stripQuotes(kv[2]);\n else if (key === \"name\") coil.name = stripQuotes(kv[2]);\n } else {\n coil.address = stripQuotes(a);\n }\n }\n return coil;\n }\n\n if (FB_TYPES.has(op as LadderFBType)) {\n const params: Record<string, string | number> = {};\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const v = stripQuotes(kv[2]);\n const n = Number(v);\n params[kv[1]] = Number.isFinite(n) && v !== \"\" && /^-?\\d+(\\.\\d+)?$/.test(v) ? n : v;\n }\n }\n const fb: LadderFunctionBlock = {\n elementType: \"function_block\",\n fbType: op as LadderFBType,\n tag,\n params,\n };\n return fb;\n }\n\n throw new LadderParseError(\n `unknown element type \"${op}\"${didYouMean(op, ALL_ELEMENT_TYPES)}`,\n lineNo,\n undefined,\n line\n );\n}\n\nexport function parseLadderDSL(text: string): LadderAST {\n const rawLines = text.split(\"\\n\").map((l) => l.replace(/\\r$/, \"\"));\n let title: string | undefined;\n const rungs: LadderRung[] = [];\n\n let currentRung: LadderRung | null = null;\n let currentParallel: LadderBranch[] | null = null;\n let currentBranch: LadderBranch | null = null;\n let parallelIndent = -1;\n let branchIndent = -1;\n\n function finishParallel() {\n if (currentRung && currentParallel) {\n currentRung.elements.push({ parallel: currentParallel });\n }\n currentParallel = null;\n currentBranch = null;\n parallelIndent = -1;\n branchIndent = -1;\n }\n\n for (let i = 0; i < rawLines.length; i++) {\n const raw = rawLines[i];\n const lineNo = i + 1;\n // Strip `#`, `//`, or Mermaid `%%` line comments. Quote-awareness is\n // overkill here: ladder lines don't carry URL-shaped attributes, and\n // a literal `#` inside a quoted PLC tag is exceedingly rare.\n const stripped = raw.replace(/(#|\\/\\/|%%).*$/, \"\");\n if (!stripped.trim()) continue;\n\n // indentation = count of leading spaces/tabs (tab = 2)\n let indent = 0;\n for (const ch of stripped) {\n if (ch === \" \") indent++;\n else if (ch === \"\\t\") indent += 2;\n else break;\n }\n const line = stripped.trim();\n\n // Header: ladder \"title\"\n if (/^ladder\\b/i.test(line)) {\n const t = matchQuotedTitle(line);\n if (t !== undefined) title = t;\n continue;\n }\n\n // Rung: `rung N \"comment\":` — the trailing colon is optional, since LLMs\n // routinely emit `rung 1` without it (Mermaid never uses a colon here, so\n // it's not in the training data). The optional quoted comment is unchanged.\n const rungMatch = line.match(/^rung\\s+(\\d+)(?:\\s+\"([^\"]*)\")?\\s*:?\\s*$/i);\n if (rungMatch) {\n finishParallel();\n if (currentRung) {\n if (currentRung.elements.length === 0) {\n throw new LadderParseError(`Rung ${currentRung.number}: empty rung`);\n }\n rungs.push(currentRung);\n }\n currentRung = {\n number: Number(rungMatch[1]),\n comment: rungMatch[2],\n elements: [],\n };\n continue;\n }\n\n if (!currentRung) {\n throw new LadderParseError(`element outside of rung: ${line}`, lineNo, undefined, line);\n }\n\n // parallel:\n if (/^parallel\\s*:\\s*$/i.test(line)) {\n finishParallel();\n currentParallel = [];\n parallelIndent = indent;\n continue;\n }\n\n // branch:\n if (/^branch\\s*:\\s*$/i.test(line)) {\n if (!currentParallel) {\n throw new LadderParseError(`branch: without parallel:`, lineNo, undefined, line);\n }\n currentBranch = { elements: [] };\n currentParallel.push(currentBranch);\n branchIndent = indent;\n continue;\n }\n\n // If we're in a parallel block but indent fell back, close it.\n if (currentParallel && indent <= parallelIndent) {\n finishParallel();\n }\n\n const element = parseElement(line, lineNo);\n\n if (currentParallel && currentBranch && indent > branchIndent) {\n currentBranch.elements.push(element);\n } else {\n if (currentParallel) finishParallel();\n currentRung.elements.push(element);\n }\n }\n\n finishParallel();\n if (currentRung) {\n if (currentRung.elements.length === 0) {\n throw new LadderParseError(`Rung ${currentRung.number}: empty rung`);\n }\n rungs.push(currentRung);\n }\n\n if (rungs.length === 0) {\n throw new LadderParseError(\"Ladder diagram has no rungs\");\n }\n\n return { type: \"ladder\", title, rungs };\n}\n","import type {\n LadderAST,\n LadderRung,\n LadderElement,\n LadderBranch,\n} from \"../../core/types\";\n\nexport const LEFT_RAIL_X = 60;\nexport const RIGHT_RAIL_MARGIN = 30;\nexport const BASE_RUNG_HEIGHT = 100;\nexport const ELEMENT_WIDTH = 32;\nexport const ELEMENT_HEIGHT = 24;\nexport const FB_WIDTH = 80;\nexport const FB_HEIGHT = 56;\nexport const CMP_WIDTH = 56;\nexport const CMP_HEIGHT = 34;\nexport const RUNG_Y_OFFSET = 70;\nexport const H_SPACING = 16;\nexport const PARALLEL_GAP = 14;\nexport const CANVAS_PADDING = 30;\n\n/** Rough chars → pixels for 9px font */\nconst CHAR_W = 6.1;\nconst LINE_H = 11;\n\nexport type LadderElementKind =\n | \"contact\"\n | \"coil\"\n | \"function_block\"\n | \"compare\";\n\nexport interface LadderLayoutNode {\n id: string;\n rungIndex: number;\n element: LadderElement;\n kind: LadderElementKind;\n /** x of the element body (left edge) */\n x: number;\n /** y of the element body (top edge) */\n y: number;\n width: number;\n height: number;\n /** rung centerline Y (where wires attach) */\n rungY: number;\n}\n\nexport interface LadderLayoutWire {\n path: string;\n}\n\nexport interface LadderLayoutRung {\n rung: LadderRung;\n index: number;\n y: number;\n /** Rightmost x reached by elements on this rung. */\n endX: number;\n /** Rung slot total height (used for spacing). */\n height: number;\n /** Total pixel height reserved above rungY for name/tag labels. */\n headerHeight: number;\n}\n\nexport interface LadderLayoutResult {\n width: number;\n height: number;\n leftRailX: number;\n rightRailX: number;\n rungs: LadderLayoutRung[];\n nodes: LadderLayoutNode[];\n wires: LadderLayoutWire[];\n}\n\nconst COMPARE_TYPES = new Set([\"EQU\", \"NEQ\", \"GRT\", \"LES\", \"GEQ\", \"LEQ\"]);\n\nfunction bodyWidth(el: LadderElement): number {\n if (el.elementType === \"function_block\") {\n if (COMPARE_TYPES.has(el.fbType)) return CMP_WIDTH;\n return FB_WIDTH;\n }\n return ELEMENT_WIDTH;\n}\n\nfunction bodyHeight(el: LadderElement): number {\n if (el.elementType === \"function_block\") {\n if (COMPARE_TYPES.has(el.fbType)) return CMP_HEIGHT;\n return FB_HEIGHT;\n }\n return ELEMENT_HEIGHT;\n}\n\nfunction elementKind(el: LadderElement): LadderElementKind {\n if (el.elementType === \"contact\") return \"contact\";\n if (el.elementType === \"coil\") return \"coil\";\n if (COMPARE_TYPES.has(el.fbType)) return \"compare\";\n return \"function_block\";\n}\n\n/** Wrap a long description into lines of ~13 chars without splitting words. */\nexport function wrapName(name: string, maxChars = 14): string[] {\n const words = name.split(/\\s+/);\n const lines: string[] = [];\n let cur = \"\";\n for (const w of words) {\n const trial = cur ? `${cur} ${w}` : w;\n if (trial.length > maxChars && cur) {\n lines.push(cur);\n cur = w;\n } else {\n cur = trial;\n }\n }\n if (cur) lines.push(cur);\n return lines.slice(0, 3);\n}\n\nfunction labelLinesForContactOrCoil(el: LadderElement): string[] {\n if (el.elementType === \"function_block\") return [el.tag];\n const lines: string[] = [];\n if (el.name) lines.push(...wrapName(el.name));\n lines.push(el.tag);\n if (el.address) lines.push(el.address);\n return lines;\n}\n\n/** Max label width in px across all label lines of the element. */\nfunction labelWidth(el: LadderElement): number {\n const lines = labelLinesForContactOrCoil(el);\n let maxChars = 0;\n for (const l of lines) if (l.length > maxChars) maxChars = l.length;\n return maxChars * CHAR_W;\n}\n\n/** Slot width = max(bodyWidth, labelWidth) + padding on both sides. */\nfunction slotWidth(el: LadderElement): number {\n return Math.max(bodyWidth(el), labelWidth(el)) + 6;\n}\n\n/** Total label rows above the element body (name lines + tag). */\nfunction labelRowsAbove(el: LadderElement): number {\n if (el.elementType === \"function_block\") return 1;\n const name = el.name ? wrapName(el.name).length : 0;\n return name + 1; // + tag line\n}\n\nfunction labelRowsBelow(el: LadderElement): number {\n if (el.elementType === \"function_block\") return 0;\n if ((el as { address?: string }).address) return 1;\n return 0;\n}\n\n/** Required vertical pixels above rung centerline for tallest element label stack. */\nfunction rungLabelHeaderHeight(rung: LadderRung): number {\n let maxAbovePx = 0;\n for (const item of rung.elements) {\n if (\"parallel\" in item) {\n const ph = parallelHeight(item.parallel);\n // Only the top-branch elements extend above the centerline.\n const topBranch = item.parallel[0];\n if (!topBranch) continue;\n const aboveRows = Math.max(\n 1,\n ...topBranch.elements.map((e) => labelRowsAbove(e))\n );\n const px = ph / 2 + aboveRows * LINE_H + 4;\n if (px > maxAbovePx) maxAbovePx = px;\n } else {\n const rows = labelRowsAbove(item);\n const px = bodyHeight(item) / 2 + rows * LINE_H + 4;\n if (px > maxAbovePx) maxAbovePx = px;\n }\n }\n return maxAbovePx;\n}\n\nfunction rungLabelFooterHeight(rung: LadderRung): number {\n let maxBelowPx = 0;\n for (const item of rung.elements) {\n if (\"parallel\" in item) {\n const ph = parallelHeight(item.parallel);\n const bottomBranch = item.parallel[item.parallel.length - 1];\n if (!bottomBranch) continue;\n const belowRows = Math.max(\n 0,\n ...bottomBranch.elements.map((e) => labelRowsBelow(e))\n );\n const px = ph / 2 + belowRows * LINE_H + 4;\n if (px > maxBelowPx) maxBelowPx = px;\n } else {\n const rows = labelRowsBelow(item);\n const px = bodyHeight(item) / 2 + rows * LINE_H + 4;\n if (px > maxBelowPx) maxBelowPx = px;\n }\n }\n return maxBelowPx;\n}\n\nfunction branchInlineWidth(branch: LadderBranch): number {\n if (branch.elements.length === 0) return ELEMENT_WIDTH;\n let w = 0;\n branch.elements.forEach((el, i) => {\n w += slotWidth(el);\n if (i < branch.elements.length - 1) w += H_SPACING;\n });\n return w;\n}\n\nfunction parallelWidth(branches: LadderBranch[]): number {\n const maxBranch = Math.max(\n ELEMENT_WIDTH,\n ...branches.map(branchInlineWidth)\n );\n return maxBranch + 2 * H_SPACING;\n}\n\n/** Per-branch row height including label stack above + below. */\nfunction branchRowHeight(branch: LadderBranch): number {\n const bodyH = Math.max(\n ELEMENT_HEIGHT,\n ...branch.elements.map((e) => bodyHeight(e))\n );\n const above = Math.max(1, ...branch.elements.map((e) => labelRowsAbove(e)));\n const below = Math.max(0, ...branch.elements.map((e) => labelRowsBelow(e)));\n return bodyH + above * LINE_H + below * LINE_H + 6;\n}\n\nfunction parallelHeight(branches: LadderBranch[]): number {\n // Account for label space between branches so name/address rows don't collide.\n let total = 0;\n branches.forEach((br, i) => {\n total += branchRowHeight(br);\n if (i < branches.length - 1) total += PARALLEL_GAP;\n });\n return Math.max(total, ELEMENT_HEIGHT);\n}\n\nexport function layoutLadder(ast: LadderAST): LadderLayoutResult {\n const nodes: LadderLayoutNode[] = [];\n const wires: LadderLayoutWire[] = [];\n const rungs: LadderLayoutRung[] = [];\n\n let maxEndX = LEFT_RAIL_X + 200;\n let cursorY = RUNG_Y_OFFSET;\n\n ast.rungs.forEach((rung, rungIndex) => {\n const headerH = rungLabelHeaderHeight(rung);\n const footerH = rungLabelFooterHeight(rung);\n // Per-rung height is comment (16) + header + footer + a little breathing room.\n const rungHeight = Math.max(BASE_RUNG_HEIGHT, 16 + headerH + footerH + 16);\n const rungY = cursorY + 16 + headerH;\n\n let x = LEFT_RAIL_X + H_SPACING;\n let prevRightX = LEFT_RAIL_X;\n let prevRightY = rungY;\n\n const addWire = (x1: number, y1: number, x2: number, y2: number) => {\n wires.push({ path: `M ${x1} ${y1} L ${x2} ${y2}` });\n };\n\n rung.elements.forEach((item, elIdx) => {\n if (\"parallel\" in item) {\n const branches = item.parallel;\n const pw = parallelWidth(branches);\n const ph = parallelHeight(branches);\n const bx = x;\n const ex = x + pw;\n\n addWire(prevRightX, prevRightY, bx, rungY);\n\n const busTop = rungY - ph / 2;\n const busBot = rungY + ph / 2;\n wires.push({ path: `M ${bx} ${busTop} L ${bx} ${busBot}` });\n wires.push({ path: `M ${ex} ${busTop} L ${ex} ${busBot}` });\n\n // Pre-compute row Y for each branch using actual row heights.\n let rowY = busTop;\n branches.forEach((branch, bIdx) => {\n const rowH = branchRowHeight(branch);\n const bodyMax = Math.max(\n ELEMENT_HEIGHT,\n ...branch.elements.map((e) => bodyHeight(e))\n );\n const above = Math.max(\n 1,\n ...branch.elements.map((e) => labelRowsAbove(e))\n );\n // Position centerline so labels above fit within rowH.\n const branchY = rowY + above * LINE_H + bodyMax / 2;\n const bInline = branchInlineWidth(branch);\n const startX = bx + H_SPACING + ((ex - bx - 2 * H_SPACING) - bInline) / 2;\n let bx0 = startX;\n let prevBX = bx;\n branch.elements.forEach((bel, beIdx) => {\n const w = bodyWidth(bel);\n const h = bodyHeight(bel);\n const slot = slotWidth(bel);\n const nx = bx0 + (slot - w) / 2;\n const ny = branchY - h / 2;\n const id = `R${rung.number}_P${elIdx}_B${bIdx}_E${beIdx}`;\n nodes.push({\n id,\n rungIndex,\n element: bel,\n kind: elementKind(bel),\n x: nx,\n y: ny,\n width: w,\n height: h,\n rungY: branchY,\n });\n addWire(prevBX, branchY, nx, branchY);\n prevBX = nx + w;\n bx0 += slot + H_SPACING;\n });\n addWire(prevBX, branchY, ex, branchY);\n rowY += rowH + PARALLEL_GAP;\n });\n\n prevRightX = ex;\n prevRightY = rungY;\n x = ex + H_SPACING;\n return;\n }\n\n const el = item;\n const w = bodyWidth(el);\n const h = bodyHeight(el);\n const slot = slotWidth(el);\n const nx = x + (slot - w) / 2;\n const ny = rungY - h / 2;\n const id = `R${rung.number}_E${elIdx}`;\n nodes.push({\n id,\n rungIndex,\n element: el,\n kind: elementKind(el),\n x: nx,\n y: ny,\n width: w,\n height: h,\n rungY,\n });\n addWire(prevRightX, prevRightY, nx, rungY);\n prevRightX = nx + w;\n prevRightY = rungY;\n x += slot + H_SPACING;\n });\n\n rungs.push({\n rung,\n index: rungIndex,\n y: rungY,\n endX: prevRightX,\n height: rungHeight,\n headerHeight: headerH,\n });\n if (prevRightX > maxEndX) maxEndX = prevRightX;\n cursorY += rungHeight;\n });\n\n const rightRailX = maxEndX + H_SPACING * 2;\n const width = rightRailX + RIGHT_RAIL_MARGIN;\n const height = cursorY + CANVAS_PADDING;\n\n for (const r of rungs) {\n wires.push({ path: `M ${r.endX} ${r.y} L ${rightRailX} ${r.y}` });\n }\n\n return {\n width,\n height,\n leftRailX: LEFT_RAIL_X,\n rightRailX,\n rungs,\n nodes,\n wires,\n };\n}\n\nexport { labelRowsAbove, labelRowsBelow };\n","import type {\n LadderAST,\n LadderContact,\n LadderCoil,\n LadderFunctionBlock,\n RenderConfig,\n} from \"../../core/types\";\nimport {\n svgRoot,\n group,\n el,\n path as pathEl,\n text,\n title as titleEl,\n desc,\n} from \"../../core/svg\";\nimport { resolveIndustrialTheme, type IndustrialTokens, type ResolvedTheme } from \"../../core/theme\";\nimport { layoutLadder, type LadderLayoutNode, wrapName } from \"./layout\";\n\ntype IT = ResolvedTheme<IndustrialTokens>;\n\nfunction buildCss(t: IT): string {\n return `\n.lt-ladder { font-family: system-ui, -apple-system, sans-serif; }\n.lt-ladder-rail { stroke: ${t.strokeHeavy}; stroke-width: 4; stroke-linecap: square; }\n.lt-ladder-wire { stroke: ${t.stroke}; stroke-width: 1.5; fill: none; }\n.lt-ladder-element { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-ladder-coil { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-ladder-fb { fill: ${t.bg}; stroke: ${t.stroke}; stroke-width: 2; }\n.lt-ladder-fb-name { font: bold 11px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-ladder-pin { font: 8px sans-serif; fill: ${t.stroke}; }\n.lt-ladder-name { font: 9px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-ladder-tag { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: ${t.accent}; text-anchor: middle; }\n.lt-ladder-addr { font: 600 8.5px ui-monospace, monospace; fill: ${t.error}; text-anchor: middle; }\n.lt-ladder-rung-num { font: 10px sans-serif; fill: ${t.textMuted}; text-anchor: end; }\n.lt-ladder-comment { font: italic 10px sans-serif; fill: ${t.textMuted}; }\n.lt-ladder-title { font: 700 16px sans-serif; fill: ${t.text}; }\n.lt-ladder-symbol-label { font: bold 10px sans-serif; fill: ${t.stroke}; text-anchor: middle; }\n`.trim();\n}\n\nconst LINE_H = 11;\n\nfunction labelsAbove(\n name: string | undefined,\n tag: string,\n cx: number,\n bodyTopY: number\n): string[] {\n const pieces: string[] = [];\n const nameLines = name ? wrapName(name) : [];\n const totalLines = nameLines.length + 1; // +1 for tag\n const firstY = bodyTopY - 4 - (totalLines - 1) * LINE_H;\n nameLines.forEach((line, i) => {\n pieces.push(\n text({ x: cx, y: firstY + i * LINE_H, class: \"lt-ladder-name\" }, line)\n );\n });\n pieces.push(\n text(\n { x: cx, y: firstY + nameLines.length * LINE_H, class: \"lt-ladder-tag\" },\n tag\n )\n );\n return pieces;\n}\n\nfunction renderContact(node: LadderLayoutNode): string {\n const c = node.element as LadderContact;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const leftBarX = x + 4;\n const rightBarX = x + w - 4;\n const cx = x + w / 2;\n const pieces: string[] = [];\n pieces.push(el(\"line\", { x1: x, y1: cy, x2: leftBarX, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: rightBarX, y1: cy, x2: x + w, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: leftBarX, y1: y, x2: leftBarX, y2: y + h, class: \"lt-ladder-element\" }));\n pieces.push(el(\"line\", { x1: rightBarX, y1: y, x2: rightBarX, y2: y + h, class: \"lt-ladder-element\" }));\n\n if (c.contactType === \"XIO\") {\n pieces.push(\n el(\"line\", {\n x1: leftBarX + 2,\n y1: y + h - 2,\n x2: rightBarX - 2,\n y2: y + 2,\n class: \"lt-ladder-element\",\n })\n );\n } else if (c.contactType === \"ONS\") {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, \"↑\"));\n } else if (c.contactType === \"OSF\") {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, \"↓\"));\n }\n\n pieces.push(...labelsAbove(c.name, c.tag, cx, y));\n if (c.address) {\n pieces.push(\n text({ x: cx, y: y + h + 10, class: \"lt-ladder-addr\" }, c.address)\n );\n }\n return group({ \"data-element\": \"contact\", \"data-tag\": c.tag }, pieces);\n}\n\nfunction renderCoil(node: LadderLayoutNode): string {\n const c = node.element as LadderCoil;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n const leftArc = `M ${x + 6} ${y} A 10 ${h / 2} 0 0 0 ${x + 6} ${y + h}`;\n const rightArc = `M ${x + w - 6} ${y} A 10 ${h / 2} 0 0 1 ${x + w - 6} ${y + h}`;\n pieces.push(pathEl({ d: leftArc, class: \"lt-ladder-coil\" }));\n pieces.push(pathEl({ d: rightArc, class: \"lt-ladder-coil\" }));\n pieces.push(el(\"line\", { x1: x, y1: cy, x2: x + 6, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: x + w - 6, y1: cy, x2: x + w, y2: cy, class: \"lt-ladder-wire\" }));\n\n let inner = \"\";\n if (c.coilType === \"OTL\") inner = \"S\";\n else if (c.coilType === \"OTU\") inner = \"R\";\n else if (c.coilType === \"OTN\") inner = \"/\";\n else if (c.coilType === \"RES\") inner = \"R\";\n if (inner) {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, inner));\n }\n\n pieces.push(...labelsAbove(c.name, c.tag, cx, y));\n if (c.address) {\n pieces.push(\n text({ x: cx, y: y + h + 10, class: \"lt-ladder-addr\" }, c.address)\n );\n }\n return group({ \"data-element\": \"coil\", \"data-tag\": c.tag }, pieces);\n}\n\nfunction renderCompare(node: LadderLayoutNode): string {\n const fb = node.element as LadderFunctionBlock;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n pieces.push(el(\"rect\", { x, y, width: w, height: h, class: \"lt-ladder-fb\" }));\n pieces.push(text({ x: cx, y: y + 12, class: \"lt-ladder-fb-name\" }, fb.fbType));\n const entries = Object.entries(fb.params);\n entries.slice(0, 2).forEach(([k, v], i) => {\n pieces.push(\n text({ x: x + 4, y: y + 22 + i * 9, class: \"lt-ladder-pin\" }, `${k}:${v}`)\n );\n });\n pieces.push(el(\"line\", { x1: x - 2, y1: cy, x2: x, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: x + w, y1: cy, x2: x + w + 2, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(text({ x: cx, y: y - 4, class: \"lt-ladder-tag\" }, fb.tag));\n return group({ \"data-element\": \"compare\", \"data-tag\": fb.tag }, pieces);\n}\n\nfunction renderFunctionBlock(node: LadderLayoutNode): string {\n const fb = node.element as LadderFunctionBlock;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n\n pieces.push(el(\"rect\", { x, y, width: w, height: h, class: \"lt-ladder-fb\" }));\n pieces.push(text({ x: cx, y: y + 14, class: \"lt-ladder-fb-name\" }, fb.fbType));\n\n pieces.push(\n el(\"line\", { x1: x - 6, y1: cy, x2: x, y2: cy, class: \"lt-ladder-wire\" })\n );\n pieces.push(\n el(\"line\", { x1: x + w, y1: cy, x2: x + w + 6, y2: cy, class: \"lt-ladder-wire\" })\n );\n\n const entries = Object.entries(fb.params);\n entries.slice(0, 3).forEach(([k, v], i) => {\n pieces.push(\n text({ x: x + 4, y: y + 28 + i * 9, class: \"lt-ladder-pin\" }, `${k}=${v}`)\n );\n });\n\n pieces.push(text({ x: cx, y: y - 4, class: \"lt-ladder-tag\" }, fb.tag));\n return group({ \"data-element\": \"function_block\", \"data-tag\": fb.tag }, pieces);\n}\n\nfunction renderNode(node: LadderLayoutNode): string {\n switch (node.kind) {\n case \"contact\":\n return renderContact(node);\n case \"coil\":\n return renderCoil(node);\n case \"compare\":\n return renderCompare(node);\n case \"function_block\":\n return renderFunctionBlock(node);\n }\n}\n\nexport function renderLadder(ast: LadderAST, config?: RenderConfig): string {\n const layout = layoutLadder(ast);\n const t = resolveIndustrialTheme(config?.theme ?? \"default\");\n const titleOffset = ast.title ? 30 : 0;\n const width = layout.width;\n const height = layout.height + titleOffset;\n\n const children: string[] = [];\n children.push(titleEl(ast.title ?? \"Ladder Logic\"));\n children.push(\n desc(`PLC ladder logic diagram with ${ast.rungs.length} rung${ast.rungs.length === 1 ? \"\" : \"s\"}`)\n );\n children.push(el(\"style\", {}, buildCss(t)));\n\n if (ast.title) {\n children.push(\n text({ x: width / 2, y: 20, class: \"lt-ladder-title\", \"text-anchor\": \"middle\" }, ast.title)\n );\n }\n\n const inner: string[] = [];\n\n inner.push(\n el(\"line\", {\n x1: layout.leftRailX,\n y1: 0,\n x2: layout.leftRailX,\n y2: layout.height,\n class: \"lt-ladder-rail\",\n })\n );\n inner.push(\n el(\"line\", {\n x1: layout.rightRailX,\n y1: 0,\n x2: layout.rightRailX,\n y2: layout.height,\n class: \"lt-ladder-rail\",\n })\n );\n\n for (const r of layout.rungs) {\n inner.push(\n text(\n { x: layout.leftRailX - 6, y: r.y + 3, class: \"lt-ladder-rung-num\" },\n `Rung ${String(r.rung.number).padStart(3, \"0\")}`\n )\n );\n if (r.rung.comment) {\n // Place comment above the tallest element label on this rung (and above the parallel bus if any).\n const commentY = Math.max(14, r.y - (r.headerHeight + 6));\n inner.push(\n text(\n {\n x: layout.leftRailX + 10,\n y: commentY,\n class: \"lt-ladder-comment\",\n },\n `— ${r.rung.comment} —`\n )\n );\n }\n }\n\n for (const w of layout.wires) {\n inner.push(pathEl({ d: w.path, class: \"lt-ladder-wire\" }));\n }\n\n for (const n of layout.nodes) {\n inner.push(renderNode(n));\n }\n\n const wrap = group({ transform: `translate(0, ${titleOffset})` }, inner);\n children.push(wrap);\n\n return svgRoot(\n {\n class: \"lt-ladder\",\n role: \"img\",\n \"aria-labelledby\": \"lt-ladder-title lt-ladder-desc\",\n width,\n height,\n viewBox: `0 0 ${width} ${height}`,\n },\n children\n );\n}\n","import type { DiagramPlugin } from \"../../core/types\";\nimport { firstContentLine } from \"../../core/dsl-preprocess\";\nimport { parseLadderDSL } from \"./parser\";\nimport { renderLadder } from \"./renderer\";\n\nexport const ladder: DiagramPlugin = {\n type: \"ladder\",\n detect(text: string): boolean {\n const first = firstContentLine(text)?.toLowerCase() ?? \"\";\n return first.startsWith(\"ladder\");\n },\n parse: parseLadderDSL,\n\n render(text: string, config): string {\n const ast = parseLadderDSL(text);\n return renderLadder(ast, config);\n },\n};\n\nexport { parseLadderDSL } from \"./parser\";\nexport { renderLadder } from \"./renderer\";\nexport { layoutLadder } from \"./layout\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/diagrams/ladder/parser.ts","../src/diagrams/ladder/layout.ts","../src/diagrams/ladder/renderer.ts","../src/diagrams/ladder/index.ts"],"names":["didYouMean","text","title","matchQuotedTitle","el","w","h","slot","nx","ny","id","LINE_H","group","path","resolveIndustrialTheme","desc","svgRoot","firstContentLine"],"mappings":";;;;;;;;;AAeO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EAC1C,WAAA,CACE,OAAA,EACO,IAAA,EACA,MAAA,EACA,MAAA,EACP;AACA,IAAA,KAAA,CAAM,SAAS,MAAA,GAAY,CAAA,KAAA,EAAQ,IAAI,CAAA,EAAA,EAAK,OAAO,KAAK,OAAO,CAAA;AAJxD,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AACA,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAA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;AAAA,EAClC,CAAA;AAAA,EACA,KAAA,EAAO,cAAA;AAAA,EAEP,MAAA,CAAOA,OAAc,MAAA,EAAgB;AACnC,IAAA,MAAM,GAAA,GAAM,eAAeA,KAAI,CAAA;AAC/B,IAAA,OAAO,YAAA,CAAa,KAAK,MAAM,CAAA;AAAA,EACjC;AACF","file":"chunk-US4QZ7J7.cjs","sourcesContent":["import type {\n LadderAST,\n LadderRung,\n LadderElement,\n LadderBranch,\n LadderContact,\n LadderCoil,\n LadderFunctionBlock,\n LadderContactType,\n LadderCoilType,\n LadderFBType,\n} from \"../../core/types\";\nimport { matchQuotedTitle } from \"../../core/quotes\";\nimport { didYouMean } from \"../../core/dsl-suggest\";\n\nexport class LadderParseError extends Error {\n constructor(\n message: string,\n public line?: number,\n public column?: number,\n public source?: string\n ) {\n super(line !== undefined ? `Line ${line}: ${message}` : message);\n this.name = \"LadderParseError\";\n }\n}\n\nconst CONTACT_TYPES = new Set<LadderContactType>([\"XIC\", \"XIO\", \"ONS\", \"OSF\"]);\n// IEC 61131-3 §6.7 coil types + Rockwell/Allen-Bradley extensions.\n// OTE/OTL/OTU/OTN — output energize / latch / unlatch / not (IEC + AB)\n// RES — counter / timer reset (AB convention; IEC writes `R` on\n// a reset rung). Visually a coil with `R` inscribed.\nconst COIL_TYPES = new Set<LadderCoilType>([\"OTE\", \"OTL\", \"OTU\", \"OTN\", \"RES\"]);\nconst FB_TYPES = new Set<LadderFBType>([\n \"TON\", \"TOFF\", \"TP\",\n \"CTU\", \"CTD\", \"CTUD\",\n \"ADD\", \"SUB\", \"MUL\", \"DIV\",\n \"MOV\",\n \"EQU\", \"NEQ\", \"GRT\", \"LES\", \"GEQ\", \"LEQ\",\n]);\n\nconst ALL_ELEMENT_TYPES: string[] = [\n ...CONTACT_TYPES,\n ...COIL_TYPES,\n ...FB_TYPES,\n];\n\n/** Split comma-separated args respecting quoted strings. */\nfunction splitArgs(s: string): string[] {\n const out: string[] = [];\n let cur = \"\";\n let inQuote = false;\n for (const ch of s) {\n if (ch === '\"') inQuote = !inQuote;\n if (ch === \",\" && !inQuote) {\n out.push(cur.trim());\n cur = \"\";\n } else {\n cur += ch;\n }\n }\n if (cur.trim()) out.push(cur.trim());\n return out;\n}\n\nfunction stripQuotes(v: string): string {\n const t = v.trim();\n if (t.startsWith('\"') && t.endsWith('\"')) return t.slice(1, -1);\n return t;\n}\n\n/**\n * Split an element line into op + inner-arg-string, walking paren depth and\n * respecting double-quoted regions. Replaces the old `^OP\\s*\\(([^)]*)\\)\\s*$`\n * regex which broke on quoted names that themselves contained parens — e.g.\n * `XIC(SENSOR, name=\"الحساس (صغير)\")` would terminate at the inner `)`.\n */\nfunction splitOpAndArgs(line: string): { op: string; inside: string } | null {\n const opMatch = line.match(/^([A-Z][A-Z0-9_]*)\\s*\\(/);\n if (!opMatch) return null;\n const op = opMatch[1]!;\n const start = opMatch[0]!.length;\n let depth = 1;\n let inQuote = false;\n let end = -1;\n for (let i = start; i < line.length; i++) {\n const ch = line[i]!;\n if (ch === '\"' && line[i - 1] !== \"\\\\\") {\n inQuote = !inQuote;\n continue;\n }\n if (inQuote) continue;\n if (ch === \"(\") depth++;\n else if (ch === \")\") {\n depth--;\n if (depth === 0) {\n end = i;\n break;\n }\n }\n }\n if (end < 0) return null;\n // Trailing chars after the closing `)` are only allowed if blank.\n if (line.slice(end + 1).trim() !== \"\") return null;\n return { op, inside: line.slice(start, end) };\n}\n\n/** Parse one element line, e.g. XIC(START), TON(T1, PT=5000), OTE(MOTOR). */\nfunction parseElement(line: string, lineNo: number): LadderElement {\n const m = splitOpAndArgs(line);\n if (!m) {\n throw new LadderParseError(`invalid element syntax: ${line}`, lineNo, undefined, line);\n }\n const op = m.op;\n const args = splitArgs(m.inside);\n if (args.length === 0 || !args[0]) {\n throw new LadderParseError(`element missing tag: ${line}`, lineNo, undefined, line);\n }\n const tag = args[0];\n\n if (CONTACT_TYPES.has(op as LadderContactType)) {\n const contact: LadderContact = {\n elementType: \"contact\",\n contactType: op as LadderContactType,\n tag,\n };\n // optional address as second positional or address=...\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const key = kv[1].toLowerCase();\n if (key === \"address\") contact.address = stripQuotes(kv[2]);\n else if (key === \"name\") contact.name = stripQuotes(kv[2]);\n } else {\n contact.address = stripQuotes(a);\n }\n }\n return contact;\n }\n\n if (COIL_TYPES.has(op as LadderCoilType)) {\n const coil: LadderCoil = {\n elementType: \"coil\",\n coilType: op as LadderCoilType,\n tag,\n };\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const key = kv[1].toLowerCase();\n if (key === \"address\") coil.address = stripQuotes(kv[2]);\n else if (key === \"name\") coil.name = stripQuotes(kv[2]);\n } else {\n coil.address = stripQuotes(a);\n }\n }\n return coil;\n }\n\n if (FB_TYPES.has(op as LadderFBType)) {\n const params: Record<string, string | number> = {};\n for (let i = 1; i < args.length; i++) {\n const a = args[i];\n const kv = a.match(/^(\\w+)\\s*=\\s*(.+)$/);\n if (kv) {\n const v = stripQuotes(kv[2]);\n const n = Number(v);\n params[kv[1]] = Number.isFinite(n) && v !== \"\" && /^-?\\d+(\\.\\d+)?$/.test(v) ? n : v;\n }\n }\n const fb: LadderFunctionBlock = {\n elementType: \"function_block\",\n fbType: op as LadderFBType,\n tag,\n params,\n };\n return fb;\n }\n\n throw new LadderParseError(\n `unknown element type \"${op}\"${didYouMean(op, ALL_ELEMENT_TYPES)}`,\n lineNo,\n undefined,\n line\n );\n}\n\nexport function parseLadderDSL(text: string): LadderAST {\n const rawLines = text.split(\"\\n\").map((l) => l.replace(/\\r$/, \"\"));\n let title: string | undefined;\n const rungs: LadderRung[] = [];\n\n let currentRung: LadderRung | null = null;\n let currentParallel: LadderBranch[] | null = null;\n let currentBranch: LadderBranch | null = null;\n let parallelIndent = -1;\n let branchIndent = -1;\n\n function finishParallel() {\n if (currentRung && currentParallel) {\n currentRung.elements.push({ parallel: currentParallel });\n }\n currentParallel = null;\n currentBranch = null;\n parallelIndent = -1;\n branchIndent = -1;\n }\n\n for (let i = 0; i < rawLines.length; i++) {\n const raw = rawLines[i];\n const lineNo = i + 1;\n // Strip `#`, `//`, or Mermaid `%%` line comments. Quote-awareness is\n // overkill here: ladder lines don't carry URL-shaped attributes, and\n // a literal `#` inside a quoted PLC tag is exceedingly rare.\n const stripped = raw.replace(/(#|\\/\\/|%%).*$/, \"\");\n if (!stripped.trim()) continue;\n\n // indentation = count of leading spaces/tabs (tab = 2)\n let indent = 0;\n for (const ch of stripped) {\n if (ch === \" \") indent++;\n else if (ch === \"\\t\") indent += 2;\n else break;\n }\n const line = stripped.trim();\n\n // Header: ladder \"title\"\n if (/^ladder\\b/i.test(line)) {\n const t = matchQuotedTitle(line);\n if (t !== undefined) title = t;\n continue;\n }\n\n // Rung: `rung N \"comment\":` — the trailing colon is optional, since LLMs\n // routinely emit `rung 1` without it (Mermaid never uses a colon here, so\n // it's not in the training data). The optional quoted comment is unchanged.\n const rungMatch = line.match(/^rung\\s+(\\d+)(?:\\s+\"([^\"]*)\")?\\s*:?\\s*$/i);\n if (rungMatch) {\n finishParallel();\n if (currentRung) {\n if (currentRung.elements.length === 0) {\n throw new LadderParseError(`Rung ${currentRung.number}: empty rung`);\n }\n rungs.push(currentRung);\n }\n currentRung = {\n number: Number(rungMatch[1]),\n comment: rungMatch[2],\n elements: [],\n };\n continue;\n }\n\n if (!currentRung) {\n throw new LadderParseError(`element outside of rung: ${line}`, lineNo, undefined, line);\n }\n\n // parallel:\n if (/^parallel\\s*:\\s*$/i.test(line)) {\n finishParallel();\n currentParallel = [];\n parallelIndent = indent;\n continue;\n }\n\n // branch:\n if (/^branch\\s*:\\s*$/i.test(line)) {\n if (!currentParallel) {\n throw new LadderParseError(`branch: without parallel:`, lineNo, undefined, line);\n }\n currentBranch = { elements: [] };\n currentParallel.push(currentBranch);\n branchIndent = indent;\n continue;\n }\n\n // If we're in a parallel block but indent fell back, close it.\n if (currentParallel && indent <= parallelIndent) {\n finishParallel();\n }\n\n const element = parseElement(line, lineNo);\n\n if (currentParallel && currentBranch && indent > branchIndent) {\n currentBranch.elements.push(element);\n } else {\n if (currentParallel) finishParallel();\n currentRung.elements.push(element);\n }\n }\n\n finishParallel();\n if (currentRung) {\n if (currentRung.elements.length === 0) {\n throw new LadderParseError(`Rung ${currentRung.number}: empty rung`);\n }\n rungs.push(currentRung);\n }\n\n if (rungs.length === 0) {\n throw new LadderParseError(\"Ladder diagram has no rungs\");\n }\n\n return { type: \"ladder\", title, rungs };\n}\n","import type {\n LadderAST,\n LadderRung,\n LadderElement,\n LadderBranch,\n} from \"../../core/types\";\n\nexport const LEFT_RAIL_X = 60;\nexport const RIGHT_RAIL_MARGIN = 30;\nexport const BASE_RUNG_HEIGHT = 100;\nexport const ELEMENT_WIDTH = 32;\nexport const ELEMENT_HEIGHT = 24;\nexport const FB_WIDTH = 80;\nexport const FB_HEIGHT = 56;\nexport const CMP_WIDTH = 56;\nexport const CMP_HEIGHT = 34;\nexport const RUNG_Y_OFFSET = 70;\nexport const H_SPACING = 16;\nexport const PARALLEL_GAP = 14;\nexport const CANVAS_PADDING = 30;\n\n/** Rough chars → pixels for 9px font */\nconst CHAR_W = 6.1;\nconst LINE_H = 11;\n\nexport type LadderElementKind =\n | \"contact\"\n | \"coil\"\n | \"function_block\"\n | \"compare\";\n\nexport interface LadderLayoutNode {\n id: string;\n rungIndex: number;\n element: LadderElement;\n kind: LadderElementKind;\n /** x of the element body (left edge) */\n x: number;\n /** y of the element body (top edge) */\n y: number;\n width: number;\n height: number;\n /** rung centerline Y (where wires attach) */\n rungY: number;\n}\n\nexport interface LadderLayoutWire {\n path: string;\n}\n\nexport interface LadderLayoutRung {\n rung: LadderRung;\n index: number;\n y: number;\n /** Rightmost x reached by elements on this rung. */\n endX: number;\n /** Rung slot total height (used for spacing). */\n height: number;\n /** Total pixel height reserved above rungY for name/tag labels. */\n headerHeight: number;\n}\n\nexport interface LadderLayoutResult {\n width: number;\n height: number;\n leftRailX: number;\n rightRailX: number;\n rungs: LadderLayoutRung[];\n nodes: LadderLayoutNode[];\n wires: LadderLayoutWire[];\n}\n\nconst COMPARE_TYPES = new Set([\"EQU\", \"NEQ\", \"GRT\", \"LES\", \"GEQ\", \"LEQ\"]);\n\nfunction bodyWidth(el: LadderElement): number {\n if (el.elementType === \"function_block\") {\n if (COMPARE_TYPES.has(el.fbType)) return CMP_WIDTH;\n return FB_WIDTH;\n }\n return ELEMENT_WIDTH;\n}\n\nfunction bodyHeight(el: LadderElement): number {\n if (el.elementType === \"function_block\") {\n if (COMPARE_TYPES.has(el.fbType)) return CMP_HEIGHT;\n return FB_HEIGHT;\n }\n return ELEMENT_HEIGHT;\n}\n\nfunction elementKind(el: LadderElement): LadderElementKind {\n if (el.elementType === \"contact\") return \"contact\";\n if (el.elementType === \"coil\") return \"coil\";\n if (COMPARE_TYPES.has(el.fbType)) return \"compare\";\n return \"function_block\";\n}\n\n/** Wrap a long description into lines of ~13 chars without splitting words. */\nexport function wrapName(name: string, maxChars = 14): string[] {\n const words = name.split(/\\s+/);\n const lines: string[] = [];\n let cur = \"\";\n for (const w of words) {\n const trial = cur ? `${cur} ${w}` : w;\n if (trial.length > maxChars && cur) {\n lines.push(cur);\n cur = w;\n } else {\n cur = trial;\n }\n }\n if (cur) lines.push(cur);\n return lines.slice(0, 3);\n}\n\nfunction labelLinesForContactOrCoil(el: LadderElement): string[] {\n if (el.elementType === \"function_block\") return [el.tag];\n const lines: string[] = [];\n if (el.name) lines.push(...wrapName(el.name));\n lines.push(el.tag);\n if (el.address) lines.push(el.address);\n return lines;\n}\n\n/** Max label width in px across all label lines of the element. */\nfunction labelWidth(el: LadderElement): number {\n const lines = labelLinesForContactOrCoil(el);\n let maxChars = 0;\n for (const l of lines) if (l.length > maxChars) maxChars = l.length;\n return maxChars * CHAR_W;\n}\n\n/** Slot width = max(bodyWidth, labelWidth) + padding on both sides. */\nfunction slotWidth(el: LadderElement): number {\n return Math.max(bodyWidth(el), labelWidth(el)) + 6;\n}\n\n/** Total label rows above the element body (name lines + tag). */\nfunction labelRowsAbove(el: LadderElement): number {\n if (el.elementType === \"function_block\") return 1;\n const name = el.name ? wrapName(el.name).length : 0;\n return name + 1; // + tag line\n}\n\nfunction labelRowsBelow(el: LadderElement): number {\n if (el.elementType === \"function_block\") return 0;\n if ((el as { address?: string }).address) return 1;\n return 0;\n}\n\n/** Required vertical pixels above rung centerline for tallest element label stack. */\nfunction rungLabelHeaderHeight(rung: LadderRung): number {\n let maxAbovePx = 0;\n for (const item of rung.elements) {\n if (\"parallel\" in item) {\n const ph = parallelHeight(item.parallel);\n // Only the top-branch elements extend above the centerline.\n const topBranch = item.parallel[0];\n if (!topBranch) continue;\n const aboveRows = Math.max(\n 1,\n ...topBranch.elements.map((e) => labelRowsAbove(e))\n );\n const px = ph / 2 + aboveRows * LINE_H + 4;\n if (px > maxAbovePx) maxAbovePx = px;\n } else {\n const rows = labelRowsAbove(item);\n const px = bodyHeight(item) / 2 + rows * LINE_H + 4;\n if (px > maxAbovePx) maxAbovePx = px;\n }\n }\n return maxAbovePx;\n}\n\nfunction rungLabelFooterHeight(rung: LadderRung): number {\n let maxBelowPx = 0;\n for (const item of rung.elements) {\n if (\"parallel\" in item) {\n const ph = parallelHeight(item.parallel);\n const bottomBranch = item.parallel[item.parallel.length - 1];\n if (!bottomBranch) continue;\n const belowRows = Math.max(\n 0,\n ...bottomBranch.elements.map((e) => labelRowsBelow(e))\n );\n const px = ph / 2 + belowRows * LINE_H + 4;\n if (px > maxBelowPx) maxBelowPx = px;\n } else {\n const rows = labelRowsBelow(item);\n const px = bodyHeight(item) / 2 + rows * LINE_H + 4;\n if (px > maxBelowPx) maxBelowPx = px;\n }\n }\n return maxBelowPx;\n}\n\nfunction branchInlineWidth(branch: LadderBranch): number {\n if (branch.elements.length === 0) return ELEMENT_WIDTH;\n let w = 0;\n branch.elements.forEach((el, i) => {\n w += slotWidth(el);\n if (i < branch.elements.length - 1) w += H_SPACING;\n });\n return w;\n}\n\nfunction parallelWidth(branches: LadderBranch[]): number {\n const maxBranch = Math.max(\n ELEMENT_WIDTH,\n ...branches.map(branchInlineWidth)\n );\n return maxBranch + 2 * H_SPACING;\n}\n\n/** Per-branch row height including label stack above + below. */\nfunction branchRowHeight(branch: LadderBranch): number {\n const bodyH = Math.max(\n ELEMENT_HEIGHT,\n ...branch.elements.map((e) => bodyHeight(e))\n );\n const above = Math.max(1, ...branch.elements.map((e) => labelRowsAbove(e)));\n const below = Math.max(0, ...branch.elements.map((e) => labelRowsBelow(e)));\n return bodyH + above * LINE_H + below * LINE_H + 6;\n}\n\nfunction parallelHeight(branches: LadderBranch[]): number {\n // Account for label space between branches so name/address rows don't collide.\n let total = 0;\n branches.forEach((br, i) => {\n total += branchRowHeight(br);\n if (i < branches.length - 1) total += PARALLEL_GAP;\n });\n return Math.max(total, ELEMENT_HEIGHT);\n}\n\nexport function layoutLadder(ast: LadderAST): LadderLayoutResult {\n const nodes: LadderLayoutNode[] = [];\n const wires: LadderLayoutWire[] = [];\n const rungs: LadderLayoutRung[] = [];\n\n let maxEndX = LEFT_RAIL_X + 200;\n let cursorY = RUNG_Y_OFFSET;\n\n ast.rungs.forEach((rung, rungIndex) => {\n const headerH = rungLabelHeaderHeight(rung);\n const footerH = rungLabelFooterHeight(rung);\n // Per-rung height is comment (16) + header + footer + a little breathing room.\n const rungHeight = Math.max(BASE_RUNG_HEIGHT, 16 + headerH + footerH + 16);\n const rungY = cursorY + 16 + headerH;\n\n let x = LEFT_RAIL_X + H_SPACING;\n let prevRightX = LEFT_RAIL_X;\n let prevRightY = rungY;\n\n const addWire = (x1: number, y1: number, x2: number, y2: number) => {\n wires.push({ path: `M ${x1} ${y1} L ${x2} ${y2}` });\n };\n\n rung.elements.forEach((item, elIdx) => {\n if (\"parallel\" in item) {\n const branches = item.parallel;\n const pw = parallelWidth(branches);\n const ph = parallelHeight(branches);\n const bx = x;\n const ex = x + pw;\n\n addWire(prevRightX, prevRightY, bx, rungY);\n\n const busTop = rungY - ph / 2;\n const busBot = rungY + ph / 2;\n wires.push({ path: `M ${bx} ${busTop} L ${bx} ${busBot}` });\n wires.push({ path: `M ${ex} ${busTop} L ${ex} ${busBot}` });\n\n // Pre-compute row Y for each branch using actual row heights.\n let rowY = busTop;\n branches.forEach((branch, bIdx) => {\n const rowH = branchRowHeight(branch);\n const bodyMax = Math.max(\n ELEMENT_HEIGHT,\n ...branch.elements.map((e) => bodyHeight(e))\n );\n const above = Math.max(\n 1,\n ...branch.elements.map((e) => labelRowsAbove(e))\n );\n // Position centerline so labels above fit within rowH.\n const branchY = rowY + above * LINE_H + bodyMax / 2;\n const bInline = branchInlineWidth(branch);\n const startX = bx + H_SPACING + ((ex - bx - 2 * H_SPACING) - bInline) / 2;\n let bx0 = startX;\n let prevBX = bx;\n branch.elements.forEach((bel, beIdx) => {\n const w = bodyWidth(bel);\n const h = bodyHeight(bel);\n const slot = slotWidth(bel);\n const nx = bx0 + (slot - w) / 2;\n const ny = branchY - h / 2;\n const id = `R${rung.number}_P${elIdx}_B${bIdx}_E${beIdx}`;\n nodes.push({\n id,\n rungIndex,\n element: bel,\n kind: elementKind(bel),\n x: nx,\n y: ny,\n width: w,\n height: h,\n rungY: branchY,\n });\n addWire(prevBX, branchY, nx, branchY);\n prevBX = nx + w;\n bx0 += slot + H_SPACING;\n });\n addWire(prevBX, branchY, ex, branchY);\n rowY += rowH + PARALLEL_GAP;\n });\n\n prevRightX = ex;\n prevRightY = rungY;\n x = ex + H_SPACING;\n return;\n }\n\n const el = item;\n const w = bodyWidth(el);\n const h = bodyHeight(el);\n const slot = slotWidth(el);\n const nx = x + (slot - w) / 2;\n const ny = rungY - h / 2;\n const id = `R${rung.number}_E${elIdx}`;\n nodes.push({\n id,\n rungIndex,\n element: el,\n kind: elementKind(el),\n x: nx,\n y: ny,\n width: w,\n height: h,\n rungY,\n });\n addWire(prevRightX, prevRightY, nx, rungY);\n prevRightX = nx + w;\n prevRightY = rungY;\n x += slot + H_SPACING;\n });\n\n rungs.push({\n rung,\n index: rungIndex,\n y: rungY,\n endX: prevRightX,\n height: rungHeight,\n headerHeight: headerH,\n });\n if (prevRightX > maxEndX) maxEndX = prevRightX;\n cursorY += rungHeight;\n });\n\n const rightRailX = maxEndX + H_SPACING * 2;\n const width = rightRailX + RIGHT_RAIL_MARGIN;\n const height = cursorY + CANVAS_PADDING;\n\n for (const r of rungs) {\n wires.push({ path: `M ${r.endX} ${r.y} L ${rightRailX} ${r.y}` });\n }\n\n return {\n width,\n height,\n leftRailX: LEFT_RAIL_X,\n rightRailX,\n rungs,\n nodes,\n wires,\n };\n}\n\nexport { labelRowsAbove, labelRowsBelow };\n","import type {\n LadderAST,\n LadderContact,\n LadderCoil,\n LadderFunctionBlock,\n RenderConfig,\n} from \"../../core/types\";\nimport {\n svgRoot,\n group,\n el,\n path as pathEl,\n text,\n title as titleEl,\n desc,\n} from \"../../core/svg\";\nimport { resolveIndustrialTheme, type IndustrialTokens, type ResolvedTheme } from \"../../core/theme\";\nimport { layoutLadder, type LadderLayoutNode, wrapName } from \"./layout\";\n\ntype IT = ResolvedTheme<IndustrialTokens>;\n\nfunction buildCss(t: IT): string {\n return `\n.lt-ladder { font-family: system-ui, -apple-system, sans-serif; }\n.lt-ladder-rail { stroke: ${t.strokeHeavy}; stroke-width: 4; stroke-linecap: square; }\n.lt-ladder-wire { stroke: ${t.stroke}; stroke-width: 1.5; fill: none; }\n.lt-ladder-element { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-ladder-coil { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-ladder-fb { fill: ${t.bg}; stroke: ${t.stroke}; stroke-width: 2; }\n.lt-ladder-fb-name { font: bold 11px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-ladder-pin { font: 8px sans-serif; fill: ${t.stroke}; }\n.lt-ladder-name { font: 9px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-ladder-tag { font: 600 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: ${t.accent}; text-anchor: middle; }\n.lt-ladder-addr { font: 600 8.5px ui-monospace, monospace; fill: ${t.error}; text-anchor: middle; }\n.lt-ladder-rung-num { font: 10px sans-serif; fill: ${t.textMuted}; text-anchor: end; }\n.lt-ladder-comment { font: italic 10px sans-serif; fill: ${t.textMuted}; }\n.lt-ladder-title { font: 700 16px sans-serif; fill: ${t.text}; }\n.lt-ladder-symbol-label { font: bold 10px sans-serif; fill: ${t.stroke}; text-anchor: middle; }\n`.trim();\n}\n\nconst LINE_H = 11;\n\nfunction labelsAbove(\n name: string | undefined,\n tag: string,\n cx: number,\n bodyTopY: number\n): string[] {\n const pieces: string[] = [];\n const nameLines = name ? wrapName(name) : [];\n const totalLines = nameLines.length + 1; // +1 for tag\n const firstY = bodyTopY - 4 - (totalLines - 1) * LINE_H;\n nameLines.forEach((line, i) => {\n pieces.push(\n text({ x: cx, y: firstY + i * LINE_H, class: \"lt-ladder-name\" }, line)\n );\n });\n pieces.push(\n text(\n { x: cx, y: firstY + nameLines.length * LINE_H, class: \"lt-ladder-tag\" },\n tag\n )\n );\n return pieces;\n}\n\nfunction renderContact(node: LadderLayoutNode): string {\n const c = node.element as LadderContact;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const leftBarX = x + 4;\n const rightBarX = x + w - 4;\n const cx = x + w / 2;\n const pieces: string[] = [];\n pieces.push(el(\"line\", { x1: x, y1: cy, x2: leftBarX, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: rightBarX, y1: cy, x2: x + w, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: leftBarX, y1: y, x2: leftBarX, y2: y + h, class: \"lt-ladder-element\" }));\n pieces.push(el(\"line\", { x1: rightBarX, y1: y, x2: rightBarX, y2: y + h, class: \"lt-ladder-element\" }));\n\n if (c.contactType === \"XIO\") {\n pieces.push(\n el(\"line\", {\n x1: leftBarX + 2,\n y1: y + h - 2,\n x2: rightBarX - 2,\n y2: y + 2,\n class: \"lt-ladder-element\",\n })\n );\n } else if (c.contactType === \"ONS\") {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, \"↑\"));\n } else if (c.contactType === \"OSF\") {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, \"↓\"));\n }\n\n pieces.push(...labelsAbove(c.name, c.tag, cx, y));\n if (c.address) {\n pieces.push(\n text({ x: cx, y: y + h + 10, class: \"lt-ladder-addr\" }, c.address)\n );\n }\n return group({ \"data-element\": \"contact\", \"data-tag\": c.tag }, pieces);\n}\n\nfunction renderCoil(node: LadderLayoutNode): string {\n const c = node.element as LadderCoil;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n const leftArc = `M ${x + 6} ${y} A 10 ${h / 2} 0 0 0 ${x + 6} ${y + h}`;\n const rightArc = `M ${x + w - 6} ${y} A 10 ${h / 2} 0 0 1 ${x + w - 6} ${y + h}`;\n pieces.push(pathEl({ d: leftArc, class: \"lt-ladder-coil\" }));\n pieces.push(pathEl({ d: rightArc, class: \"lt-ladder-coil\" }));\n pieces.push(el(\"line\", { x1: x, y1: cy, x2: x + 6, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: x + w - 6, y1: cy, x2: x + w, y2: cy, class: \"lt-ladder-wire\" }));\n\n let inner = \"\";\n if (c.coilType === \"OTL\") inner = \"S\";\n else if (c.coilType === \"OTU\") inner = \"R\";\n else if (c.coilType === \"OTN\") inner = \"/\";\n else if (c.coilType === \"RES\") inner = \"R\";\n if (inner) {\n pieces.push(text({ x: cx, y: cy + 3, class: \"lt-ladder-symbol-label\" }, inner));\n }\n\n pieces.push(...labelsAbove(c.name, c.tag, cx, y));\n if (c.address) {\n pieces.push(\n text({ x: cx, y: y + h + 10, class: \"lt-ladder-addr\" }, c.address)\n );\n }\n return group({ \"data-element\": \"coil\", \"data-tag\": c.tag }, pieces);\n}\n\nfunction renderCompare(node: LadderLayoutNode): string {\n const fb = node.element as LadderFunctionBlock;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n pieces.push(el(\"rect\", { x, y, width: w, height: h, class: \"lt-ladder-fb\" }));\n pieces.push(text({ x: cx, y: y + 12, class: \"lt-ladder-fb-name\" }, fb.fbType));\n const entries = Object.entries(fb.params);\n entries.slice(0, 2).forEach(([k, v], i) => {\n pieces.push(\n text({ x: x + 4, y: y + 22 + i * 9, class: \"lt-ladder-pin\" }, `${k}:${v}`)\n );\n });\n pieces.push(el(\"line\", { x1: x - 2, y1: cy, x2: x, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(el(\"line\", { x1: x + w, y1: cy, x2: x + w + 2, y2: cy, class: \"lt-ladder-wire\" }));\n pieces.push(text({ x: cx, y: y - 4, class: \"lt-ladder-tag\" }, fb.tag));\n return group({ \"data-element\": \"compare\", \"data-tag\": fb.tag }, pieces);\n}\n\nfunction renderFunctionBlock(node: LadderLayoutNode): string {\n const fb = node.element as LadderFunctionBlock;\n const { x, y, width: w, height: h } = node;\n const cy = y + h / 2;\n const cx = x + w / 2;\n const pieces: string[] = [];\n\n pieces.push(el(\"rect\", { x, y, width: w, height: h, class: \"lt-ladder-fb\" }));\n pieces.push(text({ x: cx, y: y + 14, class: \"lt-ladder-fb-name\" }, fb.fbType));\n\n pieces.push(\n el(\"line\", { x1: x - 6, y1: cy, x2: x, y2: cy, class: \"lt-ladder-wire\" })\n );\n pieces.push(\n el(\"line\", { x1: x + w, y1: cy, x2: x + w + 6, y2: cy, class: \"lt-ladder-wire\" })\n );\n\n const entries = Object.entries(fb.params);\n entries.slice(0, 3).forEach(([k, v], i) => {\n pieces.push(\n text({ x: x + 4, y: y + 28 + i * 9, class: \"lt-ladder-pin\" }, `${k}=${v}`)\n );\n });\n\n pieces.push(text({ x: cx, y: y - 4, class: \"lt-ladder-tag\" }, fb.tag));\n return group({ \"data-element\": \"function_block\", \"data-tag\": fb.tag }, pieces);\n}\n\nfunction renderNode(node: LadderLayoutNode): string {\n switch (node.kind) {\n case \"contact\":\n return renderContact(node);\n case \"coil\":\n return renderCoil(node);\n case \"compare\":\n return renderCompare(node);\n case \"function_block\":\n return renderFunctionBlock(node);\n }\n}\n\nexport function renderLadder(ast: LadderAST, config?: RenderConfig): string {\n const layout = layoutLadder(ast);\n const t = resolveIndustrialTheme(config?.theme ?? \"default\");\n const titleOffset = ast.title ? 30 : 0;\n const width = layout.width;\n const height = layout.height + titleOffset;\n\n const children: string[] = [];\n children.push(titleEl(ast.title ?? \"Ladder Logic\"));\n children.push(\n desc(`PLC ladder logic diagram with ${ast.rungs.length} rung${ast.rungs.length === 1 ? \"\" : \"s\"}`)\n );\n children.push(el(\"style\", {}, buildCss(t)));\n\n if (ast.title) {\n children.push(\n text({ x: width / 2, y: 20, class: \"lt-ladder-title\", \"text-anchor\": \"middle\" }, ast.title)\n );\n }\n\n const inner: string[] = [];\n\n inner.push(\n el(\"line\", {\n x1: layout.leftRailX,\n y1: 0,\n x2: layout.leftRailX,\n y2: layout.height,\n class: \"lt-ladder-rail\",\n })\n );\n inner.push(\n el(\"line\", {\n x1: layout.rightRailX,\n y1: 0,\n x2: layout.rightRailX,\n y2: layout.height,\n class: \"lt-ladder-rail\",\n })\n );\n\n for (const r of layout.rungs) {\n inner.push(\n text(\n { x: layout.leftRailX - 6, y: r.y + 3, class: \"lt-ladder-rung-num\" },\n `Rung ${String(r.rung.number).padStart(3, \"0\")}`\n )\n );\n if (r.rung.comment) {\n // Place comment above the tallest element label on this rung (and above the parallel bus if any).\n const commentY = Math.max(14, r.y - (r.headerHeight + 6));\n inner.push(\n text(\n {\n x: layout.leftRailX + 10,\n y: commentY,\n class: \"lt-ladder-comment\",\n },\n `— ${r.rung.comment} —`\n )\n );\n }\n }\n\n for (const w of layout.wires) {\n inner.push(pathEl({ d: w.path, class: \"lt-ladder-wire\" }));\n }\n\n for (const n of layout.nodes) {\n inner.push(renderNode(n));\n }\n\n const wrap = group({ transform: `translate(0, ${titleOffset})` }, inner);\n children.push(wrap);\n\n return svgRoot(\n {\n class: \"lt-ladder\",\n role: \"img\",\n \"aria-labelledby\": \"lt-ladder-title lt-ladder-desc\",\n width,\n height,\n viewBox: `0 0 ${width} ${height}`,\n },\n children\n );\n}\n","import type { DiagramPlugin } from \"../../core/types\";\nimport { firstContentLine } from \"../../core/dsl-preprocess\";\nimport { parseLadderDSL } from \"./parser\";\nimport { renderLadder } from \"./renderer\";\n\nexport const ladder: DiagramPlugin = {\n type: \"ladder\",\n detect(text: string): boolean {\n const first = firstContentLine(text)?.toLowerCase() ?? \"\";\n return first.startsWith(\"ladder\");\n },\n parse: parseLadderDSL,\n\n render(text: string, config): string {\n const ast = parseLadderDSL(text);\n return renderLadder(ast, config);\n },\n};\n\nexport { parseLadderDSL } from \"./parser\";\nexport { renderLadder } from \"./renderer\";\nexport { layoutLadder } from \"./layout\";\n"]}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkUHRNFBWY_cjs = require('./chunk-UHRNFBWY.cjs');
|
|
4
4
|
var chunkIBZKIMT5_cjs = require('./chunk-IBZKIMT5.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk24YHD4YI_cjs = require('./chunk-24YHD4YI.cjs');
|
|
6
6
|
var chunkT55OQILI_cjs = require('./chunk-T55OQILI.cjs');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var chunkUS4QZ7J7_cjs = require('./chunk-US4QZ7J7.cjs');
|
|
8
|
+
var chunkAWUUGDN4_cjs = require('./chunk-AWUUGDN4.cjs');
|
|
9
9
|
var chunk4MANMKQ4_cjs = require('./chunk-4MANMKQ4.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunkAQENURKO_cjs = require('./chunk-AQENURKO.cjs');
|
|
11
11
|
var chunk3JN4762U_cjs = require('./chunk-3JN4762U.cjs');
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
12
|
+
var chunkTIHHISCK_cjs = require('./chunk-TIHHISCK.cjs');
|
|
13
|
+
var chunkCYBBBBMZ_cjs = require('./chunk-CYBBBBMZ.cjs');
|
|
14
|
+
var chunkF3JYKM6M_cjs = require('./chunk-F3JYKM6M.cjs');
|
|
15
|
+
var chunk7DQXFTA7_cjs = require('./chunk-7DQXFTA7.cjs');
|
|
16
|
+
var chunk3TGOOZ36_cjs = require('./chunk-3TGOOZ36.cjs');
|
|
17
17
|
var chunkTFUVNQNA_cjs = require('./chunk-TFUVNQNA.cjs');
|
|
18
18
|
var chunkKYE7CRED_cjs = require('./chunk-KYE7CRED.cjs');
|
|
19
19
|
var chunkJHJJT5H5_cjs = require('./chunk-JHJJT5H5.cjs');
|
|
@@ -3832,7 +3832,7 @@ function layoutStateDiagram(ast) {
|
|
|
3832
3832
|
}
|
|
3833
3833
|
return true;
|
|
3834
3834
|
});
|
|
3835
|
-
const fcResult =
|
|
3835
|
+
const fcResult = chunkTIHHISCK_cjs.layoutFlowchart(fcAst);
|
|
3836
3836
|
const stateById = /* @__PURE__ */ new Map();
|
|
3837
3837
|
const collectStates = (s) => {
|
|
3838
3838
|
stateById.set(s.id, s);
|
|
@@ -28631,7 +28631,7 @@ var SEAT_FS = 0.17;
|
|
|
28631
28631
|
var SEAT_FS_MIN = 0.085;
|
|
28632
28632
|
function seatName(c, cx, cy, name, slotW) {
|
|
28633
28633
|
if (!name) return "";
|
|
28634
|
-
const unitW =
|
|
28634
|
+
const unitW = chunkF3JYKM6M_cjs.estimateTextWidth(name, 1);
|
|
28635
28635
|
let fs = SEAT_FS;
|
|
28636
28636
|
if (unitW > 0 && unitW * fs > slotW) fs = Math.max(SEAT_FS_MIN, slotW / unitW);
|
|
28637
28637
|
return chunk3WNW5Y7P_cjs.text(
|
|
@@ -29967,7 +29967,23 @@ var FURNITURE_ALIASES = {
|
|
|
29967
29967
|
panel: "electrical-panel",
|
|
29968
29968
|
"breaker-panel": "electrical-panel",
|
|
29969
29969
|
db: "distribution-board",
|
|
29970
|
-
"consumer-unit": "distribution-board"
|
|
29970
|
+
"consumer-unit": "distribution-board",
|
|
29971
|
+
// Common everyday synonyms an LLM reaches for that map cleanly onto an
|
|
29972
|
+
// existing type. Keeps a valid layout from failing on a vocabulary gap.
|
|
29973
|
+
"console-table": "side-table",
|
|
29974
|
+
console: "side-table",
|
|
29975
|
+
"end-table": "side-table",
|
|
29976
|
+
couch: "sofa",
|
|
29977
|
+
settee: "loveseat",
|
|
29978
|
+
"tv-console": "tv-stand",
|
|
29979
|
+
"media-console": "tv-stand",
|
|
29980
|
+
"entertainment-center": "tv-stand",
|
|
29981
|
+
refrigerator: "fridge",
|
|
29982
|
+
cooktop: "stove",
|
|
29983
|
+
stovetop: "stove",
|
|
29984
|
+
armoire: "wardrobe",
|
|
29985
|
+
wc: "toilet",
|
|
29986
|
+
"water-closet": "toilet"
|
|
29971
29987
|
};
|
|
29972
29988
|
function parseFurnitureType(t, ln) {
|
|
29973
29989
|
const word = isWord(t) ? t.word : "";
|
|
@@ -34992,7 +35008,7 @@ function layoutQfd(ast) {
|
|
|
34992
35008
|
const weightW = QFD_WEIGHT_W;
|
|
34993
35009
|
const maxHowW = Math.max(
|
|
34994
35010
|
0,
|
|
34995
|
-
...(ast.qfd?.hows ?? []).map((h) =>
|
|
35011
|
+
...(ast.qfd?.hows ?? []).map((h) => chunkF3JYKM6M_cjs.estimateTextWidth(h.label, QFD_HOW_FONT))
|
|
34996
35012
|
);
|
|
34997
35013
|
const howLabelH = Math.max(48, Math.min(220, Math.ceil(maxHowW * QFD_HOW_ANGLE_SIN) + 26));
|
|
34998
35014
|
const footerH = QFD_FOOTER_H;
|
|
@@ -36689,6 +36705,9 @@ function parseMermaidErd(lines) {
|
|
|
36689
36705
|
const entityMap = /* @__PURE__ */ new Map();
|
|
36690
36706
|
const order = [];
|
|
36691
36707
|
const refs = [];
|
|
36708
|
+
let title2;
|
|
36709
|
+
let direction = "LR";
|
|
36710
|
+
let notation = "crowsfoot";
|
|
36692
36711
|
const ensure = (id) => {
|
|
36693
36712
|
let e = entityMap.get(id);
|
|
36694
36713
|
if (!e) {
|
|
@@ -36702,6 +36721,33 @@ function parseMermaidErd(lines) {
|
|
|
36702
36721
|
while (i < lines.length) {
|
|
36703
36722
|
const t = lines[i].text;
|
|
36704
36723
|
const ln = lines[i].lineNumber;
|
|
36724
|
+
const lower = t.toLowerCase();
|
|
36725
|
+
if (lower.startsWith("title:")) {
|
|
36726
|
+
title2 = unquote7(t.slice("title:".length).trim());
|
|
36727
|
+
i++;
|
|
36728
|
+
continue;
|
|
36729
|
+
}
|
|
36730
|
+
if (lower.startsWith("direction:")) {
|
|
36731
|
+
const v = t.slice("direction:".length).trim().toUpperCase();
|
|
36732
|
+
if (v !== "LR" && v !== "TB") {
|
|
36733
|
+
throw new ErdParseError(`Unknown direction '${v}'. Use LR or TB.`, ln);
|
|
36734
|
+
}
|
|
36735
|
+
direction = v;
|
|
36736
|
+
i++;
|
|
36737
|
+
continue;
|
|
36738
|
+
}
|
|
36739
|
+
if (lower.startsWith("notation:")) {
|
|
36740
|
+
const v = t.slice("notation:".length).trim().toLowerCase();
|
|
36741
|
+
if (v !== "crowsfoot") {
|
|
36742
|
+
throw new ErdParseError(
|
|
36743
|
+
`notation '${v}' is documented but not yet implemented in v0.1; use 'crowsfoot'.`,
|
|
36744
|
+
ln
|
|
36745
|
+
);
|
|
36746
|
+
}
|
|
36747
|
+
notation = v;
|
|
36748
|
+
i++;
|
|
36749
|
+
continue;
|
|
36750
|
+
}
|
|
36705
36751
|
const inlineBlock = new RegExp(`^(${MERMAID_NAME.source})\\s*\\{\\s*(.*?)\\s*\\}$`).exec(t);
|
|
36706
36752
|
const openBlock = new RegExp(`^(${MERMAID_NAME.source})\\s*\\{$`).exec(t);
|
|
36707
36753
|
if (inlineBlock) {
|
|
@@ -36748,8 +36794,9 @@ function parseMermaidErd(lines) {
|
|
|
36748
36794
|
}
|
|
36749
36795
|
return {
|
|
36750
36796
|
type: "erd",
|
|
36751
|
-
notation
|
|
36752
|
-
direction
|
|
36797
|
+
notation,
|
|
36798
|
+
direction,
|
|
36799
|
+
title: title2,
|
|
36753
36800
|
entities: order.map((id) => entityMap.get(id)),
|
|
36754
36801
|
refs
|
|
36755
36802
|
};
|
|
@@ -42663,21 +42710,21 @@ var sfc = {
|
|
|
42663
42710
|
|
|
42664
42711
|
// src/core/api.ts
|
|
42665
42712
|
var plugins = [
|
|
42666
|
-
|
|
42667
|
-
|
|
42668
|
-
|
|
42713
|
+
chunkCYBBBBMZ_cjs.genogram,
|
|
42714
|
+
chunkF3JYKM6M_cjs.ecomap,
|
|
42715
|
+
chunk7DQXFTA7_cjs.pedigree,
|
|
42669
42716
|
chunkTFUVNQNA_cjs.phylo,
|
|
42670
42717
|
chunkKYE7CRED_cjs.sociogram,
|
|
42671
42718
|
chunkJHJJT5H5_cjs.timing,
|
|
42672
42719
|
chunkYDEQZSPQ_cjs.logic,
|
|
42673
|
-
|
|
42720
|
+
chunk24YHD4YI_cjs.circuit,
|
|
42674
42721
|
chunkT55OQILI_cjs.blockdiagram,
|
|
42675
|
-
|
|
42676
|
-
|
|
42722
|
+
chunkUS4QZ7J7_cjs.ladder,
|
|
42723
|
+
chunkAWUUGDN4_cjs.sld,
|
|
42677
42724
|
chunk4MANMKQ4_cjs.entity,
|
|
42678
|
-
|
|
42725
|
+
chunkAQENURKO_cjs.fishbone,
|
|
42679
42726
|
chunk3JN4762U_cjs.venn,
|
|
42680
|
-
|
|
42727
|
+
chunkTIHHISCK_cjs.flowchart,
|
|
42681
42728
|
mindmap,
|
|
42682
42729
|
matrix,
|
|
42683
42730
|
chunkUHRNFBWY_cjs.orgchart,
|
|
@@ -42752,7 +42799,8 @@ function normalizeHeader(text2, type) {
|
|
|
42752
42799
|
return text2;
|
|
42753
42800
|
}
|
|
42754
42801
|
function preprocess9(text2) {
|
|
42755
|
-
const { data, body } =
|
|
42802
|
+
const { data, body: rawBody } = chunk3TGOOZ36_cjs.parseFrontmatter(stripCodeFences(text2));
|
|
42803
|
+
const body = chunk3TGOOZ36_cjs.stripComments(rawBody, chunk3TGOOZ36_cjs.UNIVERSAL_COMMENT_MARKERS);
|
|
42756
42804
|
if (!data.title) return body;
|
|
42757
42805
|
const safeTitle = data.title.replace(/"/g, '\\"');
|
|
42758
42806
|
const lines = body.split("\n");
|
|
@@ -42896,5 +42944,5 @@ exports.timeline = timeline;
|
|
|
42896
42944
|
exports.umlclass = umlclass;
|
|
42897
42945
|
exports.usecase = usecase;
|
|
42898
42946
|
exports.welding = welding;
|
|
42899
|
-
//# sourceMappingURL=chunk-
|
|
42900
|
-
//# sourceMappingURL=chunk-
|
|
42947
|
+
//# sourceMappingURL=chunk-V5TY3N2W.cjs.map
|
|
42948
|
+
//# sourceMappingURL=chunk-V5TY3N2W.cjs.map
|