@likec4/core 1.43.0 → 1.45.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 (72) hide show
  1. package/dist/builder/index.d.mts +15 -14
  2. package/dist/builder/index.mjs +35 -18
  3. package/dist/compute-view/index.d.mts +9 -9
  4. package/dist/compute-view/index.mjs +8 -7
  5. package/dist/compute-view/relationships-view/index.d.mts +7 -7
  6. package/dist/compute-view/relationships-view/index.mjs +2 -2
  7. package/dist/index.d.mts +27 -7
  8. package/dist/index.mjs +8 -7
  9. package/dist/model/connection/deployment/index.d.mts +9 -9
  10. package/dist/model/connection/deployment/index.mjs +2 -2
  11. package/dist/model/connection/index.d.mts +10 -10
  12. package/dist/model/connection/index.mjs +3 -3
  13. package/dist/model/connection/model/index.d.mts +9 -9
  14. package/dist/model/connection/model/index.mjs +2 -2
  15. package/dist/model/index.d.mts +11 -11
  16. package/dist/model/index.mjs +4 -4
  17. package/dist/shared/{core.CDvVInBp.d.mts → core.0zAQeenX.d.mts} +3 -3
  18. package/dist/shared/core.3ZhnKAlZ.mjs +106 -0
  19. package/dist/shared/{core.CwsG7hOw.d.mts → core.5ZQ-r3Oa.d.mts} +1 -1
  20. package/dist/shared/{core.hNWo20Ym.d.mts → core.B73yxfPi.d.mts} +55 -36
  21. package/dist/shared/{core.Cq2kxOI-.d.mts → core.BGFjN3nv.d.mts} +3 -3
  22. package/dist/shared/{core.rCeaAqgW.mjs → core.BdPcbSkN.mjs} +1 -1
  23. package/dist/shared/core.BhNcrwzK.mjs +7 -0
  24. package/dist/shared/core.BkVA6gjl.mjs +5 -0
  25. package/dist/shared/core.BuQZczj6.mjs +38 -0
  26. package/dist/shared/{core.2N_9BzyD.mjs → core.CQPEY2wQ.mjs} +5 -4
  27. package/dist/shared/{core.DFi2dOTl.mjs → core.CR3PmPzr.mjs} +85 -1
  28. package/dist/shared/{core.DyToofsP.mjs → core.CRI1AjFj.mjs} +276 -145
  29. package/dist/shared/{core.CXWsKEDr.mjs → core.CWwSgOzF.mjs} +268 -631
  30. package/dist/shared/{core.727Qoh_W.mjs → core.CdNCAwq7.mjs} +2 -101
  31. package/dist/shared/{core.QJD_fcrc.mjs → core.CmPXpJ8l.mjs} +1 -14
  32. package/dist/shared/{core.DTdfiejA.d.mts → core.Cog93roC.d.mts} +2 -2
  33. package/dist/shared/core.Coi_LOUZ.mjs +7 -0
  34. package/dist/shared/{core.CcJ1FZ7h.d.mts → core.CpURdWRM.d.mts} +174 -76
  35. package/dist/shared/{core.D5fzJWbF.d.mts → core.DB0Ue5Wx.d.mts} +1 -1
  36. package/dist/shared/{core.DNbUPnve.mjs → core.DEieYfbG.mjs} +27 -25
  37. package/dist/shared/{core.BYNkXQ8A.mjs → core.DH7TXqXf.mjs} +30 -1
  38. package/dist/shared/{core.DMMOWQqc.mjs → core.DIE3F6sw.mjs} +2 -2
  39. package/dist/shared/{core.D0NziuvN.mjs → core.DViDmiAu.mjs} +5 -5
  40. package/dist/shared/{core.Be05qJwN.mjs → core.D_f4F48-.mjs} +41 -18
  41. package/dist/shared/{core.C2TiyjI6.mjs → core.DbfO90vF.mjs} +20 -31
  42. package/dist/shared/{core.BT-9gaqQ.d.mts → core.DnCLhN8C.d.mts} +83 -94
  43. package/dist/shared/{core.BouyJs63.mjs → core.DqlrMlsf.mjs} +1 -1
  44. package/dist/shared/{core.CNgZvKb8.mjs → core.DrUt0Lbi.mjs} +1 -1
  45. package/dist/shared/{core.CT1xBp4R.d.mts → core.Dvh1H0T2.d.mts} +2 -2
  46. package/dist/shared/core.M9ayqQZa.mjs +1207 -0
  47. package/dist/shared/{core.CvLjw3bH.d.mts → core.mUnpvHtA.d.mts} +96 -12
  48. package/dist/shared/core.oSV6SRfk.mjs +13 -0
  49. package/dist/shared/core.q10OP9oJ.mjs +5 -0
  50. package/dist/shared/{core.BXs4wY7R.d.mts → core.t3qfsVvn.d.mts} +4 -4
  51. package/dist/shared/core.uFk_o9X6.mjs +13 -0
  52. package/dist/shared/core.vzLtp8i3.mjs +1282 -0
  53. package/dist/styles/index.d.mts +18 -8
  54. package/dist/styles/index.mjs +63 -1
  55. package/dist/types/_aux.d.mts +2 -2
  56. package/dist/types/_aux.mjs +8 -1
  57. package/dist/types/expression-model.d.mts +3 -3
  58. package/dist/types/expression.d.mts +3 -3
  59. package/dist/types/fqnRef.d.mts +7 -8
  60. package/dist/types/index.d.mts +17 -13
  61. package/dist/types/index.mjs +51 -14
  62. package/dist/utils/graphology/index.mjs +1 -1
  63. package/dist/utils/index.d.mts +3 -2
  64. package/dist/utils/index.mjs +9 -6
  65. package/dist/utils/iterable/index.d.mts +1 -1
  66. package/dist/utils/iterable/index.mjs +2 -1
  67. package/package.json +18 -17
  68. package/dist/shared/core.01VTr9qu.mjs +0 -170
  69. package/dist/shared/core.1vX5a9AY.mjs +0 -86
  70. package/dist/shared/core.BazD6cot.mjs +0 -14
  71. package/dist/shared/core.BzTakU3I.mjs +0 -67
  72. package/dist/shared/core.OHD4KXm9.mjs +0 -5
