@likec4/language-server 1.18.0 → 1.19.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 (220) hide show
  1. package/dist/LikeC4FileSystem.d.ts +13 -0
  2. package/dist/LikeC4FileSystem.js +27 -0
  3. package/dist/Rpc.d.ts +9 -0
  4. package/dist/Rpc.js +126 -0
  5. package/dist/ast.d.ts +200 -0
  6. package/dist/ast.js +276 -0
  7. package/dist/browser.d.ts +6 -20
  8. package/dist/browser.js +13 -0
  9. package/dist/formatting/LikeC4Formatter.d.ts +27 -0
  10. package/dist/formatting/LikeC4Formatter.js +261 -0
  11. package/dist/formatting/utils.d.ts +6 -0
  12. package/dist/formatting/utils.js +15 -0
  13. package/dist/generated/ast.d.ts +1242 -0
  14. package/dist/generated/ast.js +1945 -0
  15. package/dist/generated/grammar.d.ts +6 -0
  16. package/dist/generated/grammar.js +3 -0
  17. package/dist/generated/module.d.ts +9 -0
  18. package/dist/generated/module.js +23 -0
  19. package/dist/generated-lib/icons.d.ts +1 -0
  20. package/dist/{likec4lib.mjs → generated-lib/icons.js} +1 -6
  21. package/dist/index.d.ts +8 -31
  22. package/dist/index.js +13 -0
  23. package/dist/like-c4.langium +845 -0
  24. package/dist/likec4lib.d.ts +4 -6
  25. package/dist/likec4lib.js +4 -0
  26. package/dist/logger.d.ts +7 -0
  27. package/dist/logger.js +73 -0
  28. package/dist/lsp/CodeLensProvider.d.ts +9 -0
  29. package/dist/lsp/CodeLensProvider.js +40 -0
  30. package/dist/lsp/CompletionProvider.d.ts +6 -0
  31. package/dist/lsp/CompletionProvider.js +135 -0
  32. package/dist/lsp/DocumentHighlightProvider.d.ts +9 -0
  33. package/dist/lsp/DocumentHighlightProvider.js +10 -0
  34. package/dist/lsp/DocumentLinkProvider.d.ts +11 -0
  35. package/dist/lsp/DocumentLinkProvider.js +49 -0
  36. package/dist/lsp/DocumentSymbolProvider.d.ts +23 -0
  37. package/dist/lsp/DocumentSymbolProvider.js +202 -0
  38. package/dist/lsp/HoverProvider.d.ts +10 -0
  39. package/dist/lsp/HoverProvider.js +69 -0
  40. package/dist/lsp/RenameProvider.d.ts +5 -0
  41. package/dist/lsp/RenameProvider.js +6 -0
  42. package/dist/lsp/SemanticTokenProvider.d.ts +7 -0
  43. package/dist/lsp/SemanticTokenProvider.js +297 -0
  44. package/dist/lsp/index.d.ts +7 -0
  45. package/dist/lsp/index.js +7 -0
  46. package/dist/model/deployments-index.d.ts +60 -0
  47. package/dist/model/deployments-index.js +181 -0
  48. package/dist/model/fqn-computation.d.ts +3 -0
  49. package/dist/model/fqn-computation.js +72 -0
  50. package/dist/model/fqn-index.d.ts +25 -0
  51. package/dist/model/fqn-index.js +96 -0
  52. package/dist/model/index.d.ts +6 -0
  53. package/dist/model/index.js +6 -0
  54. package/dist/model/model-builder.d.ts +32 -0
  55. package/dist/model/model-builder.js +598 -0
  56. package/dist/model/model-locator.d.ts +23 -0
  57. package/dist/model/model-locator.js +126 -0
  58. package/dist/model/model-parser-where.d.ts +3 -0
  59. package/dist/model/model-parser-where.js +70 -0
  60. package/dist/model/model-parser.d.ts +292 -0
  61. package/dist/model/model-parser.js +72 -0
  62. package/dist/model/parser/Base.d.ts +28 -0
  63. package/dist/model/parser/Base.js +87 -0
  64. package/dist/model/parser/DeploymentModelParser.d.ts +33 -0
  65. package/dist/model/parser/DeploymentModelParser.js +162 -0
  66. package/dist/model/parser/DeploymentViewParser.d.ts +38 -0
  67. package/dist/model/parser/DeploymentViewParser.js +98 -0
  68. package/dist/model/parser/FqnRefParser.d.ts +29 -0
  69. package/dist/model/parser/FqnRefParser.js +108 -0
  70. package/dist/model/parser/GlobalsParser.d.ts +66 -0
  71. package/dist/model/parser/GlobalsParser.js +80 -0
  72. package/dist/model/parser/ModelParser.d.ts +27 -0
  73. package/dist/model/parser/ModelParser.js +122 -0
  74. package/dist/model/parser/PredicatesParser.d.ts +34 -0
  75. package/dist/model/parser/PredicatesParser.js +272 -0
  76. package/dist/model/parser/SpecificationParser.d.ts +27 -0
  77. package/dist/model/parser/SpecificationParser.js +120 -0
  78. package/dist/model/parser/ViewsParser.d.ts +64 -0
  79. package/dist/model/parser/ViewsParser.js +377 -0
  80. package/dist/model-change/ModelChanges.d.ts +15 -0
  81. package/dist/model-change/ModelChanges.js +89 -0
  82. package/dist/model-change/changeElementStyle.d.ts +16 -0
  83. package/dist/model-change/changeElementStyle.js +136 -0
  84. package/dist/model-change/changeViewLayout.d.ts +12 -0
  85. package/dist/model-change/changeViewLayout.js +32 -0
  86. package/dist/model-change/saveManualLayout.d.ts +11 -0
  87. package/dist/model-change/saveManualLayout.js +27 -0
  88. package/dist/module.d.ts +62 -0
  89. package/dist/module.js +123 -0
  90. package/dist/protocol.d.ts +20 -23
  91. package/dist/protocol.js +14 -0
  92. package/dist/references/index.d.ts +3 -0
  93. package/dist/references/index.js +3 -0
  94. package/dist/references/name-provider.d.ts +9 -0
  95. package/dist/references/name-provider.js +33 -0
  96. package/dist/references/scope-computation.d.ts +20 -0
  97. package/dist/references/scope-computation.js +281 -0
  98. package/dist/references/scope-provider.d.ts +16 -0
  99. package/dist/references/scope-provider.js +165 -0
  100. package/dist/shared/NodeKindProvider.d.ts +15 -0
  101. package/dist/shared/NodeKindProvider.js +108 -0
  102. package/dist/shared/WorkspaceManager.d.ts +18 -0
  103. package/dist/shared/WorkspaceManager.js +36 -0
  104. package/dist/shared/WorkspaceSymbolProvider.d.ts +3 -0
  105. package/dist/shared/WorkspaceSymbolProvider.js +3 -0
  106. package/dist/shared/index.d.ts +3 -0
  107. package/dist/shared/index.js +3 -0
  108. package/dist/test/index.d.ts +1 -0
  109. package/dist/test/index.js +1 -0
  110. package/dist/test/setup.d.ts +1 -0
  111. package/dist/test/setup.js +7 -0
  112. package/dist/test/testServices.d.ts +22 -0
  113. package/dist/test/testServices.js +119 -0
  114. package/dist/utils/elementRef.d.ts +11 -0
  115. package/dist/utils/elementRef.js +15 -0
  116. package/dist/utils/fqnRef.d.ts +8 -0
  117. package/dist/utils/fqnRef.js +46 -0
  118. package/dist/utils/index.d.ts +1 -0
  119. package/dist/utils/index.js +1 -0
  120. package/dist/utils/printDocs.d.ts +2 -0
  121. package/dist/utils/printDocs.js +1 -0
  122. package/dist/utils/stringHash.d.ts +1 -0
  123. package/dist/utils/stringHash.js +5 -0
  124. package/dist/validation/_shared.d.ts +3 -0
  125. package/dist/validation/_shared.js +22 -0
  126. package/dist/validation/deployment-checks.d.ts +6 -0
  127. package/dist/validation/deployment-checks.js +114 -0
  128. package/dist/validation/dynamic-view-rule.d.ts +4 -0
  129. package/dist/validation/dynamic-view-rule.js +16 -0
  130. package/dist/validation/dynamic-view-step.d.ts +4 -0
  131. package/dist/validation/dynamic-view-step.js +33 -0
  132. package/dist/validation/element.d.ts +4 -0
  133. package/dist/validation/element.js +49 -0
  134. package/dist/validation/index.d.ts +15 -0
  135. package/dist/validation/index.js +152 -0
  136. package/dist/validation/property-checks.d.ts +6 -0
  137. package/dist/validation/property-checks.js +38 -0
  138. package/dist/validation/relation.d.ts +5 -0
  139. package/dist/validation/relation.js +56 -0
  140. package/dist/validation/specification.d.ts +11 -0
  141. package/dist/validation/specification.js +136 -0
  142. package/dist/validation/view-predicates/element-with.d.ts +4 -0
  143. package/dist/validation/view-predicates/element-with.js +30 -0
  144. package/dist/validation/view-predicates/expanded-element.d.ts +4 -0
  145. package/dist/validation/view-predicates/expanded-element.js +11 -0
  146. package/dist/validation/view-predicates/expression-v2.d.ts +5 -0
  147. package/dist/validation/view-predicates/expression-v2.js +83 -0
  148. package/dist/validation/view-predicates/incoming.d.ts +4 -0
  149. package/dist/validation/view-predicates/incoming.js +15 -0
  150. package/dist/validation/view-predicates/index.d.ts +6 -0
  151. package/dist/validation/view-predicates/index.js +6 -0
  152. package/dist/validation/view-predicates/outgoing.d.ts +4 -0
  153. package/dist/validation/view-predicates/outgoing.js +15 -0
  154. package/dist/validation/view-predicates/relation-with.d.ts +4 -0
  155. package/dist/validation/view-predicates/relation-with.js +12 -0
  156. package/dist/validation/view.d.ts +4 -0
  157. package/dist/validation/view.js +23 -0
  158. package/dist/view-utils/assignNavigateTo.d.ts +2 -0
  159. package/dist/view-utils/assignNavigateTo.js +25 -0
  160. package/dist/view-utils/index.d.ts +2 -0
  161. package/dist/view-utils/index.js +2 -0
  162. package/dist/view-utils/manual-layout.d.ts +7 -0
  163. package/dist/view-utils/manual-layout.js +99 -0
  164. package/dist/view-utils/resolve-relative-paths.d.ts +2 -0
  165. package/dist/view-utils/resolve-relative-paths.js +78 -0
  166. package/package.json +36 -53
  167. package/src/LikeC4FileSystem.ts +22 -21
  168. package/src/ast.ts +44 -133
  169. package/src/browser.ts +10 -11
  170. package/src/generated/ast.ts +177 -177
  171. package/src/generated/grammar.ts +1 -1
  172. package/src/index.ts +10 -8
  173. package/src/like-c4.langium +37 -34
  174. package/src/logger.ts +34 -55
  175. package/src/lsp/CompletionProvider.ts +4 -4
  176. package/src/lsp/HoverProvider.ts +5 -3
  177. package/src/lsp/SemanticTokenProvider.ts +2 -2
  178. package/src/model/deployments-index.ts +18 -14
  179. package/src/model/model-builder.ts +10 -8
  180. package/src/model/model-parser.ts +62 -1574
  181. package/src/model/parser/Base.ts +107 -0
  182. package/src/model/parser/DeploymentModelParser.ts +192 -0
  183. package/src/model/parser/DeploymentViewParser.ts +116 -0
  184. package/src/model/parser/FqnRefParser.ts +118 -0
  185. package/src/model/parser/GlobalsParser.ts +96 -0
  186. package/src/model/parser/ModelParser.ts +141 -0
  187. package/src/model/parser/PredicatesParser.ts +291 -0
  188. package/src/model/parser/SpecificationParser.ts +133 -0
  189. package/src/model/parser/ViewsParser.ts +428 -0
  190. package/src/module.ts +17 -18
  191. package/src/references/scope-provider.ts +13 -7
  192. package/src/utils/{deploymentRef.ts → fqnRef.ts} +27 -2
  193. package/src/validation/_shared.ts +0 -1
  194. package/src/validation/deployment-checks.ts +49 -62
  195. package/src/validation/index.ts +100 -9
  196. package/src/validation/view-predicates/expression-v2.ts +101 -0
  197. package/src/validation/view-predicates/index.ts +1 -1
  198. package/src/view-utils/assignNavigateTo.ts +1 -1
  199. package/src/view-utils/manual-layout.ts +25 -0
  200. package/dist/browser.cjs +0 -25
  201. package/dist/browser.d.cts +0 -23
  202. package/dist/browser.d.mts +0 -23
  203. package/dist/browser.mjs +0 -20
  204. package/dist/index.cjs +0 -53
  205. package/dist/index.d.cts +0 -34
  206. package/dist/index.d.mts +0 -34
  207. package/dist/index.mjs +0 -46
  208. package/dist/likec4lib.cjs +0 -1546
  209. package/dist/likec4lib.d.cts +0 -6
  210. package/dist/likec4lib.d.mts +0 -6
  211. package/dist/protocol.cjs +0 -25
  212. package/dist/protocol.d.cts +0 -48
  213. package/dist/protocol.d.mts +0 -48
  214. package/dist/protocol.mjs +0 -17
  215. package/dist/shared/language-server.CO_nmHiL.cjs +0 -7689
  216. package/dist/shared/language-server.Da6ey08o.d.cts +0 -1619
  217. package/dist/shared/language-server.De7S3e5Z.d.ts +0 -1619
  218. package/dist/shared/language-server.Dj4iDjtB.d.mts +0 -1619
  219. package/dist/shared/language-server.oO_9JoAG.mjs +0 -7666
  220. package/src/validation/view-predicates/deployments.ts +0 -56
