@fengwk/kchart 0.1.1 → 0.2.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +31 -2
  3. package/README.zh-CN.md +31 -2
  4. package/dist/esm/_virtual/_kchart-families.js +2 -1
  5. package/dist/esm/chart/composition.js +7 -5
  6. package/dist/esm/chart/maps.js +9 -7
  7. package/dist/esm/chart/mindmap.js +19 -5
  8. package/dist/esm/chart/multivariate.js +49 -14
  9. package/dist/esm/chart/relations.js +15 -7
  10. package/dist/esm/chart/spec.js +5 -2
  11. package/dist/esm/core/context.js +29 -10
  12. package/dist/esm/core/scene.js +238 -21
  13. package/dist/esm/core/text.js +1 -1
  14. package/dist/esm/diagram/block.js +287 -295
  15. package/dist/esm/diagram/blocks.js +541 -605
  16. package/dist/esm/diagram/board-paint.js +594 -0
  17. package/dist/esm/diagram/board-route.js +60 -0
  18. package/dist/esm/diagram/c4.js +75 -35
  19. package/dist/esm/diagram/class.js +3 -2
  20. package/dist/esm/diagram/cynefin.js +55 -9
  21. package/dist/esm/diagram/eventmodeling.js +4 -2
  22. package/dist/esm/diagram/gantt.js +37 -15
  23. package/dist/esm/diagram/gitgraph.js +26 -5
  24. package/dist/esm/diagram/graph-layout.js +39 -2
  25. package/dist/esm/diagram/graph-route.js +296 -38
  26. package/dist/esm/diagram/info.js +32 -0
  27. package/dist/esm/diagram/journey.js +5 -5
  28. package/dist/esm/diagram/kanban.js +3 -3
  29. package/dist/esm/diagram/layers.js +9 -7
  30. package/dist/esm/diagram/mindmap.js +5 -1
  31. package/dist/esm/diagram/numeric-composition.js +24 -4
  32. package/dist/esm/diagram/numeric-model.js +1 -1
  33. package/dist/esm/diagram/numeric-radar.js +25 -7
  34. package/dist/esm/diagram/numeric-sankey.js +4 -3
  35. package/dist/esm/diagram/numeric-xy.js +12 -2
  36. package/dist/esm/diagram/packet.js +4 -4
  37. package/dist/esm/diagram/quadrant.js +12 -5
  38. package/dist/esm/diagram/railroad-parse.js +20 -10
  39. package/dist/esm/diagram/railroad.js +1 -1
  40. package/dist/esm/diagram/registry.js +46 -8
  41. package/dist/esm/diagram/sequence.js +43 -6
  42. package/dist/esm/diagram/swimlane.js +2 -2
  43. package/dist/esm/diagram/time.js +3 -3
  44. package/dist/esm/diagram/timeline.js +5 -5
  45. package/dist/esm/diagram/treeview.js +5 -3
  46. package/dist/esm/diagram/venn.js +35 -15
  47. package/dist/esm/diagram/wardley.js +61 -26
  48. package/dist/esm/diagram/zenuml.js +338 -0
  49. package/dist/esm/index.d.ts +3 -1
  50. package/dist/esm/mermaid.d.ts +1 -1
  51. package/dist/esm/mermaid.js +2 -1
  52. package/dist/esm/node.js +8 -2
  53. package/dist/esm/src/families.js +6 -1
  54. package/dist/units/chart/composition.js +1 -1
  55. package/dist/units/chart/maps.js +1 -1
  56. package/dist/units/chart/mindmap.js +1 -1
  57. package/dist/units/chart/multivariate.js +1 -1
  58. package/dist/units/chart/relations.js +1 -1
  59. package/dist/units/chart/spec.js +1 -1
  60. package/dist/units/core/context.js +1 -1
  61. package/dist/units/core/scene.js +1 -1
  62. package/dist/units/core/text.js +1 -1
  63. package/dist/units/diagram/block.js +2 -2
  64. package/dist/units/diagram/blocks.js +2 -2
  65. package/dist/units/diagram/board-paint.js +1 -0
  66. package/dist/units/diagram/board-route.js +1 -0
  67. package/dist/units/diagram/c4.js +1 -1
  68. package/dist/units/diagram/class.js +2 -2
  69. package/dist/units/diagram/cynefin.js +2 -2
  70. package/dist/units/diagram/eventmodeling.js +1 -1
  71. package/dist/units/diagram/gantt.js +3 -3
  72. package/dist/units/diagram/gitgraph.js +2 -1
  73. package/dist/units/diagram/graph-layout.js +1 -1
  74. package/dist/units/diagram/graph-route.js +1 -1
  75. package/dist/units/diagram/info.js +2 -0
  76. package/dist/units/diagram/journey.js +3 -3
  77. package/dist/units/diagram/kanban.js +1 -1
  78. package/dist/units/diagram/layers.js +1 -1
  79. package/dist/units/diagram/mindmap.js +1 -1
  80. package/dist/units/diagram/numeric-composition.js +1 -1
  81. package/dist/units/diagram/numeric-model.js +1 -1
  82. package/dist/units/diagram/numeric-radar.js +2 -2
  83. package/dist/units/diagram/numeric-sankey.js +1 -1
  84. package/dist/units/diagram/numeric-xy.js +1 -1
  85. package/dist/units/diagram/packet.js +1 -1
  86. package/dist/units/diagram/quadrant.js +1 -1
  87. package/dist/units/diagram/railroad-parse.js +2 -2
  88. package/dist/units/diagram/railroad.js +1 -1
  89. package/dist/units/diagram/registry.js +2 -2
  90. package/dist/units/diagram/sequence.js +1 -1
  91. package/dist/units/diagram/swimlane.js +2 -2
  92. package/dist/units/diagram/time.js +1 -1
  93. package/dist/units/diagram/timeline.js +1 -1
  94. package/dist/units/diagram/treeview.js +1 -1
  95. package/dist/units/diagram/venn.js +1 -1
  96. package/dist/units/diagram/wardley.js +4 -4
  97. package/dist/units/diagram/zenuml.js +2 -0
  98. package/dist/units.json +79 -51
  99. package/package.json +1 -1
  100. package/dist/esm/diagram/relations.js +0 -966
  101. package/dist/units/diagram/relations.js +0 -3