@@ -1,9 +1,9 @@
1
- import { Tagged, NonEmptyTuple, PartialDeep, WritableDeep, Except } from 'type-fest';
2
- import { s as BorderStyle, q as ShapeSize, r as SpacingSize, p as TextSize, Q as Color, u as ElementShape, v as RelationshipLineType, y as RelationshipArrowType, b as LikeC4Theme, L as LikeC4StyleDefaults } from './core.CDvVInBp.mjs';
3
- import { I as Icon, M as MarkdownOrString, d as RelationId, P as ProjectId, N as NodeId, j as EdgeId, m as StepEdgeKind } from './core.DX-WYEPA.mjs';
4
- import { A as Any, n as WithOptionalTags, o as WithOptionalLinks, h as StrictViewId, f as _stage, g as _type, F as Fqn, R as RelationKind, W as WithDescriptionAndTech, q as WithMetadata, r as WithNotation, j as ElementKind, x as WithTags, t as DeploymentKind, s as DeploymentFqn } from './core.hNWo20Ym.mjs';
1
+ import { Tagged, NonEmptyTuple, IsNever, PartialDeep, WritableDeep, Except } from 'type-fest';
2
+ import { h as ElementShape, C as Color, B as BorderStyle, e as ShapeSize, S as SpacingSize, d as TextSize, f as RelationshipLineType, g as RelationshipArrowType, T as ThemeColor, G as ColorLiteral, Q as CustomColorDefinitions, a as LikeC4Theme, b as LikeC4StyleDefaults } from './core.0zAQeenX.mjs';
3
+ import { A as Any, s as WithOptionalTags, u as WithOptionalLinks, S as StrictViewId, m as _stage, n as _type, F as Fqn, R as RelationKind, W as WithDescriptionAndTech, v as WithMetadata, w as WithNotation, E as ElementKind, T as Tag, y as DeploymentKind, C as MetadataKey, G as WithTags, x as DeploymentFqn } from './core.B73yxfPi.mjs';
4
+ import { N as NonEmptyArray, E as ExclusiveUnion, a as NonEmptyReadonlyArray, L as Link } from './core.DB0Ue5Wx.mjs';
5
+ import { M as MarkdownOrString, I as Icon, d as RelationId, T as Tag$1, P as ProjectId, N as NodeId, j as EdgeId, m as StepEdgeKind } from './core.DX-WYEPA.mjs';
5
6
  import { FqnRef } from '../types/fqnRef.mjs';