package/src/ast.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import type * as c4 from '@likec4/core'
2
- import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor, nonexhaustive } from '@likec4/core'
2
+ import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor, LinkedList, nonexhaustive } from '@likec4/core'
3
3
  import type { AstNode, AstNodeDescription, DiagnosticInfo, LangiumDocument, MultiMap } from 'langium'
4
4
  import { DocumentState } from 'langium'
5
5
  import { clamp, isDefined, isNullish, isTruthy } from 'remeda'
6
- import type { ConditionalPick, SetRequired, ValueOf } from 'type-fest'
6
+ import type { ConditionalPick, SetRequired, ValueOf, Writable } from 'type-fest'
7
7
  import type { Diagnostic } from 'vscode-languageserver-types'
8
- import { DiagnosticSeverity } from 'vscode-languageserver-types'
9
8
  import type { LikeC4Grammar } from './generated/ast'
10
9
  import * as ast from './generated/ast'
11
10
  import { LikeC4LanguageMetaData } from './generated/module'
12
11
  import { elementRef } from './utils/elementRef'
12
+ import type { IsValidFn } from './validation'
13
13
 
14
14
  export { ast }
15
15
 
@@ -113,13 +113,8 @@ export type ParsedAstDeploymentRelation = c4.DeploymentRelation & {
113
113
  astPath: string
114
114
  }
