@likec4/core 1.17.1 → 1.18.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 (112) hide show
  1. package/dist/compute-view/index.d.mts +91 -0
  2. package/dist/compute-view/index.d.ts +91 -0
  3. package/dist/compute-view/index.mjs +79 -0
  4. package/dist/index.d.mts +246 -434
  5. package/dist/index.d.ts +246 -434
  6. package/dist/index.mjs +418 -1322
  7. package/dist/model/index.d.mts +642 -0
  8. package/dist/model/index.d.ts +642 -0
  9. package/dist/model/index.mjs +2 -0
  10. package/dist/shared/core.BBgiAAv1.mjs +144 -0
  11. package/dist/shared/core.BPyJvuMU.mjs +2420 -0
  12. package/dist/shared/core.BQ4AbfvB.mjs +9228 -0
  13. package/dist/shared/{core.CoLQkcYL.d.mts → core.DMYY7C8s.d.mts} +398 -249
  14. package/dist/shared/{core.CoLQkcYL.d.ts → core.DMYY7C8s.d.ts} +398 -249
  15. package/dist/shared/core.k12s_keD.mjs +203 -0
  16. package/dist/types/index.d.mts +69 -1
  17. package/dist/types/index.d.ts +69 -1
  18. package/dist/types/index.mjs +21 -1
  19. package/package.json +38 -40
  20. package/src/builder/Builder.deployment.ts +219 -0
  21. package/src/builder/Builder.deploymentModel.ts +360 -0
  22. package/src/builder/Builder.element.ts +17 -19
  23. package/src/builder/Builder.model.ts +13 -2
  24. package/src/builder/Builder.test-d.ts +59 -4
  25. package/src/builder/Builder.ts +238 -53
  26. package/src/builder/Builder.view.ts +238 -53
  27. package/src/builder/_types.ts +87 -15
  28. package/src/compute-view/LikeC4ModelGraph.ts +330 -0
  29. package/src/compute-view/compute-view.ts +92 -0
  30. package/src/compute-view/deployment-view/Memory.ts +108 -0
  31. package/src/compute-view/deployment-view/Stage.ts +145 -0
  32. package/src/compute-view/deployment-view/__test__/fixture.ts +210 -0
  33. package/src/compute-view/deployment-view/_types.ts +29 -0
  34. package/src/compute-view/deployment-view/clean-connections.ts +229 -0
  35. package/src/compute-view/deployment-view/compute.ts +111 -0
  36. package/src/compute-view/deployment-view/predicates/deployment-ref.ts +146 -0
  37. package/src/compute-view/deployment-view/predicates/relation-direct.ts +130 -0
  38. package/src/compute-view/deployment-view/predicates/relation-in-out.ts +43 -0
  39. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +46 -0
  40. package/src/compute-view/deployment-view/predicates/relation-outgoing.ts +49 -0
  41. package/src/compute-view/deployment-view/predicates/wildcard.ts +29 -0
  42. package/src/compute-view/deployment-view/utils.ts +212 -0
  43. package/src/compute-view/dynamic-view/__test__/fixture.ts +58 -0
  44. package/src/compute-view/dynamic-view/compute.ts +310 -0
  45. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +456 -0
  46. package/src/compute-view/element-view/__test__/fixture.ts +645 -0
  47. package/src/compute-view/element-view/compute.ts +734 -0
  48. package/src/compute-view/element-view/predicates.ts +517 -0
  49. package/src/compute-view/index.ts +5 -0
  50. package/src/compute-view/utils/__snapshots__/sortNodes.spec.ts.snap +113 -0
  51. package/src/compute-view/utils/ancestorsOfNode.ts +19 -0
  52. package/src/compute-view/utils/applyCustomElementProperties.ts +66 -0
  53. package/src/compute-view/utils/applyCustomRelationProperties.ts +41 -0
  54. package/src/compute-view/utils/applyViewRuleStyles.ts +53 -0
  55. package/src/compute-view/utils/buildComputedNodes.ts +148 -0
  56. package/src/compute-view/utils/buildElementNotations.ts +63 -0
  57. package/src/compute-view/utils/derive-edge-props-from-relationships.ts +97 -0
  58. package/src/compute-view/utils/elementExpressionToPredicate.ts +52 -0
  59. package/src/compute-view/utils/link-nodes-with-edges.ts +58 -0
  60. package/src/compute-view/utils/relationExpressionToPredicates.ts +55 -0
  61. package/src/compute-view/utils/resolve-extended-views.ts +65 -0
  62. package/src/compute-view/utils/resolve-global-rules.ts +83 -0
  63. package/src/compute-view/utils/sortNodes.ts +101 -0
  64. package/src/compute-view/utils/topological-sort.ts +160 -0
  65. package/src/compute-view/utils/uniqueTags.test.ts +42 -0
  66. package/src/compute-view/utils/uniqueTags.ts +21 -0
  67. package/src/compute-view/utils/view-hash.ts +27 -0
  68. package/src/compute-view/utils/with-readable-edges.ts +31 -0
  69. package/src/index.ts +5 -1
  70. package/src/model/DeploymentElementModel.ts +534 -0
  71. package/src/model/DeploymentModel.ts +364 -0
  72. package/src/model/ElementModel.ts +195 -0
  73. package/src/model/LikeC4Model.test-d.ts +151 -0
  74. package/src/model/LikeC4Model.ts +280 -457
  75. package/src/model/RelationModel.ts +84 -0
  76. package/src/model/__test__/fixture.ts +153 -338
  77. package/src/model/connection/ConnectionModel.ts +94 -0
  78. package/src/model/connection/DeploymentConnectionModel.ts +99 -0
  79. package/src/model/connection/deployment.ts +124 -0
  80. package/src/model/connection/model.ts +123 -0
  81. package/src/model/index.ts +4 -2
  82. package/src/model/types.ts +95 -15
  83. package/src/model/view/EdgeModel.ts +103 -0
  84. package/src/model/view/LikeC4ViewModel.ts +220 -0
  85. package/src/model/view/NodeModel.ts +228 -0
  86. package/src/types/_common.ts +2 -0
  87. package/src/types/deployments.ts +237 -0
  88. package/src/types/element.ts +7 -3
  89. package/src/types/expression.ts +8 -6
  90. package/src/types/index.ts +1 -0
  91. package/src/types/model.ts +68 -9
  92. package/src/types/overview-graph.ts +2 -2
  93. package/src/types/relation.ts +4 -4
  94. package/src/types/view-notation.ts +2 -2
  95. package/src/types/view.ts +104 -30
  96. package/src/utils/{commonHead.ts → common-head.ts} +2 -0
  97. package/src/utils/fqn.ts +83 -27
  98. package/src/utils/getOrCreate.ts +42 -0
  99. package/src/utils/graphlib.ts +10 -0
  100. package/src/utils/index.ts +4 -1
  101. package/src/utils/object-hash.ts +3 -0
  102. package/src/utils/set.ts +76 -0
  103. package/src/utils/string-hash.ts +16 -0
  104. package/dist/index.cjs +0 -5452
  105. package/dist/index.d.cts +0 -1053
  106. package/dist/shared/core.BXTs-8n7.mjs +0 -293
  107. package/dist/shared/core.CoLQkcYL.d.cts +0 -734
  108. package/dist/shared/core.DIYZvpVg.cjs +0 -353
  109. package/dist/types/index.cjs +0 -70
  110. package/dist/types/index.d.cts +0 -2
  111. package/src/model/LikeC4DiagramModel.ts +0 -338
  112. package/src/model/LikeC4ViewModel.ts +0 -320