6
- import { N as NonEmptyArray, E as ExclusiveUnion, a as NonEmptyReadonlyArray } from './core.D5fzJWbF.mjs';
7
7
  import { ModelExpression, ModelFqnExpr } from '../types/expression-model.mjs';
8
8
 
9
9
  type Point = readonly [x: number, y: number];
@@ -19,11 +19,20 @@ interface BBox {
19
19
  }
20
20
  declare namespace BBox {
21
21
  function center({ x, y, width, height }: BBox): XYPoint;
22
+ /**
23
+ * Returns the four corner points of the box in clockwise order starting from top-left
24
+ */
25
+ function toPoints({ x, y, width, height }: BBox): [XYPoint, XYPoint, XYPoint, XYPoint];
22
26
  function fromPoints(points: Point[]): BBox;
23
27
  function merge(...boxes: BBox[]): BBox;
28
+ function fromRectBox(rect: RectBox): BBox;
24
29
  function toRectBox(box: BBox): RectBox;
25
30
  function expand(box: BBox, plus: number): BBox;
26
31
  function shrink(box: BBox, minus: number): BBox;
32
+ /**
33
+ * Returns true if `a` includes `b` (i.e. `b` is inside `a`)
34
+ */
35
+ function includes(a: BBox, b: BBox): boolean;
27
36
  }
