@likec4/core 0.40.0 → 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/{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/package.json +52 -55
- 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,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
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.resolveRulesExtendedViews = resolveRulesExtendedViews;
|
|
7
|
-
var _graphlib = _interopRequireDefault(require("@dagrejs/graphlib"));
|
|
8
|
-
var _types = require("../types");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const {
|
|
11
|
-
Graph,
|
|
12
|
-
alg
|
|
13
|
-
} = _graphlib.default;
|
|
14
|
-
function resolveRulesExtendedViews(unresolvedViews) {
|
|
15
|
-
const g = new Graph({
|
|
16
|
-
directed: true,
|
|
17
|
-
multigraph: false,
|
|
18
|
-
compound: false
|
|
19
|
-
});
|
|
20
|
-
for (const view of Object.values(unresolvedViews)) {
|
|
21
|
-
g.setNode(view.id);
|
|
22
|
-
if ((0, _types.isExtendsElementView)(view)) {
|
|
23
|
-
g.setEdge(view.id, view.extends);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const cycles = alg.findCycles(g);
|
|
27
|
-
if (cycles.length > 0) {
|
|
28
|
-
cycles.flat().forEach(id => g.removeNode(id));
|
|
29
|
-
}
|
|
30
|
-
const ordered = alg.postorder(g, g.sources());
|
|
31
|
-
return ordered.reduce((acc, id) => {
|
|
32
|
-
const view = unresolvedViews[id];
|
|
33
|
-
if (!view) {
|
|
34
|
-
return acc;
|
|
35
|
-
}
|
|
36
|
-
if ((0, _types.isExtendsElementView)(view)) {
|
|
37
|
-
const extendsFrom = acc[view.extends];
|
|
38
|
-
if (!extendsFrom) {
|
|
39
|
-
return acc;
|
|
40
|
-
}
|
|
41
|
-
return Object.assign(acc, {
|
|
42
|
-
[view.id]: {
|
|
43
|
-
...extendsFrom,
|
|
44
|
-
...view,
|
|
45
|
-
rules: [...extendsFrom.rules, ...view.rules]
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return Object.assign(acc, {
|
|
50
|
-
[view.id]: view
|
|
51
|
-
});
|
|
52
|
-
}, {});
|
|
53
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.resolveRelativePaths = resolveRelativePaths;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _remeda = require("remeda");
|
|
9
|
-
var _errors = require("../errors");
|
|
10
|
-
function commonAncestorPath(views, sep = "/") {
|
|
11
|
-
if (views.length <= 1) return "";
|
|
12
|
-
const uniqURIs = (0, _rambdax.uniq)(views.flatMap(({
|
|
13
|
-
docUri
|
|
14
|
-
}) => docUri ? [docUri] : []));
|
|
15
|
-
if (uniqURIs.length === 0) return "";
|
|
16
|
-
if (uniqURIs.length === 1) {
|
|
17
|
-
(0, _errors.invariant)((0, _remeda.hasAtLeast)(uniqURIs, 1));
|
|
18
|
-
return new URL(uniqURIs[0]).pathname;
|
|
19
|
-
}
|
|
20
|
-
(0, _errors.invariant)((0, _remeda.hasAtLeast)(uniqURIs, 2), "Expected at least 2 unique URIs");
|
|
21
|
-
const [baseUri, ...tail] = uniqURIs;
|
|
22
|
-
const parts = new URL(baseUri).pathname.split(sep);
|
|
23
|
-
let endOfPrefix = parts.length;
|
|
24
|
-
for (const uri of tail) {
|
|
25
|
-
if (uri === baseUri) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const compare = new URL(uri).pathname.split(sep);
|
|
29
|
-
for (let i = 0; i < endOfPrefix; i++) {
|
|
30
|
-
if (compare[i] !== parts[i]) {
|
|
31
|
-
endOfPrefix = i;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (endOfPrefix === 0) return "";
|
|
35
|
-
}
|
|
36
|
-
const prefix = parts.slice(0, endOfPrefix).join(sep);
|
|
37
|
-
return prefix.endsWith(sep) ? prefix : prefix + sep;
|
|
38
|
-
}
|
|
39
|
-
function resolveRelativePaths(views) {
|
|
40
|
-
const commonPrefix = commonAncestorPath(views);
|
|
41
|
-
return views.map(view => {
|
|
42
|
-
if (!view.docUri) {
|
|
43
|
-
return {
|
|
44
|
-
...view,
|
|
45
|
-
parts: []
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
const path = new URL(view.docUri).pathname;
|
|
49
|
-
const parts = path.replace(commonPrefix, "").split("/");
|
|
50
|
-
parts.pop();
|
|
51
|
-
return {
|
|
52
|
-
...view,
|
|
53
|
-
parts
|
|
54
|
-
};
|
|
55
|
-
}).sort((a, b) => {
|
|
56
|
-
if (a.parts.length === b.parts.length) {
|
|
57
|
-
if (a.parts.length === 0) {
|
|
58
|
-
return 0;
|
|
59
|
-
}
|
|
60
|
-
if (a.parts.length === 1 && (0, _remeda.hasAtLeast)(a.parts, 1) && (0, _remeda.hasAtLeast)(b.parts, 1)) {
|
|
61
|
-
return a.parts[0].localeCompare(b.parts[0]);
|
|
62
|
-
}
|
|
63
|
-
for (const [_a, _b] of (0, _rambdax.zip)(a.parts, b.parts)) {
|
|
64
|
-
const compare = _a.localeCompare(_b);
|
|
65
|
-
if (compare !== 0) {
|
|
66
|
-
return compare;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
return a.parts.length - b.parts.length;
|
|
72
|
-
}).map(({
|
|
73
|
-
parts,
|
|
74
|
-
...view
|
|
75
|
-
}) => {
|
|
76
|
-
if (view.docUri) {
|
|
77
|
-
return {
|
|
78
|
-
...view,
|
|
79
|
-
relativePath: parts.join("/")
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return view;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.anyPossibleRelations = anyPossibleRelations;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _utils = require("../../utils");
|
|
9
|
-
function* anyPossibleRelations(elements) {
|
|
10
|
-
const uniqElements = (0, _rambdax.uniqBy)((0, _rambdax.prop)("id"), elements).sort(_utils.compareByFqnHierarchically).reverse();
|
|
11
|
-
for (const source of uniqElements) {
|
|
12
|
-
for (const target of uniqElements) {
|
|
13
|
-
if (source !== target && !(0, _utils.isAncestor)(source, target) && !(0, _utils.isAncestor)(target, source)) {
|
|
14
|
-
yield [source, target];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|