@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,277 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CYCLE_REGISTRY,
|
|
3
|
+
measureIndent,
|
|
4
|
+
parseFirstLine,
|
|
5
|
+
splitNameAndMeta,
|
|
6
|
+
tryParseSharedOption,
|
|
7
|
+
warnUnknownMetaKeys
|
|
8
|
+
} from "./chunk-Y3J7VR52.js";
|
|
9
|
+
import {
|
|
10
|
+
makeDgmoError,
|
|
11
|
+
makeFail
|
|
12
|
+
} from "./chunk-CXK4DZH3.js";
|
|
13
|
+
|
|
14
|
+
// src/cycle/parser.ts
|
|
15
|
+
var BARE_EDGE_RE = /^->\s*(.*)?$/;
|
|
16
|
+
var LABELED_EDGE_RE = /^-(.+?)->\s*(.*)?$/;
|
|
17
|
+
function parseCycle(content) {
|
|
18
|
+
const options = {};
|
|
19
|
+
const result = {
|
|
20
|
+
type: "cycle",
|
|
21
|
+
title: "",
|
|
22
|
+
titleLineNumber: 0,
|
|
23
|
+
nodes: [],
|
|
24
|
+
edges: [],
|
|
25
|
+
direction: "clockwise",
|
|
26
|
+
options,
|
|
27
|
+
diagnostics: [],
|
|
28
|
+
error: null
|
|
29
|
+
};
|
|
30
|
+
const lines = content.split("\n");
|
|
31
|
+
let headerParsed = false;
|
|
32
|
+
let state = "top";
|
|
33
|
+
let currentNode = null;
|
|
34
|
+
let currentEdge = null;
|
|
35
|
+
const fail = makeFail(result);
|
|
36
|
+
const warn = (line, message, severity = "warning") => {
|
|
37
|
+
result.diagnostics.push(makeDgmoError(line, message, severity));
|
|
38
|
+
};
|
|
39
|
+
const info = (line, message) => {
|
|
40
|
+
result.diagnostics.push(makeDgmoError(line, message, "warning"));
|
|
41
|
+
};
|
|
42
|
+
function flushEdge() {
|
|
43
|
+
if (currentEdge) {
|
|
44
|
+
result.edges.push(currentEdge);
|
|
45
|
+
currentEdge = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function flushNode() {
|
|
49
|
+
flushEdge();
|
|
50
|
+
if (currentNode) {
|
|
51
|
+
result.nodes.push(currentNode);
|
|
52
|
+
currentNode = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (let i = 0; i < lines.length; i++) {
|
|
56
|
+
const lineNum = i + 1;
|
|
57
|
+
const raw = lines[i];
|
|
58
|
+
const trimmed = raw.trim();
|
|
59
|
+
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
60
|
+
const indent = measureIndent(raw);
|
|
61
|
+
if (!headerParsed) {
|
|
62
|
+
const firstLineResult = parseFirstLine(trimmed);
|
|
63
|
+
if (firstLineResult?.chartType === "cycle") {
|
|
64
|
+
result.title = firstLineResult.title ?? "";
|
|
65
|
+
result.titleLineNumber = lineNum;
|
|
66
|
+
headerParsed = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
return fail(lineNum, 'Expected "cycle [Title]" as the first line.');
|
|
70
|
+
}
|
|
71
|
+
if (indent === 0 && trimmed === "direction-counterclockwise") {
|
|
72
|
+
result.direction = "counterclockwise";
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (indent === 0 && trimmed.toLowerCase() === "no-descriptions") {
|
|
76
|
+
warn(
|
|
77
|
+
lineNum,
|
|
78
|
+
'"no-descriptions" has been removed \u2014 delete description lines from your source instead.'
|
|
79
|
+
);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (indent === 0 && trimmed.toLowerCase() === "circle-nodes") {
|
|
83
|
+
options["circle-nodes"] = "true";
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (indent === 0 && tryParseSharedOption(trimmed, options)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (indent === 0) {
|
|
90
|
+
flushNode();
|
|
91
|
+
if (trimmed.includes("->") || trimmed.includes("<-")) {
|
|
92
|
+
warn(
|
|
93
|
+
lineNum,
|
|
94
|
+
'Node labels cannot contain "->". Use indented lines for edges.',
|
|
95
|
+
"error"
|
|
96
|
+
);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const split = splitNameAndMeta(
|
|
100
|
+
trimmed,
|
|
101
|
+
CYCLE_REGISTRY,
|
|
102
|
+
/* @__PURE__ */ new Map(),
|
|
103
|
+
void 0,
|
|
104
|
+
result.diagnostics,
|
|
105
|
+
lineNum
|
|
106
|
+
);
|
|
107
|
+
warnUnknownMetaKeys(
|
|
108
|
+
split.meta,
|
|
109
|
+
CYCLE_REGISTRY,
|
|
110
|
+
(msg) => warn(lineNum, msg),
|
|
111
|
+
split.name
|
|
112
|
+
);
|
|
113
|
+
const label = split.name;
|
|
114
|
+
const metadata = { ...split.meta };
|
|
115
|
+
if (split.color !== void 0) metadata["color"] = split.color;
|
|
116
|
+
if (!label) {
|
|
117
|
+
warn(lineNum, "Empty node label.");
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const color = metadata["color"];
|
|
121
|
+
const spanStr = metadata["span"];
|
|
122
|
+
let span = 1;
|
|
123
|
+
if (spanStr !== void 0) {
|
|
124
|
+
const spanVal = parseFloat(spanStr);
|
|
125
|
+
if (isNaN(spanVal) || spanVal <= 0) {
|
|
126
|
+
warn(
|
|
127
|
+
lineNum,
|
|
128
|
+
`span must be a positive number, got "${spanStr}".`,
|
|
129
|
+
"error"
|
|
130
|
+
);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
span = spanVal;
|
|
134
|
+
}
|
|
135
|
+
const descFromPipe = metadata["description"];
|
|
136
|
+
const description = descFromPipe ? [descFromPipe] : [];
|
|
137
|
+
const restMeta = { ...metadata };
|
|
138
|
+
delete restMeta["color"];
|
|
139
|
+
delete restMeta["span"];
|
|
140
|
+
delete restMeta["description"];
|
|
141
|
+
currentNode = {
|
|
142
|
+
label,
|
|
143
|
+
lineNumber: lineNum,
|
|
144
|
+
...color !== void 0 && { color },
|
|
145
|
+
span,
|
|
146
|
+
description,
|
|
147
|
+
metadata: restMeta
|
|
148
|
+
};
|
|
149
|
+
state = "node";
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (indent > 0) {
|
|
153
|
+
const bareMatch = trimmed.match(BARE_EDGE_RE);
|
|
154
|
+
const labeledMatch = !bareMatch ? trimmed.match(LABELED_EDGE_RE) : null;
|
|
155
|
+
const edgeMatch = bareMatch ?? labeledMatch;
|
|
156
|
+
if (edgeMatch) {
|
|
157
|
+
flushEdge();
|
|
158
|
+
if (!currentNode) {
|
|
159
|
+
warn(lineNum, "Edge line found outside of a node context.");
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const edgeLabel = bareMatch ? void 0 : labeledMatch[1]?.trim() || void 0;
|
|
163
|
+
const rest = (bareMatch ? bareMatch[1] ?? "" : labeledMatch[2] ?? "").trim();
|
|
164
|
+
const edgeSplit = splitNameAndMeta(
|
|
165
|
+
rest,
|
|
166
|
+
CYCLE_REGISTRY,
|
|
167
|
+
/* @__PURE__ */ new Map(),
|
|
168
|
+
void 0,
|
|
169
|
+
result.diagnostics,
|
|
170
|
+
lineNum
|
|
171
|
+
);
|
|
172
|
+
warnUnknownMetaKeys(
|
|
173
|
+
edgeSplit.meta,
|
|
174
|
+
CYCLE_REGISTRY,
|
|
175
|
+
(msg) => warn(lineNum, msg),
|
|
176
|
+
edgeSplit.name
|
|
177
|
+
);
|
|
178
|
+
const explicitTarget = edgeSplit.name || void 0;
|
|
179
|
+
if (explicitTarget?.endsWith(":")) {
|
|
180
|
+
warn(
|
|
181
|
+
lineNum,
|
|
182
|
+
`Trailing colon is not valid \u2014 write '${explicitTarget.replace(/:$/, "")}' instead`,
|
|
183
|
+
"error"
|
|
184
|
+
);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const edgeMeta = { ...edgeSplit.meta };
|
|
188
|
+
if (edgeSplit.color !== void 0) edgeMeta["color"] = edgeSplit.color;
|
|
189
|
+
const edgeColor = edgeMeta["color"];
|
|
190
|
+
const widthStr = edgeMeta["width"];
|
|
191
|
+
const edgeWidth = widthStr ? parseFloat(widthStr) : void 0;
|
|
192
|
+
const edgeDescFromPipe = edgeMeta["description"];
|
|
193
|
+
const edgeRestMeta = { ...edgeMeta };
|
|
194
|
+
delete edgeRestMeta["color"];
|
|
195
|
+
delete edgeRestMeta["width"];
|
|
196
|
+
delete edgeRestMeta["description"];
|
|
197
|
+
const sourceIndex = result.nodes.length;
|
|
198
|
+
const targetIndex = sourceIndex + 1;
|
|
199
|
+
currentEdge = {
|
|
200
|
+
sourceIndex,
|
|
201
|
+
targetIndex,
|
|
202
|
+
...edgeLabel !== void 0 && { label: edgeLabel },
|
|
203
|
+
...edgeColor !== void 0 && { color: edgeColor },
|
|
204
|
+
...edgeWidth !== void 0 && { width: edgeWidth },
|
|
205
|
+
description: edgeDescFromPipe ? [edgeDescFromPipe] : [],
|
|
206
|
+
lineNumber: lineNum,
|
|
207
|
+
metadata: edgeRestMeta
|
|
208
|
+
};
|
|
209
|
+
if (explicitTarget) {
|
|
210
|
+
currentEdge._explicitTarget = explicitTarget;
|
|
211
|
+
}
|
|
212
|
+
state = "edge";
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (state === "edge" && currentEdge) {
|
|
216
|
+
const descLine = trimmed.startsWith("- ") ? `\u2022 ${trimmed.substring(2)}` : trimmed;
|
|
217
|
+
currentEdge.description.push(descLine);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (state === "node" && currentNode) {
|
|
221
|
+
const descLine = trimmed.startsWith("- ") ? `\u2022 ${trimmed.substring(2)}` : trimmed;
|
|
222
|
+
currentNode.description.push(descLine);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
warn(
|
|
226
|
+
lineNum,
|
|
227
|
+
`Indented line "${trimmed}" has no step above it \u2014 add a step on a non-indented line first, then indent its details. (\xA721)`
|
|
228
|
+
);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
flushNode();
|
|
233
|
+
if (result.nodes.length < 2) {
|
|
234
|
+
return fail(
|
|
235
|
+
result.titleLineNumber || 1,
|
|
236
|
+
"cycle requires at least 2 nodes."
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
const nodeCount = result.nodes.length;
|
|
240
|
+
const edgeBySource = /* @__PURE__ */ new Map();
|
|
241
|
+
for (const edge of result.edges) {
|
|
242
|
+
edge.targetIndex = (edge.sourceIndex + 1) % nodeCount;
|
|
243
|
+
edgeBySource.set(edge.sourceIndex, edge);
|
|
244
|
+
const typed = edge;
|
|
245
|
+
if (typed._explicitTarget) {
|
|
246
|
+
const actualTarget = result.nodes[edge.targetIndex].label;
|
|
247
|
+
if (typed._explicitTarget !== actualTarget) {
|
|
248
|
+
info(
|
|
249
|
+
edge.lineNumber,
|
|
250
|
+
`In cycle diagrams, edges always connect to the next node ('${actualTarget}'). Explicit target '${typed._explicitTarget}' is ignored.`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
delete typed._explicitTarget;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const allEdges = [];
|
|
257
|
+
for (let i = 0; i < nodeCount; i++) {
|
|
258
|
+
const existing = edgeBySource.get(i);
|
|
259
|
+
if (existing) {
|
|
260
|
+
allEdges.push(existing);
|
|
261
|
+
} else {
|
|
262
|
+
allEdges.push({
|
|
263
|
+
sourceIndex: i,
|
|
264
|
+
targetIndex: (i + 1) % nodeCount,
|
|
265
|
+
description: [],
|
|
266
|
+
metadata: {}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
result.edges = allEdges;
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
parseCycle
|
|
276
|
+
};
|
|
277
|
+
//# sourceMappingURL=chunk-6HO5ZTXK.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/map/load-data.ts
|
|
2
|
+
async function loadNodeBuiltins() {
|
|
3
|
+
const [{ readFile }, { fileURLToPath }, { dirname, resolve }] = await Promise.all([
|
|
4
|
+
import("fs/promises"),
|
|
5
|
+
import("url"),
|
|
6
|
+
import("path")
|
|
7
|
+
]);
|
|
8
|
+
return { readFile, fileURLToPath, dirname, resolve };
|
|
9
|
+
}
|
|
10
|
+
var FILES = {
|
|
11
|
+
worldCoarse: "world-coarse.json",
|
|
12
|
+
worldDetail: "world-detail.json",
|
|
13
|
+
usStates: "us-states.json",
|
|
14
|
+
lakes: "lakes.json",
|
|
15
|
+
rivers: "rivers.json",
|
|
16
|
+
mountainRanges: "mountain-ranges.json",
|
|
17
|
+
naLand: "na-land.json",
|
|
18
|
+
naLakes: "na-lakes.json",
|
|
19
|
+
waterBodies: "water-bodies.json",
|
|
20
|
+
airports: "airports.json",
|
|
21
|
+
gazetteer: "gazetteer.json"
|
|
22
|
+
};
|
|
23
|
+
var CANDIDATE_DIRS = [
|
|
24
|
+
"./data",
|
|
25
|
+
"./map-data",
|
|
26
|
+
"../map-data",
|
|
27
|
+
"../src/map/data"
|
|
28
|
+
];
|
|
29
|
+
var cache;
|
|
30
|
+
async function readJson(nb, dir, name) {
|
|
31
|
+
return JSON.parse(await nb.readFile(nb.resolve(dir, name), "utf8"));
|
|
32
|
+
}
|
|
33
|
+
async function firstExistingDir(nb, baseDir) {
|
|
34
|
+
for (const rel of CANDIDATE_DIRS) {
|
|
35
|
+
const dir = nb.resolve(baseDir, rel);
|
|
36
|
+
try {
|
|
37
|
+
await nb.readFile(nb.resolve(dir, FILES.gazetteer), "utf8");
|
|
38
|
+
return dir;
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new Error(
|
|
43
|
+
`map data assets not found near ${baseDir} (looked in ${CANDIDATE_DIRS.join(", ")}). Run \`pnpm build:map-data\` and \`pnpm build\`.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
function validate(data) {
|
|
47
|
+
const topoOk = (t) => !!t && t.type === "Topology" && !!t.objects;
|
|
48
|
+
if (!topoOk(data.worldCoarse) || !topoOk(data.worldDetail) || !topoOk(data.usStates) || !data.gazetteer || !Array.isArray(data.gazetteer.cities) || !data.gazetteer.byName) {
|
|
49
|
+
throw new Error("map data assets are malformed (failed shape validation)");
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
function moduleBaseDir(nb) {
|
|
54
|
+
try {
|
|
55
|
+
const url = import.meta.url;
|
|
56
|
+
if (url) return nb.dirname(nb.fileURLToPath(url));
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
if (typeof __dirname !== "undefined") return __dirname;
|
|
60
|
+
return process.cwd();
|
|
61
|
+
}
|
|
62
|
+
function loadMapData() {
|
|
63
|
+
cache ??= (async () => {
|
|
64
|
+
const nb = await loadNodeBuiltins();
|
|
65
|
+
const dir = await firstExistingDir(nb, moduleBaseDir(nb));
|
|
66
|
+
const [
|
|
67
|
+
worldCoarse,
|
|
68
|
+
worldDetail,
|
|
69
|
+
usStates,
|
|
70
|
+
lakes,
|
|
71
|
+
rivers,
|
|
72
|
+
mountainRanges,
|
|
73
|
+
naLand,
|
|
74
|
+
naLakes,
|
|
75
|
+
waterBodies,
|
|
76
|
+
airports,
|
|
77
|
+
gazetteer
|
|
78
|
+
] = await Promise.all([
|
|
79
|
+
// worldCoarse (110m) is LOAD-BEARING but NOT a render source: the world
|
|
80
|
+
// basemap renders from worldDetail (50m) at all scales (resolver pins
|
|
81
|
+
// basemaps.world = 'detail'). Coarse stays as the authoritative region
|
|
82
|
+
// name index + dominant-landmass bbox source in resolver.ts. Do not drop it.
|
|
83
|
+
readJson(nb, dir, FILES.worldCoarse),
|
|
84
|
+
readJson(nb, dir, FILES.worldDetail),
|
|
85
|
+
readJson(nb, dir, FILES.usStates),
|
|
86
|
+
// Lakes/rivers/mountain/NA/water assets are optional — older bundles may predate them.
|
|
87
|
+
readJson(nb, dir, FILES.lakes).catch(() => void 0),
|
|
88
|
+
readJson(nb, dir, FILES.rivers).catch(() => void 0),
|
|
89
|
+
readJson(nb, dir, FILES.mountainRanges).catch(
|
|
90
|
+
() => void 0
|
|
91
|
+
),
|
|
92
|
+
readJson(nb, dir, FILES.naLand).catch(() => void 0),
|
|
93
|
+
readJson(nb, dir, FILES.naLakes).catch(() => void 0),
|
|
94
|
+
readJson(nb, dir, FILES.waterBodies).catch(() => void 0),
|
|
95
|
+
readJson(nb, dir, FILES.airports).catch(() => void 0),
|
|
96
|
+
readJson(nb, dir, FILES.gazetteer)
|
|
97
|
+
]);
|
|
98
|
+
return validate({
|
|
99
|
+
worldCoarse,
|
|
100
|
+
worldDetail,
|
|
101
|
+
usStates,
|
|
102
|
+
gazetteer,
|
|
103
|
+
...lakes && { lakes },
|
|
104
|
+
...rivers && { rivers },
|
|
105
|
+
...mountainRanges && { mountainRanges },
|
|
106
|
+
...naLand && { naLand },
|
|
107
|
+
...naLakes && { naLakes },
|
|
108
|
+
...waterBodies && { waterBodies },
|
|
109
|
+
...airports && { airports }
|
|
110
|
+
});
|
|
111
|
+
})().catch((e) => {
|
|
112
|
+
cache = void 0;
|
|
113
|
+
throw e;
|
|
114
|
+
});
|
|
115
|
+
return cache;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
loadMapData
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=chunk-6MTWIQVO.js.map
|