@likec4/core 0.37.1 → 0.41.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/README.md +2 -6
- package/dist/cjs/colors/element.d.ts +68 -0
- package/dist/{colors.js → cjs/colors/element.js} +24 -46
- package/dist/cjs/colors/index.d.ts +132 -0
- package/dist/cjs/colors/index.js +27 -0
- package/dist/cjs/colors/relationships.d.ts +57 -0
- package/dist/cjs/colors/relationships.js +76 -0
- package/dist/cjs/errors/index.d.ts +45 -0
- package/dist/cjs/errors/index.js +137 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +3 -5
- package/dist/{index.cjs → cjs/index.js} +16 -38
- package/dist/{types → cjs/types}/computed-view.d.ts +11 -7
- package/dist/{types → cjs/types}/diagram.d.ts +15 -11
- package/dist/{types → cjs/types}/expression.d.ts +1 -1
- package/dist/{types/index.cjs → cjs/types/index.js} +10 -10
- package/dist/cjs/types/relation.d.ts +22 -0
- package/dist/cjs/types/relation.js +12 -0
- package/dist/{types → cjs/types}/theme.d.ts +10 -6
- package/dist/{types → cjs/types}/view.d.ts +22 -4
- package/dist/{types/view.cjs → cjs/types/view.js} +1 -1
- package/dist/{utils → cjs/utils}/fqn.d.ts +6 -1
- package/dist/{utils/fqn.cjs → cjs/utils/fqn.js} +18 -5
- package/dist/{utils → cjs/utils}/guards.d.ts +1 -2
- package/dist/cjs/utils/guards.js +20 -0
- package/dist/{utils → cjs/utils}/index.d.ts +0 -1
- package/dist/{utils/index.cjs → cjs/utils/index.js} +3 -14
- package/dist/{utils/relations.cjs → cjs/utils/relations.js} +1 -1
- package/dist/esm/colors/element.d.ts +68 -0
- package/dist/esm/colors/element.js +82 -0
- package/dist/esm/colors/index.d.ts +132 -0
- package/dist/esm/colors/index.js +9 -0
- package/dist/esm/colors/relationships.d.ts +57 -0
- package/dist/esm/colors/relationships.js +64 -0
- package/dist/esm/errors/index.d.ts +45 -0
- package/dist/esm/errors/index.js +97 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/types/_common.d.ts +3 -0
- package/dist/esm/types/computed-view.d.ts +44 -0
- package/dist/esm/types/diagram.d.ts +41 -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 +22 -0
- package/dist/esm/types/relation.js +3 -0
- package/dist/esm/types/theme.d.ts +26 -0
- package/dist/esm/types/view.d.ts +61 -0
- package/dist/{types → esm/types}/view.js +1 -1
- package/dist/esm/utils/fqn.d.ts +33 -0
- package/dist/{utils → esm/utils}/fqn.js +16 -4
- package/dist/esm/utils/guards.d.ts +4 -0
- package/dist/esm/utils/guards.js +7 -0
- package/dist/esm/utils/index.d.ts +3 -0
- package/dist/{utils → esm/utils}/index.js +0 -1
- package/dist/esm/utils/relations.d.ts +25 -0
- package/package.json +44 -61
- package/dist/colors.cjs +0 -124
- package/dist/colors.d.ts +0 -148
- package/dist/compute-view/EdgeBuilder.cjs +0 -37
- package/dist/compute-view/EdgeBuilder.d.ts +0 -6
- package/dist/compute-view/EdgeBuilder.js +0 -30
- package/dist/compute-view/compute-ctx.cjs +0 -89
- package/dist/compute-view/compute-ctx.d.ts +0 -19
- package/dist/compute-view/compute-ctx.js +0 -98
- package/dist/compute-view/compute-element-view.cjs +0 -91
- package/dist/compute-view/compute-element-view.d.ts +0 -3
- package/dist/compute-view/compute-element-view.js +0 -86
- package/dist/compute-view/compute-predicates.cjs +0 -363
- package/dist/compute-view/compute-predicates.d.ts +0 -16
- package/dist/compute-view/compute-predicates.js +0 -324
- package/dist/compute-view/compute.cjs +0 -46
- package/dist/compute-view/compute.d.ts +0 -14
- package/dist/compute-view/compute.js +0 -36
- package/dist/compute-view/index.cjs +0 -38
- package/dist/compute-view/index.d.ts +0 -3
- package/dist/compute-view/index.js +0 -3
- package/dist/compute-view/resolve-extended-views.cjs +0 -50
- package/dist/compute-view/resolve-extended-views.d.ts +0 -6
- package/dist/compute-view/resolve-extended-views.js +0 -38
- package/dist/compute-view/utils/anyPossibleRelations.cjs +0 -18
- package/dist/compute-view/utils/anyPossibleRelations.d.ts +0 -2
- package/dist/compute-view/utils/anyPossibleRelations.js +0 -12
- package/dist/compute-view/utils/applyViewRuleStyles.cjs +0 -57
- package/dist/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
- package/dist/compute-view/utils/applyViewRuleStyles.js +0 -50
- 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/index.js +0 -6
- package/dist/model-index/ModelIndex.cjs +0 -140
- package/dist/model-index/ModelIndex.d.ts +0 -27
- package/dist/model-index/ModelIndex.js +0 -128
- package/dist/model-index/index.cjs +0 -13
- package/dist/model-index/index.d.ts +0 -1
- package/dist/model-index/index.js +0 -1
- package/dist/types/relation.d.ts +0 -10
- package/dist/types/relation.js +0 -0
- package/dist/types/theme.cjs +0 -1
- package/dist/utils/compute-node-levels.cjs +0 -48
- package/dist/utils/compute-node-levels.d.ts +0 -7
- package/dist/utils/compute-node-levels.js +0 -31
- package/dist/utils/guards.cjs +0 -22
- package/dist/utils/guards.js +0 -13
- /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/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/relation.cjs → cjs/types/theme.js} +0 -0
- /package/dist/{utils → cjs/utils}/relations.d.ts +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}/theme.js +0 -0
- /package/dist/{utils → esm/utils}/relations.js +0 -0
package/dist/colors.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
export declare const RelationColors: {
|
|
2
|
-
readonly lineColor: "#a3a3a3";
|
|
3
|
-
readonly labelColor: "#d4d4d4";
|
|
4
|
-
};
|
|
5
|
-
export declare const Colors: {
|
|
6
|
-
readonly primary: {
|
|
7
|
-
fill: "#3b82f6";
|
|
8
|
-
stroke: "#2563eb";
|
|
9
|
-
hiContrast: "#eff6ff";
|
|
10
|
-
loContrast: "#dbeafe";
|
|
11
|
-
};
|
|
12
|
-
readonly blue: {
|
|
13
|
-
fill: "#3b82f6";
|
|
14
|
-
stroke: "#2563eb";
|
|
15
|
-
hiContrast: "#eff6ff";
|
|
16
|
-
loContrast: "#dbeafe";
|
|
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: "#ef4444";
|
|
50
|
-
readonly stroke: "#dc2626";
|
|
51
|
-
readonly hiContrast: "#111827";
|
|
52
|
-
readonly loContrast: "#1f2937";
|
|
53
|
-
};
|
|
54
|
-
readonly green: {
|
|
55
|
-
readonly fill: "#16a34a";
|
|
56
|
-
readonly stroke: "#15803d";
|
|
57
|
-
readonly hiContrast: "#111827";
|
|
58
|
-
readonly loContrast: "#1f2937";
|
|
59
|
-
};
|
|
60
|
-
readonly amber: {
|
|
61
|
-
readonly fill: "#d97706";
|
|
62
|
-
readonly stroke: "#b45309";
|
|
63
|
-
readonly hiContrast: "#111827";
|
|
64
|
-
readonly loContrast: "#1f2937";
|
|
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: "#a3a3a3";
|
|
78
|
-
readonly labelColor: "#d4d4d4";
|
|
79
|
-
};
|
|
80
|
-
readonly colors: {
|
|
81
|
-
readonly primary: {
|
|
82
|
-
fill: "#3b82f6";
|
|
83
|
-
stroke: "#2563eb";
|
|
84
|
-
hiContrast: "#eff6ff";
|
|
85
|
-
loContrast: "#dbeafe";
|
|
86
|
-
};
|
|
87
|
-
readonly blue: {
|
|
88
|
-
fill: "#3b82f6";
|
|
89
|
-
stroke: "#2563eb";
|
|
90
|
-
hiContrast: "#eff6ff";
|
|
91
|
-
loContrast: "#dbeafe";
|
|
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: "#ef4444";
|
|
125
|
-
readonly stroke: "#dc2626";
|
|
126
|
-
readonly hiContrast: "#111827";
|
|
127
|
-
readonly loContrast: "#1f2937";
|
|
128
|
-
};
|
|
129
|
-
readonly green: {
|
|
130
|
-
readonly fill: "#16a34a";
|
|
131
|
-
readonly stroke: "#15803d";
|
|
132
|
-
readonly hiContrast: "#111827";
|
|
133
|
-
readonly loContrast: "#1f2937";
|
|
134
|
-
};
|
|
135
|
-
readonly amber: {
|
|
136
|
-
readonly fill: "#d97706";
|
|
137
|
-
readonly stroke: "#b45309";
|
|
138
|
-
readonly hiContrast: "#111827";
|
|
139
|
-
readonly loContrast: "#1f2937";
|
|
140
|
-
};
|
|
141
|
-
readonly indigo: {
|
|
142
|
-
readonly fill: "#6366f1";
|
|
143
|
-
readonly stroke: "#4f46e5";
|
|
144
|
-
readonly hiContrast: "#eef2ff";
|
|
145
|
-
readonly loContrast: "#c7d2fe";
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.EdgeBuilder = void 0;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _utils = require("../utils/index.cjs");
|
|
9
|
-
class EdgeBuilder {
|
|
10
|
-
_relationsObj = {};
|
|
11
|
-
add(source, target, relation) {
|
|
12
|
-
const bySource = this._relationsObj[source] ?? {};
|
|
13
|
-
const relations = bySource[target] ?? [];
|
|
14
|
-
relations.push(relation);
|
|
15
|
-
bySource[target] = relations;
|
|
16
|
-
this._relationsObj[source] = bySource;
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
build() {
|
|
20
|
-
return (0, _rambdax.keys)(this._relationsObj).flatMap(source => {
|
|
21
|
-
const targets = this._relationsObj[source] ?? {};
|
|
22
|
-
return (0, _rambdax.keys)(targets).map(target => {
|
|
23
|
-
const relations = (targets[target] ?? []).sort(_utils.compareRelations);
|
|
24
|
-
const label = relations.find(r => r.title !== "")?.title ?? null;
|
|
25
|
-
return {
|
|
26
|
-
id: `${source}:${target}`,
|
|
27
|
-
parent: (0, _utils.commonAncestor)(source, target),
|
|
28
|
-
source,
|
|
29
|
-
target,
|
|
30
|
-
label,
|
|
31
|
-
relations: (0, _rambdax.pluck)("id", relations)
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
}).sort(_utils.compareRelations).reverse();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.EdgeBuilder = EdgeBuilder;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { keys, pluck } from "rambdax";
|
|
2
|
-
import { commonAncestor, compareRelations } from "../utils/index.js";
|
|
3
|
-
export class EdgeBuilder {
|
|
4
|
-
_relationsObj = {};
|
|
5
|
-
add(source, target, relation) {
|
|
6
|
-
const bySource = this._relationsObj[source] ?? {};
|
|
7
|
-
const relations = bySource[target] ?? [];
|
|
8
|
-
relations.push(relation);
|
|
9
|
-
bySource[target] = relations;
|
|
10
|
-
this._relationsObj[source] = bySource;
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
build() {
|
|
14
|
-
return keys(this._relationsObj).flatMap((source) => {
|
|
15
|
-
const targets = this._relationsObj[source] ?? {};
|
|
16
|
-
return keys(targets).map((target) => {
|
|
17
|
-
const relations = (targets[target] ?? []).sort(compareRelations);
|
|
18
|
-
const label = relations.find((r) => r.title !== "")?.title ?? null;
|
|
19
|
-
return {
|
|
20
|
-
id: `${source}:${target}`,
|
|
21
|
-
parent: commonAncestor(source, target),
|
|
22
|
-
source,
|
|
23
|
-
target,
|
|
24
|
-
label,
|
|
25
|
-
relations: pluck("id", relations)
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
}).sort(compareRelations).reverse();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ComputeCtx = void 0;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _types = require("../types/index.cjs");
|
|
9
|
-
var _computePredicates = require("./compute-predicates.cjs");
|
|
10
|
-
var _errors = require("../errors/index.cjs");
|
|
11
|
-
class ComputeCtx {
|
|
12
|
-
constructor(index, root, elements = /* @__PURE__ */new Set(), relations = /* @__PURE__ */new Set(), implicits = /* @__PURE__ */new Set()) {
|
|
13
|
-
this.index = index;
|
|
14
|
-
this.root = root;
|
|
15
|
-
this.elements = elements;
|
|
16
|
-
this.relations = relations;
|
|
17
|
-
this.implicits = implicits;
|
|
18
|
-
}
|
|
19
|
-
include({
|
|
20
|
-
elements,
|
|
21
|
-
relations,
|
|
22
|
-
implicits
|
|
23
|
-
}) {
|
|
24
|
-
return new ComputeCtx(this.index, this.root, elements ? /* @__PURE__ */new Set([...this.elements, ...elements]) : this.elements, relations ? /* @__PURE__ */new Set([...this.relations, ...relations]) : this.relations, implicits ? /* @__PURE__ */new Set([...this.implicits, ...implicits]) : this.implicits);
|
|
25
|
-
}
|
|
26
|
-
exclude({
|
|
27
|
-
elements,
|
|
28
|
-
relations,
|
|
29
|
-
implicits
|
|
30
|
-
}) {
|
|
31
|
-
let newImplicits = implicits ? new Set((0, _rambdax.difference)([...this.implicits], implicits)) : this.implicits;
|
|
32
|
-
if (elements) {
|
|
33
|
-
newImplicits = new Set((0, _rambdax.difference)([...newImplicits], elements));
|
|
34
|
-
}
|
|
35
|
-
return new ComputeCtx(this.index, this.root, elements ? new Set((0, _rambdax.difference)([...this.elements], elements)) : this.elements, relations ? new Set((0, _rambdax.difference)([...this.relations], relations)) : this.relations, newImplicits);
|
|
36
|
-
}
|
|
37
|
-
processViewRules(viewRules) {
|
|
38
|
-
let ctx = this;
|
|
39
|
-
for (const {
|
|
40
|
-
isInclude,
|
|
41
|
-
exprs
|
|
42
|
-
} of viewRules) {
|
|
43
|
-
for (const expr of exprs) {
|
|
44
|
-
if (_types.Expr.isElementKindExpr(expr) || _types.Expr.isElementTagExpr(expr)) {
|
|
45
|
-
ctx = isInclude ? (0, _computePredicates.includeElementKindOrTag)(ctx, expr) : (0, _computePredicates.excludeElementKindOrTag)(ctx, expr);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (_types.Expr.isElementRef(expr)) {
|
|
49
|
-
ctx = isInclude ? (0, _computePredicates.includeElementRef)(ctx, expr) : (0, _computePredicates.excludeElementRef)(ctx, expr);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (_types.Expr.isWildcard(expr)) {
|
|
53
|
-
ctx = isInclude ? (0, _computePredicates.includeWildcardRef)(ctx, expr) : (0, _computePredicates.excludeWildcardRef)(ctx, expr);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (_types.Expr.isIncoming(expr)) {
|
|
57
|
-
ctx = isInclude ? (0, _computePredicates.includeIncomingExpr)(ctx, expr) : (0, _computePredicates.excludeIncomingExpr)(ctx, expr);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (_types.Expr.isOutgoing(expr)) {
|
|
61
|
-
ctx = isInclude ? (0, _computePredicates.includeOutgoingExpr)(ctx, expr) : (0, _computePredicates.excludeOutgoingExpr)(ctx, expr);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (_types.Expr.isInOut(expr)) {
|
|
65
|
-
ctx = isInclude ? (0, _computePredicates.includeInOutExpr)(ctx, expr) : (0, _computePredicates.excludeInOutExpr)(ctx, expr);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (_types.Expr.isRelation(expr)) {
|
|
69
|
-
ctx = isInclude ? (0, _computePredicates.includeRelationExpr)(ctx, expr) : (0, _computePredicates.excludeRelationExpr)(ctx, expr);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
(0, _errors.nonexhaustive)(expr);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return ctx;
|
|
76
|
-
}
|
|
77
|
-
static create(view, index) {
|
|
78
|
-
const rootElement = (0, _types.isStrictElementView)(view) ? view.viewOf : null;
|
|
79
|
-
let ctx = new ComputeCtx(index, rootElement);
|
|
80
|
-
const rulesInclude = view.rules.filter(_types.isViewRuleExpression);
|
|
81
|
-
if (rootElement && rulesInclude.length == 0) {
|
|
82
|
-
ctx = ctx.include({
|
|
83
|
-
elements: [index.find(rootElement)]
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return ctx.processViewRules(rulesInclude);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.ComputeCtx = ComputeCtx;
|
|
@@ -1,19 +0,0 @@
|
|
|
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: Set<Element>;
|
|
12
|
-
relations: Set<Relation>;
|
|
13
|
-
implicits: Set<Element>;
|
|
14
|
-
constructor(index: ModelIndex, root: Fqn | null, elements?: Set<Element>, relations?: Set<Relation>, implicits?: Set<Element>);
|
|
15
|
-
include({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
16
|
-
exclude({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
17
|
-
processViewRules(viewRules: ViewRuleExpression[]): ComputeCtx;
|
|
18
|
-
static create(view: ElementView, index: ModelIndex): ComputeCtx;
|
|
19
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { difference } from "rambdax";
|
|
2
|
-
import { Expr, isStrictElementView, isViewRuleExpression } from "../types/index.js";
|
|
3
|
-
import {
|
|
4
|
-
excludeElementKindOrTag,
|
|
5
|
-
excludeElementRef,
|
|
6
|
-
excludeInOutExpr,
|
|
7
|
-
excludeIncomingExpr,
|
|
8
|
-
excludeOutgoingExpr,
|
|
9
|
-
excludeRelationExpr,
|
|
10
|
-
excludeWildcardRef,
|
|
11
|
-
includeElementKindOrTag,
|
|
12
|
-
includeElementRef,
|
|
13
|
-
includeInOutExpr,
|
|
14
|
-
includeIncomingExpr,
|
|
15
|
-
includeOutgoingExpr,
|
|
16
|
-
includeRelationExpr,
|
|
17
|
-
includeWildcardRef
|
|
18
|
-
} from "./compute-predicates.js";
|
|
19
|
-
import { nonexhaustive } from "../errors/index.js";
|
|
20
|
-
export class ComputeCtx {
|
|
21
|
-
constructor(index, root, elements = /* @__PURE__ */ new Set(), relations = /* @__PURE__ */ new Set(), implicits = /* @__PURE__ */ new Set()) {
|
|
22
|
-
this.index = index;
|
|
23
|
-
this.root = root;
|
|
24
|
-
this.elements = elements;
|
|
25
|
-
this.relations = relations;
|
|
26
|
-
this.implicits = implicits;
|
|
27
|
-
}
|
|
28
|
-
include({ elements, relations, implicits }) {
|
|
29
|
-
return new ComputeCtx(
|
|
30
|
-
this.index,
|
|
31
|
-
this.root,
|
|
32
|
-
elements ? /* @__PURE__ */ new Set([...this.elements, ...elements]) : this.elements,
|
|
33
|
-
relations ? /* @__PURE__ */ new Set([...this.relations, ...relations]) : this.relations,
|
|
34
|
-
implicits ? /* @__PURE__ */ new Set([...this.implicits, ...implicits]) : this.implicits
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
exclude({ elements, relations, implicits }) {
|
|
38
|
-
let newImplicits = implicits ? new Set(difference([...this.implicits], implicits)) : this.implicits;
|
|
39
|
-
if (elements) {
|
|
40
|
-
newImplicits = new Set(difference([...newImplicits], elements));
|
|
41
|
-
}
|
|
42
|
-
return new ComputeCtx(
|
|
43
|
-
this.index,
|
|
44
|
-
this.root,
|
|
45
|
-
elements ? new Set(difference([...this.elements], elements)) : this.elements,
|
|
46
|
-
relations ? new Set(difference([...this.relations], relations)) : this.relations,
|
|
47
|
-
newImplicits
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
processViewRules(viewRules) {
|
|
51
|
-
let ctx = this;
|
|
52
|
-
for (const { isInclude, exprs } of viewRules) {
|
|
53
|
-
for (const expr of exprs) {
|
|
54
|
-
if (Expr.isElementKindExpr(expr) || Expr.isElementTagExpr(expr)) {
|
|
55
|
-
ctx = isInclude ? includeElementKindOrTag(ctx, expr) : excludeElementKindOrTag(ctx, expr);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (Expr.isElementRef(expr)) {
|
|
59
|
-
ctx = isInclude ? includeElementRef(ctx, expr) : excludeElementRef(ctx, expr);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (Expr.isWildcard(expr)) {
|
|
63
|
-
ctx = isInclude ? includeWildcardRef(ctx, expr) : excludeWildcardRef(ctx, expr);
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (Expr.isIncoming(expr)) {
|
|
67
|
-
ctx = isInclude ? includeIncomingExpr(ctx, expr) : excludeIncomingExpr(ctx, expr);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (Expr.isOutgoing(expr)) {
|
|
71
|
-
ctx = isInclude ? includeOutgoingExpr(ctx, expr) : excludeOutgoingExpr(ctx, expr);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (Expr.isInOut(expr)) {
|
|
75
|
-
ctx = isInclude ? includeInOutExpr(ctx, expr) : excludeInOutExpr(ctx, expr);
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (Expr.isRelation(expr)) {
|
|
79
|
-
ctx = isInclude ? includeRelationExpr(ctx, expr) : excludeRelationExpr(ctx, expr);
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
nonexhaustive(expr);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return ctx;
|
|
86
|
-
}
|
|
87
|
-
static create(view, index) {
|
|
88
|
-
const rootElement = isStrictElementView(view) ? view.viewOf : null;
|
|
89
|
-
let ctx = new ComputeCtx(index, rootElement);
|
|
90
|
-
const rulesInclude = view.rules.filter(isViewRuleExpression);
|
|
91
|
-
if (rootElement && rulesInclude.length == 0) {
|
|
92
|
-
ctx = ctx.include({
|
|
93
|
-
elements: [index.find(rootElement)]
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return ctx.processViewRules(rulesInclude);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.computeElementView = computeElementView;
|
|
7
|
-
var _remeda = require("remeda");
|
|
8
|
-
var _errors = require("../errors/index.cjs");
|
|
9
|
-
var _types = require("../types/index.cjs");
|
|
10
|
-
var _utils = require("../utils/index.cjs");
|
|
11
|
-
var _EdgeBuilder = require("./EdgeBuilder.cjs");
|
|
12
|
-
var _computeCtx = require("./compute-ctx.cjs");
|
|
13
|
-
var _applyViewRuleStyles = require("./utils/applyViewRuleStyles.cjs");
|
|
14
|
-
var _sortNodes = require("./utils/sortNodes.cjs");
|
|
15
|
-
function reduceToMap(elementsIterator) {
|
|
16
|
-
return Array.from(elementsIterator).sort(_utils.compareByFqnHierarchically).reduce((map, {
|
|
17
|
-
id,
|
|
18
|
-
color,
|
|
19
|
-
shape,
|
|
20
|
-
...el
|
|
21
|
-
}) => {
|
|
22
|
-
let parent = (0, _utils.parentFqn)(id);
|
|
23
|
-
while (parent) {
|
|
24
|
-
if (map.has(parent)) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
parent = (0, _utils.parentFqn)(parent);
|
|
28
|
-
}
|
|
29
|
-
if (parent) {
|
|
30
|
-
const parentNd = (0, _errors.nonNullable)(map.get(parent));
|
|
31
|
-
parentNd.children.push(id);
|
|
32
|
-
}
|
|
33
|
-
const node = {
|
|
34
|
-
...el,
|
|
35
|
-
id,
|
|
36
|
-
parent,
|
|
37
|
-
color: color ?? _types.DefaultThemeColor,
|
|
38
|
-
shape: shape ?? _types.DefaultElementShape,
|
|
39
|
-
children: [],
|
|
40
|
-
inEdges: [],
|
|
41
|
-
outEdges: []
|
|
42
|
-
};
|
|
43
|
-
map.set(id, node);
|
|
44
|
-
return map;
|
|
45
|
-
}, /* @__PURE__ */new Map());
|
|
46
|
-
}
|
|
47
|
-
function computeElementView(view, index) {
|
|
48
|
-
const ctx = _computeCtx.ComputeCtx.create(view, index);
|
|
49
|
-
const allElements = [...ctx.elements, ...ctx.implicits].sort(_utils.compareByFqnHierarchically).reverse();
|
|
50
|
-
const elementsWithRelations = /* @__PURE__ */new Set();
|
|
51
|
-
const edgeBuilder = new _EdgeBuilder.EdgeBuilder();
|
|
52
|
-
const anscestorOf = id => e => e.id === id || (0, _utils.isAncestor)(e.id, id);
|
|
53
|
-
const sortedRelations = [...ctx.relations];
|
|
54
|
-
for (const rel of sortedRelations) {
|
|
55
|
-
const source = (0, _remeda.find)(allElements, anscestorOf(rel.source));
|
|
56
|
-
if (!source) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
const target = (0, _remeda.find)(allElements, (0, _remeda.allPass)([anscestorOf(rel.target), e => !(0, _utils.isSameHierarchy)(e, source)]));
|
|
60
|
-
if (!target) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
elementsWithRelations.add(source);
|
|
64
|
-
elementsWithRelations.add(target);
|
|
65
|
-
edgeBuilder.add(source.id, target.id, rel);
|
|
66
|
-
}
|
|
67
|
-
const elements = /* @__PURE__ */new Set([...ctx.elements, ...elementsWithRelations]);
|
|
68
|
-
const nodesMap = reduceToMap(elements);
|
|
69
|
-
const edges = edgeBuilder.build().map(edge => {
|
|
70
|
-
while (edge.parent) {
|
|
71
|
-
if (nodesMap.has(edge.parent)) {
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
edge.parent = (0, _utils.parentFqn)(edge.parent);
|
|
75
|
-
}
|
|
76
|
-
(0, _errors.nonNullable)(nodesMap.get(edge.source)).outEdges.push(edge.id);
|
|
77
|
-
(0, _errors.nonNullable)(nodesMap.get(edge.target)).inEdges.push(edge.id);
|
|
78
|
-
return edge;
|
|
79
|
-
});
|
|
80
|
-
const nodes = (0, _applyViewRuleStyles.applyViewRuleStyles)(view.rules.filter(_types.isViewRuleStyle), (0, _sortNodes.sortNodes)(nodesMap, edges)
|
|
81
|
-
// map(e => nodesMap.get(e.id)!, Array.from(elements))
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const autoLayoutRule = view.rules.find(_types.isViewRuleAutoLayout);
|
|
85
|
-
return {
|
|
86
|
-
...view,
|
|
87
|
-
autoLayout: autoLayoutRule?.autoLayout ?? "TB",
|
|
88
|
-
nodes,
|
|
89
|
-
edges
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { allPass, find } from "remeda";
|
|
2
|
-
import { nonNullable } from "../errors/index.js";
|
|
3
|
-
import {
|
|
4
|
-
DefaultElementShape,
|
|
5
|
-
DefaultThemeColor,
|
|
6
|
-
isViewRuleAutoLayout,
|
|
7
|
-
isViewRuleStyle
|
|
8
|
-
} from "../types/index.js";
|
|
9
|
-
import { compareByFqnHierarchically, isAncestor, isSameHierarchy, parentFqn } from "../utils/index.js";
|
|
10
|
-
import { EdgeBuilder } from "./EdgeBuilder.js";
|
|
11
|
-
import { ComputeCtx } from "./compute-ctx.js";
|
|
12
|
-
import { applyViewRuleStyles } from "./utils/applyViewRuleStyles.js";
|
|
13
|
-
import { sortNodes } from "./utils/sortNodes.js";
|
|
14
|
-
function reduceToMap(elementsIterator) {
|
|
15
|
-
return Array.from(elementsIterator).sort(compareByFqnHierarchically).reduce((map, { id, color, shape, ...el }) => {
|
|
16
|
-
let parent = parentFqn(id);
|
|
17
|
-
while (parent) {
|
|
18
|
-
if (map.has(parent)) {
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
parent = parentFqn(parent);
|
|
22
|
-
}
|
|
23
|
-
if (parent) {
|
|
24
|
-
const parentNd = nonNullable(map.get(parent));
|
|
25
|
-
parentNd.children.push(id);
|
|
26
|
-
}
|
|
27
|
-
const node = {
|
|
28
|
-
...el,
|
|
29
|
-
id,
|
|
30
|
-
parent,
|
|
31
|
-
color: color ?? DefaultThemeColor,
|
|
32
|
-
shape: shape ?? DefaultElementShape,
|
|
33
|
-
children: [],
|
|
34
|
-
inEdges: [],
|
|
35
|
-
outEdges: []
|
|
36
|
-
};
|
|
37
|
-
map.set(id, node);
|
|
38
|
-
return map;
|
|
39
|
-
}, /* @__PURE__ */ new Map());
|
|
40
|
-
}
|
|
41
|
-
export function computeElementView(view, index) {
|
|
42
|
-
const ctx = ComputeCtx.create(view, index);
|
|
43
|
-
const allElements = [...ctx.elements, ...ctx.implicits].sort(compareByFqnHierarchically).reverse();
|
|
44
|
-
const elementsWithRelations = /* @__PURE__ */ new Set();
|
|
45
|
-
const edgeBuilder = new EdgeBuilder();
|
|
46
|
-
const anscestorOf = (id) => (e) => e.id === id || isAncestor(e.id, id);
|
|
47
|
-
const sortedRelations = [...ctx.relations];
|
|
48
|
-
for (const rel of sortedRelations) {
|
|
49
|
-
const source = find(allElements, anscestorOf(rel.source));
|
|
50
|
-
if (!source) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const target = find(allElements, allPass([anscestorOf(rel.target), (e) => !isSameHierarchy(e, source)]));
|
|
54
|
-
if (!target) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
elementsWithRelations.add(source);
|
|
58
|
-
elementsWithRelations.add(target);
|
|
59
|
-
edgeBuilder.add(source.id, target.id, rel);
|
|
60
|
-
}
|
|
61
|
-
const elements = /* @__PURE__ */ new Set([...ctx.elements, ...elementsWithRelations]);
|
|
62
|
-
const nodesMap = reduceToMap(elements);
|
|
63
|
-
const edges = edgeBuilder.build().map((edge) => {
|
|
64
|
-
while (edge.parent) {
|
|
65
|
-
if (nodesMap.has(edge.parent)) {
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
edge.parent = parentFqn(edge.parent);
|
|
69
|
-
}
|
|
70
|
-
nonNullable(nodesMap.get(edge.source)).outEdges.push(edge.id);
|
|
71
|
-
nonNullable(nodesMap.get(edge.target)).inEdges.push(edge.id);
|
|
72
|
-
return edge;
|
|
73
|
-
});
|
|
74
|
-
const nodes = applyViewRuleStyles(
|
|
75
|
-
view.rules.filter(isViewRuleStyle),
|
|
76
|
-
sortNodes(nodesMap, edges)
|
|
77
|
-
// map(e => nodesMap.get(e.id)!, Array.from(elements))
|
|
78
|
-
);
|
|
79
|
-
const autoLayoutRule = view.rules.find(isViewRuleAutoLayout);
|
|
80
|
-
return {
|
|
81
|
-
...view,
|
|
82
|
-
autoLayout: autoLayoutRule?.autoLayout ?? "TB",
|
|
83
|
-
nodes,
|
|
84
|
-
edges
|
|
85
|
-
};
|
|
86
|
-
}
|