@@ -0,0 +1,203 @@
1
+ function u$1(t,n,a){let o=r=>t(r,...n);return a===void 0?o:Object.assign(o,{lazy:a,lazyArgs:n})}
2
+
3
+ function u(r,n,a){let o=r.length-n.length;if(o===0)return r(...n);if(o===1)return u$1(r,n,a);throw new Error("Wrong number of arguments")}
4
+
5
+ function n(e){return e==null}
6
+
7
+ function o(r){return Array.isArray(r)}
8
+
9
+ function nonNullable(value, message) {
10
+ if (typeof value === "undefined" || value == null) {
11
+ throw new Error(message ?? `Expected defined value, but received ${value}`);
12
+ }
13
+ return value;
14
+ }
15
+ function invariant(condition, message) {
16
+ if (condition) {
17
+ return;
18
+ }
19
+ throw new Error(message ?? "Invariant failed");
20
+ }
21
+ function nonexhaustive(value) {
22
+ throw new Error(`NonExhaustive value: ${value}`);
23
+ }
24
+
25
+ var DeploymentElement;
26
+ ((DeploymentElement2) => {
27
+ DeploymentElement2.isDeploymentNode = (el) => {
28
+ return "kind" in el && !("element" in el);
29
+ };
30
+ DeploymentElement2.isInstance = (el) => {
31
+ return "element" in el && !("kind" in el);
32
+ };
33
+ })(DeploymentElement || (DeploymentElement = {}));
34
+ var DeploymentRelationExpression;
35
+ ((DeploymentRelationExpression2) => {
36
+ DeploymentRelationExpression2.isDirect = (expr) => {
37
+ return "source" in expr && "target" in expr;
38
+ };
39
+ DeploymentRelationExpression2.isIncoming = (expr) => {
40
+ return "incoming" in expr;
41
+ };
42
+ DeploymentRelationExpression2.isOutgoing = (expr) => {
43
+ return "outgoing" in expr;
44
+ };
45
+ DeploymentRelationExpression2.isInOut = (expr) => {
46
+ return "inout" in expr;
47
+ };
48
+ })(DeploymentRelationExpression || (DeploymentRelationExpression = {}));
49
+ var DeploymentElementExpression;
50
+ ((DeploymentElementExpression2) => {
51
+ DeploymentElementExpression2.isRef = (expr) => {
52
+ return "ref" in expr;
53
+ };
54
+ DeploymentElementExpression2.isWildcard = (expr) => {
55
+ return "wildcard" in expr && expr.wildcard === true;
56
+ };
57
+ })(DeploymentElementExpression || (DeploymentElementExpression = {}));
58
+ var DeploymentExpression;
59
+ ((DeploymentExpression2) => {
60
+ DeploymentExpression2.isElement = (expr) => {
61
+ return DeploymentElementExpression.isRef(expr) || DeploymentElementExpression.isWildcard(expr);
62
+ };
63
+ DeploymentExpression2.isRelation = (expr) => {
64
+ return !DeploymentExpression2.isElement(expr);
65
+ };
66
+ })(DeploymentExpression || (DeploymentExpression = {}));
67
+
68
+ function AsFqn(name, parent) {
69
+ return parent ? parent + "." + name : name;
70
+ }
71
+ const BorderStyles = ["solid", "dashed", "dotted", "none"];
72
+ var ElementKind;
73
+ ((ElementKind2) => {
74
+ ElementKind2.Group = "@group";
75
+ })(ElementKind || (ElementKind = {}));
76
+ const ElementShapes = [
77
+ "rectangle",
78
+ "person",
79
+ "browser",
80
+ "mobile",
81
+ "cylinder",
82
+ "storage",
83
+ "queue"
84
+ ];
85
+ const DefaultThemeColor = "primary";
86
+ const DefaultElementShape = "rectangle";
87
+
88
+ function isViewRulePredicate(rule) {
89
+ return "include" in rule && Array.isArray(rule.include) || "exclude" in rule && Array.isArray(rule.exclude);
90
+ }
91
+ function isViewRuleGlobalPredicateRef(rule) {
92
+ return "predicateId" in rule;
93
+ }
94
+ function isViewRuleStyle(rule) {
95
+ return "style" in rule && "targets" in rule && Array.isArray(rule.targets);
96
+ }
97
+ function isViewRuleGlobalStyle(rule) {
98
+ return "styleId" in rule;
99
+ }
100
+ function isAutoLayoutDirection(autoLayout) {
101
+ return autoLayout === "TB" || autoLayout === "BT" || autoLayout === "LR" || autoLayout === "RL";
102
+ }
103
+ function isViewRuleAutoLayout(rule) {
104
+ return "direction" in rule;
105
+ }
106
+ function isViewRuleGroup(rule) {
107
+ return "title" in rule && "groupRules" in rule && Array.isArray(rule.groupRules);
108
+ }
109
+ function isDynamicViewParallelSteps(step) {
110
+ return "__parallel" in step && o(step.__parallel);
111
+ }
112
+ function isDeploymentView(view) {
113
+ return view.__ === "deployment";
114
+ }
115
+ function isDynamicView(view) {
116
+ return view.__ === "dynamic";
117
+ }
118
+ function isElementView(view) {
119
+ return n(view.__) || view.__ === "element";
120
+ }
121
+ function isExtendsElementView(view) {
122
+ return isElementView(view) && "extends" in view;
123
+ }
124
+ function isScopedElementView(view) {
125
+ return isElementView(view) && "viewOf" in view;
126
+ }
127
+ function stepEdgeId(step, parallelStep) {
128
+ const id = `step-${String(step).padStart(2, "0")}`;
129
+ return parallelStep ? `${id}.${parallelStep}` : id;
130
+ }
131
+ function isStepEdgeId(id) {
132
+ return id.startsWith("step-");
133
+ }
134
+ function extractStep(id) {
135
+ if (!isStepEdgeId(id)) {
136
+ throw new Error(`Invalid step edge id: ${id}`);
137
+ }
138
+ return parseFloat(id.slice("step-".length));
139
+ }
140
+ function getParallelStepsPrefix(id) {
141
+ if (isStepEdgeId(id) && id.includes(".")) {
142
+ return id.slice(0, id.indexOf(".") + 1);
143
+ }
144
+ return null;
145
+ }
146
+ var ComputedNode;
147
+ ((ComputedNode2) => {
148
+ function modelRef(node) {
149
+ return node.modelRef === 1 ? node.id : node.modelRef ?? null;
150
+ }
151
+ ComputedNode2.modelRef = modelRef;
152
+ function deploymentRef(node) {
153
+ return node.deploymentRef === 1 ? node.id : node.deploymentRef ?? null;
154
+ }
155
+ ComputedNode2.deploymentRef = deploymentRef;
156
+ function isNodesGroup(node) {
157
+ return node.kind === ElementKind.Group;
158
+ }
159
+ ComputedNode2.isNodesGroup = isNodesGroup;
160
+ })(ComputedNode || (ComputedNode = {}));
161
+ var ComputedView;
162
+ ((ComputedView2) => {
163
+ function isDeployment(view) {
164
+ return view.__ === "deployment";
165
+ }
166
+ ComputedView2.isDeployment = isDeployment;
167
+ function isDynamic(view) {
168
+ return view.__ === "dynamic";
169
+ }
170
+ ComputedView2.isDynamic = isDynamic;
171
+ function isElement(view) {
172
+ return n(view.__) || view.__ === "element";
173
+ }
174
+ ComputedView2.isElement = isElement;
175
+ })(ComputedView || (ComputedView = {}));
176
+ function getBBoxCenter({
177
+ x,
178
+ y,
179
+ width,
180
+ height
181
+ }) {
182
+ return {
183
+ x: x + width / 2,
184
+ y: y + height / 2
185
+ };
186
+ }
187
+ var DiagramNode;
188
+ ((DiagramNode2) => {
189
+ function modelRef(node) {
190
+ return node.modelRef === 1 ? node.id : node.modelRef ?? null;
191
+ }
192
+ DiagramNode2.modelRef = modelRef;
193
+ function deploymentRef(node) {
194
+ return node.deploymentRef === 1 ? node.id : node.deploymentRef ?? null;
195
+ }
196
+ DiagramNode2.deploymentRef = deploymentRef;
197
+ function isNodesGroup(node) {
198
+ return node.kind === ElementKind.Group;
199
+ }
200
+ DiagramNode2.isNodesGroup = isNodesGroup;
201
+ })(DiagramNode || (DiagramNode = {}));
202
+
203
+ export { AsFqn as A, BorderStyles as B, isStepEdgeId as C, DeploymentElement as D, ElementKind as E, extractStep as F, getParallelStepsPrefix as G, ComputedNode as H, ComputedView as I, getBBoxCenter as J, DiagramNode as K, n as a, invariant as b, isScopedElementView as c, DefaultThemeColor as d, DefaultElementShape as e, nonNullable as f, DeploymentRelationExpression as g, DeploymentElementExpression as h, isExtendsElementView as i, DeploymentExpression as j, ElementShapes as k, isViewRulePredicate as l, isViewRuleGlobalPredicateRef as m, nonexhaustive as n, o, isViewRuleStyle as p, isViewRuleGlobalStyle as q, isAutoLayoutDirection as r, isViewRuleAutoLayout as s, isViewRuleGroup as t, u, isDynamicViewParallelSteps as v, isDeploymentView as w, isDynamicView as x, isElementView as y, stepEdgeId as z };
@@ -1,2 +1,70 @@
1
- export { aG as AndOperator, G as AsFqn, A as AutoLayoutDirection, bF as BBox, bc as BasicElementView, bb as BasicView, B as BorderStyle, J as BorderStyles, C as Color, aS as ColorLiteral, bC as ComputedDynamicView, q as ComputedEdge, bB as ComputedElementView, r as ComputedLikeC4Model, n as ComputedNode, l as ComputedView, y as CustomColor, bo as CustomColorDefinitions, g as CustomElementExpr, h as CustomRelationExpr, aP as DefaultArrowType, O as DefaultElementShape, aO as DefaultLineStyle, aQ as DefaultRelationshipColor, M as DefaultThemeColor, v as DiagramEdge, u as DiagramNode, D as DiagramView, bm as DynamicView, bj as DynamicViewIncludeRule, bh as DynamicViewParallelSteps, bl as DynamicViewRule, bg as DynamicViewStep, bi as DynamicViewStepOrParallel, k as EdgeId, d as Element, a8 as ElementExpression, p as ElementKind, a4 as ElementKindExpr, E as ElementKindSpecification, Y as ElementKindSpecificationStyle, bJ as ElementNotation, ac as ElementPredicateExpression, Z as ElementRefExpr, a as ElementShape, K as ElementShapes, Q as ElementStyle, a6 as ElementTagExpr, aU as ElementThemeColorValues, aV as ElementThemeColors, bf as ElementView, aa as ElementWhereExpr, az as EqualOperator, $ as ExpandedElementExpr, f as Expression, be as ExtendsElementView, aL as Filterable, F as Fqn, av as GlobalDynamicPredicates, at as GlobalPredicateId, au as GlobalPredicates, aw as GlobalStyleID, ax as GlobalStyles, H as HexColorLiteral, I as IconUrl, ag as InOutExpr, ai as IncomingExpr, aC as KindEqual, s as LayoutedLikeC4Model, aY as LikeC4Theme, L as LikeC4View, U as Link, ay as ModelGlobals, o as NodeId, N as NonEmptyArray, x as NonEmptyReadonlyArray, aE as NotOperator, aI as OrOperator, ak as OutgoingExpr, aN as OverviewGraph, P as ParsedLikeC4Model, z as Point, e as Relation, ae as RelationExpr, am as RelationExpression, i as RelationID, ar as RelationPredicateExpression, ao as RelationWhereExpr, b as RelationshipArrowType, t as RelationshipKind, R as RelationshipKindSpecification, c as RelationshipLineType, aW as RelationshipThemeColorValues, aX as RelationshipThemeColors, bd as ScopedElementView, bu as StepEdgeId, bt as StepEdgeIdLiteral, m as Tag, aA as TagEqual, S as TagSpec, aR as ThemeColor, T as ThemeColorValues, W as TypedElement, bA as ViewAutoLayout, bI as ViewChange, j as ViewID, bH as ViewManualLayout, ba as ViewRule, b6 as ViewRuleAutoLayout, a$ as ViewRuleGlobalPredicateRef, b2 as ViewRuleGlobalStyle, b8 as ViewRuleGroup, aZ as ViewRulePredicate, V as ViewRuleStyle, b4 as ViewRuleStyleOrGlobalRef, by as ViewWithHash, bz as ViewWithNotation, aK as WhereOperator, a2 as WildcardExpr, X as XYPoint, bw as extractStep, bG as getBBoxCenter, bx as getParallelStepsPrefix, aH as isAndOperator, b5 as isAutoLayoutDirection, bD as isComputedDynamicView, bE as isComputedElementView, a1 as isCustomElement, aq as isCustomRelationExpr, bp as isDynamicView, bk as isDynamicViewIncludeRule, bn as isDynamicViewParallelSteps, a9 as isElement, a5 as isElementKindExpr, ad as isElementPredicateExpr, _ as isElementRef, a7 as isElementTagExpr, bq as isElementView, ab as isElementWhere, a0 as isExpandedElementExpr, br as isExtendsElementView, ah as isInOut, aj as isIncoming, aD as isKindEqual, aF as isNotOperator, aJ as isOrOperator, al as isOutgoing, af as isRelation, an as isRelationExpression, as as isRelationPredicateExpr, ap as isRelationWhere, bs as isScopedElementView, bv as isStepEdgeId, aB as isTagEqual, aT as isThemeColor, b7 as isViewRuleAutoLayout, b0 as isViewRuleGlobalPredicateRef, b3 as isViewRuleGlobalStyle, b9 as isViewRuleGroup, a_ as isViewRulePredicate, b1 as isViewRuleStyle, a3 as isWildcard, aM as whereOperatorAsPredicate } from '../shared/core.CoLQkcYL.mjs';
1
+ import { X as XYPoint, b3 as ViewId, N as NonEmptyArray, s as Point, bU as BBox, B as BorderStyle, f as ElementShape, aX as ThemeColor, F as Fqn, bZ as ViewManualLayout, A as AutoLayoutDirection } from '../shared/core.DMYY7C8s.mjs';
2
+ export { aM as AndOperator, aD as AnyLikeC4Model, G as AsFqn, bj as BasicElementView, bi as BasicView, J as BorderStyles, g as Color, aY as ColorLiteral, bT as ComputedDeploymentView, bS as ComputedDynamicView, bN as ComputedEdge, bR as ComputedElementView, c as ComputedLikeC4Model, C as ComputedLikeC4ModelFromParsed, bM as ComputedNode, a as ComputedView, r as CustomColor, bu as CustomColorDefinitions, m as CustomElementExpr, n as CustomRelationExpr, aV as DefaultArrowType, U as DefaultElementShape, aU as DefaultLineStyle, aW as DefaultRelationshipColor, S as DefaultThemeColor, w as DeployedInstance, j as DeploymentElement, z as DeploymentElementExpression, o as DeploymentExpression, v as DeploymentNode, t as DeploymentNodeKind, D as DeploymentNodeKindSpecification, x as DeploymentRef, k as DeploymentRelation, y as DeploymentRelationExpression, by as DeploymentView, bx as DeploymentViewRule, bv as DeploymentViewRulePredicate, bw as DeploymentViewRuleStyle, bX as DiagramEdge, bW as DiagramNode, bY as DiagramView, bs as DynamicView, bq as DynamicViewIncludeRule, bo as DynamicViewParallelSteps, br as DynamicViewRule, bn as DynamicViewStep, bp as DynamicViewStepOrParallel, bF as EdgeId, E as Element, ac as ElementExpression, O as ElementKind, a8 as ElementKindExpr, d as ElementKindSpecification, a0 as ElementKindSpecificationStyle, b_ as ElementNotation, ag as ElementPredicateExpression, a1 as ElementRefExpr, Q as ElementShapes, W as ElementStyle, aa as ElementTagExpr, a_ as ElementThemeColorValues, a$ as ElementThemeColors, bm as ElementView, ae as ElementWhereExpr, aF as EqualOperator, a3 as ExpandedElementExpr, l as Expression, bl as ExtendsElementView, aR as Filterable, az as GlobalDynamicPredicates, ax as GlobalPredicateId, ay as GlobalPredicates, aA as GlobalStyleID, aB as GlobalStyles, H as HexColorLiteral, I as IconUrl, ak as InOutExpr, am as IncomingExpr, K as KeysOf, aI as KindEqual, aE as LayoutedLikeC4Model, b2 as LikeC4Theme, L as LikeC4View, _ as Link, M as ModelGlobals, bE as NodeId, q as NonEmptyReadonlyArray, aK as NotOperator, aO as OrOperator, ao as OutgoingExpr, P as ParsedLikeC4Model, aC as ParsedLikeC4ModelDump, u as PhysicalElementStyle, R as Relation, ai as RelationExpr, aq as RelationExpression, b as RelationId, av as RelationPredicateExpression, as as RelationWhereExpr, h as RelationshipArrowType, aT as RelationshipKind, e as RelationshipKindSpecification, i as RelationshipLineType, b0 as RelationshipThemeColorValues, b1 as RelationshipThemeColors, bk as ScopedElementView, bH as StepEdgeId, bG as StepEdgeIdLiteral, Y as Tag, aG as TagEqual, Z as TagSpec, T as ThemeColorValues, $ as TypedElement, bQ as ViewAutoLayout, bh as ViewRule, bd as ViewRuleAutoLayout, b6 as ViewRuleGlobalPredicateRef, b9 as ViewRuleGlobalStyle, bf as ViewRuleGroup, b4 as ViewRulePredicate, V as ViewRuleStyle, bb as ViewRuleStyleOrGlobalRef, bO as ViewWithHash, bP as ViewWithNotation, aQ as WhereOperator, a6 as WildcardExpr, bK as extractStep, bV as getBBoxCenter, bL as getParallelStepsPrefix, aN as isAndOperator, bc as isAutoLayoutDirection, a5 as isCustomElement, au as isCustomRelationExpr, bz as isDeploymentView, bA as isDynamicView, bt as isDynamicViewParallelSteps, ad as isElement, a9 as isElementKindExpr, ah as isElementPredicateExpr, a2 as isElementRef, ab as isElementTagExpr, bB as isElementView, af as isElementWhere, a4 as isExpandedElementExpr, bC as isExtendsElementView, al as isInOut, an as isIncoming, aJ as isKindEqual, aL as isNotOperator, aP as isOrOperator, ap as isOutgoing, aj as isRelation, ar as isRelationExpression, aw as isRelationPredicateExpr, at as isRelationWhere, bD as isScopedElementView, bJ as isStepEdgeId, aH as isTagEqual, aZ as isThemeColor, be as isViewRuleAutoLayout, b7 as isViewRuleGlobalPredicateRef, ba as isViewRuleGlobalStyle, bg as isViewRuleGroup, b5 as isViewRulePredicate, b8 as isViewRuleStyle, a7 as isWildcard, bI as stepEdgeId, aS as whereOperatorAsPredicate } from '../shared/core.DMYY7C8s.mjs';
2
3
  import 'type-fest';
