@likec4/core 0.40.0 → 0.42.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 (124) hide show
  1. package/README.md +2 -6
  2. package/dist/cjs/colors/element.d.ts +68 -0
  3. package/dist/{esm/colors.js → cjs/colors/element.js} +9 -23
  4. package/dist/cjs/colors/index.d.ts +132 -0
  5. package/dist/cjs/colors/index.js +27 -0
  6. package/dist/cjs/colors/relationships.d.ts +57 -0
  7. package/dist/cjs/colors/relationships.js +76 -0
  8. package/dist/cjs/index.d.ts +0 -2
  9. package/dist/cjs/index.js +0 -22
  10. package/dist/cjs/types/computed-view.d.ts +10 -7
  11. package/dist/cjs/types/diagram.d.ts +14 -5
  12. package/dist/cjs/types/expression.d.ts +1 -1
  13. package/dist/cjs/types/relation.d.ts +12 -0
  14. package/dist/cjs/types/relation.js +12 -1
  15. package/dist/cjs/types/theme.d.ts +12 -14
  16. package/dist/cjs/types/view.d.ts +7 -4
  17. package/dist/cjs/types/view.js +1 -1
  18. package/dist/cjs/utils/fqn.d.ts +6 -1
  19. package/dist/cjs/utils/fqn.js +17 -4
  20. package/dist/cjs/utils/guards.d.ts +1 -0
  21. package/dist/cjs/utils/guards.js +7 -0
  22. package/dist/cjs/utils/index.d.ts +0 -1
  23. package/dist/cjs/utils/index.js +0 -11
  24. package/dist/esm/colors/element.d.ts +68 -0
  25. package/dist/{cjs/colors.js → esm/colors/element.js} +1 -33
  26. package/dist/esm/colors/index.d.ts +132 -0
  27. package/dist/esm/colors/index.js +9 -0
  28. package/dist/esm/colors/relationships.d.ts +57 -0
  29. package/dist/esm/colors/relationships.js +64 -0
  30. package/dist/esm/index.d.ts +0 -2
  31. package/dist/esm/index.js +1 -3
  32. package/dist/esm/types/computed-view.d.ts +10 -7
  33. package/dist/esm/types/diagram.d.ts +14 -5
  34. package/dist/esm/types/expression.d.ts +1 -1
  35. package/dist/esm/types/relation.d.ts +12 -0
  36. package/dist/esm/types/relation.js +3 -0
  37. package/dist/esm/types/theme.d.ts +12 -14
  38. package/dist/esm/types/view.d.ts +7 -4
  39. package/dist/esm/types/view.js +1 -1
  40. package/dist/esm/utils/fqn.d.ts +6 -1
  41. package/dist/esm/utils/fqn.js +16 -4
  42. package/dist/esm/utils/guards.d.ts +1 -0
  43. package/dist/esm/utils/guards.js +1 -0
  44. package/dist/esm/utils/index.d.ts +0 -1
  45. package/dist/esm/utils/index.js +0 -1
  46. package/dist/types/colors/element.d.ts +69 -0
  47. package/dist/types/colors/index.d.ts +133 -0
  48. package/dist/types/colors/relationships.d.ts +58 -0
  49. package/dist/types/errors/index.d.ts +46 -0
  50. package/dist/types/index.d.ts +7 -0
  51. package/dist/types/types/_common.d.ts +4 -0
  52. package/dist/types/types/computed-view.d.ts +45 -0
  53. package/dist/types/types/diagram.d.ts +42 -0
  54. package/dist/types/types/element.d.ts +30 -0
  55. package/dist/types/types/expression.d.ts +57 -0
  56. package/dist/types/types/index.d.ts +12 -0
  57. package/dist/types/types/model.d.ts +15 -0
  58. package/dist/types/types/opaque.d.ts +103 -0
  59. package/dist/types/types/relation.d.ts +23 -0
  60. package/dist/types/types/theme.d.ts +27 -0
  61. package/dist/types/types/view.d.ts +62 -0
  62. package/dist/types/utils/fqn.d.ts +34 -0
  63. package/dist/types/utils/guards.d.ts +5 -0
  64. package/dist/types/utils/index.d.ts +4 -0
  65. package/dist/types/utils/relations.d.ts +26 -0
  66. package/package.json +51 -54
  67. package/dist/cjs/colors.d.ts +0 -148
  68. package/dist/cjs/compute-view/EdgeBuilder.d.ts +0 -6
  69. package/dist/cjs/compute-view/EdgeBuilder.js +0 -37
  70. package/dist/cjs/compute-view/compute-ctx.d.ts +0 -20
  71. package/dist/cjs/compute-view/compute-ctx.js +0 -91
  72. package/dist/cjs/compute-view/compute-element-view.d.ts +0 -3
  73. package/dist/cjs/compute-view/compute-element-view.js +0 -100
  74. package/dist/cjs/compute-view/compute-predicates.d.ts +0 -16
  75. package/dist/cjs/compute-view/compute-predicates.js +0 -363
  76. package/dist/cjs/compute-view/compute.d.ts +0 -14
  77. package/dist/cjs/compute-view/compute.js +0 -46
  78. package/dist/cjs/compute-view/index.d.ts +0 -4
  79. package/dist/cjs/compute-view/index.js +0 -49
  80. package/dist/cjs/compute-view/resolve-extended-views.d.ts +0 -6
  81. package/dist/cjs/compute-view/resolve-extended-views.js +0 -53
  82. package/dist/cjs/compute-view/resolve-relative-paths.d.ts +0 -2
  83. package/dist/cjs/compute-view/resolve-relative-paths.js +0 -84
  84. package/dist/cjs/compute-view/utils/anyPossibleRelations.d.ts +0 -2
  85. package/dist/cjs/compute-view/utils/anyPossibleRelations.js +0 -18
  86. package/dist/cjs/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
  87. package/dist/cjs/compute-view/utils/applyViewRuleStyles.js +0 -57
  88. package/dist/cjs/compute-view/utils/sortNodes.d.ts +0 -19
  89. package/dist/cjs/compute-view/utils/sortNodes.js +0 -47
  90. package/dist/cjs/model-index/ModelIndex.d.ts +0 -27
  91. package/dist/cjs/model-index/ModelIndex.js +0 -139
  92. package/dist/cjs/model-index/index.d.ts +0 -1
  93. package/dist/cjs/model-index/index.js +0 -13
  94. package/dist/cjs/utils/compute-node-levels.d.ts +0 -7
  95. package/dist/cjs/utils/compute-node-levels.js +0 -48
  96. package/dist/esm/colors.d.ts +0 -148
  97. package/dist/esm/compute-view/EdgeBuilder.d.ts +0 -6
  98. package/dist/esm/compute-view/EdgeBuilder.js +0 -30
  99. package/dist/esm/compute-view/compute-ctx.d.ts +0 -20
  100. package/dist/esm/compute-view/compute-ctx.js +0 -100
  101. package/dist/esm/compute-view/compute-element-view.d.ts +0 -3
  102. package/dist/esm/compute-view/compute-element-view.js +0 -98
  103. package/dist/esm/compute-view/compute-predicates.d.ts +0 -16
  104. package/dist/esm/compute-view/compute-predicates.js +0 -324
  105. package/dist/esm/compute-view/compute.d.ts +0 -14
  106. package/dist/esm/compute-view/compute.js +0 -36
  107. package/dist/esm/compute-view/index.d.ts +0 -4
  108. package/dist/esm/compute-view/index.js +0 -4
  109. package/dist/esm/compute-view/resolve-extended-views.d.ts +0 -6
  110. package/dist/esm/compute-view/resolve-extended-views.js +0 -41
  111. package/dist/esm/compute-view/resolve-relative-paths.d.ts +0 -2
  112. package/dist/esm/compute-view/resolve-relative-paths.js +0 -76
  113. package/dist/esm/compute-view/utils/anyPossibleRelations.d.ts +0 -2
  114. package/dist/esm/compute-view/utils/anyPossibleRelations.js +0 -12
  115. package/dist/esm/compute-view/utils/applyViewRuleStyles.d.ts +0 -2
  116. package/dist/esm/compute-view/utils/applyViewRuleStyles.js +0 -50
  117. package/dist/esm/compute-view/utils/sortNodes.d.ts +0 -19
  118. package/dist/esm/compute-view/utils/sortNodes.js +0 -37
  119. package/dist/esm/model-index/ModelIndex.d.ts +0 -27
  120. package/dist/esm/model-index/ModelIndex.js +0 -127
  121. package/dist/esm/model-index/index.d.ts +0 -1
  122. package/dist/esm/model-index/index.js +0 -1
  123. package/dist/esm/utils/compute-node-levels.d.ts +0 -7
  124. package/dist/esm/utils/compute-node-levels.js +0 -31
