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
@@ -1,827 +0,0 @@
1
- import "./rolldown-runtime.mjs";
2
- import { O as t, w as useSyncedRef } from "./hooks.mjs";
3
- import { $ as useCallbackRef, D as EnsureMantine, E as FramerMotionConfig, F as Base, P as BaseXYFlow, R as bezierPath, a as ElementNodeContainer, b as useId$1, c as EdgePath, d as EdgeContainer, f as Logo$1, ht as t$1, i as ElementShape, k as RootContainer, l as EdgeLabelContainer, m as useChangeLikeC4Project, n as DefaultHandles, nt as MinZoom, o as ElementData, p as LogoIcon, r as memoEdge, rt as ZIndexes, s as ElementActionButtons, st as IconZoomScan, t as LikeC4Styles, u as EdgeLabel } from "./LikeC4Styles.mjs";
4
- import { fn as useCallbackRef$1 } from "./libs/@mantine.mjs";
5
- import { A as createStyleContext, I as cx, M as isCssProperty, t as navigationPanel } from "./styled-system.mjs";
6
- import { C as getViewportForBounds, c as ReactFlowProvider, d as applyNodeChanges, g as useStoreApi, u as applyEdgeChanges } from "./libs/@xyflow/react.mjs";
7
- import { n as shallowEqual } from "./libs/fast-equals.mjs";
8
- import { _ as stagger, d as isValidMotionProp, g as mapValue, i as m, o as animate, p as LayoutGroup, v as styleEffect, y as motionValue } from "./libs/framer.mjs";
9
- import { a as emit, i as setup, l as assign, n as useSelector, r as assertEvent, t as useActorRef } from "./libs/@xstate/react.mjs";
10
- import { createContext, forwardRef, memo, useContext, useEffect, useRef } from "react";
11
- import { c } from "react/compiler-runtime";
12
- import { jsx, jsxs } from "react/jsx-runtime";
13
- import { invariant, nonNullable, nonexhaustive } from "@likec4/core";
14
- import { useLikeC4ProjectsOverview } from "likec4:projects-overview";
15
- //#region ../diagram/src/projects-overview/layouted-to-xyflow.ts
16
- function layoutedProjectsViewToXYFlow(view) {
17
- return {
18
- xynodes: t(view.nodes, projectNodeToXY),
19
- xyedges: t(view.edges, projectEdgeToXY)
20
- };
21
- }
22
- function projectNodeToXY({ id, x, y, width, height, ...node }) {
23
- return {
24
- id,
25
- position: {
26
- x,
27
- y
28
- },
29
- type: "project",
30
- initialWidth: width,
31
- initialHeight: height,
32
- draggable: false,
33
- deletable: false,
34
- zIndex: ZIndexes.Element,
35
- style: {
36
- width,
37
- height
38
- },
39
- data: {
40
- id,
41
- width,
42
- height,
43
- ...node
44
- }
45
- };
46
- }
47
- function projectEdgeToXY({ id, source, target, ...edge }) {
48
- return {
49
- id,
50
- source,
51
- target,
52
- type: "relationship",
53
- zIndex: ZIndexes.Edge,
54
- deletable: false,
55
- data: {
56
- id,
57
- technology: null,
58
- labelBBox: null,
59
- ...edge
60
- }
61
- };
62
- }
63
- //#endregion
64
- //#region ../diagram/src/projects-overview/persistence.ts
65
- var key = `likec4:projects-overview:lastViewport`;
66
- var ProjectsOverviewViewportPersistence = {
67
- read() {
68
- try {
69
- let fromStorage = sessionStorage.getItem(key);
70
- if (fromStorage) return JSON.parse(fromStorage);
71
- return null;
72
- } catch (e) {
73
- console.error(`Error reading fromStorage ${key}:`, e);
74
- return null;
75
- }
76
- },
77
- write(viewport) {
78
- if (!viewport) {
79
- sessionStorage.removeItem(key);
80
- return;
81
- }
82
- sessionStorage.setItem(key, JSON.stringify(viewport));
83
- }
84
- };
85
- //#endregion
86
- //#region ../diagram/src/projects-overview/actor.ts
87
- var machine = setup({
88
- types: {
89
- context: {},
90
- tags: "",
91
- input: {},
92
- events: {},
93
- emitted: {}
94
- },
95
- guards: {
96
- isReady: ({ context }) => context.initialized.xydata && context.initialized.xyflow && !!context.xystore && !!context.xyflow,
97
- "click: selected node": ({ event }) => {
98
- return event.type === "xyflow.click.node" && event.node.selected === true;
99
- }
100
- }
101
- });
102
- var updateView = () => machine.assign(({ event }) => {
103
- assertEvent(event, "update.view");
104
- const { xynodes, xyedges } = layoutedProjectsViewToXYFlow(event.view);
105
- return {
106
- view: event.view,
107
- xynodes,
108
- xyedges
109
- };
110
- });
111
- var xyflowApplyNodeChanges = () => machine.assign(({ context, event }) => {
112
- assertEvent(event, "xyflow.applyNodeChanges");
113
- return { xynodes: applyNodeChanges(event.changes, context.xynodes) };
114
- });
115
- var xyflowApplyEdgeChanges = () => machine.assign(({ context, event }) => {
116
- assertEvent(event, "xyflow.applyEdgeChanges");
117
- return { xyedges: applyEdgeChanges(event.changes, context.xyedges) };
118
- });
119
- var onMouseEnterOrLeave = () => machine.assign(({ context, event }) => {
120
- assertEvent(event, [
121
- "xyflow.mouse.enter.edge",
122
- "xyflow.mouse.leave.edge",
123
- "xyflow.mouse.enter.node",
124
- "xyflow.mouse.leave.node"
125
- ]);
126
- const isEnter = event.type.startsWith("xyflow.mouse.enter");
127
- switch (event.type) {
128
- case "xyflow.mouse.enter.edge":
129
- case "xyflow.mouse.leave.edge": {
130
- const edgeId = event.edge.id;
131
- return { xyedges: context.xyedges.map((e) => {
132
- if (e.id === edgeId) return Base.setHovered(e, isEnter);
133
- return e;
134
- }) };
135
- }
136
- case "xyflow.mouse.enter.node":
137
- case "xyflow.mouse.leave.node": {
138
- const nodeId = event.node.id;
139
- return { xynodes: context.xynodes.map((n) => {
140
- if (n.id === nodeId) return Base.setHovered(n, isEnter);
141
- return n;
142
- }) };
143
- }
144
- default: nonexhaustive(event);
145
- }
146
- });
147
- var saveViewport = () => machine.createAction(({ context }) => {
148
- const xyflow = context.xyflow;
149
- if (xyflow) ProjectsOverviewViewportPersistence.write(xyflow.getViewport());
150
- });
151
- var handleClick = () => machine.enqueueActions(({ event, enqueue }) => {
152
- if (event.type === "xyflow.click.double") {
153
- enqueue(fitDiagram());
154
- return;
155
- }
156
- });
157
- var fitDiagram = (params) => machine.enqueueActions(({ context, event }) => {
158
- let bounds = context.view.bounds;
159
- let duration;
160
- if (params) {
161
- bounds = params.bounds ?? context.view.bounds;
162
- duration = params.duration;
163
- } else if (event.type === "xyflow.fitDiagram") {
164
- bounds = event.bounds ?? context.view.bounds;
165
- duration = event.duration;
166
- }
167
- duration ??= 450;
168
- const { width, height, panZoom, transform } = nonNullable(context.xystore).getState();
169
- const maxZoom = Math.max(1, transform[2]);
170
- const viewport = getViewportForBounds(bounds, width, height, MinZoom, maxZoom, context.fitViewPadding);
171
- viewport.x = Math.round(viewport.x);
172
- viewport.y = Math.round(viewport.y);
173
- const animationProps = duration > 0 ? {
174
- duration,
175
- interpolate: "smooth"
176
- } : void 0;
177
- panZoom?.setViewport(viewport, animationProps).catch((err) => {
178
- console.error("Error during fitDiagram panZoom setViewport", { err });
179
- });
180
- ProjectsOverviewViewportPersistence.write(null);
181
- });
182
- var restoreViewport = () => machine.enqueueActions(({ context, enqueue }) => {
183
- const viewport = ProjectsOverviewViewportPersistence.read();
184
- if (viewport) {
185
- nonNullable(context.xyflow).setViewport(viewport, { duration: 0 });
186
- return;
187
- }
188
- enqueue(fitDiagram({ duration: 0 }));
189
- });
190
- var dispose = () => machine.assign({
191
- xyflow: null,
192
- xystore: null,
193
- initialized: {
194
- xyflow: false,
195
- xydata: false
196
- },
197
- xyedges: [],
198
- xynodes: []
199
- });
200
- var assignNavigateTo = () => machine.assign(({ event, context }) => {
201
- let navigateTo;
202
- switch (event.type) {
203
- case "xyflow.click.node":
204
- navigateTo = event.node;
205
- break;
206
- case "navigate.to":
207
- navigateTo = nonNullable(context.xynodes.find((n) => n.id === event.fromNode), `Node ${event.fromNode} not found`);
208
- break;
209
- default:
210
- console.warn(`Unexpected event ${event.type} in assignNavigateTo`);
211
- return {};
212
- }
213
- return { navigateTo };
214
- });
215
- var projectOverviewLogic = machine.createMachine({
216
- id: "projects-overview",
217
- context: ({ input }) => ({
218
- ...input,
219
- initialized: {
220
- xydata: false,
221
- xyflow: false
222
- },
223
- xyflow: null,
224
- xystore: null,
225
- xynodes: [],
226
- xyedges: []
227
- }),
228
- initial: "init",
229
- on: { "close": { target: ".closed" } },
230
- states: {
231
- init: { on: {
232
- "update.view": {
233
- actions: [updateView(), assign(({ context }) => ({ initialized: {
234
- ...context.initialized,
235
- xydata: true
236
- } }))],
237
- target: "isReady"
238
- },
239
- "xyflow.init": {
240
- actions: [assign(({ context, event }) => ({
241
- initialized: {
242
- ...context.initialized,
243
- xyflow: true
244
- },
245
- xyflow: event.xyflow,
246
- xystore: event.xystore
247
- }))],
248
- target: "isReady"
249
- }
250
- } },
251
- isReady: { always: [{
252
- guard: "isReady",
253
- target: "active"
254
- }, { target: "init" }] },
255
- active: {
256
- tags: "active",
257
- entry: [restoreViewport()],
258
- on: {
259
- "navigate.to": {
260
- actions: assignNavigateTo(),
261
- target: "navigate"
262
- },
263
- "xyflow.applyNodeChanges": { actions: xyflowApplyNodeChanges() },
264
- "xyflow.applyEdgeChanges": { actions: xyflowApplyEdgeChanges() },
265
- "xyflow.mouse.*": { actions: onMouseEnterOrLeave() },
266
- "xyflow.click.*": [{
267
- guard: "click: selected node",
268
- actions: assignNavigateTo(),
269
- target: "navigate"
270
- }, { actions: handleClick() }],
271
- "xyflow.fitDiagram": { actions: fitDiagram() },
272
- "update.view": { actions: updateView() }
273
- }
274
- },
275
- navigate: {
276
- tags: "active",
277
- entry: [
278
- saveViewport(),
279
- assign({ xyedges: [] }),
280
- ({ context: { navigateTo, xyflow, xystore }, self }) => {
281
- invariant(xyflow && navigateTo, "Invalid state, xyflow is undefined");
282
- const { width, domNode } = nonNullable(xystore).getState();
283
- const nextZoom = t$1(Math.min(width * 7 / 9 / navigateTo.data.width), {
284
- min: MinZoom,
285
- max: 2.5
286
- });
287
- const next = {
288
- x: Math.round(-nextZoom * navigateTo.position.x + (width - nextZoom * navigateTo.data.width) / 2),
289
- y: Math.round(-nextZoom * navigateTo.position.y) + 50
290
- };
291
- const current = xyflow.getViewport();
292
- const otherNodes = domNode.querySelectorAll(`.react-flow__node-project:not([data-id="${navigateTo.id}"]) > *`);
293
- const otherNodesAnimation = animate(otherNodes, {
294
- opacity: 0,
295
- scale: .9
296
- }, {
297
- visualDuration: .25,
298
- delay: stagger(.08, { from: "center" })
299
- });
300
- const v = motionValue(1);
301
- const transform = mapValue(v, [1, 0], [`translate(${current.x}px, ${current.y}px) scale(${current.zoom})`, `translate(${next.x}px, ${next.y}px) scale(${nextZoom})`]);
302
- const cancelViewportAnimation = styleEffect(domNode.querySelector(".xyflow__viewport"), { transform });
303
- const cancelOpacityAnimation = styleEffect(domNode.querySelector(`.react-flow__node-project:is([data-id="${navigateTo.id}"]) > *`), { opacity: v });
304
- const targetAnimation = animate(v, 0, {
305
- delay: otherNodes.length > 3 ? .25 : 0,
306
- type: "spring",
307
- stiffness: 350,
308
- damping: 40,
309
- mass: 1.5,
310
- visualDuration: .55
311
- });
312
- Promise.race([targetAnimation.finished, sleep(750)]).then(() => {
313
- cancelViewportAnimation();
314
- cancelOpacityAnimation();
315
- targetAnimation.stop();
316
- otherNodesAnimation.stop();
317
- self.send({
318
- type: "emit.navigate.to",
319
- projectId: navigateTo.data.projectId
320
- });
321
- });
322
- }
323
- ],
324
- on: { "emit.navigate.to": { actions: emit(({ event }) => ({
325
- ...event,
326
- type: "navigate.to"
327
- })) } }
328
- },
329
- closed: {
330
- id: "closed",
331
- type: "final",
332
- entry: dispose()
333
- }
334
- }
335
- });
336
- function sleep(ms) {
337
- return new Promise((resolve) => setTimeout(resolve, ms));
338
- }
339
- //#endregion
340
- //#region ../diagram/src/projects-overview/context.ts
341
- var ProjectsOverviewActorContext = createContext(null);
342
- var ProjectsOverviewActorContextProvider = ProjectsOverviewActorContext.Provider;
343
- function useProjectsOverviewActor() {
344
- const $ = c(2);
345
- const t0 = useContext(ProjectsOverviewActorContext);
346
- let t1;
347
- if ($[0] !== t0) {
348
- t1 = nonNullable(t0, "No ProjectsOverviewActorContext");
349
- $[0] = t0;
350
- $[1] = t1;
351
- } else t1 = $[1];
352
- return t1;
353
- }
354
- //#endregion
355
- //#region ../diagram/src/components/NavigationPanel.tsx
356
- var { withProvider, withContext } = createStyleContext(navigationPanel);
357
- var shouldForwardProp = (prop, variantKeys) => !variantKeys.includes(prop) && (isValidMotionProp(prop) || !isCssProperty(prop));
358
- var LogoButton = forwardRef((t0, ref) => {
359
- const $ = c(11);
360
- let className;
361
- let props;
362
- if ($[0] !== t0) {
363
- ({className, ...props} = t0);
364
- $[0] = t0;
365
- $[1] = className;
366
- $[2] = props;
367
- } else {
368
- className = $[1];
369
- props = $[2];
370
- }
371
- let t1;
372
- if ($[3] !== className) {
373
- t1 = cx("mantine-active", className);
374
- $[3] = className;
375
- $[4] = t1;
376
- } else t1 = $[4];
377
- let t2;
378
- let t3;
379
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
380
- t2 = /* @__PURE__ */ jsx(LogoIcon, { "data-logo-icon": true });
381
- t3 = /* @__PURE__ */ jsx(Logo$1, { "data-logo-full": true });
382
- $[5] = t2;
383
- $[6] = t3;
384
- } else {
385
- t2 = $[5];
386
- t3 = $[6];
387
- }
388
- let t4;
389
- if ($[7] !== props || $[8] !== ref || $[9] !== t1) {
390
- t4 = /* @__PURE__ */ jsxs("button", {
391
- ...props,
392
- ref,
393
- className: t1,
394
- children: [t2, t3]
395
- });
396
- $[7] = props;
397
- $[8] = ref;
398
- $[9] = t1;
399
- $[10] = t4;
400
- } else t4 = $[10];
401
- return t4;
402
- });
403
- var NavigationPanel = {
404
- Root: withProvider(m.div, "root", { shouldForwardProp }),
405
- Body: withContext(m.div, "body", { shouldForwardProp }),
406
- Logo: withContext(LogoButton, "logo", { shouldForwardProp }),
407
- Label: withContext(m.div, "label", { shouldForwardProp }),
408
- Dropdown: withContext(m.div, "dropdown", { shouldForwardProp })
409
- };
410
- //#endregion
411
- //#region ../diagram/src/projects-overview/panel/ProjectsOverviewPanel.tsx
412
- var ProjectsOverviewPanel = () => {
413
- const $ = c(1);
414
- let t0;
415
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
416
- t0 = /* @__PURE__ */ jsx(NavigationPanel.Root, { children: /* @__PURE__ */ jsxs(NavigationPanel.Body, { children: [/* @__PURE__ */ jsx(NavigationPanel.Logo, {}), /* @__PURE__ */ jsx(NavigationPanel.Label, { children: "Projects Overview" })] }) });
417
- $[0] = t0;
418
- } else t0 = $[0];
419
- return t0;
420
- };
421
- //#endregion
422
- //#region ../diagram/src/projects-overview/custom/edgeTypes.tsx
423
- var RelationshipEdge = memoEdge((edgeProps) => {
424
- const path = bezierPath(edgeProps.data.points);
425
- return /* @__PURE__ */ jsxs(EdgeContainer, {
426
- ...edgeProps,
427
- children: [/* @__PURE__ */ jsx(EdgePath, {
428
- edgeProps,
429
- svgPath: path
430
- }), /* @__PURE__ */ jsx(EdgeLabelContainer, {
431
- edgeProps,
432
- children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps })
433
- })]
434
- });
435
- });
436
- //#endregion
437
- //#region ../diagram/src/projects-overview/custom/nodeTypes.tsx
438
- function ProjectNode(props) {
439
- const $ = c(19);
440
- const actor = useProjectsOverviewActor();
441
- let t0;
442
- if ($[0] !== actor || $[1] !== props.data.id || $[2] !== props.data.projectId) {
443
- t0 = (e) => {
444
- e.stopPropagation();
445
- actor.send({
446
- type: "navigate.to",
447
- fromNode: props.data.id,
448
- projectId: props.data.projectId
449
- });
450
- };
451
- $[0] = actor;
452
- $[1] = props.data.id;
453
- $[2] = props.data.projectId;
454
- $[3] = t0;
455
- } else t0 = $[3];
456
- const navigateTo = useCallbackRef$1(t0);
457
- let t1;
458
- let t2;
459
- if ($[4] !== props) {
460
- t1 = /* @__PURE__ */ jsx(ElementShape, { ...props });
461
- t2 = /* @__PURE__ */ jsx(ElementData, { ...props });
462
- $[4] = props;
463
- $[5] = t1;
464
- $[6] = t2;
465
- } else {
466
- t1 = $[5];
467
- t2 = $[6];
468
- }
469
- let t3;
470
- if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
471
- t3 = /* @__PURE__ */ jsx(IconZoomScan, {});
472
- $[7] = t3;
473
- } else t3 = $[7];
474
- let t4;
475
- if ($[8] !== navigateTo) {
476
- t4 = [{
477
- key: "navigate",
478
- icon: t3,
479
- onClick: navigateTo
480
- }];
481
- $[8] = navigateTo;
482
- $[9] = t4;
483
- } else t4 = $[9];
484
- let t5;
485
- if ($[10] !== props || $[11] !== t4) {
486
- t5 = /* @__PURE__ */ jsx(ElementActionButtons, {
487
- ...props,
488
- buttons: t4
489
- });
490
- $[10] = props;
491
- $[11] = t4;
492
- $[12] = t5;
493
- } else t5 = $[12];
494
- let t6;
495
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
496
- t6 = /* @__PURE__ */ jsx(DefaultHandles, {});
497
- $[13] = t6;
498
- } else t6 = $[13];
499
- let t7;
500
- if ($[14] !== props || $[15] !== t1 || $[16] !== t2 || $[17] !== t5) {
501
- t7 = /* @__PURE__ */ jsxs(ElementNodeContainer, {
502
- layout: true,
503
- nodeProps: props,
504
- children: [
505
- t1,
506
- t2,
507
- t5,
508
- t6
509
- ]
510
- }, props.id);
511
- $[14] = props;
512
- $[15] = t1;
513
- $[16] = t2;
514
- $[17] = t5;
515
- $[18] = t7;
516
- } else t7 = $[18];
517
- return t7;
518
- }
519
- //#endregion
520
- //#region ../diagram/src/projects-overview/hooks.ts
521
- function useProjectsOverviewState(selector, t0) {
522
- const compare = t0 === void 0 ? shallowEqual : t0;
523
- const actor = useProjectsOverviewActor();
524
- return useSelector(actor, selector, compare);
525
- }
526
- function useProjectsOverviewXYStoreApi() {
527
- return useStoreApi();
528
- }
529
- //#endregion
530
- //#region ../diagram/src/projects-overview/ProjectsOverviewXY.tsx
531
- var nodeTypes = { project: ProjectNode };
532
- var edgeTypes = { relationship: RelationshipEdge };
533
- var selector = (state) => ({
534
- isActive: state.hasTag("active"),
535
- nodes: state.context.xynodes,
536
- edges: state.context.xyedges
537
- });
538
- var selectorEq = (a, b) => a.isActive === b.isActive && shallowEqual(a.nodes, b.nodes) && shallowEqual(a.edges, b.edges);
539
- var ProjectsOverviewXY = memo((t0) => {
540
- const $ = c(45);
541
- let props;
542
- let t1;
543
- if ($[0] !== t0) {
544
- ({background: t1, ...props} = t0);
545
- $[0] = t0;
546
- $[1] = props;
547
- $[2] = t1;
548
- } else {
549
- props = $[1];
550
- t1 = $[2];
551
- }
552
- const background = t1 === void 0 ? "dots" : t1;
553
- const actorRef = useProjectsOverviewActor();
554
- const { isActive, nodes, edges } = useProjectsOverviewState(selector, selectorEq);
555
- const xystore = useProjectsOverviewXYStoreApi();
556
- const t2 = isActive ? "initialized" : "not-initialized";
557
- let t3;
558
- if ($[3] !== t2) {
559
- t3 = cx(t2, "projects-overview");
560
- $[3] = t2;
561
- $[4] = t3;
562
- } else t3 = $[4];
563
- let t4;
564
- if ($[5] !== actorRef) {
565
- t4 = (_e, node) => {
566
- _e.stopPropagation();
567
- actorRef.send({
568
- type: "xyflow.click.node",
569
- node
570
- });
571
- };
572
- $[5] = actorRef;
573
- $[6] = t4;
574
- } else t4 = $[6];
575
- const t5 = useCallbackRef(t4);
576
- let t6;
577
- if ($[7] !== actorRef) {
578
- t6 = (_e_0, edge) => {
579
- _e_0.stopPropagation();
580
- actorRef.send({
581
- type: "xyflow.click.edge",
582
- edge
583
- });
584
- };
585
- $[7] = actorRef;
586
- $[8] = t6;
587
- } else t6 = $[8];
588
- const t7 = useCallbackRef(t6);
589
- let t8;
590
- if ($[9] !== actorRef) {
591
- t8 = (_e_1) => {
592
- _e_1.stopPropagation();
593
- actorRef.send({ type: "xyflow.click.pane" });
594
- };
595
- $[9] = actorRef;
596
- $[10] = t8;
597
- } else t8 = $[10];
598
- const t9 = useCallbackRef(t8);
599
- let t10;
600
- if ($[11] !== actorRef) {
601
- t10 = (_e_2) => {
602
- _e_2.stopPropagation();
603
- actorRef.send({ type: "xyflow.click.double" });
604
- };
605
- $[11] = actorRef;
606
- $[12] = t10;
607
- } else t10 = $[12];
608
- const t11 = useCallbackRef(t10);
609
- let t12;
610
- if ($[13] !== actorRef) {
611
- t12 = (changes) => {
612
- actorRef.send({
613
- type: "xyflow.applyNodeChanges",
614
- changes
615
- });
616
- };
617
- $[13] = actorRef;
618
- $[14] = t12;
619
- } else t12 = $[14];
620
- const t13 = useCallbackRef(t12);
621
- let t14;
622
- if ($[15] !== actorRef) {
623
- t14 = (changes_0) => {
624
- actorRef.send({
625
- type: "xyflow.applyEdgeChanges",
626
- changes: changes_0
627
- });
628
- };
629
- $[15] = actorRef;
630
- $[16] = t14;
631
- } else t14 = $[16];
632
- const t15 = useCallbackRef(t14);
633
- let t16;
634
- if ($[17] !== actorRef) {
635
- t16 = (event, edge_0) => {
636
- actorRef.send({
637
- type: "xyflow.mouse.enter.edge",
638
- edge: edge_0,
639
- event
640
- });
641
- };
642
- $[17] = actorRef;
643
- $[18] = t16;
644
- } else t16 = $[18];
645
- const t17 = useCallbackRef(t16);
646
- let t18;
647
- if ($[19] !== actorRef) {
648
- t18 = (event_0, edge_1) => {
649
- actorRef.send({
650
- type: "xyflow.mouse.leave.edge",
651
- edge: edge_1,
652
- event: event_0
653
- });
654
- };
655
- $[19] = actorRef;
656
- $[20] = t18;
657
- } else t18 = $[20];
658
- const t19 = useCallbackRef(t18);
659
- let t20;
660
- if ($[21] !== actorRef) {
661
- t20 = (event_1, node_0) => {
662
- actorRef.send({
663
- type: "xyflow.mouse.enter.node",
664
- node: node_0
665
- });
666
- };
667
- $[21] = actorRef;
668
- $[22] = t20;
669
- } else t20 = $[22];
670
- const t21 = useCallbackRef(t20);
671
- let t22;
672
- if ($[23] !== actorRef) {
673
- t22 = (event_2, node_1) => {
674
- actorRef.send({
675
- type: "xyflow.mouse.leave.node",
676
- node: node_1
677
- });
678
- };
679
- $[23] = actorRef;
680
- $[24] = t22;
681
- } else t22 = $[24];
682
- const t23 = useCallbackRef(t22);
683
- let t24;
684
- if ($[25] !== actorRef || $[26] !== xystore) {
685
- t24 = (xyflow) => {
686
- actorRef.send({
687
- type: "xyflow.init",
688
- xyflow,
689
- xystore
690
- });
691
- };
692
- $[25] = actorRef;
693
- $[26] = xystore;
694
- $[27] = t24;
695
- } else t24 = $[27];
696
- const t25 = useCallbackRef(t24);
697
- let t26;
698
- if ($[28] !== background || $[29] !== edges || $[30] !== nodes || $[31] !== props || $[32] !== t11 || $[33] !== t13 || $[34] !== t15 || $[35] !== t17 || $[36] !== t19 || $[37] !== t21 || $[38] !== t23 || $[39] !== t25 || $[40] !== t3 || $[41] !== t5 || $[42] !== t7 || $[43] !== t9) {
699
- t26 = /* @__PURE__ */ jsx(BaseXYFlow, {
700
- nodes,
701
- edges,
702
- className: t3,
703
- nodeTypes,
704
- edgeTypes,
705
- fitView: false,
706
- onNodeClick: t5,
707
- onEdgeClick: t7,
708
- onPaneClick: t9,
709
- onDoubleClick: t11,
710
- onNodesChange: t13,
711
- onEdgesChange: t15,
712
- onEdgeMouseEnter: t17,
713
- onEdgeMouseLeave: t19,
714
- onNodeMouseEnter: t21,
715
- onNodeMouseLeave: t23,
716
- onInit: t25,
717
- nodesDraggable: false,
718
- nodesSelectable: true,
719
- pannable: true,
720
- zoomable: true,
721
- background,
722
- ...props
723
- });
724
- $[28] = background;
725
- $[29] = edges;
726
- $[30] = nodes;
727
- $[31] = props;
728
- $[32] = t11;
729
- $[33] = t13;
730
- $[34] = t15;
731
- $[35] = t17;
732
- $[36] = t19;
733
- $[37] = t21;
734
- $[38] = t23;
735
- $[39] = t25;
736
- $[40] = t3;
737
- $[41] = t5;
738
- $[42] = t7;
739
- $[43] = t9;
740
- $[44] = t26;
741
- } else t26 = $[44];
742
- return t26;
743
- });
744
- ProjectsOverviewXY.displayName = "ProjectsOverviewXY";
745
- //#endregion
746
- //#region ../diagram/src/projects-overview/ProjectsOverview.tsx
747
- function ProjectsOverview({ view, onNavigateToProject, fitViewPadding = {
748
- top: "50px",
749
- bottom: "32px",
750
- left: "32px",
751
- right: "32px"
752
- }, ...props }) {
753
- const actorRef = useActorRef(projectOverviewLogic, { input: {
754
- view,
755
- fitViewPadding
756
- } });
757
- useEffect(() => {
758
- actorRef.send({
759
- type: "update.view",
760
- view
761
- });
762
- }, [actorRef, view]);
763
- const onNavigateToProjectRef = useSyncedRef(onNavigateToProject);
764
- useEffect(() => {
765
- const subs = [actorRef.on("navigate.to", ({ projectId }) => {
766
- onNavigateToProjectRef.current?.(projectId);
767
- })];
768
- return () => {
769
- subs.forEach((sub) => sub.unsubscribe());
770
- };
771
- }, [actorRef]);
772
- const bounds = view.bounds;
773
- const initialRef = useRef({
774
- initialNodes: [],
775
- initialEdges: [],
776
- initialWidth: bounds.width,
777
- initialHeight: bounds.height,
778
- fitView: false
779
- });
780
- return /* @__PURE__ */ jsx(ProjectsOverviewActorContextProvider, {
781
- value: actorRef,
782
- children: /* @__PURE__ */ jsxs(ReactFlowProvider, {
783
- ...initialRef.current,
784
- children: [/* @__PURE__ */ jsx(LayoutGroup, {
785
- id: actorRef.sessionId,
786
- inherit: false,
787
- children: /* @__PURE__ */ jsx(ProjectsOverviewXY, { ...props })
788
- }), /* @__PURE__ */ jsx(ProjectsOverviewPanel, {})]
789
- })
790
- });
791
- }
792
- //#endregion
793
- //#region ../diagram/src/LikeC4ProjectsOverview.tsx
794
- function LikeC4ProjectsOverview({ view, className, onNavigateToProject, ...props }) {
795
- const onChangeLikeC4Project = useChangeLikeC4Project();
796
- const id = useId$1();
797
- onNavigateToProject ??= onChangeLikeC4Project;
798
- return /* @__PURE__ */ jsx(EnsureMantine, { children: /* @__PURE__ */ jsxs(FramerMotionConfig, { children: [/* @__PURE__ */ jsx(LikeC4Styles, { rootSelector: `#${id}` }), /* @__PURE__ */ jsx(RootContainer, {
799
- id,
800
- className,
801
- children: /* @__PURE__ */ jsx(ProjectsOverview, {
802
- view,
803
- onNavigateToProject,
804
- ...props
805
- })
806
- })] }) });
807
- }
808
- //#endregion
809
- //#region src/pages/ProjectsOverview.tsx
810
- function ProjectsOverviewPage() {
811
- const $ = c(3);
812
- const changeProject = useChangeLikeC4Project();
813
- const projectsOverview = useLikeC4ProjectsOverview();
814
- let t0;
815
- if ($[0] !== changeProject || $[1] !== projectsOverview) {
816
- t0 = /* @__PURE__ */ jsx(LikeC4ProjectsOverview, {
817
- view: projectsOverview,
818
- onNavigateToProject: changeProject
819
- });
820
- $[0] = changeProject;
821
- $[1] = projectsOverview;
822
- $[2] = t0;
823
- } else t0 = $[2];
824
- return t0;
825
- }
826
- //#endregion
827
- export { ProjectsOverviewPage };