@likec4/language-server 1.12.1 → 1.13.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 (43) hide show
  1. package/dist/browser.cjs +1 -1
  2. package/dist/browser.d.cts +2 -2
  3. package/dist/browser.d.mts +2 -2
  4. package/dist/browser.d.ts +2 -2
  5. package/dist/browser.mjs +2 -2
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +2 -2
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.mjs +2 -2
  11. package/dist/model-graph/index.cjs +1 -1
  12. package/dist/model-graph/index.d.cts +1 -1
  13. package/dist/model-graph/index.d.mts +1 -1
  14. package/dist/model-graph/index.d.ts +1 -1
  15. package/dist/model-graph/index.mjs +1 -1
  16. package/dist/shared/{language-server.CzkWpuWT.d.mts → language-server.B-9_mDoo.d.mts} +7 -2
  17. package/dist/shared/{language-server.BH0brgLf.cjs → language-server.C2ebP2pZ.cjs} +80 -90
  18. package/dist/shared/{language-server.DJAHXekh.d.cts → language-server.C3oS5yhF.d.cts} +7 -2
  19. package/dist/shared/{language-server.3Bh0zvVS.cjs → language-server.CbDa016p.cjs} +9 -7
  20. package/dist/shared/{language-server.DtLmc4Fz.d.cts → language-server.Cnq_hgfm.d.cts} +6 -1
  21. package/dist/shared/{language-server.BYjS7OIz.mjs → language-server.CrE0nFSB.mjs} +79 -89
  22. package/dist/shared/{language-server.BxxqS4Id.mjs → language-server.DFLaUdYu.mjs} +7 -6
  23. package/dist/shared/{language-server.BCDM5gt9.d.ts → language-server.eY70DuKx.d.ts} +6 -1
  24. package/dist/shared/{language-server.B8Ce0R_D.d.ts → language-server.r5AXAWzc.d.ts} +7 -2
  25. package/dist/shared/{language-server.BN7V1vQA.d.mts → language-server.ryB8CivX.d.mts} +6 -1
  26. package/package.json +7 -7
  27. package/src/ast.ts +1 -1
  28. package/src/generated/ast.ts +3 -1
  29. package/src/generated/grammar.ts +1 -1
  30. package/src/like-c4.langium +4 -2
  31. package/src/lsp/CompletionProvider.ts +2 -2
  32. package/src/model/model-parser.ts +78 -69
  33. package/src/model-change/ModelChanges.ts +0 -28
  34. package/src/model-change/changeViewLayout.ts +5 -5
  35. package/src/model-graph/compute-view/compute.ts +1 -1
  36. package/src/model-graph/dynamic-view/compute.ts +1 -1
  37. package/src/model-graph/utils/sortNodes.ts +3 -3
  38. package/src/test/testServices.ts +9 -5
  39. package/src/utils/graphlib.ts +5 -7
  40. package/src/validation/_shared.ts +2 -1
  41. package/src/validation/index.ts +0 -2
  42. package/src/validation/specification.ts +0 -11
  43. package/src/view-utils/resolve-extended-views.ts +2 -2
@@ -1,6 +1,6 @@
1
1
  import { Expr, whereOperatorAsPredicate, parentFqn, nonexhaustive, isViewRuleStyle, compareByFqnHierarchically, DefaultThemeColor, DefaultElementShape, compareRelations, invariant, nonNullable, compareNatural, hasAtLeast, isAncestor, isViewRulePredicate, ancestorsFqn, isViewRuleAutoLayout, isScopedElementView, commonAncestor, StepEdgeId, isDynamicViewParallelSteps, isDynamicViewIncludeRule, DefaultRelationshipColor, DefaultLineStyle, DefaultArrowType, isSameHierarchy } from '@likec4/core';
2
2
  import { pipe, map, pick, mapToObj, isTruthy, isNullish, omitBy, isEmpty, filter, anyPass, isDefined, groupBy, prop, mapValues, piped, unique, entries, flatMap, sortBy, sort, difference, allPass, omit, hasAtLeast as hasAtLeast$1, only, reduce, isNonNull, isString, isArray } from 'remeda';
3
- import graphlib, { Graph } from '@dagrejs/graphlib';
3
+ import dagre from '@dagrejs/dagre';
4
4
  import objectHash from 'object-hash';
5
5
 
6
6
  function calcViewLayoutHash(view) {
@@ -298,9 +298,10 @@ function buildElementNotations(nodes) {
298
298
  );
299
299
  }
300
300
 
301
- const postorder = graphlib.alg.postorder;
302
- const findCycles = graphlib.alg.findCycles;
303
- const isAcyclic = graphlib.alg.isAcyclic;
301
+ const Graph = dagre.graphlib.Graph;
302
+ const postorder = dagre.graphlib.alg.postorder;
303
+ const findCycles = dagre.graphlib.alg.findCycles;
304
+ const isAcyclic = dagre.graphlib.alg.isAcyclic;
304
305
 