@@ -1,966 +0,0 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
- import { error, labelText } from "./support.js";
3
- import { parseFlow } from "./graph-parse.js";
4
- import { layoutGraph } from "./graph-layout.js";
5
- import { cubicPath } from "../core/geometry.js";
6
- // src/diagram/relations.js
7
- var relations_exports = /* @__PURE__ */ __exportAll({ implementations: () => implementations });
8
- var TYPES = ["zenuml"];
9
- var MAX = {
10
- nodes: 40,
11
- edges: 60,
12
- lines: 240
13
- };
14
- var ICONS = {
15
- cloud: "M6.657 18c-2.572 0-4.657-2.007-4.657-4.483 0-2.475 2.085-4.482 4.657-4.482.393-1.762 1.794-3.2 3.675-3.773 1.88-.572 3.956-.193 5.444 1 1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486 0 1.927-1.551 3.487-3.465 3.487h-11.878",
16
- database: "M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0 M4 6v6a8 3 0 0 0 16 0v-6 M4 12v6a8 3 0 0 0 16 0v-6",
17
- disk: "M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0 M4 6v6a8 3 0 0 0 16 0v-6 M4 12v6a8 3 0 0 0 16 0v-6",
18
- internet: "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0 M3.6 9h16.8 M3.6 15h16.8 M11.5 3a17 17 0 0 0 0 18 M12.5 3a17 17 0 0 1 0 18",
19
- server: "M3 7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3h-12a3 3 0 0 1-3-3v-2 M3 15a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v2a3 3 0 0 1-3 3h-12a3 3 0 0 1-3-3l0-2 M7 8l0 .01 M7 16l0 .01",
20
- browser: "M4 8h16 M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-12a2 2 0 0 1-2-2l0-12 M8 4v4"
21
- };
22
- var TYPE_WORDS = {
23
- person: ["人员", "Person"],
24
- person_ext: ["外部人员", "External person"],
25
- system: ["软件系统", "Software system"],
26
- system_ext: ["外部系统", "External system"],
27
- container: ["容器", "Container"],
28
- containerdb: ["数据库容器", "Database container"],
29
- containerqueue: ["队列容器", "Queue container"],
30
- component: ["组件", "Component"],
31
- deployment_node: ["部署节点", "Deployment node"],
32
- requirement: ["需求", "Requirement"],
33
- functionalrequirement: ["功能需求", "Functional requirement"],
34
- interfacerequirement: ["接口需求", "Interface requirement"],
35
- performancerequirement: ["性能需求", "Performance requirement"],
36
- physicalrequirement: ["物理需求", "Physical requirement"],
37
- designconstraint: ["设计约束", "Design constraint"],
38
- element: ["元素", "Element"]
39
- };
40
- var validId = (value) => /^[\w.-]+$/u.test(value);
41
- var issue = (lang, line, text) => error(lang, line, `不支持或无效的关系图语句:「${text}」`, `Unsupported or invalid relation-diagram statement: "${text}"`, "按受支持子集修正;未实现语法不会被忽略", "Use the supported subset; unsupported syntax is never ignored");
42
- var unquote = (value) => String(value || "").trim().replace(/^("|')(.*)\1$/u, "$2");
43
- function splitArgs(source) {
44
- const result = [];
45
- let value = "", quote = "", depth = 0;
46
- for (const ch of source) if (quote) {
47
- value += ch;
48
- if (ch === quote) quote = "";
49
- } else if (ch === "\"" || ch === "'") {
50
- quote = ch;
51
- value += ch;
52
- } else if ("([{".includes(ch)) {
53
- depth++;
54
- value += ch;
55
- } else if (")]}".includes(ch)) {
56
- depth--;
57
- value += ch;
58
- } else if (ch === "," && depth === 0) {
59
- result.push(unquote(value).trim());
60
- value = "";
61
- } else value += ch;
62
- result.push(unquote(value).trim());
63
- return result;
64
- }
65
- function parseFor(kind, source, info = {}) {
66
- const lang = info.lang || "zh", firstLine = info.firstLine || 2;
67
- const errors = [], nodes = [], edges = [], groups = [], sequence = [], byId = /* @__PURE__ */ new Map();
68
- let title = info.title || "", parent = null, classNode = null, requirement = null, columns = 1, blockGroup = null;
69
- for (const key of Object.keys(info.options || {})) errors.push(issue(lang, firstLine - 1, `${kind} option ${key}`));
70
- const addNode = (id, label = id, type = "node", line = firstLine, extra = {}) => {
71
- if (!validId(id)) {
72
- errors.push(issue(lang, line, id));
73
- return null;
74
- }
75
- let found = byId.get(id);
76
- if (found) {
77
- if (extra.declared && found.implicit) Object.assign(found, {
78
- label: label || id,
79
- type,
80
- line,
81
- implicit: false,
82
- ...extra
83
- });
84
- else if (extra.declared) errors.push(issue(lang, line, `duplicate declaration ${id}`));
85
- return found;
86
- }
87
- found = {
88
- id,
89
- label: label || id,
90
- type,
91
- line,
92
- parent,
93
- implicit: !extra.declared,
94
- attrs: [],
95
- methods: [],
96
- ...extra
97
- };
98
- byId.set(id, found);
99
- nodes.push(found);
100
- return found;
101
- };
102
- const addEdge = (from, to, label, line, type = "relation", direction = "both", extra = {}) => edges.push({
103
- from,
104
- to,
105
- label: label || "",
106
- line,
107
- type,
108
- direction,
109
- ...extra
110
- });
111
- const lines = String(source ?? "").replace(/\r\n?/gu, "\n").split("\n");
112
- if (lines.length > MAX.lines) errors.push(issue(lang, firstLine + MAX.lines, "input line limit"));
113
- for (let i = 0; i < Math.min(lines.length, MAX.lines); i++) {
114
- const text = lines[i].trim(), line = firstLine + i;
115
- if (!text || text.startsWith("%%")) continue;
116
- const titleMatch = /^title\s+(.+)$/iu.exec(text);
117
- if (titleMatch) {
118
- if (title) errors.push(issue(lang, line, "duplicate title"));
119
- else title = titleMatch[1];
120
- continue;
121
- }
122
- if (kind === "classDiagram") {
123
- let m = /^class\s+([\w.-]+)(?:\s+as\s+(.+?))?\s*\{$/iu.exec(text);
124
- if (m) {
125
- classNode = addNode(m[1], unquote(m[2]) || m[1], "class", line, { declared: true });
126
- continue;
127
- }
128
- if (text === "}") {
129
- if (!classNode) errors.push(issue(lang, line, text));
130
- classNode = null;
131
- continue;
132
- }
133
- m = /^([\w.-]+)(?:\s+"([^"]+)")?\s+(<\|--|<\|\.\.|\.\.\|>|\*--|--\*|o--|--o|\.\.>|-->|--|\.\.)(?:\s+"([^"]+)")?\s+([\w.-]+)(?:\s*:\s*(.*))?$/u.exec(text);
134
- if (m) {
135
- addNode(m[1], m[1], "class", line);
136
- addNode(m[5], m[5], "class", line);
137
- addEdge(m[1], m[5], m[6] || "", line, m[3], ["<|--", "<|.."].includes(m[3]) ? "left" : [
138
- "..|>",
139
- "-->",
140
- "..>"
141
- ].includes(m[3]) ? "right" : "none", {
142
- startCard: m[2] || "",
143
- endCard: m[4] || ""
144
- });
145
- continue;
146
- }
147
- if (classNode && /^[+~#-]?\s*[\w$]+(?:\s*:\s*[\w.$<>\[\]]+|\([^()]*\)(?:\s*:\s*[\w.$<>\[\]]+)?)$/u.test(text)) {
148
- (/[()]/u.test(text) ? classNode.methods : classNode.attrs).push(text);
149
- continue;
150
- }
151
- m = /^class\s+([\w.-]+)(?:\s+as\s+(.+))?$/iu.exec(text);
152
- if (m) {
153
- addNode(m[1], unquote(m[2]) || m[1], "class", line, { declared: true });
154
- continue;
155
- }
156
- } else if (kind === "requirementDiagram") {
157
- let m = /^(requirement|functionalRequirement|performanceRequirement|interfaceRequirement|physicalRequirement|designConstraint|element)\s+([\w.-]+)\s*\{$/iu.exec(text);
158
- if (m) {
159
- requirement = addNode(m[2], m[2], m[1], line, { declared: true });
160
- continue;
161
- }
162
- if (text === "}") {
163
- if (!requirement) errors.push(issue(lang, line, text));
164
- requirement = null;
165
- continue;
166
- }
167
- m = /^(id|text|risk|verifymethod|owner|docref)\s*:\s*(.+)$/iu.exec(text);
168
- if (requirement && m) {
169
- requirement.attrs.push(`${m[1]}: ${m[2]}`);
170
- continue;
171
- }
172
- m = /^([\w.-]+)\s+-\s*(satisfies|contains|derives|refines|traces|copies|verifies)\s*->\s*([\w.-]+)$/iu.exec(text);
173
- if (m) {
174
- addNode(m[1], m[1], "requirement", line);
175
- addNode(m[3], m[3], "requirement", line);
176
- addEdge(m[1], m[3], m[2], line, m[2], "right");
177
- continue;
178
- }
179
- } else if (/^C4/u.test(kind)) {
180
- let m = /^(Enterprise_Boundary|System_Boundary|Container_Boundary|Boundary|Deployment_Node)\s*\(\s*([^,]+),\s*"([^"]+)"(?:,\s*"([^"]*)")?\s*\)\s*\{$/iu.exec(text);
181
- if (m && m[4] && !/^Deployment_Node$/iu.test(m[1])) m = null;
182
- if (m) {
183
- const id = m[2].trim();
184
- if (parent || !validId(id) || groups.some((g) => g.id === id) || byId.has(id)) errors.push(issue(lang, line, `invalid or nested boundary ${id}`));
185
- else {
186
- groups.push({
187
- id,
188
- label: m[4] ? `${m[3]} [${m[4]}]` : m[3],
189
- line,
190
- kind: "c4",
191
- parent: null
192
- });
193
- parent = id;
194
- }
195
- continue;
196
- }
197
- if (text === "}") {
198
- if (!parent) errors.push(issue(lang, line, text));
199
- parent = null;
200
- continue;
201
- }
202
- m = /^Rel(?:_[LRUD])?\s*\(\s*([^,]+),\s*([^,]+),\s*"([^"]+)"(?:,\s*"([^"]*)")?\s*\)$/iu.exec(text);
203
- if (m) {
204
- const label = kind === "C4Dynamic" && !/^\d+\.\s/u.test(m[3]) ? `${edges.length + 1}. ${m[3]}` : m[3];
205
- addEdge(m[1].trim(), m[2].trim(), label, line, "Rel", "right", { description: m[4] || "" });
206
- continue;
207
- }
208
- m = /^Deployment_Node\s*\(\s*([^,]+),\s*"([^"]+)"(?:,\s*"([^"]*)")?\s*\)$/iu.exec(text);
209
- if (m) {
210
- addNode(m[1].trim(), m[2], "Deployment_Node", line, {
211
- attrs: m[3] ? [m[3]] : [],
212
- declared: true
213
- });
214
- continue;
215
- }
216
- m = /^(Person|Person_Ext|System|System_Ext|Container|ContainerDb|ContainerQueue|Component|Deployment_Node)\s*\((.*)\)$/iu.exec(text);
217
- if (m) {
218
- const args = splitArgs(m[2]);
219
- if (args.length >= 2 && args.length <= 5) {
220
- addNode(args[0], args[1], m[1], line, {
221
- attrs: args.slice(2),
222
- declared: true
223
- });
224
- continue;
225
- }
226
- }
227
- } else if (kind === "architecture-beta") {
228
- let m = /^(group|service|junction)\s+([\w.-]+)(?:\(([^)]*)\))?(?:\s*\[([^\]]+)\])?(?:\s+in\s+([\w.-]+))?$/iu.exec(text);
229
- if (m && (m[1].toLowerCase() === "junction" || m[4])) {
230
- const type = m[1].toLowerCase(), icon = (m[3] || "").toLowerCase();
231
- if (type === "group" && m[5]) errors.push(issue(lang, line, "nested architecture groups are unsupported"));
232
- else if (type !== "junction" && !ICONS[icon]) errors.push(issue(lang, line, `unrenderable architecture icon ${icon || "(missing)"}`));
233
- else {
234
- const n = addNode(m[2], m[4] || m[2], type, line, {
235
- icon,
236
- parent: m[5] || null,
237
- declared: true
238
- });
239
- if (n && type === "group") groups.push({
240
- id: n.id,
241
- label: n.label,
242
- line,
243
- kind: "architecture",
244
- parent: null
245
- });
246
- }
247
- continue;
248
- }
249
- m = /^([\w.-]+)(?::([LRTB]))?\s*(<-->|<--|-->|--)\s*(?:([LRTB]):)?([\w.-]+)(?:\s*:\s*(.+))?$/u.exec(text);
250
- if (m) {
251
- const direction = m[3] === "<-->" ? "both" : m[3] === "--" ? "none" : m[3].startsWith("<") ? "left" : "right";
252
- addEdge(m[1], m[5], m[6] || "", line, "architecture", direction, {
253
- startPort: m[2] || "",
254
- endPort: m[4] || ""
255
- });
256
- continue;
257
- }
258
- } else if (kind === "block-beta") {
259
- let m = /^columns\s+(\d+)$/iu.exec(text);
260
- if (m) {
261
- columns = Number(m[1]);
262
- if (columns < 1 || columns > 8) errors.push(issue(lang, line, text));
263
- continue;
264
- }
265
- if (/^space$/iu.test(text)) {
266
- const n = addNode(`__space${nodes.length + 1}`, " ", "space", line, { parent: blockGroup });
267
- if (n) n.hidden = true;
268
- continue;
269
- }
270
- m = /^block(?::([\w.-]+))?$/iu.exec(text);
271
- if (m) {
272
- const id = m[1] || `__block${groups.length + 1}`;
273
- if (blockGroup || !validId(id) || byId.has(id)) errors.push(issue(lang, line, "nested or duplicate block group"));
274
- else {
275
- groups.push({
276
- id,
277
- label: m[1] || "Block group",
278
- line,
279
- kind: "block",
280
- parent: null
281
- });
282
- blockGroup = id;
283
- }
284
- continue;
285
- }
286
- if (/^end$/iu.test(text)) {
287
- if (!blockGroup) errors.push(issue(lang, line, text));
288
- blockGroup = null;
289
- continue;
290
- }
291
- m = /^([\w.-]+)\s*(<-->|<--|-->|---|==|--x)\s*([\w.-]+)(?:\s*:\s*(.*))?$/u.exec(text);
292
- if (m) {
293
- addNode(m[1], m[1], "block", line, { parent: blockGroup });
294
- addNode(m[3], m[3], "block", line, { parent: blockGroup });
295
- const direction = {
296
- "<-->": "both",
297
- "<--": "left",
298
- "-->": "right",
299
- "--x": "right"
300
- }[m[2]] || "none";
301
- addEdge(m[1], m[3], m[4] || "", line, m[2], direction);
302
- continue;
303
- }
304
- m = /^([\w.-]+)(?:\["?([^\]]+?)"?\])?$/u.exec(text);
305
- if (m) {
306
- addNode(m[1], m[2] || m[1], "block", line, { parent: blockGroup });
307
- continue;
308
- }
309
- } else if (kind === "zenuml") {
310
- if (/^(?:@startuml|@enduml)$/iu.test(text)) continue;
311
- if (/^[\w.-]+$/u.test(text)) {
312
- addNode(text, text, "participant", line, { declared: true });
313
- continue;
314
- }
315
- let m = /^([\w.-]+)\s*->\s*([\w.-]+)\s*:\s*(.+)$/u.exec(text);
316
- if (m) {
317
- addNode(m[1], m[1], "participant", line);
318
- addNode(m[2], m[2], "participant", line);
319
- sequence.push({
320
- from: m[1],
321
- to: m[2],
322
- label: m[3],
323
- line,
324
- kind: "message"
325
- });
326
- continue;
327
- }
328
- m = /^([\w.-]+)\.([\w.-]+)\(([^()]*)\)\s*\{\s*([\w.-]+)\.([\w.-]+)\(([^()]*)\)\s*\}$/u.exec(text);
329
- if (m) {
330
- addNode(m[1], m[1], "participant", line);
331
- addNode(m[4], m[4], "participant", line);
332
- sequence.push({
333
- from: m[1],
334
- to: m[1],
335
- label: `${m[2]}(${m[3]})`,
336
- line,
337
- kind: "call"
338
- }, {
339
- from: m[1],
340
- to: m[4],
341
- label: `${m[5]}(${m[6]})`,
342
- line,
343
- kind: "call"
344
- });
345
- continue;
346
- }
347
- m = /^([\w.-]+)\.([\w.-]+)\(([^()]*)\)$/u.exec(text);
348
- if (m) {
349
- addNode(m[1], m[1], "participant", line);
350
- sequence.push({
351
- from: m[1],
352
- to: m[1],
353
- label: `${m[2]}(${m[3]})`,
354
- line,
355
- kind: "call"
356
- });
357
- continue;
358
- }
359
- }
360
- errors.push(issue(lang, line, text));
361
- }
362
- if (classNode) errors.push(issue(lang, classNode.line, "class block missing }"));
363
- if (requirement) errors.push(issue(lang, requirement.line, "requirement block missing }"));
364
- if (parent || blockGroup) errors.push(issue(lang, firstLine + lines.length - 1, "unclosed group"));
365
- for (const edge of edges) {
366
- const a = byId.get(edge.from), b = byId.get(edge.to);
367
- if (!a || !b) errors.push(issue(lang, edge.line, `unknown endpoint ${edge.from} -> ${edge.to}`));
368
- else if ((/^C4/u.test(kind) || kind === "architecture-beta") && (a.implicit || b.implicit)) errors.push(issue(lang, edge.line, `undeclared endpoint ${a.implicit ? a.id : b.id}`));
369
- else if (a.type === "group" || b.type === "group") errors.push(issue(lang, edge.line, `edges to a group are unsupported: ${a.type === "group" ? a.id : b.id}`));
370
- }
371
- for (const group of groups) {
372
- if (group.parent && !groups.some((candidate) => candidate.id === group.parent)) errors.push(issue(lang, group.line, `unknown group parent ${group.parent}`));
373
- if (group.kind !== "architecture" && byId.has(group.id)) errors.push(issue(lang, group.line, `group id conflicts with node ${group.id}`));
374
- }
375
- for (const node of nodes) if (node.parent && !byId.has(node.parent) && !groups.some((group) => group.id === node.parent)) errors.push(issue(lang, node.line, `unknown group ${node.parent}`));
376
- if (kind === "block-beta" && columns > 1 && nodes.length > columns) errors.push(issue(lang, nodes[columns].line, "multi-row block grids are unsupported"));
377
- if (nodes.length > MAX.nodes) errors.push(issue(lang, nodes[MAX.nodes].line, "node limit exceeded"));
378
- if (edges.length > MAX.edges) errors.push(issue(lang, edges[MAX.edges].line, "edge limit exceeded"));
379
- if (!nodes.length) errors.push(issue(lang, firstLine, "diagram must contain at least one node"));
380
- return {
381
- model: {
382
- kind,
383
- title,
384
- nodes,
385
- edges,
386
- groups,
387
- sequence,
388
- columns
389
- },
390
- errors
391
- };
392
- }
393
- function layoutSequence(model, ctx) {
394
- const boxW = Math.max(112, ...model.nodes.map((n) => ctx.measure(n.label, 13, 600) + 24));
395
- const gap = boxW + 38, top = 24, pad = 16;
396
- const xOf = new Map(model.nodes.map((n, i) => [n.id, pad + boxW / 2 + i * gap]));
397
- const width = 32 + boxW + Math.max(0, model.nodes.length - 1) * gap;
398
- const height = Math.max(120, 92 + model.sequence.length * 56), children = [];
399
- for (const n of model.nodes) {
400
- const x = xOf.get(n.id);
401
- children.push(ctx.rect(x - boxW / 2, top, boxW, 34, {
402
- rx: 7,
403
- fill: ctx.color("bg"),
404
- stroke: ctx.color("axis"),
405
- "stroke-width": 1,
406
- meta: {
407
- kind: "participant",
408
- node: n.id
409
- }
410
- }));
411
- children.push(ctx.text(x, 46, n.label, {
412
- anchor: "middle",
413
- size: 13,
414
- weight: 600,
415
- fill: ctx.color("fg"),
416
- meta: {
417
- kind: "participant-label",
418
- node: n.id
419
- }
420
- }));
421
- children.push(ctx.line(x, 58, x, height - 12, {
422
- stroke: ctx.color("tone5"),
423
- "stroke-width": 1,
424
- "stroke-dasharray": "4 4",
425
- meta: {
426
- kind: "lifeline",
427
- participant: n.id
428
- }
429
- }));
430
- }
431
- for (const [i, event] of model.sequence.entries()) {
432
- const y = 82 + i * 56, x1 = xOf.get(event.from), x2 = xOf.get(event.to);
433
- if (x1 === x2) {
434
- children.push(ctx.path(`M${x1} ${y} H${x1 + 26} V${y + 18} H${x1}`, {
435
- fill: "none",
436
- stroke: ctx.design.fg4,
437
- "stroke-width": 1.2,
438
- meta: {
439
- kind: "call",
440
- line: event.line
441
- }
442
- }));
443
- children.push(ctx.text(x1 + 32, y + 13, event.label, {
444
- size: 12,
445
- meta: {
446
- kind: "message-label",
447
- line: event.line
448
- }
449
- }));
450
- } else {
451
- const direction = x2 > x1 ? -1 : 1;
452
- children.push(ctx.line(x1, y, x2, y, {
453
- stroke: ctx.design.fg4,
454
- "stroke-width": 1.2,
455
- meta: {
456
- kind: "message",
457
- line: event.line
458
- }
459
- }));
460
- children.push(ctx.shape("polygon", {
461
- points: `${x2},${y} ${x2 + direction * 7},${y - 4} ${x2 + direction * 7},${y + 4}`,
462
- fill: ctx.color("muted")
463
- }, {
464
- kind: "message-arrow",
465
- line: event.line
466
- }));
467
- children.push(ctx.text((x1 + x2) / 2, y - 6, event.label, {
468
- anchor: "middle",
469
- size: 12,
470
- meta: {
471
- kind: "message-label",
472
- line: event.line
473
- }
474
- }));
475
- }
476
- }
477
- return {
478
- width,
479
- height,
480
- scene: {
481
- width,
482
- height,
483
- children,
484
- title: model.title || model.kind,
485
- heading: model.title || void 0
486
- },
487
- errors: []
488
- };
489
- }
490
- function layoutGeometry(model, { width = 800, lang = "zh", measure, ctx }) {
491
- if (model.kind === "zenuml") return layoutSequence(model, ctx);
492
- const ids = new Map(model.nodes.map((n, i) => [n.id, `rel_${i}`]));
493
- const english = /^en(?:-|$)/iu.test(String(lang));
494
- const typeWord = (type) => {
495
- const words = TYPE_WORDS[String(type).toLowerCase()];
496
- return words ? words[english ? 1 : 0] : type;
497
- };
498
- const typeLine = (n) => [
499
- "node",
500
- "class",
501
- "service",
502
- "block",
503
- "group",
504
- "junction"
505
- ].includes(n.type) ? [] : [typeWord(n.type)];
506
- const quoted = (text) => String(text).replace(/"/gu, "&quot;");
507
- const nodeStatement = (n) => ({
508
- text: `${ids.get(n.id)}["${quoted([
509
- n.label,
510
- ...typeLine(n),
511
- ...n.attrs || [],
512
- ...n.methods || []
513
- ].join("<br/>"))}"]`,
514
- line: n.line
515
- });
516
- const groupIndex = new Map(model.groups.map((group, i) => [group.id, i]));
517
- const statements = [], emitted = /* @__PURE__ */ new Set();
518
- for (const n of model.nodes.filter((node) => node.type !== "group")) {
519
- if (!groupIndex.has(n.parent)) {
520
- statements.push(nodeStatement(n));
521
- continue;
522
- }
523
- if (emitted.has(n.parent)) continue;
524
- emitted.add(n.parent);
525
- const group = model.groups[groupIndex.get(n.parent)];
526
- statements.push({
527
- text: `subgraph grp_${groupIndex.get(n.parent)}["${quoted(group.label)}"]`,
528
- line: group.line
529
- }, ...model.nodes.filter((member) => member.type !== "group" && member.parent === n.parent).map(nodeStatement), {
530
- text: "end",
531
- line: group.line
532
- });
533
- }
534
- for (const edge of model.edges) statements.push({
535
- text: `${ids.get(edge.from)} --> ${ids.get(edge.to)}`,
536
- line: edge.line
537
- });
538
- if (model.kind === "block-beta" && model.columns > 1) for (let i = 0; i + model.columns < model.nodes.length; i++) statements.push({
539
- text: `${ids.get(model.nodes[i].id)} --> ${ids.get(model.nodes[i + model.columns].id)}`,
540
- line: model.nodes[i].line
541
- });
542
- const ports = model.kind === "architecture-beta" ? model.edges.flatMap((edge) => [edge.startPort, edge.endPort]).filter(Boolean) : [];
543
- const sideways = ports.filter((port) => port === "L" || port === "R").length;
544
- const direction = model.kind === "block-beta" && model.columns > 1 || sideways && sideways * 2 >= ports.length ? "LR" : "TB";
545
- const parsed = parseFlow(statements, { direction });
546
- if (parsed.errors?.length) return {
547
- width,
548
- height: 1,
549
- scene: ctx.scene(1, [], model.title || model.kind),
550
- errors: parsed.errors
551
- };
552
- const iconTitles = new Set(model.nodes.filter((n) => n.icon && ICONS[n.icon]).map((n) => n.label));
553
- const graph = layoutGraph(parsed.model, {
554
- width,
555
- measure: (text, font) => measure(text, font) + (iconTitles.has(text) ? 24 : 0)
556
- });
557
- const placements = /* @__PURE__ */ new Map();
558
- for (const item of graph.nodes) {
559
- const n = model.nodes[Number(String(item.id).replace("rel_", ""))];
560
- if (n) placements.set(n.id, {
561
- n,
562
- x: item.x + item.w / 2,
563
- y: item.y + item.h / 2,
564
- w: item.w,
565
- h: item.h,
566
- attrs: [...typeLine(n), ...n.attrs || []],
567
- methods: n.methods || []
568
- });
569
- }
570
- const frames = new Map((graph.frames || []).map((frame) => [frame.id, frame]));
571
- const groupBounds = model.groups.map((group, i) => {
572
- const frame = frames.get(`grp_${i}`);
573
- return frame ? {
574
- group,
575
- left: frame.x,
576
- right: frame.x + frame.w,
577
- top: frame.y,
578
- bottom: frame.y + frame.h
579
- } : null;
580
- }).filter(Boolean);
581
- const overlaps = (a, b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
582
- const errors = [];
583
- for (let i = 0; i < groupBounds.length; i++) {
584
- for (let j = i + 1; j < groupBounds.length; j++) if (overlaps(groupBounds[i], groupBounds[j])) errors.push(error(lang, groupBounds[j].group.line, "分组边界交叠", "Relation group boundaries overlap", "调整分组成员或拆分图", "Adjust group members or split the diagram"));
585
- for (const placement of placements.values()) if (placement.n.parent !== groupBounds[i].group.id && overlaps(groupBounds[i], {
586
- left: placement.x - placement.w / 2,
587
- right: placement.x + placement.w / 2,
588
- top: placement.y - placement.h / 2,
589
- bottom: placement.y + placement.h / 2
590
- })) errors.push(error(lang, placement.n.line, "节点落入其他分组边界", "A node overlaps another group boundary", "调整分组成员或拆分图", "Adjust group members or split the diagram"));
591
- }
592
- if (errors.length) return {
593
- width: graph.width,
594
- height: 1,
595
- scene: ctx.scene(1, [], model.title || model.kind),
596
- errors
597
- };
598
- const children = [];
599
- for (const { group, left, right, top, bottom } of groupBounds) {
600
- children.push(ctx.rect(left, top, right - left, bottom - top, {
601
- rx: 9,
602
- fill: ctx.color("bg"),
603
- "fill-opacity": .3,
604
- stroke: ctx.color("axis"),
605
- "stroke-width": 1,
606
- meta: {
607
- kind: "group",
608
- group: group.id
609
- }
610
- }));
611
- children.push(ctx.text(left + 12, top + 16, group.label, {
612
- size: 12,
613
- weight: 600,
614
- fill: ctx.color("muted"),
615
- meta: {
616
- kind: "group-label",
617
- group: group.id
618
- }
619
- }));
620
- }
621
- const titleHoles = groupBounds.map(({ group, left, top }) => ({
622
- x: left + 8,
623
- y: top + 3,
624
- w: ctx.measure(group.label, 12, 600) + 8,
625
- h: 18
626
- }));
627
- let edgeClip = null;
628
- if (titleHoles.length) {
629
- const x0 = Math.min(0, ...groupBounds.map((g) => g.left)) - 24;
630
- const d = [`M${x0} ${Math.min(0, ...groupBounds.map((g) => g.top)) - 24}H${Math.max(graph.width, ...groupBounds.map((g) => g.right)) + 24}V${Math.max(graph.height, ...groupBounds.map((g) => g.bottom)) + 24}H${x0}Z`, ...titleHoles.map((h) => `M${h.x} ${h.y}H${h.x + h.w}V${h.y + h.h}H${h.x}Z`)].join("");
631
- children.push(ctx.el("clipPath", { id: "group-titles" }, [ctx.path(d, {
632
- "clip-rule": "evenodd",
633
- meta: { kind: "group-title-holes" }
634
- })]));
635
- edgeClip = "url(#group-titles)";
636
- }
637
- for (const route of graph.edges) {
638
- if (route.id >= model.edges.length) continue;
639
- const edge = model.edges[route.id], a = placements.get(edge?.from), b = placements.get(edge?.to);
640
- if (!edge || !a || !b) continue;
641
- let end = route.end || {
642
- x: b.x - b.w / 2,
643
- y: b.y
644
- }, start = route.start || {
645
- x: a.x + a.w / 2,
646
- y: a.y
647
- };
648
- let path;
649
- if (edge.type === "architecture" && (edge.startPort || edge.endPort)) {
650
- const portPoint = (placement, port) => port === "L" ? {
651
- x: placement.x - placement.w / 2,
652
- y: placement.y
653
- } : port === "R" ? {
654
- x: placement.x + placement.w / 2,
655
- y: placement.y
656
- } : port === "T" ? {
657
- x: placement.x,
658
- y: placement.y - placement.h / 2
659
- } : {
660
- x: placement.x,
661
- y: placement.y + placement.h / 2
662
- };
663
- const step = (point, port) => ({
664
- x: point.x + (port === "L" ? -12 : port === "R" ? 12 : 0),
665
- y: point.y + (port === "T" ? -12 : port === "B" ? 12 : 0)
666
- });
667
- if (edge.startPort) start = portPoint(a, edge.startPort);
668
- if (edge.endPort) end = portPoint(b, edge.endPort);
669
- const out = edge.startPort ? step(start, edge.startPort) : start, into = edge.endPort ? step(end, edge.endPort) : end;
670
- const across = (port) => port === "L" || port === "R";
671
- const startAcross = edge.startPort ? across(edge.startPort) : Math.abs(into.x - out.x) >= Math.abs(into.y - out.y);
672
- const endAcross = edge.endPort ? across(edge.endPort) : startAcross;
673
- const bends = out.x === into.x || out.y === into.y ? [] : startAcross && endAcross ? [{
674
- x: (out.x + into.x) / 2,
675
- y: out.y
676
- }, {
677
- x: (out.x + into.x) / 2,
678
- y: into.y
679
- }] : !startAcross && !endAcross ? [{
680
- x: out.x,
681
- y: (out.y + into.y) / 2
682
- }, {
683
- x: into.x,
684
- y: (out.y + into.y) / 2
685
- }] : startAcross ? [{
686
- x: into.x,
687
- y: out.y
688
- }] : [{
689
- x: out.x,
690
- y: into.y
691
- }];
692
- path = [
693
- start,
694
- out,
695
- ...bends,
696
- into,
697
- end
698
- ].filter((point, index, all) => !index || point.x !== all[index - 1].x || point.y !== all[index - 1].y).map((point, index) => `${index ? "L" : "M"}${point.x} ${point.y}`).join(" ");
699
- } else path = cubicPath(route.segments);
700
- const dashed = [
701
- "..|>",
702
- "<|..",
703
- "..>",
704
- ".."
705
- ].includes(edge.type);
706
- children.push(ctx.path(path, {
707
- fill: "none",
708
- stroke: ctx.design.fg4,
709
- "stroke-width": 1.25,
710
- "stroke-dasharray": dashed ? "4 3" : null,
711
- "clip-path": edgeClip,
712
- meta: {
713
- kind: "edge",
714
- edge: String(route.id),
715
- source: edge.from,
716
- target: edge.to,
717
- type: edge.type,
718
- startPort: edge.startPort || void 0,
719
- endPort: edge.endPort || void 0,
720
- direction: edge.direction
721
- }
722
- }));
723
- const vectorAt = (atStart) => {
724
- const port = atStart ? edge.startPort : edge.endPort;
725
- if (edge.type === "architecture" && port) return port === "L" ? {
726
- x: 1,
727
- y: 0
728
- } : port === "R" ? {
729
- x: -1,
730
- y: 0
731
- } : port === "T" ? {
732
- x: 0,
733
- y: 1
734
- } : {
735
- x: 0,
736
- y: -1
737
- };
738
- const segment = atStart ? route.segments?.[0] : route.segments?.at(-1);
739
- if (!segment) return {
740
- x: atStart ? -1 : 1,
741
- y: 0
742
- };
743
- const from = atStart ? segment.p1 : segment.p0, to = atStart ? segment.p0 : segment.p1;
744
- const dx = to.x - from.x, dy = to.y - from.y, length = Math.hypot(dx, dy) || 1;
745
- return {
746
- x: dx / length,
747
- y: dy / length
748
- };
749
- };
750
- const reach = {
751
- start: 0,
752
- end: 0
753
- };
754
- if (edge.type === "--x") {
755
- reach.end = 5;
756
- const { x, y } = end;
757
- children.push(ctx.path(`M${x - 4} ${y - 4} L${x + 4} ${y + 4} M${x + 4} ${y - 4} L${x - 4} ${y + 4}`, {
758
- fill: "none",
759
- stroke: ctx.design.fg4,
760
- "stroke-width": 1.25,
761
- meta: {
762
- kind: "relation-marker",
763
- edge: String(route.id),
764
- marker: "cross"
765
- }
766
- }));
767
- }
768
- const marker = (point, type, filled = false, vector = {
769
- x: -1,
770
- y: 0
771
- }) => {
772
- const { x: ux, y: uy } = vector, px = -uy, py = ux;
773
- let points;
774
- if (type === "triangle") points = `${point.x},${point.y} ${point.x - ux * 7 + px * 5},${point.y - uy * 7 + py * 5} ${point.x - ux * 7 - px * 5},${point.y - uy * 7 - py * 5}`;
775
- else if (type === "diamond") points = `${point.x},${point.y} ${point.x - ux * 6 + px * 5},${point.y - uy * 6 + py * 5} ${point.x - ux * 12},${point.y - uy * 12} ${point.x - ux * 6 - px * 5},${point.y - uy * 6 - py * 5}`;
776
- else points = `${point.x},${point.y} ${point.x - ux * 7 + px * 4},${point.y - uy * 7 + py * 4} ${point.x - ux * 7 - px * 4},${point.y - uy * 7 - py * 4}`;
777
- reach[point === start ? "start" : "end"] = type === "diamond" ? 12 : 7;
778
- children.push(ctx.shape("polygon", {
779
- points,
780
- fill: type === "triangle" || type === "diamond" && !filled ? ctx.color("bg") : ctx.color("muted"),
781
- ...type === "arrow" ? {} : {
782
- stroke: ctx.color("muted"),
783
- "stroke-width": 1
784
- }
785
- }, {
786
- kind: "relation-marker",
787
- edge: String(route.id),
788
- marker: type
789
- }));
790
- };
791
- if (edge.type === "<|--" || edge.type === "<|..") marker(start, "triangle", false, vectorAt(true));
792
- else if (edge.type === "..|>") marker(end, "triangle", false, vectorAt(false));
793
- else if ([
794
- "*--",
795
- "--*",
796
- "o--",
797
- "--o"
798
- ].includes(edge.type)) {
799
- const atStart = edge.type.startsWith("*") || edge.type.startsWith("o");
800
- marker(atStart ? start : end, "diamond", edge.type.includes("*"), vectorAt(atStart));
801
- } else {
802
- if (edge.direction === "left" || edge.direction === "both") marker(start, "arrow", false, vectorAt(true));
803
- if (edge.type !== "--x" && (edge.direction === "right" || edge.direction === "both")) marker(end, "arrow", false, vectorAt(false));
804
- }
805
- let labelBox;
806
- if (edge.label) {
807
- const dx = end.x - start.x, dy = end.y - start.y, length = Math.hypot(dx, dy) || 1;
808
- const along = reach.start + Math.max(0, length - reach.start - reach.end) / 2;
809
- const mx = start.x + dx / length * along, my = start.y + dy / length * along;
810
- const upright = Math.abs(dy) > Math.abs(dx) && (reach.start || reach.end);
811
- const x = mx, y = upright ? my + (edge.description ? -2 : 5) : my - (edge.description ? 10 : 4);
812
- const labels = [edge.label, edge.description].filter(Boolean);
813
- const w = Math.max(...labels.map((label) => ctx.measure(label, 12, 400))) + 14;
814
- labelBox = {
815
- x: x - w / 2,
816
- y: y - 15,
817
- w,
818
- h: edge.description ? 34 : 20
819
- };
820
- children.push(ctx.rect(labelBox.x, labelBox.y, labelBox.w, labelBox.h, {
821
- rx: 5,
822
- fill: ctx.color("bg"),
823
- stroke: ctx.color("grid"),
824
- "stroke-width": .6
825
- }));
826
- labels.forEach((label, index) => children.push(ctx.text(x, y + index * 14, label, {
827
- anchor: "middle",
828
- size: 12,
829
- fill: ctx.color("muted"),
830
- meta: {
831
- kind: index ? "edge-description" : "edge-label",
832
- edge: String(route.id)
833
- }
834
- })));
835
- }
836
- for (const [point, value, atStart] of [[
837
- start,
838
- edge.startCard,
839
- true
840
- ], [
841
- end,
842
- edge.endCard,
843
- false
844
- ]]) {
845
- if (!value) continue;
846
- const into = vectorAt(atStart);
847
- const vertical = Math.abs(into.y) > Math.abs(into.x);
848
- let x = vertical ? point.x + (atStart ? -6 : 6) : point.x - Math.sign(into.x) * 6;
849
- let y = vertical ? point.y - Math.sign(into.y) * 8 : point.y - 9;
850
- const anchor = vertical ? atStart ? "end" : "start" : into.x > 0 ? "end" : "start";
851
- if (labelBox && y + 7 > labelBox.y && y - 7 < labelBox.y + labelBox.h) {
852
- const w = ctx.measure(value, 12, 400);
853
- const left = anchor === "end" ? x - w : x;
854
- if (left < labelBox.x + labelBox.w + 4 && left + w > labelBox.x - 4) {
855
- if (vertical) x = atStart ? labelBox.x - 4 : labelBox.x + labelBox.w + 4;
856
- else y = labelBox.y - 9;
857
- }
858
- }
859
- children.push(ctx.text(x, y, value, {
860
- anchor,
861
- size: 12,
862
- fill: ctx.color("muted"),
863
- "dominant-baseline": "central",
864
- meta: {
865
- kind: "cardinality",
866
- edge: String(route.id),
867
- endpoint: atStart ? "start" : "end"
868
- }
869
- }));
870
- }
871
- }
872
- for (const p of placements.values()) {
873
- if (p.n.hidden) continue;
874
- const left = p.x - p.w / 2, top = p.y - p.h / 2;
875
- const detailed = p.attrs.length + p.methods.length > 0;
876
- children.push(ctx.rect(left, top, p.w, p.h, {
877
- rx: 8,
878
- fill: ctx.color("bg"),
879
- stroke: ctx.color("axis"),
880
- "stroke-width": 1,
881
- meta: {
882
- kind: "node",
883
- node: p.n.id,
884
- type: p.n.type
885
- }
886
- }));
887
- if (detailed) children.push(ctx.rect(left, top, p.w, 31, {
888
- rx: 8,
889
- fill: ctx.color("grid"),
890
- "fill-opacity": .5,
891
- stroke: "none",
892
- meta: {
893
- kind: "node-header",
894
- node: p.n.id
895
- }
896
- }));
897
- const titleY = detailed ? top + 20 : p.y + 5, iconY = detailed ? top + 7 : p.y - 8.64;
898
- if (p.n.icon && ICONS[p.n.icon]) children.push(ctx.path(ICONS[p.n.icon], {
899
- transform: `translate(${left + 9} ${iconY}) scale(.72)`,
900
- fill: "none",
901
- stroke: ctx.color("muted"),
902
- "stroke-width": 1.8,
903
- meta: {
904
- kind: "icon",
905
- node: p.n.id,
906
- icon: p.n.icon
907
- }
908
- }));
909
- children.push(ctx.text(p.x + (p.n.icon && ICONS[p.n.icon] ? 12 : 0), titleY, p.n.label, {
910
- anchor: "middle",
911
- size: 14,
912
- weight: 600,
913
- fill: ctx.color("fg"),
914
- meta: {
915
- kind: "node-label",
916
- node: p.n.id
917
- }
918
- }));
919
- let y = top + 48;
920
- for (const [i, text] of [...p.attrs, ...p.methods].entries()) {
921
- if (i === p.attrs.length && p.methods.length) children.push(ctx.line(left + 10, y - 12, left + p.w - 10, y - 12, {
922
- stroke: ctx.color("grid"),
923
- "stroke-width": .8,
924
- meta: {
925
- kind: "member-divider",
926
- node: p.n.id
927
- }
928
- }));
929
- for (const paragraph of String(text).split(/<br\s*\/?\s*>/iu)) for (const line of ctx.wrap(labelText(paragraph), Math.max(1, p.w - 24), 12, 400)) {
930
- children.push(ctx.text(left + 12, y, line, {
931
- anchor: "start",
932
- size: 12,
933
- fill: ctx.color("muted"),
934
- meta: {
935
- kind: "node-detail",
936
- node: p.n.id
937
- }
938
- }));
939
- y += 16;
940
- }
941
- }
942
- }
943
- const topInset = Math.max(0, ...groupBounds.map((group) => 12 - group.top));
944
- const leftInset = Math.max(0, ...groupBounds.map((group) => 12 - group.left));
945
- const bottom = Math.max(graph.height + 10, ...groupBounds.map((group) => group.bottom + 12));
946
- const right = Math.max(graph.width, ...groupBounds.map((group) => group.right + 12));
947
- const height = Math.max(100, bottom + topInset), sceneWidth = right + leftInset;
948
- return {
949
- width: sceneWidth,
950
- height,
951
- geometry: graph,
952
- scene: {
953
- width: sceneWidth,
954
- height,
955
- children: leftInset || topInset ? [ctx.el("g", { transform: `translate(${leftInset} ${topInset})` }, children)] : children,
956
- title: model.title || model.kind,
957
- heading: model.title || void 0
958
- },
959
- errors: []
960
- };
961
- }
962
- var implementations = Object.fromEntries(TYPES.map((kind) => [kind, {
963
- parse: (body, info) => parseFor(kind, body, info),
964
- layout: layoutGeometry
965
- }]));
966
- export { implementations, relations_exports };