115
115
 
116
- // export interface ParsedAstGlobals {
117
- // predicates: Record<c4.GlobalElRelID, c4.NonEmptyArray<c4.ViewRulePredicate>>
118
- // dynamicPredicates: Record<c4.GlobalElRelID, c4.NonEmptyArray<c4.DynamicViewIncludeRule>>
119
- // styles: Record<c4.GlobalStyleID, c4.NonEmptyArray<c4.ViewRuleStyle>>
120
- // }
121
116
  // Alias for refactoring
122
- export type ParsedAstGlobals = c4.ModelGlobals
117
+ export type ParsedAstGlobals = Writable<c4.ModelGlobals>
123
118
 
124
119
  export interface ParsedAstElementView {
125
120
  __: 'element'
@@ -167,7 +162,7 @@ export const ViewOps = {
167
162
  },
168
163
  readId(node: ast.LikeC4View): c4.ViewId | undefined {
169
164
  return node[idattr]
170
- }
165
+ },
171
166
  }
172
167
 
173
168
  export interface ParsedLink {
@@ -186,7 +181,7 @@ export const ElementOps = {
186
181
  },
187
182
  readId(node: ast.Element | ast.DeploymentElement) {
188
183
  return node[idattr]
189
- }
184
+ },
190
185
  }
