@likec4/core 0.40.0 → 0.42.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/{esm/colors.js → cjs/colors/element.js} +9 -23
- 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/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/types/computed-view.d.ts +10 -7
- package/dist/cjs/types/diagram.d.ts +14 -5
- package/dist/cjs/types/expression.d.ts +1 -1
- package/dist/cjs/types/relation.d.ts +12 -0
- package/dist/cjs/types/relation.js +12 -1
- package/dist/cjs/types/theme.d.ts +12 -14
- package/dist/cjs/types/view.d.ts +7 -4
- package/dist/cjs/types/view.js +1 -1
- package/dist/cjs/utils/fqn.d.ts +6 -1
- package/dist/cjs/utils/fqn.js +17 -4
- package/dist/cjs/utils/guards.d.ts +1 -0
- package/dist/cjs/utils/guards.js +7 -0
- package/dist/cjs/utils/index.d.ts +0 -1
- package/dist/cjs/utils/index.js +0 -11
- package/dist/esm/colors/element.d.ts +68 -0
- package/dist/{cjs/colors.js → esm/colors/element.js} +1 -33
- 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/index.d.ts +0 -2
- package/dist/esm/index.js +1 -3
- package/dist/esm/types/computed-view.d.ts +10 -7
- package/dist/esm/types/diagram.d.ts +14 -5
- package/dist/esm/types/expression.d.ts +1 -1
- package/dist/esm/types/relation.d.ts +12 -0
- package/dist/esm/types/relation.js +3 -0
- package/dist/esm/types/theme.d.ts +12 -14
- package/dist/esm/types/view.d.ts +7 -4
- package/dist/esm/types/view.js +1 -1
- package/dist/esm/utils/fqn.d.ts +6 -1
- package/dist/esm/utils/fqn.js +16 -4
- package/dist/esm/utils/guards.d.ts +1 -0
- package/dist/esm/utils/guards.js +1 -0
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/utils/index.js +0 -1
- package/dist/types/colors/element.d.ts +69 -0
- package/dist/types/colors/index.d.ts +133 -0
- package/dist/types/colors/relationships.d.ts +58 -0
- package/dist/types/errors/index.d.ts +46 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/types/_common.d.ts +4 -0
- package/dist/types/types/computed-view.d.ts +45 -0
- package/dist/types/types/diagram.d.ts +42 -0
- package/dist/types/types/element.d.ts +30 -0
- package/dist/types/types/expression.d.ts +57 -0
- package/dist/types/types/index.d.ts +12 -0
- package/dist/types/types/model.d.ts +15 -0
- package/dist/types/types/opaque.d.ts +103 -0
- package/dist/types/types/relation.d.ts +23 -0
- package/dist/types/types/theme.d.ts +27 -0
- package/dist/types/types/view.d.ts +62 -0
- package/dist/types/utils/fqn.d.ts +34 -0
- package/dist/types/utils/guards.d.ts +5 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/relations.d.ts +26 -0
- package/package.json +51 -54
- package/dist/cjs/colors.d.ts +0 -148
- package/dist/cjs/compute-view/EdgeBuilder.d.ts +0 -6
- package/dist/cjs/compute-view/EdgeBuilder.js +0 -37
- package/dist/cjs/compute-view/compute-ctx.d.ts +0 -20
- package/dist/cjs/compute-view/compute-ctx.js +0 -91
- package/dist/cjs/compute-view/compute-element-view.d.ts +0 -3
- package/dist/cjs/compute-view/compute-element-view.js +0 -100
- package/dist/cjs/compute-view/compute-predicates.d.ts +0 -16
- package/dist/cjs/compute-view/compute-predicates.js +0 -363
- package/dist/cjs/compute-view/compute.d.ts +0 -14
- package/dist/cjs/compute-view/compute.js +0 -46
- package/dist/cjs/compute-view/index.d.ts +0 -4
- package/dist/cjs/compute-view/index.js +0 -49
- package/dist/cjs/compute-view/resolve-extended-views.d.ts +0 -6
- package/dist/cjs/compute-view/resolve-extended-views.js +0 -53
- package/dist/cjs/compute-view/resolve-relative-paths.d.ts +0 -2
- package/dist/cjs/compute-view/resolve-relative-paths.js +0 -84
- package/dist/cjs/compute-view/utils/anyPossibleRelations.d.ts +0 -2
- package/dist/cjs/compute-view/utils/anyPossibleRelations.js +0 -18
- package/dist/cjs/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
- package/dist/cjs/compute-view/utils/applyViewRuleStyles.js +0 -57
- package/dist/cjs/compute-view/utils/sortNodes.d.ts +0 -19
- package/dist/cjs/compute-view/utils/sortNodes.js +0 -47
- package/dist/cjs/model-index/ModelIndex.d.ts +0 -27
- package/dist/cjs/model-index/ModelIndex.js +0 -139
- package/dist/cjs/model-index/index.d.ts +0 -1
- package/dist/cjs/model-index/index.js +0 -13
- package/dist/cjs/utils/compute-node-levels.d.ts +0 -7
- package/dist/cjs/utils/compute-node-levels.js +0 -48
- package/dist/esm/colors.d.ts +0 -148
- package/dist/esm/compute-view/EdgeBuilder.d.ts +0 -6
- package/dist/esm/compute-view/EdgeBuilder.js +0 -30
- package/dist/esm/compute-view/compute-ctx.d.ts +0 -20
- package/dist/esm/compute-view/compute-ctx.js +0 -100
- package/dist/esm/compute-view/compute-element-view.d.ts +0 -3
- package/dist/esm/compute-view/compute-element-view.js +0 -98
- package/dist/esm/compute-view/compute-predicates.d.ts +0 -16
- package/dist/esm/compute-view/compute-predicates.js +0 -324
- package/dist/esm/compute-view/compute.d.ts +0 -14
- package/dist/esm/compute-view/compute.js +0 -36
- package/dist/esm/compute-view/index.d.ts +0 -4
- package/dist/esm/compute-view/index.js +0 -4
- package/dist/esm/compute-view/resolve-extended-views.d.ts +0 -6
- package/dist/esm/compute-view/resolve-extended-views.js +0 -41
- package/dist/esm/compute-view/resolve-relative-paths.d.ts +0 -2
- package/dist/esm/compute-view/resolve-relative-paths.js +0 -76
- package/dist/esm/compute-view/utils/anyPossibleRelations.d.ts +0 -2
- package/dist/esm/compute-view/utils/anyPossibleRelations.js +0 -12
- package/dist/esm/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
- package/dist/esm/compute-view/utils/applyViewRuleStyles.js +0 -50
- package/dist/esm/compute-view/utils/sortNodes.d.ts +0 -19
- package/dist/esm/compute-view/utils/sortNodes.js +0 -37
- package/dist/esm/model-index/ModelIndex.d.ts +0 -27
- package/dist/esm/model-index/ModelIndex.js +0 -127
- package/dist/esm/model-index/index.d.ts +0 -1
- package/dist/esm/model-index/index.js +0 -1
- package/dist/esm/utils/compute-node-levels.d.ts +0 -7
- package/dist/esm/utils/compute-node-levels.js +0 -31
|
@@ -1,91 +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");
|
|
9
|
-
var _computePredicates = require("./compute-predicates");
|
|
10
|
-
var _errors = require("../errors");
|
|
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
|
-
this.allElements = /* @__PURE__ */new Set([...this.elements, ...this.implicits]);
|
|
19
|
-
}
|
|
20
|
-
allElements;
|
|
21
|
-
include({
|
|
22
|
-
elements,
|
|
23
|
-
relations,
|
|
24
|
-
implicits
|
|
25
|
-
}) {
|
|
26
|
-
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);
|
|
27
|
-
}
|
|
28
|
-
exclude({
|
|
29
|
-
elements,
|
|
30
|
-
relations,
|
|
31
|
-
implicits
|
|
32
|
-
}) {
|
|
33
|
-
let newImplicits = implicits ? new Set((0, _rambdax.difference)([...this.implicits], implicits)) : this.implicits;
|
|
34
|
-
if (elements) {
|
|
35
|
-
newImplicits = new Set((0, _rambdax.difference)([...newImplicits], elements));
|
|
36
|
-
}
|
|
37
|
-
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);
|
|
38
|
-
}
|
|
39
|
-
processViewRules(viewRules) {
|
|
40
|
-
let ctx = this;
|
|
41
|
-
for (const {
|
|
42
|
-
isInclude,
|
|
43
|
-
exprs
|
|
44
|
-
} of viewRules) {
|
|
45
|
-
for (const expr of exprs) {
|
|
46
|
-
if (_types.Expr.isElementKindExpr(expr) || _types.Expr.isElementTagExpr(expr)) {
|
|
47
|
-
ctx = isInclude ? (0, _computePredicates.includeElementKindOrTag)(ctx, expr) : (0, _computePredicates.excludeElementKindOrTag)(ctx, expr);
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (_types.Expr.isElementRef(expr)) {
|
|
51
|
-
ctx = isInclude ? (0, _computePredicates.includeElementRef)(ctx, expr) : (0, _computePredicates.excludeElementRef)(ctx, expr);
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (_types.Expr.isWildcard(expr)) {
|
|
55
|
-
ctx = isInclude ? (0, _computePredicates.includeWildcardRef)(ctx, expr) : (0, _computePredicates.excludeWildcardRef)(ctx, expr);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (_types.Expr.isIncoming(expr)) {
|
|
59
|
-
ctx = isInclude ? (0, _computePredicates.includeIncomingExpr)(ctx, expr) : (0, _computePredicates.excludeIncomingExpr)(ctx, expr);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (_types.Expr.isOutgoing(expr)) {
|
|
63
|
-
ctx = isInclude ? (0, _computePredicates.includeOutgoingExpr)(ctx, expr) : (0, _computePredicates.excludeOutgoingExpr)(ctx, expr);
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (_types.Expr.isInOut(expr)) {
|
|
67
|
-
ctx = isInclude ? (0, _computePredicates.includeInOutExpr)(ctx, expr) : (0, _computePredicates.excludeInOutExpr)(ctx, expr);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (_types.Expr.isRelation(expr)) {
|
|
71
|
-
ctx = isInclude ? (0, _computePredicates.includeRelationExpr)(ctx, expr) : (0, _computePredicates.excludeRelationExpr)(ctx, expr);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
(0, _errors.nonexhaustive)(expr);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return ctx;
|
|
78
|
-
}
|
|
79
|
-
static create(view, index) {
|
|
80
|
-
const rootElement = (0, _types.isStrictElementView)(view) ? view.viewOf : null;
|
|
81
|
-
let ctx = new ComputeCtx(index, rootElement);
|
|
82
|
-
const rulesInclude = view.rules.filter(_types.isViewRuleExpression);
|
|
83
|
-
if (rootElement && rulesInclude.length == 0) {
|
|
84
|
-
ctx = ctx.include({
|
|
85
|
-
elements: [index.find(rootElement)]
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return ctx.processViewRules(rulesInclude);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.ComputeCtx = ComputeCtx;
|
|
@@ -1,100 +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");
|
|
9
|
-
var _types = require("../types");
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
var _EdgeBuilder = require("./EdgeBuilder");
|
|
12
|
-
var _computeCtx = require("./compute-ctx");
|
|
13
|
-
var _applyViewRuleStyles = require("./utils/applyViewRuleStyles");
|
|
14
|
-
var _sortNodes = require("./utils/sortNodes");
|
|
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
|
-
let level = 0;
|
|
24
|
-
while (parent) {
|
|
25
|
-
if (map.has(parent)) {
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
parent = (0, _utils.parentFqn)(parent);
|
|
29
|
-
}
|
|
30
|
-
if (parent) {
|
|
31
|
-
const parentNd = (0, _errors.nonNullable)(map.get(parent));
|
|
32
|
-
parentNd.children.push(id);
|
|
33
|
-
level = parentNd.level + 1;
|
|
34
|
-
}
|
|
35
|
-
const node = {
|
|
36
|
-
...el,
|
|
37
|
-
id,
|
|
38
|
-
parent,
|
|
39
|
-
level,
|
|
40
|
-
color: color ?? _types.DefaultThemeColor,
|
|
41
|
-
shape: shape ?? _types.DefaultElementShape,
|
|
42
|
-
children: [],
|
|
43
|
-
inEdges: [],
|
|
44
|
-
outEdges: []
|
|
45
|
-
};
|
|
46
|
-
map.set(id, node);
|
|
47
|
-
return map;
|
|
48
|
-
}, /* @__PURE__ */new Map());
|
|
49
|
-
}
|
|
50
|
-
const keepOriginalSortFromView = (_nodes, ctx) => {
|
|
51
|
-
const nodes = [...ctx.allElements].flatMap(e => _nodes.get(e.id) || []);
|
|
52
|
-
for (const node of nodes) {
|
|
53
|
-
node.children = nodes.flatMap(n => n.parent === node.id ? n.id : []);
|
|
54
|
-
}
|
|
55
|
-
return nodes;
|
|
56
|
-
};
|
|
57
|
-
function computeElementView(view, index) {
|
|
58
|
-
const ctx = _computeCtx.ComputeCtx.create(view, index);
|
|
59
|
-
const leafsFirst = [...ctx.allElements].sort((a, b) => -1 * (0, _utils.compareByFqnHierarchically)(a, b));
|
|
60
|
-
const elementsWithRelations = /* @__PURE__ */new Set();
|
|
61
|
-
const edgeBuilder = new _EdgeBuilder.EdgeBuilder();
|
|
62
|
-
const anscestorOf = id => e => e.id === id || (0, _utils.isAncestor)(e.id, id);
|
|
63
|
-
const sortedRelations = [...ctx.relations];
|
|
64
|
-
for (const rel of sortedRelations) {
|
|
65
|
-
const source = (0, _remeda.find)(leafsFirst, anscestorOf(rel.source));
|
|
66
|
-
if (!source) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const target = (0, _remeda.find)(leafsFirst, (0, _remeda.allPass)([anscestorOf(rel.target), e => !(0, _utils.isSameHierarchy)(e, source)]));
|
|
70
|
-
if (!target) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
elementsWithRelations.add(source);
|
|
74
|
-
elementsWithRelations.add(target);
|
|
75
|
-
edgeBuilder.add(source.id, target.id, rel);
|
|
76
|
-
}
|
|
77
|
-
const nodesMap = reduceToMap( /* @__PURE__ */new Set([...ctx.elements, ...elementsWithRelations]));
|
|
78
|
-
const edges = edgeBuilder.build().map(edge => {
|
|
79
|
-
while (edge.parent) {
|
|
80
|
-
if (nodesMap.has(edge.parent)) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
edge.parent = (0, _utils.parentFqn)(edge.parent);
|
|
84
|
-
}
|
|
85
|
-
(0, _errors.nonNullable)(nodesMap.get(edge.source)).outEdges.push(edge.id);
|
|
86
|
-
(0, _errors.nonNullable)(nodesMap.get(edge.target)).inEdges.push(edge.id);
|
|
87
|
-
return edge;
|
|
88
|
-
});
|
|
89
|
-
const nodes = (0, _applyViewRuleStyles.applyViewRuleStyles)(view.rules.filter(_types.isViewRuleStyle), (0, _sortNodes.sortNodes)(keepOriginalSortFromView(nodesMap, ctx), edges)
|
|
90
|
-
// map(e => nodesMap.get(e.id)!, Array.from(elements))
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const autoLayoutRule = view.rules.find(_types.isViewRuleAutoLayout);
|
|
94
|
-
return {
|
|
95
|
-
...view,
|
|
96
|
-
autoLayout: autoLayoutRule?.autoLayout ?? "TB",
|
|
97
|
-
nodes,
|
|
98
|
-
edges
|
|
99
|
-
};
|
|
100
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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,363 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.includeWildcardRef = exports.includeRelationExpr = exports.includeOutgoingExpr = exports.includeIncomingExpr = exports.includeInOutExpr = exports.includeElementRef = exports.includeElementKindOrTag = exports.excludeWildcardRef = exports.excludeRelationExpr = exports.excludeOutgoingExpr = exports.excludeIncomingExpr = exports.excludeInOutExpr = exports.excludeElementRef = exports.excludeElementKindOrTag = void 0;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _types = require("../types");
|
|
9
|
-
var _utils = require("../utils");
|
|
10
|
-
var _computeCtx = require("./compute-ctx");
|
|
11
|
-
const {
|
|
12
|
-
isAnyInOut,
|
|
13
|
-
isBetween,
|
|
14
|
-
isIncoming,
|
|
15
|
-
isInside,
|
|
16
|
-
isOutgoing,
|
|
17
|
-
isAnyBetween
|
|
18
|
-
} = _utils.Relations;
|
|
19
|
-
const includeElementRef = (ctx, expr) => {
|
|
20
|
-
const elements = expr.isDescedants ? ctx.index.children(expr.element) : [ctx.index.find(expr.element)];
|
|
21
|
-
const filters = [];
|
|
22
|
-
if (expr.isDescedants) {
|
|
23
|
-
elements.forEach(child => {
|
|
24
|
-
filters.push((0, _rambdax.both)(isInside(expr.element), isAnyInOut(child.id)));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const ctxElements = (0, _rambdax.uniq)([...ctx.elements, ...ctx.implicits]);
|
|
28
|
-
const excludeImplicits = [];
|
|
29
|
-
for (const el of elements) {
|
|
30
|
-
if (ctx.root && ctx.root !== el.id && !(0, _utils.isAncestor)(el.id, ctx.root)) {
|
|
31
|
-
excludeImplicits.push(...[...ctx.implicits].filter(impl => (0, _utils.isAncestor)(el.id, impl.id)));
|
|
32
|
-
}
|
|
33
|
-
for (const ctxEl of ctxElements) {
|
|
34
|
-
if (!(0, _utils.isSameHierarchy)(el, ctxEl)) {
|
|
35
|
-
filters.push(isAnyBetween(el.id, ctxEl.id));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const relations = filters.length ? ctx.index.filterRelations((0, _rambdax.anyPass)(filters)) : [];
|
|
40
|
-
if (excludeImplicits.length == 0) {
|
|
41
|
-
return ctx.include({
|
|
42
|
-
elements,
|
|
43
|
-
relations
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return ctx.include({
|
|
47
|
-
elements,
|
|
48
|
-
relations
|
|
49
|
-
}).exclude({
|
|
50
|
-
implicits: excludeImplicits
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.includeElementRef = includeElementRef;
|
|
54
|
-
const excludeElementRef = (ctx, expr) => {
|
|
55
|
-
const elements = expr.isDescedants ? ctx.index.children(expr.element) : [ctx.index.find(expr.element)];
|
|
56
|
-
const elementsIds = elements.map(e => e.id);
|
|
57
|
-
const relations = [...ctx.relations].filter(r => elementsIds.includes(r.source) || elementsIds.includes(r.target));
|
|
58
|
-
return ctx.exclude({
|
|
59
|
-
elements,
|
|
60
|
-
relations
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
exports.excludeElementRef = excludeElementRef;
|
|
64
|
-
const asElementPredicate = expr => {
|
|
65
|
-
if (expr.isEqual) {
|
|
66
|
-
if (_types.Expr.isElementKindExpr(expr)) {
|
|
67
|
-
return e => e.kind === expr.elementKind;
|
|
68
|
-
} else {
|
|
69
|
-
return ({
|
|
70
|
-
tags
|
|
71
|
-
}) => !!tags && tags.includes(expr.elementTag);
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
if (_types.Expr.isElementKindExpr(expr)) {
|
|
75
|
-
return e => e.kind !== expr.elementKind;
|
|
76
|
-
} else {
|
|
77
|
-
return ({
|
|
78
|
-
tags
|
|
79
|
-
}) => (0, _rambdax.isNil)(tags) || tags.length === 0 || !tags.includes(expr.elementTag);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const includeElementKindOrTag = (ctx, expr) => {
|
|
84
|
-
const elements = ctx.index.elements.filter(asElementPredicate(expr));
|
|
85
|
-
return elements.reduce((accCtx, el) => includeElementRef(accCtx, {
|
|
86
|
-
element: el.id,
|
|
87
|
-
isDescedants: false
|
|
88
|
-
}), ctx);
|
|
89
|
-
};
|
|
90
|
-
exports.includeElementKindOrTag = includeElementKindOrTag;
|
|
91
|
-
const excludeElementKindOrTag = (ctx, expr) => {
|
|
92
|
-
const predicate = asElementPredicate(expr);
|
|
93
|
-
const elements = [...ctx.elements].filter(predicate);
|
|
94
|
-
const implicits = [...ctx.implicits].filter(predicate);
|
|
95
|
-
return ctx.exclude({
|
|
96
|
-
elements,
|
|
97
|
-
implicits
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
exports.excludeElementKindOrTag = excludeElementKindOrTag;
|
|
101
|
-
const includeWildcardRef = (ctx, _expr) => {
|
|
102
|
-
const {
|
|
103
|
-
root
|
|
104
|
-
} = ctx;
|
|
105
|
-
if (root) {
|
|
106
|
-
const elements = [ctx.index.find(root), ...ctx.index.children(root)];
|
|
107
|
-
const allImplicits = [...ctx.index.siblings(root), ...ctx.index.ancestors(root).flatMap(a => [...ctx.index.siblings(a.id)])];
|
|
108
|
-
const inOut = ctx.index.filterRelations(isAnyInOut(root));
|
|
109
|
-
const implicits = [];
|
|
110
|
-
for (const implicit of allImplicits) {
|
|
111
|
-
if (inOut.some(isAnyInOut(implicit.id))) {
|
|
112
|
-
implicits.push(implicit);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return ctx.include({
|
|
116
|
-
elements,
|
|
117
|
-
relations: [...ctx.index.filterRelations(isInside(root)), ...inOut],
|
|
118
|
-
implicits
|
|
119
|
-
});
|
|
120
|
-
} else {
|
|
121
|
-
const elements = ctx.index.rootElements();
|
|
122
|
-
if (elements.length <= 1) {
|
|
123
|
-
return new _computeCtx.ComputeCtx(ctx.index, ctx.root, new Set(elements));
|
|
124
|
-
}
|
|
125
|
-
const relations = ctx.index.filterRelations(rel => (0, _rambdax.isNil)((0, _utils.commonAncestor)(rel.source, rel.target)));
|
|
126
|
-
return ctx.include({
|
|
127
|
-
elements,
|
|
128
|
-
relations
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
exports.includeWildcardRef = includeWildcardRef;
|
|
133
|
-
const excludeWildcardRef = (ctx, _expr) => {
|
|
134
|
-
const {
|
|
135
|
-
root
|
|
136
|
-
} = ctx;
|
|
137
|
-
if (root) {
|
|
138
|
-
const relations = [...ctx.relations].filter((0, _rambdax.either)(isInside(root), isAnyInOut(root)));
|
|
139
|
-
return ctx.exclude({
|
|
140
|
-
elements: [...ctx.elements].filter(e => e.id === root || (0, _utils.isAncestor)(root, e.id)),
|
|
141
|
-
relations,
|
|
142
|
-
implicits: [...ctx.implicits].filter(e => relations.some(isAnyInOut(e.id)))
|
|
143
|
-
});
|
|
144
|
-
} else {
|
|
145
|
-
return new _computeCtx.ComputeCtx(ctx.index, ctx.root);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
exports.excludeWildcardRef = excludeWildcardRef;
|
|
149
|
-
const resolveElements = (ctx, expr) => {
|
|
150
|
-
if (_types.Expr.isWildcard(expr)) {
|
|
151
|
-
if (ctx.root) {
|
|
152
|
-
return [ctx.index.find(ctx.root)];
|
|
153
|
-
} else {
|
|
154
|
-
return ctx.index.rootElements();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (_types.Expr.isElementKindExpr(expr)) {
|
|
158
|
-
return ctx.index.elements.filter(el => {
|
|
159
|
-
if (expr.isEqual) {
|
|
160
|
-
return el.kind === expr.elementKind;
|
|
161
|
-
}
|
|
162
|
-
return el.kind !== expr.elementKind;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (_types.Expr.isElementTagExpr(expr)) {
|
|
166
|
-
return ctx.index.elements.filter(el => {
|
|
167
|
-
const tags = el.tags;
|
|
168
|
-
if (expr.isEqual) {
|
|
169
|
-
return !!tags && tags.includes(expr.elementTag);
|
|
170
|
-
}
|
|
171
|
-
return (0, _rambdax.isNil)(tags) || tags.length === 0 || !tags.includes(expr.elementTag);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (expr.isDescedants) {
|
|
175
|
-
return ctx.index.children(expr.element);
|
|
176
|
-
} else {
|
|
177
|
-
return [ctx.index.find(expr.element)];
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const includeIncomingExpr = (ctx, expr) => {
|
|
181
|
-
if (_types.Expr.isWildcard(expr.incoming) && !ctx.root) {
|
|
182
|
-
return ctx;
|
|
183
|
-
}
|
|
184
|
-
const elements = resolveElements(ctx, expr.incoming);
|
|
185
|
-
if (elements.length === 0) {
|
|
186
|
-
return ctx;
|
|
187
|
-
}
|
|
188
|
-
let allrelations = ctx.index.relations;
|
|
189
|
-
if (_types.Expr.isElementRef(expr.incoming)) {
|
|
190
|
-
allrelations = allrelations.filter(isIncoming(expr.incoming.element));
|
|
191
|
-
}
|
|
192
|
-
const implicits = [];
|
|
193
|
-
const relations = [];
|
|
194
|
-
for (const el of elements) {
|
|
195
|
-
const elRelations = allrelations.filter(isIncoming(el.id));
|
|
196
|
-
if (elRelations.length > 0) {
|
|
197
|
-
relations.push(...elRelations);
|
|
198
|
-
implicits.push(el);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return ctx.include({
|
|
202
|
-
relations,
|
|
203
|
-
implicits
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
exports.includeIncomingExpr = includeIncomingExpr;
|
|
207
|
-
const excludeIncomingExpr = (ctx, expr) => {
|
|
208
|
-
if (_types.Expr.isWildcard(expr.incoming) && !ctx.root) {
|
|
209
|
-
return ctx;
|
|
210
|
-
}
|
|
211
|
-
const elements = resolveElements(ctx, expr.incoming);
|
|
212
|
-
if (elements.length === 0) {
|
|
213
|
-
return ctx;
|
|
214
|
-
}
|
|
215
|
-
const isIncomings = (0, _rambdax.anyPass)(elements.map(el => isIncoming(el.id)));
|
|
216
|
-
const excluded = [...ctx.relations].filter(isIncomings);
|
|
217
|
-
if (excluded.length > 0) {
|
|
218
|
-
return ctx.exclude({
|
|
219
|
-
relations: excluded
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return ctx;
|
|
223
|
-
};
|
|
224
|
-
exports.excludeIncomingExpr = excludeIncomingExpr;
|
|
225
|
-
const includeOutgoingExpr = (ctx, expr) => {
|
|
226
|
-
if (_types.Expr.isWildcard(expr.outgoing) && !ctx.root) {
|
|
227
|
-
return ctx;
|
|
228
|
-
}
|
|
229
|
-
const elements = resolveElements(ctx, expr.outgoing);
|
|
230
|
-
if (elements.length === 0) {
|
|
231
|
-
return ctx;
|
|
232
|
-
}
|
|
233
|
-
let allrelations = ctx.index.relations;
|
|
234
|
-
if (_types.Expr.isElementRef(expr.outgoing)) {
|
|
235
|
-
allrelations = allrelations.filter(isOutgoing(expr.outgoing.element));
|
|
236
|
-
}
|
|
237
|
-
const implicits = [];
|
|
238
|
-
const relations = [];
|
|
239
|
-
for (const el of elements) {
|
|
240
|
-
const elRelations = allrelations.filter(isOutgoing(el.id));
|
|
241
|
-
if (elRelations.length > 0) {
|
|
242
|
-
relations.push(...elRelations);
|
|
243
|
-
implicits.push(el);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return ctx.include({
|
|
247
|
-
relations,
|
|
248
|
-
implicits
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
exports.includeOutgoingExpr = includeOutgoingExpr;
|
|
252
|
-
const excludeOutgoingExpr = (ctx, expr) => {
|
|
253
|
-
if (_types.Expr.isWildcard(expr.outgoing) && !ctx.root) {
|
|
254
|
-
return ctx;
|
|
255
|
-
}
|
|
256
|
-
const elements = resolveElements(ctx, expr.outgoing);
|
|
257
|
-
if (elements.length === 0) {
|
|
258
|
-
return ctx;
|
|
259
|
-
}
|
|
260
|
-
const isOutgoings = (0, _rambdax.anyPass)(elements.map(el => isOutgoing(el.id)));
|
|
261
|
-
const excluded = [...ctx.relations].filter(isOutgoings);
|
|
262
|
-
if (excluded.length > 0) {
|
|
263
|
-
return ctx.exclude({
|
|
264
|
-
relations: excluded
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return ctx;
|
|
268
|
-
};
|
|
269
|
-
exports.excludeOutgoingExpr = excludeOutgoingExpr;
|
|
270
|
-
const includeInOutExpr = (ctx, expr) => {
|
|
271
|
-
if (_types.Expr.isWildcard(expr.inout) && !ctx.root) {
|
|
272
|
-
return ctx;
|
|
273
|
-
}
|
|
274
|
-
const targets = resolveElements(ctx, expr.inout);
|
|
275
|
-
if (targets.length === 0) {
|
|
276
|
-
return ctx;
|
|
277
|
-
}
|
|
278
|
-
let allrelations = ctx.index.relations;
|
|
279
|
-
if (_types.Expr.isElementRef(expr.inout)) {
|
|
280
|
-
allrelations = allrelations.filter(isAnyInOut(expr.inout.element));
|
|
281
|
-
}
|
|
282
|
-
const implicits = [];
|
|
283
|
-
const relations = [];
|
|
284
|
-
for (const target of targets) {
|
|
285
|
-
const foundRelations = allrelations.filter(isAnyInOut(target.id));
|
|
286
|
-
if (foundRelations.length > 0) {
|
|
287
|
-
relations.push(...foundRelations);
|
|
288
|
-
implicits.push(target);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return ctx.include({
|
|
292
|
-
relations,
|
|
293
|
-
implicits
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
exports.includeInOutExpr = includeInOutExpr;
|
|
297
|
-
const excludeInOutExpr = (ctx, expr) => {
|
|
298
|
-
if (_types.Expr.isWildcard(expr.inout) && !ctx.root) {
|
|
299
|
-
return ctx;
|
|
300
|
-
}
|
|
301
|
-
const targets = resolveElements(ctx, expr.inout);
|
|
302
|
-
if (targets.length === 0) {
|
|
303
|
-
return ctx;
|
|
304
|
-
}
|
|
305
|
-
const excluded = [...ctx.relations].filter((0, _rambdax.anyPass)(targets.map(t => isAnyInOut(t.id))));
|
|
306
|
-
if (excluded.length > 0) {
|
|
307
|
-
return ctx.exclude({
|
|
308
|
-
relations: excluded
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
return ctx;
|
|
312
|
-
};
|
|
313
|
-
exports.excludeInOutExpr = excludeInOutExpr;
|
|
314
|
-
const includeRelationExpr = (ctx, expr) => {
|
|
315
|
-
const sources = resolveElements(ctx, expr.source);
|
|
316
|
-
const targets = resolveElements(ctx, expr.target);
|
|
317
|
-
if (sources.length === 0 || targets.length === 0) {
|
|
318
|
-
return ctx;
|
|
319
|
-
}
|
|
320
|
-
const implicits = [];
|
|
321
|
-
const relations = [];
|
|
322
|
-
for (const source of sources) {
|
|
323
|
-
for (const target of targets) {
|
|
324
|
-
if ((0, _utils.isSameHierarchy)(source, target)) {
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
const foundRelations = ctx.index.filterRelations(isBetween(source.id, target.id));
|
|
328
|
-
if (foundRelations.length > 0) {
|
|
329
|
-
relations.push(...foundRelations);
|
|
330
|
-
implicits.push(source, target);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return ctx.include({
|
|
335
|
-
relations,
|
|
336
|
-
implicits
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
exports.includeRelationExpr = includeRelationExpr;
|
|
340
|
-
const excludeRelationExpr = (ctx, expr) => {
|
|
341
|
-
const sources = resolveElements(ctx, expr.source);
|
|
342
|
-
const targets = resolveElements(ctx, expr.target);
|
|
343
|
-
const filters = [];
|
|
344
|
-
for (const source of sources) {
|
|
345
|
-
for (const target of targets) {
|
|
346
|
-
if ((0, _utils.isSameHierarchy)(source, target)) {
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
filters.push(isBetween(source.id, target.id));
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (filters.length == 0) {
|
|
353
|
-
return ctx;
|
|
354
|
-
}
|
|
355
|
-
const excluded = [...ctx.relations].filter((0, _rambdax.anyPass)(filters));
|
|
356
|
-
if (excluded.length == 0) {
|
|
357
|
-
return ctx;
|
|
358
|
-
}
|
|
359
|
-
return ctx.exclude({
|
|
360
|
-
relations: excluded
|
|
361
|
-
});
|
|
362
|
-
};
|
|
363
|
-
exports.excludeRelationExpr = excludeRelationExpr;
|
|
@@ -1,14 +0,0 @@
|
|
|
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,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.assignNavigateTo = assignNavigateTo;
|
|
7
|
-
exports.computeView = computeView;
|
|
8
|
-
var _rambdax = require("rambdax");
|
|
9
|
-
var _errors = require("../errors");
|
|
10
|
-
var _computeElementView = require("./compute-element-view");
|
|
11
|
-
function computeView(view, index) {
|
|
12
|
-
try {
|
|
13
|
-
return {
|
|
14
|
-
isSuccess: true,
|
|
15
|
-
view: (0, _computeElementView.computeElementView)(view, index)
|
|
16
|
-
};
|
|
17
|
-
} catch (e) {
|
|
18
|
-
return {
|
|
19
|
-
isSuccess: false,
|
|
20
|
-
error: (0, _errors.normalizeError)(e),
|
|
21
|
-
view: void 0
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function assignNavigateTo(views) {
|
|
26
|
-
const allElementViews = /* @__PURE__ */new Map();
|
|
27
|
-
for (const v of views) {
|
|
28
|
-
if (v.viewOf && !v.extends) {
|
|
29
|
-
const viewsOf = allElementViews.get(v.viewOf) ?? [];
|
|
30
|
-
viewsOf.push(v.id);
|
|
31
|
-
allElementViews.set(v.viewOf, viewsOf);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (const {
|
|
35
|
-
id,
|
|
36
|
-
nodes
|
|
37
|
-
} of views) {
|
|
38
|
-
for (const node of nodes) {
|
|
39
|
-
const navigateTo = (0, _rambdax.find)(v => v !== id, allElementViews.get(node.id) ?? []);
|
|
40
|
-
if (navigateTo) {
|
|
41
|
-
node.navigateTo = navigateTo;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return views;
|
|
46
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _compute = require("./compute");
|
|
7
|
-
Object.keys(_compute).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _compute[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _compute[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _resolveExtendedViews = require("./resolve-extended-views");
|
|
18
|
-
Object.keys(_resolveExtendedViews).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _resolveExtendedViews[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _resolveExtendedViews[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _resolveRelativePaths = require("./resolve-relative-paths");
|
|
29
|
-
Object.keys(_resolveRelativePaths).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _resolveRelativePaths[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _resolveRelativePaths[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _EdgeBuilder = require("./EdgeBuilder");
|
|
40
|
-
Object.keys(_EdgeBuilder).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _EdgeBuilder[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _EdgeBuilder[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|