4
+
5
+ /**
6
+ * OverviewGraph is a graph representation of all views in a model
7
+ */
8
+ declare namespace OverviewGraph {
9
+ type Node = {
10
+ id: string;
11
+ type: 'folder' | 'file';
12
+ path: string;
13
+ label: string;
14
+ parentId: string | null;
15
+ position: XYPoint;
16
+ width: number;
17
+ height: number;
18
+ } | {
19
+ id: string;
20
+ type: 'view';
21
+ viewId: ViewId;
22
+ label: string;
23
+ parentId: string | null;
24
+ position: XYPoint;
25
+ width: number;
26
+ height: number;
27
+ };
28
+ /**
29
+ * Edge represents a navigational link from one view to another
30
+ */
31
+ type Edge = {
32
+ id: string;
33
+ source: string;
34
+ target: string;
35
+ points: NonEmptyArray<Point>;
36
+ };
37
+ }
38
+ interface OverviewGraph {
39
+ nodes: OverviewGraph.Node[];
40
+ edges: OverviewGraph.Edge[];
41
+ bounds: BBox;
42
+ }
43
+
44
+ declare namespace ViewChange {
45
+ interface ChangeElementStyle {
46
+ op: 'change-element-style';
47
+ style: {
48
+ border?: BorderStyle;
49
+ opacity?: number;
50
+ shape?: ElementShape;
51
+ color?: ThemeColor;
52
+ };
53
+ targets: NonEmptyArray<Fqn>;
54
+ }
55
+ interface SaveManualLayout {
56
+ op: 'save-manual-layout';
57
+ layout: ViewManualLayout;
58
+ }
59
+ interface ChangeAutoLayout {
60
+ op: 'change-autolayout';
61
+ layout: {
62
+ direction: AutoLayoutDirection;
63
+ nodeSep?: number | null;
64
+ rankSep?: number | null;
65
+ };
66
+ }
67
+ }
68
+ type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
69
+
70
+ export { AutoLayoutDirection, BBox, BorderStyle, ElementShape, Fqn, NonEmptyArray, OverviewGraph, Point, ThemeColor, ViewChange, ViewId, ViewManualLayout, XYPoint };
@@ -1,2 +1,70 @@
1
- export { aG as AndOperator, G as AsFqn, A as AutoLayoutDirection, bF as BBox, bc as BasicElementView, bb as BasicView, B as BorderStyle, J as BorderStyles, C as Color, aS as ColorLiteral, bC as ComputedDynamicView, q as ComputedEdge, bB as ComputedElementView, r as ComputedLikeC4Model, n as ComputedNode, l as ComputedView, y as CustomColor, bo as CustomColorDefinitions, g as CustomElementExpr, h as CustomRelationExpr, aP as DefaultArrowType, O as DefaultElementShape, aO as DefaultLineStyle, aQ as DefaultRelationshipColor, M as DefaultThemeColor, v as DiagramEdge, u as DiagramNode, D as DiagramView, bm as DynamicView, bj as DynamicViewIncludeRule, bh as DynamicViewParallelSteps, bl as DynamicViewRule, bg as DynamicViewStep, bi as DynamicViewStepOrParallel, k as EdgeId, d as Element, a8 as ElementExpression, p as ElementKind, a4 as ElementKindExpr, E as ElementKindSpecification, Y as ElementKindSpecificationStyle, bJ as ElementNotation, ac as ElementPredicateExpression, Z as ElementRefExpr, a as ElementShape, K as ElementShapes, Q as ElementStyle, a6 as ElementTagExpr, aU as ElementThemeColorValues, aV as ElementThemeColors, bf as ElementView, aa as ElementWhereExpr, az as EqualOperator, $ as ExpandedElementExpr, f as Expression, be as ExtendsElementView, aL as Filterable, F as Fqn, av as GlobalDynamicPredicates, at as GlobalPredicateId, au as GlobalPredicates, aw as GlobalStyleID, ax as GlobalStyles, H as HexColorLiteral, I as IconUrl, ag as InOutExpr, ai as IncomingExpr, aC as KindEqual, s as LayoutedLikeC4Model, aY as LikeC4Theme, L as LikeC4View, U as Link, ay as ModelGlobals, o as NodeId, N as NonEmptyArray, x as NonEmptyReadonlyArray, aE as NotOperator, aI as OrOperator, ak as OutgoingExpr, aN as OverviewGraph, P as ParsedLikeC4Model, z as Point, e as Relation, ae as RelationExpr, am as RelationExpression, i as RelationID, ar as RelationPredicateExpression, ao as RelationWhereExpr, b as RelationshipArrowType, t as RelationshipKind, R as RelationshipKindSpecification, c as RelationshipLineType, aW as RelationshipThemeColorValues, aX as RelationshipThemeColors, bd as ScopedElementView, bu as StepEdgeId, bt as StepEdgeIdLiteral, m as Tag, aA as TagEqual, S as TagSpec, aR as ThemeColor, T as ThemeColorValues, W as TypedElement, bA as ViewAutoLayout, bI as ViewChange, j as ViewID, bH as ViewManualLayout, ba as ViewRule, b6 as ViewRuleAutoLayout, a$ as ViewRuleGlobalPredicateRef, b2 as ViewRuleGlobalStyle, b8 as ViewRuleGroup, aZ as ViewRulePredicate, V as ViewRuleStyle, b4 as ViewRuleStyleOrGlobalRef, by as ViewWithHash, bz as ViewWithNotation, aK as WhereOperator, a2 as WildcardExpr, X as XYPoint, bw as extractStep, bG as getBBoxCenter, bx as getParallelStepsPrefix, aH as isAndOperator, b5 as isAutoLayoutDirection, bD as isComputedDynamicView, bE as isComputedElementView, a1 as isCustomElement, aq as isCustomRelationExpr, bp as isDynamicView, bk as isDynamicViewIncludeRule, bn as isDynamicViewParallelSteps, a9 as isElement, a5 as isElementKindExpr, ad as isElementPredicateExpr, _ as isElementRef, a7 as isElementTagExpr, bq as isElementView, ab as isElementWhere, a0 as isExpandedElementExpr, br as isExtendsElementView, ah as isInOut, aj as isIncoming, aD as isKindEqual, aF as isNotOperator, aJ as isOrOperator, al as isOutgoing, af as isRelation, an as isRelationExpression, as as isRelationPredicateExpr, ap as isRelationWhere, bs as isScopedElementView, bv as isStepEdgeId, aB as isTagEqual, aT as isThemeColor, b7 as isViewRuleAutoLayout, b0 as isViewRuleGlobalPredicateRef, b3 as isViewRuleGlobalStyle, b9 as isViewRuleGroup, a_ as isViewRulePredicate, b1 as isViewRuleStyle, a3 as isWildcard, aM as whereOperatorAsPredicate } from '../shared/core.CoLQkcYL.js';
1
+ import { X as XYPoint, b3 as ViewId, N as NonEmptyArray, s as Point, bU as BBox, B as BorderStyle, f as ElementShape, aX as ThemeColor, F as Fqn, bZ as ViewManualLayout, A as AutoLayoutDirection } from '../shared/core.DMYY7C8s.js';
2
+ export { aM as AndOperator, aD as AnyLikeC4Model, G as AsFqn, bj as BasicElementView, bi as BasicView, J as BorderStyles, g as Color, aY as ColorLiteral, bT as ComputedDeploymentView, bS as ComputedDynamicView, bN as ComputedEdge, bR as ComputedElementView, c as ComputedLikeC4Model, C as ComputedLikeC4ModelFromParsed, bM as ComputedNode, a as ComputedView, r as CustomColor, bu as CustomColorDefinitions, m as CustomElementExpr, n as CustomRelationExpr, aV as DefaultArrowType, U as DefaultElementShape, aU as DefaultLineStyle, aW as DefaultRelationshipColor, S as DefaultThemeColor, w as DeployedInstance, j as DeploymentElement, z as DeploymentElementExpression, o as DeploymentExpression, v as DeploymentNode, t as DeploymentNodeKind, D as DeploymentNodeKindSpecification, x as DeploymentRef, k as DeploymentRelation, y as DeploymentRelationExpression, by as DeploymentView, bx as DeploymentViewRule, bv as DeploymentViewRulePredicate, bw as DeploymentViewRuleStyle, bX as DiagramEdge, bW as DiagramNode, bY as DiagramView, bs as DynamicView, bq as DynamicViewIncludeRule, bo as DynamicViewParallelSteps, br as DynamicViewRule, bn as DynamicViewStep, bp as DynamicViewStepOrParallel, bF as EdgeId, E as Element, ac as ElementExpression, O as ElementKind, a8 as ElementKindExpr, d as ElementKindSpecification, a0 as ElementKindSpecificationStyle, b_ as ElementNotation, ag as ElementPredicateExpression, a1 as ElementRefExpr, Q as ElementShapes, W as ElementStyle, aa as ElementTagExpr, a_ as ElementThemeColorValues, a$ as ElementThemeColors, bm as ElementView, ae as ElementWhereExpr, aF as EqualOperator, a3 as ExpandedElementExpr, l as Expression, bl as ExtendsElementView, aR as Filterable, az as GlobalDynamicPredicates, ax as GlobalPredicateId, ay as GlobalPredicates, aA as GlobalStyleID, aB as GlobalStyles, H as HexColorLiteral, I as IconUrl, ak as InOutExpr, am as IncomingExpr, K as KeysOf, aI as KindEqual, aE as LayoutedLikeC4Model, b2 as LikeC4Theme, L as LikeC4View, _ as Link, M as ModelGlobals, bE as NodeId, q as NonEmptyReadonlyArray, aK as NotOperator, aO as OrOperator, ao as OutgoingExpr, P as ParsedLikeC4Model, aC as ParsedLikeC4ModelDump, u as PhysicalElementStyle, R as Relation, ai as RelationExpr, aq as RelationExpression, b as RelationId, av as RelationPredicateExpression, as as RelationWhereExpr, h as RelationshipArrowType, aT as RelationshipKind, e as RelationshipKindSpecification, i as RelationshipLineType, b0 as RelationshipThemeColorValues, b1 as RelationshipThemeColors, bk as ScopedElementView, bH as StepEdgeId, bG as StepEdgeIdLiteral, Y as Tag, aG as TagEqual, Z as TagSpec, T as ThemeColorValues, $ as TypedElement, bQ as ViewAutoLayout, bh as ViewRule, bd as ViewRuleAutoLayout, b6 as ViewRuleGlobalPredicateRef, b9 as ViewRuleGlobalStyle, bf as ViewRuleGroup, b4 as ViewRulePredicate, V as ViewRuleStyle, bb as ViewRuleStyleOrGlobalRef, bO as ViewWithHash, bP as ViewWithNotation, aQ as WhereOperator, a6 as WildcardExpr, bK as extractStep, bV as getBBoxCenter, bL as getParallelStepsPrefix, aN as isAndOperator, bc as isAutoLayoutDirection, a5 as isCustomElement, au as isCustomRelationExpr, bz as isDeploymentView, bA as isDynamicView, bt as isDynamicViewParallelSteps, ad as isElement, a9 as isElementKindExpr, ah as isElementPredicateExpr, a2 as isElementRef, ab as isElementTagExpr, bB as isElementView, af as isElementWhere, a4 as isExpandedElementExpr, bC as isExtendsElementView, al as isInOut, an as isIncoming, aJ as isKindEqual, aL as isNotOperator, aP as isOrOperator, ap as isOutgoing, aj as isRelation, ar as isRelationExpression, aw as isRelationPredicateExpr, at as isRelationWhere, bD as isScopedElementView, bJ as isStepEdgeId, aH as isTagEqual, aZ as isThemeColor, be as isViewRuleAutoLayout, b7 as isViewRuleGlobalPredicateRef, ba as isViewRuleGlobalStyle, bg as isViewRuleGroup, b5 as isViewRulePredicate, b8 as isViewRuleStyle, a7 as isWildcard, bI as stepEdgeId, aS as whereOperatorAsPredicate } from '../shared/core.DMYY7C8s.js';
2
3
  import 'type-fest';