191
186
 
192
187
  export interface DocFqnIndexAstNodeDescription extends AstNodeDescription {
@@ -222,29 +217,6 @@ export interface FqnIndexedDocument extends SetRequired<LikeC4LangiumDocument, '
222
217
 
223
218
  export interface ParsedLikeC4LangiumDocument extends LikeC4GrammarDocument, Required<LikeC4DocumentProps> {}
224
219
 
225
- export function cleanParsedModel(doc: LikeC4LangiumDocument) {
226
- const props: Required<Omit<LikeC4DocumentProps, 'c4fqnIndex' | 'diagnostics'>> = {
227
- c4Specification: {
228
- tags: new Set(),
229
- elements: {},
230
- relationships: {},
231
- colors: {},
232
- deployments: {}
233
- },
234
- c4Elements: [],
235
- c4Relations: [],
236
- c4Deployments: [],
237
- c4DeploymentRelations: [],
238
- c4Globals: {
239
- predicates: {},
240
- dynamicPredicates: {},
241
- styles: {}
242
- },
243
- c4Views: []
244
- }
245
- return Object.assign(doc, props) as ParsedLikeC4LangiumDocument
246
- }
247
-
248
220
  export function isLikeC4LangiumDocument(doc: LangiumDocument): doc is LikeC4LangiumDocument {
249
221
  return doc.textDocument.languageId === LikeC4LanguageMetaData.languageId
250
222
  }
@@ -254,7 +226,7 @@ export function isFqnIndexedDocument(doc: LangiumDocument): doc is FqnIndexedDoc
254
226
  }