@@ -5,13 +5,18 @@ export declare function isAncestor<E extends {
5
5
  }>(...args: [ancestor: Fqn, another: Fqn] | [ancestor: E, another: E]): boolean;
6
6
  export declare function isSameHierarchy<E extends {
7
7
  id: Fqn;
8
- }>(...args: [one: Fqn, another: Fqn] | [one: E, another: E]): boolean;
8
+ }>(one: E | Fqn, another: E | Fqn): boolean;
9
9
  export declare function isDescendantOf<E extends {
10
10
  id: Fqn;
11
11
  }>(ancestors: E[]): (e: E) => boolean;
12
12
  export declare function notDescendantOf(ancestors: Element[]): (e: Element) => boolean;
13
13
  export declare function commonAncestor(first: Fqn, second: Fqn): Fqn | null;
14
14
  export declare function parentFqn(fqn: Fqn): Fqn | null;
15
+ /**
16
+ * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
17
+ * (from closest to root)
18
+ */
19
+ export declare function ancestorsFqn(fqn: Fqn): Fqn[];
15
20
  /**
16
21
  * Compares two fully qualified names (fqns) hierarchically based on their depth.
17
22
  * From parent nodes to leaves
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.ancestorsFqn = ancestorsFqn;
6
7
  exports.commonAncestor = commonAncestor;
7
8
  exports.compareByFqnHierarchically = compareByFqnHierarchically;
8
9
  exports.compareFqnHierarchically = compareFqnHierarchically;
@@ -27,10 +28,10 @@ function isAncestor(...args) {
27
28
  const another = (0, _guards.isString)(args[1]) ? args[1] : args[1].id;
28
29
  return another.startsWith(ancestor + ".");
29
30
  }
30
- function isSameHierarchy(...args) {
31
- const one = (0, _guards.isString)(args[0]) ? args[0] : args[0].id;
32
- const another = (0, _guards.isString)(args[1]) ? args[1] : args[1].id;
33
- return one === another || another.startsWith(one + ".") || one.startsWith(another + ".");
31
+ function isSameHierarchy(one, another) {
32
+ const first = (0, _guards.isString)(one) ? one : one.id;
33
+ const second = (0, _guards.isString)(another) ? another : another.id;
34
+ return first === second || second.startsWith(first + ".") || first.startsWith(second + ".");
34
35
  }
35
36
  function isDescendantOf(ancestors) {
36
37
  const predicates = ancestors.flatMap(a => [e => e.id === a.id, e => isAncestor(a, e)]);
@@ -66,6 +67,18 @@ function parentFqn(fqn) {
66
67
  }
67
68
  return null;
68
69
  }
70
+ function ancestorsFqn(fqn) {
71
+ const path = fqn.split(".");
72
+ path.pop();
73
+ if (path.length === 0) {
74
+ return [];
75
+ }
76
+ return path.reduce((acc, _, idx) => {
77
+ const ancestor = path.slice(0, idx + 1).join(".");
78
+ acc.unshift(ancestor);
79
+ return acc;
80
+ }, []);
81
+ }
69
82
  function compareFqnHierarchically(a, b) {
70
83
  const depthA = a.split(".").length;
71
84
  const depthB = b.split(".").length;
@@ -1,3 +1,4 @@
1
1
  import type { NonEmptyArray } from '../types';
2
+ export { hasAtLeast } from 'remeda';
2
3
  export declare function isString(value: unknown): value is string;
3
4
  export declare function isNonEmptyArray<A>(arr: ArrayLike<A>): arr is NonEmptyArray<A>;
@@ -3,8 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "hasAtLeast", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _remeda.hasAtLeast;
10
+ }
11
+ });
6
12
  exports.isNonEmptyArray = isNonEmptyArray;
7
13
  exports.isString = isString;
14
+ var _remeda = require("remeda");
8
15
  function isString(value) {
9
16
  return value != null && typeof value === "string";
10
17
  }
@@ -1,4 +1,3 @@
1
1
  export * from './fqn';
2
2
  export * from './guards';
3
- export * from './compute-node-levels';
4
3
  export * from './relations';
@@ -25,17 +25,6 @@ Object.keys(_guards).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
- var _computeNodeLevels = require("./compute-node-levels");
29
- Object.keys(_computeNodeLevels).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _computeNodeLevels[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _computeNodeLevels[key];
36
- }
37
- });
38
- });
39
28
  var _relations = require("./relations");
40
29
  Object.keys(_relations).forEach(function (key) {
41
30
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,68 @@
1
+ export declare const ElementColors: {
2
+ readonly primary: {
3
+ fill: "#3b82f6";
4
+ stroke: "#2563eb";
5
+ hiContrast: "#eff6ff";
6
+ loContrast: "#bfdbfe";
7
+ };
8
+ readonly blue: {
9
+ fill: "#3b82f6";
10
+ stroke: "#2563eb";
11
+ hiContrast: "#eff6ff";
12
+ loContrast: "#bfdbfe";
13
+ };
14
+ readonly secondary: {
15
+ fill: "#0284c7";
16
+ stroke: "#0369a1";
17
+ hiContrast: "#f0f9ff";
18
+ loContrast: "#e0f2fe";
19
+ };
20
+ readonly sky: {
21
+ fill: "#0284c7";
22
+ stroke: "#0369a1";
23
+ hiContrast: "#f0f9ff";
24
+ loContrast: "#e0f2fe";
25
+ };
26
+ readonly muted: {
27
+ fill: "#64748b";
28
+ stroke: "#475569";
29
+ hiContrast: "#f8fafc";
30
+ loContrast: "#e2e8f0";
31
+ };
32
+ readonly slate: {
33
+ fill: "#64748b";
34
+ stroke: "#475569";
35
+ hiContrast: "#f8fafc";
36
+ loContrast: "#e2e8f0";
37
+ };
38
+ readonly gray: {
39
+ readonly fill: "#737373";
40
+ readonly stroke: "#525252";
41
+ readonly hiContrast: "#fafafa";
42
+ readonly loContrast: "#e5e5e5";
43
+ };
44
+ readonly red: {
45
+ readonly fill: "#b54548";
46
+ readonly stroke: "#8c333a";
47
+ readonly hiContrast: "#f8fafc";
48
+ readonly loContrast: "#F9C6C6";
49
+ };
50
+ readonly green: {
51
+ readonly fill: "#428a4f";
52
+ readonly stroke: "#2d5d39";
53
+ readonly hiContrast: "#f8fafc";
54
+ readonly loContrast: "#c2f0c2";
55
+ };
56
+ readonly amber: {
57
+ readonly fill: "#d97706";
58
+ readonly stroke: "#b45309";
59
+ readonly hiContrast: "#f8fafc";
60
+ readonly loContrast: "#ffe0c2";
61
+ };
62
+ readonly indigo: {
63
+ readonly fill: "#6366f1";
64
+ readonly stroke: "#4f46e5";
65
+ readonly hiContrast: "#eef2ff";
66
+ readonly loContrast: "#c7d2fe";
67
+ };
68
+ };
@@ -1,45 +1,22 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defaultTheme = exports.RelationColors = exports.Colors = void 0;
7
1
  const blue = {
8
- // fill: colors.blue[500],
9
- // stroke: colors.blue[600],
10
- // hiContrast: colors.blue[50],
11
- // loContrast: colors.blue[200],
12
2
  fill: "#3b82f6",
13
3
  stroke: "#2563eb",
14
4
  hiContrast: "#eff6ff",
15
5
  loContrast: "#bfdbfe"
16
6
  };
17
7
  const sky = {
18
- // fill: colors.sky[600],
19
- // stroke: colors.sky[700],
20
- // hiContrast: colors.sky[50],
21
- // loContrast: colors.sky[100],
22
8
  fill: "#0284c7",
23
9
  stroke: "#0369a1",
24
10
  hiContrast: "#f0f9ff",
25
11
  loContrast: "#e0f2fe"
26
12
  };
27
13
  const slate = {
28
- // fill: colors.slate[500],
29
- // stroke: colors.slate[600],
30
- // hiContrast: colors.slate[50],
31
- // loContrast: colors.slate[200],
32
14
  fill: "#64748b",
33
15
  stroke: "#475569",
34
16
  hiContrast: "#f8fafc",
35
17
  loContrast: "#e2e8f0"
36
18
  };
37
- const RelationColors = {
38
- lineColor: "#b1b1b1",
39
- labelColor: "#b1b1b1"
40
- };
41
- exports.RelationColors = RelationColors;
42
- const Colors = {
19
+ export const ElementColors = {
43
20
  primary: blue,
44
21
  blue,
45
22
  secondary: sky,
@@ -92,7 +69,6 @@ const Colors = {
92
69
  loContrast: "#ffe0c2"
93
70
  // colors.gray[800],
94
71
  },
95
-
96
72
  indigo: {
97
73
  // fill: colors.indigo[500],
98
74
  // stroke: colors.indigo[600],
@@ -104,11 +80,3 @@ const Colors = {
104
80
  loContrast: "#c7d2fe"
105
81
  }
106
82
  };
107
- exports.Colors = Colors;
108
- const defaultTheme = {
109
- font: "Helvetica",
110
- shadow: "#0a0a0a",
111
- relation: RelationColors,
112
- colors: Colors
113
- };
114
- exports.defaultTheme = defaultTheme;
@@ -0,0 +1,132 @@
1
+ import { ElementColors } from './element';
2
+ import { RelationshipColors } from './relationships';
3
+ export declare const defaultTheme: {
4
+ elements: {
5
+ readonly primary: {
6
+ fill: "#3b82f6";
7
+ stroke: "#2563eb";
8
+ hiContrast: "#eff6ff";
9
+ loContrast: "#bfdbfe";
10
+ };
11
+ readonly blue: {
12
+ fill: "#3b82f6";
13
+ stroke: "#2563eb";
14
+ hiContrast: "#eff6ff";
15
+ loContrast: "#bfdbfe";
16
+ };
17
+ readonly secondary: {
18
+ fill: "#0284c7";
19
+ stroke: "#0369a1";
20
+ hiContrast: "#f0f9ff";
21
+ loContrast: "#e0f2fe";
22
+ };
23
+ readonly sky: {
24
+ fill: "#0284c7";
25
+ stroke: "#0369a1";
26
+ hiContrast: "#f0f9ff";
27
+ loContrast: "#e0f2fe";
28
+ };
29
+ readonly muted: {
30
+ fill: "#64748b";
31
+ stroke: "#475569";
32
+ hiContrast: "#f8fafc";
33
+ loContrast: "#e2e8f0";
34
+ };
35
+ readonly slate: {
36
+ fill: "#64748b";
37
+ stroke: "#475569";
38
+ hiContrast: "#f8fafc";
39
+ loContrast: "#e2e8f0";
40
+ };
41
+ readonly gray: {
42
+ readonly fill: "#737373";
43
+ readonly stroke: "#525252";
44
+ readonly hiContrast: "#fafafa";
45
+ readonly loContrast: "#e5e5e5";
46
+ };
47
+ readonly red: {
48
+ readonly fill: "#b54548";
49
+ readonly stroke: "#8c333a";
50
+ readonly hiContrast: "#f8fafc";
51
+ readonly loContrast: "#F9C6C6";
52
+ };
53
+ readonly green: {
54
+ readonly fill: "#428a4f";
55
+ readonly stroke: "#2d5d39";
56
+ readonly hiContrast: "#f8fafc";
57
+ readonly loContrast: "#c2f0c2";
58
+ };
59
+ readonly amber: {
60
+ readonly fill: "#d97706";
61
+ readonly stroke: "#b45309";
62
+ readonly hiContrast: "#f8fafc";
63
+ readonly loContrast: "#ffe0c2";
64
+ };
65
+ readonly indigo: {
66
+ readonly fill: "#6366f1";
67
+ readonly stroke: "#4f46e5";
68
+ readonly hiContrast: "#eef2ff";
69
+ readonly loContrast: "#c7d2fe";
70
+ };
71
+ };
72
+ relationships: {
73
+ amber: {
74
+ lineColor: "#b45309";
75
+ labelBgColor: "#78350f";
76
+ labelColor: "#f59e0b";
77
+ };
78
+ blue: {
79
+ lineColor: "#3b82f6";
80
+ labelBgColor: "#172554";
81
+ labelColor: "#60a5fa";
82
+ };
83
+ gray: {
84
+ lineColor: "#6E6E6E";
85
+ labelBgColor: "#18191b";
86
+ labelColor: "#C6C6C6";
87
+ };
88
+ green: {
89
+ lineColor: "#15803d";
90
+ labelBgColor: "#052e16";
91
+ labelColor: "#22c55e";
92
+ };
93
+ indigo: {
94
+ lineColor: "#6366f1";
95
+ labelBgColor: "#1e1b4b";
96
+ labelColor: "#818cf8";
97
+ };
98
+ muted: {
99
+ lineColor: "#64748b";
100
+ labelBgColor: "#0f172a";
101
+ labelColor: "#cbd5e1";
102
+ };
103
+ primary: {
104
+ lineColor: "#3b82f6";
105
+ labelBgColor: "#172554";
106
+ labelColor: "#60a5fa";
107
+ };
108
+ red: {
109
+ lineColor: "#b91c1c";
110
+ labelBgColor: "#b91c1c";
111
+ labelColor: "#dc2626";
112
+ };
113
+ secondary: {
114
+ lineColor: "#0ea5e9";
115
+ labelBgColor: "#082f49";
116
+ labelColor: "#38bdf8";
117
+ };
118
+ sky: {
119
+ lineColor: "#0ea5e9";
120
+ labelBgColor: "#082f49";
121
+ labelColor: "#38bdf8";
122
+ };
123
+ slate: {
124
+ lineColor: "#64748b";
125
+ labelBgColor: "#0f172a";
126
+ labelColor: "#cbd5e1";
127
+ };
128
+ };
129
+ font: "Helvetica";
130
+ shadow: "#0a0a0a";
131
+ };
132
+ export { ElementColors, RelationshipColors };
@@ -0,0 +1,9 @@
1
+ import { ElementColors } from "./element.js";
2
+ import { RelationshipColors } from "./relationships.js";
3
+ export const defaultTheme = {
4
+ elements: ElementColors,
5
+ relationships: RelationshipColors,
6
+ font: "Helvetica",
7
+ shadow: "#0a0a0a"
8
+ };
9
+ export { ElementColors, RelationshipColors };
@@ -0,0 +1,57 @@
1
+ export declare const RelationshipColors: {
2
+ amber: {
3
+ lineColor: "#b45309";
4
+ labelBgColor: "#78350f";
5
+ labelColor: "#f59e0b";
6
+ };
7
+ blue: {
8
+ lineColor: "#3b82f6";
9
+ labelBgColor: "#172554";
10
+ labelColor: "#60a5fa";
11
+ };
12
+ gray: {
13
+ lineColor: "#6E6E6E";
14
+ labelBgColor: "#18191b";
15
+ labelColor: "#C6C6C6";
16
+ };
17
+ green: {
18
+ lineColor: "#15803d";
19
+ labelBgColor: "#052e16";
20
+ labelColor: "#22c55e";
21
+ };
22
+ indigo: {
23
+ lineColor: "#6366f1";
24
+ labelBgColor: "#1e1b4b";
25
+ labelColor: "#818cf8";
26
+ };
27
+ muted: {
28
+ lineColor: "#64748b";
29
+ labelBgColor: "#0f172a";
30
+ labelColor: "#cbd5e1";
31
+ };
32
+ primary: {
33
+ lineColor: "#3b82f6";
34
+ labelBgColor: "#172554";
35
+ labelColor: "#60a5fa";
36
+ };
37
+ red: {
38
+ lineColor: "#b91c1c";
39
+ labelBgColor: "#b91c1c";
40
+ labelColor: "#dc2626";
41
+ };
42
+ secondary: {
43
+ lineColor: "#0ea5e9";
44
+ labelBgColor: "#082f49";
45
+ labelColor: "#38bdf8";
46
+ };
47
+ sky: {
48
+ lineColor: "#0ea5e9";
49
+ labelBgColor: "#082f49";
50
+ labelColor: "#38bdf8";
51
+ };
52
+ slate: {
53
+ lineColor: "#64748b";
54
+ labelBgColor: "#0f172a";
55
+ labelColor: "#cbd5e1";
56
+ };
57
+ };
@@ -0,0 +1,64 @@
1
+ const gray = {
2
+ lineColor: "#6E6E6E",
3
+ labelBgColor: "#18191b",
4
+ labelColor: "#C6C6C6"
5
+ };
6
+ const slate = {
7
+ lineColor: "#64748b",
8
+ // 500
9
+ labelBgColor: "#0f172a",
10
+ // 900
11
+ labelColor: "#cbd5e1"
12
+ // 300
13
+ };
14
+ const blue = {
15
+ lineColor: "#3b82f6",
16
+ // 500
17
+ labelBgColor: "#172554",
18
+ // 950
19
+ labelColor: "#60a5fa"
20
+ // 400
21
+ };
22
+ const sky = {
23
+ lineColor: "#0ea5e9",
24
+ // 500
25
+ labelBgColor: "#082f49",
26
+ // 950
27
+ labelColor: "#38bdf8"
28
+ // 400
29
+ };
30
+ export const RelationshipColors = {
31
+ amber: {
32
+ lineColor: "#b45309",
33
+ labelBgColor: "#78350f",
34
+ labelColor: "#f59e0b"
35
+ },
36
+ blue,
37
+ gray,
38
+ green: {
39
+ lineColor: "#15803d",
40
+ // 700
41
+ labelBgColor: "#052e16",
42
+ //950
43
+ labelColor: "#22c55e"
44
+ // 500
45
+ },
46
+ indigo: {
47
+ lineColor: "#6366f1",
48
+ // 500
49
+ labelBgColor: "#1e1b4b",
50
+ // 950
51
+ labelColor: "#818cf8"
52
+ // 400
53
+ },
54
+ muted: slate,
55
+ primary: blue,
56
+ red: {
57
+ lineColor: "#b91c1c",
58
+ labelBgColor: "#b91c1c",
59
+ labelColor: "#dc2626"
60
+ },
61
+ secondary: sky,
62
+ sky,
63
+ slate
64
+ };
@@ -1,7 +1,5 @@
1
1
  export * from './colors';
2
- export * from './compute-view';
3
2
  export * from './errors';
4
- export * from './model-index';
5
3
  export * from './types';
6
4
  export * from './utils';
7
5
  export type * as likec4 from './types';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,4 @@
1
- export * from "./colors.js";
2
- export * from "./compute-view/index.js";
1
+ export * from "./colors/index.js";
3
2
  export * from "./errors/index.js";
4
- export * from "./model-index/index.js";
5
3
  export * from "./types/index.js";
6
4
  export * from "./utils/index.js";
@@ -1,6 +1,6 @@
1
1
  import type { Opaque } from './opaque';
2
2
  import type { ElementKind, ElementShape, Fqn, Tag } from './element';
3
- import type { RelationID } from './relation';
3
+ import type { RelationID, RelationshipArrowType, RelationshipLineType } from './relation';
4
4
  import type { BasicElementView, ViewID, ViewRuleAutoLayout } from './view';
5
5
  import type { IconUrl, NonEmptyArray } from './_common';
6
6
  import type { ThemeColor } from './theme';
@@ -31,11 +31,14 @@ export interface ComputedEdge {
31
31
  target: NodeId;
32
32
  label: string | null;
33
33
  relations: RelationID[];
34
+ color?: ThemeColor;
35
+ line?: RelationshipLineType;
36
+ head?: RelationshipArrowType;
37
+ tail?: RelationshipArrowType;
34
38
  }
35
- export interface ComputedView extends BasicElementView {
36
- viewOf?: Fqn;
37
- extends?: ViewID;
38
- autoLayout: ViewRuleAutoLayout['autoLayout'];
39
- nodes: ComputedNode[];
40
- edges: ComputedEdge[];
39
+ export interface ComputedView extends Omit<BasicElementView, 'rules'> {
40
+ readonly extends?: ViewID;
41
+ readonly autoLayout: ViewRuleAutoLayout['autoLayout'];
42
+ readonly nodes: ComputedNode[];
43
+ readonly edges: ComputedEdge[];
41
44
  }
@@ -1,6 +1,13 @@
1
1
  import type { ColorLiteral } from './theme';
2
2
  import type { ComputedEdge, ComputedNode, ComputedView } from './computed-view';
3
+ import type { NonEmptyArray } from './_common';
3
4
  export type Point = [x: number, y: number];
5
+ export type BBox = {
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ };
4
11
  export interface DiagramLabel {
5
12
  align: 'left' | 'right' | 'center';
6
13
  fontStyle?: 'bold' | 'normal';
@@ -20,13 +27,15 @@ export interface DiagramNode extends ComputedNode {
20
27
  depth?: number;
21
28
  }
22
29
  export interface DiagramEdge extends ComputedEdge {
23
- points: Point[];
24
- headArrow?: Point[];
25
- labels: DiagramLabel[];
30
+ points: NonEmptyArray<Point>;
31
+ headArrow?: NonEmptyArray<Point>;
32
+ tailArrow?: NonEmptyArray<Point>;
33
+ labels?: NonEmptyArray<DiagramLabel>;
34
+ labelBBox?: BBox;
26
35
  }
27
36
  export interface DiagramView extends Omit<ComputedView, 'nodes' | 'edges'> {
28
37
  readonly nodes: DiagramNode[];
29
38
  readonly edges: DiagramEdge[];
30
- width: number;
31
- height: number;
39
+ readonly width: number;
40
+ readonly height: number;
32
41
  }
@@ -14,7 +14,7 @@ interface BaseExpr {
14
14
  }
15
15
  export interface ElementRefExpr extends Omit<BaseExpr, 'element' | 'isDescedants'> {
16
16
  element: Fqn;
17
- isDescedants: boolean;
17
+ isDescedants?: boolean;
18
18
  }
19
19
  export declare function isElementRef(expr: Expression): expr is ElementRefExpr;
20
20
  export interface WildcardExpr extends Omit<BaseExpr, 'wildcard'> {
@@ -1,10 +1,22 @@
1
1
  import type { Opaque } from './opaque';
2
2
  import type { Fqn, Tag } from './element';
3
+ import type { ThemeColor } from './theme';
3
4
  export type RelationID = Opaque<string, 'RelationID'>;
5
+ export type RelationshipKind = Opaque<string, 'RelationshipKind'>;
6
+ export type RelationshipLineType = 'dashed' | 'solid' | 'dotted';
7
+ export type RelationshipArrowType = 'none' | 'normal' | 'onormal' | 'diamond' | 'odiamond' | 'crow' | 'open' | 'vee';
8
+ export declare const DefaultLineStyle = "dashed";
9
+ export declare const DefaultArrowType = "normal";
10
+ export declare const DefaultRelationshipColor = "gray";
4
11
  export interface Relation {
5
12
  readonly id: RelationID;
6
13
  readonly source: Fqn;
7
14
  readonly target: Fqn;
8
15
  readonly title: string;
9
16
  readonly tags?: Tag[];
17
+ readonly kind?: RelationshipKind;
18
+ readonly color?: ThemeColor;
19
+ readonly line?: RelationshipLineType;
20
+ readonly head?: RelationshipArrowType;
21
+ readonly tail?: RelationshipArrowType;
10
22
  }
@@ -0,0 +1,3 @@
1
+ export const DefaultLineStyle = "dashed";
2
+ export const DefaultArrowType = "normal";
3
+ export const DefaultRelationshipColor = "gray";
@@ -1,28 +1,26 @@
1
1
  export type ThemeColor = 'amber' | 'blue' | 'gray' | 'slate' | 'green' | 'indigo' | 'muted' | 'primary' | 'red' | 'secondary' | 'sky';
2
2
  export type HexColorLiteral = `#${string}`;
3
3
  export type ColorLiteral = HexColorLiteral;
4
- export type InteractiveColor = HexColorLiteral | [
5
- HexColorLiteral,
6
- {
7
- onHover: HexColorLiteral;
8
- }
9
- ];
10
- export interface ThemeColorValues {
4
+ export interface ElementThemeColorValues {
11
5
  fill: ColorLiteral;
12
6
  stroke: ColorLiteral;
13
7
  hiContrast: ColorLiteral;
14
8
  loContrast: ColorLiteral;
15
9
  }
16
- export type ThemeColors = {
17
- [key in ThemeColor]: ThemeColorValues;
10
+ export type ElementThemeColors = {
11
+ [key in ThemeColor]: ElementThemeColorValues;
18
12
  };
19
- export interface ThemeRelationColors {
20
- lineColor: InteractiveColor;
21
- labelColor: InteractiveColor;
13
+ export interface RelationshipThemeColorValues {
14
+ lineColor: ColorLiteral;
15
+ labelBgColor: ColorLiteral;
16
+ labelColor: ColorLiteral;
22
17
  }
18
+ export type RelationshipThemeColors = {
19
+ [key in ThemeColor]: RelationshipThemeColorValues;
20
+ };
23
21
  export interface LikeC4Theme {
24
22
  font: 'Helvetica';
25
23
  shadow: ColorLiteral;
26
- relation: ThemeRelationColors;
27
- colors: ThemeColors;
24
+ relationships: RelationshipThemeColors;
25
+ elements: ElementThemeColors;
28
26
  }