4
+
5
+ /**
6
+ * OverviewGraph is a graph representation of all views in a model
7
+ */
8
+ declare namespace OverviewGraph {
9
+ type Node = {
10
+ id: string;
11
+ type: 'folder' | 'file';
12
+ path: string;
13
+ label: string;
14
+ parentId: string | null;
15
+ position: XYPoint;
16
+ width: number;
17
+ height: number;
18
+ } | {
19
+ id: string;
20
+ type: 'view';
21
+ viewId: ViewId;
22
+ label: string;
23
+ parentId: string | null;
24
+ position: XYPoint;
25
+ width: number;
26
+ height: number;
27
+ };
28
+ /**
29
+ * Edge represents a navigational link from one view to another
30
+ */
31
+ type Edge = {
32
+ id: string;
33
+ source: string;
34
+ target: string;
35
+ points: NonEmptyArray<Point>;
36
+ };
37
+ }
38
+ interface OverviewGraph {
39
+ nodes: OverviewGraph.Node[];
40
+ edges: OverviewGraph.Edge[];
41
+ bounds: BBox;
42
+ }
43
+
44
+ declare namespace ViewChange {
45
+ interface ChangeElementStyle {
46
+ op: 'change-element-style';
47
+ style: {
48
+ border?: BorderStyle;
49
+ opacity?: number;
50
+ shape?: ElementShape;
51
+ color?: ThemeColor;
52
+ };
53
+ targets: NonEmptyArray<Fqn>;
54
+ }
55
+ interface SaveManualLayout {
56
+ op: 'save-manual-layout';
57
+ layout: ViewManualLayout;
58
+ }
59
+ interface ChangeAutoLayout {
60
+ op: 'change-autolayout';
61
+ layout: {
62
+ direction: AutoLayoutDirection;
63
+ nodeSep?: number | null;
64
+ rankSep?: number | null;
65
+ };
66
+ }
67
+ }
68
+ type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
69
+
70
+ export { AutoLayoutDirection, BBox, BorderStyle, ElementShape, Fqn, NonEmptyArray, OverviewGraph, Point, ThemeColor, ViewChange, ViewId, ViewManualLayout, XYPoint };
@@ -1 +1,21 @@
1
- export { A as AsFqn, B as BorderStyles, a3 as ComputedNode, N as DefaultArrowType, c as DefaultElementShape, M as DefaultLineStyle, e as DefaultRelationshipColor, D as DefaultThemeColor, a7 as DiagramNode, E as ElementKind, h as ElementShapes, $ as StepEdgeId, a1 as extractStep, a6 as getBBoxCenter, a2 as getParallelStepsPrefix, J as isAndOperator, T as isAutoLayoutDirection, a4 as isComputedDynamicView, a5 as isComputedElementView, l as isCustomElement, C as isCustomRelationExpr, Y as isDynamicView, W as isDynamicViewIncludeRule, X as isDynamicViewParallelSteps, r as isElement, p as isElementKindExpr, i as isElementPredicateExpr, j as isElementRef, q as isElementTagExpr, Z as isElementView, s as isElementWhere, k as isExpandedElementExpr, _ as isExtendsElementView, v as isInOut, w as isIncoming, H as isKindEqual, I as isNotOperator, K as isOrOperator, x as isOutgoing, t as isRelation, y as isRelationExpression, F as isRelationPredicateExpr, z as isRelationWhere, b as isScopedElementView, a0 as isStepEdgeId, G as isTagEqual, O as isThemeColor, U as isViewRuleAutoLayout, Q as isViewRuleGlobalPredicateRef, S as isViewRuleGlobalStyle, V as isViewRuleGroup, P as isViewRulePredicate, R as isViewRuleStyle, m as isWildcard, L as whereOperatorAsPredicate } from '../shared/core.BXTs-8n7.mjs';
1
+ export { A as AsFqn, B as BorderStyles, H as ComputedNode, I as ComputedView, e as DefaultElementShape, d as DefaultThemeColor, D as DeploymentElement, h as DeploymentElementExpression, j as DeploymentExpression, g as DeploymentRelationExpression, K as DiagramNode, E as ElementKind, k as ElementShapes, F as extractStep, J as getBBoxCenter, G as getParallelStepsPrefix, r as isAutoLayoutDirection, w as isDeploymentView, x as isDynamicView, v as isDynamicViewParallelSteps, y as isElementView, i as isExtendsElementView, c as isScopedElementView, C as isStepEdgeId, s as isViewRuleAutoLayout, m as isViewRuleGlobalPredicateRef, q as isViewRuleGlobalStyle, t as isViewRuleGroup, l as isViewRulePredicate, p as isViewRuleStyle, z as stepEdgeId } from '../shared/core.k12s_keD.mjs';
2
+ export { y as DefaultArrowType, D as DefaultLineStyle, z as DefaultRelationshipColor, v as isAndOperator, c as isCustomElement, q as isCustomRelationExpr, h as isElement, f as isElementKindExpr, i as isElementPredicateExpr, a as isElementRef, g as isElementTagExpr, j as isElementWhere, b as isExpandedElementExpr, l as isInOut, m as isIncoming, t as isKindEqual, u as isNotOperator, w as isOrOperator, n as isOutgoing, k as isRelation, o as isRelationExpression, r as isRelationPredicateExpr, p as isRelationWhere, s as isTagEqual, d as isWildcard, x as whereOperatorAsPredicate } from '../shared/core.BBgiAAv1.mjs';
3
+
4
+ const ThemeColors = [
5
+ "amber",
6
+ "blue",
7
+ "gray",
8
+ "slate",
9
+ "green",
10
+ "indigo",
11
+ "muted",
12
+ "primary",
13
+ "red",
14
+ "secondary",
15
+ "sky"
16
+ ];
17
+ function isThemeColor(color) {
18
+ return color in ThemeColors;
19
+ }
20
+
21
+ export { isThemeColor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.17.1",
3
+ "version": "1.18.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -29,24 +29,20 @@
29
29
  "sideEffects": false,
30
30
  "exports": {
31
31
  ".": {
32
- "import": {
33
- "types": "./dist/index.d.mts",
34
- "default": "./dist/index.mjs"
35
- },
36
- "require": {
37
- "types": "./dist/index.d.cts",
38
- "default": "./dist/index.cjs"
39
- }
32
+ "types": "./dist/index.d.mts",
33
+ "default": "./dist/index.mjs"
34
+ },
35
+ "./compute-view": {
36
+ "types": "./dist/compute-view/index.d.mts",
37
+ "default": "./dist/compute-view/index.mjs"
38
+ },
39
+ "./model": {
40
+ "types": "./dist/model/index.d.mts",
41
+ "default": "./dist/model/index.mjs"
40
42
  },
41
43
  "./types": {
42
- "import": {
43
- "types": "./dist/types/index.d.mts",
44
- "default": "./dist/types/index.mjs"
45
- },
46
- "require": {
47
- "types": "./dist/types/index.d.cts",
48
- "default": "./dist/types/index.cjs"
49
- }
44
+ "types": "./dist/types/index.d.mts",
45
+ "default": "./dist/types/index.mjs"
50
46
  }
51
47
  },
52
48
  "publishConfig": {
@@ -54,43 +50,45 @@
54
50
  "access": "public",
55
51
  "exports": {
56
52
  ".": {
57
- "import": {
58
- "types": "./dist/index.d.mts",
59
- "default": "./dist/index.mjs"
60
- },
61
- "require": {
62
- "types": "./dist/index.d.cts",
63
- "default": "./dist/index.cjs"
64
- }
53
+ "types": "./dist/index.d.mts",
54
+ "default": "./dist/index.mjs"
55
+ },
56
+ "./compute-view": {
57
+ "types": "./dist/compute-view/index.d.mts",
58
+ "default": "./dist/compute-view/index.mjs"
59
+ },
60
+ "./model": {
61
+ "types": "./dist/model/index.d.mts",
62
+ "default": "./dist/model/index.mjs"
65
63
  },
66
64
  "./types": {
67
- "import": {
68
- "types": "./dist/types/index.d.mts",
69
- "default": "./dist/types/index.mjs"
70
- },
71
- "require": {
72
- "types": "./dist/types/index.d.cts",
73
- "default": "./dist/types/index.cjs"
74
- }
65
+ "types": "./dist/types/index.d.mts",
66
+ "default": "./dist/types/index.mjs"
75
67
  }
76
68
  }
77
69
  },
78
70
  "dependencies": {
79
71
  "defu": "^6.1.4",
80
- "type-fest": "4.27.1"
72
+ "type-fest": "4.28.1"
81
73
  },
82
74
  "devDependencies": {
83
- "@likec4/tsconfig": "1.17.1",
84
- "@mantine/colors-generator": "7.14.1",
75
+ "@dagrejs/dagre": "^1.1.4",
76
+ "@likec4/tsconfig": "1.18.0",
77
+ "@mantine/colors-generator": "7.15.1",
85
78
  "@types/natural-compare-lite": "^1.4.2",
79
+ "@types/object-hash": "^3.0.6",
86
80
  "chroma-js": "^3.1.2",
87
- "execa": "^9.3.1",
81
+ "graphology": "^0.25.4",
82
+ "graphology-dag": "^0.4.1",
83
+ "graphology-types": "^0.24.8",
84
+ "mnemonist": "^0.39.8",
88
85
  "natural-compare-lite": "^1.4.0",
89
- "remeda": "^2.17.3",
90
- "turbo": "^2.3.1",
86
+ "object-hash": "^3.0.0",
87
+ "remeda": "^2.17.4",
88
+ "turbo": "^2.3.3",
91
89
  "typescript": "^5.7.2",
92
90
  "unbuild": "^3.0.0-rc.11",
93
- "vitest": "^2.1.5"
91
+ "vitest": "^2.1.8"
94
92
  },
95
93
  "packageManager": "yarn@4.5.3"
96
94
  }