@likec4/core 1.23.1 → 1.24.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 +3 -3
  2. package/dist/builder/index.d.ts +3 -3
  3. package/dist/builder/index.mjs +2 -2
  4. package/dist/compute-view/index.d.mts +4 -4
  5. package/dist/compute-view/index.d.ts +4 -4
  6. package/dist/compute-view/index.mjs +4 -4
  7. package/dist/index.d.mts +7 -8
  8. package/dist/index.d.ts +7 -8
  9. package/dist/index.mjs +4 -4
  10. package/dist/model/index.d.mts +5 -5
  11. package/dist/model/index.d.ts +5 -5
  12. package/dist/model/index.mjs +1 -1
  13. package/dist/shared/{core.3xeQpJ_K.d.cts → core.3L0y_SNW.d.mts} +2 -2
  14. package/dist/shared/{core.QP35c488.d.cts → core.Bhx0OGK8.d.mts} +1 -1
  15. package/dist/shared/{core.QP35c488.d.mts → core.Bhx0OGK8.d.ts} +1 -1
  16. package/dist/shared/{core.DsDq-blc.d.ts → core.BreLKHbT.d.mts} +1 -2
  17. package/dist/shared/{core.DQCc-Jxk.d.ts → core.BsAIrb_r.d.ts} +1 -1
  18. package/dist/shared/{core.GIZxdz4M.mjs → core.C92OYZca.mjs} +1 -1
  19. package/dist/shared/{core.CJaCUZQ9.d.mts → core.C9UbC1nX.d.ts} +1 -2
  20. package/dist/shared/{core.s6UB2oA0.d.ts → core.DBToPQ3n.d.ts} +2 -2
  21. package/dist/shared/{core.1pNr6Ryk.d.ts → core.DbfQeUKm.d.mts} +5 -4
  22. package/dist/shared/core.FFJhmauw.mjs +2078 -0
  23. package/dist/shared/{core.BYs5deiY.d.cts → core.RiWsY3jz.d.mts} +1 -1
  24. package/dist/shared/{core.uGbvOLGK.mjs → core.gWObeLn9.mjs} +28 -9
  25. package/dist/shared/{core.DKJ2y3NP.d.mts → core.k4jahJ8j.d.ts} +5 -4
  26. package/dist/types/index.d.mts +4 -4
  27. package/dist/types/index.d.ts +4 -4
  28. package/dist/types/index.mjs +1 -1
  29. package/dist/utils/index.d.mts +46 -4
  30. package/dist/utils/index.d.ts +46 -4
  31. package/dist/utils/index.mjs +2 -2
  32. package/package.json +3 -27
  33. package/src/compute-view/deployment-view/clean-connections.ts +1 -1
  34. package/src/compute-view/deployment-view/stages/stage-final.ts +1 -1
  35. package/src/compute-view/element-view/compute.ts +1 -1
  36. package/src/compute-view/element-view/memory/memory.ts +1 -1
  37. package/src/compute-view/memory/ops.ts +1 -1
  38. package/src/compute-view/relationships-view/layout.ts +1 -1
  39. package/src/compute-view/relationships-view/utils.ts +1 -1
  40. package/src/model/DeploymentElementModel.ts +4 -6
  41. package/src/model/DeploymentModel.ts +1 -1
  42. package/src/model/LikeC4Model.ts +22 -1
  43. package/src/model/view/LikeC4ViewModel.ts +5 -6
  44. package/src/types/deployments.ts +0 -1
  45. package/src/types/index.ts +1 -1
  46. package/src/types/theme.ts +1 -1
  47. package/src/utils/index.ts +7 -1
  48. package/src/utils/mnemonist.ts +7 -0
  49. package/src/utils/set.ts +5 -3
  50. package/dist/builder/index.cjs +0 -887
  51. package/dist/builder/index.d.cts +0 -509
  52. package/dist/compute-view/index.cjs +0 -86
  53. package/dist/compute-view/index.d.cts +0 -23
  54. package/dist/index.cjs +0 -3857
  55. package/dist/index.d.cts +0 -146
  56. package/dist/model/index.cjs +0 -40
  57. package/dist/model/index.d.cts +0 -259
  58. package/dist/shared/core.BHQYwEvc.d.mts +0 -12
  59. package/dist/shared/core.BS_nXBsP.d.cts +0 -858
  60. package/dist/shared/core.BYiA0A6H.cjs +0 -39
  61. package/dist/shared/core.CEJQrbXY.cjs +0 -441
  62. package/dist/shared/core.D0KD4FiT.d.mts +0 -127
  63. package/dist/shared/core.DEzbhxsA.cjs +0 -14874
  64. package/dist/shared/core.DUbKSpjd.cjs +0 -26
  65. package/dist/shared/core.DqmAHWZs.cjs +0 -7501
  66. package/dist/shared/core.OjOfEBRQ.d.cts +0 -731
  67. package/dist/shared/core.QP35c488.d.ts +0 -185
  68. package/dist/shared/core.f1tiPwpd.mjs +0 -14819
  69. package/dist/types/index.cjs +0 -110
  70. package/dist/types/index.d.cts +0 -72
  71. package/dist/utils/index.cjs +0 -99
  72. package/dist/utils/index.d.cts +0 -340
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@likec4/core",
3
- "version": "1.23.1",
3
+ "version": "1.24.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://likec4.dev",
6
6
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -23,10 +23,6 @@
23
23
  "exports": {
24
24
  ".": {
25
25
  "sources": "./src/index.ts",
26
- "require": {
27
- "types": "./dist/index.d.cts",
28
- "default": "./dist/index.cjs"
29
- },
30
26
  "default": {
31
27
  "types": "./dist/index.d.mts",
32
28
  "import": "./dist/index.mjs",
@@ -35,10 +31,6 @@
35
31
  },
36
32
  "./builder": {
37
33
  "sources": "./src/builder/index.ts",
38
- "require": {
39
- "types": "./dist/builder/index.d.cts",
40
- "default": "./dist/builder/index.cjs"
41
- },
42
34
  "default": {
43
35
  "types": "./dist/builder/index.d.mts",
44
36
  "import": "./dist/builder/index.mjs",
@@ -47,10 +39,6 @@
47
39
  },
48
40
  "./compute-view": {
49
41
  "sources": "./src/compute-view/index.ts",
50
- "require": {
51
- "types": "./dist/compute-view/index.d.cts",
52
- "default": "./dist/compute-view/index.cjs"
53
- },
54
42
  "default": {
55
43
  "types": "./dist/compute-view/index.d.mts",
56
44
  "import": "./dist/compute-view/index.mjs",
@@ -59,10 +47,6 @@
59
47
  },
60
48
  "./model": {
61
49
  "sources": "./src/model/index.ts",
62
- "require": {
63
- "types": "./dist/model/index.d.cts",
64
- "default": "./dist/model/index.cjs"
65
- },
66
50
  "default": {
67
51
  "types": "./dist/model/index.d.mts",
68
52
  "import": "./dist/model/index.mjs",
@@ -71,10 +55,6 @@
71
55
  },
72
56
  "./utils": {
73
57
  "sources": "./src/utils/index.ts",
74
- "require": {
75
- "types": "./dist/utils/index.d.cts",
76
- "default": "./dist/utils/index.cjs"
77
- },
78
58
  "default": {
79
59
  "types": "./dist/utils/index.d.mts",
80
60
  "import": "./dist/utils/index.mjs",
@@ -83,10 +63,6 @@
83
63
  },
84
64
  "./types": {
85
65
  "sources": "./src/types/index.ts",
86
- "require": {
87
- "types": "./dist/types/index.d.cts",
88
- "default": "./dist/types/index.cjs"
89
- },
90
66
  "default": {
91
67
  "types": "./dist/types/index.d.mts",
92
68
  "import": "./dist/types/index.mjs",
@@ -111,7 +87,7 @@
111
87
  "graphology": "^0.25.4",
112
88
  "graphology-dag": "^0.4.1",
113
89
  "graphology-types": "^0.24.8",
114
- "mnemonist": "^0.40.2",
90
+ "mnemonist": "0.40.2",
115
91
  "natural-compare-lite": "^1.4.0",
116
92
  "object-hash": "^3.0.0",
117
93
  "obliterator": "^2.0.5",
@@ -120,7 +96,7 @@
120
96
  "typescript": "5.7.3",
121
97
  "unbuild": "^3.3.1",
122
98
  "vitest": "^3.0.4",
123
- "@likec4/tsconfig": "1.23.1"
99
+ "@likec4/tsconfig": "1.24.0"
124
100
  },
125
101
  "scripts": {
126
102
  "typecheck": "tsc --noEmit",
@@ -1,4 +1,3 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import {
3
2
  dropWhile,
4
3
  filter,
@@ -25,6 +24,7 @@ import { findConnection } from '../../model/connection/deployment'
25
24
  import { RelationshipsAccum } from '../../model/DeploymentElementModel'
26
25
  import type { RelationshipModel } from '../../model/RelationModel'
27
26
  import { imap, toArray } from '../../utils/iterable'
27
+ import { DefaultMap } from '../../utils/mnemonist'
28
28
  import { intersection, union } from '../../utils/set'
29
29
  import type { Connection, Connections } from './_types'
30
30
 
@@ -1,9 +1,9 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { forEach, only, pipe } from 'remeda'
3
2
  import { differenceConnections } from '../../../model/connection'
4
3
  import type { RelationshipModel } from '../../../model/RelationModel'
5
4
  import { isAncestor, sortByFqnHierarchically } from '../../../utils/fqn'
6
5
  import { ifilter, isome, toArray } from '../../../utils/iterable'
6
+ import { DefaultMap } from '../../../utils/mnemonist'
7
7
  import { difference, union } from '../../../utils/set'
8
8
  import { treeFromMemoryState } from '../../memory'
9
9
  import { cleanCrossBoundary, cleanRedundantRelationships } from '../clean-connections'
@@ -1,4 +1,3 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { filter, findLast, forEach, map, pipe } from 'remeda'
3
2
  import { invariant, nonexhaustive, nonNullable } from '../../errors'
4
3
  import { ConnectionModel } from '../../model/connection/model/ConnectionModel'
@@ -17,6 +16,7 @@ import type {
17
16
  import { isViewRuleAutoLayout, isViewRuleGroup, isViewRulePredicate, whereOperatorAsPredicate } from '../../types'
18
17
  import * as Expr from '../../types/expression'
19
18
  import { sortParentsFirst } from '../../utils'
19
+ import { DefaultMap } from '../../utils/mnemonist'
20
20
  import { applyCustomElementProperties } from '../utils/applyCustomElementProperties'
21
21
  import { applyCustomRelationProperties } from '../utils/applyCustomRelationProperties'
22
22
  import { applyViewRuleStyles } from '../utils/applyViewRuleStyles'
@@ -1,8 +1,8 @@
1
- import { Stack } from 'mnemonist'
2
1
  import { nonNullable } from '../../../errors'
3
2
  import type { ConnectionModel } from '../../../model/connection'
4
3
  import type { ElementModel } from '../../../model/ElementModel'
5
4
  import type { Expression, NodeId, ViewRuleGroup } from '../../../types'
5
+ import { Stack } from '../../../utils/mnemonist'
6
6
  import { type ComputeCtx, type CtxElement, type MutableState, type StageExpression, AbstractMemory } from '../../memory'
7
7
  import { NodesGroup } from './NodeGroup'
8
8
  import { ActiveGroupStageExclude, StageExclude } from './stage-exclude'
@@ -1,7 +1,7 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { Connection } from '../../model'
3
2
  import { isAncestor, sortParentsFirst } from '../../utils'
4
3
  import { toArray } from '../../utils/iterable'
4
+ import { DefaultMap } from '../../utils/mnemonist'
5
5
  import type { AnyCtx, ComputeMemory, CtxElement } from './_types'
6
6
 
7
7
  export function treeFromMemoryState<T extends AnyCtx, M extends ComputeMemory<T> = ComputeMemory<T>>(
@@ -1,5 +1,4 @@
1
1
  import dagre, { type EdgeConfig, type GraphLabel } from '@dagrejs/dagre'
2
- import { DefaultMap } from 'mnemonist'
3
2
  import { concat, filter, forEachObj, groupBy, map, mapToObj, pipe, prop, reduce, tap } from 'remeda'
4
3
  import { invariant } from '../../errors'
5
4
  import type { ElementModel } from '../../model/ElementModel'
@@ -7,6 +6,7 @@ import type { RelationshipModel } from '../../model/RelationModel'
7
6
  import type { DiagramNode, DiagramView, Fqn, NodeId } from '../../types'
8
7
  import { sortParentsFirst } from '../../utils'
9
8
  import { toArray } from '../../utils/iterable'
9
+ import { DefaultMap } from '../../utils/mnemonist'
10
10
  import type { RelationshipsViewData } from './_types'
11
11
  import { treeFromElements } from './utils'
12
12
 
@@ -1,8 +1,8 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { nonNullable } from '../../errors'
3
2
  import type { ElementModel } from '../../model/ElementModel'
4
3
  import type { Fqn } from '../../types'
5
4
  import { isAncestor, isDescendantOf, sortParentsFirst } from '../../utils/fqn'
5
+ import { DefaultMap } from '../../utils/mnemonist'
6
6
 
7
7
  export function treeFromElements(elements: Iterable<ElementModel>) {
8
8
  const sorted = sortParentsFirst([...elements]) as ReadonlyArray<ElementModel>
@@ -8,6 +8,7 @@ import {
8
8
  type DeploymentNode,
9
9
  type DeploymentNodeKind,
10
10
  type DeploymentRelation,
11
+ type ElementKind,
11
12
  type ElementShape as C4ElementShape,
12
13
  type IteratorLike,
13
14
  type Link,
@@ -43,6 +44,7 @@ abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux> {
43
44
 
44
45
  abstract readonly $model: LikeC4DeploymentModel<M>
45
46
  abstract readonly $node: DeploymentNode | DeployedInstance
47
+ abstract readonly kind: DeploymentNodeKind | ElementKind
46
48
 
47
49
  get style(): SetRequired<DeploymentElementStyle, 'shape' | 'color' | 'size'> {
48
50
  return {
@@ -65,10 +67,6 @@ abstract class AbstractDeploymentElementModel<M extends AnyAux = AnyAux> {
65
67
  return this.$node.tags ?? []
66
68
  }
67
69
 
68
- get kind(): DeploymentNodeKind | string | null {
69
- return this.$node.kind ?? null
70
- }
71
-
72
70
  get description(): string | null {
73
71
  return this.$node.description ?? null
74
72
  }
@@ -375,8 +373,8 @@ export class DeployedInstanceModel<M extends AnyAux = AnyAux> extends AbstractDe
375
373
  return this.$instance.tags ?? []
376
374
  }
377
375
 
378
- override get kind(): string | null {
379
- return this.$instance.kind ?? null
376
+ override get kind(): ElementKind {
377
+ return this.element.kind
380
378
  }
381
379
 
382
380
  override get description(): string | null {
@@ -1,4 +1,3 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { values } from 'remeda'
3
2
  import type { LiteralUnion } from 'type-fest'
4
3
  import { invariant, nonNullable } from '../errors'
@@ -14,6 +13,7 @@ import {
14
13
  import { ancestorsFqn, parentFqn, sortParentsFirst } from '../utils/fqn'
15
14
  import { getOrCreate } from '../utils/getOrCreate'
16
15
  import { isString } from '../utils/guards'
16
+ import { DefaultMap } from '../utils/mnemonist'
17
17
  import {
18
18
  type DeployedInstancesIterator,
19
19
  type DeploymentElementModel,
@@ -1,4 +1,3 @@
1
- import { DefaultMap } from 'mnemonist'
2
1
  import { mapValues, pipe, sort, values } from 'remeda'
3
2
  import type { LiteralUnion } from 'type-fest'
4
3
  import { computeView, unsafeComputeView } from '../compute-view'
@@ -11,6 +10,7 @@ import type { AnyParsedLikeC4Model, GenericLikeC4Model, LikeC4ModelDump } from '
11
10
  import type { ModelRelation } from '../types/relation'
12
11
  import { compareNatural } from '../utils'
13
12
  import { ancestorsFqn, commonAncestor, parentFqn } from '../utils/fqn'
13
+ import { DefaultMap } from '../utils/mnemonist'
14
14
  import type {
15
15
  DeployedInstanceModel,
16
16
  DeploymentElementModel,
@@ -417,6 +417,27 @@ export class LikeC4Model<M extends AnyAux = LikeC4Model.Any> {
417
417
  }
418
418
 
419
419
  export namespace LikeC4Model {
420
+ export const EMPTY = LikeC4Model.create({
421
+ specification: {
422
+ elements: {},
423
+ relationships: {},
424
+ deployments: {},
425
+ tags: [],
426
+ },
427
+ globals: {
428
+ predicates: {},
429
+ dynamicPredicates: {},
430
+ styles: {},
431
+ },
432
+ deployments: {
433
+ elements: {},
434
+ relations: {},
435
+ },
436
+ elements: {},
437
+ relations: {},
438
+ views: {},
439
+ }) as LikeC4Model<AnyAux>
440
+
420
441
  export type Any = Aux<
421
442
  string,
422
443
  string,
@@ -1,4 +1,3 @@
1
- import { sort } from 'remeda'
2
1
  import { nonNullable } from '../../errors'
3
2
  import type { IteratorLike } from '../../types'
4
3
  import type { Link, Tag } from '../../types/element'
@@ -16,7 +15,7 @@ import {
16
15
  isElementView,
17
16
  isScopedElementView,
18
17
  } from '../../types/view'
19
- import { compareByFqnHierarchically, getOrCreate, ifind } from '../../utils'
18
+ import { DefaultMap, ifind } from '../../utils'
20
19
  import type { ElementModel } from '../ElementModel'
21
20
  import type { LikeC4Model } from '../LikeC4Model'
22
21
  import { type AnyAux, getId } from '../types'
@@ -32,13 +31,13 @@ export class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramV
32
31
  readonly #includeElements = new Set<M['Element']>()
33
32
  readonly #includeDeployments = new Set<M['Deployment']>()
34
33
  readonly #includeRelations = new Set<M['RelationId']>()
35
- readonly #allTags = new Map<Tag, Set<NodeModel<M, V> | EdgeModel<M, V>>>()
34
+ readonly #allTags = new DefaultMap((_key: Tag) => new Set<NodeModel<M, V> | EdgeModel<M, V>>())
36
35
 
37
36
  constructor(
38
37
  public readonly $model: LikeC4Model<M>,
39
38
  public readonly $view: V,
40
39
  ) {
41
- for (const node of sort($view.nodes, compareByFqnHierarchically)) {
40
+ for (const node of $view.nodes) {
42
41
  const el = new NodeModel(this, Object.freeze(node))
43
42
  this.#nodes.set(node.id, el)
44
43
  if (!node.parent) {
@@ -51,7 +50,7 @@ export class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramV
51
50
  this.#includeElements.add(el.element.id)
52
51
  }
53
52
  for (const tag of el.tags) {
54
- getOrCreate(this.#allTags, tag, () => new Set()).add(el)
53
+ this.#allTags.get(tag).add(el)
55
54
  }
56
55
  }
57
56
 
@@ -63,7 +62,7 @@ export class LikeC4ViewModel<M extends AnyAux, V extends ComputedView | DiagramV
63
62
  this.node(edge.target),
64
63
  )
65
64
  for (const tag of edgeModel.tags) {
66
- getOrCreate(this.#allTags, tag, () => new Set()).add(edgeModel)
65
+ this.#allTags.get(tag).add(edgeModel)
67
66
  }
68
67
  for (const rel of edge.relations) {
69
68
  this.#includeRelations.add(rel)
@@ -42,7 +42,6 @@ export interface DeployedInstance {
42
42
  readonly title?: string
43
43
  readonly description?: string | null
44
44
  readonly technology?: string | null
45
- readonly kind?: string | null // TODO: ensure the property is set
46
45
  readonly tags?: NonEmptyArray<Tag> | null
47
46
  readonly links?: NonEmptyArray<Link> | null
48
47
  readonly style?: DeploymentElementStyle
@@ -140,7 +140,7 @@ export type {
140
140
  RelationshipKindSpecification,
141
141
  RelationshipLineType,
142
142
  } from './relation'
143
- export { isThemeColor } from './theme'
143
+ export { isThemeColor, ThemeColors } from './theme'
144
144
  export type {
145
145
  Color,
146
146
  ColorLiteral,
@@ -1,6 +1,6 @@
1
1
  import type { LiteralUnion } from 'type-fest'
2
2
 
3
- const ThemeColors = [
3
+ export const ThemeColors = [
4
4
  'amber',
5
5
  'blue',
6
6
  'gray',
@@ -1,4 +1,10 @@
1
- export { DefaultMap, LinkedList, Queue, Stack } from 'mnemonist'
1
+ export {
2
+ DefaultMap,
3
+ DefaultWeakMap,
4
+ LinkedList,
5
+ Queue,
6
+ Stack,
7
+ } from './mnemonist'
2
8
 
3
9
  export {
4
10
  commonHead,
@@ -0,0 +1,7 @@
1
+ export {
2
+ DefaultMap,
3
+ DefaultWeakMap,
4
+ LinkedList,
5
+ Queue,
6
+ Stack,
7
+ } from 'mnemonist/patch'
package/src/utils/set.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { set } from 'mnemonist'
1
+ import {
2
+ intersection as _intersection,
3
+ symmetricDifference as _symmetricDifference,
4
+ } from 'mnemonist/patch'
5
+
2
6
  import { hasAtLeast } from 'remeda'
3
7
  import type { NonEmptyArray } from '../types/_common'
4
8
 
5
- const { intersection: _intersection, symmetricDifference: _symmetricDifference } = set
6
-
7
9
  /**
8
10
  * Returns new set as a union of given sets
9
11
  * Keeps order of elements