@likec4/core 1.32.2 → 1.34.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 (113) hide show
  1. package/dist/builder/index.d.mts +6 -4
  2. package/dist/builder/index.mjs +45 -13
  3. package/dist/compute-view/index.d.mts +6 -4
  4. package/dist/compute-view/index.mjs +33 -10
  5. package/dist/compute-view/relationships-view/index.d.mts +6 -4
  6. package/dist/compute-view/relationships-view/index.mjs +6 -3
  7. package/dist/index.d.mts +9 -138
  8. package/dist/index.mjs +31 -3712
  9. package/dist/model/connection/deployment/index.d.mts +10 -0
  10. package/dist/model/connection/deployment/index.mjs +18 -0
  11. package/dist/model/connection/index.d.mts +70 -0
  12. package/dist/model/connection/index.mjs +23 -0
  13. package/dist/model/connection/model/index.d.mts +10 -0
  14. package/dist/model/connection/model/index.mjs +11 -0
  15. package/dist/model/index.d.mts +14 -256
  16. package/dist/model/index.mjs +27 -5
  17. package/dist/shared/{core.cbA9VZ02.mjs → core.4SpVCM9m.mjs} +31 -1073
  18. package/dist/shared/{core.BuO4ncfY.d.mts → core.668kXpZq.d.mts} +42 -52
  19. package/dist/shared/core.8KM0D6va.mjs +33 -0
  20. package/dist/shared/core.B0oEIXqd.mjs +47 -0
  21. package/dist/shared/core.BH9nN-_I.mjs +22 -0
  22. package/dist/shared/core.BMCb0wJI.mjs +177 -0
  23. package/dist/shared/core.BTnf14gD.mjs +331 -0
  24. package/dist/shared/core.BgvIuGGU.mjs +3 -0
  25. package/dist/shared/core.BoyJPEen.mjs +21 -0
  26. package/dist/shared/{core.CUYDgv2-.mjs → core.Br7Fab9l.mjs} +12 -15
  27. package/dist/shared/{core.BrCnZFTn.mjs → core.Btl47GOn.mjs} +3 -3
  28. package/dist/shared/core.ByrmCl9I.mjs +5 -0
  29. package/dist/shared/core.C80Z37Eu.mjs +29 -0
  30. package/dist/shared/{core.Pf5I9o0e.d.mts → core.CF82MWyh.d.mts} +1 -1
  31. package/dist/shared/core.CJSFKrYf.d.mts +83 -0
  32. package/dist/shared/{core.rmvsy0n3.mjs → core.C_C-3c1S.mjs} +5 -198
  33. package/dist/shared/{core.DoK86JEe.mjs → core.CpwrZi3D.mjs} +2 -73
  34. package/dist/shared/{core.CpXlRyE5.mjs → core.CtKXPqN_.mjs} +5 -36
  35. package/dist/shared/core.CxGKeL-L.mjs +144 -0
  36. package/dist/shared/core.CzdwsPmY.d.mts +69 -0
  37. package/dist/shared/core.D3xEWj5B.d.mts +41 -0
  38. package/dist/shared/{core.Cy9smucx.mjs → core.D4npX2q8.mjs} +1 -3
  39. package/dist/shared/core.D56nCp7e.mjs +168 -0
  40. package/dist/shared/core.D5qVzkws.mjs +724 -0
  41. package/dist/shared/{core.CBxTtXMi.d.mts → core.DAj3LuFH.d.mts} +58 -57
  42. package/dist/shared/{core.Bk7wEZFG.mjs → core.DXRAwwDB.mjs} +3 -2
  43. package/dist/shared/core.DcS-0zys.mjs +10 -0
  44. package/dist/shared/core.Di7__sMg.d.mts +87 -0
  45. package/dist/shared/{core.DaAyklhe.d.mts → core.DrS4Bf4y.d.mts} +31 -22
  46. package/dist/shared/core.DsMrjY2q.mjs +34 -0
  47. package/dist/shared/core.DuSLYTG6.d.mts +57 -0
  48. package/dist/shared/{core.Bdz6fBF1.d.mts → core.IWLie-Ma.d.mts} +92 -81
  49. package/dist/shared/{core.CBpKAlhj.mjs → core.PqNe5WxQ.mjs} +96 -56
  50. package/dist/shared/core.XptQjhMA.mjs +1295 -0
  51. package/dist/shared/core.zLlww-07.mjs +3 -0
  52. package/dist/theme/index.d.mts +134 -0
  53. package/dist/theme/index.mjs +3709 -0
  54. package/dist/types/_aux.d.mts +4 -0
  55. package/dist/types/index.d.mts +9 -5
  56. package/dist/types/index.mjs +17 -146
  57. package/dist/utils/index.d.mts +15 -100
  58. package/dist/utils/index.mjs +25 -1315
  59. package/dist/utils/iterable/index.d.mts +100 -0
  60. package/dist/utils/iterable/index.mjs +24 -0
  61. package/package.json +29 -13
  62. package/src/builder/Builder.ts +13 -4
  63. package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +0 -13
  64. package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +2 -6
  65. package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +0 -7
  66. package/src/compute-view/deployment-view/__test__/fixture.ts +15 -5
  67. package/src/compute-view/deployment-view/utils.ts +13 -13
  68. package/src/compute-view/dynamic-view/compute.ts +2 -1
  69. package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +2 -2
  70. package/src/compute-view/relationships-view/layout.ts +1 -1
  71. package/src/compute-view/utils/applyCustomElementProperties.ts +8 -0
  72. package/src/compute-view/utils/applyCustomRelationProperties.ts +2 -0
  73. package/src/compute-view/utils/buildComputedNodes.ts +4 -3
  74. package/src/compute-view/utils/merge-props-from-relationships.ts +6 -5
  75. package/src/compute-view/utils/view-hash.ts +24 -3
  76. package/src/model/DeploymentElementModel.ts +21 -17
  77. package/src/model/DeploymentModel.ts +1 -1
  78. package/src/model/ElementModel.ts +15 -5
  79. package/src/model/LikeC4Model.ts +1 -1
  80. package/src/model/RelationModel.ts +20 -17
  81. package/src/model/index.ts +2 -0
  82. package/src/model/types.ts +2 -1
  83. package/src/model/view/EdgeModel.ts +4 -3
  84. package/src/model/view/LikeC4ViewModel.ts +6 -1
  85. package/src/model/view/NodeModel.ts +5 -3
  86. package/src/theme/index.ts +12 -5
  87. package/src/types/RichText.ts +200 -0
  88. package/src/types/expression-model.ts +2 -2
  89. package/src/types/expression.ts +2 -2
  90. package/src/types/fqnRef.ts +2 -2
  91. package/src/types/global.ts +1 -1
  92. package/src/types/index.ts +4 -2
  93. package/src/types/model-data.ts +2 -2
  94. package/src/types/model-deployment.ts +6 -5
  95. package/src/types/model-dump.ts +1 -1
  96. package/src/types/model-logical.ts +5 -5
  97. package/src/types/model-spec.ts +2 -2
  98. package/src/types/operators.ts +2 -2
  99. package/src/types/scalar.ts +47 -2
  100. package/src/types/view-common.ts +3 -3
  101. package/src/types/view-computed.ts +4 -6
  102. package/src/types/view-layouted.ts +11 -2
  103. package/src/types/view-parsed.deployment.ts +1 -1
  104. package/src/types/view-parsed.dynamic.ts +2 -2
  105. package/src/types/view-parsed.element.ts +2 -2
  106. package/src/types/view.ts +2 -2
  107. package/src/utils/index.ts +4 -9
  108. package/src/utils/markdown/index.ts +2 -0
  109. package/src/utils/markdown/to-html.ts +32 -0
  110. package/src/utils/markdown/to-text.ts +14 -0
  111. package/dist/types/aux.d.mts +0 -3
  112. /package/dist/types/{aux.mjs → _aux.mjs} +0 -0
  113. /package/src/types/{aux.ts → _aux.ts} +0 -0