28
37
  interface RectBox {
29
38
  x1: number;
@@ -36,6 +45,10 @@ declare namespace RectBox {
36
45
  function fromPoints(points: Point[]): RectBox;
37
46
  function merge(...boxes: RectBox[]): RectBox;
38
47
  function toBBox(box: RectBox): BBox;
48
+ /**
49
+ * Returns true if `a` includes `b` (i.e. `b` is inside `a`)
50
+ */
51
+ function includes(a: RectBox, b: RectBox): boolean;
39
52
  }
40
53
 
41
54
  interface AnyIncludePredicate<Expr> {
@@ -82,6 +95,12 @@ interface ViewAutoLayout {
82
95
  rankSep?: number;
83
96
  nodeSep?: number;
84
97
  }
98
+ /**
99
+ * v1 Manual layout of a view, stored in the block comment to the view definition.
100
+ * Keeping this type for backward compatibility and migration purposes.
101
+ *
102
+ * @deprecated Use {@link ViewManualLayoutSnapshot} instead
103
+ */
85
104
  type ViewManualLayout = {
86
105
  readonly hash: string;
87
106
  readonly x: number;
@@ -97,7 +116,6 @@ type ViewManualLayout = {
97
116
  height: number;
98
117
  }>;
99
118
  readonly edges: Record<string, {
100
- dotpos?: string;
101
119
  points: NonEmptyArray<Point>;
102
120
  controlPoints?: NonEmptyArray<XYPoint>;
103
121
  labelBBox?: BBox;
@@ -125,10 +143,6 @@ interface BaseParsedViewProperties<A extends Any> extends BaseViewProperties<A>
125
143
  * Undefined if the view is auto-generated.
126
144
  */
127
145
  readonly docUri?: string | undefined;
128
- /**
129
- * If the view is changed manually this field contains the layout data.
130
- */
131
- readonly manualLayout?: ViewManualLayout | undefined;
132
146
  }
133
147
  type NodeNotation = {
134
148
  kinds: string[];
@@ -320,6 +334,64 @@ interface Relationship<A extends Any = Any> extends AbstractRelationship<A> {
320
334
  */
321
335
  type ModelRelation<A extends Any = Any> = Relationship<A>;
322
336
 
337
+ /**
338
+ * Element and deployment kind specification
339
+ */
340
+ interface ElementSpecification {
341
+ tags?: Tag$1[];
342
+ title?: string;
343
+ summary?: MarkdownOrString;
344
+ description?: MarkdownOrString;
345
+ technology?: string;
346
+ notation?: string;
347
+ links?: NonEmptyArray<Link>;
348
+ style: {
349
+ shape?: ElementShape;
350
+ icon?: Icon;
351
+ color?: Color;
352
+ border?: BorderStyle;
353
+ opacity?: number;
354
+ size?: ShapeSize;
355
+ padding?: SpacingSize;
356
+ textSize?: TextSize;
357
+ multiple?: boolean;
358
+ };
359
+ }
360
+ interface TagSpecification {
361
+ color: ThemeColor | ColorLiteral;
362
+ }
363
+ /**
364
+ * Checks if tag color is defined in the specification
365
+ * Expects HEX, `rgb(...)` or `rgba(...)` color
366
+ */
367
+ declare function isTagColorSpecified(spec: string | TagSpecification): spec is {
368
+ color: ColorLiteral;
369
+ };
370
+ interface RelationshipSpecification {
371
+ technology?: string;
372
+ notation?: string;
373
+ color?: Color;
374
+ line?: RelationshipLineType;
375
+ head?: RelationshipArrowType;
376
+ tail?: RelationshipArrowType;
377
+ }
378
+ type Specification<A> = A extends Any ? {
379
+ tags: {
380
+ [key in Tag<A>]: TagSpecification;
381
+ };
382
+ elements: {
383
+ [key in ElementKind<A>]: Partial<ElementSpecification>;
384
+ };
385
+ deployments: {
386
+ [key in DeploymentKind<A>]: Partial<ElementSpecification>;
387
+ };
388
+ relationships: {
389
+ [key in RelationKind<A>]: Partial<RelationshipSpecification>;
390
+ };
391
+ metadataKeys?: IsNever<MetadataKey<A>> extends true ? never : MetadataKey<A>[];
392
+ customColors?: CustomColorDefinitions;
393
+ } : never;
394
+
323
395
  type LikeC4ProjectTheme = PartialDeep<WritableDeep<LikeC4Theme>, {
324
396
  recurseIntoArrays: false;
325
397
  allowUndefinedInNonTupleArrays: false;
@@ -332,6 +404,9 @@ interface LikeC4ProjectStylesConfig {
332
404
  theme?: LikeC4ProjectTheme;
333
405
  defaults?: LikeC4ProjectStyleDefaults;
334
406
  }
407
+ interface LikeC4ProjectManualLayoutsConfig {
408
+ outDir: string;
409
+ }
335
410
  /**
336
411
  * Configuration of the project, as read from the config file.
337
412
  * LikeC4 projects encapsulate models, and can import from each other
@@ -346,6 +421,10 @@ interface LikeC4Project {
346
421
  * Custom styles
347
422
  */
348
423
  styles?: LikeC4ProjectStylesConfig | undefined;
424
+ /**
425
+ * Configuration for manual layouts snapshots
426
+ */
427
+ manualLayouts?: LikeC4ProjectManualLayoutsConfig | undefined;
349
428
  }
350
429
 
351
430
  type ComputedNodeStyle = Except<ElementStyle, 'icon' | 'shape' | 'color', {
@@ -425,7 +504,12 @@ interface BaseComputedViewProperties<A extends Any> extends BaseViewProperties<A
425
504
  readonly nodes: ComputedNode<A>[];
426
505
  readonly edges: ComputedEdge<A>[];
427
506
  /**
428
- * If the view is changed manually this field contains the layout data.
507
+ * If the view has manual layout (v2)
508
+ */
509
+ readonly hasManualLayout?: boolean;
510
+ /**
511
+ * Manual layout data (v1), for compatibility during migration
512
+ * @deprecated
429
513
  */
430
514
  readonly manualLayout?: ViewManualLayout | undefined;
431
515
  }
@@ -447,4 +531,4 @@ interface ComputedDynamicView<A extends Any = Any> extends BaseComputedViewPrope
447
531
  readonly variant: DynamicViewDisplayVariant;
448
532
  }
449
533
 
450
- export { type DynamicViewIncludeRule as $, type AbstractRelationship as A, BBox as B, type ViewWithNotation as C, type ViewWithHash as D, type ElementStyle as E, type ComputedNodeStyle as F, type GlobalPredicateId as G, type ComputedNode as H, type ComputedEdge as I, type ComputedElementView as J, type ComputedDeploymentView as K, type LikeC4ProjectTheme as L, type ModelGlobals as M, type NodeNotation as N, type ComputedDynamicView as O, type Point as P, type DynamicStep as Q, RectBox as R, type DynamicStepsSeries as S, type DynamicStepsParallel as T, getParallelStepsPrefix as U, type ViewRuleGlobalStyle as V, type DynamicViewStep as W, type XYPoint as X, isDynamicStep as Y, isDynamicStepsParallel as Z, isDynamicStepsSeries as _, type GlobalPredicates as a, type DynamicViewRule as a0, type DynamicViewDisplayVariant as a1, type ParsedDynamicView as a2, type ElementViewIncludePredicate as a3, type ElementViewExcludePredicate as a4, type ElementViewPredicate as a5, type ElementViewRuleGroup as a6, isViewRuleGroup as a7, type ElementViewRuleStyle as a8, type ElementViewRule as a9, type ParsedElementView as aa, type GlobalDynamicPredicates as b, type GlobalStyleID as c, type GlobalStyles as d, ensureSizes as e, type Element as f, type Relationship as g, type ModelRelation as h, type LikeC4ProjectStyleDefaults as i, type LikeC4ProjectStylesConfig as j, type LikeC4Project as k, type AnyIncludePredicate as l, type AnyExcludePredicate as m, type AnyViewRuleStyle as n, isViewRuleGlobalStyle as o, type ViewRuleGlobalPredicateRef as p, isViewRuleGlobalPredicateRef as q, type AutoLayoutDirection as r, isAutoLayoutDirection as s, type ViewRuleAutoLayout as t, isViewRuleAutoLayout as u, type ViewAutoLayout as v, type ViewManualLayout as w, type ViewType as x, type BaseViewProperties as y, type BaseParsedViewProperties as z };
534
+ export { type DynamicStepsParallel as $, type AbstractRelationship as A, BBox as B, type ComputedNodeStyle as C, type ViewManualLayout as D, type ElementStyle as E, type ViewType as F, type GlobalPredicateId as G, type BaseViewProperties as H, type BaseParsedViewProperties as I, type ViewWithNotation as J, type ViewWithHash as K, type LikeC4ProjectStylesConfig as L, type ModelGlobals as M, type NodeNotation as N, type ComputedNode as O, type Point as P, type ComputedEdge as Q, RectBox as R, type Specification as S, type TagSpecification as T, type ComputedElementView as U, type ViewRuleGlobalStyle as V, type ComputedDeploymentView as W, type XYPoint as X, type ComputedDynamicView as Y, type DynamicStep as Z, type DynamicStepsSeries as _, type GlobalPredicates as a, getParallelStepsPrefix as a0, type DynamicViewStep as a1, isDynamicStep as a2, isDynamicStepsParallel as a3, isDynamicStepsSeries as a4, type DynamicViewIncludeRule as a5, type DynamicViewRule as a6, type DynamicViewDisplayVariant as a7, type ParsedDynamicView as a8, type ElementViewIncludePredicate as a9, type ElementViewExcludePredicate as aa, type ElementViewPredicate as ab, type ElementViewRuleGroup as ac, isViewRuleGroup as ad, type ElementViewRuleStyle as ae, type ElementViewRule as af, type ParsedElementView as ag, type GlobalDynamicPredicates as b, type GlobalStyleID as c, type GlobalStyles as d, ensureSizes as e, type Element as f, type Relationship as g, type ModelRelation as h, type ElementSpecification as i, isTagColorSpecified as j, type RelationshipSpecification as k, type LikeC4ProjectTheme as l, type LikeC4ProjectStyleDefaults as m, type LikeC4ProjectManualLayoutsConfig as n, type LikeC4Project as o, type AnyIncludePredicate as p, type AnyExcludePredicate as q, type AnyViewRuleStyle as r, isViewRuleGlobalStyle as s, type ViewRuleGlobalPredicateRef as t, isViewRuleGlobalPredicateRef as u, type AutoLayoutDirection as v, isAutoLayoutDirection as w, type ViewRuleAutoLayout as x, isViewRuleAutoLayout as y, type ViewAutoLayout as z };
@@ -0,0 +1,13 @@
1
+ import { i as invariant } from './core.D4npX2q8.mjs';
2
+
3
+ function stringHash(str) {
4
+ let hash = 5381;
5
+ const len = str.length;
6
+ invariant(len > 0, "stringHash: empty string");
7
+ for (let i = 0; i < len; i++) {
8
+ hash = hash * 33 ^ str.charCodeAt(i);
9
+ }
10
+ return (hash >>> 0).toString(36);
11
+ }
12
+
13
+ export { stringHash as s };
@@ -0,0 +1,5 @@
1
+ import { t as t$1 } from './core.BsSXS-_R.mjs';
2
+
3
+ function t(...t){return t$1(n,t)}const n=(e,t)=>[...e,...t];
4
+
5
+ export { t };
@@ -1,7 +1,7 @@
1
- import { C as Connection, c as customInspectSymbol } from './core.DTdfiejA.mjs';
2
- import { e as DeploymentElementModel, h as RelationshipsAccum, D as DeploymentNodeModel, R as RelationshipModel, b as DeploymentRelationModel } from './core.CcJ1FZ7h.mjs';
3
- import { A as Any, v as EdgeId } from './core.hNWo20Ym.mjs';
4
- import { c as IteratorLike } from './core.D5fzJWbF.mjs';
1
+ import { C as Connection, c as customInspectSymbol } from './core.Cog93roC.mjs';
2
+ import { e as DeploymentElementModel, h as RelationshipsAccum, D as DeploymentNodeModel, R as RelationshipModel, b as DeploymentRelationModel } from './core.CpURdWRM.mjs';
3
+ import { A as Any, z as EdgeId } from './core.B73yxfPi.mjs';
4
+ import { c as IteratorLike } from './core.DB0Ue5Wx.mjs';
5
5
 
6
6
  /**
7
7
  * Connection is ephemeral entity, result of a resolving relationships between source and target.
@@ -0,0 +1,13 @@
1
+ function ihead(iterable) {
2
+ if (!iterable) {
3
+ return _head;
4
+ }
5
+ return _head(iterable);
6
+ }
7
+ function _head(iter) {
8
+ const iterator = iter[Symbol.iterator]();
9
+ const { value } = iterator.next();
10
+ return value;
11
+ }
12
+
13
+ export { ihead as i };