@likec4/core 1.48.0 → 1.50.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 (130) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +1034 -0
  2. package/dist/_chunks/Builder.view-element.mjs +2 -3284
  3. package/dist/_chunks/LikeC4Model.d.mts +21 -25
  4. package/dist/_chunks/_types.d.mts +1 -5
  5. package/dist/_chunks/_types2.d.mts +2 -4
  6. package/dist/_chunks/assignTagColors.mjs +1 -24
  7. package/dist/_chunks/geometry.mjs +1 -335
  8. package/dist/_chunks/index.d.mts +1995 -131
  9. package/dist/_chunks/index2.d.mts +153 -892
  10. package/dist/_chunks/index3.d.mts +15 -13
  11. package/dist/_chunks/index4.d.mts +229 -3
  12. package/dist/_chunks/index5.d.mts +392 -30
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
  16. package/dist/_chunks/libs/bail.mjs +1 -14
  17. package/dist/_chunks/libs/ccount.mjs +1 -25
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
  20. package/dist/_chunks/libs/character-entities.mjs +2 -2136
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
  23. package/dist/_chunks/libs/defu.mjs +1 -42
  24. package/dist/_chunks/libs/devlop.mjs +1 -5
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
  26. package/dist/_chunks/libs/extend.mjs +1 -77
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -703
  28. package/dist/_chunks/libs/graphology.mjs +1 -4565
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -30
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -290
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
  39. package/dist/_chunks/libs/mnemonist.d.mts +1 -91
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -1978
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -36
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -39
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -171
  49. package/dist/_chunks/libs/remeda.mjs +2 -702
  50. package/dist/_chunks/libs/trough.mjs +1 -158
  51. package/dist/_chunks/libs/unified.mjs +1 -2212
  52. package/dist/_chunks/manual-layout.mjs +1 -0
  53. package/dist/_chunks/model.mjs +4 -1898
  54. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  55. package/dist/_chunks/types.mjs +1 -0
  56. package/dist/_chunks/utils.mjs +1 -483
  57. package/dist/builder/index.d.mts +3 -6
  58. package/dist/builder/index.mjs +1 -662
  59. package/dist/compute-view/index.d.mts +85 -13
  60. package/dist/compute-view/index.mjs +2 -262
  61. package/dist/geometry/index.d.mts +2 -2
  62. package/dist/geometry/index.mjs +1 -3
  63. package/dist/index.d.mts +7 -13
  64. package/dist/index.mjs +1 -27
  65. package/dist/model/index.d.mts +4 -11
  66. package/dist/model/index.mjs +1 -11
  67. package/dist/styles/index.d.mts +2 -7
  68. package/dist/styles/index.mjs +1 -30
  69. package/dist/types/index.d.mts +3 -9
  70. package/dist/types/index.mjs +1 -15
  71. package/dist/utils/graphology/index.d.mts +1 -1
  72. package/dist/utils/graphology/index.mjs +1 -3
  73. package/dist/utils/index.d.mts +5 -10
  74. package/dist/utils/index.mjs +1 -17
  75. package/package.json +14 -13
  76. package/dist/_chunks/LikeC4Styles.mjs +0 -691
  77. package/dist/_chunks/RichText.d.mts +0 -84
  78. package/dist/_chunks/RichText.mjs +0 -148
  79. package/dist/_chunks/_aux.d.mts +0 -289
  80. package/dist/_chunks/_aux.mjs +0 -18
  81. package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
  82. package/dist/_chunks/connection.mjs +0 -0
  83. package/dist/_chunks/const.d.mts +0 -43
  84. package/dist/_chunks/const.mjs +0 -33
  85. package/dist/_chunks/expression-model.d.mts +0 -192
  86. package/dist/_chunks/expression-model.mjs +0 -103
  87. package/dist/_chunks/expression.d.mts +0 -347
  88. package/dist/_chunks/expression.mjs +0 -107
  89. package/dist/_chunks/find.d.mts +0 -82
  90. package/dist/_chunks/find.mjs +0 -646
  91. package/dist/_chunks/find2.d.mts +0 -78
  92. package/dist/_chunks/find2.mjs +0 -287
  93. package/dist/_chunks/fqnRef.d.mts +0 -58
  94. package/dist/_chunks/fqnRef.mjs +0 -41
  95. package/dist/_chunks/index6.d.mts +0 -43
  96. package/dist/_chunks/index7.d.mts +0 -268
  97. package/dist/_chunks/index8.d.mts +0 -144
  98. package/dist/_chunks/invariant.mjs +0 -18
  99. package/dist/_chunks/iterable.mjs +0 -146
  100. package/dist/_chunks/libs/graphology-types.d.mts +0 -601
  101. package/dist/_chunks/libs/graphology.d.mts +0 -6
  102. package/dist/_chunks/mnemonist.mjs +0 -0
  103. package/dist/_chunks/model2.mjs +0 -0
  104. package/dist/_chunks/relationships-view.mjs +0 -132
  105. package/dist/_chunks/scalar.d.mts +0 -109
  106. package/dist/_chunks/scalar.mjs +0 -84
  107. package/dist/compute-view/relationships-view/index.d.mts +0 -16
  108. package/dist/compute-view/relationships-view/index.mjs +0 -7
  109. package/dist/model/connection/deployment/index.d.mts +0 -12
  110. package/dist/model/connection/deployment/index.mjs +0 -9
  111. package/dist/model/connection/index.d.mts +0 -14
  112. package/dist/model/connection/index.mjs +0 -10
  113. package/dist/model/connection/model/index.d.mts +0 -12
  114. package/dist/model/connection/model/index.mjs +0 -8
  115. package/dist/types/RichText.d.mts +0 -3
  116. package/dist/types/RichText.mjs +0 -7
  117. package/dist/types/_aux.d.mts +0 -3
  118. package/dist/types/_aux.mjs +0 -3
  119. package/dist/types/expression-model.d.mts +0 -6
  120. package/dist/types/expression-model.mjs +0 -7
  121. package/dist/types/expression.d.mts +0 -5
  122. package/dist/types/expression.mjs +0 -7
  123. package/dist/types/fqnRef.d.mts +0 -4
  124. package/dist/types/fqnRef.mjs +0 -7
  125. package/dist/types/scalar.d.mts +0 -2
  126. package/dist/types/scalar.mjs +0 -7
  127. package/dist/utils/iterable/index.d.mts +0 -9
  128. package/dist/utils/iterable/index.mjs +0 -3
  129. package/dist/utils/mnemonist.d.mts +0 -2
  130. package/dist/utils/mnemonist.mjs +0 -12