@@ -0,0 +1,168 @@
1
+ import { m as memoizeProp, b as markdownToText, a as markdownToHtml } from './core.B0oEIXqd.mjs';
2
+ import { n as nonexhaustive } from './core.D4npX2q8.mjs';
3
+
4
+ function n(e){return !!e}
5
+
6
+ const DefaultThemeColor = "primary";
7
+ const DefaultElementShape = "rectangle";
8
+ const DefaultShapeSize = "md";
9
+ const DefaultPaddingSize = "md";
10
+ const DefaultTextSize = "md";
11
+ const DefaultLineStyle = "dashed";
12
+ const DefaultArrowType = "normal";
13
+ const DefaultRelationshipColor = "gray";
14
+
15
+ const richtxt = Symbol.for("richtxt");
16
+ const symb_text = Symbol.for("text");
17
+ const symb_html = Symbol.for("html");
18
+ const emptyTxt = "";
19
+ class RichText {
20
+ static _cache = /* @__PURE__ */ new WeakMap();
21
+ /**
22
+ * Creates and memoizes a RichText instance.
23
+ * @see ElementModel.description
24
+ * @example
25
+ *
26
+ * get description(): RichTextOrEmpty {
27
+ * return RichText.memoize(this, this.$element.description)
28
+ * }
29
+ */
30
+ static memoize(obj, source) {
31
+ return memoizeProp(obj, richtxt, () => RichText.from(source));
32
+ }
33
+ /**
34
+ * Creates a RichText instance from a source.
35
+ */
36
+ static from(source) {
37
+ if (source === null || source === void 0 || source === RichText.EMPTY) {
38
+ return RichText.EMPTY;
39
+ }
40
+ if (source instanceof RichText) {
41
+ return source;
42
+ }
43
+ if (typeof source === "string") {
44
+ return RichText.from({ txt: source });
45
+ }
46
+ if ("isEmpty" in source && source.isEmpty) {
47
+ return RichText.EMPTY;
48
+ }
49
+ if ("md" in source && source.md.trim() === emptyTxt) {
50
+ return RichText.EMPTY;
51
+ }
52
+ if ("txt" in source && source.txt.trim() === emptyTxt) {
53
+ return RichText.EMPTY;
54
+ }
55
+ const _source = source;
56
+ const cached = RichText._cache.get(_source);
57
+ if (cached) {
58
+ return cached;
59
+ }
60
+ const rt = new RichText(_source);
61
+ RichText._cache.set(_source, rt);
62
+ return rt;
63
+ }
64
+ /**
65
+ * This is a workaround for the fact that we need instance of RichText for `instanceof` checks
66
+ * It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty
67
+ */
68
+ static EMPTY = new class extends RichText {
69
+ isEmpty = true;
70
+ nonEmpty = false;
71
+ isMarkdown = false;
72
+ $source = null;
73
+ constructor() {
74
+ super({ txt: emptyTxt });
75
+ }
76
+ get text() {
77
+ return null;
78
+ }
79
+ get md() {
80
+ return null;
81
+ }
82
+ get html() {
83
+ return null;
84
+ }
85
+ }();
86
+ $source;
87
+ isEmpty;
88
+ nonEmpty;
89
+ isMarkdown;
90
+ /**
91
+ * Private constructor to prevent direct instantiation.
92
+ * Use {@link RichText.from} or {@link RichText.memoize} instead.
93
+ */
94
+ constructor(source) {
95
+ this.isMarkdown = false;
96
+ if (typeof source === "string") {
97
+ this.$source = { txt: source };
98
+ this.isEmpty = source.trim() === emptyTxt;
99
+ } else {
100
+ this.$source = source;
101
+ this.isEmpty = true;
102
+ if ("md" in source) {
103
+ this.isEmpty = source.md === emptyTxt;
104
+ this.isMarkdown = true;
105
+ } else {
106
+ this.isEmpty = source.txt === emptyTxt;
107
+ }
108
+ }
109
+ this.nonEmpty = !this.isEmpty;
110
+ }
111
+ /**
112
+ * Returns the text content of the rich text.
113
+ * If the source is a string, it returns the string.
114
+ * If the source is a markdown, it returns the markdown.
115
+ */
116
+ get text() {
117
+ if (this.isEmpty || this.$source === null) {
118
+ return emptyTxt;
119
+ }
120
+ const source = this.$source;
121
+ if ("txt" in source) {
122
+ return source.txt;
123
+ }
124
+ return memoizeProp(this, symb_text, () => markdownToText(source.md));
125
+ }
126
+ /**
127
+ * Returns the markdown content of the rich text.
128
+ * If the source is a string, it returns the string.
129
+ * If the source is a markdown, it returns the markdown.
130
+ */
131
+ get md() {
132
+ if (this.isEmpty || this.$source === null) {
133
+ return emptyTxt;
134
+ }
135
+ const source = this.$source;
136
+ if ("md" in source) {
137
+ return source.md;
138
+ }
139
+ if ("txt" in source) {
140
+ return source.txt;
141
+ }
142
+ nonexhaustive(source);
143
+ }
144
+ /**
145
+ * Returns the html content of the rich text.
146
+ * If the source is a string, it returns the string.
147
+ * If the source is a markdown, it returns the HTML.
148
+ */
149
+ get html() {
150
+ if (this.isEmpty || this.$source === null) {
151
+ return emptyTxt;
152
+ }
153
+ const markdown = this.$source.md ?? this.$source.txt;
154
+ return memoizeProp(this, symb_html, () => markdownToHtml(markdown));
155
+ }
156
+ equals(other) {
157
+ if (this === other) return true;
158
+ if (!(other instanceof RichText)) return false;
159
+ if (this.isEmpty && other.isEmpty) return true;
160
+ if (this.isEmpty !== other.isEmpty || this.isMarkdown !== other.isMarkdown) return false;
161
+ if (this.isMarkdown) {
162
+ return this.$source?.md === other.$source?.md;
163
+ }
164
+ return this.$source?.txt === other.$source?.txt;
165
+ }
166
+ }
167
+
168
+ export { DefaultThemeColor as D, RichText as R, DefaultElementShape as a, DefaultShapeSize as b, DefaultPaddingSize as c, DefaultTextSize as d, DefaultLineStyle as e, DefaultArrowType as f, DefaultRelationshipColor as g, n };