@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.
Files changed (106) hide show
  1. package/dist/colors.d.ts +76 -9
  2. package/dist/colors.js +116 -93
  3. package/dist/colors.mjs +112 -0
  4. package/dist/compute-view/EdgeBuilder.d.ts +0 -1
  5. package/dist/compute-view/EdgeBuilder.js +37 -34
  6. package/dist/compute-view/EdgeBuilder.mjs +31 -0
  7. package/dist/compute-view/compute-ctx.d.ts +0 -1
  8. package/dist/compute-view/compute-ctx.js +33 -24
  9. package/dist/compute-view/compute-ctx.mjs +42 -0
  10. package/dist/compute-view/compute-element-view.d.ts +2 -3
  11. package/dist/compute-view/compute-element-view.js +137 -525
  12. package/dist/compute-view/compute-element-view.mjs +145 -0
  13. package/dist/compute-view/compute-predicates.d.ts +16 -0
  14. package/dist/compute-view/compute-predicates.js +358 -0
  15. package/dist/compute-view/compute-predicates.mjs +324 -0
  16. package/dist/compute-view/compute.d.ts +8 -9
  17. package/dist/compute-view/compute.js +49 -39
  18. package/dist/compute-view/compute.mjs +39 -0
  19. package/dist/compute-view/index.d.ts +1 -1
  20. package/dist/compute-view/index.js +24 -2
  21. package/dist/compute-view/index.mjs +1 -0
  22. package/dist/compute-view/utils/anyPossibleRelations.d.ts +0 -1
  23. package/dist/compute-view/utils/anyPossibleRelations.js +17 -12
  24. package/dist/compute-view/utils/anyPossibleRelations.mjs +12 -0
  25. package/dist/compute-view/utils/applyViewRuleStyles.d.ts +3 -0
  26. package/dist/compute-view/utils/applyViewRuleStyles.js +59 -0
  27. package/dist/compute-view/utils/applyViewRuleStyles.mjs +50 -0
  28. package/dist/compute-view/utils/sortNodes.d.ts +0 -1
  29. package/dist/compute-view/utils/sortNodes.js +47 -42
  30. package/dist/compute-view/utils/sortNodes.mjs +40 -0
  31. package/dist/errors/_base.d.ts +0 -1
  32. package/dist/errors/_base.js +14 -11
  33. package/dist/errors/_base.mjs +4 -0
  34. package/dist/errors/index.d.ts +1 -1
  35. package/dist/errors/index.js +60 -5
  36. package/dist/errors/index.mjs +5 -0
  37. package/dist/errors/invariant.d.ts +0 -2
  38. package/dist/errors/invariant.js +16 -21
  39. package/dist/errors/invariant.mjs +8 -0
  40. package/dist/errors/model-index.d.ts +0 -1
  41. package/dist/errors/model-index.js +16 -14
  42. package/dist/errors/model-index.mjs +8 -0
  43. package/dist/errors/non-nullable.d.ts +2 -0
  44. package/dist/errors/non-nullable.js +16 -0
  45. package/dist/errors/non-nullable.mjs +8 -0
  46. package/dist/errors/nonexhaustive.d.ts +0 -1
  47. package/dist/errors/nonexhaustive.js +13 -6
  48. package/dist/errors/nonexhaustive.mjs +5 -0
  49. package/dist/index.d.ts +6 -3
  50. package/dist/index.js +71 -7
  51. package/dist/index.mjs +6 -0
  52. package/dist/model-index/ModelIndex.d.ts +0 -1
  53. package/dist/model-index/ModelIndex.js +125 -122
  54. package/dist/model-index/ModelIndex.mjs +128 -0
  55. package/dist/model-index/index.d.ts +0 -1
  56. package/dist/model-index/index.js +13 -2
  57. package/dist/model-index/index.mjs +1 -0
  58. package/dist/types/_common.d.ts +0 -1
  59. package/dist/types/_common.js +1 -2
  60. package/dist/types/_common.mjs +0 -0
  61. package/dist/types/computed-view.d.ts +7 -6
  62. package/dist/types/computed-view.js +1 -2
  63. package/dist/types/computed-view.mjs +0 -0
  64. package/dist/types/diagram.d.ts +5 -2
  65. package/dist/types/diagram.js +1 -2
  66. package/dist/types/diagram.mjs +0 -0
  67. package/dist/types/element.d.ts +3 -7
  68. package/dist/types/element.js +13 -5
  69. package/dist/types/element.mjs +5 -0
  70. package/dist/types/expression.d.ts +0 -1
  71. package/dist/types/expression.js +45 -31
  72. package/dist/types/expression.mjs +30 -0
  73. package/dist/types/index.d.ts +1 -1
  74. package/dist/types/index.js +48 -4
  75. package/dist/types/index.mjs +3 -0
  76. package/dist/types/model.d.ts +0 -1
  77. package/dist/types/model.js +1 -2
  78. package/dist/types/model.mjs +0 -0
  79. package/dist/types/opaque.d.ts +0 -1
  80. package/dist/types/opaque.js +1 -2
  81. package/dist/types/opaque.mjs +0 -0
  82. package/dist/types/relation.d.ts +0 -1
  83. package/dist/types/relation.js +1 -2
  84. package/dist/types/relation.mjs +0 -0
  85. package/dist/types/theme.d.ts +22 -0
  86. package/dist/types/theme.js +1 -0
  87. package/dist/types/theme.mjs +0 -0
  88. package/dist/types/view.d.ts +2 -2
  89. package/dist/types/view.js +15 -8
  90. package/dist/types/view.mjs +9 -0
  91. package/dist/utils/compute-node-levels.d.ts +0 -1
  92. package/dist/utils/compute-node-levels.js +45 -29
  93. package/dist/utils/compute-node-levels.mjs +31 -0
  94. package/dist/utils/fqn.d.ts +0 -1
  95. package/dist/utils/fqn.js +71 -71
  96. package/dist/utils/fqn.mjs +66 -0
  97. package/dist/utils/guards.d.ts +0 -1
  98. package/dist/utils/guards.js +19 -12
  99. package/dist/utils/guards.mjs +13 -0
  100. package/dist/utils/index.d.ts +0 -1
  101. package/dist/utils/index.js +49 -5
  102. package/dist/utils/index.mjs +4 -0
  103. package/dist/utils/relations.d.ts +0 -1
  104. package/dist/utils/relations.js +56 -49
  105. package/dist/utils/relations.mjs +42 -0
  106. package/package.json +20 -55
