@likec4/core 1.47.0 → 1.48.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 (181) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_chunks/Builder.view-element.mjs +3284 -0
  3. package/dist/_chunks/LikeC4Model.d.mts +1287 -0
  4. package/dist/_chunks/LikeC4Styles.mjs +691 -0
  5. package/dist/_chunks/RichText.d.mts +84 -0
  6. package/dist/_chunks/RichText.mjs +148 -0
  7. package/dist/_chunks/_aux.d.mts +289 -0
  8. package/dist/_chunks/_aux.mjs +18 -0
  9. package/dist/_chunks/_types.d.mts +781 -0
  10. package/dist/_chunks/_types2.d.mts +38 -0
  11. package/dist/_chunks/assignTagColors.mjs +24 -0
  12. package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
  13. package/dist/_chunks/connection.mjs +0 -0
  14. package/dist/_chunks/const.d.mts +43 -0
  15. package/dist/_chunks/const.mjs +33 -0
  16. package/dist/_chunks/expression-model.d.mts +192 -0
  17. package/dist/_chunks/expression-model.mjs +103 -0
  18. package/dist/_chunks/expression.d.mts +347 -0
  19. package/dist/_chunks/expression.mjs +107 -0
  20. package/dist/_chunks/find.d.mts +82 -0
  21. package/dist/_chunks/find.mjs +646 -0
  22. package/dist/_chunks/find2.d.mts +78 -0
  23. package/dist/_chunks/find2.mjs +287 -0
  24. package/dist/_chunks/fqnRef.d.mts +58 -0
  25. package/dist/_chunks/fqnRef.mjs +41 -0
  26. package/dist/_chunks/geometry.mjs +335 -0
  27. package/dist/_chunks/index.d.mts +169 -0
  28. package/dist/_chunks/index2.d.mts +937 -0
  29. package/dist/_chunks/index3.d.mts +146 -0
  30. package/dist/_chunks/index4.d.mts +62 -0
  31. package/dist/_chunks/index5.d.mts +42 -0
  32. package/dist/_chunks/index6.d.mts +43 -0
  33. package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
  34. package/dist/_chunks/index8.d.mts +144 -0
  35. package/dist/_chunks/invariant.mjs +18 -0
  36. package/dist/_chunks/iterable.mjs +146 -0
  37. package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
  38. package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
  39. package/dist/_chunks/libs/bail.mjs +14 -0
  40. package/dist/_chunks/libs/ccount.mjs +25 -0
  41. package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
  42. package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
  43. package/dist/_chunks/libs/character-entities.mjs +2136 -0
  44. package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
  45. package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
  46. package/dist/_chunks/libs/defu.mjs +42 -0
  47. package/dist/_chunks/libs/devlop.mjs +5 -0
  48. package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
  49. package/dist/_chunks/libs/extend.mjs +77 -0
  50. package/dist/_chunks/libs/graphology-dag.mjs +703 -0
  51. package/dist/_chunks/libs/graphology-types.d.mts +601 -0
  52. package/dist/_chunks/libs/graphology.d.mts +6 -0
  53. package/dist/_chunks/libs/graphology.mjs +4565 -0
  54. package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
  55. package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
  56. package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
  57. package/dist/_chunks/libs/longest-streak.mjs +30 -0
  58. package/dist/_chunks/libs/markdown-table.mjs +290 -0
  59. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
  60. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
  61. package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
  62. package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
  63. package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
  64. package/dist/_chunks/libs/mnemonist.d.mts +254 -0
  65. package/dist/_chunks/libs/mnemonist.mjs +1978 -0
  66. package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
  67. package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
  68. package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
  69. package/dist/_chunks/libs/remark-gfm.mjs +36 -0
  70. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
  71. package/dist/_chunks/libs/remark-parse.mjs +39 -0
  72. package/dist/_chunks/libs/remark-rehype.mjs +171 -0
  73. package/dist/_chunks/libs/remeda.mjs +702 -0
  74. package/dist/_chunks/libs/trough.mjs +158 -0
  75. package/dist/_chunks/libs/unified.mjs +2212 -0
  76. package/dist/_chunks/mnemonist.d.mts +1 -0
  77. package/dist/_chunks/mnemonist.mjs +0 -0
  78. package/dist/_chunks/model.mjs +1898 -0
  79. package/dist/_chunks/model2.mjs +0 -0
  80. package/dist/_chunks/relationships-view.mjs +132 -0
  81. package/dist/_chunks/rolldown-runtime.mjs +42 -0
  82. package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
  83. package/dist/_chunks/scalar.mjs +84 -0
  84. package/dist/_chunks/utils.mjs +483 -0
  85. package/dist/builder/index.d.mts +11 -775
  86. package/dist/builder/index.mjs +631 -1022
  87. package/dist/compute-view/index.d.mts +85 -56
  88. package/dist/compute-view/index.mjs +247 -214
  89. package/dist/compute-view/relationships-view/index.d.mts +16 -51
  90. package/dist/compute-view/relationships-view/index.mjs +6 -184
  91. package/dist/geometry/index.d.mts +2 -109
  92. package/dist/geometry/index.mjs +2 -327
  93. package/dist/index.d.mts +18 -20
  94. package/dist/index.mjs +27 -18
  95. package/dist/model/connection/deployment/index.d.mts +12 -15
  96. package/dist/model/connection/deployment/index.mjs +9 -2
  97. package/dist/model/connection/index.d.mts +14 -75
  98. package/dist/model/connection/index.mjs +10 -3
  99. package/dist/model/connection/model/index.d.mts +12 -15
  100. package/dist/model/connection/model/index.mjs +8 -2
  101. package/dist/model/index.d.mts +15 -57
  102. package/dist/model/index.mjs +11 -4
  103. package/dist/styles/index.d.mts +9 -117
  104. package/dist/styles/index.mjs +26 -59
  105. package/dist/types/RichText.d.mts +3 -0
  106. package/dist/types/RichText.mjs +7 -0
  107. package/dist/types/_aux.d.mts +3 -4
  108. package/dist/types/_aux.mjs +2 -7
  109. package/dist/types/expression-model.d.mts +6 -190
  110. package/dist/types/expression-model.mjs +6 -108
  111. package/dist/types/expression.d.mts +5 -6
  112. package/dist/types/expression.mjs +6 -112
  113. package/dist/types/fqnRef.d.mts +4 -60
  114. package/dist/types/fqnRef.mjs +6 -44
  115. package/dist/types/index.d.mts +9 -47
  116. package/dist/types/index.mjs +14 -16
  117. package/dist/types/scalar.d.mts +2 -2
  118. package/dist/types/scalar.mjs +7 -4
  119. package/dist/utils/graphology/index.d.mts +2 -1864
  120. package/dist/utils/graphology/index.mjs +3 -1
  121. package/dist/utils/index.d.mts +11 -124
  122. package/dist/utils/index.mjs +16 -43
  123. package/dist/utils/iterable/index.d.mts +9 -132
  124. package/dist/utils/iterable/index.mjs +2 -61
  125. package/dist/utils/mnemonist.d.mts +2 -0
  126. package/dist/utils/mnemonist.mjs +12 -0
  127. package/package.json +17 -22
  128. package/compute-view/relationships/package.json +0 -4
  129. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  130. package/dist/shared/core.78IWAHAE.mjs +0 -332
  131. package/dist/shared/core.B85MJLTf.mjs +0 -5
  132. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  133. package/dist/shared/core.BKlholso.mjs +0 -3
  134. package/dist/shared/core.BNN-3vPH.mjs +0 -1255
  135. package/dist/shared/core.BPGOjone.d.mts +0 -46
  136. package/dist/shared/core.BP_QHEXs.mjs +0 -785
  137. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  138. package/dist/shared/core.Bdy3hhTc.mjs +0 -28382
  139. package/dist/shared/core.BfCKSW-g.d.mts +0 -1266
  140. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  141. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  142. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  143. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  144. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  145. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  146. package/dist/shared/core.CAgYpDtM.d.mts +0 -98
  147. package/dist/shared/core.CHf8VEa3.mjs +0 -1206
  148. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  149. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  150. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  151. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  152. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  153. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  154. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  155. package/dist/shared/core.CywrQs86.d.mts +0 -31
  156. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  157. package/dist/shared/core.D0WZutNd.mjs +0 -94
  158. package/dist/shared/core.D4npX2q8.mjs +0 -18
  159. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  160. package/dist/shared/core.DC5IAaDT.d.mts +0 -334
  161. package/dist/shared/core.DE9qzhn8.d.mts +0 -83
  162. package/dist/shared/core.DGcIbsj4.mjs +0 -3946
  163. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  164. package/dist/shared/core.DKhRkHRN.d.mts +0 -41
  165. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  166. package/dist/shared/core.DU5SRqNF.mjs +0 -2209
  167. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  168. package/dist/shared/core.DbfO90vF.mjs +0 -434
  169. package/dist/shared/core.DcS-0zys.mjs +0 -10
  170. package/dist/shared/core.Dh119QSP.mjs +0 -4995
  171. package/dist/shared/core.DjcWextK.mjs +0 -1371
  172. package/dist/shared/core.Dojz4bvg.d.mts +0 -504
  173. package/dist/shared/core.FZ305VYd.mjs +0 -21
  174. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  175. package/dist/shared/core.btEq3i3f.mjs +0 -300
  176. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  177. package/dist/shared/core.om36dXXW.mjs +0 -41
  178. package/dist/shared/core.osFs8tU7.d.mts +0 -466
  179. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  180. package/dist/shared/core.tpvDGvdC.d.mts +0 -87
  181. package/dist/shared/core.uFk_o9X6.mjs +0 -13
