@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
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Relations: true
|
|
8
|
+
};
|
|
9
|
+
exports.Relations = void 0;
|
|
10
|
+
var _fqn = require("./fqn");
|
|
11
|
+
Object.keys(_fqn).forEach(function (key) {
|
|
12
|
+
if (key === "default" || key === "__esModule") return;
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
+
if (key in exports && exports[key] === _fqn[key]) return;
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _fqn[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
var _guards = require("./guards");
|
|
23
|
+
Object.keys(_guards).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _guards[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _guards[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
var _computeNodeLevels = require("./compute-node-levels");
|
|
35
|
+
Object.keys(_computeNodeLevels).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
+
if (key in exports && exports[key] === _computeNodeLevels[key]) return;
|
|
39
|
+
Object.defineProperty(exports, key, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _computeNodeLevels[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
var _Relations = _interopRequireWildcard(require("./relations"));
|
|
47
|
+
exports.Relations = _Relations;
|
|
48
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
49
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/dist/utils/relations.js
CHANGED
|
@@ -1,49 +1,56 @@
|
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isOutgoing = exports.isInside = exports.isIncoming = exports.isBetween = exports.isAnyInOut = exports.isAnyBetween = exports.hasRelation = exports.compareRelations = void 0;
|
|
7
|
+
var _remeda = require("remeda");
|
|
8
|
+
var _fqn = require("./fqn");
|
|
9
|
+
var _rambdax = require("rambdax");
|
|
10
|
+
const compareRelations = (a, b) => {
|
|
11
|
+
return (0, _fqn.compareFqnHierarchically)(a.source, b.source) || (0, _fqn.compareFqnHierarchically)(a.target, b.target);
|
|
12
|
+
};
|
|
13
|
+
exports.compareRelations = compareRelations;
|
|
14
|
+
const isInside = parent => {
|
|
15
|
+
const prefix = parent + ".";
|
|
16
|
+
return rel => {
|
|
17
|
+
return rel.source.startsWith(prefix) && rel.target.startsWith(prefix);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.isInside = isInside;
|
|
21
|
+
const isBetween = (source, target) => {
|
|
22
|
+
const sourcePrefix = source + ".";
|
|
23
|
+
const targetPrefix = target + ".";
|
|
24
|
+
return rel => {
|
|
25
|
+
return (rel.source === source || (rel.source + ".").startsWith(sourcePrefix)) && (rel.target === target || (rel.target + ".").startsWith(targetPrefix));
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.isBetween = isBetween;
|
|
29
|
+
const isAnyBetween = (source, target) => {
|
|
30
|
+
return (0, _remeda.anyPass)([isBetween(source, target), isBetween(target, source)]);
|
|
31
|
+
};
|
|
32
|
+
exports.isAnyBetween = isAnyBetween;
|
|
33
|
+
const isIncoming = target => {
|
|
34
|
+
const targetPrefix = target + ".";
|
|
35
|
+
return rel => {
|
|
36
|
+
return !(rel.source + ".").startsWith(targetPrefix) && (rel.target === target || (rel.target + ".").startsWith(targetPrefix));
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.isIncoming = isIncoming;
|
|
40
|
+
const isOutgoing = source => {
|
|
41
|
+
const sourcePrefix = source + ".";
|
|
42
|
+
return rel => {
|
|
43
|
+
return (rel.source === source || (rel.source + ".").startsWith(sourcePrefix)) && !(rel.target + ".").startsWith(sourcePrefix);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.isOutgoing = isOutgoing;
|
|
47
|
+
const isAnyInOut = source => {
|
|
48
|
+
return (0, _rambdax.either)(isIncoming(source), isOutgoing(source));
|
|
49
|
+
};
|
|
50
|
+
exports.isAnyInOut = isAnyInOut;
|
|
51
|
+
const hasRelation = rel => {
|
|
52
|
+
return element => {
|
|
53
|
+
return rel.source === element.id || rel.target === element.id || (0, _fqn.isAncestor)(element.id, rel.source) || (0, _fqn.isAncestor)(element.id, rel.target);
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.hasRelation = hasRelation;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { anyPass } from "remeda";
|
|
2
|
+
import { compareFqnHierarchically, isAncestor } from "./fqn.mjs";
|
|
3
|
+
import { either } from "rambdax";
|
|
4
|
+
export const compareRelations = (a, b) => {
|
|
5
|
+
return compareFqnHierarchically(a.source, b.source) || compareFqnHierarchically(a.target, b.target);
|
|
6
|
+
};
|
|
7
|
+
export const isInside = (parent) => {
|
|
8
|
+
const prefix = parent + ".";
|
|
9
|
+
return (rel) => {
|
|
10
|
+
return rel.source.startsWith(prefix) && rel.target.startsWith(prefix);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const isBetween = (source, target) => {
|
|
14
|
+
const sourcePrefix = source + ".";
|
|
15
|
+
const targetPrefix = target + ".";
|
|
16
|
+
return (rel) => {
|
|
17
|
+
return (rel.source === source || (rel.source + ".").startsWith(sourcePrefix)) && (rel.target === target || (rel.target + ".").startsWith(targetPrefix));
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export const isAnyBetween = (source, target) => {
|
|
21
|
+
return anyPass([isBetween(source, target), isBetween(target, source)]);
|
|
22
|
+
};
|
|
23
|
+
export const isIncoming = (target) => {
|
|
24
|
+
const targetPrefix = target + ".";
|
|
25
|
+
return (rel) => {
|
|
26
|
+
return !(rel.source + ".").startsWith(targetPrefix) && (rel.target === target || (rel.target + ".").startsWith(targetPrefix));
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const isOutgoing = (source) => {
|
|
30
|
+
const sourcePrefix = source + ".";
|
|
31
|
+
return (rel) => {
|
|
32
|
+
return (rel.source === source || (rel.source + ".").startsWith(sourcePrefix)) && !(rel.target + ".").startsWith(sourcePrefix);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export const isAnyInOut = (source) => {
|
|
36
|
+
return either(isIncoming(source), isOutgoing(source));
|
|
37
|
+
};
|
|
38
|
+
export const hasRelation = (rel) => {
|
|
39
|
+
return (element) => {
|
|
40
|
+
return rel.source === element.id || rel.target === element.id || isAncestor(element.id, rel.source) || isAncestor(element.id, rel.target);
|
|
41
|
+
};
|
|
42
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"compile": "tsc --noEmit",
|
|
15
|
-
"build": "
|
|
15
|
+
"build": "unbuild",
|
|
16
16
|
"dev": "tsc --watch",
|
|
17
17
|
"lint": "run -T eslint src/ --fix",
|
|
18
18
|
"test": "run -T vitest run",
|
|
@@ -20,84 +20,48 @@
|
|
|
20
20
|
"clean": "run -T rimraf dist"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
"!dist/__test__",
|
|
25
|
-
"!**/*.spec.*",
|
|
26
|
-
"!**/*.map"
|
|
23
|
+
"dist"
|
|
27
24
|
],
|
|
28
|
-
"module": "./dist/index.js",
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
25
|
"type": "module",
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"module": "dist/index.mjs",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
31
29
|
"exports": {
|
|
32
30
|
".": {
|
|
33
31
|
"types": "./dist/index.d.ts",
|
|
34
|
-
"import": "./dist/index.
|
|
35
|
-
"
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.js"
|
|
36
34
|
},
|
|
37
35
|
"./types": {
|
|
38
36
|
"types": "./dist/types/index.d.ts",
|
|
39
|
-
"import": "./dist/types/index.
|
|
40
|
-
"
|
|
37
|
+
"import": "./dist/types/index.mjs",
|
|
38
|
+
"require": "./dist/types/index.js"
|
|
41
39
|
},
|
|
42
40
|
"./colors": {
|
|
43
41
|
"types": "./dist/colors.d.ts",
|
|
44
|
-
"import": "./dist/colors.
|
|
45
|
-
"
|
|
42
|
+
"import": "./dist/colors.mjs",
|
|
43
|
+
"require": "./dist/colors.js"
|
|
46
44
|
},
|
|
47
45
|
"./errors": {
|
|
48
46
|
"types": "./dist/errors/index.d.ts",
|
|
49
|
-
"import": "./dist/errors/index.
|
|
50
|
-
"
|
|
47
|
+
"import": "./dist/errors/index.mjs",
|
|
48
|
+
"require": "./dist/errors/index.js"
|
|
51
49
|
},
|
|
52
50
|
"./utils": {
|
|
53
51
|
"types": "./dist/utils/index.d.ts",
|
|
54
|
-
"import": "./dist/utils/index.
|
|
55
|
-
"
|
|
52
|
+
"import": "./dist/utils/index.mjs",
|
|
53
|
+
"require": "./dist/utils/index.js"
|
|
56
54
|
},
|
|
57
55
|
"./compute-view": {
|
|
58
56
|
"types": "./dist/compute-view/index.d.ts",
|
|
59
|
-
"import": "./dist/compute-view/index.
|
|
60
|
-
"
|
|
57
|
+
"import": "./dist/compute-view/index.mjs",
|
|
58
|
+
"require": "./dist/compute-view/index.js"
|
|
61
59
|
}
|
|
62
60
|
},
|
|
63
61
|
"sideEffects": false,
|
|
64
62
|
"publishConfig": {
|
|
65
63
|
"registry": "https://registry.npmjs.org",
|
|
66
|
-
"access": "public"
|
|
67
|
-
"module": "./dist/index.js",
|
|
68
|
-
"types": "./dist/index.d.ts",
|
|
69
|
-
"exports": {
|
|
70
|
-
".": {
|
|
71
|
-
"types": "./dist/index.d.ts",
|
|
72
|
-
"import": "./dist/index.js",
|
|
73
|
-
"default": "./dist/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./types": {
|
|
76
|
-
"types": "./dist/types/index.d.ts",
|
|
77
|
-
"import": "./dist/types/index.js",
|
|
78
|
-
"default": "./dist/types/index.js"
|
|
79
|
-
},
|
|
80
|
-
"./colors": {
|
|
81
|
-
"types": "./dist/colors.d.ts",
|
|
82
|
-
"import": "./dist/colors.js",
|
|
83
|
-
"default": "./dist/colors.js"
|
|
84
|
-
},
|
|
85
|
-
"./errors": {
|
|
86
|
-
"types": "./dist/errors/index.d.ts",
|
|
87
|
-
"import": "./dist/errors/index.js",
|
|
88
|
-
"default": "./dist/errors/index.js"
|
|
89
|
-
},
|
|
90
|
-
"./utils": {
|
|
91
|
-
"types": "./dist/utils/index.d.ts",
|
|
92
|
-
"import": "./dist/utils/index.js",
|
|
93
|
-
"default": "./dist/utils/index.js"
|
|
94
|
-
},
|
|
95
|
-
"./compute-view": {
|
|
96
|
-
"types": "./dist/compute-view/index.d.ts",
|
|
97
|
-
"import": "./dist/compute-view/index.js",
|
|
98
|
-
"default": "./dist/compute-view/index.js"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
64
|
+
"access": "public"
|
|
101
65
|
},
|
|
102
66
|
"dependencies": {
|
|
103
67
|
"@dagrejs/graphlib": "^2.1.13",
|
|
@@ -107,6 +71,7 @@
|
|
|
107
71
|
},
|
|
108
72
|
"devDependencies": {
|
|
109
73
|
"typescript": "^5.1.6",
|
|
74
|
+
"unbuild": "^2.0.0-rc.0",
|
|
110
75
|
"vitest": "^0.34.1"
|
|
111
76
|
}
|
|
112
77
|
}
|