@@ -1,5 +1,49 @@
1
- export * from './fqn';
2
- export * from './guards';
3
- export * from './compute-node-levels';
4
- export * as Relations from './relations';
5
- //# sourceMappingURL=index.js.map
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; }
@@ -0,0 +1,4 @@
1
+ export * from "./fqn.mjs";
2
+ export * from "./guards.mjs";
3
+ export * from "./compute-node-levels.mjs";
4
+ export * as Relations from "./relations.mjs";
@@ -21,4 +21,3 @@ export declare const hasRelation: <R extends {
21
21
  id: Fqn;
22
22
  }>(element: E) => boolean;
23
23
  export {};
24
- //# sourceMappingURL=relations.d.ts.map
@@ -1,49 +1,56 @@
1
- import { anyPass } from 'remeda';
2
- import { compareFqnHierarchically, isAncestor } from './fqn';
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)) &&
18
- (rel.target === target || (rel.target + '.').startsWith(targetPrefix)));
19
- };
20
- };
21
- export const isAnyBetween = (source, target) => {
22
- return anyPass([isBetween(source, target), isBetween(target, source)]);
23
- };
24
- export const isIncoming = (target) => {
25
- const targetPrefix = target + '.';
26
- return (rel) => {
27
- return (!(rel.source + '.').startsWith(targetPrefix) &&
28
- (rel.target === target || (rel.target + '.').startsWith(targetPrefix)));
29
- };
30
- };
31
- export const isOutgoing = (source) => {
32
- const sourcePrefix = source + '.';
33
- return (rel) => {
34
- return ((rel.source === source || (rel.source + '.').startsWith(sourcePrefix)) &&
35
- !(rel.target + '.').startsWith(sourcePrefix));
36
- };
37
- };
38
- export const isAnyInOut = (source) => {
39
- return either(isIncoming(source), isOutgoing(source));
40
- };
41
- export const hasRelation = (rel) => {
42
- return (element) => {
43
- return (rel.source === element.id ||
44
- rel.target === element.id ||
45
- isAncestor(element.id, rel.source) ||
46
- isAncestor(element.id, rel.target));
47
- };
48
- };
49
- //# sourceMappingURL=relations.js.map
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.32.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": "tsc",
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.js",
35
- "default": "./dist/index.js"
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.js",
40
- "default": "./dist/types/index.js"
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.js",
45
- "default": "./dist/colors.js"
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.js",
50
- "default": "./dist/errors/index.js"
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.js",
55
- "default": "./dist/utils/index.js"
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.js",
60
- "default": "./dist/compute-view/index.js"
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
  }