@likec4/core 0.45.0 → 0.46.1

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.
@@ -23,6 +23,7 @@ export interface ComputedNode {
23
23
  icon?: IconUrl;
24
24
  navigateTo?: ViewID;
25
25
  level: number;
26
+ depth?: number;
26
27
  }
27
28
  export interface ComputedEdge {
28
29
  id: EdgeId;
@@ -7,7 +7,16 @@ exports.compareRelations = exports.Relations = void 0;
7
7
  var _fqn = require("./fqn");
8
8
  var _rambdax = require("rambdax");
9
9
  const compareRelations = (a, b) => {
10
- return (0, _fqn.compareFqnHierarchically)(a.source, b.source) || (0, _fqn.compareFqnHierarchically)(a.target, b.target);
10
+ const parentA = (0, _fqn.commonAncestor)(a.source, a.target);
11
+ const parentB = (0, _fqn.commonAncestor)(b.source, b.target);
12
+ if (parentA && !parentB) {
13
+ return 1;
14
+ }
15
+ if (!parentA && parentB) {
16
+ return -1;
17
+ }
18
+ const compareParents = parentA && parentB ? (0, _fqn.compareFqnHierarchically)(parentA, parentB) : 0;
19
+ return compareParents || (0, _fqn.compareFqnHierarchically)(a.source, b.source) || (0, _fqn.compareFqnHierarchically)(a.target, b.target);
11
20
  };
12
21
  exports.compareRelations = compareRelations;
13
22
  const isInside = parent => {
@@ -23,6 +23,7 @@ export interface ComputedNode {
23
23
  icon?: IconUrl;
24
24
  navigateTo?: ViewID;
25
25
  level: number;
26
+ depth?: number;
26
27
  }
27
28
  export interface ComputedEdge {
28
29
  id: EdgeId;
@@ -1,7 +1,16 @@
1
- import { compareFqnHierarchically, isAncestor } from "./fqn.js";
1
+ import { commonAncestor, compareFqnHierarchically, isAncestor } from "./fqn.js";
2
2
  import { either } from "rambdax";
3
3
  export const compareRelations = (a, b) => {
4
- return compareFqnHierarchically(a.source, b.source) || compareFqnHierarchically(a.target, b.target);
4
+ const parentA = commonAncestor(a.source, a.target);
5
+ const parentB = commonAncestor(b.source, b.target);
6
+ if (parentA && !parentB) {
7
+ return 1;
8
+ }
9
+ if (!parentA && parentB) {
10
+ return -1;
11
+ }
12
+ const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0;
13
+ return compareParents || compareFqnHierarchically(a.source, b.source) || compareFqnHierarchically(a.target, b.target);
5
14
  };
6
15
  const isInside = (parent) => {
7
16
  const prefix = parent + ".";
@@ -23,6 +23,7 @@ export interface ComputedNode {
23
23
  icon?: IconUrl;
24
24
  navigateTo?: ViewID;
25
25
  level: number;
26
+ depth?: number;
26
27
  }
27
28
  export interface ComputedEdge {
28
29
  id: EdgeId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "0.45.0",
3
+ "version": "0.46.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -78,7 +78,7 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "rambdax": "^9.1.1",
81
- "remeda": "^1.28.0",
81
+ "remeda": "^1.29.0",
82
82
  "safe-stable-stringify": "^2.4.3",
83
83
  "ts-custom-error": "^3.3.1"
84
84
  },