255
227
 
256
228
  export function isParsedLikeC4LangiumDocument(
257
- doc: LangiumDocument
229
+ doc: LangiumDocument,
258
230
  ): doc is ParsedLikeC4LangiumDocument {
259
231
  return (
260
232
  isLikeC4LangiumDocument(doc)
@@ -269,115 +241,54 @@ export function isParsedLikeC4LangiumDocument(
269
241
  )
270
242
  }
271
243
 
272
- type Guard<N extends AstNode> = (n: AstNode) => n is N
273
- type Guarded<G> = G extends Guard<infer N> ? N : never
274
-
275
- function validatableAstNodeGuards<const Predicates extends Guard<AstNode>[]>(
276
- predicates: Predicates
277
- ) {
278
- return (n: AstNode): n is Guarded<Predicates[number]> => predicates.some(p => p(n))
279
- }
280
- const isValidatableAstNode = validatableAstNodeGuards([
281
- ast.isGlobals,
282
- ast.isGlobalPredicateGroup,
283
- ast.isGlobalDynamicPredicateGroup,
284
- ast.isGlobalStyle,
285
- ast.isGlobalStyleGroup,
286
- ast.isDynamicViewPredicateIterator,
287
- ast.isElementPredicateWith,
288
- ast.isRelationPredicateWith,
289
- ast.isElementExpression,
290
- ast.isRelationExpression,
291
- ast.isDynamicViewParallelSteps,
292
- ast.isDynamicViewStep,
293
- ast.isDeploymentViewRule,
294
- ast.isDeploymentViewRulePredicate,
295
- ast.isDeploymentExpression,
296
- ast.isViewProperty,
297
- ast.isStyleProperty,
298
- ast.isPredicate,
299
- ast.isTags,
300
- ast.isViewRule,
301
- ast.isDynamicViewRule,
302
- ast.isLikeC4View,
303
- ast.isViewRuleStyleOrGlobalRef,
304
- ast.isDeployedInstance,
305
- ast.isDeploymentNode,
306
- ast.isRelationshipStyleProperty,
307
- ast.isRelation,
308
- ast.isElementProperty,
309
- ast.isStringProperty,
310
- ast.isNavigateToProperty,
311
- ast.isElement,
312
- ast.isExtendElement,
313
- ast.isSpecificationElementKind,
314
- ast.isSpecificationRelationshipKind,
315
- ast.isSpecificationDeploymentNodeKind,
316
- ast.isSpecificationTag,
317
- ast.isSpecificationColor,
318
- ast.isSpecificationRule
319
- ])
320
- type ValidatableAstNode = Guarded<typeof isValidatableAstNode>
321
-
322
- const findInvalidContainer = (node: LikeC4AstNode): ValidatableAstNode | undefined => {
323
- let nd = node as LikeC4AstNode['$container']
324
- while (nd) {
325
- if (isValidatableAstNode(nd)) {
326
- return nd
327
- }
328
- nd = nd.$container
329
- }
330
- return undefined
331
- }
332
-
333
- export function checksFromDiagnostics(doc: LikeC4LangiumDocument) {
334
- const errors = doc.diagnostics?.filter(d => d.severity === DiagnosticSeverity.Error) ?? []
335
- const invalidNodes = new WeakSet()
336
- for (const { node } of errors) {
337
- if (isNullish(node) || invalidNodes.has(node)) {
338
- continue
339
- }
340
- invalidNodes.add(node)
341
- const container = findInvalidContainer(node)
342
- if (container) {
343
- invalidNodes.add(container)
344
- }
345
- }
346
- const isValid = (n: ValidatableAstNode) => !invalidNodes.has(n)
347
- return {
348
- isValid,
349
- invalidNodes
350
- }
351
- }
352
- export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>
353
- export type IsValidFn = ChecksFromDiagnostics['isValid']
354
-
355
- export function* streamModel(doc: LikeC4LangiumDocument, isValid: IsValidFn) {
356
- const traverseStack = doc.parseResult.value.models.flatMap(m => m.elements)
244
+ export function* streamModel(doc: LikeC4LangiumDocument) {
245
+ const traverseStack = LinkedList.from(doc.parseResult.value.models.flatMap(m => m.elements))
357
246
  const relations = [] as ast.Relation[]
358
247
  let el
359
248
  while ((el = traverseStack.shift())) {
360
249
  if (ast.isRelation(el)) {
361
- isValid(el) && relations.push(el)
250
+ relations.push(el)
362
251
  continue
363
252
  }
364
253
  if (ast.isExtendElement(el)) {
365
254
  if (el.body && el.body.elements.length > 0) {
366
- traverseStack.push(...el.body.elements)
255
+ for (const child of el.body.elements) {
256
+ traverseStack.push(child)
257
+ }
367
258
  }
368
259
  continue
369
260
  }
370
261
  if (el.body && el.body.elements.length > 0) {
371
- traverseStack.push(...el.body.elements)
262
+ for (const child of el.body.elements) {
263
+ traverseStack.push(child)
264
+ }
372
265
  }
373
- if (!isValid(el)) {
266
+ yield el
267
+ }
268
+ yield* relations
269
+ return
270
+ }
271
+
272
+ export function* streamDeploymentModel(doc: LikeC4LangiumDocument) {
273
+ const traverseStack = LinkedList.from<ast.DeploymentRelation | ast.DeploymentElement>(
274
+ doc.parseResult.value.deployments.flatMap(m => m.elements),
275
+ )
276
+ const relations = [] as ast.DeploymentRelation[]
277
+ let el
278
+ while ((el = traverseStack.shift())) {
279
+ if (ast.isDeploymentRelation(el)) {
280
+ relations.push(el)
374
281
  continue
375
282
  }
283
+ if (ast.isDeploymentNode(el) && el.body && el.body.elements.length > 0) {
284
+ for (const child of el.body.elements) {
285
+ traverseStack.push(child)
286
+ }
287
+ }
376
288
  yield el
377
289
  }
378
- for (const relation of relations) {
379
- yield relation
380
- }
290
+ yield* relations
291
+ return
381
292
  }
382
293
 
383
294
  export function resolveRelationPoints(node: ast.Relation): {
@@ -395,7 +306,7 @@ export function resolveRelationPoints(node: ast.Relation): {
395
306
  }
396
307
  return {
397
308
  source,
398
- target
309
+ target,
399
310
  }
400
311
  }
401
312
  if (!ast.isElementBody(node.$container)) {
@@ -403,7 +314,7 @@ export function resolveRelationPoints(node: ast.Relation): {
403
314
  }
404
315
  return {
405
316
  source: node.$container.$container,
406
- target
317
+ target,
407
318
  }
408
319
  }
409
320
 
@@ -511,14 +422,14 @@ export function toRelationshipStyle(props: ast.RelationshipStyleProperty[] | und
511
422
 
512
423
  export function toRelationshipStyleExcludeDefaults(
513
424
  props: ast.SpecificationRelationshipKind['props'] | undefined,
514
- isValid: IsValidFn
425
+ isValid: IsValidFn,
515
426
  ) {
516
427
  const { color, line, head, tail } = toRelationshipStyle(props?.filter(ast.isRelationshipStyleProperty), isValid)
517
428
  return {
518
429
  ...(color && color !== DefaultRelationshipColor ? { color } : {}),
519
430
  ...(line && line !== DefaultLineStyle ? { line } : {}),
520
431
  ...(head && head !== DefaultArrowType ? { head } : {}),
521
- ...(tail ? { tail } : {})
432
+ ...(tail ? { tail } : {}),
522
433
  }
523
434
  }
524
435
 
@@ -527,7 +438,7 @@ export function toColor(astNode: ast.ColorProperty): c4.Color | undefined {
527
438
  }
528
439
 
529
440
  export function toAutoLayout(
530
- rule: ast.ViewRuleAutoLayout
441
+ rule: ast.ViewRuleAutoLayout,
531
442
  ): c4.ViewRuleAutoLayout {
532
443
  const rankSep = rule.rankSep
533
444
  const nodeSep = rule.nodeSep
@@ -557,7 +468,7 @@ export function toAutoLayout(
557
468
  return {
558
469
  direction,
559
470
  ...(nodeSep && { nodeSep }),
560
- ...(rankSep && { rankSep })
471
+ ...(rankSep && { rankSep }),
561
472
  }
562
473
  }
563
474
 
package/src/browser.ts CHANGED
@@ -1,18 +1,22 @@
1
1
  import { startLanguageServer as startLanguim } from 'langium/lsp'
2
2
  import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser'
3
- import { createLanguageServices } from './module'
3
+ import { type LikeC4Services, type LikeC4SharedServices, createLanguageServices } from './module'
4
+
5
+ export { logger as lspLogger, setLogLevel } from './logger'
6
+ export type { DocumentParser, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model'
4
7
 
5
- export { setLogLevel } from './logger'
6
- export type * from './model'
7
- export type * from './module'
8
8
  export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from './module'
9
+ export type { LikeC4Services, LikeC4SharedServices } from './module'
9
10
 
10
11
  // This is an example copied as is from here:
11
12
  // https://github.com/microsoft/vscode-extension-samples/blob/main/lsp-web-extension-sample/server/src/browserServerMain.ts
12
13
  // the only addition is the following line:
13
14
  declare const self: DedicatedWorkerGlobalScope
14
15
 
15
- export function startLanguageServer() {
16
+ export function startLanguageServer(): {
17
+ shared: LikeC4SharedServices
18
+ likec4: LikeC4Services
19
+ } {
16
20
  /* browser specific setup code */
17
21
 
18
22
  const messageReader = new BrowserMessageReader(self)
@@ -26,10 +30,5 @@ export function startLanguageServer() {
26
30
  // Start the language server with the shared services
27
31
  startLanguim(services.shared)
28
32
 
29
- return {
30
- ...services,
31
- connection,
32
- messageReader,
33
- messageWriter
34
- }
33
+ return services
35
34
  }