@likec4/core 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/colors.d.ts +76 -9
- package/dist/colors.js +116 -93
- package/dist/colors.mjs +112 -0
- package/dist/compute-view/EdgeBuilder.d.ts +0 -1
- package/dist/compute-view/EdgeBuilder.js +37 -34
- package/dist/compute-view/EdgeBuilder.mjs +31 -0
- package/dist/compute-view/compute-ctx.d.ts +0 -1
- package/dist/compute-view/compute-ctx.js +33 -24
- package/dist/compute-view/compute-ctx.mjs +42 -0
- package/dist/compute-view/compute-element-view.d.ts +2 -3
- package/dist/compute-view/compute-element-view.js +137 -525
- package/dist/compute-view/compute-element-view.mjs +145 -0
- package/dist/compute-view/compute-predicates.d.ts +16 -0
- package/dist/compute-view/compute-predicates.js +358 -0
- package/dist/compute-view/compute-predicates.mjs +324 -0
- package/dist/compute-view/compute.d.ts +8 -9
- package/dist/compute-view/compute.js +49 -39
- package/dist/compute-view/compute.mjs +39 -0
- package/dist/compute-view/index.d.ts +1 -1
- package/dist/compute-view/index.js +24 -2
- package/dist/compute-view/index.mjs +1 -0
- package/dist/compute-view/utils/anyPossibleRelations.d.ts +0 -1
- package/dist/compute-view/utils/anyPossibleRelations.js +17 -12
- package/dist/compute-view/utils/anyPossibleRelations.mjs +12 -0
- package/dist/compute-view/utils/applyViewRuleStyles.d.ts +3 -0
- package/dist/compute-view/utils/applyViewRuleStyles.js +59 -0
- package/dist/compute-view/utils/applyViewRuleStyles.mjs +50 -0
- package/dist/compute-view/utils/sortNodes.d.ts +0 -1
- package/dist/compute-view/utils/sortNodes.js +47 -42
- package/dist/compute-view/utils/sortNodes.mjs +40 -0
- package/dist/errors/_base.d.ts +0 -1
- package/dist/errors/_base.js +14 -11
- package/dist/errors/_base.mjs +4 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +60 -5
- package/dist/errors/index.mjs +5 -0
- package/dist/errors/invariant.d.ts +0 -2
- package/dist/errors/invariant.js +16 -21
- package/dist/errors/invariant.mjs +8 -0
- package/dist/errors/model-index.d.ts +0 -1
- package/dist/errors/model-index.js +16 -14
- package/dist/errors/model-index.mjs +8 -0
- package/dist/errors/non-nullable.d.ts +2 -0
- package/dist/errors/non-nullable.js +16 -0
- package/dist/errors/non-nullable.mjs +8 -0
- package/dist/errors/nonexhaustive.d.ts +0 -1
- package/dist/errors/nonexhaustive.js +13 -6
- package/dist/errors/nonexhaustive.mjs +5 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +71 -7
- package/dist/index.mjs +6 -0
- package/dist/model-index/ModelIndex.d.ts +0 -1
- package/dist/model-index/ModelIndex.js +125 -122
- package/dist/model-index/ModelIndex.mjs +128 -0
- package/dist/model-index/index.d.ts +0 -1
- package/dist/model-index/index.js +13 -2
- package/dist/model-index/index.mjs +1 -0
- package/dist/types/_common.d.ts +0 -1
- package/dist/types/_common.js +1 -2
- package/dist/types/_common.mjs +0 -0
- package/dist/types/computed-view.d.ts +7 -6
- package/dist/types/computed-view.js +1 -2
- package/dist/types/computed-view.mjs +0 -0
- package/dist/types/diagram.d.ts +5 -2
- package/dist/types/diagram.js +1 -2
- package/dist/types/diagram.mjs +0 -0
- package/dist/types/element.d.ts +3 -7
- package/dist/types/element.js +13 -5
- package/dist/types/element.mjs +5 -0
- package/dist/types/expression.d.ts +0 -1
- package/dist/types/expression.js +45 -31
- package/dist/types/expression.mjs +30 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +48 -4
- package/dist/types/index.mjs +3 -0
- package/dist/types/model.d.ts +0 -1
- package/dist/types/model.js +1 -2
- package/dist/types/model.mjs +0 -0
- package/dist/types/opaque.d.ts +0 -1
- package/dist/types/opaque.js +1 -2
- package/dist/types/opaque.mjs +0 -0
- package/dist/types/relation.d.ts +0 -1
- package/dist/types/relation.js +1 -2
- package/dist/types/relation.mjs +0 -0
- package/dist/types/theme.d.ts +22 -0
- package/dist/types/theme.js +1 -0
- package/dist/types/theme.mjs +0 -0
- package/dist/types/view.d.ts +2 -2
- package/dist/types/view.js +15 -8
- package/dist/types/view.mjs +9 -0
- package/dist/utils/compute-node-levels.d.ts +0 -1
- package/dist/utils/compute-node-levels.js +45 -29
- package/dist/utils/compute-node-levels.mjs +31 -0
- package/dist/utils/fqn.d.ts +0 -1
- package/dist/utils/fqn.js +71 -71
- package/dist/utils/fqn.mjs +66 -0
- package/dist/utils/guards.d.ts +0 -1
- package/dist/utils/guards.js +19 -12
- package/dist/utils/guards.mjs +13 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +49 -5
- package/dist/utils/index.mjs +4 -0
- package/dist/utils/relations.d.ts +0 -1
- package/dist/utils/relations.js +56 -49
- package/dist/utils/relations.mjs +42 -0
- package/package.json +20 -55
|
@@ -1,137 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 _fqn = require("../utils/fqn");
|
|
4
10
|
function childrenOf(trie) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const children = [];
|
|
12
|
+
for (const {
|
|
13
|
+
el
|
|
14
|
+
} of (0, _remeda.values)(trie.children)) {
|
|
15
|
+
if (el) {
|
|
16
|
+
children.push(el);
|
|
10
17
|
}
|
|
11
|
-
|
|
18
|
+
}
|
|
19
|
+
return children;
|
|
12
20
|
}
|
|
13
21
|
function asPath(id) {
|
|
14
|
-
|
|
22
|
+
return id.split(".");
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
const sortedElements = (0, _remeda.pipe)((0, _remeda.values)(elements), (0, _remeda.sort)(_fqn.compareByFqnHierarchically));
|
|
44
|
+
for (const el of sortedElements) {
|
|
45
|
+
index.addElement(el);
|
|
26
46
|
}
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
for (const rel of (0, _remeda.values)(relations)) {
|
|
48
|
+
index.addRelation(rel);
|
|
29
49
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
for (const rel of values(relations)) {
|
|
37
|
-
index.addRelation(rel);
|
|
38
|
-
}
|
|
39
|
-
return index;
|
|
50
|
+
return index;
|
|
51
|
+
}
|
|
52
|
+
addElement(el) {
|
|
53
|
+
if (this.hasElement(el.id)) {
|
|
54
|
+
throw new _errors.InvalidModelError(`Element already exists with id ${el.id}`);
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
children: {}
|
|
50
|
-
};
|
|
51
|
-
scope.children[name] = next;
|
|
52
|
-
scope = next;
|
|
53
|
-
}
|
|
54
|
-
scope.el = el;
|
|
55
|
-
this._elements.set(el.id, el);
|
|
56
|
+
const path = asPath(el.id);
|
|
57
|
+
let scope = this.root;
|
|
58
|
+
for (const name of path) {
|
|
59
|
+
const next = scope.children[name] ?? {
|
|
60
|
+
children: {}
|
|
61
|
+
};
|
|
62
|
+
scope.children[name] = next;
|
|
63
|
+
scope = next;
|
|
56
64
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
find = (id) => {
|
|
67
|
-
const el = this._elements.get(id);
|
|
68
|
-
ensureModel(el, `Element not found with id ${id}`);
|
|
69
|
-
return el;
|
|
70
|
-
};
|
|
71
|
-
children = (id) => {
|
|
72
|
-
return childrenOf(this.locateTrie(id));
|
|
73
|
-
};
|
|
74
|
-
siblings = (id) => {
|
|
75
|
-
const parent = parentFqn(id);
|
|
76
|
-
const trie = parent ? this.locateTrie(parent) : this.root;
|
|
77
|
-
return childrenOf(trie).filter(e => e.id !== id);
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Ancestors from closest parent to root
|
|
81
|
-
*/
|
|
82
|
-
ancestors(id) {
|
|
83
|
-
const path = asPath(id);
|
|
84
|
-
const ancestors = [];
|
|
85
|
-
// The root
|
|
86
|
-
if (path.length === 1) {
|
|
87
|
-
return ancestors;
|
|
88
|
-
}
|
|
89
|
-
// Remove the element itself
|
|
90
|
-
path.pop();
|
|
91
|
-
let name = path.shift();
|
|
92
|
-
let trie = this.root;
|
|
93
|
-
while (name) {
|
|
94
|
-
const next = trie.children[name];
|
|
95
|
-
ensureModel(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
96
|
-
trie = next;
|
|
97
|
-
ensureModel(trie.el, `invalid index, no element ${name} found in ${id}`);
|
|
98
|
-
ancestors.unshift(trie.el);
|
|
99
|
-
name = path.shift();
|
|
100
|
-
}
|
|
101
|
-
return ancestors;
|
|
65
|
+
scope.el = el;
|
|
66
|
+
this._elements.set(el.id, el);
|
|
67
|
+
}
|
|
68
|
+
locateTrie = id => {
|
|
69
|
+
let scope = this.root;
|
|
70
|
+
for (const name of asPath(id)) {
|
|
71
|
+
const next = scope.children[name];
|
|
72
|
+
(0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
73
|
+
scope = next;
|
|
102
74
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
75
|
+
return scope;
|
|
76
|
+
};
|
|
77
|
+
find = id => {
|
|
78
|
+
const el = this._elements.get(id);
|
|
79
|
+
(0, _errors.ensureModel)(el, `Element not found with id ${id}`);
|
|
80
|
+
return el;
|
|
81
|
+
};
|
|
82
|
+
children = id => {
|
|
83
|
+
return childrenOf(this.locateTrie(id));
|
|
84
|
+
};
|
|
85
|
+
siblings = id => {
|
|
86
|
+
const parent = (0, _fqn.parentFqn)(id);
|
|
87
|
+
const trie = parent ? this.locateTrie(parent) : this.root;
|
|
88
|
+
return childrenOf(trie).filter(e => e.id !== id);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Ancestors from closest parent to root
|
|
92
|
+
*/
|
|
93
|
+
ancestors(id) {
|
|
94
|
+
const path = asPath(id);
|
|
95
|
+
const ancestors = [];
|
|
96
|
+
if (path.length === 1) {
|
|
97
|
+
return ancestors;
|
|
114
98
|
}
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
path.pop();
|
|
100
|
+
let name = path.shift();
|
|
101
|
+
let trie = this.root;
|
|
102
|
+
while (name) {
|
|
103
|
+
const next = trie.children[name];
|
|
104
|
+
(0, _errors.ensureModel)(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
105
|
+
trie = next;
|
|
106
|
+
(0, _errors.ensureModel)(trie.el, `invalid index, no element ${name} found in ${id}`);
|
|
107
|
+
ancestors.unshift(trie.el);
|
|
108
|
+
name = path.shift();
|
|
117
109
|
}
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
return ancestors;
|
|
111
|
+
}
|
|
112
|
+
// tagged = (tag?: Tag): TaggedResult => {
|
|
113
|
+
// return tag ? {
|
|
114
|
+
// elements: [...this._taggedElements.get(tag)?.values() ?? []],
|
|
115
|
+
// relations: [...this._taggedRelations.get(tag)?.values() ?? []],
|
|
116
|
+
// } : {
|
|
117
|
+
// elements: uniq([...this._taggedElements.values()].flatMap(s => [...s.values()])),
|
|
118
|
+
// relations: uniq([...this._taggedRelations.values()].flatMap(s => [...s.values()]))
|
|
119
|
+
// }
|
|
120
|
+
// }
|
|
121
|
+
rootElements() {
|
|
122
|
+
return childrenOf(this.root);
|
|
123
|
+
}
|
|
124
|
+
get elements() {
|
|
125
|
+
return Array.from(this._elements.values());
|
|
126
|
+
}
|
|
127
|
+
hasElement(fqn) {
|
|
128
|
+
return this._elements.has(fqn);
|
|
129
|
+
}
|
|
130
|
+
addRelation(rel) {
|
|
131
|
+
if (!this.hasElement(rel.source)) {
|
|
132
|
+
throw new _errors.InvalidModelError(`Source of relation not found ${rel.source}`);
|
|
120
133
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!this.hasElement(rel.source)) {
|
|
124
|
-
throw new InvalidModelError(`Source of relation not found ${rel.source}`);
|
|
125
|
-
}
|
|
126
|
-
if (!this.hasElement(rel.target)) {
|
|
127
|
-
throw new InvalidModelError(`Target of relation not found ${rel.target}`);
|
|
128
|
-
}
|
|
129
|
-
this._relations.set(rel.id, rel);
|
|
130
|
-
// for (const tag of rel.tags) {
|
|
131
|
-
// const tagged = this._taggedRelations.get(tag) ?? new Set()
|
|
132
|
-
// tagged.add(rel)
|
|
133
|
-
// this._taggedRelations.set(tag, tagged)
|
|
134
|
-
// }
|
|
134
|
+
if (!this.hasElement(rel.target)) {
|
|
135
|
+
throw new _errors.InvalidModelError(`Target of relation not found ${rel.target}`);
|
|
135
136
|
}
|
|
137
|
+
this._relations.set(rel.id, rel);
|
|
138
|
+
}
|
|
136
139
|
}
|
|
137
|
-
|
|
140
|
+
module.exports = ModelIndex;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { pipe, sort, values } from "remeda";
|
|
2
|
+
import { InvalidModelError, ensureModel } from "../errors/index.mjs";
|
|
3
|
+
import { compareByFqnHierarchically, parentFqn } from "../utils/fqn.mjs";
|
|
4
|
+
function childrenOf(trie) {
|
|
5
|
+
const children = [];
|
|
6
|
+
for (const { el } of values(trie.children)) {
|
|
7
|
+
if (el) {
|
|
8
|
+
children.push(el);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return children;
|
|
12
|
+
}
|
|
13
|
+
function asPath(id) {
|
|
14
|
+
return id.split(".");
|
|
15
|
+
}
|
|
16
|
+
export default class ModelIndex {
|
|
17
|
+
root = {
|
|
18
|
+
children: {}
|
|
19
|
+
};
|
|
20
|
+
_elements = /* @__PURE__ */ new Map();
|
|
21
|
+
_relations = /* @__PURE__ */ new Map();
|
|
22
|
+
// private _taggedElements = new Map<Tag, Set<Element>>()
|
|
23
|
+
// private _taggedRelations = new Map<Tag, Set<Relation>>()
|
|
24
|
+
get relations() {
|
|
25
|
+
return Array.from(this._relations.values());
|
|
26
|
+
}
|
|
27
|
+
filterRelations(predicate) {
|
|
28
|
+
return this.relations.filter(predicate);
|
|
29
|
+
}
|
|
30
|
+
static from({ elements, relations }) {
|
|
31
|
+
const index = new ModelIndex();
|
|
32
|
+
const sortedElements = pipe(values(elements), sort(compareByFqnHierarchically));
|
|
33
|
+
for (const el of sortedElements) {
|
|
34
|
+
index.addElement(el);
|
|
35
|
+
}
|
|
36
|
+
for (const rel of values(relations)) {
|
|
37
|
+
index.addRelation(rel);
|
|
38
|
+
}
|
|
39
|
+
return index;
|
|
40
|
+
}
|
|
41
|
+
addElement(el) {
|
|
42
|
+
if (this.hasElement(el.id)) {
|
|
43
|
+
throw new InvalidModelError(`Element already exists with id ${el.id}`);
|
|
44
|
+
}
|
|
45
|
+
const path = asPath(el.id);
|
|
46
|
+
let scope = this.root;
|
|
47
|
+
for (const name of path) {
|
|
48
|
+
const next = scope.children[name] ?? {
|
|
49
|
+
children: {}
|
|
50
|
+
};
|
|
51
|
+
scope.children[name] = next;
|
|
52
|
+
scope = next;
|
|
53
|
+
}
|
|
54
|
+
scope.el = el;
|
|
55
|
+
this._elements.set(el.id, el);
|
|
56
|
+
}
|
|
57
|
+
locateTrie = (id) => {
|
|
58
|
+
let scope = this.root;
|
|
59
|
+
for (const name of asPath(id)) {
|
|
60
|
+
const next = scope.children[name];
|
|
61
|
+
ensureModel(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
62
|
+
scope = next;
|
|
63
|
+
}
|
|
64
|
+
return scope;
|
|
65
|
+
};
|
|
66
|
+
find = (id) => {
|
|
67
|
+
const el = this._elements.get(id);
|
|
68
|
+
ensureModel(el, `Element not found with id ${id}`);
|
|
69
|
+
return el;
|
|
70
|
+
};
|
|
71
|
+
children = (id) => {
|
|
72
|
+
return childrenOf(this.locateTrie(id));
|
|
73
|
+
};
|
|
74
|
+
siblings = (id) => {
|
|
75
|
+
const parent = parentFqn(id);
|
|
76
|
+
const trie = parent ? this.locateTrie(parent) : this.root;
|
|
77
|
+
return childrenOf(trie).filter((e) => e.id !== id);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Ancestors from closest parent to root
|
|
81
|
+
*/
|
|
82
|
+
ancestors(id) {
|
|
83
|
+
const path = asPath(id);
|
|
84
|
+
const ancestors = [];
|
|
85
|
+
if (path.length === 1) {
|
|
86
|
+
return ancestors;
|
|
87
|
+
}
|
|
88
|
+
path.pop();
|
|
89
|
+
let name = path.shift();
|
|
90
|
+
let trie = this.root;
|
|
91
|
+
while (name) {
|
|
92
|
+
const next = trie.children[name];
|
|
93
|
+
ensureModel(next, `Invalid index, Element not found at path ${name} of ${id}`);
|
|
94
|
+
trie = next;
|
|
95
|
+
ensureModel(trie.el, `invalid index, no element ${name} found in ${id}`);
|
|
96
|
+
ancestors.unshift(trie.el);
|
|
97
|
+
name = path.shift();
|
|
98
|
+
}
|
|
99
|
+
return ancestors;
|
|
100
|
+
}
|
|
101
|
+
// tagged = (tag?: Tag): TaggedResult => {
|
|
102
|
+
// return tag ? {
|
|
103
|
+
// elements: [...this._taggedElements.get(tag)?.values() ?? []],
|
|
104
|
+
// relations: [...this._taggedRelations.get(tag)?.values() ?? []],
|
|
105
|
+
// } : {
|
|
106
|
+
// elements: uniq([...this._taggedElements.values()].flatMap(s => [...s.values()])),
|
|
107
|
+
// relations: uniq([...this._taggedRelations.values()].flatMap(s => [...s.values()]))
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
110
|
+
rootElements() {
|
|
111
|
+
return childrenOf(this.root);
|
|
112
|
+
}
|
|
113
|
+
get elements() {
|
|
114
|
+
return Array.from(this._elements.values());
|
|
115
|
+
}
|
|
116
|
+
hasElement(fqn) {
|
|
117
|
+
return this._elements.has(fqn);
|
|
118
|
+
}
|
|
119
|
+
addRelation(rel) {
|
|
120
|
+
if (!this.hasElement(rel.source)) {
|
|
121
|
+
throw new InvalidModelError(`Source of relation not found ${rel.source}`);
|
|
122
|
+
}
|
|
123
|
+
if (!this.hasElement(rel.target)) {
|
|
124
|
+
throw new InvalidModelError(`Target of relation not found ${rel.target}`);
|
|
125
|
+
}
|
|
126
|
+
this._relations.set(rel.id, rel);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 }; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ModelIndex } from "./ModelIndex.mjs";
|
package/dist/types/_common.d.ts
CHANGED
package/dist/types/_common.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=_common.js.map
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Opaque } from './opaque';
|
|
2
|
-
import type { ElementKind, ElementShape, Fqn, Tag
|
|
2
|
+
import type { ElementKind, ElementShape, Fqn, Tag } from './element';
|
|
3
3
|
import type { RelationID } from './relation';
|
|
4
4
|
import type { ElementView, ViewID, ViewRuleAutoLayout } from './view';
|
|
5
5
|
import type { IconUrl, NonEmptyArray } from './_common';
|
|
6
|
+
import type { ThemeColor } from './theme';
|
|
6
7
|
export type NodeId = Fqn;
|
|
7
8
|
export type EdgeId = Opaque<string, 'EdgeId'>;
|
|
8
9
|
export interface ComputedNode {
|
|
@@ -15,6 +16,8 @@ export interface ComputedNode {
|
|
|
15
16
|
tags: NonEmptyArray<Tag> | null;
|
|
16
17
|
links: NonEmptyArray<string> | null;
|
|
17
18
|
children: NodeId[];
|
|
19
|
+
inEdges: EdgeId[];
|
|
20
|
+
outEdges: EdgeId[];
|
|
18
21
|
shape: ElementShape;
|
|
19
22
|
color: ThemeColor;
|
|
20
23
|
icon?: IconUrl;
|
|
@@ -28,10 +31,8 @@ export interface ComputedEdge {
|
|
|
28
31
|
label: string | null;
|
|
29
32
|
relations: RelationID[];
|
|
30
33
|
}
|
|
31
|
-
export interface ComputedView
|
|
34
|
+
export interface ComputedView extends ElementView {
|
|
32
35
|
autoLayout: ViewRuleAutoLayout['autoLayout'];
|
|
33
|
-
nodes:
|
|
34
|
-
edges:
|
|
36
|
+
nodes: ComputedNode[];
|
|
37
|
+
edges: ComputedEdge[];
|
|
35
38
|
}
|
|
36
|
-
export type ComputeResult<V extends ElementView> = V & Pick<ComputedView, 'autoLayout' | 'nodes' | 'edges'>;
|
|
37
|
-
//# sourceMappingURL=computed-view.d.ts.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=computed-view.js.map
|
|
1
|
+
"use strict";
|
|
File without changes
|
package/dist/types/diagram.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ColorLiteral } from './theme';
|
|
1
2
|
import type { ComputedEdge, ComputedNode, ComputedView } from './computed-view';
|
|
2
3
|
export type Point = [x: number, y: number];
|
|
3
4
|
export interface DiagramLabel {
|
|
4
5
|
align: 'left' | 'right' | 'center';
|
|
5
6
|
fontStyle?: 'bold' | 'normal';
|
|
7
|
+
color?: ColorLiteral;
|
|
6
8
|
fontSize: number;
|
|
7
9
|
pt: Point;
|
|
8
10
|
width: number;
|
|
@@ -21,7 +23,9 @@ export interface DiagramEdge extends ComputedEdge {
|
|
|
21
23
|
headArrow?: Point[];
|
|
22
24
|
labels: DiagramLabel[];
|
|
23
25
|
}
|
|
24
|
-
export interface DiagramView extends ComputedView
|
|
26
|
+
export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
|
|
27
|
+
readonly nodes: DiagramNode[];
|
|
28
|
+
readonly edges: DiagramEdge[];
|
|
25
29
|
width: number;
|
|
26
30
|
height: number;
|
|
27
31
|
boundingBox: {
|
|
@@ -31,4 +35,3 @@ export interface DiagramView extends ComputedView<DiagramNode, DiagramEdge> {
|
|
|
31
35
|
height: number;
|
|
32
36
|
};
|
|
33
37
|
}
|
|
34
|
-
//# sourceMappingURL=diagram.d.ts.map
|
package/dist/types/diagram.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=diagram.js.map
|
|
1
|
+
"use strict";
|
|
File without changes
|
package/dist/types/element.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { IconUrl, NonEmptyArray } from './_common';
|
|
2
2
|
import type { Opaque } from './opaque';
|
|
3
|
+
import type { ThemeColor } from './theme';
|
|
3
4
|
export type Fqn = Opaque<string, 'Fqn'>;
|
|
4
5
|
export declare function AsFqn(name: string, parent?: Fqn | null): Fqn;
|
|
5
6
|
export type ElementKind = Opaque<string, 'ElementKind'>;
|
|
6
|
-
/**
|
|
7
|
-
* TailwindCSS based color palette
|
|
8
|
-
*/
|
|
9
|
-
export type ThemeColor = 'amber' | 'blue' | 'gray' | 'slate' | 'green' | 'indigo' | 'muted' | 'primary' | 'red' | 'secondary' | 'sky';
|
|
10
7
|
export type ElementShape = 'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
|
|
11
|
-
export declare const DefaultThemeColor
|
|
12
|
-
export declare const DefaultElementShape
|
|
8
|
+
export declare const DefaultThemeColor = "primary";
|
|
9
|
+
export declare const DefaultElementShape = "rectangle";
|
|
13
10
|
export interface ElementStyle {
|
|
14
11
|
shape?: ElementShape;
|
|
15
12
|
}
|
|
@@ -30,4 +27,3 @@ export interface Element {
|
|
|
30
27
|
readonly shape?: ElementShape;
|
|
31
28
|
readonly color?: ThemeColor;
|
|
32
29
|
}
|
|
33
|
-
//# sourceMappingURL=element.d.ts.map
|
package/dist/types/element.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AsFqn = AsFqn;
|
|
7
|
+
exports.DefaultThemeColor = exports.DefaultElementShape = void 0;
|
|
8
|
+
function AsFqn(name, parent) {
|
|
9
|
+
return parent ? parent + "." + name : name;
|
|
3
10
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
const DefaultThemeColor = "primary";
|
|
12
|
+
exports.DefaultThemeColor = DefaultThemeColor;
|
|
13
|
+
const DefaultElementShape = "rectangle";
|
|
14
|
+
exports.DefaultElementShape = DefaultElementShape;
|
|
@@ -54,4 +54,3 @@ export type AnyRelationExpression = RelationExpr | InOutExpr | IncomingExpr | Ou
|
|
|
54
54
|
export declare function isAnyRelation(expr: Expression): expr is AnyRelationExpression;
|
|
55
55
|
export type Expression = ElementExpression | AnyRelationExpression;
|
|
56
56
|
export {};
|
|
57
|
-
//# sourceMappingURL=expression.d.ts.map
|
package/dist/types/expression.js
CHANGED
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAnyRelation = isAnyRelation;
|
|
7
|
+
exports.isElement = isElement;
|
|
8
|
+
exports.isElementKindExpr = isElementKindExpr;
|
|
9
|
+
exports.isElementRef = isElementRef;
|
|
10
|
+
exports.isElementTagExpr = isElementTagExpr;
|
|
11
|
+
exports.isInOut = isInOut;
|
|
12
|
+
exports.isIncoming = isIncoming;
|
|
13
|
+
exports.isOutgoing = isOutgoing;
|
|
14
|
+
exports.isRelation = isRelation;
|
|
15
|
+
exports.isWildcard = isWildcard;
|
|
16
|
+
function isElementRef(expr) {
|
|
17
|
+
return "element" in expr && "isDescedants" in expr;
|
|
18
|
+
}
|
|
19
|
+
function isWildcard(expr) {
|
|
20
|
+
return "wildcard" in expr;
|
|
21
|
+
}
|
|
22
|
+
function isElementKindExpr(expr) {
|
|
23
|
+
return "elementKind" in expr && "isEqual" in expr;
|
|
24
|
+
}
|
|
25
|
+
function isElementTagExpr(expr) {
|
|
26
|
+
return "elementTag" in expr && "isEqual" in expr;
|
|
27
|
+
}
|
|
28
|
+
function isElement(expr) {
|
|
29
|
+
return isElementRef(expr) || isWildcard(expr) || isElementKindExpr(expr) || isElementTagExpr(expr);
|
|
30
|
+
}
|
|
31
|
+
function isRelation(expr) {
|
|
32
|
+
return "source" in expr && "target" in expr;
|
|
33
|
+
}
|
|
34
|
+
function isInOut(expr) {
|
|
35
|
+
return "inout" in expr;
|
|
36
|
+
}
|
|
37
|
+
function isIncoming(expr) {
|
|
38
|
+
return "incoming" in expr;
|
|
39
|
+
}
|
|
40
|
+
function isOutgoing(expr) {
|
|
41
|
+
return "outgoing" in expr;
|
|
42
|
+
}
|
|
43
|
+
function isAnyRelation(expr) {
|
|
44
|
+
return isRelation(expr) || isInOut(expr) || isIncoming(expr) || isOutgoing(expr);
|
|
45
|
+
}
|