likec4 1.60.0 → 1.61.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 (157) hide show
  1. package/README.md +2 -0
  2. package/__app__/codegen/react.mjs +4 -10
  3. package/__app__/codegen/webcomponent.mjs +5 -208
  4. package/__app__/index.html +15 -15
  5. package/__app__/src/aichat/index.mjs +1 -2
  6. package/__app__/src/chunks/AIChat.mjs +292 -117
  7. package/__app__/src/chunks/ErrorComponent.mjs +444 -0
  8. package/__app__/src/chunks/Header.mjs +269 -0
  9. package/__app__/src/chunks/ViewReact.mjs +438 -0
  10. package/__app__/src/chunks/find.mjs +38 -0
  11. package/__app__/src/chunks/hooks.mjs +18 -541
  12. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
  13. package/__app__/src/chunks/libs/@tanstack-ai.mjs +11101 -1797
  14. package/__app__/src/chunks/libs/@tanstack.mjs +4563 -3083
  15. package/__app__/src/chunks/libs/fast-equals.mjs +140 -71
  16. package/__app__/src/chunks/{es.mjs → libs/html-to-image.mjs} +16 -22
  17. package/__app__/src/chunks/libs/nanostores.mjs +4 -8
  18. package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
  19. package/__app__/src/chunks/react.mjs +22 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +3 -32
  21. package/__app__/src/chunks/router.mjs +106 -0
  22. package/__app__/src/chunks/scope.mjs +106 -0
  23. package/__app__/src/chunks/searchParams.mjs +29 -0
  24. package/__app__/src/chunks/single-index.mjs +465 -0
  25. package/__app__/src/chunks/styled-system.mjs +1916 -2946
  26. package/__app__/src/chunks/useAsync.mjs +69 -0
  27. package/__app__/src/chunks/useSyncedRef.mjs +16 -0
  28. package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
  29. package/__app__/src/components/CopyToClipboard.mjs +53 -0
  30. package/__app__/src/components/ErrorComponent.mjs +1 -0
  31. package/__app__/src/components/NavigationPanel.mjs +63 -0
  32. package/__app__/src/components/NotFound.mjs +155 -0
  33. package/__app__/src/components/ViewOutlet.mjs +9 -0
  34. package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
  35. package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
  36. package/__app__/src/components/model-diff/compare-model.mjs +76 -0
  37. package/__app__/src/components/model-diff/state.mjs +45 -0
  38. package/__app__/src/components/search/OverviewSearch.mjs +92 -0
  39. package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
  40. package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
  41. package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
  42. package/__app__/src/components/sidebar/Drawer.mjs +178 -0
  43. package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
  44. package/__app__/src/components/sidebar/data.mjs +94 -0
  45. package/__app__/src/components/sidebar/state.mjs +16 -0
  46. package/__app__/src/components/view-page/Header.mjs +1 -0
  47. package/__app__/src/components/view-page/SelectProject.mjs +258 -0
  48. package/__app__/src/components/view-page/ShareModal.mjs +111 -0
  49. package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
  50. package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
  51. package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
  52. package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
  53. package/__app__/src/components/view-page/state.mjs +17 -0
  54. package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
  55. package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
  56. package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
  57. package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
  58. package/__app__/src/context/ModelDiffsContext.mjs +33 -0
  59. package/__app__/src/context/safeCtx.mjs +14 -0
  60. package/__app__/src/hooks.mjs +1 -0
  61. package/__app__/src/main.mjs +4 -48126
  62. package/__app__/src/pages/EmbedPage.mjs +93 -0
  63. package/__app__/src/pages/ExportPage.mjs +691 -0
  64. package/__app__/src/pages/ProjectsOverview.mjs +23 -0
  65. package/__app__/src/pages/ViewAsD2.mjs +105 -0
  66. package/__app__/src/pages/ViewAsDot.mjs +65 -0
  67. package/__app__/src/pages/ViewAsMmd.mjs +109 -0
  68. package/__app__/src/pages/ViewAsPuml.mjs +105 -0
  69. package/__app__/src/pages/ViewEditor.mjs +220 -0
  70. package/__app__/src/pages/ViewReact.mjs +1 -0
  71. package/__app__/src/pages/export-layout.mjs +95 -0
  72. package/__app__/src/pages/export-page-params.mjs +9 -0
  73. package/__app__/src/pages/styles.css.mjs +23 -0
  74. package/__app__/src/routeTree.gen.mjs +105 -0
  75. package/__app__/src/router.mjs +1 -0
  76. package/__app__/src/routes/__root.mjs +65 -0
  77. package/__app__/src/routes/index.css.mjs +29 -0
  78. package/__app__/src/routes/index.mjs +32 -0
  79. package/__app__/src/routes/project._projectId/-components.mjs +100 -0
  80. package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
  81. package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
  82. package/__app__/src/routes/project._projectId/index.mjs +14 -0
  83. package/__app__/src/routes/project._projectId/route.mjs +93 -0
  84. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
  85. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
  86. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
  87. package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
  88. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
  89. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
  90. package/__app__/src/routes/projects.mjs +36 -0
  91. package/__app__/src/routes/single-index.mjs +1 -0
  92. package/__app__/src/routes/webcomponent._.mjs +94 -0
  93. package/__app__/src/style.css +1156 -1147
  94. package/config/schema.json +26 -2
  95. package/dist/app/render-view-client.css +1 -1
  96. package/dist/app/render-view-client.js +375 -393
  97. package/dist/chunks/filenames.mjs +26 -20
  98. package/dist/chunks/generate-likec4.mjs +4 -4
  99. package/dist/chunks/index.d.mts +16 -15
  100. package/dist/chunks/index2.d.mts +7041 -3293
  101. package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
  102. package/dist/chunks/libs/@logtape/logtape.mjs +5 -5
  103. package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
  104. package/dist/chunks/libs/chevrotain.mjs +19 -19
  105. package/dist/chunks/libs/clone.mjs +1 -0
  106. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  107. package/dist/chunks/libs/fast-equals.mjs +1 -0
  108. package/dist/chunks/libs/fontkit.mjs +1 -0
  109. package/dist/chunks/libs/langium.d.mts +80 -2933
  110. package/dist/chunks/libs/langium.mjs +6 -6
  111. package/dist/chunks/libs/pako.mjs +1 -1
  112. package/dist/chunks/libs/pathe.mjs +1 -1
  113. package/dist/chunks/libs/remeda.mjs +1 -1
  114. package/dist/chunks/node.mjs +110 -77
  115. package/dist/chunks/rolldown-runtime.mjs +1 -1
  116. package/dist/chunks/sequence-view.mjs +1 -1
  117. package/dist/chunks/vite-plugin.mjs +183 -164
  118. package/dist/cli/index.mjs +157 -101
  119. package/dist/config/index.d.mts +65 -4
  120. package/dist/config/index.mjs +1 -1
  121. package/dist/generators/likec4.d.mts +16 -64
  122. package/dist/index.d.mts +2 -4
  123. package/dist/model/index.d.mts +0 -10
  124. package/dist/vite-plugin/index.d.mts +83 -61
  125. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -2
  126. package/dist/vite-plugin/internal/index.d.mts +91 -17
  127. package/dist/vite-plugin/internal/index.mjs +156 -110
  128. package/package.json +60 -55
  129. package/react/index.d.mts +3010 -4014
  130. package/react/index.mjs +170 -171
  131. package/react/rolldown-runtime-CfRud99p.js +1 -0
  132. package/skills/likec4-dsl/SKILL.md +71 -25
  133. package/skills/likec4-dsl/evals/evals-public.json +5 -0
  134. package/skills/likec4-dsl/evals/grading-spec.json +15 -1
  135. package/skills/likec4-dsl/references/cli.md +39 -10
  136. package/skills/likec4-dsl/references/configuration.md +5 -5
  137. package/skills/likec4-dsl/references/diffs.md +52 -0
  138. package/skills/likec4-dsl/references/examples.md +2 -2
  139. package/skills/likec4-dsl/references/identifier-validity.md +31 -31
  140. package/skills/likec4-dsl/references/include-predicates-wildcards.md +16 -15
  141. package/skills/likec4-dsl/references/model.md +42 -11
  142. package/skills/likec4-dsl/references/specification.md +11 -7
  143. package/skills/likec4-dsl/references/troubleshooting.md +47 -42
  144. package/skills/likec4-dsl/references/views.md +2 -2
  145. package/vite-plugin-modules.d.ts +126 -51
  146. package/__app__/src/chunks/LikeC4Styles.mjs +0 -4522
  147. package/__app__/src/chunks/ProjectsOverview.mjs +0 -827
  148. package/__app__/src/chunks/libs/@floating-ui.mjs +0 -3286
  149. package/__app__/src/chunks/libs/@mantine.mjs +0 -17731
  150. package/__app__/src/chunks/libs/@xstate/react.mjs +0 -3471
  151. package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -7927
  152. package/__app__/src/chunks/libs/bezier-js.mjs +0 -1593
  153. package/__app__/src/chunks/libs/d3.mjs +0 -4531
  154. package/__app__/src/chunks/libs/framer.mjs +0 -11331
  155. package/__app__/src/chunks/libs/zod.mjs +0 -5404
  156. package/dist/chunks/libs/@chevrotain/types.d.mts +0 -111
  157. package/react/rolldown-runtime-DnkiqaRY.js +0 -1
