@diagrammo/dgmo 0.46.0 → 0.47.0
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/advanced.d.cts +3 -855
- package/dist/advanced.d.ts +3 -855
- package/dist/advanced.js +541 -70107
- package/dist/analyzer-UYKBXAKR.js +15 -0
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/auto.mjs +1 -1
- package/dist/block.js +83 -69417
- package/dist/calculator-LDYQCDDY.js +11 -0
- package/dist/charts-d3-QOZHKTCT.js +25 -0
- package/dist/chunk-2DXMZRWJ.js +800 -0
- package/dist/chunk-2LACINWN.js +786 -0
- package/dist/chunk-33LCUH4H.js +893 -0
- package/dist/chunk-3CIOJ5YJ.js +35 -0
- package/dist/chunk-3HDBAXF5.js +86 -0
- package/dist/chunk-3JLKYGBQ.js +290 -0
- package/dist/chunk-3MQQNXPD.js +415 -0
- package/dist/chunk-3R5POCTZ.js +967 -0
- package/dist/chunk-3SMGIJDD.js +112 -0
- package/dist/chunk-44CM72SQ.js +409 -0
- package/dist/chunk-4GRI7MEB.js +1604 -0
- package/dist/chunk-4OHACBGX.js +606 -0
- package/dist/chunk-5DH3KYFH.js +21 -0
- package/dist/chunk-5MLYVTYM.js +76 -0
- package/dist/chunk-5QXL4NYS.js +553 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-6EK55ART.js +117 -0
- package/dist/chunk-6FZYCKXB.js +2065 -0
- package/dist/chunk-6HO5ZTXK.js +277 -0
- package/dist/chunk-6KFWC4CO.js +7 -0
- package/dist/chunk-6MTWIQVO.js +121 -0
- package/dist/chunk-6NYWYNBI.js +329 -0
- package/dist/chunk-6SM5NJQH.js +620 -0
- package/dist/chunk-725LDASD.js +422 -0
- package/dist/chunk-76OWZ3BA.js +130 -0
- package/dist/chunk-7JEGTRLD.js +338 -0
- package/dist/chunk-A44USUV7.js +923 -0
- package/dist/chunk-A4GOY3PE.js +25 -0
- package/dist/chunk-A4VFQH5G.js +251 -0
- package/dist/chunk-AELOBFW5.js +375 -0
- package/dist/chunk-AN2MOO5T.js +522 -0
- package/dist/chunk-BMR4CIEO.js +41 -0
- package/dist/chunk-BS7SV7C3.js +51 -0
- package/dist/chunk-BUPDIHML.js +613 -0
- package/dist/chunk-BUVJFRPY.js +887 -0
- package/dist/chunk-C3Z4DX3V.js +112 -0
- package/dist/chunk-CI2G3OEB.js +1818 -0
- package/dist/chunk-CKNVO24D.js +54 -0
- package/dist/chunk-CUVHQHZ7.js +391 -0
- package/dist/chunk-CXK4DZH3.js +114 -0
- package/dist/chunk-DKEPS5LH.js +315 -0
- package/dist/chunk-DU7W62N5.js +487 -0
- package/dist/chunk-DZAQBW35.js +751 -0
- package/dist/chunk-EB6FPQUP.js +316 -0
- package/dist/chunk-EMS2SK26.js +376 -0
- package/dist/chunk-ERLBPDGU.js +510 -0
- package/dist/chunk-EVCVDTXE.js +732 -0
- package/dist/chunk-FCIIHT24.js +384 -0
- package/dist/chunk-FFUN5D66.js +97 -0
- package/dist/chunk-FITOLXSX.js +714 -0
- package/dist/chunk-FMDSF3OV.js +68 -0
- package/dist/chunk-FNB3PNGF.js +410 -0
- package/dist/chunk-G2H74XJZ.js +2104 -0
- package/dist/chunk-GMR5MFHJ.js +339 -0
- package/dist/chunk-H6PI3KJT.js +305 -0
- package/dist/chunk-I46X5VUA.js +59 -0
- package/dist/chunk-I5IGB56C.js +255 -0
- package/dist/chunk-IH6ZMVQ5.js +3950 -0
- package/dist/chunk-IJZFN3HM.js +463 -0
- package/dist/chunk-IPWPWM6R.js +3079 -0
- package/dist/chunk-IYULMRBE.js +23 -0
- package/dist/chunk-IZMRON6C.js +167 -0
- package/dist/chunk-J5FIXQRT.js +813 -0
- package/dist/chunk-JED6ZDEE.js +73 -0
- package/dist/chunk-JEUJOX5X.js +136 -0
- package/dist/chunk-JM4LEPY3.js +436 -0
- package/dist/chunk-L3UHP6TD.js +101 -0
- package/dist/chunk-L66GEFB6.js +524 -0
- package/dist/chunk-LIOHW36Z.js +469 -0
- package/dist/chunk-LP7EC4MI.js +16 -0
- package/dist/chunk-MITI6NOL.js +548 -0
- package/dist/chunk-MO5YHHMQ.js +168 -0
- package/dist/chunk-MZSBFAPJ.js +885 -0
- package/dist/chunk-NNAAJVBU.js +9 -0
- package/dist/chunk-NOTA6TEI.js +47 -0
- package/dist/chunk-NURGB5Z4.js +335 -0
- package/dist/chunk-NX4EQS3U.js +1062 -0
- package/dist/chunk-NXMESY4J.js +1 -0
- package/dist/chunk-OJR3MQYV.js +1458 -0
- package/dist/chunk-OURHMODR.js +454 -0
- package/dist/chunk-P235SVAH.js +1057 -0
- package/dist/chunk-P4RH4OSP.js +1038 -0
- package/dist/chunk-P6T66CCZ.js +226 -0
- package/dist/chunk-PBAHEPLQ.js +223 -0
- package/dist/chunk-PBHE5UG6.js +1530 -0
- package/dist/chunk-PDKUANDZ.js +35 -0
- package/dist/chunk-PWIHZ6NJ.js +296 -0
- package/dist/chunk-QEBUY5NY.js +1685 -0
- package/dist/chunk-QLCCJEJI.js +253 -0
- package/dist/chunk-QOOUC2J5.js +52 -0
- package/dist/chunk-QYTPPDAO.js +402 -0
- package/dist/chunk-R3XI2VC7.js +801 -0
- package/dist/chunk-RCERWOJR.js +154 -0
- package/dist/chunk-RJE5JTVK.js +362 -0
- package/dist/chunk-RTLBSQ3G.js +1155 -0
- package/dist/chunk-RUNNI6VE.js +448 -0
- package/dist/chunk-RVMRZAPB.js +354 -0
- package/dist/chunk-RYEGFMUO.js +955 -0
- package/dist/chunk-RZCF2VVM.js +528 -0
- package/dist/chunk-SML67VPV.js +1025 -0
- package/dist/chunk-SQ7IY53Q.js +44 -0
- package/dist/chunk-SQAG3UXH.js +161 -0
- package/dist/chunk-SRTU6HMQ.js +1851 -0
- package/dist/chunk-T2OE3YQB.js +550 -0
- package/dist/chunk-T3UBLACL.js +299 -0
- package/dist/chunk-TLVIHFRO.js +296 -0
- package/dist/chunk-TYS6CSS5.js +52 -0
- package/dist/chunk-U6EQI3U6.js +130 -0
- package/dist/chunk-UJ4FJLBF.js +86 -0
- package/dist/chunk-ULOEATBZ.js +347 -0
- package/dist/chunk-UNCCZ3NU.js +127 -0
- package/dist/chunk-USZW2HHU.js +197 -0
- package/dist/chunk-UWN33VNX.js +1610 -0
- package/dist/chunk-UZ7EZW3B.js +40 -0
- package/dist/chunk-VOKGH627.js +37 -0
- package/dist/chunk-WBRZJOEC.js +204 -0
- package/dist/chunk-WCSOJFU3.js +380 -0
- package/dist/chunk-WCT3NYCV.js +160 -0
- package/dist/chunk-WVAJFAIA.js +529 -0
- package/dist/chunk-X5LCYCL5.js +394 -0
- package/dist/chunk-XAKEUMEJ.js +1256 -0
- package/dist/chunk-Y2ZE3MSG.js +590 -0
- package/dist/chunk-Y3J7VR52.js +646 -0
- package/dist/chunk-Y5QGVTVC.js +33 -0
- package/dist/chunk-YAA6IID3.js +548 -0
- package/dist/chunk-YGJTDXVR.js +692 -0
- package/dist/chunk-YRYKTYMQ.js +186 -0
- package/dist/chunk-YYVTBZZC.js +61 -0
- package/dist/chunk-Z5CGSFJB.js +647 -0
- package/dist/chunk-Z72XRXD4.js +787 -0
- package/dist/chunk-ZGR7ULFJ.js +978 -0
- package/dist/chunk-ZJEL4H2R.js +851 -0
- package/dist/chunk-ZO27FGJS.js +554 -0
- package/dist/collapse-CLPJD2RL.js +11 -0
- package/dist/collapse-SLINJQW6.js +9 -0
- package/dist/collapse-ZWUFFCK2.js +9 -0
- package/dist/compute-G55RG53N.js +8 -0
- package/dist/dgmo-router-DZCIDUO5.js +73 -0
- package/dist/dimensions-J3FHIMJ6.js +22 -0
- package/dist/element.cjs +1 -1
- package/dist/element.js +1 -1
- package/dist/element.mjs +1 -1
- package/dist/flowchart-parser-ZNSKIBVR.js +21 -0
- package/dist/flowchart-renderer-ZAEOL4DX.js +35 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -469
- package/dist/index.d.ts +3 -469
- package/dist/index.js +137 -69685
- package/dist/layout-46N4JJYK.js +17 -0
- package/dist/layout-5RA6QWR6.js +26 -0
- package/dist/layout-5T6RH5M6.js +14 -0
- package/dist/layout-7QXCNOVS.js +13 -0
- package/dist/layout-EE6GE46Y.js +17 -0
- package/dist/layout-G23F7LDH.js +9 -0
- package/dist/layout-HRBZPFCN.js +23 -0
- package/dist/layout-HWDSRX5E.js +20 -0
- package/dist/layout-HYZPWAK5.js +18 -0
- package/dist/layout-N76NR4ZO.js +19 -0
- package/dist/layout-OB3RI63S.js +14 -0
- package/dist/layout-S2QBYSK2.js +15 -0
- package/dist/layout-UM5F4DJB.js +15 -0
- package/dist/layout-search-OYV77HHS.js +1655 -0
- package/dist/load-data-EHDDZ5ZS.js +8 -0
- package/dist/palettes-PRJ2RI6D.js +56 -0
- package/dist/parser-2MFP2H2E.js +11 -0
- package/dist/parser-3STE62GB.js +21 -0
- package/dist/parser-4FL2CMDG.js +18 -0
- package/dist/parser-4OGOBJJ4.js +13 -0
- package/dist/parser-6BTRLKRZ.js +15 -0
- package/dist/parser-AQETEVRW.js +21 -0
- package/dist/parser-CFZD5IBL.js +12 -0
- package/dist/parser-FUSKFGZN.js +16 -0
- package/dist/parser-I6KXEYFK.js +13 -0
- package/dist/parser-IXSZZQHY.js +18 -0
- package/dist/parser-JAL2HD4I.js +13 -0
- package/dist/parser-KNSQSKQO.js +20 -0
- package/dist/parser-N5O4IHUN.js +13 -0
- package/dist/parser-NGU3ETO6.js +16 -0
- package/dist/parser-NRAI6O25.js +19 -0
- package/dist/parser-O5J4VBII.js +11 -0
- package/dist/parser-OV7NOBW6.js +21 -0
- package/dist/parser-PQ3POX45.js +23 -0
- package/dist/parser-TFZFBVWN.js +11 -0
- package/dist/parser-TRTHDFPP.js +18 -0
- package/dist/parser-VQP2UJ6W.js +11 -0
- package/dist/parser-XDVELHRK.js +13 -0
- package/dist/parser-XKRP7QKP.js +11 -0
- package/dist/parser-Y6WTBU76.js +14 -0
- package/dist/parser-ZSDPZYQP.js +12 -0
- package/dist/renderer-2XQQQ6QR.js +28 -0
- package/dist/renderer-5NDVNDAZ.js +26 -0
- package/dist/renderer-6EEZHMH4.js +26 -0
- package/dist/renderer-6W5462RB.js +43 -0
- package/dist/renderer-7MVLWWQD.js +22 -0
- package/dist/renderer-AWWAF6XD.js +33 -0
- package/dist/renderer-BYCNMBF7.js +34 -0
- package/dist/renderer-CLJHQPBJ.js +29 -0
- package/dist/renderer-GHPZMFU2.js +15 -0
- package/dist/renderer-JGBKUCZD.js +16 -0
- package/dist/renderer-KQB7UGDS.js +19 -0
- package/dist/renderer-PGX2TKVS.js +24 -0
- package/dist/renderer-QIWVHWZO.js +15 -0
- package/dist/renderer-RPOA5YPZ.js +35 -0
- package/dist/renderer-SMIBCRVB.js +24 -0
- package/dist/renderer-T7YKC5VP.js +28 -0
- package/dist/renderer-TOCOVLHS.js +37 -0
- package/dist/renderer-UWA5XS74.js +39 -0
- package/dist/renderer-VACVQYML.js +25 -0
- package/dist/renderer-W4M6QLIJ.js +37 -0
- package/dist/renderer-WZRREQ2P.js +23 -0
- package/dist/renderer-YY2OSF6E.js +27 -0
- package/dist/renderer-Z7I3W2PP.js +24 -0
- package/dist/renderer-ZGNTUWC4.js +22 -0
- package/dist/renderer-ZTR3DER3.js +19 -0
- package/dist/renderer-radial-C32GPJQ7.js +21 -0
- package/dist/resolver-NOAA7ID7.js +13 -0
- package/dist/state-collapse-HCGD6IVJ.js +8 -0
- package/dist/state-parser-Z2V23ATR.js +18 -0
- package/dist/state-renderer-RFYHSP4K.js +34 -0
- package/dist/themes-1-CuKpeH.d.cts +908 -0
- package/dist/themes-1-CuKpeH.d.ts +908 -0
- package/package.json +1 -1
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tryStripDescriptionKeyword
|
|
3
|
+
} from "./chunk-IYULMRBE.js";
|
|
4
|
+
import {
|
|
5
|
+
AUTO_TAG_COLOR_SENTINEL,
|
|
6
|
+
finalizeAutoTagColors,
|
|
7
|
+
isTagBlockHeading,
|
|
8
|
+
matchTagBlockHeading,
|
|
9
|
+
stripDefaultModifier,
|
|
10
|
+
tagAttrKey,
|
|
11
|
+
validateTagGroupNames,
|
|
12
|
+
validateTagValues
|
|
13
|
+
} from "./chunk-QLCCJEJI.js";
|
|
14
|
+
import {
|
|
15
|
+
normalizeName
|
|
16
|
+
} from "./chunk-NOTA6TEI.js";
|
|
17
|
+
import {
|
|
18
|
+
ALL_CHART_TYPES,
|
|
19
|
+
OPTION_NOCOLON_RE,
|
|
20
|
+
SITEMAP_REGISTRY,
|
|
21
|
+
extractColor,
|
|
22
|
+
measureIndent,
|
|
23
|
+
parseFirstLine,
|
|
24
|
+
splitNameAndMeta,
|
|
25
|
+
tryParseSharedOption,
|
|
26
|
+
warnUnknownMetaKeys,
|
|
27
|
+
withTagAliases
|
|
28
|
+
} from "./chunk-Y3J7VR52.js";
|
|
29
|
+
import {
|
|
30
|
+
formatDgmoError,
|
|
31
|
+
makeDgmoError,
|
|
32
|
+
makeFail,
|
|
33
|
+
suggest
|
|
34
|
+
} from "./chunk-CXK4DZH3.js";
|
|
35
|
+
|
|
36
|
+
// src/sitemap/parser.ts
|
|
37
|
+
var CONTAINER_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
38
|
+
var METADATA_RE = /^([^:]+):\s*(.+)$/;
|
|
39
|
+
var ARROW_RE = /^-([^>][^>]*?)?\s*->\s*(.+)$/;
|
|
40
|
+
var BARE_ARROW_RE = /^->\s*(.+)$/;
|
|
41
|
+
function parseArrowLine(trimmed, _palette, _lineNumber, _diagnostics) {
|
|
42
|
+
const bareMatch = trimmed.match(BARE_ARROW_RE);
|
|
43
|
+
if (bareMatch) {
|
|
44
|
+
const rawTarget = bareMatch[1].trim();
|
|
45
|
+
const groupMatch = rawTarget.match(/^\[(.+)\]$/);
|
|
46
|
+
return {
|
|
47
|
+
target: groupMatch ? groupMatch[1].trim() : rawTarget,
|
|
48
|
+
targetIsGroup: !!groupMatch
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const arrowMatch = trimmed.match(ARROW_RE);
|
|
52
|
+
if (arrowMatch) {
|
|
53
|
+
const label = arrowMatch[1]?.trim() || void 0;
|
|
54
|
+
const rawTarget = arrowMatch[2].trim();
|
|
55
|
+
const groupMatch = rawTarget.match(/^\[(.+)\]$/);
|
|
56
|
+
return {
|
|
57
|
+
...label !== void 0 && { label },
|
|
58
|
+
target: groupMatch ? groupMatch[1].trim() : rawTarget,
|
|
59
|
+
targetIsGroup: !!groupMatch
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function looksLikeSitemap(content) {
|
|
65
|
+
const lines = content.split("\n");
|
|
66
|
+
let hasArrow = false;
|
|
67
|
+
let hasContainer = false;
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
const trimmed = line.trim();
|
|
70
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
71
|
+
if (parseFirstLine(trimmed)) continue;
|
|
72
|
+
if (isTagBlockHeading(trimmed)) continue;
|
|
73
|
+
if (/^-.*->\s*.+/.test(trimmed) || /^->\s*.+/.test(trimmed)) {
|
|
74
|
+
hasArrow = true;
|
|
75
|
+
}
|
|
76
|
+
if (CONTAINER_RE.test(trimmed)) {
|
|
77
|
+
hasContainer = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!hasArrow || !hasContainer) return false;
|
|
81
|
+
const hasFlowchartShapes = /[\])][ \t]*-.*->/.test(content) || /->[ \t]*[[(</]/.test(content);
|
|
82
|
+
return !hasFlowchartShapes;
|
|
83
|
+
}
|
|
84
|
+
function parseSitemap(content, palette) {
|
|
85
|
+
const options = {};
|
|
86
|
+
const result = {
|
|
87
|
+
title: null,
|
|
88
|
+
titleLineNumber: null,
|
|
89
|
+
direction: "LR",
|
|
90
|
+
roots: [],
|
|
91
|
+
edges: [],
|
|
92
|
+
tagGroups: [],
|
|
93
|
+
options,
|
|
94
|
+
diagnostics: [],
|
|
95
|
+
error: null
|
|
96
|
+
};
|
|
97
|
+
const fail = makeFail(result);
|
|
98
|
+
const pushError = (line, message) => {
|
|
99
|
+
const diag = makeDgmoError(line, message);
|
|
100
|
+
result.diagnostics.push(diag);
|
|
101
|
+
if (!result.error) result.error = formatDgmoError(diag);
|
|
102
|
+
};
|
|
103
|
+
const pushWarning = (line, message) => {
|
|
104
|
+
result.diagnostics.push(makeDgmoError(line, message, "warning"));
|
|
105
|
+
};
|
|
106
|
+
if (!content?.trim()) {
|
|
107
|
+
return fail(0, "No content provided");
|
|
108
|
+
}
|
|
109
|
+
const lines = content.split("\n");
|
|
110
|
+
let contentStarted = false;
|
|
111
|
+
let nodeCounter = 0;
|
|
112
|
+
let containerCounter = 0;
|
|
113
|
+
let firstLineParsed = false;
|
|
114
|
+
let currentTagGroup = null;
|
|
115
|
+
const metaAliasMap = /* @__PURE__ */ new Map();
|
|
116
|
+
const nameAliasMap = /* @__PURE__ */ new Map();
|
|
117
|
+
const indentStack = [];
|
|
118
|
+
const labelToNode = /* @__PURE__ */ new Map();
|
|
119
|
+
const labelToContainer = /* @__PURE__ */ new Map();
|
|
120
|
+
const deferredArrows = [];
|
|
121
|
+
for (let i = 0; i < lines.length; i++) {
|
|
122
|
+
const line = lines[i];
|
|
123
|
+
const lineNumber = i + 1;
|
|
124
|
+
const trimmed = line.trim();
|
|
125
|
+
if (!trimmed) {
|
|
126
|
+
if (currentTagGroup) {
|
|
127
|
+
currentTagGroup = null;
|
|
128
|
+
}
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (trimmed.startsWith("//")) continue;
|
|
132
|
+
if (!firstLineParsed && !contentStarted) {
|
|
133
|
+
const firstLineResult = parseFirstLine(trimmed);
|
|
134
|
+
if (firstLineResult) {
|
|
135
|
+
firstLineParsed = true;
|
|
136
|
+
if (firstLineResult.chartType !== "sitemap") {
|
|
137
|
+
const allTypes = Array.from(ALL_CHART_TYPES);
|
|
138
|
+
let msg = `Expected chart type "sitemap", got "${firstLineResult.chartType}"`;
|
|
139
|
+
const hint = suggest(firstLineResult.chartType, allTypes);
|
|
140
|
+
if (hint) msg += `. ${hint}`;
|
|
141
|
+
return fail(lineNumber, msg);
|
|
142
|
+
}
|
|
143
|
+
if (firstLineResult.title) {
|
|
144
|
+
result.title = firstLineResult.title;
|
|
145
|
+
result.titleLineNumber = lineNumber;
|
|
146
|
+
}
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const tagBlockMatch = matchTagBlockHeading(trimmed);
|
|
151
|
+
if (tagBlockMatch) {
|
|
152
|
+
if (contentStarted) {
|
|
153
|
+
pushError(lineNumber, "Tag groups must appear before sitemap content");
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const newTagGroup = {
|
|
157
|
+
name: tagBlockMatch.name,
|
|
158
|
+
...tagBlockMatch.alias !== void 0 && {
|
|
159
|
+
alias: tagBlockMatch.alias
|
|
160
|
+
},
|
|
161
|
+
entries: [],
|
|
162
|
+
lineNumber
|
|
163
|
+
};
|
|
164
|
+
currentTagGroup = newTagGroup;
|
|
165
|
+
if (tagBlockMatch.alias) {
|
|
166
|
+
metaAliasMap.set(
|
|
167
|
+
normalizeName(tagBlockMatch.alias),
|
|
168
|
+
tagAttrKey(tagBlockMatch.name)
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
metaAliasMap.set(
|
|
172
|
+
normalizeName(tagBlockMatch.name),
|
|
173
|
+
tagAttrKey(tagBlockMatch.name)
|
|
174
|
+
);
|
|
175
|
+
result.tagGroups.push(newTagGroup);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!contentStarted && !currentTagGroup && measureIndent(line) === 0 && !trimmed.includes("|") && !trimmed.includes("->") && !trimmed.includes(":")) {
|
|
179
|
+
if (/^direction-tb$/i.test(trimmed)) {
|
|
180
|
+
result.direction = "TB";
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (tryParseSharedOption(trimmed, options)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const optMatch = trimmed.match(OPTION_NOCOLON_RE);
|
|
187
|
+
if (optMatch) {
|
|
188
|
+
const key = optMatch[1].trim().toLowerCase();
|
|
189
|
+
options[key] = optMatch[2].trim();
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (currentTagGroup && !contentStarted) {
|
|
194
|
+
const indent2 = measureIndent(line);
|
|
195
|
+
if (indent2 > 0) {
|
|
196
|
+
const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
|
|
197
|
+
const { label, color } = extractColor(
|
|
198
|
+
cleanEntry,
|
|
199
|
+
palette,
|
|
200
|
+
result.diagnostics,
|
|
201
|
+
lineNumber
|
|
202
|
+
);
|
|
203
|
+
currentTagGroup.entries.push({
|
|
204
|
+
value: label,
|
|
205
|
+
color: color ?? AUTO_TAG_COLOR_SENTINEL,
|
|
206
|
+
lineNumber
|
|
207
|
+
});
|
|
208
|
+
if (isDefault) {
|
|
209
|
+
currentTagGroup.defaultValue = label;
|
|
210
|
+
} else if (currentTagGroup.entries.length === 1) {
|
|
211
|
+
currentTagGroup.defaultValue = label;
|
|
212
|
+
}
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
currentTagGroup = null;
|
|
216
|
+
}
|
|
217
|
+
contentStarted = true;
|
|
218
|
+
currentTagGroup = null;
|
|
219
|
+
const indent = measureIndent(line);
|
|
220
|
+
const arrowInfo = parseArrowLine(
|
|
221
|
+
trimmed,
|
|
222
|
+
palette,
|
|
223
|
+
lineNumber,
|
|
224
|
+
result.diagnostics
|
|
225
|
+
);
|
|
226
|
+
if (arrowInfo) {
|
|
227
|
+
const source = findParentNode(indent, indentStack);
|
|
228
|
+
if (!source) {
|
|
229
|
+
pushError(
|
|
230
|
+
lineNumber,
|
|
231
|
+
"Arrow '-> target' must be indented under its source page \u2014 no page precedes it."
|
|
232
|
+
);
|
|
233
|
+
} else {
|
|
234
|
+
deferredArrows.push({
|
|
235
|
+
sourceNode: source,
|
|
236
|
+
targetLabel: arrowInfo.target,
|
|
237
|
+
targetIsGroup: arrowInfo.targetIsGroup,
|
|
238
|
+
...arrowInfo.label !== void 0 && { label: arrowInfo.label },
|
|
239
|
+
lineNumber
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const containerMatch = trimmed.match(CONTAINER_RE);
|
|
245
|
+
const metadataMatch = (() => {
|
|
246
|
+
if (trimmed.includes("|")) return null;
|
|
247
|
+
const m = trimmed.match(METADATA_RE);
|
|
248
|
+
if (!m) return null;
|
|
249
|
+
const keyRegion = m[1].trim();
|
|
250
|
+
if (/\s/.test(keyRegion)) return null;
|
|
251
|
+
return m;
|
|
252
|
+
})();
|
|
253
|
+
if (containerMatch) {
|
|
254
|
+
const rawLabel = containerMatch[1].trim();
|
|
255
|
+
const asMatch = rawLabel.match(
|
|
256
|
+
/^(.*?)\s+as\s+([A-Za-z][A-Za-z0-9_]{0,11})\s*$/
|
|
257
|
+
);
|
|
258
|
+
const label = asMatch ? asMatch[1].trim() : rawLabel;
|
|
259
|
+
const tail = (containerMatch[2] ?? "").trim();
|
|
260
|
+
const containerMetadata = {};
|
|
261
|
+
if (tail.length > 0) {
|
|
262
|
+
Object.assign(
|
|
263
|
+
containerMetadata,
|
|
264
|
+
parseSitemapMetaTail(tail, metaAliasMap)
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
containerCounter++;
|
|
268
|
+
const containerId = `container-${containerCounter}`;
|
|
269
|
+
if (asMatch) nameAliasMap.set(asMatch[2], containerId);
|
|
270
|
+
const node = {
|
|
271
|
+
id: containerId,
|
|
272
|
+
label,
|
|
273
|
+
metadata: containerMetadata,
|
|
274
|
+
children: [],
|
|
275
|
+
parentId: null,
|
|
276
|
+
isContainer: true,
|
|
277
|
+
lineNumber
|
|
278
|
+
};
|
|
279
|
+
attachNode(node, indent, indentStack, result);
|
|
280
|
+
const key = normalizeName(label);
|
|
281
|
+
labelToContainer.set(key, node);
|
|
282
|
+
} else if (metadataMatch && indentStack.length > 0) {
|
|
283
|
+
const rawKey = metadataMatch[1].trim().toLowerCase();
|
|
284
|
+
const key = metaAliasMap.get(rawKey) ?? rawKey;
|
|
285
|
+
const value = metadataMatch[2].trim();
|
|
286
|
+
const parent = findParentNode(indent, indentStack);
|
|
287
|
+
if (!parent) {
|
|
288
|
+
pushError(
|
|
289
|
+
lineNumber,
|
|
290
|
+
"Metadata 'key: value' must be indented under a page \u2014 no page precedes it."
|
|
291
|
+
);
|
|
292
|
+
} else {
|
|
293
|
+
parent.metadata = { ...parent.metadata, [key]: value };
|
|
294
|
+
}
|
|
295
|
+
} else if (metadataMatch && indentStack.length === 0) {
|
|
296
|
+
if (indent === 0) {
|
|
297
|
+
const node = parseNodeLabel(
|
|
298
|
+
trimmed,
|
|
299
|
+
lineNumber,
|
|
300
|
+
palette,
|
|
301
|
+
++nodeCounter,
|
|
302
|
+
metaAliasMap,
|
|
303
|
+
pushWarning,
|
|
304
|
+
result.diagnostics,
|
|
305
|
+
nameAliasMap
|
|
306
|
+
);
|
|
307
|
+
attachNode(node, indent, indentStack, result);
|
|
308
|
+
const key = normalizeName(node.label);
|
|
309
|
+
labelToNode.set(key, node);
|
|
310
|
+
} else {
|
|
311
|
+
pushError(
|
|
312
|
+
lineNumber,
|
|
313
|
+
"Metadata 'key: value' must be indented under a page \u2014 no page precedes it."
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
const descResult = tryStripDescriptionKeyword(trimmed);
|
|
318
|
+
if (descResult.isKeyword && !descResult.needsColon && indentStack.length > 0) {
|
|
319
|
+
const parent = findParentNode(indent, indentStack);
|
|
320
|
+
if (parent) {
|
|
321
|
+
parent.description = [
|
|
322
|
+
...parent.description ?? [],
|
|
323
|
+
descResult.text.trim()
|
|
324
|
+
];
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const enclosingContainer = nestedPageInsideContainer(indent, indentStack);
|
|
329
|
+
if (enclosingContainer) {
|
|
330
|
+
pushError(
|
|
331
|
+
lineNumber,
|
|
332
|
+
`Pages inside container '[${enclosingContainer}]' cannot have indented sub-pages. Containers hold a flat list of pages.`
|
|
333
|
+
);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
const node = parseNodeLabel(
|
|
337
|
+
trimmed,
|
|
338
|
+
lineNumber,
|
|
339
|
+
palette,
|
|
340
|
+
++nodeCounter,
|
|
341
|
+
metaAliasMap,
|
|
342
|
+
pushWarning,
|
|
343
|
+
result.diagnostics,
|
|
344
|
+
nameAliasMap
|
|
345
|
+
);
|
|
346
|
+
attachNode(node, indent, indentStack, result);
|
|
347
|
+
const key = normalizeName(node.label);
|
|
348
|
+
labelToNode.set(key, node);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
for (const arrow of deferredArrows) {
|
|
352
|
+
const aliasHit = nameAliasMap.get(arrow.targetLabel.trim());
|
|
353
|
+
if (aliasHit !== void 0) {
|
|
354
|
+
result.edges.push({
|
|
355
|
+
sourceId: arrow.sourceNode.id,
|
|
356
|
+
targetId: aliasHit,
|
|
357
|
+
...arrow.label !== void 0 && { label: arrow.label },
|
|
358
|
+
lineNumber: arrow.lineNumber
|
|
359
|
+
});
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
const targetKey = normalizeName(arrow.targetLabel);
|
|
363
|
+
if (arrow.targetIsGroup) {
|
|
364
|
+
const targetContainer = labelToContainer.get(targetKey);
|
|
365
|
+
if (!targetContainer) {
|
|
366
|
+
const allLabels = Array.from(labelToContainer.keys());
|
|
367
|
+
let msg = `Group '[${arrow.targetLabel}]' not found`;
|
|
368
|
+
const hint = suggest(targetKey, allLabels);
|
|
369
|
+
if (hint) msg += `. ${hint}`;
|
|
370
|
+
pushError(arrow.lineNumber, msg);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
result.edges.push({
|
|
374
|
+
sourceId: arrow.sourceNode.id,
|
|
375
|
+
targetId: targetContainer.id,
|
|
376
|
+
...arrow.label !== void 0 && { label: arrow.label },
|
|
377
|
+
lineNumber: arrow.lineNumber
|
|
378
|
+
});
|
|
379
|
+
} else {
|
|
380
|
+
const targetNode = labelToNode.get(targetKey);
|
|
381
|
+
if (!targetNode) {
|
|
382
|
+
const allLabels = Array.from(labelToNode.keys());
|
|
383
|
+
let msg = `Arrow target "${arrow.targetLabel}" not found`;
|
|
384
|
+
const hint = suggest(targetKey, allLabels);
|
|
385
|
+
if (hint) msg += `. ${hint}`;
|
|
386
|
+
pushError(arrow.lineNumber, msg);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
result.edges.push({
|
|
390
|
+
sourceId: arrow.sourceNode.id,
|
|
391
|
+
targetId: targetNode.id,
|
|
392
|
+
...arrow.label !== void 0 && { label: arrow.label },
|
|
393
|
+
lineNumber: arrow.lineNumber
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
finalizeAutoTagColors(result.tagGroups, palette);
|
|
398
|
+
if (result.tagGroups.length > 0) {
|
|
399
|
+
const allNodes = [];
|
|
400
|
+
const collectAll = (nodes) => {
|
|
401
|
+
for (const node of nodes) {
|
|
402
|
+
allNodes.push(node);
|
|
403
|
+
collectAll(node.children);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
collectAll(result.roots);
|
|
407
|
+
validateTagValues(allNodes, result.tagGroups, pushWarning, suggest);
|
|
408
|
+
validateTagGroupNames(result.tagGroups, pushWarning, pushError);
|
|
409
|
+
}
|
|
410
|
+
if (result.roots.length === 0 && result.tagGroups.length === 0 && !result.error) {
|
|
411
|
+
const diag = makeDgmoError(1, "No pages found in sitemap");
|
|
412
|
+
result.diagnostics.push(diag);
|
|
413
|
+
result.error = formatDgmoError(diag);
|
|
414
|
+
}
|
|
415
|
+
return result;
|
|
416
|
+
}
|
|
417
|
+
function parseNodeLabel(trimmed, lineNumber, _palette, counter, metaAliasMap = /* @__PURE__ */ new Map(), warnFn, _diagnostics, nameAliasMap) {
|
|
418
|
+
const registry = withTagAliases(
|
|
419
|
+
SITEMAP_REGISTRY,
|
|
420
|
+
new Set(metaAliasMap.keys())
|
|
421
|
+
);
|
|
422
|
+
const id = `node-${counter}`;
|
|
423
|
+
const split = splitNameAndMeta(
|
|
424
|
+
trimmed,
|
|
425
|
+
registry,
|
|
426
|
+
metaAliasMap,
|
|
427
|
+
void 0,
|
|
428
|
+
_diagnostics,
|
|
429
|
+
lineNumber
|
|
430
|
+
);
|
|
431
|
+
if (warnFn) {
|
|
432
|
+
warnUnknownMetaKeys(
|
|
433
|
+
split.meta,
|
|
434
|
+
registry,
|
|
435
|
+
(msg) => warnFn(lineNumber, msg),
|
|
436
|
+
split.name
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
const label = split.name;
|
|
440
|
+
if (split.alias) nameAliasMap?.set(normalizeName(split.alias), id);
|
|
441
|
+
const metadata = { ...split.meta };
|
|
442
|
+
if (split.color !== void 0) metadata["color"] = split.color;
|
|
443
|
+
let description;
|
|
444
|
+
if ("description" in metadata) {
|
|
445
|
+
const descVal = metadata["description"].trim();
|
|
446
|
+
if (descVal) {
|
|
447
|
+
description = [descVal];
|
|
448
|
+
}
|
|
449
|
+
delete metadata["description"];
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
id,
|
|
453
|
+
label,
|
|
454
|
+
metadata,
|
|
455
|
+
...description !== void 0 && { description },
|
|
456
|
+
children: [],
|
|
457
|
+
parentId: null,
|
|
458
|
+
isContainer: false,
|
|
459
|
+
lineNumber
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
function parseSitemapMetaTail(tail, metaAliasMap) {
|
|
463
|
+
const trimmed = tail.trim();
|
|
464
|
+
if (!trimmed?.includes(":")) return {};
|
|
465
|
+
const registry = withTagAliases(
|
|
466
|
+
SITEMAP_REGISTRY,
|
|
467
|
+
new Set(metaAliasMap.keys())
|
|
468
|
+
);
|
|
469
|
+
const split = splitNameAndMeta(
|
|
470
|
+
`color: __smph, ${trimmed}`,
|
|
471
|
+
registry,
|
|
472
|
+
metaAliasMap
|
|
473
|
+
);
|
|
474
|
+
const meta = split.meta;
|
|
475
|
+
if (meta["color"] === "__smph") delete meta["color"];
|
|
476
|
+
return meta;
|
|
477
|
+
}
|
|
478
|
+
function attachNode(node, indent, indentStack, result) {
|
|
479
|
+
while (indentStack.length > 0) {
|
|
480
|
+
const top = indentStack[indentStack.length - 1];
|
|
481
|
+
if (top.indent < indent) break;
|
|
482
|
+
indentStack.pop();
|
|
483
|
+
}
|
|
484
|
+
if (indentStack.length > 0) {
|
|
485
|
+
const parent = indentStack[indentStack.length - 1].node;
|
|
486
|
+
node.parentId = parent.id;
|
|
487
|
+
if (parent.isContainer && Object.keys(parent.metadata).length > 0 && !node.isContainer) {
|
|
488
|
+
node.metadata = { ...parent.metadata, ...node.metadata };
|
|
489
|
+
}
|
|
490
|
+
parent.children.push(node);
|
|
491
|
+
} else {
|
|
492
|
+
result.roots.push(node);
|
|
493
|
+
}
|
|
494
|
+
indentStack.push({ node, indent });
|
|
495
|
+
}
|
|
496
|
+
function nestedPageInsideContainer(indent, indentStack) {
|
|
497
|
+
let idx = indentStack.length - 1;
|
|
498
|
+
while (idx >= 0 && indentStack[idx].indent >= indent) idx--;
|
|
499
|
+
if (idx < 0) return null;
|
|
500
|
+
if (indentStack[idx].node.isContainer) return null;
|
|
501
|
+
for (let k = idx - 1; k >= 0; k--) {
|
|
502
|
+
if (indentStack[k].node.isContainer) return indentStack[k].node.label;
|
|
503
|
+
}
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
function findParentNode(indent, indentStack) {
|
|
507
|
+
for (let i = indentStack.length - 1; i >= 0; i--) {
|
|
508
|
+
if (indentStack[i].indent < indent) {
|
|
509
|
+
return indentStack[i].node;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
if (indentStack.length > 0) {
|
|
513
|
+
return indentStack[indentStack.length - 1].node;
|
|
514
|
+
}
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export {
|
|
519
|
+
looksLikeSitemap,
|
|
520
|
+
parseSitemap
|
|
521
|
+
};
|
|
522
|
+
//# sourceMappingURL=chunk-AN2MOO5T.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/utils/wrapped-desc.ts
|
|
2
|
+
var BULLET_PREFIX = "\u2022 ";
|
|
3
|
+
var BULLET_INDENT_CHARS = 2;
|
|
4
|
+
function wrapDescriptionLines(lines, charsPerLine, lengthFn = (s) => s.length) {
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const line of lines) {
|
|
7
|
+
if (!line.startsWith(BULLET_PREFIX)) {
|
|
8
|
+
const wrapped2 = wrapPlainLine(line, charsPerLine, lengthFn);
|
|
9
|
+
for (const w of wrapped2) result.push({ text: w, kind: "plain" });
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const body = line.slice(BULLET_PREFIX.length);
|
|
13
|
+
const bodyLimit = Math.max(8, charsPerLine - BULLET_INDENT_CHARS);
|
|
14
|
+
const wrapped = wrapPlainLine(body, bodyLimit, lengthFn);
|
|
15
|
+
wrapped.forEach((w, i) => {
|
|
16
|
+
result.push({ text: w, kind: i === 0 ? "bullet-first" : "bullet-cont" });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
function wrapPlainLine(line, charsPerLine, lengthFn) {
|
|
22
|
+
const words = line.split(/\s+/);
|
|
23
|
+
const result = [];
|
|
24
|
+
let current = "";
|
|
25
|
+
for (const word of words) {
|
|
26
|
+
const test = current ? `${current} ${word}` : word;
|
|
27
|
+
if (lengthFn(test) > charsPerLine && current) {
|
|
28
|
+
result.push(current);
|
|
29
|
+
current = word;
|
|
30
|
+
} else {
|
|
31
|
+
current = test;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (current) result.push(current);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
wrapDescriptionLines
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-BMR4CIEO.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/utils/collapse-engine/tree.ts
|
|
2
|
+
function countDescendants(node, shape) {
|
|
3
|
+
let count = 0;
|
|
4
|
+
for (const child of shape.getChildren(node)) {
|
|
5
|
+
count += (shape.countsAsHidden(child) ? 1 : 0) + countDescendants(child, shape);
|
|
6
|
+
}
|
|
7
|
+
return count;
|
|
8
|
+
}
|
|
9
|
+
function computeHiddenCounts(nodes, collapsedIds, hiddenCounts, shape) {
|
|
10
|
+
for (const node of nodes) {
|
|
11
|
+
const children = shape.getChildren(node);
|
|
12
|
+
if (collapsedIds.has(shape.getId(node)) && children.length > 0) {
|
|
13
|
+
hiddenCounts.set(shape.getId(node), countDescendants(node, shape));
|
|
14
|
+
}
|
|
15
|
+
computeHiddenCounts(children, collapsedIds, hiddenCounts, shape);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function pruneCollapsed(node, collapsedIds, shape) {
|
|
19
|
+
for (const child of shape.getChildren(node)) {
|
|
20
|
+
pruneCollapsed(child, collapsedIds, shape);
|
|
21
|
+
}
|
|
22
|
+
if (collapsedIds.has(shape.getId(node)) && shape.getChildren(node).length > 0) {
|
|
23
|
+
shape.setChildren(node, []);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function collapseTree(roots, collapsedIds, shape) {
|
|
27
|
+
const hiddenCounts = /* @__PURE__ */ new Map();
|
|
28
|
+
computeHiddenCounts(roots, collapsedIds, hiddenCounts, shape);
|
|
29
|
+
const clonedRoots = roots.map((root) => shape.clone(root));
|
|
30
|
+
for (const root of clonedRoots) {
|
|
31
|
+
pruneCollapsed(root, collapsedIds, shape);
|
|
32
|
+
}
|
|
33
|
+
return { roots: clonedRoots, hiddenCounts };
|
|
34
|
+
}
|
|
35
|
+
function collectTreeIds(roots, shape) {
|
|
36
|
+
const ids = /* @__PURE__ */ new Set();
|
|
37
|
+
const walk = (nodes) => {
|
|
38
|
+
for (const node of nodes) {
|
|
39
|
+
ids.add(shape.getId(node));
|
|
40
|
+
walk(shape.getChildren(node));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
walk(roots);
|
|
44
|
+
return ids;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
collapseTree,
|
|
49
|
+
collectTreeIds
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-BS7SV7C3.js.map
|