305
306
  function sortChildren(nodes) {
306
307
  nodes.forEach((parent) => {
@@ -333,7 +334,7 @@ function sortNodes({
333
334
  g.setEdge(e.source, e.target);
334
335
  }
335
336
  for (const n of nodes) {
336
- g.setNode(n.id);
337
+ g.setNode(n.id, n.id);
337
338
  if (n.children.length > 0) {
338
339
  n.inEdges.forEach((e) => {
339
340
  const edge = getEdge(e);
@@ -1675,4 +1676,4 @@ class LikeC4ModelGraph {
1675
1676
  }
1676
1677
  }
1677
1678
 
1678
- export { LikeC4ModelGraph as L, computeView as a, computeDynamicView as b, computeElementView as c, findCycles as f, isAcyclic as i, postorder as p };
1679
+ export { Graph as G, LikeC4ModelGraph as L, computeView as a, computeDynamicView as b, computeElementView as c, findCycles as f, isAcyclic as i, postorder as p };
@@ -448,6 +448,7 @@ interface ModelViews extends AstNode {
448
448
  readonly $container: LikeC4Grammar;
449
449
  readonly $type: 'ModelViews';
450
450
  name: 'views';
451
+ styles: Array<ViewRuleStyle>;
451
452
  views: Array<LikeC4View>;
452
453
  }
453
454
  declare const ModelViews = "ModelViews";
@@ -650,7 +651,7 @@ interface ViewRuleAutoLayout extends AstNode {
650
651
  }
651
652
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
652
653
  interface ViewRuleStyle extends AstNode {
653
- readonly $container: DynamicViewBody | ElementViewBody;
654
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
654
655
  readonly $type: 'ViewRuleStyle';
655
656
  props: Array<NotationProperty | StyleProperty>;
656
657
  target: ElementExpressionsIterator;
@@ -1087,11 +1088,15 @@ declare class LikeC4ModelParser {
1087
1088
  private parseRelationPredicateWith;
1088
1089
  private parseRelationExpr;
1089
1090
  private parseViewRule;
1091
+ private parseViewRuleStyle;
1092
+ private parseRuleStyle;
1090
1093
  private parseViewManualLaout;
1091
1094
  private parseDynamicParallelSteps;
1092
1095
  private parseDynamicStep;
1093
1096
  private parseElementView;
1094
1097
  private parseDynamicElementView;
1098
+ private parseDynamicViewRule;
1099
+ private parseDynamicViewIncludePredicate;
1095
1100
  protected resolveFqn(node: Element | ExtendElement): c4.Fqn;
1096
1101
  private getAstNodePath;
1097
1102
  private getMetadata;
@@ -448,6 +448,7 @@ interface ModelViews extends AstNode {
448
448
  readonly $container: LikeC4Grammar;
449
449
  readonly $type: 'ModelViews';
450
450
  name: 'views';
451
+ styles: Array<ViewRuleStyle>;
451
452
  views: Array<LikeC4View>;
452
453
  }
453
454
  declare const ModelViews = "ModelViews";
@@ -650,7 +651,7 @@ interface ViewRuleAutoLayout extends AstNode {
650
651
  }
651
652
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
652
653
  interface ViewRuleStyle extends AstNode {
653
- readonly $container: DynamicViewBody | ElementViewBody;
654
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
654
655
  readonly $type: 'ViewRuleStyle';
655
656
  props: Array<NotationProperty | StyleProperty>;
656
657
  target: ElementExpressionsIterator;
@@ -955,7 +956,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
955
956
  }
956
957
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
957
958
  type Guarded<G> = G extends Guard<infer N> ? N : never;
958
- declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isRelation | typeof isExtendElement | typeof isElement | typeof isLikeC4View | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
959
+ declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isRelation | typeof isLikeC4View | typeof isExtendElement | typeof isElement | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
959
960
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
960
961
  declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
961
962
  isValid: (n: ValidatableAstNode) => boolean;
@@ -1087,11 +1088,15 @@ declare class LikeC4ModelParser {
1087
1088
  private parseRelationPredicateWith;
1088
1089
  private parseRelationExpr;
1089
1090
  private parseViewRule;
1091
+ private parseViewRuleStyle;
1092
+ private parseRuleStyle;
1090
1093
  private parseViewManualLaout;
1091
1094
  private parseDynamicParallelSteps;
1092
1095
  private parseDynamicStep;
1093
1096
  private parseElementView;
1094
1097
  private parseDynamicElementView;
1098
+ private parseDynamicViewRule;
1099
+ private parseDynamicViewIncludePredicate;
1095
1100
  protected resolveFqn(node: Element | ExtendElement): c4.Fqn;
1096
1101
  private getAstNodePath;
1097
1102
  private getMetadata;
@@ -448,6 +448,7 @@ interface ModelViews extends AstNode {
448
448
  readonly $container: LikeC4Grammar;
449
449
  readonly $type: 'ModelViews';
450
450
  name: 'views';
451
+ styles: Array<ViewRuleStyle>;
451
452
  views: Array<LikeC4View>;
452
453
  }
453
454
  declare const ModelViews = "ModelViews";
@@ -650,7 +651,7 @@ interface ViewRuleAutoLayout extends AstNode {
650
651
  }
651
652
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
652
653
  interface ViewRuleStyle extends AstNode {
653
- readonly $container: DynamicViewBody | ElementViewBody;
654
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
654
655
  readonly $type: 'ViewRuleStyle';
655
656
  props: Array<NotationProperty | StyleProperty>;
656
657
  target: ElementExpressionsIterator;
@@ -1087,11 +1088,15 @@ declare class LikeC4ModelParser {
1087
1088
  private parseRelationPredicateWith;
1088
1089
  private parseRelationExpr;
1089
1090
  private parseViewRule;
1091
+ private parseViewRuleStyle;
1092
+ private parseRuleStyle;
1090
1093
  private parseViewManualLaout;
1091
1094
  private parseDynamicParallelSteps;
1092
1095
  private parseDynamicStep;
1093
1096
  private parseElementView;
1094
1097
  private parseDynamicElementView;
1098
+ private parseDynamicViewRule;
1099
+ private parseDynamicViewIncludePredicate;
1095
1100
  protected resolveFqn(node: Element | ExtendElement): c4.Fqn;
1096
1101
  private getAstNodePath;
1097
1102
  private getMetadata;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.12.1",
4
+ "version": "1.13.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -111,9 +111,9 @@
111
111
  "test:watch": "vitest"
112
112
  },
113
113
  "dependencies": {
114
- "@dagrejs/graphlib": "^2.2.4",
115
- "@likec4/core": "1.12.1",
116
- "@likec4/log": "1.12.1",
114
+ "@dagrejs/dagre": "^1.1.4",
115
+ "@likec4/core": "1.13.0",
116
+ "@likec4/log": "1.13.0",
117
117
  "@msgpack/msgpack": "^3.0.0-beta2",
118
118
  "@smithy/util-base64": "^3.0.0",
119
119
  "fast-equals": "^5.0.1",
@@ -133,8 +133,8 @@
133
133
  "vscode-uri": "3.0.8"
134
134
  },
135
135
  "devDependencies": {
136
- "@likec4/icons": "1.12.1",
137
- "@likec4/tsconfig": "1.12.1",
136
+ "@likec4/icons": "1.13.0",
137
+ "@likec4/tsconfig": "1.13.0",
138
138
  "@types/node": "^20.16.5",
139
139
  "@types/object-hash": "^3.0.6",
140
140
  "@types/string-hash": "^1.1.3",
@@ -144,7 +144,7 @@
144
144
  "npm-run-all2": "^6.2.2",
145
145
  "tsx": "~4.9.3",
146
146
  "turbo": "^2.1.3",
147
- "typescript": "^5.6.2",
147
+ "typescript": "^5.6.3",
148
148
  "unbuild": "^3.0.0-rc.11",
149
149
  "vitest": "^2.1.2"
150
150
  },
package/src/ast.ts CHANGED
@@ -460,7 +460,7 @@ export function toAutoLayout(
460
460
  const rankSep = rule.rankSep
461
461
  const nodeSep = rule.nodeSep
462
462
 
463
- let direction: c4.ViewRuleAutoLayout['direction'];
463
+ let direction: c4.ViewRuleAutoLayout['direction']
464
464
  switch (rule.direction) {
465
465
  case 'TopBottom': {
466
466
  direction = 'TB'
@@ -1005,6 +1005,7 @@ export interface ModelViews extends AstNode {
1005
1005
  readonly $container: LikeC4Grammar;
1006
1006
  readonly $type: 'ModelViews';
1007
1007
  name: 'views';
1008
+ styles: Array<ViewRuleStyle>;
1008
1009
  views: Array<LikeC4View>;
1009
1010
  }
1010
1011
 
@@ -1359,7 +1360,7 @@ export function isViewRuleAutoLayout(item: unknown): item is ViewRuleAutoLayout
1359
1360
  }
1360
1361
 
1361
1362
  export interface ViewRuleStyle extends AstNode {
1362
- readonly $container: DynamicViewBody | ElementViewBody;
1363
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
1363
1364
  readonly $type: 'ViewRuleStyle';
1364
1365
  props: Array<NotationProperty | StyleProperty>;
1365
1366
  target: ElementExpressionsIterator;
@@ -2206,6 +2207,7 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2206
2207
  name: ModelViews,
2207
2208
  properties: [
2208
2209
  { name: 'name' },
2210
+ { name: 'styles', defaultValue: [] },
2209
2211
  { name: 'views', defaultValue: [] }
2210
2212
  ]
2211
2213
  };