@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,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyViewRuleStyles = applyViewRuleStyles;
|
|
7
|
-
var _rambdax = require("rambdax");
|
|
8
|
-
var _remeda = require("remeda");
|
|
9
|
-
var _errors = require("../../errors");
|
|
10
|
-
var _types = require("../../types");
|
|
11
|
-
function applyViewRuleStyles(rules, _nodes) {
|
|
12
|
-
if (rules.length === 0) {
|
|
13
|
-
return _nodes;
|
|
14
|
-
}
|
|
15
|
-
const nodes = (0, _rambdax.clone)(_nodes);
|
|
16
|
-
for (const rule of rules) {
|
|
17
|
-
const predicates = [];
|
|
18
|
-
if (!rule.style.color && !rule.style.shape) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
for (const target of rule.targets) {
|
|
22
|
-
if (_types.Expr.isWildcard(target)) {
|
|
23
|
-
predicates.push(() => true);
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
if (_types.Expr.isElementKindExpr(target)) {
|
|
27
|
-
predicates.push(target.isEqual ? n => n.kind === target.elementKind : n => n.kind !== target.elementKind);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (_types.Expr.isElementTagExpr(target)) {
|
|
31
|
-
predicates.push(target.isEqual ? ({
|
|
32
|
-
tags
|
|
33
|
-
}) => !!tags && tags.includes(target.elementTag) : ({
|
|
34
|
-
tags
|
|
35
|
-
}) => (0, _rambdax.isNil)(tags) || !tags.includes(target.elementTag));
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (_types.Expr.isElementRef(target)) {
|
|
39
|
-
const {
|
|
40
|
-
element,
|
|
41
|
-
isDescedants
|
|
42
|
-
} = target;
|
|
43
|
-
predicates.push(isDescedants ? n => n.id.startsWith(element + ".") : n => n.id === element);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
(0, _errors.nonexhaustive)(target);
|
|
47
|
-
}
|
|
48
|
-
(0, _rambdax.filter)((0, _rambdax.anyPass)(predicates), nodes).forEach(n => {
|
|
49
|
-
n.shape = rule.style.shape ?? n.shape;
|
|
50
|
-
n.color = rule.style.color ?? n.color;
|
|
51
|
-
if (_remeda.isDefined.strict(rule.style.icon)) {
|
|
52
|
-
n.icon = rule.style.icon;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return nodes;
|
|
57
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ComputedEdge, ComputedNode } from '../../types';
|
|
2
|
-
export declare function sortNodes(_nodes: ComputedNode[], edges: ComputedEdge[]): {
|
|
3
|
-
children: import("../../types").Fqn[];
|
|
4
|
-
id: import("../../types").Fqn;
|
|
5
|
-
kind: import("../../types").ElementKind;
|
|
6
|
-
parent: import("../../types").Fqn | null;
|
|
7
|
-
title: string;
|
|
8
|
-
description: string | null;
|
|
9
|
-
technology: string | null;
|
|
10
|
-
tags: import("../../types").NonEmptyArray<import("../../types").Tag> | null;
|
|
11
|
-
links: import("../../types").NonEmptyArray<string> | null;
|
|
12
|
-
inEdges: import("../../types").EdgeId[];
|
|
13
|
-
outEdges: import("../../types").EdgeId[];
|
|
14
|
-
shape: import("../../types").ElementShape;
|
|
15
|
-
color: import("../../types").ThemeColor;
|
|
16
|
-
icon?: import("../../types").IconUrl | undefined;
|
|
17
|
-
navigateTo?: import("../../types").ViewID | undefined;
|
|
18
|
-
level: number;
|
|
19
|
-
}[];
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sortNodes = sortNodes;
|
|
7
|
-
var _graphlib = _interopRequireDefault(require("@dagrejs/graphlib"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
const {
|
|
10
|
-
Graph,
|
|
11
|
-
alg
|
|
12
|
-
} = _graphlib.default;
|
|
13
|
-
function fillChildren(nodes) {
|
|
14
|
-
return nodes.map(node => ({
|
|
15
|
-
...node,
|
|
16
|
-
children: nodes.flatMap(n => n.parent === node.id ? n.id : [])
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
function sortNodes(_nodes, edges) {
|
|
20
|
-
if (edges.length === 0) {
|
|
21
|
-
return fillChildren(_nodes);
|
|
22
|
-
}
|
|
23
|
-
const g = new Graph({
|
|
24
|
-
compound: true,
|
|
25
|
-
directed: true,
|
|
26
|
-
multigraph: false
|
|
27
|
-
});
|
|
28
|
-
for (const e of edges) {
|
|
29
|
-
g.setEdge(e.source, e.target);
|
|
30
|
-
}
|
|
31
|
-
for (const n of _nodes) {
|
|
32
|
-
g.setNode(n.id);
|
|
33
|
-
if (n.parent) {
|
|
34
|
-
g.setEdge(n.id, n.parent);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const unprocessed = [..._nodes];
|
|
38
|
-
const sorted = [];
|
|
39
|
-
const ordered = alg.postorder(g, g.sources()).reverse();
|
|
40
|
-
for (const id of ordered) {
|
|
41
|
-
const inx = unprocessed.findIndex(n => n.id === id);
|
|
42
|
-
if (inx >= 0) {
|
|
43
|
-
sorted.push(...unprocessed.splice(inx, 1));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return fillChildren(sorted.concat(unprocessed));
|
|
47
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Element, Fqn, Relation, RelationID } from '../types';
|
|
2
|
-
type ModelInput = {
|
|
3
|
-
elements: Record<Fqn, Element>;
|
|
4
|
-
relations: Record<RelationID, Relation>;
|
|
5
|
-
};
|
|
6
|
-
export default class ModelIndex {
|
|
7
|
-
private root;
|
|
8
|
-
private _elements;
|
|
9
|
-
private _relations;
|
|
10
|
-
get relations(): Relation[];
|
|
11
|
-
filterRelations(predicate: (r: Relation) => boolean): Relation[];
|
|
12
|
-
static from({ elements, relations }: ModelInput): ModelIndex;
|
|
13
|
-
addElement(el: Element): void;
|
|
14
|
-
private locateTrie;
|
|
15
|
-
find: (id: Fqn) => Element;
|
|
16
|
-
children: (id: Fqn) => Element[];
|
|
17
|
-
siblings: (id: Fqn) => Element[];
|
|
18
|
-
/**
|
|
19
|
-
* Ancestors from closest parent to root
|
|
20
|
-
*/
|
|
21
|
-
ancestors(id: Fqn): Element[];
|
|
22
|
-
rootElements(): Element[];
|
|
23
|
-
get elements(): Element[];
|
|
24
|
-
hasElement(fqn: Fqn): boolean;
|
|
25
|
-
addRelation(rel: Relation): void;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
module.exports = void 0;
|
|
7
|
-
var _remeda = require("remeda");
|
|
8
|
-
var _errors = require("../errors");
|
|
9
|
-
var _utils = require("../utils");
|
|
10
|
-
function childrenOf(trie) {
|
|
11
|
-
const children = [];
|
|
12
|
-
for (const {
|
|
13
|
-
el
|
|
14
|
-
} of (0, _remeda.values)(trie.children)) {
|
|
15
|
-
if (el) {
|
|
16
|
-
children.push(el);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return children;
|
|
20
|
-
}
|
|
21
|
-
function asPath(id) {
|
|
22
|
-
return id.split(".");
|
|
23
|
-
}
|
|
24
|
-
class ModelIndex {
|
|
25
|
-
root = {
|
|
26
|
-
children: {}
|
|
27
|
-
};
|
|
28
|
-
_elements = /* @__PURE__ */new Map();
|
|
29
|
-
_relations = /* @__PURE__ */new Map();
|
|
30
|
-
// private _taggedElements = new Map<Tag, Set<Element>>()
|
|
31
|
-
// private _taggedRelations = new Map<Tag, Set<Relation>>()
|
|
32
|
-
get relations() {
|
|
33
|
-
return Array.from(this._relations.values());
|
|
34
|
-
}
|
|
35
|
-
filterRelations(predicate) {
|
|
36
|
-
return this.relations.filter(predicate);
|
|
37
|
-
}
|
|
38
|
-
static from({
|
|
39
|
-
elements,
|
|
40
|
-
relations
|
|
41
|
-
}) {
|
|
42
|
-
const index = new ModelIndex();
|
|
43
|
-
for (const el of (0, _remeda.values)(elements)) {
|
|
44
|
-
index.addElement(el);
|
|
45
|
-
}
|
|
46
|
-
for (const rel of (0, _remeda.values)(relations)) {
|
|
47
|
-
index.addRelation(rel);
|
|
48
|
-
}
|
|
49
|
-
return index;
|
|
50
|
-
}
|
|
51
|
-
addElement(el) {
|
|
52
|
-
if (this.hasElement(el.id)) {
|
|
53
|
-
throw new _errors.InvalidModelError(`Element already exists with id ${el.id}`);
|
|
54
|
-
}
|
|
55
|
-
const path = asPath(el.id);
|
|
56
|
-
let scope = this.root;
|
|
57
|
-
for (const name of path) {
|
|
58
|
-
const next = scope.children[name] ?? {
|
|
59
|
-
children: {}
|
|
60
|
-
};
|
|
61
|
-
scope.children[name] = next;
|
|
62
|
-
scope = next;
|
|
63
|
-
}
|
|
64
|
-
scope.el = el;
|
|
65
|
-
this._elements.set(el.id, el);
|
|
66
|
-
}
|
|
67
|
-
locateTrie = id => {
|
|
68
|
-
let scope = this.root;
|
|
69
|
-
for (const name of asPath(id)) {
|
|
70
|
-
const next = scope.children[name];
|
|
71
|
-
(0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
72
|
-
scope = next;
|
|
73
|
-
}
|
|
74
|
-
return scope;
|
|
75
|
-
};
|
|
76
|
-
find = id => {
|
|
77
|
-
const el = this._elements.get(id);
|
|
78
|
-
(0, _errors.ensureModel)(el, `Element not found with id ${id}`);
|
|
79
|
-
return el;
|
|
80
|
-
};
|
|
81
|
-
children = id => {
|
|
82
|
-
return childrenOf(this.locateTrie(id));
|
|
83
|
-
};
|
|
84
|
-
siblings = id => {
|
|
85
|
-
const parent = (0, _utils.parentFqn)(id);
|
|
86
|
-
const trie = parent ? this.locateTrie(parent) : this.root;
|
|
87
|
-
return childrenOf(trie).filter(e => e.id !== id);
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Ancestors from closest parent to root
|
|
91
|
-
*/
|
|
92
|
-
ancestors(id) {
|
|
93
|
-
const path = asPath(id);
|
|
94
|
-
const ancestors = [];
|
|
95
|
-
if (path.length === 1) {
|
|
96
|
-
return ancestors;
|
|
97
|
-
}
|
|
98
|
-
path.pop();
|
|
99
|
-
let name = path.shift();
|
|
100
|
-
let trie = this.root;
|
|
101
|
-
while (name) {
|
|
102
|
-
const next = trie.children[name];
|
|
103
|
-
(0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
104
|
-
trie = next;
|
|
105
|
-
(0, _errors.ensureModel)(trie.el, `invalid index, no element ${name} found in ${id}`);
|
|
106
|
-
ancestors.unshift(trie.el);
|
|
107
|
-
name = path.shift();
|
|
108
|
-
}
|
|
109
|
-
return ancestors;
|
|
110
|
-
}
|
|
111
|
-
// tagged = (tag?: Tag): TaggedResult => {
|
|
112
|
-
// return tag ? {
|
|
113
|
-
// elements: [...this._taggedElements.get(tag)?.values() ?? []],
|
|
114
|
-
// relations: [...this._taggedRelations.get(tag)?.values() ?? []],
|
|
115
|
-
// } : {
|
|
116
|
-
// elements: uniq([...this._taggedElements.values()].flatMap(s => [...s.values()])),
|
|
117
|
-
// relations: uniq([...this._taggedRelations.values()].flatMap(s => [...s.values()]))
|
|
118
|
-
// }
|
|
119
|
-
// }
|
|
120
|
-
rootElements() {
|
|
121
|
-
return childrenOf(this.root);
|
|
122
|
-
}
|
|
123
|
-
get elements() {
|
|
124
|
-
return Array.from(this._elements.values());
|
|
125
|
-
}
|
|
126
|
-
hasElement(fqn) {
|
|
127
|
-
return this._elements.has(fqn);
|
|
128
|
-
}
|
|
129
|
-
addRelation(rel) {
|
|
130
|
-
if (!this.hasElement(rel.source)) {
|
|
131
|
-
throw new _errors.InvalidModelError(`Source of relation not found ${rel.source}`);
|
|
132
|
-
}
|
|
133
|
-
if (!this.hasElement(rel.target)) {
|
|
134
|
-
throw new _errors.InvalidModelError(`Target of relation not found ${rel.target}`);
|
|
135
|
-
}
|
|
136
|
-
this._relations.set(rel.id, rel);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
module.exports = ModelIndex;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ModelIndex } from './ModelIndex';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "ModelIndex", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _ModelIndex.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _ModelIndex = _interopRequireDefault(require("./ModelIndex"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.computeNodeLevels = void 0;
|
|
7
|
-
var _errors = require("../errors");
|
|
8
|
-
const computeNodeLevels = ({
|
|
9
|
-
nodes
|
|
10
|
-
}) => {
|
|
11
|
-
const nodeLevels = {};
|
|
12
|
-
const compute = (node, level) => {
|
|
13
|
-
let levels = nodeLevels[node.id];
|
|
14
|
-
if (levels) {
|
|
15
|
-
return levels;
|
|
16
|
-
}
|
|
17
|
-
if (node.children.length === 0) {
|
|
18
|
-
levels = {
|
|
19
|
-
level,
|
|
20
|
-
depth: 0
|
|
21
|
-
};
|
|
22
|
-
nodeLevels[node.id] = levels;
|
|
23
|
-
return levels;
|
|
24
|
-
}
|
|
25
|
-
let depth = 1;
|
|
26
|
-
for (const childId of node.children) {
|
|
27
|
-
const child = nodes.find(n => n.id === childId);
|
|
28
|
-
(0, _errors.invariant)(child, `Child ${childId} not found`);
|
|
29
|
-
const {
|
|
30
|
-
depth: childDepth
|
|
31
|
-
} = compute(child, level + 1);
|
|
32
|
-
depth = Math.max(childDepth + 1, depth);
|
|
33
|
-
}
|
|
34
|
-
levels = {
|
|
35
|
-
level,
|
|
36
|
-
depth
|
|
37
|
-
};
|
|
38
|
-
nodeLevels[node.id] = levels;
|
|
39
|
-
return levels;
|
|
40
|
-
};
|
|
41
|
-
for (const node of nodes) {
|
|
42
|
-
if (!node.parent) {
|
|
43
|
-
compute(node, 0);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return nodeLevels;
|
|
47
|
-
};
|
|
48
|
-
exports.computeNodeLevels = computeNodeLevels;
|
package/dist/esm/colors.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
export declare const RelationColors: {
|
|
2
|
-
readonly lineColor: "#b1b1b1";
|
|
3
|
-
readonly labelColor: "#b1b1b1";
|
|
4
|
-
};
|
|
5
|
-
export declare const Colors: {
|
|
6
|
-
readonly primary: {
|
|
7
|
-
fill: "#3b82f6";
|
|
8
|
-
stroke: "#2563eb";
|
|
9
|
-
hiContrast: "#eff6ff";
|
|
10
|
-
loContrast: "#bfdbfe";
|
|
11
|
-
};
|
|
12
|
-
readonly blue: {
|
|
13
|
-
fill: "#3b82f6";
|
|
14
|
-
stroke: "#2563eb";
|
|
15
|
-
hiContrast: "#eff6ff";
|
|
16
|
-
loContrast: "#bfdbfe";
|
|
17
|
-
};
|
|
18
|
-
readonly secondary: {
|
|
19
|
-
fill: "#0284c7";
|
|
20
|
-
stroke: "#0369a1";
|
|
21
|
-
hiContrast: "#f0f9ff";
|
|
22
|
-
loContrast: "#e0f2fe";
|
|
23
|
-
};
|
|
24
|
-
readonly sky: {
|
|
25
|
-
fill: "#0284c7";
|
|
26
|
-
stroke: "#0369a1";
|
|
27
|
-
hiContrast: "#f0f9ff";
|
|
28
|
-
loContrast: "#e0f2fe";
|
|
29
|
-
};
|
|
30
|
-
readonly muted: {
|
|
31
|
-
fill: "#64748b";
|
|
32
|
-
stroke: "#475569";
|
|
33
|
-
hiContrast: "#f8fafc";
|
|
34
|
-
loContrast: "#e2e8f0";
|
|
35
|
-
};
|
|
36
|
-
readonly slate: {
|
|
37
|
-
fill: "#64748b";
|
|
38
|
-
stroke: "#475569";
|
|
39
|
-
hiContrast: "#f8fafc";
|
|
40
|
-
loContrast: "#e2e8f0";
|
|
41
|
-
};
|
|
42
|
-
readonly gray: {
|
|
43
|
-
readonly fill: "#737373";
|
|
44
|
-
readonly stroke: "#525252";
|
|
45
|
-
readonly hiContrast: "#fafafa";
|
|
46
|
-
readonly loContrast: "#e5e5e5";
|
|
47
|
-
};
|
|
48
|
-
readonly red: {
|
|
49
|
-
readonly fill: "#b54548";
|
|
50
|
-
readonly stroke: "#8c333a";
|
|
51
|
-
readonly hiContrast: "#f8fafc";
|
|
52
|
-
readonly loContrast: "#F9C6C6";
|
|
53
|
-
};
|
|
54
|
-
readonly green: {
|
|
55
|
-
readonly fill: "#428a4f";
|
|
56
|
-
readonly stroke: "#2d5d39";
|
|
57
|
-
readonly hiContrast: "#f8fafc";
|
|
58
|
-
readonly loContrast: "#c2f0c2";
|
|
59
|
-
};
|
|
60
|
-
readonly amber: {
|
|
61
|
-
readonly fill: "#d97706";
|
|
62
|
-
readonly stroke: "#b45309";
|
|
63
|
-
readonly hiContrast: "#f8fafc";
|
|
64
|
-
readonly loContrast: "#ffe0c2";
|
|
65
|
-
};
|
|
66
|
-
readonly indigo: {
|
|
67
|
-
readonly fill: "#6366f1";
|
|
68
|
-
readonly stroke: "#4f46e5";
|
|
69
|
-
readonly hiContrast: "#eef2ff";
|
|
70
|
-
readonly loContrast: "#c7d2fe";
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export declare const defaultTheme: {
|
|
74
|
-
readonly font: "Helvetica";
|
|
75
|
-
readonly shadow: "#0a0a0a";
|
|
76
|
-
readonly relation: {
|
|
77
|
-
readonly lineColor: "#b1b1b1";
|
|
78
|
-
readonly labelColor: "#b1b1b1";
|
|
79
|
-
};
|
|
80
|
-
readonly colors: {
|
|
81
|
-
readonly primary: {
|
|
82
|
-
fill: "#3b82f6";
|
|
83
|
-
stroke: "#2563eb";
|
|
84
|
-
hiContrast: "#eff6ff";
|
|
85
|
-
loContrast: "#bfdbfe";
|
|
86
|
-
};
|
|
87
|
-
readonly blue: {
|
|
88
|
-
fill: "#3b82f6";
|
|
89
|
-
stroke: "#2563eb";
|
|
90
|
-
hiContrast: "#eff6ff";
|
|
91
|
-
loContrast: "#bfdbfe";
|
|
92
|
-
};
|
|
93
|
-
readonly secondary: {
|
|
94
|
-
fill: "#0284c7";
|
|
95
|
-
stroke: "#0369a1";
|
|
96
|
-
hiContrast: "#f0f9ff";
|
|
97
|
-
loContrast: "#e0f2fe";
|
|
98
|
-
};
|
|
99
|
-
readonly sky: {
|
|
100
|
-
fill: "#0284c7";
|
|
101
|
-
stroke: "#0369a1";
|
|
102
|
-
hiContrast: "#f0f9ff";
|
|
103
|
-
loContrast: "#e0f2fe";
|
|
104
|
-
};
|
|
105
|
-
readonly muted: {
|
|
106
|
-
fill: "#64748b";
|
|
107
|
-
stroke: "#475569";
|
|
108
|
-
hiContrast: "#f8fafc";
|
|
109
|
-
loContrast: "#e2e8f0";
|
|
110
|
-
};
|
|
111
|
-
readonly slate: {
|
|
112
|
-
fill: "#64748b";
|
|
113
|
-
stroke: "#475569";
|
|
114
|
-
hiContrast: "#f8fafc";
|
|
115
|
-
loContrast: "#e2e8f0";
|
|
116
|
-
};
|
|
117
|
-
readonly gray: {
|
|
118
|
-
readonly fill: "#737373";
|
|
119
|
-
readonly stroke: "#525252";
|
|
120
|
-
readonly hiContrast: "#fafafa";
|
|
121
|
-
readonly loContrast: "#e5e5e5";
|
|
122
|
-
};
|
|
123
|
-
readonly red: {
|
|
124
|
-
readonly fill: "#b54548";
|
|
125
|
-
readonly stroke: "#8c333a";
|
|
126
|
-
readonly hiContrast: "#f8fafc";
|
|
127
|
-
readonly loContrast: "#F9C6C6";
|
|
128
|
-
};
|
|
129
|
-
readonly green: {
|
|
130
|
-
readonly fill: "#428a4f";
|
|
131
|
-
readonly stroke: "#2d5d39";
|
|
132
|
-
readonly hiContrast: "#f8fafc";
|
|
133
|
-
readonly loContrast: "#c2f0c2";
|
|
134
|
-
};
|
|
135
|
-
readonly amber: {
|
|
136
|
-
readonly fill: "#d97706";
|
|
137
|
-
readonly stroke: "#b45309";
|
|
138
|
-
readonly hiContrast: "#f8fafc";
|
|
139
|
-
readonly loContrast: "#ffe0c2";
|
|
140
|
-
};
|
|
141
|
-
readonly indigo: {
|
|
142
|
-
readonly fill: "#6366f1";
|
|
143
|
-
readonly stroke: "#4f46e5";
|
|
144
|
-
readonly hiContrast: "#eef2ff";
|
|
145
|
-
readonly loContrast: "#c7d2fe";
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
};
|
|
@@ -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,20 +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: ReadonlySet<Element>;
|
|
12
|
-
relations: ReadonlySet<Relation>;
|
|
13
|
-
implicits: ReadonlySet<Element>;
|
|
14
|
-
readonly allElements: ReadonlySet<Element>;
|
|
15
|
-
constructor(index: ModelIndex, root: Fqn | null, elements?: ReadonlySet<Element>, relations?: ReadonlySet<Relation>, implicits?: ReadonlySet<Element>);
|
|
16
|
-
include({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
17
|
-
exclude({ elements, relations, implicits }: ComputeCtxPatch): ComputeCtx;
|
|
18
|
-
processViewRules(viewRules: ViewRuleExpression[]): ComputeCtx;
|
|
19
|
-
static create(view: ElementView, index: ModelIndex): ComputeCtx;
|
|
20
|
-
}
|
|
@@ -1,100 +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
|
-
this.allElements = /* @__PURE__ */ new Set([...this.elements, ...this.implicits]);
|
|
28
|
-
}
|
|
29
|
-
allElements;
|
|
30
|
-
include({ elements, relations, implicits }) {
|
|
31
|
-
return new ComputeCtx(
|
|
32
|
-
this.index,
|
|
33
|
-
this.root,
|
|
34
|
-
elements ? /* @__PURE__ */ new Set([...this.elements, ...elements]) : this.elements,
|
|
35
|
-
relations ? /* @__PURE__ */ new Set([...this.relations, ...relations]) : this.relations,
|
|
36
|
-
implicits ? /* @__PURE__ */ new Set([...this.implicits, ...implicits]) : this.implicits
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
exclude({ elements, relations, implicits }) {
|
|
40
|
-
let newImplicits = implicits ? new Set(difference([...this.implicits], implicits)) : this.implicits;
|
|
41
|
-
if (elements) {
|
|
42
|
-
newImplicits = new Set(difference([...newImplicits], elements));
|
|
43
|
-
}
|
|
44
|
-
return new ComputeCtx(
|
|
45
|
-
this.index,
|
|
46
|
-
this.root,
|
|
47
|
-
elements ? new Set(difference([...this.elements], elements)) : this.elements,
|
|
48
|
-
relations ? new Set(difference([...this.relations], relations)) : this.relations,
|
|
49
|
-
newImplicits
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
processViewRules(viewRules) {
|
|
53
|
-
let ctx = this;
|
|
54
|
-
for (const { isInclude, exprs } of viewRules) {
|
|
55
|
-
for (const expr of exprs) {
|
|
56
|
-
if (Expr.isElementKindExpr(expr) || Expr.isElementTagExpr(expr)) {
|
|
57
|
-
ctx = isInclude ? includeElementKindOrTag(ctx, expr) : excludeElementKindOrTag(ctx, expr);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (Expr.isElementRef(expr)) {
|
|
61
|
-
ctx = isInclude ? includeElementRef(ctx, expr) : excludeElementRef(ctx, expr);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (Expr.isWildcard(expr)) {
|
|
65
|
-
ctx = isInclude ? includeWildcardRef(ctx, expr) : excludeWildcardRef(ctx, expr);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (Expr.isIncoming(expr)) {
|
|
69
|
-
ctx = isInclude ? includeIncomingExpr(ctx, expr) : excludeIncomingExpr(ctx, expr);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (Expr.isOutgoing(expr)) {
|
|
73
|
-
ctx = isInclude ? includeOutgoingExpr(ctx, expr) : excludeOutgoingExpr(ctx, expr);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (Expr.isInOut(expr)) {
|
|
77
|
-
ctx = isInclude ? includeInOutExpr(ctx, expr) : excludeInOutExpr(ctx, expr);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (Expr.isRelation(expr)) {
|
|
81
|
-
ctx = isInclude ? includeRelationExpr(ctx, expr) : excludeRelationExpr(ctx, expr);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
nonexhaustive(expr);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return ctx;
|
|
88
|
-
}
|
|
89
|
-
static create(view, index) {
|
|
90
|
-
const rootElement = isStrictElementView(view) ? view.viewOf : null;
|
|
91
|
-
let ctx = new ComputeCtx(index, rootElement);
|
|
92
|
-
const rulesInclude = view.rules.filter(isViewRuleExpression);
|
|
93
|
-
if (rootElement && rulesInclude.length == 0) {
|
|
94
|
-
ctx = ctx.include({
|
|
95
|
-
elements: [index.find(rootElement)]
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return ctx.processViewRules(rulesInclude);
|
|
99
|
-
}
|
|
100
|
-
}
|