@@ -0,0 +1,335 @@
1
+ import { Z as t } from "./libs/remeda.mjs";
2
+ import { t as invariant } from "./invariant.mjs";
3
+
4
+ //#region src/geometry/bbox.ts
5
+ let BBox;
6
+ (function(_BBox) {
7
+ function center({ x, y, width, height }) {
8
+ return {
9
+ x: x + width / 2,
10
+ y: y + height / 2
11
+ };
12
+ }
13
+ _BBox.center = center;
14
+ function toPoints({ x, y, width, height }) {
15
+ return [
16
+ {
17
+ x,
18
+ y
19
+ },
20
+ {
21
+ x: x + width,
22
+ y
23
+ },
24
+ {
25
+ x: x + width,
26
+ y: y + height
27
+ },
28
+ {
29
+ x,
30
+ y: y + height
31
+ }
32
+ ];
33
+ }
34
+ _BBox.toPoints = toPoints;
35
+ function fromPoints(points) {
36
+ const { x1, y1, x2, y2 } = RectBox.fromPoints(points);
37
+ return {
38
+ x: x1,
39
+ y: y1,
40
+ width: x2 - x1,
41
+ height: y2 - y1
42
+ };
43
+ }
44
+ _BBox.fromPoints = fromPoints;
45
+ function merge(...boxes) {
46
+ invariant(t(boxes, 1), "No boxes provided");
47
+ if (boxes.length === 1) return boxes[0];
48
+ let minX = boxes[0].x;
49
+ let minY = boxes[0].y;
50
+ let maxX = boxes[0].x + boxes[0].width;
51
+ let maxY = boxes[0].y + boxes[0].height;
52
+ for (let i = 1; i < boxes.length; i++) {
53
+ const box = boxes[i];
54
+ minX = Math.min(minX, box.x);
55
+ minY = Math.min(minY, box.y);
56
+ maxX = Math.max(maxX, box.x + box.width);
57
+ maxY = Math.max(maxY, box.y + box.height);
58
+ }
59
+ return {
60
+ x: Math.floor(minX),
61
+ y: Math.floor(minY),
62
+ width: Math.round(maxX - minX),
63
+ height: Math.round(maxY - minY)
64
+ };
65
+ }
66
+ _BBox.merge = merge;
67
+ function fromRectBox(rect) {
68
+ return {
69
+ x: Math.min(rect.x1, rect.x2),
70
+ y: Math.min(rect.y1, rect.y2),
71
+ width: Math.abs(rect.x2 - rect.x1),
72
+ height: Math.abs(rect.y2 - rect.y1)
73
+ };
74
+ }
75
+ _BBox.fromRectBox = fromRectBox;
76
+ function toRectBox(box) {
77
+ return {
78
+ x1: box.x,
79
+ y1: box.y,
80
+ x2: box.x + box.width,
81
+ y2: box.y + box.height
82
+ };
83
+ }
84
+ _BBox.toRectBox = toRectBox;
85
+ function expand(box, plus) {
86
+ if (plus === 0) return box;
87
+ return {
88
+ x: box.x - plus,
89
+ y: box.y - plus,
90
+ width: box.width + plus * 2,
91
+ height: box.height + plus * 2
92
+ };
93
+ }
94
+ _BBox.expand = expand;
95
+ function shrink(box, minus) {
96
+ if (minus === 0) return box;
97
+ return {
98
+ x: box.x + minus,
99
+ y: box.y + minus,
100
+ width: box.width - minus * 2,
101
+ height: box.height - minus * 2
102
+ };
103
+ }
104
+ _BBox.shrink = shrink;
105
+ function includes(a, b) {
106
+ if (a === b) return true;
107
+ return a.x <= b.x && a.y <= b.y && a.x + a.width >= b.x + b.width && a.y + a.height >= b.y + b.height;
108
+ }
109
+ _BBox.includes = includes;
110
+ })(BBox || (BBox = {}));
111
+ let RectBox;
112
+ (function(_RectBox) {
113
+ function center({ x1, y1, x2, y2 }) {
114
+ return {
115
+ x: (x1 + x2) / 2,
116
+ y: (y1 + y2) / 2
117
+ };
118
+ }
119
+ _RectBox.center = center;
120
+ function fromPoints(points) {
121
+ invariant(points.length > 0, "At least one point is required");
122
+ let minX = Infinity;
123
+ let minY = Infinity;
124
+ let maxX = -Infinity;
125
+ let maxY = -Infinity;
126
+ for (const [x, y] of points) {
127
+ minX = Math.min(minX, x);
128
+ minY = Math.min(minY, y);
129
+ maxX = Math.max(maxX, x);
130
+ maxY = Math.max(maxY, y);
131
+ }
132
+ return {
133
+ x1: minX,
134
+ y1: minY,
135
+ x2: maxX,
136
+ y2: maxY
137
+ };
138
+ }
139
+ _RectBox.fromPoints = fromPoints;
140
+ function merge(...boxes) {
141
+ invariant(boxes.length > 0, "No boxes provided");
142
+ let minX = Infinity;
143
+ let minY = Infinity;
144
+ let maxX = -Infinity;
145
+ let maxY = -Infinity;
146
+ for (const box of boxes) {
147
+ minX = Math.min(minX, box.x1);
148
+ minY = Math.min(minY, box.y1);
149
+ maxX = Math.max(maxX, box.x2);
150
+ maxY = Math.max(maxY, box.y2);
151
+ }
152
+ return {
153
+ x1: minX,
154
+ y1: minY,
155
+ x2: maxX,
156
+ y2: maxY
157
+ };
158
+ }
159
+ _RectBox.merge = merge;
160
+ function toBBox(box) {
161
+ return {
162
+ x: box.x1,
163
+ y: box.y1,
164
+ width: box.x2 - box.x1,
165
+ height: box.y2 - box.y1
166
+ };
167
+ }
168
+ _RectBox.toBBox = toBBox;
169
+ function includes(a, b) {
170
+ if (a === b) return true;
171
+ return a.x1 <= b.x1 && a.y1 <= b.y1 && a.x2 >= b.x2 && a.y2 >= b.y2;
172
+ }
173
+ _RectBox.includes = includes;
174
+ })(RectBox || (RectBox = {}));
175
+
176
+ //#endregion
177
+ //#region src/geometry/vector.ts
178
+ var Vector = class Vector {
179
+ constructor(x, y) {
180
+ this.x = x;
181
+ this.y = y;
182
+ }
183
+ static create(...args) {
184
+ if (args.length === 2) return new Vector(args[0], args[1]);
185
+ return new Vector(args[0].x, args[0].y);
186
+ }
187
+ /**
188
+ * Adds two vectors.
189
+ * @param a The first vector.
190
+ * @param b The second vector.
191
+ * @returns The sum of the two vectors.
192
+ */
193
+ static add(a, b) {
194
+ return {
195
+ x: a.x + b.x,
196
+ y: a.y + b.y
197
+ };
198
+ }
199
+ /**
200
+ * Subtracts two vectors.
201
+ * @param a The first vector.
202
+ * @param b The second vector.
203
+ * @returns The difference of the two vectors.
204
+ */
205
+ static subtract(a, b) {
206
+ return {
207
+ x: a.x - b.x,
208
+ y: a.y - b.y
209
+ };
210
+ }
211
+ /**
212
+ * Multiplies a vector by a scalar.
213
+ * @param a The vector.
214
+ * @param b The scalar.
215
+ * @returns The scaled vector.
216
+ */
217
+ static multiply(a, b) {
218
+ return {
219
+ x: a.x * b,
220
+ y: a.y * b
221
+ };
222
+ }
223
+ /**
224
+ * Divides a vector by a scalar.
225
+ * @param a The vector.
226
+ * @param b The scalar.
227
+ * @returns The scaled vector.
228
+ */
229
+ static divide(a, b) {
230
+ return {
231
+ x: a.x / b,
232
+ y: a.y / b
233
+ };
234
+ }
235
+ /**
236
+ * Calculates the dot product of the vectors.
237
+ * @param a The first vector.
238
+ * @param b The second vector.
239
+ * @returns The dot product.
240
+ */
241
+ static dot(a, b) {
242
+ return a.x * b.x + a.y * b.y;
243
+ }
244
+ /**
245
+ * Adds the given vector to this vector.
246
+ * @param b The vector to add.
247
+ * @returns A new vector that is the sum of this vector and the given vector.
248
+ */
249
+ add(b) {
250
+ return new Vector(this.x + b.x, this.y + b.y);
251
+ }
252
+ /**
253
+ * Subtracts the given vector from this vector.
254
+ * @param b The vector to subtract.
255
+ * @returns A new vector that is the difference of this vector and the given vector.
256
+ */
257
+ subtract(b) {
258
+ return new Vector(this.x - b.x, this.y - b.y);
259
+ }
260
+ /**
261
+ * Multiplies this vector by a scalar.
262
+ * @param b The scalar to multiply by.
263
+ * @returns A new vector that is the product of this vector and the given scalar.
264
+ */
265
+ multiply(b) {
266
+ return new Vector(this.x * b, this.y * b);
267
+ }
268
+ /**
269
+ * Divides this vector by a scalar.
270
+ * @param b The scalar to divide by.
271
+ * @returns A new vector that is the quotient of this vector and the given scalar.
272
+ */
273
+ divide(b) {
274
+ return new Vector(this.x / b, this.y / b);
275
+ }
276
+ /**
277
+ * Calculates the dot product of this vector and another vector.
278
+ * @param b The other vector.
279
+ * @returns The dot product.
280
+ */
281
+ dot(b) {
282
+ return this.x * b.x + this.y * b.y;
283
+ }
284
+ /**
285
+ * Calculates the cross product of this vector and another vector.
286
+ * The cross product of two 2D vectors is a scalar value: a.x * b.y - a.y * b.x
287
+ * @param b The other vector.
288
+ * @returns The cross product as a scalar.
289
+ */
290
+ cross(b) {
291
+ return this.x * b.y - this.y * b.x;
292
+ }
293
+ /**
294
+ * Calculates the length (magnitude) of this vector.
295
+ * @returns The length of the vector.
296
+ */
297
+ length() {
298
+ if (this.x === 0 && this.y === 0) return 0;
299
+ return Math.sqrt(this.x ** 2 + this.y ** 2);
300
+ }
301
+ /**
302
+ * Normalizes the vector (makes it unit length, i.e., has a length of 1).
303
+ * @returns A new vector that is the normalized version of this vector.
304
+ */
305
+ normalize() {
306
+ const len = this.length();
307
+ if (len === 0) return new Vector(0, 0);
308
+ return new Vector(this.x / len, this.y / len);
309
+ }
310
+ /**
311
+ * Rounds the components of the vector to the nearest integers.
312
+ * @returns A new vector with rounded components.
313
+ */
314
+ round() {
315
+ return new Vector(Math.round(this.x), Math.round(this.y));
316
+ }
317
+ /**
318
+ * Converts the vector to a plain object.
319
+ * @returns An object with x and y properties.
320
+ */
321
+ toObject() {
322
+ return {
323
+ x: this.x,
324
+ y: this.y
325
+ };
326
+ }
327
+ };
328
+ function vector(...args) {
329
+ if (args.length === 1 && args[0] instanceof Vector) return args[0];
330
+ if (args.length === 2) return new Vector(args[0], args[1]);
331
+ return new Vector(args[0].x, args[0].y);
332
+ }
333
+
334
+ //#endregion
335
+ export { RectBox as i, vector as n, BBox as r, Vector as t };
@@ -0,0 +1,169 @@
1
+ //#region src/geometry/bbox.d.ts
2
+ type Point = readonly [x: number, y: number];
3
+ interface XYPoint {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ interface BBox {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }
13
+ declare namespace BBox {
14
+ function center({
15
+ x,
16
+ y,
17
+ width,
18
+ height
19
+ }: BBox): XYPoint;
20
+ /**
21
+ * Returns the four corner points of the box in clockwise order starting from top-left
22
+ */
23
+ function toPoints({
24
+ x,
25
+ y,
26
+ width,
27
+ height
28
+ }: BBox): [XYPoint, XYPoint, XYPoint, XYPoint];
29
+ function fromPoints(points: Point[]): BBox;
30
+ function merge(...boxes: BBox[]): BBox;
31
+ function fromRectBox(rect: RectBox): BBox;
32
+ function toRectBox(box: BBox): RectBox;
33
+ function expand(box: BBox, plus: number): BBox;
34
+ function shrink(box: BBox, minus: number): BBox;
35
+ /**
36
+ * Returns true if `a` includes `b` (i.e. `b` is inside `a`)
37
+ */
38
+ function includes(a: BBox, b: BBox): boolean;
39
+ }
40
+ interface RectBox {
41
+ x1: number;
42
+ y1: number;
43
+ x2: number;
44
+ y2: number;
45
+ }
46
+ declare namespace RectBox {
47
+ function center({
48
+ x1,
49
+ y1,
50
+ x2,
51
+ y2
52
+ }: RectBox): XYPoint;
53
+ function fromPoints(points: Point[]): RectBox;
54
+ function merge(...boxes: RectBox[]): RectBox;
55
+ function toBBox(box: RectBox): BBox;
56
+ /**
57
+ * Returns true if `a` includes `b` (i.e. `b` is inside `a`)
58
+ */
59
+ function includes(a: RectBox, b: RectBox): boolean;
60
+ }
61
+ //#endregion
62
+ //#region src/geometry/vector.d.ts
63
+ interface VectorValue {
64
+ readonly x: number;
65
+ readonly y: number;
66
+ }
67
+ declare class Vector implements VectorValue {
68
+ readonly x: number;
69
+ readonly y: number;
70
+ constructor(x: number, y: number);
71
+ static create(position: VectorValue): Vector;
72
+ static create(x: number, y: number): Vector;
73
+ /**
74
+ * Adds two vectors.
75
+ * @param a The first vector.
76
+ * @param b The second vector.
77
+ * @returns The sum of the two vectors.
78
+ */
79
+ static add(a: VectorValue, b: VectorValue): VectorValue;
80
+ /**
81
+ * Subtracts two vectors.
82
+ * @param a The first vector.
83
+ * @param b The second vector.
84
+ * @returns The difference of the two vectors.
85
+ */
86
+ static subtract(a: VectorValue, b: VectorValue): VectorValue;
87
+ /**
88
+ * Multiplies a vector by a scalar.
89
+ * @param a The vector.
90
+ * @param b The scalar.
91
+ * @returns The scaled vector.
92
+ */
93
+ static multiply(a: VectorValue, b: number): VectorValue;
94
+ /**
95
+ * Divides a vector by a scalar.
96
+ * @param a The vector.
97
+ * @param b The scalar.
98
+ * @returns The scaled vector.
99
+ */
100
+ static divide(a: VectorValue, b: number): VectorValue;
101
+ /**
102
+ * Calculates the dot product of the vectors.
103
+ * @param a The first vector.
104
+ * @param b The second vector.
105
+ * @returns The dot product.
106
+ */
107
+ static dot(a: VectorValue, b: VectorValue): number;
108
+ /**
109
+ * Adds the given vector to this vector.
110
+ * @param b The vector to add.
111
+ * @returns A new vector that is the sum of this vector and the given vector.
112
+ */
113
+ add(b: VectorValue): Vector;
114
+ /**
115
+ * Subtracts the given vector from this vector.
116
+ * @param b The vector to subtract.
117
+ * @returns A new vector that is the difference of this vector and the given vector.
118
+ */
119
+ subtract(b: VectorValue): Vector;
120
+ /**
121
+ * Multiplies this vector by a scalar.
122
+ * @param b The scalar to multiply by.
123
+ * @returns A new vector that is the product of this vector and the given scalar.
124
+ */
125
+ multiply(b: number): Vector;
126
+ /**
127
+ * Divides this vector by a scalar.
128
+ * @param b The scalar to divide by.
129
+ * @returns A new vector that is the quotient of this vector and the given scalar.
130
+ */
131
+ divide(b: number): Vector;
132
+ /**
133
+ * Calculates the dot product of this vector and another vector.
134
+ * @param b The other vector.
135
+ * @returns The dot product.
136
+ */
137
+ dot(b: VectorValue): number;
138
+ /**
139
+ * Calculates the cross product of this vector and another vector.
140
+ * The cross product of two 2D vectors is a scalar value: a.x * b.y - a.y * b.x
141
+ * @param b The other vector.
142
+ * @returns The cross product as a scalar.
143
+ */
144
+ cross(b: VectorValue): number;
145
+ /**
146
+ * Calculates the length (magnitude) of this vector.
147
+ * @returns The length of the vector.
148
+ */
149
+ length(): number;
150
+ /**
151
+ * Normalizes the vector (makes it unit length, i.e., has a length of 1).
152
+ * @returns A new vector that is the normalized version of this vector.
153
+ */
154
+ normalize(): Vector;
155
+ /**
156
+ * Rounds the components of the vector to the nearest integers.
157
+ * @returns A new vector with rounded components.
158
+ */
159
+ round(): Vector;
160
+ /**
161
+ * Converts the vector to a plain object.
162
+ * @returns An object with x and y properties.
163
+ */
164
+ toObject(): VectorValue;
165
+ }
166
+ declare function vector(source: VectorValue | Vector): Vector;
167
+ declare function vector(x: number, y: number): Vector;
168
+ //#endregion
169
+ export { Point as a, BBox as i, VectorValue as n, RectBox as o, vector as r, XYPoint as s, Vector as t };