schematex 0.9.1 → 0.9.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/ai/ai-sdk.cjs +24 -24
- package/dist/ai/ai-sdk.js +19 -19
- package/dist/ai/index.cjs +33 -33
- package/dist/ai/index.js +20 -20
- package/dist/browser.cjs +25 -25
- package/dist/browser.js +19 -19
- package/dist/{chunk-YMFYPB5Y.cjs → chunk-2A5HJFOX.cjs} +4 -4
- package/dist/{chunk-YMFYPB5Y.cjs.map → chunk-2A5HJFOX.cjs.map} +1 -1
- package/dist/{chunk-6L46VIXI.cjs → chunk-2ASZMLC3.cjs} +20 -28
- package/dist/chunk-2ASZMLC3.cjs.map +1 -0
- package/dist/{chunk-6NUAGU6O.js → chunk-2RFFCZ3I.js} +3 -3
- package/dist/{chunk-6NUAGU6O.js.map → chunk-2RFFCZ3I.js.map} +1 -1
- package/dist/{chunk-2R4UXKCT.cjs → chunk-3DSNGR26.cjs} +5 -5
- package/dist/{chunk-2R4UXKCT.cjs.map → chunk-3DSNGR26.cjs.map} +1 -1
- package/dist/{chunk-D34VGLSE.cjs → chunk-4MGALM2C.cjs} +5 -5
- package/dist/{chunk-D34VGLSE.cjs.map → chunk-4MGALM2C.cjs.map} +1 -1
- package/dist/{chunk-ABCMTAOZ.js → chunk-56DSMSXK.js} +7 -4
- package/dist/chunk-56DSMSXK.js.map +1 -0
- package/dist/{chunk-Q2YRJHFB.cjs → chunk-6BJKQULN.cjs} +7 -7
- package/dist/chunk-6BJKQULN.cjs.map +1 -0
- package/dist/{chunk-NFZMNKOR.cjs → chunk-7JJQEECD.cjs} +15 -15
- package/dist/{chunk-NFZMNKOR.cjs.map → chunk-7JJQEECD.cjs.map} +1 -1
- package/dist/{chunk-JN6FHUC6.js → chunk-7SVB3XA7.js} +3 -3
- package/dist/{chunk-JN6FHUC6.js.map → chunk-7SVB3XA7.js.map} +1 -1
- package/dist/{chunk-J34HDRFY.js → chunk-7Z2GDS4G.js} +4 -4
- package/dist/{chunk-J34HDRFY.js.map → chunk-7Z2GDS4G.js.map} +1 -1
- package/dist/{chunk-Z5ML4QYG.js → chunk-CURAZVOH.js} +3 -3
- package/dist/{chunk-Z5ML4QYG.js.map → chunk-CURAZVOH.js.map} +1 -1
- package/dist/{chunk-KGOZBABH.cjs → chunk-GYTU7L4L.cjs} +12 -12
- package/dist/{chunk-KGOZBABH.cjs.map → chunk-GYTU7L4L.cjs.map} +1 -1
- package/dist/{chunk-B5AQ3CG3.cjs → chunk-HILYXWGJ.cjs} +16 -13
- package/dist/chunk-HILYXWGJ.cjs.map +1 -0
- package/dist/{chunk-E3CAJGJM.js → chunk-HJA7MIMV.js} +6 -6
- package/dist/chunk-HJA7MIMV.js.map +1 -0
- package/dist/{chunk-DX44TBFZ.js → chunk-IQLZUCWI.js} +20 -28
- package/dist/chunk-IQLZUCWI.js.map +1 -0
- package/dist/{chunk-NXU4XKLY.cjs → chunk-JHJJT5H5.cjs} +9 -7
- package/dist/chunk-JHJJT5H5.cjs.map +1 -0
- package/dist/{chunk-CDK7KDIW.js → chunk-JR6JNQEZ.js} +4 -4
- package/dist/{chunk-CDK7KDIW.js.map → chunk-JR6JNQEZ.js.map} +1 -1
- package/dist/{chunk-YTGOLTLJ.js → chunk-KR7PPCC4.js} +4 -4
- package/dist/{chunk-YTGOLTLJ.js.map → chunk-KR7PPCC4.js.map} +1 -1
- package/dist/{chunk-AJJYWXZB.cjs → chunk-L2NY4XEY.cjs} +4 -4
- package/dist/{chunk-AJJYWXZB.cjs.map → chunk-L2NY4XEY.cjs.map} +1 -1
- package/dist/{chunk-EBX4KCYW.js → chunk-MERU76LW.js} +4 -4
- package/dist/{chunk-EBX4KCYW.js.map → chunk-MERU76LW.js.map} +1 -1
- package/dist/{chunk-IXRPRMHI.js → chunk-MTIZIHWE.js} +9 -7
- package/dist/chunk-MTIZIHWE.js.map +1 -0
- package/dist/{chunk-47SGK5R6.cjs → chunk-MUE45N2A.cjs} +5 -5
- package/dist/{chunk-47SGK5R6.cjs.map → chunk-MUE45N2A.cjs.map} +1 -1
- package/dist/{chunk-DHI7YAQJ.cjs → chunk-MYVY55DO.cjs} +15 -15
- package/dist/{chunk-DHI7YAQJ.cjs.map → chunk-MYVY55DO.cjs.map} +1 -1
- package/dist/{chunk-NZT5P2XZ.cjs → chunk-NT6VVMLW.cjs} +291 -2
- package/dist/chunk-NT6VVMLW.cjs.map +1 -0
- package/dist/{chunk-QYC6WZEM.cjs → chunk-NTQBNBBP.cjs} +486 -437
- package/dist/chunk-NTQBNBBP.cjs.map +1 -0
- package/dist/{chunk-T5KHNJ67.cjs → chunk-PSQGLE6U.cjs} +6 -6
- package/dist/{chunk-T5KHNJ67.cjs.map → chunk-PSQGLE6U.cjs.map} +1 -1
- package/dist/{chunk-GDZNTILD.js → chunk-TMAOPJCT.js} +4 -4
- package/dist/chunk-TMAOPJCT.js.map +1 -0
- package/dist/{chunk-VOJGLBE5.js → chunk-TP7LQ5PF.js} +312 -263
- package/dist/chunk-TP7LQ5PF.js.map +1 -0
- package/dist/{chunk-UOM3EDE6.js → chunk-TWTUIUNK.js} +3 -3
- package/dist/{chunk-UOM3EDE6.js.map → chunk-TWTUIUNK.js.map} +1 -1
- package/dist/{chunk-UK6HF6PE.js → chunk-TYEQC7PV.js} +288 -3
- package/dist/chunk-TYEQC7PV.js.map +1 -0
- package/dist/{chunk-2SZJQVPN.cjs → chunk-V3JTVTPY.cjs} +87 -30
- package/dist/chunk-V3JTVTPY.cjs.map +1 -0
- package/dist/{chunk-KF3DFASA.js → chunk-VMUNKEB2.js} +3 -3
- package/dist/{chunk-KF3DFASA.js.map → chunk-VMUNKEB2.js.map} +1 -1
- package/dist/{chunk-K2D6VFLP.js → chunk-VWIKDJNV.js} +78 -22
- package/dist/chunk-VWIKDJNV.js.map +1 -0
- package/dist/{chunk-JGCKW5RS.js → chunk-VY4JOTM2.js} +5 -5
- package/dist/chunk-VY4JOTM2.js.map +1 -0
- package/dist/{chunk-LENRV7ZJ.cjs → chunk-VYAUTNHC.cjs} +5 -5
- package/dist/chunk-VYAUTNHC.cjs.map +1 -0
- package/dist/{chunk-E7LXMEKX.js → chunk-VZVREOTM.js} +3 -3
- package/dist/{chunk-E7LXMEKX.js.map → chunk-VZVREOTM.js.map} +1 -1
- package/dist/{chunk-JIUC4DRS.cjs → chunk-WFVRUUJW.cjs} +6 -6
- package/dist/chunk-WFVRUUJW.cjs.map +1 -0
- package/dist/{chunk-FJVQGBPU.cjs → chunk-XA6XIAMN.cjs} +5 -5
- package/dist/{chunk-FJVQGBPU.cjs.map → chunk-XA6XIAMN.cjs.map} +1 -1
- package/dist/diagrams/blockdiagram/index.cjs +6 -5
- package/dist/diagrams/blockdiagram/index.d.cts +2 -2
- package/dist/diagrams/blockdiagram/index.d.ts +2 -2
- package/dist/diagrams/blockdiagram/index.js +2 -1
- package/dist/diagrams/circuit/index.cjs +9 -9
- package/dist/diagrams/circuit/index.js +2 -2
- package/dist/diagrams/ecomap/index.cjs +7 -7
- package/dist/diagrams/ecomap/index.js +2 -2
- package/dist/diagrams/entity/index.cjs +6 -6
- package/dist/diagrams/entity/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/logic/index.cjs +8 -8
- package/dist/diagrams/logic/index.js +2 -2
- package/dist/diagrams/orgchart/index.cjs +8 -8
- package/dist/diagrams/orgchart/index.js +2 -2
- package/dist/diagrams/pedigree/index.cjs +7 -7
- package/dist/diagrams/pedigree/index.js +2 -2
- package/dist/diagrams/phylo/index.cjs +7 -7
- package/dist/diagrams/phylo/index.js +2 -2
- package/dist/diagrams/sld/index.cjs +8 -8
- package/dist/diagrams/sld/index.js +2 -2
- package/dist/diagrams/sociogram/index.cjs +6 -6
- package/dist/diagrams/sociogram/index.js +2 -2
- package/dist/diagrams/timing/index.cjs +4 -4
- package/dist/diagrams/timing/index.js +1 -1
- package/dist/diagrams/venn/index.cjs +9 -9
- package/dist/diagrams/venn/index.js +2 -2
- package/dist/index.cjs +87 -87
- package/dist/index.js +23 -23
- package/dist/react.cjs +19 -19
- package/dist/react.js +18 -18
- package/package.json +1 -1
- package/dist/chunk-2SZJQVPN.cjs.map +0 -1
- package/dist/chunk-6L46VIXI.cjs.map +0 -1
- package/dist/chunk-ABCMTAOZ.js.map +0 -1
- package/dist/chunk-B5AQ3CG3.cjs.map +0 -1
- package/dist/chunk-DX44TBFZ.js.map +0 -1
- package/dist/chunk-E3CAJGJM.js.map +0 -1
- package/dist/chunk-GDZNTILD.js.map +0 -1
- package/dist/chunk-IXRPRMHI.js.map +0 -1
- package/dist/chunk-JGCKW5RS.js.map +0 -1
- package/dist/chunk-JIUC4DRS.cjs.map +0 -1
- package/dist/chunk-K2D6VFLP.js.map +0 -1
- package/dist/chunk-LENRV7ZJ.cjs.map +0 -1
- package/dist/chunk-NXU4XKLY.cjs.map +0 -1
- package/dist/chunk-NZT5P2XZ.cjs.map +0 -1
- package/dist/chunk-Q2YRJHFB.cjs.map +0 -1
- package/dist/chunk-QYC6WZEM.cjs.map +0 -1
- package/dist/chunk-UK6HF6PE.js.map +0 -1
- package/dist/chunk-VOJGLBE5.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { firstContentLine } from './chunk-2KTQ75LN.js';
|
|
2
2
|
import { parseLegendDirective, applyLegendOverrides, renderLegend } from './chunk-FO7BLCEW.js';
|
|
3
|
-
import { resolveBaseTheme, STROKE_WIDTH, cssCustomProperties } from './chunk-
|
|
3
|
+
import { resolveBaseTheme, STROKE_WIDTH, cssCustomProperties } from './chunk-TYEQC7PV.js';
|
|
4
4
|
import { title, desc, group, svgRoot, el, text } from './chunk-SYYBKDL7.js';
|
|
5
5
|
|
|
6
6
|
// src/diagrams/ecomap/parser.ts
|
|
@@ -221,8 +221,40 @@ function buildIndividual(id, props, isCenter) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
// src/core/text-metrics.ts
|
|
225
|
+
var FULL_WIDTH_RE = /[ᄀ-ᇿ⺀-〿-ヿ-㇀-㏿㐀-䶿一-鿿ꥠ-가-豈-︰-﹏-⦆¢-₩]/;
|
|
226
|
+
function isFullWidth(ch) {
|
|
227
|
+
return FULL_WIDTH_RE.test(ch);
|
|
228
|
+
}
|
|
229
|
+
var NARROW_RE = /[iIljtf.,:;'"!|()[\]{}` ]/;
|
|
230
|
+
var WIDE_RE = /[0-9A-HK-Z@#%&mwMW_<>=+~^$]/;
|
|
231
|
+
function estimateTextWidth(text2, fontSize, opts = {}) {
|
|
232
|
+
let units = 0;
|
|
233
|
+
for (const ch of text2) {
|
|
234
|
+
if (isFullWidth(ch)) {
|
|
235
|
+
units += 1;
|
|
236
|
+
} else if (opts.monospace) {
|
|
237
|
+
units += 0.6;
|
|
238
|
+
} else if (NARROW_RE.test(ch)) {
|
|
239
|
+
units += 0.32;
|
|
240
|
+
} else if (WIDE_RE.test(ch)) {
|
|
241
|
+
units += 0.66;
|
|
242
|
+
} else {
|
|
243
|
+
units += 0.54;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const weightFactor = (opts.fontWeight ?? 400) >= 600 ? 1.06 : 1;
|
|
247
|
+
return units * fontSize * weightFactor;
|
|
248
|
+
}
|
|
249
|
+
|
|
224
250
|
// src/diagrams/ecomap/layout.ts
|
|
225
251
|
var CENTER_R = 50;
|
|
252
|
+
var CENTER_LABEL_FONT = 14;
|
|
253
|
+
function getCenterRadius(center) {
|
|
254
|
+
const label = center.label !== center.id ? center.label : center.id.charAt(0).toUpperCase() + center.id.slice(1);
|
|
255
|
+
const w = estimateTextWidth(label, CENTER_LABEL_FONT, { fontWeight: 600 });
|
|
256
|
+
return Math.max(CENTER_R, Math.ceil(w / 2) + 10);
|
|
257
|
+
}
|
|
226
258
|
var SYS_R = 30;
|
|
227
259
|
var SYS_R_LARGE = 40;
|
|
228
260
|
var SYS_R_SMALL = 20;
|
|
@@ -237,18 +269,19 @@ function layoutEcomap(ast, _config) {
|
|
|
237
269
|
(ind) => ind.properties?.center !== "true"
|
|
238
270
|
);
|
|
239
271
|
const n = systems.length;
|
|
272
|
+
const centerR = getCenterRadius(center);
|
|
240
273
|
if (n === 0) {
|
|
241
|
-
const size = (
|
|
274
|
+
const size = (centerR + PADDING + LABEL_CLEARANCE) * 2;
|
|
242
275
|
return {
|
|
243
276
|
width: size,
|
|
244
277
|
height: size,
|
|
245
278
|
nodes: [
|
|
246
279
|
{
|
|
247
280
|
id: center.id,
|
|
248
|
-
x: size / 2 -
|
|
249
|
-
y: size / 2 -
|
|
250
|
-
width:
|
|
251
|
-
height:
|
|
281
|
+
x: size / 2 - centerR,
|
|
282
|
+
y: size / 2 - centerR,
|
|
283
|
+
width: centerR * 2,
|
|
284
|
+
height: centerR * 2,
|
|
252
285
|
generation: 0,
|
|
253
286
|
individual: center
|
|
254
287
|
}
|
|
@@ -271,10 +304,10 @@ function layoutEcomap(ast, _config) {
|
|
|
271
304
|
const nodes = [];
|
|
272
305
|
nodes.push({
|
|
273
306
|
id: center.id,
|
|
274
|
-
x: cx -
|
|
275
|
-
y: cy -
|
|
276
|
-
width:
|
|
277
|
-
height:
|
|
307
|
+
x: cx - centerR,
|
|
308
|
+
y: cy - centerR,
|
|
309
|
+
width: centerR * 2,
|
|
310
|
+
height: centerR * 2,
|
|
278
311
|
generation: 0,
|
|
279
312
|
individual: center
|
|
280
313
|
});
|
|
@@ -443,11 +476,16 @@ function buildEcomapLegend(ast) {
|
|
|
443
476
|
}
|
|
444
477
|
const orderedCats = Array.from(usedCats).sort();
|
|
445
478
|
for (const cat of orderedCats) {
|
|
479
|
+
const color = CATEGORY_COLORS[cat] ?? "#9ca3af";
|
|
446
480
|
items.push({
|
|
447
481
|
key: `cat.${cat}`,
|
|
448
482
|
label: humanize(cat),
|
|
449
|
-
|
|
450
|
-
color
|
|
483
|
+
// WYSIWYG: system nodes draw as circles with a ~9% tint fill and the
|
|
484
|
+
// category color as stroke — the swatch must match, not show solid color.
|
|
485
|
+
kind: "shape",
|
|
486
|
+
shape: "circle",
|
|
487
|
+
color,
|
|
488
|
+
fill: `${color}18`,
|
|
451
489
|
section: "systems"
|
|
452
490
|
});
|
|
453
491
|
}
|
|
@@ -540,7 +578,7 @@ function renderEcomap(layout, config, ast) {
|
|
|
540
578
|
const connectionsStr = renderConnections(layout.edges, centerNode?.individual.id);
|
|
541
579
|
const centerStr = centerNode ? renderCenter(centerNode, config) : "";
|
|
542
580
|
const systemsStr = renderSystems(systemNodes, config);
|
|
543
|
-
const labelsStr = renderConnectionLabels(layout.edges, t);
|
|
581
|
+
const labelsStr = renderConnectionLabels(layout.edges, layout.nodes, t);
|
|
544
582
|
const layers = [
|
|
545
583
|
title("Ecomap"),
|
|
546
584
|
desc(`Ecomap diagram with ${systemNodes.length} external systems`),
|
|
@@ -626,7 +664,7 @@ function buildStyles(config, t) {
|
|
|
626
664
|
.schematex-ecomap-eco-line-weak { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; stroke-dasharray: 6,4; fill: none; stroke-linecap: round; }
|
|
627
665
|
.schematex-ecomap-eco-line-broken { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; stroke-dasharray: 3,8; fill: none; stroke-linecap: round; }
|
|
628
666
|
.schematex-ecomap-eco-line-stressful { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; fill: none; stroke-linecap: round; }
|
|
629
|
-
.schematex-ecomap-eco-conn-label { font-family: ${config.fontFamily}; font-size: ${config.fontSize - 2}px; text-anchor: middle; fill: ${t.textMuted}; }
|
|
667
|
+
.schematex-ecomap-eco-conn-label { font-family: ${config.fontFamily}; font-size: ${config.fontSize - 2}px; text-anchor: middle; fill: ${t.textMuted}; paint-order: stroke; stroke: ${t.bg}; stroke-width: 3px; stroke-linejoin: round; }
|
|
630
668
|
.schematex-ecomap-eco-arrow { fill: ${t.neutral}; }
|
|
631
669
|
.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line,
|
|
632
670
|
.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line-parallel,
|
|
@@ -837,20 +875,38 @@ function renderConnections(edges, centerId) {
|
|
|
837
875
|
}
|
|
838
876
|
return group({ class: "schematex-ecomap-connections" }, elements);
|
|
839
877
|
}
|
|
840
|
-
function renderConnectionLabels(edges, t) {
|
|
878
|
+
function renderConnectionLabels(edges, nodes, t) {
|
|
841
879
|
const elements = [];
|
|
880
|
+
const clearsNodes = (x, y, halfW) => nodes.every((n) => {
|
|
881
|
+
const r = n.width / 2;
|
|
882
|
+
const ncx = n.x + r;
|
|
883
|
+
const ncy = n.y + r;
|
|
884
|
+
const dx = Math.max(Math.abs(x - ncx) - halfW, 0);
|
|
885
|
+
const dy = Math.abs(y - ncy);
|
|
886
|
+
return dx * dx + dy * dy > (r + 4) * (r + 4);
|
|
887
|
+
});
|
|
842
888
|
for (const edge of edges) {
|
|
843
889
|
if (!edge.relationship.label) continue;
|
|
844
890
|
const coords = extractLineCoords(edge.path);
|
|
845
891
|
if (!coords) continue;
|
|
846
|
-
const
|
|
847
|
-
|
|
892
|
+
const labelW = estimateTextWidth(edge.relationship.label, 10) + 12;
|
|
893
|
+
let lt = 0.5;
|
|
894
|
+
for (const cand of [0.5, 0.62, 0.38, 0.72, 0.28]) {
|
|
895
|
+
const x = coords.x1 + (coords.x2 - coords.x1) * cand;
|
|
896
|
+
const y = coords.y1 + (coords.y2 - coords.y1) * cand;
|
|
897
|
+
if (clearsNodes(x, y, labelW / 2)) {
|
|
898
|
+
lt = cand;
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
const mx = coords.x1 + (coords.x2 - coords.x1) * lt;
|
|
903
|
+
const my = coords.y1 + (coords.y2 - coords.y1) * lt;
|
|
848
904
|
elements.push(
|
|
849
905
|
group({ class: "schematex-ecomap-conn-label-group" }, [
|
|
850
906
|
el("rect", {
|
|
851
|
-
x: mx -
|
|
907
|
+
x: mx - labelW / 2,
|
|
852
908
|
y: my - 8,
|
|
853
|
-
width:
|
|
909
|
+
width: labelW,
|
|
854
910
|
height: 16,
|
|
855
911
|
rx: 3,
|
|
856
912
|
fill: t.bg,
|
|
@@ -1003,6 +1059,6 @@ var ecomap = {
|
|
|
1003
1059
|
}
|
|
1004
1060
|
};
|
|
1005
1061
|
|
|
1006
|
-
export { EcomapParseError, ecomap, layoutEcomap, parseEcomap, renderEcomap };
|
|
1007
|
-
//# sourceMappingURL=chunk-
|
|
1008
|
-
//# sourceMappingURL=chunk-
|
|
1062
|
+
export { EcomapParseError, ecomap, estimateTextWidth, layoutEcomap, parseEcomap, renderEcomap };
|
|
1063
|
+
//# sourceMappingURL=chunk-VWIKDJNV.js.map
|
|
1064
|
+
//# sourceMappingURL=chunk-VWIKDJNV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/diagrams/ecomap/parser.ts","../src/core/text-metrics.ts","../src/diagrams/ecomap/layout.ts","../src/diagrams/ecomap/legend.ts","../src/diagrams/ecomap/renderer.ts","../src/diagrams/ecomap/index.ts"],"names":["text","CATEGORY_COLORS"],"mappings":";;;;;;AAYO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EAC1C,WAAA,CAAY,SAAwB,IAAA,EAAc;AAChD,IAAA,KAAA,CAAM,CAAA,KAAA,EAAQ,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA;AADE,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAElC,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AAAA,EACd;AAAA,EAHoC,IAAA;AAItC;AASA,IAAM,cAAA,GAAmD;AAAA,EACvD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K,OAAO,CAAA;AAC/B,EAAA,OAAO,KAAA;AACT;;;ACxmBO,IAAM,MAAA,GAAwB;AAAA,EACnC,IAAA,EAAM,QAAA;AAAA,EAEN,OAAOD,KAAAA,EAAuB;AAC5B,IAAA,MAAM,SAAA,GAAY,gBAAA,CAAiBA,KAAI,CAAA,EAAG,aAAY,IAAK,EAAA;AAC3D,IAAA,OACE,SAAA,KAAc,YACd,SAAA,CAAU,UAAA,CAAW,SAAS,CAAA,IAC9B,SAAA,CAAU,WAAW,SAAS,CAAA;AAAA,EAElC,CAAA;AAAA,EAEA,KAAA,EAAO,WAAA;AAAA,EAEP,MAAA,CAAOA,OAAc,MAAA,EAA+B;AAClD,IAAA,MAAM,GAAA,GAAM,YAAYA,KAAI,CAAA;AAO5B,IAAA,MAAM,MAAA,GAAS,YAAA,CAAa,GAAiB,CAAA;AAC7C,IAAA,MAAM,YAAA,GAA6B;AAAA,MACjC,UAAA,EAAY,QAAQ,UAAA,IAAc,sCAAA;AAAA,MAClC,QAAA,EAAU,QAAQ,QAAA,IAAY,EAAA;AAAA,MAC9B,KAAA,EAAO,QAAQ,KAAA,IAAS,SAAA;AAAA,MACxB,OAAA,EAAS,QAAQ,OAAA,IAAW;AAAA,KAC9B;AACA,IAAA,OAAO,YAAA,CAAa,MAAA,EAAQ,YAAA,EAAc,GAAG,CAAA;AAAA,EAC/C;AACF","file":"chunk-VWIKDJNV.js","sourcesContent":["import type {\n DiagramAST,\n Individual,\n LegendOverrides,\n Relationship,\n RelationshipType,\n Sex,\n} from \"../../core/types\";\nimport { parseLegendDirective } from \"../../core/legend-parser\";\n\n// ─── Error ─────────────────────────────────────────────────\n\nexport class EcomapParseError extends Error {\n constructor(message: string, public line: number) {\n super(`Line ${line}: ${message}`);\n this.name = \"EcomapParseError\";\n }\n}\n\n// ─── Connection operator table ─────────────────────────────\n\ninterface ConnectionOpInfo {\n relType: RelationshipType;\n energyFlow?: \"from\" | \"to\" | \"mutual\";\n}\n\nconst CONNECTION_OPS: Record<string, ConnectionOpInfo> = {\n \"===\": { relType: \"strong\" },\n \"==\": { relType: \"moderate\" },\n \"---\": { relType: \"normal\" },\n \"- -\": { relType: \"weak\" },\n \"~~~\": { relType: \"stressful\" },\n \"~=~\": { relType: \"stressful-strong\" },\n \"~x~\": { relType: \"conflictual\" },\n \"-/-\": { relType: \"broken\" },\n \"===>\": { relType: \"strong\", energyFlow: \"from\" },\n \"<===\": { relType: \"strong\", energyFlow: \"to\" },\n \"<=>\": { relType: \"moderate\", energyFlow: \"mutual\" },\n \"==>\": { relType: \"moderate\", energyFlow: \"from\" },\n \"<==\": { relType: \"moderate\", energyFlow: \"to\" },\n \"-->\": { relType: \"normal\", energyFlow: \"from\" },\n \"<--\": { relType: \"normal\", energyFlow: \"to\" },\n \"<->\": { relType: \"normal\", energyFlow: \"mutual\" },\n};\n\nconst OP_PATTERN =\n \"===>|<===|===|<=>|==>|<==|<->|-->|<--|~=~|~x~|~~~|-\\\\/-|---|==|- -\";\nconst CONNECTION_RE = new RegExp(\n `^([a-zA-Z][a-zA-Z0-9_-]*)\\\\s+(${OP_PATTERN})\\\\s+([a-zA-Z][a-zA-Z0-9_-]*)(.*)$`\n);\n\n// ─── Public API ────────────────────────────────────────────\n\nexport function parseEcomap(text: string): DiagramAST {\n const lines = text.split(\"\\n\");\n const individuals: Individual[] = [];\n const knownIds = new Set<string>();\n const relationships: Relationship[] = [];\n const metadata: Record<string, string> = {};\n const legendOverrides: LegendOverrides = {};\n let hasLegendOverrides = false;\n let centerId: string | null = null;\n\n let i = 0;\n\n while (\n i < lines.length &&\n (lines[i].trim() === \"\" ||\n lines[i].trim().startsWith(\"#\") ||\n lines[i].trim().startsWith(\"//\") ||\n lines[i].trim().startsWith(\"%%\"))\n ) {\n i++;\n }\n if (i >= lines.length) throw new EcomapParseError(\"Empty input\", 1);\n\n const header = lines[i].trim();\n // Mermaid-style header tolerance: `ecomap`, `ecomap \"Title\"`,\n // `ecomap:mode`, `ecomap:mode \"Title\"`. The `:mode` is captured as\n // metadata for future use; current renderer ignores it.\n const headerMatch = header.match(\n /^ecomap(?::([a-zA-Z][\\w-]*))?\\s*(?:\"([^\"]*)\")?\\s*$/i\n );\n if (!headerMatch)\n throw new EcomapParseError(\n `Expected 'ecomap' header (got '${header}')`,\n i + 1\n );\n if (headerMatch[1]) metadata.mode = headerMatch[1].toLowerCase();\n if (headerMatch[2]) metadata.title = headerMatch[2];\n i++;\n\n while (i < lines.length) {\n const raw = lines[i];\n const trimmed = raw.trim();\n if (\n trimmed === \"\" ||\n trimmed.startsWith(\"#\") ||\n trimmed.startsWith(\"//\") ||\n trimmed.startsWith(\"%%\")\n ) {\n i++;\n continue;\n }\n\n // Legend directives: legend.title, legend.position, legend.label, etc.\n if (parseLegendDirective(trimmed, legendOverrides)) {\n hasLegendOverrides = true;\n i++;\n continue;\n }\n\n // Center definition\n const centerMatch = trimmed.match(\n /^center:\\s*([a-zA-Z][a-zA-Z0-9_-]*)\\s*(\\[.*\\])?\\s*$/\n );\n if (centerMatch) {\n const id = centerMatch[1].toLowerCase();\n centerId = id;\n const props = centerMatch[2] ? parseProps(centerMatch[2]) : {};\n individuals.push(buildIndividual(id, props, true));\n knownIds.add(id);\n i++;\n // Skip indented family content under center\n const baseIndent = leadingSpaces(raw);\n while (i < lines.length) {\n if (lines[i].trim() === \"\") {\n i++;\n continue;\n }\n if (leadingSpaces(lines[i]) > baseIndent + 2) {\n i++;\n } else {\n break;\n }\n }\n continue;\n }\n\n // Connection\n const connMatch = trimmed.match(CONNECTION_RE);\n if (connMatch) {\n const fromRaw = connMatch[1].toLowerCase();\n const op = connMatch[2];\n const toRaw = connMatch[3].toLowerCase();\n const rest = connMatch[4]?.trim() ?? \"\";\n\n const opInfo = CONNECTION_OPS[op];\n if (!opInfo)\n throw new EcomapParseError(`Unknown operator '${op}'`, i + 1);\n\n let label: string | undefined;\n const lblMatch = rest.match(/\\[\\s*label:\\s*\"([^\"]*)\"\\s*\\]/);\n if (lblMatch) label = lblMatch[1];\n\n let from = fromRaw;\n let to = toRaw;\n let flow = opInfo.energyFlow;\n\n if (to === centerId && from !== centerId) {\n [from, to] = [to, from];\n if (flow === \"from\") flow = \"to\";\n else if (flow === \"to\") flow = \"from\";\n }\n\n relationships.push({\n type: opInfo.relType,\n from,\n to,\n label,\n energyFlow: flow,\n });\n i++;\n continue;\n }\n\n // System definition\n const sysMatch = trimmed.match(\n /^([a-zA-Z][a-zA-Z0-9_-]*)\\s*(\\[.*\\])?\\s*$/\n );\n if (sysMatch) {\n const id = sysMatch[1].toLowerCase();\n if (!knownIds.has(id)) {\n const props = sysMatch[2] ? parseProps(sysMatch[2]) : {};\n individuals.push(buildIndividual(id, props, false));\n knownIds.add(id);\n }\n i++;\n continue;\n }\n\n throw new EcomapParseError(`Unexpected: ${trimmed}`, i + 1);\n }\n\n return {\n type: \"ecomap\",\n individuals,\n relationships,\n metadata,\n legendOverrides: hasLegendOverrides ? legendOverrides : undefined,\n };\n}\n\n// ─── Helpers ───────────────────────────────────────────────\n\nfunction leadingSpaces(line: string): number {\n const m = line.match(/^(\\s*)/);\n return m ? m[1].length : 0;\n}\n\nfunction parseProps(bracketStr: string): Record<string, string> {\n const inner = bracketStr.slice(1, -1).trim();\n if (!inner) return {};\n const props: Record<string, string> = {};\n\n for (const part of splitCommas(inner)) {\n const t = part.trim();\n if (!t) continue;\n\n const kv = t.match(/^([\\w][\\w-]*)\\s*:\\s*(?:\"([^\"]*)\"|(\\S+))$/);\n if (kv) {\n props[kv[1]] = kv[2] ?? kv[3];\n continue;\n }\n\n if (t === \"male\" || t === \"female\" || t === \"unknown\") {\n props.sex = t;\n continue;\n }\n\n props[t] = \"true\";\n }\n return props;\n}\n\nfunction splitCommas(s: string): string[] {\n const parts: string[] = [];\n let cur = \"\";\n let inQ = false;\n for (const ch of s) {\n if (ch === '\"') {\n inQ = !inQ;\n cur += ch;\n } else if (ch === \",\" && !inQ) {\n parts.push(cur);\n cur = \"\";\n } else {\n cur += ch;\n }\n }\n if (cur) parts.push(cur);\n return parts;\n}\n\nfunction parseSex(s?: string): Sex {\n switch (s) {\n case \"male\":\n case \"female\":\n case \"unknown\":\n case \"other\":\n case \"nonbinary\":\n case \"intersex\":\n return s;\n default:\n return \"unknown\";\n }\n}\n\nfunction buildIndividual(\n id: string,\n props: Record<string, string>,\n isCenter: boolean\n): Individual {\n const properties: Record<string, string> = {};\n if (isCenter) properties.center = \"true\";\n if (props.category) properties.category = props.category;\n if (props.size) properties.size = props.size;\n if (props.importance) properties.importance = props.importance;\n if (props.sector) properties.sector = props.sector;\n\n return {\n id,\n label: props.label ?? id,\n sex: parseSex(props.sex),\n status: \"alive\",\n age: props.age ? parseInt(props.age, 10) : undefined,\n properties,\n };\n}\n","/**\n * Shared text-width estimation for all diagram layouts.\n *\n * Schematex renders to static SVG with no DOM access, so layouts must\n * *estimate* how wide a label will paint. Before this module, five diagram\n * families each carried their own estimator with different per-char factors\n * and different CJK detection ranges — porting a label from one family to\n * another changed its measured width. This is the single source of truth;\n * new families must use it, existing families migrate as they're touched.\n *\n * The model is a char-class weighted sum (not a single average): full-width\n * glyphs count 1.0 × fontSize, narrow Latin (i, l, punctuation) ~0.32 ×,\n * digits/uppercase ~0.66 ×, other Latin ~0.54 ×. This tracks system-ui within\n * a few percent for typical diagram labels — and critically, it does not\n * under-measure CJK, the main overflow source for LLM-generated diagrams.\n */\n\n/**\n * Full-width character detection — one rule for the whole library.\n * Covers CJK Unified Ideographs (+ext A), Hiragana/Katakana, Hangul,\n * CJK punctuation (U+3000–303F), and full-width forms (U+FF00–FF60).\n */\nconst FULL_WIDTH_RE =\n /[ᄀ-ᇿ⺀-〿-ヿ-㇀-㏿㐀-䶿一-鿿ꥠ-가-豈-︰-﹏-⦆¢-₩]/;\n\nexport function isFullWidth(ch: string): boolean {\n return FULL_WIDTH_RE.test(ch);\n}\n\n/** Narrow Latin glyphs and punctuation (~0.32 × fontSize). */\nconst NARROW_RE = /[iIljtf.,:;'\"!|()[\\]{}` ]/;\n\n/** Wide-ish Latin: digits, uppercase, and the widest lowercase (~0.66 ×). */\nconst WIDE_RE = /[0-9A-HK-Z@#%&mwMW_<>=+~^$]/;\n\nexport interface EstimateTextWidthOptions {\n /** CSS font-weight; ≥600 widens the estimate ~6%. Default 400. */\n fontWeight?: number;\n /** Monospace stacks: every non-full-width char is 0.6 × fontSize. */\n monospace?: boolean;\n}\n\n/**\n * Estimated painted width in px of a single-line string at `fontSize`,\n * assuming the library's system-ui stack (or a monospace stack with\n * `monospace: true`).\n */\nexport function estimateTextWidth(\n text: string,\n fontSize: number,\n opts: EstimateTextWidthOptions = {}\n): number {\n let units = 0;\n for (const ch of text) {\n if (isFullWidth(ch)) {\n units += 1.0;\n } else if (opts.monospace) {\n units += 0.6;\n } else if (NARROW_RE.test(ch)) {\n units += 0.32;\n } else if (WIDE_RE.test(ch)) {\n units += 0.66;\n } else {\n units += 0.54;\n }\n }\n const weightFactor = (opts.fontWeight ?? 400) >= 600 ? 1.06 : 1.0;\n return units * fontSize * weightFactor;\n}\n\n/**\n * Width of the widest line in a multi-line string (split on \\n).\n */\nexport function estimateMaxLineWidth(\n text: string,\n fontSize: number,\n opts: EstimateTextWidthOptions = {}\n): number {\n let max = 0;\n for (const line of text.split(\"\\n\")) {\n const w = estimateTextWidth(line, fontSize, opts);\n if (w > max) max = w;\n }\n return max;\n}\n","import type {\n DiagramAST,\n Individual,\n Relationship,\n LayoutConfig,\n LayoutResult,\n LayoutNode,\n LayoutEdge,\n} from \"../../core/types\";\nimport { estimateTextWidth } from \"../../core/text-metrics\";\n\n// ─── Constants ─────────────────────────────────────────────\n\nconst CENTER_R = 50;\n/** Renderer paints the center label at fontSize+2 (= 14px), weight 600. */\nconst CENTER_LABEL_FONT = 14;\n\n/** Center circle must fit its single-line label — grow beyond CENTER_R when needed. */\nfunction getCenterRadius(center: Individual): number {\n const label =\n center.label !== center.id\n ? center.label\n : center.id.charAt(0).toUpperCase() + center.id.slice(1);\n const w = estimateTextWidth(label, CENTER_LABEL_FONT, { fontWeight: 600 });\n return Math.max(CENTER_R, Math.ceil(w / 2) + 10);\n}\nconst SYS_R = 30;\nconst SYS_R_LARGE = 40;\nconst SYS_R_SMALL = 20;\nconst PADDING = 40;\nconst LABEL_CLEARANCE = 60;\n\n// ─── Public API ────────────────────────────────────────────\n\nexport function layoutEcomap(\n ast: DiagramAST,\n _config: LayoutConfig\n): LayoutResult {\n const center = ast.individuals.find(\n (ind) => ind.properties?.center === \"true\"\n );\n if (!center) throw new Error(\"Ecomap requires a center element\");\n\n const systems = ast.individuals.filter(\n (ind) => ind.properties?.center !== \"true\"\n );\n const n = systems.length;\n\n const centerR = getCenterRadius(center);\n\n if (n === 0) {\n const size = (centerR + PADDING + LABEL_CLEARANCE) * 2;\n return {\n width: size,\n height: size,\n nodes: [\n {\n id: center.id,\n x: size / 2 - centerR,\n y: size / 2 - centerR,\n width: centerR * 2,\n height: centerR * 2,\n generation: 0,\n individual: center,\n },\n ],\n edges: [],\n };\n }\n\n const ringRadii = getRingRadii(n);\n const ringAssignment = assignToRings(\n center.id,\n systems,\n ast.relationships,\n ringRadii.length\n );\n const systemPositions = placeOnRings(systems, ringAssignment, ringRadii);\n\n const maxRing = ringRadii[ringRadii.length - 1] ?? 180;\n const canvasSize = (maxRing + SYS_R_LARGE + LABEL_CLEARANCE + PADDING) * 2;\n const cx = canvasSize / 2;\n const cy = canvasSize / 2;\n\n const nodes: LayoutNode[] = [];\n\n nodes.push({\n id: center.id,\n x: cx - centerR,\n y: cy - centerR,\n width: centerR * 2,\n height: centerR * 2,\n generation: 0,\n individual: center,\n });\n\n for (const sys of systems) {\n const pos = systemPositions.get(sys.id);\n if (!pos) continue;\n const r = getSystemRadius(sys);\n nodes.push({\n id: sys.id,\n x: cx + pos.x - r,\n y: cy + pos.y - r,\n width: r * 2,\n height: r * 2,\n generation: pos.ring + 1,\n individual: sys,\n });\n }\n\n const edges = computeEdges(nodes, ast.relationships);\n\n return { width: canvasSize, height: canvasSize, nodes, edges };\n}\n\n// ─── Ring configuration ────────────────────────────────────\n\nfunction getRingRadii(n: number): number[] {\n if (n === 0) return [];\n if (n <= 6) return [180];\n if (n <= 12) return [150, 270];\n return [140, 230, 320];\n}\n\nfunction assignToRings(\n _centerId: string,\n systems: Individual[],\n rels: Relationship[],\n ringCount: number\n): Map<string, number> {\n const relBySys = new Map<string, Relationship>();\n for (const r of rels) {\n const sysId =\n r.from === _centerId ? r.to : r.from === _centerId ? r.to : r.to;\n if (!relBySys.has(sysId)) relBySys.set(sysId, r);\n const otherId = r.from === _centerId ? r.to : r.from;\n if (!relBySys.has(otherId)) relBySys.set(otherId, r);\n }\n\n const result = new Map<string, number>();\n\n if (ringCount <= 1) {\n for (const s of systems) result.set(s.id, 0);\n return result;\n }\n\n for (const s of systems) {\n const rel = relBySys.get(s.id);\n if (!rel) {\n result.set(s.id, ringCount - 1);\n continue;\n }\n\n if (rel.type === \"strong\" || rel.type === \"stressful-strong\") {\n result.set(s.id, 0);\n } else if (rel.type === \"weak\" || rel.type === \"broken\") {\n result.set(s.id, ringCount - 1);\n } else {\n result.set(s.id, Math.min(1, ringCount - 1));\n }\n }\n\n return result;\n}\n\n// ─── Placement ─────────────────────────────────────────────\n\ninterface SysPos {\n x: number;\n y: number;\n ring: number;\n}\n\nfunction placeOnRings(\n systems: Individual[],\n ringAssignment: Map<string, number>,\n ringRadii: number[]\n): Map<string, SysPos> {\n const ringGroups = new Map<number, Individual[]>();\n for (const s of systems) {\n const ring = ringAssignment.get(s.id) ?? 0;\n const grp = ringGroups.get(ring) ?? [];\n grp.push(s);\n ringGroups.set(ring, grp);\n }\n\n const positions = new Map<string, SysPos>();\n\n for (const [ring, grp] of ringGroups) {\n const radius = ringRadii[ring] ?? ringRadii[ringRadii.length - 1] ?? 180;\n const n = grp.length;\n const startAngle = -Math.PI / 2;\n\n for (let idx = 0; idx < n; idx++) {\n const angle = startAngle + (2 * Math.PI * idx) / n;\n positions.set(grp[idx].id, {\n x: radius * Math.cos(angle),\n y: radius * Math.sin(angle),\n ring,\n });\n }\n }\n\n return positions;\n}\n\n// ─── Edges ─────────────────────────────────────────────────\n\nfunction computeEdges(\n nodes: LayoutNode[],\n rels: Relationship[]\n): LayoutEdge[] {\n const nodeMap = new Map<string, LayoutNode>();\n for (const n of nodes) nodeMap.set(n.id, n);\n\n const edges: LayoutEdge[] = [];\n\n for (const rel of rels) {\n const fromNode = nodeMap.get(rel.from);\n const toNode = nodeMap.get(rel.to);\n if (!fromNode || !toNode) continue;\n\n const fcx = fromNode.x + fromNode.width / 2;\n const fcy = fromNode.y + fromNode.height / 2;\n const tcx = toNode.x + toNode.width / 2;\n const tcy = toNode.y + toNode.height / 2;\n\n const dx = tcx - fcx;\n const dy = tcy - fcy;\n const dist = Math.sqrt(dx * dx + dy * dy);\n if (dist < 1) continue;\n\n const ux = dx / dist;\n const uy = dy / dist;\n const fromR = fromNode.width / 2;\n const toR = toNode.width / 2;\n\n const x1 = fcx + ux * fromR;\n const y1 = fcy + uy * fromR;\n const x2 = tcx - ux * toR;\n const y2 = tcy - uy * toR;\n\n edges.push({\n from: rel.from,\n to: rel.to,\n relationship: rel,\n path: `M ${x1} ${y1} L ${x2} ${y2}`,\n });\n }\n\n return edges;\n}\n\n// ─── Helpers ───────────────────────────────────────────────\n\nfunction getSystemRadius(ind: Individual): number {\n const imp = ind.properties?.importance ?? ind.properties?.size;\n switch (imp) {\n case \"major\":\n case \"large\":\n return SYS_R_LARGE;\n case \"minor\":\n case \"small\":\n return SYS_R_SMALL;\n default:\n return SYS_R;\n }\n}\n","/**\n * Auto-derive a LegendSpec from an ecomap AST.\n *\n * Two sections, each emitted only when the diagram uses something non-trivial:\n * 1. Systems — color swatch per used `category` (Hartman palette)\n * 2. Ties — line style per used relationship type (strong/moderate/\n * weak/stressful/conflictual/broken). The default plain\n * line tie is treated as \"obvious\" and not listed.\n */\n\nimport type {\n DiagramAST,\n LegendItem,\n LegendSection,\n LegendSpec,\n RelationshipType,\n} from \"../../core/types\";\n\n// Mirrors the palette in renderer.ts. Kept colocated so the legend swatch\n// matches whatever the renderer paints.\nconst CATEGORY_COLORS: Record<string, string> = {\n family: \"#8D6E63\",\n friends: \"#42A5F5\",\n work: \"#66BB6A\",\n education: \"#FFA726\",\n health: \"#EF5350\",\n \"mental-health\": \"#AB47BC\",\n religion: \"#CCBB33\",\n recreation: \"#26C6DA\",\n legal: \"#78909C\",\n government: \"#8D6E63\",\n financial: \"#66BB6A\",\n community: \"#29B6F6\",\n cultural: \"#FFA726\",\n substance: \"#EF5350\",\n technology: \"#42A5F5\",\n pet: \"#8D6E63\",\n};\n\nconst ECOMAP_TIE_TYPES: ReadonlySet<RelationshipType> = new Set<RelationshipType>([\n \"strong\",\n \"moderate\",\n \"weak\",\n \"stressful\",\n \"stressful-strong\",\n \"conflictual\",\n \"broken\",\n]);\n\nconst SECTIONS: LegendSection[] = [\n { id: \"systems\", title: \"Systems\" },\n { id: \"ties\", title: \"Ties\" },\n];\n\nexport function buildEcomapLegend(ast: DiagramAST): LegendSpec {\n const items: LegendItem[] = [];\n\n // Systems — only categories actually present (excluding the center node).\n const usedCats = new Set<string>();\n for (const ind of ast.individuals) {\n if (ind.properties?.center === \"true\") continue;\n const cat = ind.properties?.category;\n if (cat) usedCats.add(cat);\n }\n // Stable ordering: sort alphabetically.\n const orderedCats = Array.from(usedCats).sort();\n for (const cat of orderedCats) {\n const color = CATEGORY_COLORS[cat] ?? \"#9ca3af\";\n items.push({\n key: `cat.${cat}`,\n label: humanize(cat),\n // WYSIWYG: system nodes draw as circles with a ~9% tint fill and the\n // category color as stroke — the swatch must match, not show solid color.\n kind: \"shape\",\n shape: \"circle\",\n color,\n fill: `${color}18`,\n section: \"systems\",\n });\n }\n\n // Ties — only types used.\n const usedTies = new Set<RelationshipType>();\n for (const r of ast.relationships) {\n if (ECOMAP_TIE_TYPES.has(r.type)) usedTies.add(r.type);\n }\n const tieOrder: RelationshipType[] = [\n \"strong\",\n \"moderate\",\n \"weak\",\n \"stressful\",\n \"stressful-strong\",\n \"conflictual\",\n \"broken\",\n ];\n for (const t of tieOrder) {\n if (!usedTies.has(t)) continue;\n items.push(tieItem(t));\n }\n\n return {\n mode: \"auto\",\n title: \"Legend\",\n position: \"bottom-inline\",\n columns: 1,\n sections: SECTIONS,\n items,\n };\n}\n\nfunction tieItem(t: RelationshipType): LegendItem {\n const base: LegendItem = {\n key: t,\n label: humanize(t),\n kind: \"line\",\n section: \"ties\",\n pattern: \"solid\",\n };\n switch (t) {\n case \"strong\":\n // Three parallel lines visualised — represented in legend as a thicker solid bar.\n return { ...base, strokeWidth: 4 };\n case \"moderate\":\n return { ...base, strokeWidth: 3 };\n case \"weak\":\n return { ...base, pattern: \"dashed\", strokeWidth: 1.5 };\n case \"stressful\":\n return { ...base, pattern: \"wavy\", strokeWidth: 2 };\n case \"stressful-strong\":\n return { ...base, pattern: \"wavy\", strokeWidth: 3 };\n case \"conflictual\":\n return { ...base, kind: \"edge\", pattern: \"wavy\", marker: \"X\", strokeWidth: 2 };\n case \"broken\":\n return { ...base, pattern: \"broken\" };\n default:\n return base;\n }\n}\n\nfunction humanize(s: string): string {\n return s\n .replace(/[-_]+/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n","import type {\n DiagramAST,\n LayoutResult,\n LayoutNode,\n LayoutEdge,\n RenderConfig,\n} from \"../../core/types\";\nimport { svgRoot, el, group, text, title, desc } from \"../../core/svg\";\nimport { cssCustomProperties, resolveBaseTheme, STROKE_WIDTH, type BaseTheme } from \"../../core/theme\";\nimport { applyLegendOverrides, renderLegend } from \"../../core/legend\";\nimport { estimateTextWidth } from \"../../core/text-metrics\";\nimport { buildEcomapLegend } from \"./legend\";\n\n// ─── Category colors (Hartman standard) ────────────────────\n\nconst CATEGORY_COLORS: Record<string, string> = {\n family: \"#8D6E63\",\n friends: \"#42A5F5\",\n work: \"#66BB6A\",\n education: \"#FFA726\",\n health: \"#EF5350\",\n \"mental-health\": \"#AB47BC\",\n religion: \"#CCBB33\",\n recreation: \"#26C6DA\",\n legal: \"#78909C\",\n government: \"#8D6E63\",\n financial: \"#66BB6A\",\n community: \"#29B6F6\",\n cultural: \"#FFA726\",\n substance: \"#EF5350\",\n technology: \"#42A5F5\",\n pet: \"#8D6E63\",\n};\n\n// ─── Public API ────────────────────────────────────────────\n\nexport function renderEcomap(\n layout: LayoutResult,\n config: RenderConfig,\n ast?: DiagramAST\n): string {\n const centerNode = layout.nodes.find(\n (n) => n.individual.properties?.center === \"true\"\n );\n const systemNodes = layout.nodes.filter(\n (n) => n.individual.properties?.center !== \"true\"\n );\n\n const t = resolveBaseTheme(config.theme);\n const defsStr = buildDefs(t);\n const styleStr = buildStyles(config, t);\n const connectionsStr = renderConnections(layout.edges, centerNode?.individual.id);\n const centerStr = centerNode ? renderCenter(centerNode, config) : \"\";\n const systemsStr = renderSystems(systemNodes, config);\n const labelsStr = renderConnectionLabels(layout.edges, layout.nodes, t);\n\n const layers: string[] = [\n title(\"Ecomap\"),\n desc(`Ecomap diagram with ${systemNodes.length} external systems`),\n defsStr,\n styleStr,\n ];\n\n // Defer pushing chart-content until we know whether the legend widens the\n // viewBox so we can horizontally center the chart.\n const chartContent = [\n connectionsStr,\n centerStr,\n systemsStr,\n labelsStr,\n ];\n\n let finalWidth = layout.width;\n let finalHeight = layout.height;\n let legendSvg = \"\";\n\n if (ast) {\n const autoSpec = buildEcomapLegend(ast);\n const finalSpec = applyLegendOverrides(autoSpec, ast.legendOverrides);\n if (finalSpec.mode === \"on\" && finalSpec.items.length > 0) {\n const { svg, bbox: lb } = renderLegend(\n finalSpec,\n {\n canvasWidth: layout.width,\n canvasHeight: layout.height,\n padding: 16,\n },\n t,\n { fontFamily: config.fontFamily, fontSize: config.fontSize }\n );\n if (svg) {\n legendSvg = svg;\n const overflowX = lb.x + lb.w + 8;\n const overflowY = lb.y + lb.h + 8;\n if (overflowX > finalWidth) finalWidth = overflowX;\n if (overflowY > finalHeight) finalHeight = overflowY;\n }\n }\n }\n\n const chartXOffset = Math.max(0, (finalWidth - layout.width) / 2);\n layers.push(\n group(\n { transform: chartXOffset > 0 ? `translate(${chartXOffset}, 0)` : undefined },\n chartContent\n )\n );\n if (legendSvg) layers.push(legendSvg);\n\n return svgRoot(\n {\n viewBox: `0 0 ${finalWidth} ${finalHeight}`,\n class: \"schematex-diagram schematex-ecomap\",\n width: finalWidth,\n height: finalHeight,\n },\n layers\n );\n}\n\n// ─── Defs ──────────────────────────────────────────────────\n\nfunction buildDefs(t: BaseTheme): string {\n const arrowMarker = el(\n \"marker\",\n {\n id: \"schematex-ecomap-eco-arrow\",\n viewBox: \"0 0 10 10\",\n refX: \"10\",\n refY: \"5\",\n markerWidth: \"8\",\n markerHeight: \"8\",\n orient: \"auto-start-reverse\",\n },\n [el(\"path\", { d: \"M 0 0 L 10 5 L 0 10 z\", fill: t.neutral })]\n );\n\n return el(\"defs\", {}, [arrowMarker]);\n}\n\n// ─── Styles ────────────────────────────────────────────────\n\nfunction buildStyles(config: RenderConfig, t: BaseTheme): string {\n let css = `\n.schematex-ecomap {${cssCustomProperties(t)}\n}\n.schematex-ecomap-center-shape { fill: ${t.fill}; stroke: ${t.stroke}; stroke-width: ${STROKE_WIDTH.thick}; }\n.schematex-ecomap-center-label { font-family: ${config.fontFamily}; font-size: ${config.fontSize + 2}px; text-anchor: middle; dominant-baseline: central; fill: ${t.text}; font-weight: 600; }\n.schematex-ecomap-system-shape { fill: ${t.fillMuted}; stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; }\n.schematex-ecomap-system-label { font-family: ${config.fontFamily}; font-size: ${config.fontSize - 1}px; text-anchor: middle; fill: ${t.text}; }\n.schematex-ecomap-eco-line { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; fill: none; stroke-linecap: round; }\n.schematex-ecomap-eco-line-parallel { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; fill: none; stroke-linecap: round; }\n.schematex-ecomap-eco-line-weak { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; stroke-dasharray: 6,4; fill: none; stroke-linecap: round; }\n.schematex-ecomap-eco-line-broken { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; stroke-dasharray: 3,8; fill: none; stroke-linecap: round; }\n.schematex-ecomap-eco-line-stressful { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; fill: none; stroke-linecap: round; }\n.schematex-ecomap-eco-conn-label { font-family: ${config.fontFamily}; font-size: ${config.fontSize - 2}px; text-anchor: middle; fill: ${t.textMuted}; paint-order: stroke; stroke: ${t.bg}; stroke-width: 3px; stroke-linejoin: round; }\n.schematex-ecomap-eco-arrow { fill: ${t.neutral}; }\n.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line,\n.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line-parallel,\n.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line-weak,\n.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line-broken,\n.schematex-ecomap-connection-mesosystem .schematex-ecomap-eco-line-stressful { stroke-opacity: 0.55; }\n`;\n\n for (const [cat, color] of Object.entries(CATEGORY_COLORS)) {\n css += `.schematex-ecomap-system-${cat} .schematex-ecomap-system-shape { fill: ${color}18; stroke: ${color}; }\\n`;\n }\n\n return el(\"style\", {}, css);\n}\n\n// ─── Center ────────────────────────────────────────────────\n\nfunction renderCenter(node: LayoutNode, config: RenderConfig): string {\n const cx = node.x + node.width / 2;\n const cy = node.y + node.height / 2;\n const r = node.width / 2;\n const ind = node.individual;\n\n const label = ind.label !== ind.id ? ind.label : capitalize(ind.id);\n const elements: string[] = [\n el(\"circle\", {\n cx,\n cy,\n r,\n class: \"schematex-ecomap-center-shape\",\n }),\n text(\n {\n x: cx,\n y: cy,\n class: \"schematex-ecomap-center-label\",\n },\n label\n ),\n ];\n\n if (ind.age) {\n elements.push(\n text(\n {\n x: cx,\n y: cy + config.fontSize + 4,\n class: \"schematex-ecomap-center-label\",\n \"font-size\": `${config.fontSize}px`,\n \"font-weight\": \"normal\",\n },\n `Age ${ind.age}`\n )\n );\n }\n\n return group(\n { class: \"schematex-ecomap-center\", \"data-id\": ind.id },\n elements\n );\n}\n\n// ─── Systems ───────────────────────────────────────────────\n\nfunction renderSystems(\n nodes: LayoutNode[],\n config: RenderConfig\n): string {\n const elements: string[] = [];\n\n for (const node of nodes) {\n const cx = node.x + node.width / 2;\n const cy = node.y + node.height / 2;\n const r = node.width / 2;\n const ind = node.individual;\n const cat = ind.properties?.category ?? \"other\";\n const label = ind.label !== ind.id ? ind.label : capitalize(ind.id);\n\n const labelLines = wrapLabel(label, 12);\n const labelElements: string[] = [];\n const labelStartY = cy + r + config.fontSize + 2;\n\n for (let li = 0; li < labelLines.length; li++) {\n labelElements.push(\n text(\n {\n x: cx,\n y: labelStartY + li * (config.fontSize + 1),\n class: \"schematex-ecomap-system-label\",\n },\n labelLines[li]\n )\n );\n }\n\n elements.push(\n group(\n {\n class: `schematex-ecomap-system schematex-ecomap-system-${cat}`,\n \"data-system-id\": ind.id,\n },\n [\n el(\"circle\", {\n cx,\n cy,\n r,\n class: \"schematex-ecomap-system-shape\",\n }),\n ...labelElements,\n ]\n )\n );\n }\n\n return group({ class: \"schematex-ecomap-systems\" }, elements);\n}\n\n// ─── Connections ───────────────────────────────────────────\n\nfunction renderConnections(edges: LayoutEdge[], centerId?: string): string {\n const elements: string[] = [];\n\n for (const edge of edges) {\n const coords = extractLineCoords(edge.path);\n if (!coords) continue;\n\n const relType = edge.relationship.type;\n const flow = edge.relationship.energyFlow;\n const lineElements: string[] = [];\n\n const arrowAttrs = getArrowAttrs(flow);\n\n switch (relType) {\n case \"strong\":\n lineElements.push(\n ...parallelLines(coords, 3, 4, {\n class: \"schematex-ecomap-eco-line-parallel\",\n ...arrowAttrs,\n })\n );\n break;\n\n case \"moderate\":\n lineElements.push(\n ...parallelLines(coords, 2, 4, {\n class: \"schematex-ecomap-eco-line-parallel\",\n ...arrowAttrs,\n })\n );\n break;\n\n case \"weak\":\n lineElements.push(\n el(\"line\", {\n x1: coords.x1,\n y1: coords.y1,\n x2: coords.x2,\n y2: coords.y2,\n class: \"schematex-ecomap-eco-line-weak\",\n ...arrowAttrs,\n })\n );\n break;\n\n case \"stressful\":\n case \"stressful-strong\":\n lineElements.push(\n el(\"path\", {\n d: wavyPath(\n coords.x1,\n coords.y1,\n coords.x2,\n coords.y2,\n 8,\n 20\n ),\n class: \"schematex-ecomap-eco-line-stressful\",\n \"stroke-width\": relType === \"stressful-strong\" ? \"3\" : \"2\",\n ...arrowAttrs,\n })\n );\n break;\n\n case \"conflictual\":\n lineElements.push(\n el(\"path\", {\n d: wavyPath(\n coords.x1,\n coords.y1,\n coords.x2,\n coords.y2,\n 8,\n 20\n ),\n class: \"schematex-ecomap-eco-line-stressful\",\n ...arrowAttrs,\n })\n );\n lineElements.push(\n ...conflictMarks(coords)\n );\n break;\n\n case \"broken\":\n lineElements.push(\n el(\"line\", {\n x1: coords.x1,\n y1: coords.y1,\n x2: coords.x2,\n y2: coords.y2,\n class: \"schematex-ecomap-eco-line-broken\",\n ...arrowAttrs,\n })\n );\n break;\n\n default:\n lineElements.push(\n el(\"line\", {\n x1: coords.x1,\n y1: coords.y1,\n x2: coords.x2,\n y2: coords.y2,\n class: \"schematex-ecomap-eco-line\",\n ...arrowAttrs,\n })\n );\n break;\n }\n\n const isMesosystem =\n centerId !== undefined && edge.from !== centerId && edge.to !== centerId;\n const groupClass = isMesosystem\n ? `schematex-ecomap-connection schematex-ecomap-connection-${relType} schematex-ecomap-connection-mesosystem`\n : `schematex-ecomap-connection schematex-ecomap-connection-${relType}`;\n const groupAttrs: Record<string, string> = {\n class: groupClass,\n \"data-from\": edge.from,\n \"data-to\": edge.to,\n };\n if (isMesosystem) groupAttrs[\"data-mesosystem\"] = \"true\";\n\n elements.push(group(groupAttrs, lineElements));\n }\n\n return group({ class: \"schematex-ecomap-connections\" }, elements);\n}\n\n// ─── Connection labels ─────────────────────────────────────\n\nfunction renderConnectionLabels(\n edges: LayoutEdge[],\n nodes: LayoutNode[],\n t: BaseTheme\n): string {\n const elements: string[] = [];\n\n // A label whose anchor lands inside any node circle gets nudged along its\n // line (an outer-ring spoke can pass straight through an inner-ring node).\n const clearsNodes = (x: number, y: number, halfW: number): boolean =>\n nodes.every((n) => {\n const r = n.width / 2;\n const ncx = n.x + r;\n const ncy = n.y + r;\n const dx = Math.max(Math.abs(x - ncx) - halfW, 0);\n const dy = Math.abs(y - ncy);\n return dx * dx + dy * dy > (r + 4) * (r + 4);\n });\n\n for (const edge of edges) {\n if (!edge.relationship.label) continue;\n const coords = extractLineCoords(edge.path);\n if (!coords) continue;\n\n const labelW = estimateTextWidth(edge.relationship.label, 10) + 12;\n let lt = 0.5;\n for (const cand of [0.5, 0.62, 0.38, 0.72, 0.28]) {\n const x = coords.x1 + (coords.x2 - coords.x1) * cand;\n const y = coords.y1 + (coords.y2 - coords.y1) * cand;\n if (clearsNodes(x, y, labelW / 2)) {\n lt = cand;\n break;\n }\n }\n const mx = coords.x1 + (coords.x2 - coords.x1) * lt;\n const my = coords.y1 + (coords.y2 - coords.y1) * lt;\n\n elements.push(\n group({ class: \"schematex-ecomap-conn-label-group\" }, [\n el(\"rect\", {\n x: mx - labelW / 2,\n y: my - 8,\n width: labelW,\n height: 16,\n rx: 3,\n fill: t.bg,\n \"fill-opacity\": \"0.85\",\n }),\n text(\n { x: mx, y: my + 4, class: \"schematex-ecomap-eco-conn-label\" },\n edge.relationship.label\n ),\n ])\n );\n }\n\n return group({ class: \"schematex-ecomap-connection-labels\" }, elements);\n}\n\n// ─── Line type helpers ─────────────────────────────────────\n\ninterface LineCoords {\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n}\n\nfunction extractLineCoords(pathData: string): LineCoords | null {\n const m = pathData.match(\n /M\\s*([\\d.-]+)\\s+([\\d.-]+)\\s*L\\s*([\\d.-]+)\\s+([\\d.-]+)/\n );\n if (!m) return null;\n return { x1: +m[1], y1: +m[2], x2: +m[3], y2: +m[4] };\n}\n\nfunction parallelLines(\n coords: LineCoords,\n count: number,\n gap: number,\n attrs: Record<string, string | number | undefined>\n): string[] {\n const { x1, y1, x2, y2 } = coords;\n const dx = x2 - x1;\n const dy = y2 - y1;\n const len = Math.sqrt(dx * dx + dy * dy);\n if (len < 1) return [];\n\n const nx = -dy / len;\n const ny = dx / len;\n\n const lines: string[] = [];\n const offsets =\n count === 2\n ? [-gap / 2, gap / 2]\n : count === 3\n ? [-gap, 0, gap]\n : [0];\n\n for (const off of offsets) {\n lines.push(\n el(\"line\", {\n x1: x1 + nx * off,\n y1: y1 + ny * off,\n x2: x2 + nx * off,\n y2: y2 + ny * off,\n ...attrs,\n })\n );\n }\n\n return lines;\n}\n\nfunction wavyPath(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n amplitude: number,\n wavelength: number\n): string {\n const dx = x2 - x1;\n const dy = y2 - y1;\n const len = Math.sqrt(dx * dx + dy * dy);\n const segments = Math.max(4, Math.round(len / wavelength));\n\n const ux = dx / len;\n const uy = dy / len;\n const nx = -uy;\n const ny = ux;\n\n let d = `M ${x1} ${y1}`;\n for (let i = 0; i < segments; i++) {\n const t1 = (i + 0.5) / segments;\n const t2 = (i + 1) / segments;\n const sign = i % 2 === 0 ? 1 : -1;\n const cpx = x1 + dx * t1 + nx * amplitude * sign;\n const cpy = y1 + dy * t1 + ny * amplitude * sign;\n const ex = x1 + dx * t2;\n const ey = y1 + dy * t2;\n d += ` Q ${cpx} ${cpy} ${ex} ${ey}`;\n }\n\n return d;\n}\n\nfunction conflictMarks(coords: LineCoords): string[] {\n const mx = (coords.x1 + coords.x2) / 2;\n const my = (coords.y1 + coords.y2) / 2;\n const dx = coords.x2 - coords.x1;\n const dy = coords.y2 - coords.y1;\n const len = Math.sqrt(dx * dx + dy * dy);\n if (len < 1) return [];\n\n const nx = -dy / len;\n const ny = dx / len;\n const markLen = 6;\n\n return [\n el(\"line\", {\n x1: mx - 3 + nx * markLen,\n y1: my - 3 + ny * markLen,\n x2: mx - 3 - nx * markLen,\n y2: my - 3 - ny * markLen,\n class: \"schematex-ecomap-eco-line\",\n \"stroke-width\": \"2\",\n }),\n el(\"line\", {\n x1: mx + 3 + nx * markLen,\n y1: my + 3 + ny * markLen,\n x2: mx + 3 - nx * markLen,\n y2: my + 3 - ny * markLen,\n class: \"schematex-ecomap-eco-line\",\n \"stroke-width\": \"2\",\n }),\n ];\n}\n\nfunction getArrowAttrs(\n flow?: \"from\" | \"to\" | \"mutual\" | \"none\"\n): Record<string, string> {\n if (!flow || flow === \"none\") return {};\n switch (flow) {\n case \"from\":\n return { \"marker-end\": \"url(#schematex-ecomap-eco-arrow)\" };\n case \"to\":\n return { \"marker-start\": \"url(#schematex-ecomap-eco-arrow)\" };\n case \"mutual\":\n return {\n \"marker-start\": \"url(#schematex-ecomap-eco-arrow)\",\n \"marker-end\": \"url(#schematex-ecomap-eco-arrow)\",\n };\n default:\n return {};\n }\n}\n\n// ─── Text helpers ──────────────────────────────────────────\n\nfunction capitalize(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\nfunction wrapLabel(label: string, maxChars: number): string[] {\n if (label.length <= maxChars) return [label];\n const words = label.split(/\\s+/);\n const lines: string[] = [];\n let current = \"\";\n\n for (const word of words) {\n if (current && current.length + word.length + 1 > maxChars) {\n lines.push(current);\n current = word;\n } else {\n current = current ? current + \" \" + word : word;\n }\n }\n if (current) lines.push(current);\n return lines;\n}\n","import type { DiagramPlugin, RenderConfig } from \"../../core/types\";\nimport { firstContentLine } from \"../../core/dsl-preprocess\";\nimport { parseEcomap } from \"./parser\";\nimport { layoutEcomap } from \"./layout\";\nimport { renderEcomap } from \"./renderer\";\n\nexport { parseEcomap, EcomapParseError } from \"./parser\";\nexport { layoutEcomap } from \"./layout\";\nexport { renderEcomap } from \"./renderer\";\n\nexport const ecomap: DiagramPlugin = {\n type: \"ecomap\",\n\n detect(text: string): boolean {\n const firstLine = firstContentLine(text)?.toLowerCase() ?? \"\";\n return (\n firstLine === \"ecomap\" ||\n firstLine.startsWith(\"ecomap \") ||\n firstLine.startsWith(\"ecomap:\")\n );\n },\n\n parse: parseEcomap,\n\n render(text: string, config?: RenderConfig): string {\n const ast = parseEcomap(text);\n const layoutConfig = {\n nodeSpacingX: 80,\n nodeSpacingY: 100,\n nodeWidth: 40,\n nodeHeight: 40,\n };\n const layout = layoutEcomap(ast, layoutConfig);\n const renderConfig: RenderConfig = {\n fontFamily: config?.fontFamily ?? \"system-ui, -apple-system, sans-serif\",\n fontSize: config?.fontSize ?? 12,\n theme: config?.theme ?? \"default\",\n padding: config?.padding ?? 20,\n };\n return renderEcomap(layout, renderConfig, ast);\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { firstContentLine } from './chunk-2KTQ75LN.js';
|
|
2
2
|
import { didYouMean } from './chunk-PIV2A3HG.js';
|
|
3
|
-
import { resolveIndustrialTheme } from './chunk-
|
|
3
|
+
import { resolveIndustrialTheme } from './chunk-TYEQC7PV.js';
|
|
4
4
|
import { matchQuotedTitle } from './chunk-TO6PNBT3.js';
|
|
5
5
|
import { title, desc, el, text, path, group, svgRoot } from './chunk-SYYBKDL7.js';
|
|
6
6
|
|
|
@@ -557,7 +557,7 @@ function buildCss(t) {
|
|
|
557
557
|
.lt-ladder-addr { font: 600 8.5px ui-monospace, monospace; fill: ${t.error}; text-anchor: middle; }
|
|
558
558
|
.lt-ladder-rung-num { font: 10px sans-serif; fill: ${t.textMuted}; text-anchor: end; }
|
|
559
559
|
.lt-ladder-comment { font: italic 10px sans-serif; fill: ${t.textMuted}; }
|
|
560
|
-
.lt-ladder-title { font:
|
|
560
|
+
.lt-ladder-title { font: 700 16px sans-serif; fill: ${t.text}; }
|
|
561
561
|
.lt-ladder-symbol-label { font: bold 10px sans-serif; fill: ${t.stroke}; text-anchor: middle; }
|
|
562
562
|
`.trim();
|
|
563
563
|
}
|
|
@@ -711,7 +711,7 @@ function renderLadder(ast, config) {
|
|
|
711
711
|
children.push(el("style", {}, buildCss(t)));
|
|
712
712
|
if (ast.title) {
|
|
713
713
|
children.push(
|
|
714
|
-
text({ x:
|
|
714
|
+
text({ x: width / 2, y: 20, class: "lt-ladder-title", "text-anchor": "middle" }, ast.title)
|
|
715
715
|
);
|
|
716
716
|
}
|
|
717
717
|
const inner = [];
|
|
@@ -790,5 +790,5 @@ var ladder = {
|
|
|
790
790
|
};
|
|
791
791
|
|
|
792
792
|
export { ladder, layoutLadder, parseLadderDSL, renderLadder };
|
|
793
|
-
//# sourceMappingURL=chunk-
|
|
794
|
-
//# sourceMappingURL=chunk-
|
|
793
|
+
//# sourceMappingURL=chunk-VY4JOTM2.js.map
|
|
794
|
+
//# sourceMappingURL=chunk-VY4JOTM2.js.map
|
|
@@ -0,0 +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":["text","title","el","w","h","slot","nx","ny","id","LINE_H"],"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,CAAA;AAEA,IAAM,aAAA,uBAAoB,GAAA,CAAuB,CAAC,OAAO,KAAA,EAAO,KAAA,EAAO,KAAK,CAAC,CAAA;AAK7E,IAAM,UAAA,uBAAiB,GAAA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\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,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNT6VVMLW_cjs = require('./chunk-NT6VVMLW.cjs');
|
|
4
4
|
var chunkVHDSPI6A_cjs = require('./chunk-VHDSPI6A.cjs');
|
|
5
5
|
var chunk3WNW5Y7P_cjs = require('./chunk-3WNW5Y7P.cjs');
|
|
6
6
|
|
|
@@ -921,7 +921,7 @@ function renderEdgeLabel(le) {
|
|
|
921
921
|
}
|
|
922
922
|
function renderEntity(ast, config) {
|
|
923
923
|
const layout = layoutEntity(ast);
|
|
924
|
-
const t =
|
|
924
|
+
const t = chunkNT6VVMLW_cjs.resolveBaseTheme(config?.theme ?? "default");
|
|
925
925
|
const titleOffset = ast.title ? 34 : 12;
|
|
926
926
|
const width = Math.ceil(layout.width);
|
|
927
927
|
const height = Math.ceil(layout.height + titleOffset);
|
|
@@ -943,7 +943,7 @@ function renderEntity(ast, config) {
|
|
|
943
943
|
])
|
|
944
944
|
);
|
|
945
945
|
if (ast.title) {
|
|
946
|
-
children.push(chunk3WNW5Y7P_cjs.text({ x:
|
|
946
|
+
children.push(chunk3WNW5Y7P_cjs.text({ x: width / 2, y: 22, class: "lt-entity-title", "text-anchor": "middle" }, ast.title));
|
|
947
947
|
}
|
|
948
948
|
const inner = [];
|
|
949
949
|
for (const c of layout.clusters) {
|
|
@@ -1056,5 +1056,5 @@ exports.entity = entity;
|
|
|
1056
1056
|
exports.layoutEntity = layoutEntity;
|
|
1057
1057
|
exports.parseEntityDSL = parseEntityDSL;
|
|
1058
1058
|
exports.renderEntity = renderEntity;
|
|
1059
|
-
//# sourceMappingURL=chunk-
|
|
1060
|
-
//# sourceMappingURL=chunk-
|
|
1059
|
+
//# sourceMappingURL=chunk-VYAUTNHC.cjs.map
|
|
1060
|
+
//# sourceMappingURL=chunk-VYAUTNHC.cjs.map
|