@likec4/core 0.37.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{colors.d.ts → cjs/colors.d.ts} +28 -28
- package/dist/{colors.cjs → cjs/colors.js} +18 -28
- package/dist/{compute-view/EdgeBuilder.cjs → cjs/compute-view/EdgeBuilder.js} +1 -1
- package/dist/{compute-view → cjs/compute-view}/compute-ctx.d.ts +5 -4
- package/dist/{compute-view/compute-ctx.cjs → cjs/compute-view/compute-ctx.js} +5 -3
- package/dist/{compute-view/compute-element-view.cjs → cjs/compute-view/compute-element-view.js} +22 -13
- package/dist/{compute-view/compute-predicates.cjs → cjs/compute-view/compute-predicates.js} +3 -3
- package/dist/{compute-view/compute.cjs → cjs/compute-view/compute.js} +2 -2
- package/dist/{compute-view → cjs/compute-view}/index.d.ts +1 -0
- package/dist/{compute-view/index.cjs → cjs/compute-view/index.js} +14 -3
- package/dist/{compute-view → cjs/compute-view}/resolve-extended-views.d.ts +2 -2
- package/dist/{compute-view/resolve-extended-views.cjs → cjs/compute-view/resolve-extended-views.js} +16 -13
- package/dist/cjs/compute-view/resolve-relative-paths.d.ts +2 -0
- package/dist/cjs/compute-view/resolve-relative-paths.js +84 -0
- package/dist/{compute-view/utils/anyPossibleRelations.cjs → cjs/compute-view/utils/anyPossibleRelations.js} +1 -1
- package/dist/{compute-view/utils/applyViewRuleStyles.cjs → cjs/compute-view/utils/applyViewRuleStyles.js} +2 -2
- package/dist/cjs/compute-view/utils/sortNodes.d.ts +19 -0
- package/dist/cjs/compute-view/utils/sortNodes.js +47 -0
- package/dist/cjs/errors/index.d.ts +45 -0
- package/dist/cjs/errors/index.js +137 -0
- package/dist/{index.cjs → cjs/index.js} +24 -24
- package/dist/{model-index/ModelIndex.cjs → cjs/model-index/ModelIndex.js} +3 -4
- package/dist/{model-index/index.cjs → cjs/model-index/index.js} +1 -1
- package/dist/{types → cjs/types}/computed-view.d.ts +1 -0
- package/dist/{types → cjs/types}/diagram.d.ts +1 -6
- package/dist/{types/index.cjs → cjs/types/index.js} +10 -10
- package/dist/{types → cjs/types}/theme.d.ts +8 -2
- package/dist/{types → cjs/types}/view.d.ts +15 -0
- package/dist/{utils/compute-node-levels.cjs → cjs/utils/compute-node-levels.js} +1 -1
- package/dist/{utils/fqn.cjs → cjs/utils/fqn.js} +1 -1
- package/dist/{utils → cjs/utils}/guards.d.ts +0 -2
- package/dist/cjs/utils/guards.js +13 -0
- package/dist/{utils/index.cjs → cjs/utils/index.js} +4 -4
- package/dist/{utils/relations.cjs → cjs/utils/relations.js} +1 -1
- package/dist/esm/colors.d.ts +148 -0
- package/dist/{colors.js → esm/colors.js} +18 -26
- package/dist/esm/compute-view/EdgeBuilder.d.ts +6 -0
- package/dist/esm/compute-view/compute-ctx.d.ts +20 -0
- package/dist/{compute-view → esm/compute-view}/compute-ctx.js +2 -0
- package/dist/esm/compute-view/compute-element-view.d.ts +3 -0
- package/dist/{compute-view → esm/compute-view}/compute-element-view.js +18 -6
- package/dist/esm/compute-view/compute-predicates.d.ts +16 -0
- package/dist/{compute-view → esm/compute-view}/compute-predicates.js +1 -1
- package/dist/esm/compute-view/compute.d.ts +14 -0
- package/dist/esm/compute-view/index.d.ts +4 -0
- package/dist/{compute-view → esm/compute-view}/index.js +1 -0
- package/dist/esm/compute-view/resolve-extended-views.d.ts +6 -0
- package/dist/{compute-view → esm/compute-view}/resolve-extended-views.js +17 -14
- package/dist/esm/compute-view/resolve-relative-paths.d.ts +2 -0
- package/dist/esm/compute-view/resolve-relative-paths.js +76 -0
- package/dist/esm/compute-view/utils/anyPossibleRelations.d.ts +2 -0
- package/dist/esm/compute-view/utils/applyViewRuleStyles.d.ts +2 -0
- package/dist/esm/compute-view/utils/sortNodes.d.ts +19 -0
- package/dist/esm/compute-view/utils/sortNodes.js +37 -0
- package/dist/esm/errors/index.d.ts +45 -0
- package/dist/esm/errors/index.js +97 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/model-index/ModelIndex.d.ts +27 -0
- package/dist/{model-index → esm/model-index}/ModelIndex.js +3 -4
- package/dist/esm/model-index/index.d.ts +1 -0
- package/dist/esm/types/_common.d.ts +3 -0
- package/dist/esm/types/computed-view.d.ts +41 -0
- package/dist/esm/types/diagram.d.ts +32 -0
- package/dist/esm/types/element.d.ts +29 -0
- package/dist/esm/types/expression.d.ts +56 -0
- package/dist/esm/types/index.d.ts +11 -0
- package/dist/esm/types/model.d.ts +14 -0
- package/dist/esm/types/opaque.d.ts +102 -0
- package/dist/esm/types/relation.d.ts +10 -0
- package/dist/esm/types/theme.d.ts +28 -0
- package/dist/esm/types/view.d.ts +58 -0
- package/dist/esm/utils/compute-node-levels.d.ts +7 -0
- package/dist/esm/utils/fqn.d.ts +28 -0
- package/dist/esm/utils/guards.d.ts +3 -0
- package/dist/esm/utils/guards.js +6 -0
- package/dist/esm/utils/index.d.ts +4 -0
- package/dist/esm/utils/relations.d.ts +25 -0
- package/package.json +54 -68
- package/dist/compute-view/utils/sortNodes.cjs +0 -50
- package/dist/compute-view/utils/sortNodes.d.ts +0 -2
- package/dist/compute-view/utils/sortNodes.js +0 -40
- package/dist/errors/_base.cjs +0 -62
- package/dist/errors/_base.d.ts +0 -26
- package/dist/errors/_base.js +0 -41
- package/dist/errors/index.cjs +0 -60
- package/dist/errors/index.d.ts +0 -5
- package/dist/errors/index.js +0 -5
- package/dist/errors/invariant.cjs +0 -23
- package/dist/errors/invariant.d.ts +0 -6
- package/dist/errors/invariant.js +0 -13
- package/dist/errors/model-index.cjs +0 -23
- package/dist/errors/model-index.d.ts +0 -6
- package/dist/errors/model-index.js +0 -13
- package/dist/errors/non-nullable.cjs +0 -23
- package/dist/errors/non-nullable.d.ts +0 -6
- package/dist/errors/non-nullable.js +0 -13
- package/dist/errors/nonexhaustive.cjs +0 -23
- package/dist/errors/nonexhaustive.d.ts +0 -6
- package/dist/errors/nonexhaustive.js +0 -12
- package/dist/utils/guards.cjs +0 -22
- package/dist/utils/guards.js +0 -13
- package/dist/{compute-view → cjs/compute-view}/EdgeBuilder.d.ts +0 -0
- package/dist/{compute-view → cjs/compute-view}/compute-element-view.d.ts +0 -0
- package/dist/{compute-view → cjs/compute-view}/compute-predicates.d.ts +0 -0
- package/dist/{compute-view → cjs/compute-view}/compute.d.ts +0 -0
- package/dist/{compute-view → cjs/compute-view}/utils/anyPossibleRelations.d.ts +0 -0
- package/dist/{compute-view → cjs/compute-view}/utils/applyViewRuleStyles.d.ts +0 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +5 -5
- package/dist/{model-index → cjs/model-index}/ModelIndex.d.ts +0 -0
- package/dist/{model-index → cjs/model-index}/index.d.ts +0 -0
- package/dist/{types → cjs/types}/_common.d.ts +0 -0
- package/dist/{types/_common.cjs → cjs/types/_common.js} +0 -0
- package/dist/{types/computed-view.cjs → cjs/types/computed-view.js} +0 -0
- package/dist/{types/diagram.cjs → cjs/types/diagram.js} +0 -0
- package/dist/{types → cjs/types}/element.d.ts +0 -0
- package/dist/{types/element.cjs → cjs/types/element.js} +0 -0
- package/dist/{types → cjs/types}/expression.d.ts +0 -0
- package/dist/{types/expression.cjs → cjs/types/expression.js} +0 -0
- package/dist/{types → cjs/types}/index.d.ts +0 -0
- package/dist/{types → cjs/types}/model.d.ts +0 -0
- package/dist/{types/model.cjs → cjs/types/model.js} +0 -0
- package/dist/{types → cjs/types}/opaque.d.ts +0 -0
- package/dist/{types/opaque.cjs → cjs/types/opaque.js} +0 -0
- package/dist/{types → cjs/types}/relation.d.ts +0 -0
- package/dist/{types/relation.cjs → cjs/types/relation.js} +0 -0
- package/dist/{types/theme.cjs → cjs/types/theme.js} +0 -0
- package/dist/{types/view.cjs → cjs/types/view.js} +0 -0
- package/dist/{utils → cjs/utils}/compute-node-levels.d.ts +0 -0
- package/dist/{utils → cjs/utils}/fqn.d.ts +0 -0
- package/dist/{utils → cjs/utils}/index.d.ts +0 -0
- package/dist/{utils → cjs/utils}/relations.d.ts +0 -0
- package/dist/{compute-view → esm/compute-view}/EdgeBuilder.js +0 -0
- package/dist/{compute-view → esm/compute-view}/compute.js +0 -0
- package/dist/{compute-view → esm/compute-view}/utils/anyPossibleRelations.js +0 -0
- package/dist/{compute-view → esm/compute-view}/utils/applyViewRuleStyles.js +0 -0
- package/dist/{index.js → esm/index.js} +4 -4
- /package/dist/{model-index → esm/model-index}/index.js +0 -0
- /package/dist/{types → esm/types}/_common.js +0 -0
- /package/dist/{types → esm/types}/computed-view.js +0 -0
- /package/dist/{types → esm/types}/diagram.js +0 -0
- /package/dist/{types → esm/types}/element.js +0 -0
- /package/dist/{types → esm/types}/expression.js +0 -0
- /package/dist/{types → esm/types}/index.js +0 -0
- /package/dist/{types → esm/types}/model.js +0 -0
- /package/dist/{types → esm/types}/opaque.js +0 -0
- /package/dist/{types → esm/types}/relation.js +0 -0
- /package/dist/{types → esm/types}/theme.js +0 -0
- /package/dist/{types → esm/types}/view.js +0 -0
- /package/dist/{utils → esm/utils}/compute-node-levels.js +0 -0
- /package/dist/{utils → esm/utils}/fqn.js +0 -0
- /package/dist/{utils → esm/utils}/index.js +0 -0
- /package/dist/{utils → esm/utils}/relations.js +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export declare const RelationColors: {
|
|
2
|
+
readonly lineColor: "#b1b1b1";
|
|
3
|
+
readonly labelColor: "#b1b1b1";
|
|
4
|
+
};
|
|
5
|
+
export declare const Colors: {
|
|
6
|
+
readonly primary: {
|
|
7
|
+
fill: "#3b82f6";
|
|
8
|
+
stroke: "#2563eb";
|
|
9
|
+
hiContrast: "#eff6ff";
|
|
10
|
+
loContrast: "#bfdbfe";
|
|
11
|
+
};
|
|
12
|
+
readonly blue: {
|
|
13
|
+
fill: "#3b82f6";
|
|
14
|
+
stroke: "#2563eb";
|
|
15
|
+
hiContrast: "#eff6ff";
|
|
16
|
+
loContrast: "#bfdbfe";
|
|
17
|
+
};
|
|
18
|
+
readonly secondary: {
|
|
19
|
+
fill: "#0284c7";
|
|
20
|
+
stroke: "#0369a1";
|
|
21
|
+
hiContrast: "#f0f9ff";
|
|
22
|
+
loContrast: "#e0f2fe";
|
|
23
|
+
};
|
|
24
|
+
readonly sky: {
|
|
25
|
+
fill: "#0284c7";
|
|
26
|
+
stroke: "#0369a1";
|
|
27
|
+
hiContrast: "#f0f9ff";
|
|
28
|
+
loContrast: "#e0f2fe";
|
|
29
|
+
};
|
|
30
|
+
readonly muted: {
|
|
31
|
+
fill: "#64748b";
|
|
32
|
+
stroke: "#475569";
|
|
33
|
+
hiContrast: "#f8fafc";
|
|
34
|
+
loContrast: "#e2e8f0";
|
|
35
|
+
};
|
|
36
|
+
readonly slate: {
|
|
37
|
+
fill: "#64748b";
|
|
38
|
+
stroke: "#475569";
|
|
39
|
+
hiContrast: "#f8fafc";
|
|
40
|
+
loContrast: "#e2e8f0";
|
|
41
|
+
};
|
|
42
|
+
readonly gray: {
|
|
43
|
+
readonly fill: "#737373";
|
|
44
|
+
readonly stroke: "#525252";
|
|
45
|
+
readonly hiContrast: "#fafafa";
|
|
46
|
+
readonly loContrast: "#e5e5e5";
|
|
47
|
+
};
|
|
48
|
+
readonly red: {
|
|
49
|
+
readonly fill: "#b54548";
|
|
50
|
+
readonly stroke: "#8c333a";
|
|
51
|
+
readonly hiContrast: "#f8fafc";
|
|
52
|
+
readonly loContrast: "#F9C6C6";
|
|
53
|
+
};
|
|
54
|
+
readonly green: {
|
|
55
|
+
readonly fill: "#428a4f";
|
|
56
|
+
readonly stroke: "#2d5d39";
|
|
57
|
+
readonly hiContrast: "#f8fafc";
|
|
58
|
+
readonly loContrast: "#c2f0c2";
|
|
59
|
+
};
|
|
60
|
+
readonly amber: {
|
|
61
|
+
readonly fill: "#d97706";
|
|
62
|
+
readonly stroke: "#b45309";
|
|
63
|
+
readonly hiContrast: "#f8fafc";
|
|
64
|
+
readonly loContrast: "#ffe0c2";
|
|
65
|
+
};
|
|
66
|
+
readonly indigo: {
|
|
67
|
+
readonly fill: "#6366f1";
|
|
68
|
+
readonly stroke: "#4f46e5";
|
|
69
|
+
readonly hiContrast: "#eef2ff";
|
|
70
|
+
readonly loContrast: "#c7d2fe";
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare const defaultTheme: {
|
|
74
|
+
readonly font: "Helvetica";
|
|
75
|
+
readonly shadow: "#0a0a0a";
|
|
76
|
+
readonly relation: {
|
|
77
|
+
readonly lineColor: "#b1b1b1";
|
|
78
|
+
readonly labelColor: "#b1b1b1";
|
|
79
|
+
};
|
|
80
|
+
readonly colors: {
|
|
81
|
+
readonly primary: {
|
|
82
|
+
fill: "#3b82f6";
|
|
83
|
+
stroke: "#2563eb";
|
|
84
|
+
hiContrast: "#eff6ff";
|
|
85
|
+
loContrast: "#bfdbfe";
|
|
86
|
+
};
|
|
87
|
+
readonly blue: {
|
|
88
|
+
fill: "#3b82f6";
|
|
89
|
+
stroke: "#2563eb";
|
|
90
|
+
hiContrast: "#eff6ff";
|
|
91
|
+
loContrast: "#bfdbfe";
|
|
92
|
+
};
|
|
93
|
+
readonly secondary: {
|
|
94
|
+
fill: "#0284c7";
|
|
95
|
+
stroke: "#0369a1";
|
|
96
|
+
hiContrast: "#f0f9ff";
|
|
97
|
+
loContrast: "#e0f2fe";
|
|
98
|
+
};
|
|
99
|
+
readonly sky: {
|
|
100
|
+
fill: "#0284c7";
|
|
101
|
+
stroke: "#0369a1";
|
|
102
|
+
hiContrast: "#f0f9ff";
|
|
103
|
+
loContrast: "#e0f2fe";
|
|
104
|
+
};
|
|
105
|
+
readonly muted: {
|
|
106
|
+
fill: "#64748b";
|
|
107
|
+
stroke: "#475569";
|
|
108
|
+
hiContrast: "#f8fafc";
|
|
109
|
+
loContrast: "#e2e8f0";
|
|
110
|
+
};
|
|
111
|
+
readonly slate: {
|
|
112
|
+
fill: "#64748b";
|
|
113
|
+
stroke: "#475569";
|
|
114
|
+
hiContrast: "#f8fafc";
|
|
115
|
+
loContrast: "#e2e8f0";
|
|
116
|
+
};
|
|
117
|
+
readonly gray: {
|
|
118
|
+
readonly fill: "#737373";
|
|
119
|
+
readonly stroke: "#525252";
|
|
120
|
+
readonly hiContrast: "#fafafa";
|
|
121
|
+
readonly loContrast: "#e5e5e5";
|
|
122
|
+
};
|
|
123
|
+
readonly red: {
|
|
124
|
+
readonly fill: "#b54548";
|
|
125
|
+
readonly stroke: "#8c333a";
|
|
126
|
+
readonly hiContrast: "#f8fafc";
|
|
127
|
+
readonly loContrast: "#F9C6C6";
|
|
128
|
+
};
|
|
129
|
+
readonly green: {
|
|
130
|
+
readonly fill: "#428a4f";
|
|
131
|
+
readonly stroke: "#2d5d39";
|
|
132
|
+
readonly hiContrast: "#f8fafc";
|
|
133
|
+
readonly loContrast: "#c2f0c2";
|
|
134
|
+
};
|
|
135
|
+
readonly amber: {
|
|
136
|
+
readonly fill: "#d97706";
|
|
137
|
+
readonly stroke: "#b45309";
|
|
138
|
+
readonly hiContrast: "#f8fafc";
|
|
139
|
+
readonly loContrast: "#ffe0c2";
|
|
140
|
+
};
|
|
141
|
+
readonly indigo: {
|
|
142
|
+
readonly fill: "#6366f1";
|
|
143
|
+
readonly stroke: "#4f46e5";
|
|
144
|
+
readonly hiContrast: "#eef2ff";
|
|
145
|
+
readonly loContrast: "#c7d2fe";
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
@@ -2,11 +2,11 @@ const blue = {
|
|
|
2
2
|
// fill: colors.blue[500],
|
|
3
3
|
// stroke: colors.blue[600],
|
|
4
4
|
// hiContrast: colors.blue[50],
|
|
5
|
-
// loContrast: colors.blue[
|
|
5
|
+
// loContrast: colors.blue[200],
|
|
6
6
|
fill: "#3b82f6",
|
|
7
7
|
stroke: "#2563eb",
|
|
8
8
|
hiContrast: "#eff6ff",
|
|
9
|
-
loContrast: "#
|
|
9
|
+
loContrast: "#bfdbfe"
|
|
10
10
|
};
|
|
11
11
|
const sky = {
|
|
12
12
|
// fill: colors.sky[600],
|
|
@@ -29,10 +29,8 @@ const slate = {
|
|
|
29
29
|
loContrast: "#e2e8f0"
|
|
30
30
|
};
|
|
31
31
|
export const RelationColors = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
lineColor: "#a3a3a3",
|
|
35
|
-
labelColor: "#d4d4d4"
|
|
32
|
+
lineColor: "#b1b1b1",
|
|
33
|
+
labelColor: "#b1b1b1"
|
|
36
34
|
};
|
|
37
35
|
export const Colors = {
|
|
38
36
|
primary: blue,
|
|
@@ -56,28 +54,22 @@ export const Colors = {
|
|
|
56
54
|
// stroke: colors.red[600],
|
|
57
55
|
// hiContrast: colors.red[50],
|
|
58
56
|
// loContrast: colors.red[200],
|
|
59
|
-
fill: "#
|
|
60
|
-
stroke: "#
|
|
57
|
+
fill: "#b54548",
|
|
58
|
+
stroke: "#8c333a",
|
|
61
59
|
// hiContrast: '#fef2f2',
|
|
62
60
|
// loContrast: '#fecaca',
|
|
63
|
-
hiContrast:
|
|
64
|
-
// colors.gray[
|
|
65
|
-
|
|
66
|
-
//
|
|
61
|
+
// hiContrast: '#191111', // colors.gray[900],
|
|
62
|
+
// loContrast: '#3b1219' // colors.gray[800],
|
|
63
|
+
hiContrast: "#f8fafc",
|
|
64
|
+
// hiContrast: '#f8fafc',
|
|
65
|
+
// loContrast: '#fdd8d8' // radix black red 12
|
|
66
|
+
loContrast: "#F9C6C6"
|
|
67
67
|
},
|
|
68
68
|
green: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
fill: "#16a34a",
|
|
74
|
-
stroke: "#15803d",
|
|
75
|
-
hiContrast: "#111827",
|
|
76
|
-
// colors.gray[900],
|
|
77
|
-
// hiContrast: '#f0fdf4',
|
|
78
|
-
loContrast: "#1f2937"
|
|
79
|
-
// colors.gray[800],
|
|
80
|
-
// loContrast: '#bbf7d0'
|
|
69
|
+
fill: "#428a4f",
|
|
70
|
+
stroke: "#2d5d39",
|
|
71
|
+
hiContrast: "#f8fafc",
|
|
72
|
+
loContrast: "#c2f0c2"
|
|
81
73
|
},
|
|
82
74
|
amber: {
|
|
83
75
|
// fill: colors.amber[600],
|
|
@@ -88,9 +80,9 @@ export const Colors = {
|
|
|
88
80
|
stroke: "#b45309",
|
|
89
81
|
// hiContrast: '#fffbeb',
|
|
90
82
|
// loContrast: '#fde68a',
|
|
91
|
-
hiContrast: "#
|
|
83
|
+
hiContrast: "#f8fafc",
|
|
92
84
|
// colors.gray[900],
|
|
93
|
-
loContrast: "#
|
|
85
|
+
loContrast: "#ffe0c2"
|
|
94
86
|
// colors.gray[800],
|
|
95
87
|
},
|
|
96
88
|
indigo: {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelIndex } from '../model-index';
|
|
2
|
+
import type { Fqn, Element, Relation, ViewRuleExpression, ElementView } from '../types';
|
|
3
|
+
export type ComputeCtxPatch = {
|
|
4
|
+
elements?: Element[];
|
|
5
|
+
relations?: Relation[];
|
|
6
|
+
implicits?: Element[];
|
|
7
|
+
};
|
|
8
|
+
export declare class ComputeCtx {
|
|
9
|
+
index: ModelIndex;
|
|
10
|
+
root: Fqn | null;
|
|
11
|
+
elements: ReadonlySet<Element>;
|
|
12
|
+
relations: ReadonlySet<Relation>;
|
|
13
|
+
implicits: ReadonlySet<Element>;
|
|
14
|
+
readonly allElements: ReadonlySet<Element>;
|
|
15
|
+
constructor(index: ModelIndex, root: Fqn | null, elements?: ReadonlySet<Element>, relations?: ReadonlySet<Relation>, implicits?: ReadonlySet<Element>);
|
|
16
|
+
include({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
17
|
+
exclude({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
18
|
+
processViewRules(viewRules: ViewRuleExpression[]): ComputeCtx;
|
|
19
|
+
static create(view: ElementView, index: ModelIndex): ComputeCtx;
|
|
20
|
+
}
|
|
@@ -24,7 +24,9 @@ export class ComputeCtx {
|
|
|
24
24
|
this.elements = elements;
|
|
25
25
|
this.relations = relations;
|
|
26
26
|
this.implicits = implicits;
|
|
27
|
+
this.allElements = /* @__PURE__ */ new Set([...this.elements, ...this.implicits]);
|
|
27
28
|
}
|
|
29
|
+
allElements;
|
|
28
30
|
include({ elements, relations, implicits }) {
|
|
29
31
|
return new ComputeCtx(
|
|
30
32
|
this.index,
|
|
@@ -14,6 +14,7 @@ import { sortNodes } from "./utils/sortNodes.js";
|
|
|
14
14
|
function reduceToMap(elementsIterator) {
|
|
15
15
|
return Array.from(elementsIterator).sort(compareByFqnHierarchically).reduce((map, { id, color, shape, ...el }) => {
|
|
16
16
|
let parent = parentFqn(id);
|
|
17
|
+
let level = 0;
|
|
17
18
|
while (parent) {
|
|
18
19
|
if (map.has(parent)) {
|
|
19
20
|
break;
|
|
@@ -23,11 +24,13 @@ function reduceToMap(elementsIterator) {
|
|
|
23
24
|
if (parent) {
|
|
24
25
|
const parentNd = nonNullable(map.get(parent));
|
|
25
26
|
parentNd.children.push(id);
|
|
27
|
+
level = parentNd.level + 1;
|
|
26
28
|
}
|
|
27
29
|
const node = {
|
|
28
30
|
...el,
|
|
29
31
|
id,
|
|
30
32
|
parent,
|
|
33
|
+
level,
|
|
31
34
|
color: color ?? DefaultThemeColor,
|
|
32
35
|
shape: shape ?? DefaultElementShape,
|
|
33
36
|
children: [],
|
|
@@ -38,19 +41,29 @@ function reduceToMap(elementsIterator) {
|
|
|
38
41
|
return map;
|
|
39
42
|
}, /* @__PURE__ */ new Map());
|
|
40
43
|
}
|
|
44
|
+
const keepOriginalSortFromView = (_nodes, ctx) => {
|
|
45
|
+
const nodes = [...ctx.allElements].flatMap((e) => _nodes.get(e.id) || []);
|
|
46
|
+
for (const node of nodes) {
|
|
47
|
+
node.children = nodes.flatMap((n) => n.parent === node.id ? n.id : []);
|
|
48
|
+
}
|
|
49
|
+
return nodes;
|
|
50
|
+
};
|
|
41
51
|
export function computeElementView(view, index) {
|
|
42
52
|
const ctx = ComputeCtx.create(view, index);
|
|
43
|
-
const
|
|
53
|
+
const leafsFirst = [...ctx.allElements].sort((a, b) => -1 * compareByFqnHierarchically(a, b));
|
|
44
54
|
const elementsWithRelations = /* @__PURE__ */ new Set();
|
|
45
55
|
const edgeBuilder = new EdgeBuilder();
|
|
46
56
|
const anscestorOf = (id) => (e) => e.id === id || isAncestor(e.id, id);
|
|
47
57
|
const sortedRelations = [...ctx.relations];
|
|
48
58
|
for (const rel of sortedRelations) {
|
|
49
|
-
const source = find(
|
|
59
|
+
const source = find(leafsFirst, anscestorOf(rel.source));
|
|
50
60
|
if (!source) {
|
|
51
61
|
continue;
|
|
52
62
|
}
|
|
53
|
-
const target = find(
|
|
63
|
+
const target = find(
|
|
64
|
+
leafsFirst,
|
|
65
|
+
allPass([anscestorOf(rel.target), (e) => !isSameHierarchy(e, source)])
|
|
66
|
+
);
|
|
54
67
|
if (!target) {
|
|
55
68
|
continue;
|
|
56
69
|
}
|
|
@@ -58,8 +71,7 @@ export function computeElementView(view, index) {
|
|
|
58
71
|
elementsWithRelations.add(target);
|
|
59
72
|
edgeBuilder.add(source.id, target.id, rel);
|
|
60
73
|
}
|
|
61
|
-
const
|
|
62
|
-
const nodesMap = reduceToMap(elements);
|
|
74
|
+
const nodesMap = reduceToMap(/* @__PURE__ */ new Set([...ctx.elements, ...elementsWithRelations]));
|
|
63
75
|
const edges = edgeBuilder.build().map((edge) => {
|
|
64
76
|
while (edge.parent) {
|
|
65
77
|
if (nodesMap.has(edge.parent)) {
|
|
@@ -73,7 +85,7 @@ export function computeElementView(view, index) {
|
|
|
73
85
|
});
|
|
74
86
|
const nodes = applyViewRuleStyles(
|
|
75
87
|
view.rules.filter(isViewRuleStyle),
|
|
76
|
-
sortNodes(nodesMap, edges)
|
|
88
|
+
sortNodes(keepOriginalSortFromView(nodesMap, ctx), edges)
|
|
77
89
|
// map(e => nodesMap.get(e.id)!, Array.from(elements))
|
|
78
90
|
);
|
|
79
91
|
const autoLayoutRule = view.rules.find(isViewRuleAutoLayout);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Expr } from '../types';
|
|
2
|
+
import { ComputeCtx } from './compute-ctx';
|
|
3
|
+
export declare const includeElementRef: (ctx: ComputeCtx, expr: Expr.ElementRefExpr) => ComputeCtx;
|
|
4
|
+
export declare const excludeElementRef: (ctx: ComputeCtx, expr: Expr.ElementRefExpr) => ComputeCtx;
|
|
5
|
+
export declare const includeElementKindOrTag: (ctx: ComputeCtx, expr: Expr.ElementKindExpr | Expr.ElementTagExpr) => ComputeCtx;
|
|
6
|
+
export declare const excludeElementKindOrTag: (ctx: ComputeCtx, expr: Expr.ElementKindExpr | Expr.ElementTagExpr) => ComputeCtx;
|
|
7
|
+
export declare const includeWildcardRef: (ctx: ComputeCtx, _expr: Expr.WildcardExpr) => ComputeCtx;
|
|
8
|
+
export declare const excludeWildcardRef: (ctx: ComputeCtx, _expr: Expr.WildcardExpr) => ComputeCtx;
|
|
9
|
+
export declare const includeIncomingExpr: (ctx: ComputeCtx, expr: Expr.IncomingExpr) => ComputeCtx;
|
|
10
|
+
export declare const excludeIncomingExpr: (ctx: ComputeCtx, expr: Expr.IncomingExpr) => ComputeCtx;
|
|
11
|
+
export declare const includeOutgoingExpr: (ctx: ComputeCtx, expr: Expr.OutgoingExpr) => ComputeCtx;
|
|
12
|
+
export declare const excludeOutgoingExpr: (ctx: ComputeCtx, expr: Expr.OutgoingExpr) => ComputeCtx;
|
|
13
|
+
export declare const includeInOutExpr: (ctx: ComputeCtx, expr: Expr.InOutExpr) => ComputeCtx;
|
|
14
|
+
export declare const excludeInOutExpr: (ctx: ComputeCtx, expr: Expr.InOutExpr) => ComputeCtx;
|
|
15
|
+
export declare const includeRelationExpr: (ctx: ComputeCtx, expr: Expr.RelationExpr) => ComputeCtx;
|
|
16
|
+
export declare const excludeRelationExpr: (ctx: ComputeCtx, expr: Expr.RelationExpr) => ComputeCtx;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { anyPass, both, either, isNil, uniq } from "rambdax";
|
|
2
2
|
import { Expr } from "../types/index.js";
|
|
3
|
-
import { commonAncestor, isAncestor, isSameHierarchy
|
|
3
|
+
import { Relations, commonAncestor, isAncestor, isSameHierarchy } from "../utils/index.js";
|
|
4
4
|
import { ComputeCtx } from "./compute-ctx.js";
|
|
5
5
|
const { isAnyInOut, isBetween, isIncoming, isInside, isOutgoing, isAnyBetween } = Relations;
|
|
6
6
|
export const includeElementRef = (ctx, expr) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BaseError } from '../errors';
|
|
2
|
+
import type { ModelIndex } from '../model-index';
|
|
3
|
+
import { type ComputedView, type ElementView } from '../types';
|
|
4
|
+
type ComputeViewResult = {
|
|
5
|
+
isSuccess: true;
|
|
6
|
+
view: ComputedView;
|
|
7
|
+
} | {
|
|
8
|
+
isSuccess: false;
|
|
9
|
+
error: BaseError;
|
|
10
|
+
view: undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare function computeView(view: ElementView, index: ModelIndex): ComputeViewResult;
|
|
13
|
+
export declare function assignNavigateTo<R extends Iterable<ComputedView>>(views: R): R;
|
|
14
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { invariant, nonNullable } from "../errors/index.js";
|
|
1
|
+
import graphlib from "@dagrejs/graphlib";
|
|
3
2
|
import { isExtendsElementView } from "../types/index.js";
|
|
4
|
-
const { Graph, alg } =
|
|
3
|
+
const { Graph, alg } = graphlib;
|
|
5
4
|
export function resolveRulesExtendedViews(unresolvedViews) {
|
|
6
5
|
const g = new Graph({
|
|
7
6
|
directed: true,
|
|
@@ -9,22 +8,26 @@ export function resolveRulesExtendedViews(unresolvedViews) {
|
|
|
9
8
|
compound: false
|
|
10
9
|
});
|
|
11
10
|
for (const view of Object.values(unresolvedViews)) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
if (unresolvedViews[view.extends]) {
|
|
17
|
-
g.setEdge(view.extends, view.id);
|
|
11
|
+
g.setNode(view.id);
|
|
12
|
+
if (isExtendsElementView(view)) {
|
|
13
|
+
g.setEdge(view.id, view.extends);
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const cycles = alg.findCycles(g);
|
|
17
|
+
if (cycles.length > 0) {
|
|
18
|
+
cycles.flat().forEach((id) => g.removeNode(id));
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const ordered = alg.postorder(g, g.sources());
|
|
21
|
+
return ordered.reduce((acc, id) => {
|
|
22
|
+
const view = unresolvedViews[id];
|
|
23
|
+
if (!view) {
|
|
24
|
+
return acc;
|
|
25
|
+
}
|
|
25
26
|
if (isExtendsElementView(view)) {
|
|
26
27
|
const extendsFrom = acc[view.extends];
|
|
27
|
-
|
|
28
|
+
if (!extendsFrom) {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
28
31
|
return Object.assign(acc, {
|
|
29
32
|
[view.id]: {
|
|
30
33
|
...extendsFrom,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { uniq, zip } from "rambdax";
|
|
2
|
+
import { hasAtLeast } from "remeda";
|
|
3
|
+
import { invariant } from "../errors/index.js";
|
|
4
|
+
function commonAncestorPath(views, sep = "/") {
|
|
5
|
+
if (views.length <= 1)
|
|
6
|
+
return "";
|
|
7
|
+
const uniqURIs = uniq(views.flatMap(({ docUri }) => docUri ? [docUri] : []));
|
|
8
|
+
if (uniqURIs.length === 0)
|
|
9
|
+
return "";
|
|
10
|
+
if (uniqURIs.length === 1) {
|
|
11
|
+
invariant(hasAtLeast(uniqURIs, 1));
|
|
12
|
+
return new URL(uniqURIs[0]).pathname;
|
|
13
|
+
}
|
|
14
|
+
invariant(hasAtLeast(uniqURIs, 2), "Expected at least 2 unique URIs");
|
|
15
|
+
const [baseUri, ...tail] = uniqURIs;
|
|
16
|
+
const parts = new URL(baseUri).pathname.split(sep);
|
|
17
|
+
let endOfPrefix = parts.length;
|
|
18
|
+
for (const uri of tail) {
|
|
19
|
+
if (uri === baseUri) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const compare = new URL(uri).pathname.split(sep);
|
|
23
|
+
for (let i = 0; i < endOfPrefix; i++) {
|
|
24
|
+
if (compare[i] !== parts[i]) {
|
|
25
|
+
endOfPrefix = i;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (endOfPrefix === 0)
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
const prefix = parts.slice(0, endOfPrefix).join(sep);
|
|
32
|
+
return prefix.endsWith(sep) ? prefix : prefix + sep;
|
|
33
|
+
}
|
|
34
|
+
export function resolveRelativePaths(views) {
|
|
35
|
+
const commonPrefix = commonAncestorPath(views);
|
|
36
|
+
return views.map((view) => {
|
|
37
|
+
if (!view.docUri) {
|
|
38
|
+
return {
|
|
39
|
+
...view,
|
|
40
|
+
parts: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const path = new URL(view.docUri).pathname;
|
|
44
|
+
const parts = path.replace(commonPrefix, "").split("/");
|
|
45
|
+
parts.pop();
|
|
46
|
+
return {
|
|
47
|
+
...view,
|
|
48
|
+
parts
|
|
49
|
+
};
|
|
50
|
+
}).sort((a, b) => {
|
|
51
|
+
if (a.parts.length === b.parts.length) {
|
|
52
|
+
if (a.parts.length === 0) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if (a.parts.length === 1 && hasAtLeast(a.parts, 1) && hasAtLeast(b.parts, 1)) {
|
|
56
|
+
return a.parts[0].localeCompare(b.parts[0]);
|
|
57
|
+
}
|
|
58
|
+
for (const [_a, _b] of zip(a.parts, b.parts)) {
|
|
59
|
+
const compare = _a.localeCompare(_b);
|
|
60
|
+
if (compare !== 0) {
|
|
61
|
+
return compare;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
return a.parts.length - b.parts.length;
|
|
67
|
+
}).map(({ parts, ...view }) => {
|
|
68
|
+
if (view.docUri) {
|
|
69
|
+
return {
|
|
70
|
+
...view,
|
|
71
|
+
relativePath: parts.join("/")
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return view;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComputedEdge, ComputedNode } from '../../types';
|
|
2
|
+
export declare function sortNodes(_nodes: ComputedNode[], edges: ComputedEdge[]): {
|
|
3
|
+
children: import("../../types").Fqn[];
|
|
4
|
+
id: import("../../types").Fqn;
|
|
5
|
+
kind: import("../../types").ElementKind;
|
|
6
|
+
parent: import("../../types").Fqn | null;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string | null;
|
|
9
|
+
technology: string | null;
|
|
10
|
+
tags: import("../../types").NonEmptyArray<import("../../types").Tag> | null;
|
|
11
|
+
links: import("../../types").NonEmptyArray<string> | null;
|
|
12
|
+
inEdges: import("../../types").EdgeId[];
|
|
13
|
+
outEdges: import("../../types").EdgeId[];
|
|
14
|
+
shape: import("../../types").ElementShape;
|
|
15
|
+
color: import("../../types").ThemeColor;
|
|
16
|
+
icon?: import("../../types").IconUrl | undefined;
|
|
17
|
+
navigateTo?: import("../../types").ViewID | undefined;
|
|
18
|
+
level: number;
|
|
19
|
+
}[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import pkg from "@dagrejs/graphlib";
|
|
2
|
+
const { Graph, alg } = pkg;
|
|
3
|
+
function fillChildren(nodes) {
|
|
4
|
+
return nodes.map((node) => ({
|
|
5
|
+
...node,
|
|
6
|
+
children: nodes.flatMap((n) => n.parent === node.id ? n.id : [])
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
export function sortNodes(_nodes, edges) {
|
|
10
|
+
if (edges.length === 0) {
|
|
11
|
+
return fillChildren(_nodes);
|
|
12
|
+
}
|
|
13
|
+
const g = new Graph({
|
|
14
|
+
compound: true,
|
|
15
|
+
directed: true,
|
|
16
|
+
multigraph: false
|
|
17
|
+
});
|
|
18
|
+
for (const e of edges) {
|
|
19
|
+
g.setEdge(e.source, e.target);
|
|
20
|
+
}
|
|
21
|
+
for (const n of _nodes) {
|
|
22
|
+
g.setNode(n.id);
|
|
23
|
+
if (n.parent) {
|
|
24
|
+
g.setEdge(n.id, n.parent);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const unprocessed = [..._nodes];
|
|
28
|
+
const sorted = [];
|
|
29
|
+
const ordered = alg.postorder(g, g.sources()).reverse();
|
|
30
|
+
for (const id of ordered) {
|
|
31
|
+
const inx = unprocessed.findIndex((n) => n.id === id);
|
|
32
|
+
if (inx >= 0) {
|
|
33
|
+
sorted.push(...unprocessed.splice(inx, 1));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return fillChildren(sorted.concat(unprocessed));
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CustomError } from 'ts-custom-error';
|
|
2
|
+
export interface BaseErrorOptions {
|
|
3
|
+
cause?: unknown;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all errors in the LikeC4 library.
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseError extends CustomError {
|
|
9
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
export declare class InvalidArgError extends BaseError {
|
|
12
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Unknown error, mosly probably a bug, unhandled case or coming from a third-party library.
|
|
16
|
+
*/
|
|
17
|
+
export declare class UnknownError extends BaseError {
|
|
18
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
export declare class NullableError extends BaseError {
|
|
21
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
export declare class InvariantError extends BaseError {
|
|
24
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
export declare function nonNullable<T>(value: T, message?: string): T & {};
|
|
27
|
+
export declare class RelationRefError extends BaseError {
|
|
28
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
29
|
+
}
|
|
30
|
+
export declare function normalizeError(e: unknown): BaseError;
|
|
31
|
+
export declare function serializeError(e: unknown): {
|
|
32
|
+
name: string;
|
|
33
|
+
message: string;
|
|
34
|
+
error: BaseError;
|
|
35
|
+
};
|
|
36
|
+
export declare function throwNormalizedError(e: unknown): never;
|
|
37
|
+
export declare function invariant(condition: any, message?: string): asserts condition;
|
|
38
|
+
export declare class NonExhaustiveError extends BaseError {
|
|
39
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
export declare function nonexhaustive(value: never): never;
|
|
42
|
+
export declare class InvalidModelError extends BaseError {
|
|
43
|
+
constructor(message: string, options?: BaseErrorOptions);
|
|
44
|
+
}
|
|
45
|
+
export declare function ensureModel(condition: any, message?: string): asserts condition;
|