@@ -1,379 +0,0 @@
1
- import { A as e$2, B as t$8, D as e$3, G as t$6, J as n, Q as t, S as t$2, V as t$1, Y as t$5, Z as t$9, _ as t$10, c as t$7, h as t$3, i as n$1, j as e$1, m as e, w as t$4 } from "./libs/remeda.mjs";
2
- import { M as _layout, g as isElementView, h as isDynamicView } from "./LikeC4Styles.mjs";
3
- import { l as symmetricDifference } from "./utils.mjs";
4
- import { t as invariant } from "./invariant.mjs";
5
- import { f as ifilter, s as ihead } from "./iterable.mjs";
6
- import { castDraft, produce } from "immer";
7
-
8
- //#region src/compute-view/utils/buildElementNotations.ts
9
- /**
10
- * Build element notations from computed nodes:
11
- * 1. Group by notation
12
- * 2. Group by shape
13
- * 3. Group by color
14
- * 4. For each group get unique kinds
15
- * 5. Unwind the groups
16
- */
17
- function buildElementNotations(nodes) {
18
- return t(nodes, n((n) => !!n.notation), t$1(e("notation")), t$2(t$3(t$1(e("shape")), t$2(t$3(t$1(e("color")), t$2(t$3(t$4(e("kind")), n$1())), t$5(), t$4(([color, kinds]) => ({
19
- kinds,
20
- color
21
- })))), t$5(), t$6(([shape, colors]) => colors.map(({ color, kinds }) => ({
22
- shape,
23
- color,
24
- kinds
25
- }))))), t$5(), t$6(([title, shapes]) => shapes.map(({ shape, color, kinds }) => ({
26
- title,
27
- shape,
28
- color,
29
- kinds
30
- }))), t$7(e("shape"), e("title"), [(n) => n.kinds.length, "desc"]));
31
- }
32
-
33
- //#endregion
34
- //#region src/manual-layout/applyManualLayout.ts
35
- const changed = (a, b) => {
36
- if (a === b || e$1(a) && e$1(b)) return false;
37
- return !t$8(a, b);
38
- };
39
- /**
40
- * Maximum allowed drift per coordinate (top, left, bottom, right)
41
- */
42
- const MAX_ALLOWED_DRIFT = 5;
43
- /**
44
- * 'Safely' applies non-drifting properties from `next` to `draft`.
45
- * Used to auto-apply certain properties that are not considered drifting.
46
- */
47
- function autoApplyMetaAndStyles(draft, next) {
48
- draft.color = next.color;
49
- draft.kind = next.kind;
50
- draft.navigateTo = next.navigateTo ?? null;
51
- draft.links = next.links ? [...next.links] : null;
52
- draft.tags = [...next.tags];
53
- if (e$1(next.style.border)) delete draft.style.border;
54
- else draft.style.border = next.style.border;
55
- if (e$2(next.style.opacity)) draft.style.opacity = next.style.opacity;
56
- else delete draft.style.opacity;
57
- if (e$1(next.style.multiple)) delete draft.style.multiple;
58
- else draft.style.multiple = next.style.multiple;
59
- }
60
- /**
61
- * Auto-applies icon changes according to the rules:
62
- * - If icon was set before and changed, auto-apply
63
- * - If icon was set before and now removed, auto-apply
64
- * - If icon was added, only auto-apply if size not changed
65
- * @returns true if icon was auto-applied, false otherwise
66
- */
67
- function autoApplyIcon(draft, next, sizeNotChanged) {
68
- if (changed(next.icon ?? "none", draft.icon ?? "none")) {
69
- const iconWasSet = e$3(draft.icon) && draft.icon !== "none";
70
- switch (true) {
71
- case iconWasSet && e$3(next.icon) && next.icon !== "none":
72
- draft.icon = next.icon;
73
- return true;
74
- case iconWasSet && (e$1(next.icon) || next.icon === "none"):
75
- draft.icon = "none";
76
- return true;
77
- case !iconWasSet && e$3(next.icon) && next.icon !== "none": if (sizeNotChanged) {
78
- draft.icon = next.icon;
79
- return true;
80
- } else return false;
81
- }
82
- }
83
- return true;
84
- }
85
- /**
86
- * Auto-applies icon style changes according to the rules:
87
- * - iconColor is always auto-applied
88
- * - iconSize/iconPosition are auto-applied only if size not changed
89
- * @returns true if icon style changes were auto-applied, false otherwise
90
- */
91
- function autoApplyIconStyles(draft, next, sizeNotChanged) {
92
- let applied = true;
93
- if (changed(draft.style.iconColor, next.style.iconColor)) if (e$1(next.style.iconColor)) delete draft.style.iconColor;
94
- else draft.style.iconColor = next.style.iconColor;
95
- if (changed(draft.style.iconSize, next.style.iconSize)) if (sizeNotChanged) if (e$1(next.style.iconSize)) delete draft.style.iconSize;
96
- else draft.style.iconSize = next.style.iconSize;
97
- else applied = false;
98
- if (changed(draft.style.iconPosition, next.style.iconPosition)) if (sizeNotChanged) if (e$1(next.style.iconPosition)) delete draft.style.iconPosition;
99
- else draft.style.iconPosition = next.style.iconPosition;
100
- else applied = false;
101
- return applied;
102
- }
103
- function patchMarkdownOrString(draft, next) {
104
- if (!draft) return next;
105
- if ("md" in next) {
106
- draft.md = next.md;
107
- delete draft.txt;
108
- return draft;
109
- }
110
- if ("txt" in next) {
111
- draft.txt = next.txt;
112
- delete draft.md;
113
- }
114
- return draft;
115
- }
116
- /**
117
- * Auto-applies title, description, technology to leaf node
118
- * @returns true if all labels were auto-applied, false otherwise
119
- */
120
- function autoApplyLabelsToLeaf(draft, next, sizeNotChanged) {
121
- let applied = true;
122
- if (changed(draft.title, next.title)) if (sizeNotChanged) draft.title = next.title;
123
- else applied = false;
124
- if (changed(draft.description, next.description)) if (e$1(next.description)) delete draft.description;
125
- else if (sizeNotChanged) draft.description = patchMarkdownOrString(draft.description, next.description);
126
- else applied = false;
127
- if (changed(draft.technology, next.technology)) if (e$1(next.technology)) delete draft.technology;
128
- else if (sizeNotChanged) draft.technology = next.technology;
129
- else applied = false;
130
- return applied;
131
- }
132
- /**
133
- * Auto-applies title, description, technology to compound node
134
- * Currently always updates properties
135
- */
136
- function autoApplyLabelsToCompound(draft, next, _sizeNotChanged) {
137
- draft.title = next.title;
138
- if (e$1(next.description)) delete draft.description;
139
- else draft.description = patchMarkdownOrString(draft.description, next.description);
140
- if (e$1(next.technology)) delete draft.technology;
141
- else draft.technology = next.technology;
142
- return true;
143
- }
144
- /**
145
- * Proof-of-concept
146
- * Use layout from the snapshot, and 'safe'-apply style properties from the `autoLayouted` view
147
- *
148
- * @param autoLayouted Auto-layouted view
149
- * @param snapshot The view snapshot with manual-layout
150
- * @returns The snapshot with the next view applied
151
- */
152
- function applyManualLayout(autoLayouted, snapshot) {
153
- invariant(autoLayouted.id === snapshot.id, "applyManualLayout: view ids do not match");
154
- invariant(autoLayouted._stage === "layouted", "applyManualLayout: expected layouted view");
155
- invariant(snapshot._stage === "layouted", "applyManualLayout: expected layouted snapshot");
156
- invariant(autoLayouted._layout !== "manual", "applyManualLayout: expected auto-layouted view");
157
- const viewDrifts = /* @__PURE__ */ new Set();
158
- if (autoLayouted._type !== snapshot._type) viewDrifts.add("type-changed");
159
- const nodes = applyNodesManualLayout(snapshot.nodes, autoLayouted.nodes, viewDrifts);
160
- const edges = applyEdgesManualLayout(snapshot.edges, autoLayouted.edges, viewDrifts);
161
- const nodeNotations = buildElementNotations(nodes);
162
- return produce(snapshot, (draft) => {
163
- draft.title = autoLayouted.title ?? snapshot.title;
164
- draft.description = autoLayouted.description ?? snapshot.description;
165
- draft.tags = autoLayouted.tags ? [...autoLayouted.tags] : null;
166
- draft.links = autoLayouted.links ? [...autoLayouted.links] : null;
167
- draft.sourcePath = autoLayouted.sourcePath;
168
- draft[_layout] = "manual";
169
- if (nodeNotations && nodeNotations.length > 0) draft.notation = { nodes: nodeNotations };
170
- else delete draft.notation;
171
- draft.nodes = castDraft(nodes);
172
- draft.edges = castDraft(edges);
173
- if (isDynamicView(autoLayouted) && draft._type === "dynamic") draft.variant = autoLayouted.variant;
174
- if (isElementView(autoLayouted) && draft._type === "element") {
175
- if (autoLayouted.viewOf) draft.viewOf = autoLayouted.viewOf;
176
- else delete draft.viewOf;
177
- if (autoLayouted.extends) draft.extends = autoLayouted.extends;
178
- else delete draft.extends;
179
- }
180
- const drifts = [...viewDrifts];
181
- if (t$9(drifts, 1)) draft.drifts = drifts;
182
- else {
183
- draft.hash = autoLayouted.hash;
184
- delete draft.drifts;
185
- }
186
- });
187
- }
188
- function applyNodesManualLayout(snapshotNodes, latestNodes, viewDrifts) {
189
- const nextNodes = new Map(latestNodes.map((n) => [n.id, n]));
190
- const nodes = snapshotNodes.map((node) => {
191
- const next = nextNodes.get(node.id);
192
- if (!next) {
193
- viewDrifts.add("nodes-removed");
194
- return {
195
- ...node,
196
- drifts: ["removed"]
197
- };
198
- }
199
- nextNodes.delete(next.id);
200
- return produce(node, (draft) => {
201
- autoApplyMetaAndStyles(draft, next);
202
- const nodeDrifts = /* @__PURE__ */ new Set();
203
- const wasCompound = node.children.length > 0;
204
- const willBeCompound = next.children.length > 0;
205
- if (changed(draft.modelRef, next.modelRef) || changed(draft.deploymentRef, next.deploymentRef)) nodeDrifts.add("modelRef-changed");
206
- if (willBeCompound && !wasCompound) nodeDrifts.add("became-compound");
207
- if (!willBeCompound && wasCompound) nodeDrifts.add("became-leaf");
208
- if (changed(draft.parent, next.parent)) nodeDrifts.add("parent-changed");
209
- const sizeNotChanged = draft.width + MAX_ALLOWED_DRIFT >= next.width && draft.height + MAX_ALLOWED_DRIFT >= next.height;
210
- if (changed(draft.shape, next.shape)) if (sizeNotChanged) draft.shape = next.shape;
211
- else nodeDrifts.add("shape-changed");
212
- if (!autoApplyIconStyles(draft, next, sizeNotChanged)) nodeDrifts.add("label-changed");
213
- if (!autoApplyIcon(draft, next, sizeNotChanged && willBeCompound === wasCompound)) nodeDrifts.add("label-changed");
214
- if (!(wasCompound ? autoApplyLabelsToCompound : autoApplyLabelsToLeaf)(draft, next, sizeNotChanged)) nodeDrifts.add("label-changed");
215
- if (changed(node.notation, next.notation)) draft.notation = next.notation ?? null;
216
- if (wasCompound && willBeCompound && symmetricDifference(new Set(node.children), new Set(next.children)).size > 0) nodeDrifts.add("children-changed");
217
- const _drifts = [...nodeDrifts];
218
- if (t$9(_drifts, 1)) {
219
- viewDrifts.add("nodes-drift");
220
- draft.drifts = _drifts;
221
- } else delete draft.drifts;
222
- });
223
- });
224
- if (nextNodes.size > 0) viewDrifts.add("nodes-added");
225
- return nodes;
226
- }
227
- function applyEdgesManualLayout(snapshotEdges, latestEdges, viewDrifts) {
228
- const nextEdges = new Map(latestEdges.map((e) => [e.id, e]));
229
- const edges = snapshotEdges.map((edge) => {
230
- let next = nextEdges.get(edge.id) ?? t(nextEdges.values(), ifilter((e) => e.source === edge.source && e.target === edge.target), ihead());
231
- if (next) nextEdges.delete(next.id);
232
- return produce(edge, (draft) => {
233
- if (!next) {
234
- draft.drifts = ["removed"];
235
- viewDrifts.add("edges-removed");
236
- return;
237
- }
238
- const edgeDrifts = /* @__PURE__ */ new Set();
239
- const isSameId = edge.id === next.id;
240
- switch (true) {
241
- case isSameId && edge.source == next.source && edge.target == next.target:
242
- if (changed(draft.dir ?? "forward", next.dir ?? "forward")) edgeDrifts.add("direction-changed");
243
- break;
244
- case isSameId && edge.source == next.target && edge.target == next.source:
245
- if (edge.source !== edge.target) edgeDrifts.add("direction-changed");
246
- break;
247
- case isSameId:
248
- if (edge.source != next.source) edgeDrifts.add("source-changed");
249
- if (edge.target != next.target) edgeDrifts.add("target-changed");
250
- break;
251
- default:
252
- invariant(edge.id != next.id, "Unexpected case in edge drift detection, ids should not match");
253
- invariant(edge.source == next.source, "Unexpected case in edge drift detection, sources should match");
254
- invariant(edge.target == next.target, "Unexpected case in edge drift detection, targets should match");
255
- if (changed(draft.dir ?? "forward", next.dir ?? "forward")) edgeDrifts.add("direction-changed");
256
- break;
257
- }
258
- draft.color = next.color;
259
- draft.line = next.line;
260
- draft.navigateTo = next.navigateTo ?? null;
261
- draft.tags = next.tags ? [...next.tags] : null;
262
- if (changed(edge.notes, next.notes)) {
263
- if (e$1(edge.notes) !== e$1(next.notes)) edgeDrifts.add("notes-changed");
264
- draft.notes = next.notes ?? edge.notes;
265
- }
266
- if (next.astPath) draft.astPath = next.astPath;
267
- else delete draft.astPath;
268
- if (changed(t$10(edge, [
269
- "label",
270
- "description",
271
- "technology",
272
- "labelBBox"
273
- ]), t$10(next, [
274
- "label",
275
- "description",
276
- "technology",
277
- "labelBBox"
278
- ]))) switch (true) {
279
- case next.labelBBox && !edge.labelBBox:
280
- edgeDrifts.add("label-added");
281
- break;
282
- case edge.labelBBox && !next.labelBBox:
283
- edgeDrifts.add("label-removed");
284
- break;
285
- case !!edge.labelBBox && !!next.labelBBox:
286
- if (next.labelBBox.width * next.labelBBox.height > (edge.labelBBox.width + MAX_ALLOWED_DRIFT) * (edge.labelBBox.height + MAX_ALLOWED_DRIFT)) {
287
- draft.labelBBox.width = Math.round(next.labelBBox.width);
288
- draft.labelBBox.height = Math.round(next.labelBBox.height);
289
- }
290
- if (changed(edge.label, next.label)) {
291
- if (e$1(next.label) !== e$1(edge.label)) edgeDrifts.add("label-changed");
292
- draft.label = next.label ?? edge.label;
293
- }
294
- if (changed(edge.description, next.description)) {
295
- if (e$1(next.description) !== e$1(edge.description)) edgeDrifts.add("label-changed");
296
- if (next.description) draft.description = patchMarkdownOrString(edge.description, next.description);
297
- }
298
- if (changed(edge.technology, next.technology)) {
299
- if (e$1(next.technology) !== e$1(edge.technology)) edgeDrifts.add("label-changed");
300
- draft.technology = next.technology ?? edge.technology ?? null;
301
- }
302
- break;
303
- default:
304
- invariant(!edge.labelBBox, "Unexpected case in edge labelBBox drift detection");
305
- invariant(!next.labelBBox, "Unexpected case in next labelBBox drift detection");
306
- break;
307
- }
308
- const _drifts = [...edgeDrifts];
309
- if (t$9(_drifts, 1)) {
310
- viewDrifts.add("edges-drift");
311
- draft.drifts = _drifts;
312
- } else delete draft.drifts;
313
- });
314
- });
315
- if (nextEdges.size > 0) viewDrifts.add("edges-added");
316
- return edges;
317
- }
318
-
319
- //#endregion
320
- //#region src/manual-layout/calcDriftsFromSnapshot.ts
321
- /**
322
- * Calculates drifts comparing latest autoLayouted with manual snapshot.
323
- *
324
- * @returns The autoLayouted view with calculated drifts if any.
325
- */
326
- function calcDriftsFromSnapshot(autoLayouted, snapshot) {
327
- const { drifts, ...manual } = applyManualLayout(autoLayouted, snapshot);
328
- if (!drifts || drifts.length === 0) return produce(autoLayouted, (draft) => {
329
- delete draft.drifts;
330
- draft[_layout] = "auto";
331
- });
332
- const viewDrifts = /* @__PURE__ */ new Set();
333
- if (drifts.includes("type-changed")) viewDrifts.add("type-changed");
334
- const manualNodes = new Map(manual.nodes.map((n) => [n.id, n]));
335
- const manualEdges = new Map(manual.edges.map((e) => [e.id, e]));
336
- const nodes = autoLayouted.nodes.map((node) => {
337
- const snapshotNode = manualNodes.get(node.id);
338
- if (snapshotNode) manualNodes.delete(snapshotNode.id);
339
- return produce(node, (draft) => {
340
- if (!snapshotNode) {
341
- viewDrifts.add("nodes-added");
342
- draft.drifts = ["added"];
343
- return;
344
- }
345
- if (snapshotNode.drifts) {
346
- viewDrifts.add("nodes-drift");
347
- draft.drifts = [...snapshotNode.drifts];
348
- } else delete draft.drifts;
349
- });
350
- });
351
- if (manualNodes.size > 0) viewDrifts.add("nodes-removed");
352
- const edges = autoLayouted.edges.map((edge) => {
353
- const snapshotEdge = manualEdges.get(edge.id) ?? t(manualEdges.values(), ifilter((e) => e.source === edge.source && e.target === edge.target), ihead());
354
- if (snapshotEdge) manualEdges.delete(snapshotEdge.id);
355
- return produce(edge, (draft) => {
356
- if (!snapshotEdge) {
357
- viewDrifts.add("edges-added");
358
- draft.drifts = ["added"];
359
- return;
360
- }
361
- if (snapshotEdge.drifts) {
362
- viewDrifts.add("edges-drift");
363
- draft.drifts = [...snapshotEdge.drifts];
364
- } else delete draft.drifts;
365
- });
366
- });
367
- if (manualEdges.size > 0) viewDrifts.add("edges-removed");
368
- const _viewDrifts = [...viewDrifts];
369
- return produce(autoLayouted, (draft) => {
370
- if (t$9(_viewDrifts, 1)) draft.drifts = _viewDrifts;
371
- else delete draft.drifts;
372
- draft.nodes = castDraft(nodes);
373
- draft.edges = castDraft(edges);
374
- draft[_layout] = "auto";
375
- });
376
- }
377
-
378
- //#endregion
379
- export { applyManualLayout as n, buildElementNotations as r, calcDriftsFromSnapshot as t };
File without changes
@@ -1,43 +0,0 @@
1
- import { n as Any } from "./_aux.mjs";
2
- import { s as Fqn } from "./scalar.mjs";
3
- import { C as ElementModel, i as DeploymentElementModel } from "./LikeC4Model.mjs";
4
-
5
- //#region src/model/connection/Connection.d.ts
6
- interface Connection<Elem = ElementModel<Any> | DeploymentElementModel<Any>, Id = string> {
7
- readonly id: Id;
8
- readonly source: Elem;
9
- readonly target: Elem;
10
- /**
11
- * Common ancestor of the source and target elements.
12
- * Represents the boundary of the connection.
13
- */
14
- readonly boundary: Elem | null;
15
- /**
16
- * Human readable expression of the connection
17
- * Mostly used for testing and debugging
18
- */
19
- readonly expression: string;
20
- mergeWith(this: Connection<Elem, Id>, other: typeof this): typeof this;
21
- nonEmpty(): boolean;
22
- difference(this: Connection<Elem, Id>, other: typeof this): typeof this;
23
- intersect(this: Connection<Elem, Id>, other: typeof this): typeof this;
24
- equals(other: Connection): boolean;
25
- }
26
- declare namespace Connection {
27
- type ConnectionPredicate = <C extends Connection<{
28
- id: string;
29
- }, any>>(connection: C) => boolean;
30
- type ElementId = Fqn | string;
31
- export const isInside: (fqn: ElementId) => ConnectionPredicate;
32
- export const isDirectedBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
33
- export const isAnyBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
34
- export const isIncoming: (target: ElementId) => ConnectionPredicate;
35
- export const isOutgoing: (source: ElementId) => ConnectionPredicate;
36
- export const isAnyInOut: (source: ElementId) => ConnectionPredicate;
37
- export {};
38
- }
39
- //#endregion
40
- //#region src/utils/const.d.ts
41
- declare const customInspectSymbol: unique symbol;
42
- //#endregion
43
- export { Connection as n, customInspectSymbol as t };
@@ -1,33 +0,0 @@
1
- import { C as isAncestor } from "./utils.mjs";
2
-
3
- //#region src/model/connection/Connection.ts
4
- let Connection;
5
- (function(_Connection) {
6
- _Connection.isInside = (fqn) => {
7
- return (connection) => isAncestor(fqn, connection.source.id) && isAncestor(fqn, connection.target.id);
8
- };
9
- const isDirectedBetween = _Connection.isDirectedBetween = (source, target) => {
10
- return (connection) => (connection.source.id === source || isAncestor(source, connection.source.id)) && (connection.target.id === target || isAncestor(target, connection.target.id));
11
- };
12
- _Connection.isAnyBetween = (source, target) => {
13
- const forward = isDirectedBetween(source, target), backward = isDirectedBetween(target, source);
14
- return (connection) => forward(connection) || backward(connection);
15
- };
16
- const isIncoming = _Connection.isIncoming = (target) => {
17
- return (connection) => (connection.target.id === target || isAncestor(target, connection.target.id)) && !isAncestor(target, connection.source.id);
18
- };
19
- const isOutgoing = _Connection.isOutgoing = (source) => {
20
- return (connection) => (connection.source.id === source || isAncestor(source, connection.source.id)) && !isAncestor(source, connection.target.id);
21
- };
22
- _Connection.isAnyInOut = (source) => {
23
- const isIn = isIncoming(source), isOut = isOutgoing(source);
24
- return (connection) => isIn(connection) || isOut(connection);
25
- };
26
- })(Connection || (Connection = {}));
27
-
28
- //#endregion
29
- //#region src/utils/const.ts
30
- const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
31
-
32
- //#endregion
33
- export { Connection as n, customInspectSymbol as t };
@@ -1,192 +0,0 @@
1
- import { H as StrictViewId, U as Tag, m as ElementKind, n as Any, vt as ExclusiveUnion } from "./_aux.mjs";
2
- import { f as MarkdownOrString, u as Icon } from "./scalar.mjs";
3
- import { B as ShapeSize, C as BorderStyle, I as RelationshipArrowType, h as WhereOperator, j as IconPosition, k as ElementShape, r as PredicateSelector, w as Color, z as RelationshipLineType } from "./expression.mjs";
4
- import { t as FqnRef } from "./fqnRef.mjs";
5
-
6
- //#region src/types/expression-model.d.ts
7
- type AnyAux = Any;
8
- declare namespace ModelFqnExpr {
9
- type Wildcard = {
10
- wildcard: true;
11
- };
12
- function isWildcard<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelFqnExpr.Wildcard;
13
- interface Ref<M extends AnyAux> {
14
- ref: FqnRef.ModelRef<M>;
15
- selector?: PredicateSelector;
16
- }
17
- function isModelRef<A extends AnyAux>(ref: ModelExpression<A>): ref is ModelFqnExpr.Ref<A>;
18
- interface ElementKindExpr<A extends AnyAux = AnyAux> {
19
- elementKind: ElementKind<A>;
20
- isEqual: boolean;
21
- }
22
- function isElementKindExpr<A extends AnyAux>(expr: ModelExpression<A>): expr is ElementKindExpr<A>;
23
- interface ElementTagExpr<A extends AnyAux> {
24
- elementTag: Tag<A>;
25
- isEqual: boolean;
26
- }
27
- function isElementTagExpr<A extends AnyAux>(expr: ModelExpression<A>): expr is ElementTagExpr<A>;
28
- type NonWildcard<A extends AnyAux = AnyAux> = ExclusiveUnion<{
29
- Ref: Ref<A>;
30
- ElementKind: ElementKindExpr<A>;
31
- ElementTag: ElementTagExpr<A>;
32
- }>;
33
- interface Where<A extends AnyAux = AnyAux> {
34
- where: {
35
- expr: ExclusiveUnion<{
36
- Wildcard: Wildcard;
37
- Ref: Ref<A>;
38
- ElementKind: ElementKindExpr<A>;
39
- ElementTag: ElementTagExpr<A>;
40
- }>;
41
- condition: WhereOperator<A>;
42
- };
43
- }
44
- function isWhere<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelFqnExpr.Where<A>;
45
- interface Custom<A extends AnyAux = AnyAux> {
46
- custom: {
47
- expr: OrWhere<A>;
48
- title?: string;
49
- description?: MarkdownOrString;
50
- technology?: string;
51
- notation?: string;
52
- shape?: ElementShape;
53
- color?: Color;
54
- icon?: Icon;
55
- iconColor?: Color;
56
- iconSize?: ShapeSize;
57
- iconPosition?: IconPosition;
58
- border?: BorderStyle;
59
- opacity?: number;
60
- navigateTo?: StrictViewId<A>;
61
- multiple?: boolean;
62
- size?: ShapeSize;
63
- padding?: ShapeSize;
64
- textSize?: ShapeSize;
65
- };
66
- }
67
- function isCustom<A extends AnyAux>(expr: ModelExpression<A>): expr is Custom<A>;
68
- function is<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelFqnExpr<A>;
69
- type OrWhere<A extends AnyAux = AnyAux> = ExclusiveUnion<{
70
- Wildcard: ModelFqnExpr.Wildcard;
71
- Ref: ModelFqnExpr.Ref<A>;
72
- ElementKind: ElementKindExpr<A>;
73
- ElementTag: ElementTagExpr<A>;
74
- Where: ModelFqnExpr.Where<A>;
75
- }>;
76
- type Any<A extends AnyAux = AnyAux> = ExclusiveUnion<{
77
- Wildcard: Wildcard;
78
- Ref: Ref<A>;
79
- ElementKind: ElementKindExpr<A>;
80
- ElementTag: ElementTagExpr<A>;
81
- Where: Where<A>;
82
- Custom: Custom<A>;
83
- }>;
84
- function unwrap<A extends AnyAux>(expr: ModelFqnExpr.Any<A>): Wildcard | Ref<A> | ElementKindExpr<A> | ElementTagExpr<A>;
85
- }
86
- type ModelFqnExpr<A extends AnyAux = AnyAux> = ExclusiveUnion<{
87
- Wildcard: ModelFqnExpr.Wildcard;
88
- Ref: ModelFqnExpr.Ref<A>;
89
- ElementKind: ModelFqnExpr.ElementKindExpr<A>;
90
- ElementTag: ModelFqnExpr.ElementTagExpr<A>;
91
- }>;
92
- declare namespace ModelRelationExpr {
93
- type Endpoint<A extends AnyAux = AnyAux> = ModelFqnExpr.Where<A>['where']['expr'];
94
- interface Direct<A extends AnyAux = AnyAux> {
95
- source: Endpoint<A>;
96
- target: Endpoint<A>;
97
- isBidirectional?: boolean;
98
- }
99
- function isDirect<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Direct<A>;
100
- interface Incoming<A extends AnyAux = AnyAux> {
101
- incoming: Endpoint<A>;
102
- }
103
- function isIncoming<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Incoming<A>;
104
- interface Outgoing<A extends AnyAux = AnyAux> {
105
- outgoing: Endpoint<A>;
106
- }
107
- function isOutgoing<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Outgoing<A>;
108
- interface InOut<A extends AnyAux = AnyAux> {
109
- inout: Endpoint<A>;
110
- }
111
- function isInOut<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.InOut<A>;
112
- interface Where<A extends AnyAux = AnyAux> {
113
- where: {
114
- expr: ExclusiveUnion<{
115
- Direct: ModelRelationExpr.Direct<A>;
116
- Incoming: ModelRelationExpr.Incoming<A>;
117
- Outgoing: ModelRelationExpr.Outgoing<A>;
118
- InOut: ModelRelationExpr.InOut<A>;
119
- }>;
120
- condition: WhereOperator<A>;
121
- };
122
- }
123
- function isWhere<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Where<A>;
124
- interface Custom<A extends AnyAux = AnyAux> {
125
- customRelation: {
126
- expr: OrWhere<A>;
127
- title?: string;
128
- description?: string;
129
- technology?: string;
130
- notation?: string;
131
- navigateTo?: StrictViewId<A>;
132
- notes?: string;
133
- color?: Color;
134
- line?: RelationshipLineType;
135
- head?: RelationshipArrowType;
136
- tail?: RelationshipArrowType;
137
- };
138
- }
139
- function isCustom<A extends AnyAux>(expr: ModelExpression<A>): expr is Custom<A>;
140
- function is<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr<A>;
141
- type OrWhere<A extends AnyAux = AnyAux> = ExclusiveUnion<{
142
- Direct: Direct<A>;
143
- Incoming: Incoming<A>;
144
- Outgoing: Outgoing<A>;
145
- InOut: InOut<A>;
146
- Where: Where<A>;
147
- }>;
148
- type Any<A extends AnyAux = AnyAux> = ExclusiveUnion<{
149
- Direct: Direct<A>;
150
- Incoming: Incoming<A>;
151
- Outgoing: Outgoing<A>;
152
- InOut: InOut<A>;
153
- Where: Where<A>;
154
- Custom: Custom<A>;
155
- }>;
156
- function unwrap<A extends AnyAux>(expr: ModelRelationExpr.Any<A>): Direct<A> | Incoming<A> | Outgoing<A> | InOut<A>;
157
- }
158
- type ModelRelationExpr<A extends AnyAux = AnyAux> = ExclusiveUnion<{
159
- Direct: ModelRelationExpr.Direct<A>;
160
- Incoming: ModelRelationExpr.Incoming<A>;
161
- Outgoing: ModelRelationExpr.Outgoing<A>;
162
- InOut: ModelRelationExpr.InOut<A>;
163
- }>;
164
- /**
165
- * Represents a version 2 expression which can be one of several types.
166
- *
167
- * @template D - The type for the deployment FQN, defaults to `Fqn`.
168
- * @template M - The type for the model FQN, defaults to `Fqn`.
169
- */
170
- type ModelExpression<A extends AnyAux = AnyAux> = ExclusiveUnion<{
171
- Wildcard: ModelFqnExpr.Wildcard;
172
- Ref: ModelFqnExpr.Ref<A>;
173
- ElementKind: ModelFqnExpr.ElementKindExpr<A>;
174
- ElementTag: ModelFqnExpr.ElementTagExpr<A>;
175
- Custom: ModelFqnExpr.Custom<A>;
176
- Direct: ModelRelationExpr.Direct<A>;
177
- Incoming: ModelRelationExpr.Incoming<A>;
178
- Outgoing: ModelRelationExpr.Outgoing<A>;
179
- InOut: ModelRelationExpr.InOut<A>;
180
- Where: ModelExpression.Where<A>;
181
- CustomRelation: ModelRelationExpr.Custom<A>;
182
- }>;
183
- declare namespace ModelExpression {
184
- type Where<A extends AnyAux = AnyAux> = ModelFqnExpr.Where<A> | ModelRelationExpr.Where<A>;
185
- function isWhere<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelExpression.Where<A>;
186
- function isRelationWhere<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Where<A>;
187
- function isFqnExprWhere<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelFqnExpr.Where<A>;
188
- function isFqnExpr<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelFqnExpr.Any<A>;
189
- function isRelationExpr<A extends AnyAux>(expr: ModelExpression<A>): expr is ModelRelationExpr.Any<A>;
190
- }
191
- //#endregion
192
- export { ModelFqnExpr as n, ModelRelationExpr as r, ModelExpression as t };