@@ -3,6 +3,7 @@
3
3
  The `specification` block defines all named vocabularies for the project: element kinds, deployment node kinds, relationship kinds, tags, and custom color tokens. Every kind used in `model` or `deployment` blocks must be declared here first.
4
4
 
5
5
  **Key rules:**
6
+
6
7
  - Specification is global across all files in the project.
7
8
  - Duplicate identifiers (same kind, same tag, etc.) will cause a validation error.
8
9
  - Multiple `specification` blocks (in one file or across files) are allowed, but not recommended.
@@ -34,7 +35,10 @@ specification {
34
35
  relationship IDENTIFIER {
35
36
  technology "default tech for this relationship kind"
36
37
  description "default description for this relationship kind"
37
- style { ... } // default style for this relationship kind
38
+ // default style properties go directly in the body, not in a style block
39
+ color amber
40
+ line dashed
41
+ head diamond
38
42
  }
39
43
 
40
44
  // Define a custom named color token
@@ -67,9 +71,9 @@ specification {
67
71
 
68
72
  ## Common Mistakes
69
73
 
70
- | Mistake | Fix |
71
- |---------|-----|
72
- | Using a kind not defined here | Define `element KIND { }` or `deploymentNode KIND { }` in specification first |
73
- | Duplicate tag or kind identifier | Each identifier must be unique within its type category |
74
- | `#tag` in specification argument | Tags are defined without `#`; they are used with `#` elsewhere: `tag critical` → `#critical` |
75
- | Raw hex color in style | Define a named color token first: `color my-blue #003366`, then use `color my-blue` in styles |
74
+ | Mistake | Fix |
75
+ | -------------------------------- | --------------------------------------------------------------------------------------------- |
76
+ | Using a kind not defined here | Define `element KIND { }` or `deploymentNode KIND { }` in specification first |
77
+ | Duplicate tag or kind identifier | Each identifier must be unique within its type category |
78
+ | `#tag` in specification argument | Tags are defined without `#`; they are used with `#` elsewhere: `tag critical` → `#critical` |
79
+ | Raw hex color in style | Define a named color token first: `color my-blue #003366`, then use `color my-blue` in styles |
@@ -4,68 +4,73 @@ Load this file when encountering validation errors, unexpected rendering, or whe
4
4
 
5
5
  ## Syntax Errors
6
6
 
7
- | Error | Cause | Fix |
8
- |-------|-------|-----|
9
- | "Identifier PAYMENT.API not found" | Dots in identifier name | Use `payment-api` not `payment.api`; dots are FQN separators only |
10
- | "Unknown kind SERVICE" | Kind not in specification | Define `element service { ... }` in the specification block |
11
- | "Duplicate FQN cloud.backend" | Element ID repeated under the same parent | Rename one element; each sibling must have a unique identifier |
12
- | "Expected property TYPE after include *" | Malformed filter predicate | Use `include * where kind is component`, not `include * component` |
13
- | "Invalid relationship kind async-cache" | Kind not found in specification | Define `relationship async-cache { ... }` in specification first |
7
+ | Error | Cause | Fix |
8
+ | ---------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------ |
9
+ | "Identifier PAYMENT.API not found" | Dots in identifier name | Use `payment-api` not `payment.api`; dots are FQN separators only |
10
+ | "Unknown kind SERVICE" | Kind not in specification | Define `element service { ... }` in the specification block |
11
+ | "Duplicate FQN cloud.backend" | Element ID repeated under the same parent | Rename one element; each sibling must have a unique identifier |
12
+ | "Expected property TYPE after include *" | Malformed filter predicate | Use `include * where kind is component`, not `include * component` |
13
+ | "Invalid relationship kind async-cache" | Kind not found in specification | Define `relationship async-cache { ... }` in specification first |
14
14
 
15
15
  ## Model & Hierarchy
16
16
 
17
- | Error | Cause | Fix |
18
- |-------|-------|-----|
19
- | Element shows but relationships don't render | Relationship references FQN incorrectly | Use exact FQN matching the model hierarchy |
20
- | "Can't define relationship from parent to child" | Direct parent-child relationships are forbidden | Move the relationship outside the parent element or use implicit notation |
21
- | Child element not visible from other files | Referencing by short name instead of FQN | Import or use full FQN: `cloud.backend.api` |
22
- | Extend block adds duplicate tags | Tags stack on merge | Use consistent tag names; duplicates are not deduplicated automatically |
17
+ | Error | Cause | Fix |
18
+ | ------------------------------------------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
19
+ | Element shows but relationships don't render | Relationship references FQN incorrectly | Use exact FQN matching the model hierarchy |
20
+ | "Can't define relationship from parent to child" | Direct parent-child relationships are forbidden | Move the relationship outside the parent element or use implicit notation |
21
+ | Child element not visible from other files | Referencing by short name instead of FQN | Import or use full FQN: `cloud.backend.api` |
22
+ | Extend block adds duplicate tags | Tags stack on merge | Use consistent tag names; duplicates are not deduplicated automatically |
23
+ | Warning `Element 'api' not found` on `[[api]]` | Markdown link target is not an absolute FQN of the current project | Use the full FQN: `[[cloud.backend.api]]`; imported elements cannot be linked |
24
+ | Warning `Unknown link namespace 'deployment'` | Only `view:` is a known prefix in `[[…]]` | Use `[[view:id]]` or an element FQN |
25
+ | `[[cloud.api]]` shows as raw text | Plain `'…'` string, or inside inline/fenced code | Use a Markdown value `'''…'''`; move the link out of code |
26
+
27
+ Labelled link breaks a Markdown table cell: a bare pipe splits GFM table cells, so inside tables write the separator as `\\|`, e.g. `[[cloud.api\\|API]]`.
23
28
 
24
29
  ## View Predicates
25
30
 
26
- | Error | Cause | Fix |
27
- |-------|-------|-----|
28
- | `include *` shows grandchildren | Confusing `*` with `**` | `*` = direct children only; use `**` for recursive descent |
29
- | Relationships disappear in scoped view | Neighbors not explicitly included | Add `include -> scope` or `include <-> scope` to pull in inbound/outbound sources |
30
- | "WHERE predicate not matching any elements" | Tag or kind name is case-sensitive | Use exact case: `#Critical` ≠ `#critical` |
31
- | Element included but styled differently | Global vs. local style conflict | Local view styles override global; audit style rules order in the view block |
31
+ | Error | Cause | Fix |
32
+ | ------------------------------------------- | ---------------------------------- | --------------------------------------------------------------------------------- |
33
+ | `include *` shows grandchildren | Confusing `*` with `**` | `*` = direct children only; use `**` for recursive descent |
34
+ | Relationships disappear in scoped view | Neighbors not explicitly included | Add `include -> scope` or `include <-> scope` to pull in inbound/outbound sources |
35
+ | "WHERE predicate not matching any elements" | Tag or kind name is case-sensitive | Use exact case: `#Critical` ≠ `#critical` |
36
+ | Element included but styled differently | Global vs. local style conflict | Local view styles override global; audit style rules order in the view block |
32
37
 
33
38
  ## Deployment
34
39
 
35
- | Error | Cause | Fix |
36
- |-------|-------|-----|
37
- | `instanceOf` doesn't resolve | Instance refers to wrong FQN | Use the exact logical model FQN, not the deployment node identifier |
38
- | "Undefined DEPLOYMENT_KIND" | Kind referenced but not in specification | Define `deploymentNode vm { ... }` in specification |
40
+ | Error | Cause | Fix |
41
+ | --------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------ |
42
+ | `instanceOf` doesn't resolve | Instance refers to wrong FQN | Use the exact logical model FQN, not the deployment node identifier |
43
+ | "Undefined DEPLOYMENT_KIND" | Kind referenced but not in specification | Define `deploymentNode vm { ... }` in specification |
39
44
  | Deployment relationship inherits unexpectedly | Logical model edges are inherited automatically | Suppress inherited relationships explicitly in the deployment view if unwanted |
40
45
 
41
46
  ## Dynamic Views
42
47
 
43
- | Error | Cause | Fix |
44
- |-------|-------|-----|
45
- | `Nested parallel blocks are not allowed` | Nested `parallel { parallel { ... } }` (or `par`) | Flatten: put all concurrent steps in a single `parallel { }` block. Other flow blocks (`opt`/`loop`/`try`/`alt`) may nest freely |
46
- | `"loop" can not be used as an alternative branch` | Non-branch block (`loop`/`opt`/`parallel`/`try`) placed directly inside `alt` | `alt` accepts only `when`/`if`/`else` branches; nest the block inside a branch |
47
- | `"when" alternative branch must be inside "alt"` | `when`/`if`/`else` used at top level or inside a non-`alt` block | Wrap the branches in an `alt { ... }` block |
48
- | `catch`/`finally` rejected | `catch` without a preceding `try`, or `catch` after `finally` | Keep order `try` → `catch?` → `finally?` |
49
- | Response arrows (`<-`) show wrong direction | Chained `<-` steps are not supported | After `a -> b -> c`, write one `<-` step per hop: `b <- c`, then `a <- b`. `<-` cannot be chained (`a <- b <- c` is a parse error) |
50
- | `navigateTo` link doesn't work | Target view name does not exist | Ensure the target view name exists in the same project; from a dynamic step it must be another `dynamic view` |
51
- | `variant sequence` is ignored | Wrong keyword or spelling | Use exact: `variant sequence` (not `type`, `mode`, or `sequence` alone) |
48
+ | Error | Cause | Fix |
49
+ | ------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
50
+ | `Nested parallel blocks are not allowed` | Nested `parallel { parallel { ... } }` (or `par`) | Flatten: put all concurrent steps in a single `parallel { }` block. Other flow blocks (`opt`/`loop`/`try`/`alt`) may nest freely |
51
+ | `"loop" can not be used as an alternative branch` | Non-branch block (`loop`/`opt`/`parallel`/`try`) placed directly inside `alt` | `alt` accepts only `when`/`if`/`else` branches; nest the block inside a branch |
52
+ | `"when" alternative branch must be inside "alt"` | `when`/`if`/`else` used at top level or inside a non-`alt` block | Wrap the branches in an `alt { ... }` block |
53
+ | `catch`/`finally` rejected | `catch` without a preceding `try`, or `catch` after `finally` | Keep order `try` → `catch?` → `finally?` |
54
+ | Response arrows (`<-`) show wrong direction | Chained `<-` steps are not supported | After `a -> b -> c`, write one `<-` step per hop: `b <- c`, then `a <- b`. `<-` cannot be chained (`a <- b <- c` is a parse error) |
55
+ | `navigateTo` link doesn't work | Target view name does not exist | Ensure the target view name exists in the same project; from a dynamic step it must be another `dynamic view` |
56
+ | `variant sequence` is ignored | Wrong keyword or spelling | Use exact: `variant sequence` (not `type`, `mode`, or `sequence` alone) |
52
57
 
53
58
  ## Validation & Import
54
59
 
55
- | Most Common | Solution |
56
- |---|---|
57
- | `validate` reports config not found | Ensure `likec4.config.json` exists in the project root directory |
58
- | `Imported project not found` | `import` takes another project's `name` (from its `likec4.config`), not a file path: `import { x } from 'other-project'`. Files of the same project need no import; reference elements by full FQN |
59
- | Symbol from import invisible in model | Symbol must be public (defined at top level); nested elements need FQN |
60
+ | Most Common | Solution |
61
+ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62
+ | `validate` reports config not found | Ensure `likec4.config.json` exists in the project root directory |
63
+ | `Imported project not found` | `import` takes another project's `name` (from its `likec4.config`), not a file path: `import { x } from 'other-project'`. Files of the same project need no import; reference elements by full FQN |
64
+ | Symbol from import invisible in model | Symbol must be public (defined at top level); nested elements need FQN |
60
65
  | Large error count in project but your file is clean | Use `likec4 validate --json --no-layout --file <edited-file> <project-dir>` and check `filteredErrors`/`filteredFiles`; text mode can also print diagnostics from other workspace files before the filtered summary |
61
66
 
62
67
  ## Performance & Large Models
63
68
 
64
- | Symptom | Cause | Action |
65
- |---|---|---|
66
- | Validation takes >30s | Specification changes trigger full project re-parse | Keep specification in a separate file; avoid editing it frequently |
67
- | Export generates a partial PNG | Layout engine timeout on complex view | Split large views with `navigateTo` or reduce the element count |
68
- | IDE responsiveness slow | Too many open files or large specification in working file | Split into `spec.c4` + `model.c4` + `views.c4` |
69
+ | Symptom | Cause | Action |
70
+ | ------------------------------ | ---------------------------------------------------------- | ------------------------------------------------------------------ |
71
+ | Validation takes >30s | Specification changes trigger full project re-parse | Keep specification in a separate file; avoid editing it frequently |
72
+ | Export generates a partial PNG | Layout engine timeout on complex view | Split large views with `navigateTo` or reduce the element count |
73
+ | IDE responsiveness slow | Too many open files or large specification in working file | Split into `spec.c4` + `model.c4` + `views.c4` |
69
74
 
70
75
  ## Debugging Workflow
71
76
 
@@ -216,10 +216,10 @@ customer
216
216
  -> frontend "opens" // Read as "customer opens frontend"
217
217
  -> backend "requests" // Read as "frontend requests backend"
218
218
  -> database "queries" // Read as "backend queries database"
219
- <- backend "responds" // Read as "database responds to backend"
219
+ backend <- database "responds" // Read as "database responds to backend"
220
220
  ```
221
221
 
222
- Each arrow in the chain creates a separate step. The target of the previous step becomes the source of the next.
222
+ Each arrow in the chain creates a separate step. The target of the previous step becomes the source of the next. A chain can continue with `->` or a relationship-kind arrow such as `-[kind]->`. A chain cannot continue with `<-`, so write a response as its own step.
223
223
 
224
224
  ## Parallel Steps
225
225
 
@@ -33,25 +33,17 @@ declare module 'likec4:projects-overview' {
33
33
  }
34
34
 
35
35
  declare module 'likec4:icons' {
36
- import type { ReactNode } from 'react'
37
-
38
- export type ElementIconRendererProps = {
39
- node: {
40
- id: string
41
- title: string
42
- icon?: string | null | undefined
43
- }
44
- }
36
+ import type { ElementIconRenderer, ElementIconRendererProps } from 'likec4/react'
45
37
 
46
- export type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode
38
+ export type { ElementIconRenderer, ElementIconRendererProps }
47
39
  export function getProjectIcons(projectId: string): ElementIconRenderer
48
40
  }
49
41
 
50
42
  declare module 'likec4:model' {
51
- import type { DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted } from 'likec4/model'
43
+ import type { DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted, ViewId } from 'likec4/model'
52
44
  import type { Atom } from 'likec4/vite-plugin/internal'
53
45
 
54
- export type { Atom, DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted }
46
+ export type { Atom, DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted, ViewId }
55
47
 
56
48
  export function loadModel(projectId: string): Promise<{
57
49
  $likec4data: Atom<LayoutedLikeC4ModelData>
@@ -59,6 +51,7 @@ declare module 'likec4:model' {
59
51
  useLikeC4Model: () => LikeC4Model<UnknownLayouted>
60
52
  useLikeC4Views: () => ReadonlyArray<DiagramView<UnknownLayouted>>
61
53
  useLikeC4View: (viewId: string) => DiagramView<UnknownLayouted> | null
54
+ isLikeC4ViewId: (value: unknown) => value is ViewId
62
55
  }>
63
56
  }
64
57
 
@@ -69,15 +62,19 @@ declare module 'likec4:single-project' {
69
62
  LikeC4Model,
70
63
  types,
71
64
  UnknownLayouted,
65
+ ViewId,
72
66
  } from 'likec4/model'
73
67
  import type { Atom } from 'likec4/vite-plugin/internal'
74
68
  import type { ElementIconRenderer } from 'likec4:icons'
75
69
 
70
+ export type { Atom, DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted, ViewId }
71
+
76
72
  export const $likec4data: Atom<LayoutedLikeC4ModelData>
77
73
  export const $likec4model: Atom<LikeC4Model<UnknownLayouted>>
78
74
  export function useLikeC4Model(): LikeC4Model<UnknownLayouted>
79
75
  export function useLikeC4Views(): ReadonlyArray<DiagramView<UnknownLayouted>>
80
76
  export function useLikeC4View(viewId: string): DiagramView<UnknownLayouted> | null
77
+ export function isLikeC4ViewId(value: unknown): value is ViewId
81
78
 
82
79
  export const IconRenderer: ElementIconRenderer
83
80
 
@@ -85,23 +82,39 @@ declare module 'likec4:single-project' {
85
82
  }
86
83
 
87
84
  declare module 'likec4:react' {
88
- import type { aux, DiagramView, LikeC4Model, UnknownLayouted } from 'likec4/model'
89
- import type { LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
85
+ import type {
86
+ aux,
87
+ DiagramView,
88
+ LayoutedLikeC4ModelData,
89
+ LayoutedView,
90
+ LikeC4Model,
91
+ UnknownLayouted,
92
+ } from 'likec4/model'
93
+ import type { ElementIconRendererProps, LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
90
94
  import type { JSX, PropsWithChildren } from 'react'
95
+ import type { Atom } from 'likec4/vite-plugin/internal'
91
96
 
92
- // This will be used later for augmenting the types
93
- interface Types extends UnknownLayouted {
97
+ export type { Atom, DiagramView, LayoutedView, LikeC4Model, UnknownLayouted }
98
+
99
+ // This will be used for augmenting the types
100
+ export interface Register {
94
101
  }
102
+ export type $Types<T = Register> = T extends { aux: infer A extends aux.Any } ? A : UnknownLayouted
95
103
 
96
- export type LikeC4ViewId = aux.ViewId<Types>
104
+ export type LikeC4ViewId = aux.ViewId<$Types>
97
105
 
98
- export function useLikeC4Model(): LikeC4Model<Types>
99
- export function useLikeC4Views(): ReadonlyArray<DiagramView<Types>>
100
- export function useLikeC4View(viewId: LikeC4ViewId): DiagramView<Types> | null
106
+ // Re-export from likec4:model
107
+ export const $likec4data: Atom<LayoutedLikeC4ModelData<$Types>>
108
+ export const $likec4model: Atom<LikeC4Model<$Types>>
109
+ export function useLikeC4Model(): LikeC4Model<$Types>
110
+ export function useLikeC4Views(): ReadonlyArray<LayoutedView<$Types>>
111
+ export function useLikeC4View(viewId: LikeC4ViewId): LayoutedView<$Types> | null
112
+ export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId
101
113
 
102
114
  export function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element
103
- export function LikeC4View({ viewId, ...props }: LikeC4ViewProps<Types>): JSX.Element
104
- export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props<Types>): JSX.Element
115
+ export function LikeC4View({ viewId, ...props }: LikeC4ViewProps<$Types>): JSX.Element
116
+ export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props<$Types>): JSX.Element
117
+ export function IconRenderer(props: ElementIconRendererProps): JSX.Element
105
118
  }
106
119
 
107
120
  declare module 'likec4:dot' {
@@ -130,56 +143,102 @@ declare module 'likec4:drawio' {
130
143
  drawioEditUrl(this: void, viewId: string): string
131
144
  }>
132
145
  }
146
+ declare module 'likec4:diffs' {
147
+ import type { DiffSummary, LayoutedView } from 'likec4/model'
148
+ import type { Atom } from 'likec4/vite-plugin/internal'
149
+
150
+ /**
151
+ * Diffs of the project, with the compare views of the views they change (by diff id, then by view id)
152
+ */
153
+ export interface ProjectDiffs {
154
+ diffs: DiffSummary[]
155
+ views: Record<string, Record<string, LayoutedView>>
156
+ }
157
+
158
+ export function loadDiffs(projectId: string): Promise<{
159
+ $diffs: Atom<ProjectDiffs>
160
+ }>
161
+ }
133
162
 
134
163
  // Per project
135
164
 
165
+ declare module 'likec4:diffs/*' {
166
+ import type { ProjectDiffs } from 'likec4:diffs'
167
+ import type { Atom } from 'likec4/vite-plugin/internal'
168
+
169
+ export const $diffs: Atom<ProjectDiffs>
170
+ }
171
+
136
172
  declare module 'likec4:model/*' {
137
- import type { aux, DiagramView, LayoutedLikeC4ModelData, LikeC4Model, UnknownLayouted } from 'likec4/model'
138
- import type { Atom } from 'likec4:model'
173
+ import type {
174
+ aux,
175
+ DiagramView,
176
+ LayoutedLikeC4ModelData,
177
+ LayoutedView,
178
+ LikeC4Model,
179
+ UnknownLayouted,
180
+ } from 'likec4/model'
181
+ import type { ElementIconRendererProps, LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
182
+ import type { Atom } from 'likec4/vite-plugin/internal'
183
+
184
+ export type { Atom, DiagramView, LayoutedView, LikeC4Model, UnknownLayouted }
139
185
 
140
- // This will be used later for augmenting the types
141
- interface Types extends UnknownLayouted {
186
+ // This will be used for augmenting the types
187
+ export interface Register {
142
188
  }
189
+ export type $Types<T = Register> = T extends { aux: infer A extends aux.Any } ? A : UnknownLayouted
143
190
 
144
- export type LikeC4ViewId = aux.ViewId<Types>
191
+ export type LikeC4ViewId = aux.ViewId<$Types>
145
192
 
146
- export const $likec4data: Atom<LayoutedLikeC4ModelData<Types>>
147
- export const $likec4model: Atom<LikeC4Model<Types>>
148
- export function useLikeC4Model(): LikeC4Model<Types>
149
- export function useLikeC4Views(): ReadonlyArray<DiagramView<Types>>
150
- export function useLikeC4View(viewId: LikeC4ViewId): DiagramView<Types> | null
193
+ export const $likec4data: Atom<LayoutedLikeC4ModelData<$Types>>
194
+ export const $likec4model: Atom<LikeC4Model<$Types>>
195
+ export function useLikeC4Model(): LikeC4Model<$Types>
196
+ export function useLikeC4Views(): ReadonlyArray<LayoutedView<$Types>>
197
+ export function useLikeC4View(viewId: LikeC4ViewId): LayoutedView<$Types> | null
198
+ export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId
151
199
  }
152
200
 
153
201
  declare module 'likec4:icons/*' {
154
- import type { ReactNode } from 'react'
155
- type ElementIconRendererProps = {
156
- node: {
157
- id: string
158
- title: string
159
- icon?: string | null | undefined
160
- }
161
- }
162
- export function IconRenderer(props: ElementIconRendererProps): ReactNode
202
+ import type { JSX } from 'react'
203
+ import type { ElementIconRendererProps } from 'likec4/react'
204
+
205
+ export function IconRenderer(props: ElementIconRendererProps): JSX.Element
163
206
  }
164
207
 
165
208
  declare module 'likec4:react/*' {
166
- import type { aux, DiagramView, LikeC4Model, UnknownLayouted } from 'likec4/model'
167
- import type { LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
209
+ import type {
210
+ aux,
211
+ DiagramView,
212
+ LayoutedLikeC4ModelData,
213
+ LayoutedView,
214
+ LikeC4Model,
215
+ UnknownLayouted,
216
+ } from 'likec4/model'
217
+ import type { ElementIconRendererProps, LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
168
218
  import type { JSX, PropsWithChildren } from 'react'
219
+ import type { Atom } from 'likec4/vite-plugin/internal'
169
220
 
170
- // This will be used later for augmenting the types
171
- interface Types extends UnknownLayouted {
221
+ export type { Atom, DiagramView, LayoutedView, LikeC4Model, UnknownLayouted }
222
+
223
+ // This will be used for augmenting the types
224
+ export interface Register {
172
225
  }
226
+ export type $Types<T = Register> = T extends { aux: infer A extends aux.Any } ? A : UnknownLayouted
173
227
 
174
- export type LikeC4ViewId = aux.ViewId<Types>
228
+ export type LikeC4ViewId = aux.ViewId<$Types>
175
229
 
176
- export function useLikeC4Model(): LikeC4Model<Types>
177
- export function useLikeC4Views(): ReadonlyArray<DiagramView<Types>>
178
- export function useLikeC4View(viewId: LikeC4ViewId): DiagramView<Types> | null
230
+ // Re-export from likec4:model
231
+ export const $likec4data: Atom<LayoutedLikeC4ModelData<$Types>>
232
+ export const $likec4model: Atom<LikeC4Model<$Types>>
233
+ export function useLikeC4Model(): LikeC4Model<$Types>
234
+ export function useLikeC4Views(): ReadonlyArray<LayoutedView<$Types>>
235
+ export function useLikeC4View(viewId: LikeC4ViewId): LayoutedView<$Types> | null
236
+ export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId
179
237
 
180
238
  export function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element
181
- export function LikeC4View({ viewId, ...props }: LikeC4ViewProps<Types>): JSX.Element
182
- export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props<Types>): JSX.Element
239
+ export function LikeC4View({ viewId, ...props }: LikeC4ViewProps<$Types>): JSX.Element
240
+ export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props<$Types>): JSX.Element
241
+ export function IconRenderer(props: ElementIconRendererProps): JSX.Element
183
242
  }
184
243
 
185
244
  declare module 'likec4:webcomponents/*' {
@@ -207,6 +266,9 @@ declare module 'likec4:rpc' {
207
266
  declare module 'likec4:app-config' {
208
267
  export let ComponentName: {
209
268
  View: string
269
+ /**
270
+ * @deprecated
271
+ */
210
272
  Browser: string
211
273
  }
212
274
  export let pageTitle: string
@@ -217,3 +279,16 @@ declare module 'likec4:app-config' {
217
279
  export let krokiD2SvgUrl: string
218
280
  export let krokiPumlSvgUrl: string
219
281
  }
282
+
283
+ declare module 'likec4:customization' {
284
+ import type { CustomComponents } from 'likec4/react'
285
+ import type { Atom } from 'likec4/vite-plugin/internal'
286
+
287
+ export type { CustomComponents }
288
+
289
+ /**
290
+ * UI overrides from the file set in the `customization` option of the LikeC4 Vite plugin
291
+ */
292
+ export const $customComponents: Atom<CustomComponents | undefined>
293
+ export function useCustomComponents(): CustomComponents | undefined
294
+ }