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
@@ -0,0 +1,444 @@
1
+ import { r as __name } from "./rolldown-runtime.mjs";
2
+ import { a as hstack, f as css, i as HStack, o as VStack, r as Txt } from "./styled-system.mjs";
3
+ import { r as IconX } from "./libs/@tabler/icons-react.mjs";
4
+ import { d as useRouter, g as isNotFound, u as useParams } from "./libs/@tanstack.mjs";
5
+ import { Component, createContext, createElement, useEffect, useMemo, useRef } from "react";
6
+ import { c } from "react/compiler-runtime";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { Alert, Button, Code, Container, ScrollAreaAutosize, Text, ThemeIcon } from "@mantine/core";
9
+ // ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/isError.js
10
+ function e$2(e) {
11
+ return e instanceof Error;
12
+ }
13
+ __name(e$2, "e");
14
+ // ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/isNullish.js
15
+ function e$1(e) {
16
+ return e == null;
17
+ }
18
+ __name(e$1, "e");
19
+ // ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/isObjectType.js
20
+ function e(e) {
21
+ return typeof e == `object` && !!e;
22
+ }
23
+ // ../../node_modules/.pnpm/react-error-boundary@6.1.6_@types+react@19.3.0_react@19.3.1/node_modules/react-error-boundary/dist/react-error-boundary.js
24
+ var f = createContext(null);
25
+ function m({ children: r, didCatch: e, error: t, resetErrorBoundary: o }) {
26
+ const n = useMemo(() => ({
27
+ didCatch: e,
28
+ error: t,
29
+ resetErrorBoundary: o
30
+ }), [
31
+ e,
32
+ t,
33
+ o
34
+ ]);
35
+ return createElement(f.Provider, { value: n }, r);
36
+ }
37
+ var d = {
38
+ didCatch: !1,
39
+ error: null
40
+ };
41
+ var C = class extends Component {
42
+ constructor(e) {
43
+ super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = d;
44
+ }
45
+ static getDerivedStateFromError(e) {
46
+ return {
47
+ didCatch: !0,
48
+ error: e
49
+ };
50
+ }
51
+ resetErrorBoundary(...e) {
52
+ const { didCatch: t } = this.state;
53
+ t && (this.props.onReset?.({
54
+ args: e,
55
+ reason: "imperative-api"
56
+ }), this.setState(d));
57
+ }
58
+ componentDidCatch(e, t) {
59
+ this.props.onError?.(e, t);
60
+ }
61
+ componentDidUpdate(e, t) {
62
+ const { didCatch: o } = this.state, { resetKeys: n } = this.props;
63
+ o && t.didCatch && g(e.resetKeys, n) && (this.props.onReset?.({
64
+ next: n,
65
+ prev: e.resetKeys,
66
+ reason: "keys"
67
+ }), this.setState(d));
68
+ }
69
+ render() {
70
+ const { children: e, fallbackRender: t, FallbackComponent: o, fallback: n } = this.props, { didCatch: s, error: a } = this.state;
71
+ let c = e;
72
+ if (s) {
73
+ const u = {
74
+ error: a,
75
+ resetErrorBoundary: this.resetErrorBoundary
76
+ };
77
+ if (typeof t == "function") c = t(u);
78
+ else if (o) c = createElement(o, u);
79
+ else if ("fallback" in this.props) c = n;
80
+ else throw a;
81
+ }
82
+ return createElement(m, {
83
+ didCatch: s,
84
+ error: a,
85
+ resetErrorBoundary: this.resetErrorBoundary
86
+ }, c);
87
+ }
88
+ };
89
+ function g(r = [], e = []) {
90
+ return r.length !== e.length || r.some((t, o) => !Object.is(t, e[o]));
91
+ }
92
+ // src/components/ErrorComponent.tsx
93
+ var hasMessageOrStack = (error) => {
94
+ return e(error) && error !== null && (Object.hasOwn(error, "stack") || Object.hasOwn(error, "message"));
95
+ };
96
+ function errorMessage(error) {
97
+ let message;
98
+ try {
99
+ switch (true) {
100
+ case e$1(error):
101
+ message = "Unknown error";
102
+ break;
103
+ case e$2(error):
104
+ message = error.stack ?? error.message;
105
+ break;
106
+ case typeof error === "string":
107
+ message = error;
108
+ break;
109
+ case hasMessageOrStack(error):
110
+ message = error.stack ?? error.message ?? error.toString();
111
+ break;
112
+ default: message = String(error);
113
+ }
114
+ } catch (e) {
115
+ message = `${e}`;
116
+ }
117
+ return message;
118
+ }
119
+ function FallbackDialog(t0) {
120
+ const $ = c(23);
121
+ const { error, resetErrorBoundary, children } = t0;
122
+ let t1;
123
+ if ($[0] !== error) {
124
+ t1 = errorMessage(error);
125
+ $[0] = error;
126
+ $[1] = t1;
127
+ } else t1 = $[1];
128
+ const errorString = t1;
129
+ const dialogRef = useRef(null);
130
+ let t2;
131
+ let t3;
132
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
133
+ t2 = () => {
134
+ dialogRef.current?.showModal();
135
+ };
136
+ t3 = [];
137
+ $[2] = t2;
138
+ $[3] = t3;
139
+ } else {
140
+ t2 = $[2];
141
+ t3 = $[3];
142
+ }
143
+ useEffect(t2, t3);
144
+ let t4;
145
+ let t5;
146
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
147
+ t4 = hstack({
148
+ margin: "0",
149
+ padding: "0",
150
+ position: "fixed",
151
+ top: "10",
152
+ left: "10",
153
+ width: "[calc(100vw - ({spacing.10} * 2))]",
154
+ height: "max-content",
155
+ maxHeight: "[min(calc(100vh - ({spacing.10} * 3)), 500px)]",
156
+ background: "likec4.overlay.body",
157
+ rounded: "sm",
158
+ borderWidth: "extra",
159
+ borderColor: "likec4.overlay.border",
160
+ shadow: "xl",
161
+ outline: "none",
162
+ overflow: "hidden",
163
+ p: "xl",
164
+ gap: "lg",
165
+ alignItems: "flex-start",
166
+ flexWrap: "nowrap",
167
+ _backdrop: {
168
+ cursor: "zoom-out",
169
+ backdropFilter: "[blur(18px)]",
170
+ bg: "[color-mix(in oklab, {colors.likec4.overlay.backdrop} 60%, transparent)]"
171
+ }
172
+ });
173
+ t5 = (e) => {
174
+ e.stopPropagation();
175
+ if (e.target?.nodeName?.toUpperCase() === "DIALOG") {
176
+ dialogRef.current?.close();
177
+ return;
178
+ }
179
+ };
180
+ $[4] = t4;
181
+ $[5] = t5;
182
+ } else {
183
+ t4 = $[4];
184
+ t5 = $[5];
185
+ }
186
+ let t6;
187
+ if ($[6] !== resetErrorBoundary) {
188
+ t6 = (e_0) => {
189
+ e_0.stopPropagation();
190
+ resetErrorBoundary();
191
+ };
192
+ $[6] = resetErrorBoundary;
193
+ $[7] = t6;
194
+ } else t6 = $[7];
195
+ let t7;
196
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
197
+ t7 = /* @__PURE__ */ jsx(ThemeIcon, {
198
+ size: "md",
199
+ radius: "xl",
200
+ color: "red",
201
+ children: /* @__PURE__ */ jsx(IconX, { style: {
202
+ width: 20,
203
+ height: 20
204
+ } })
205
+ });
206
+ $[8] = t7;
207
+ } else t7 = $[8];
208
+ let t8;
209
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
210
+ t8 = /* @__PURE__ */ jsx(Txt, {
211
+ flex: "[0]",
212
+ children: "Oops, something went wrong"
213
+ });
214
+ $[9] = t8;
215
+ } else t8 = $[9];
216
+ let t9;
217
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
218
+ t9 = {
219
+ root: css({
220
+ background: "surface.sunken",
221
+ _hover: { background: "surface.sunken.hover" },
222
+ borderWidth: "strong",
223
+ borderStyle: "solid",
224
+ borderColor: "border.subtle",
225
+ rounded: "sm"
226
+ }),
227
+ content: css({ padding: "3" })
228
+ };
229
+ $[10] = t9;
230
+ } else t9 = $[10];
231
+ let t10;
232
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
233
+ t10 = { whiteSpace: "pre-wrap" };
234
+ $[11] = t10;
235
+ } else t10 = $[11];
236
+ let t11;
237
+ if ($[12] !== errorString) {
238
+ t11 = /* @__PURE__ */ jsx(ScrollAreaAutosize, {
239
+ flex: "1",
240
+ maw: "100%",
241
+ type: "auto",
242
+ classNames: t9,
243
+ children: /* @__PURE__ */ jsx(Txt, {
244
+ textStyle: "dimmed.sm",
245
+ fontFamily: "mono",
246
+ style: t10,
247
+ children: errorString
248
+ })
249
+ });
250
+ $[12] = errorString;
251
+ $[13] = t11;
252
+ } else t11 = $[13];
253
+ let t12;
254
+ if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
255
+ t12 = /* @__PURE__ */ jsx(Text, {
256
+ fz: "sm",
257
+ c: "dimmed",
258
+ children: "See console for more details and report the issue if it persists."
259
+ });
260
+ $[14] = t12;
261
+ } else t12 = $[14];
262
+ let t13;
263
+ if ($[15] !== children) {
264
+ t13 = /* @__PURE__ */ jsxs(HStack, {
265
+ gap: "md",
266
+ my: "sm",
267
+ flex: "[0]",
268
+ children: [children, t12]
269
+ });
270
+ $[15] = children;
271
+ $[16] = t13;
272
+ } else t13 = $[16];
273
+ let t14;
274
+ if ($[17] !== t11 || $[18] !== t13) {
275
+ t14 = /* @__PURE__ */ jsxs(VStack, {
276
+ flex: "1",
277
+ gap: "2",
278
+ h: "stretch",
279
+ overflow: "hidden",
280
+ children: [
281
+ t8,
282
+ t11,
283
+ t13
284
+ ]
285
+ });
286
+ $[17] = t11;
287
+ $[18] = t13;
288
+ $[19] = t14;
289
+ } else t14 = $[19];
290
+ let t15;
291
+ if ($[20] !== t14 || $[21] !== t6) {
292
+ t15 = /* @__PURE__ */ jsxs("dialog", {
293
+ ref: dialogRef,
294
+ className: t4,
295
+ onClick: t5,
296
+ onClose: t6,
297
+ children: [t7, t14]
298
+ });
299
+ $[20] = t14;
300
+ $[21] = t6;
301
+ $[22] = t15;
302
+ } else t15 = $[22];
303
+ return t15;
304
+ }
305
+ function Fallback(t0) {
306
+ const $ = c(20);
307
+ const { error, resetErrorBoundary } = t0;
308
+ const router = useRouter();
309
+ let t1;
310
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
311
+ t1 = { strict: false };
312
+ $[0] = t1;
313
+ } else t1 = $[0];
314
+ const params = useParams(t1);
315
+ if (isNotFound(error)) {
316
+ const t2 = params.viewId ?? "unknown";
317
+ let t3;
318
+ if ($[1] !== t2) {
319
+ t3 = /* @__PURE__ */ jsxs(Text, {
320
+ c: "orange",
321
+ fz: "md",
322
+ children: [
323
+ "The diagram",
324
+ " ",
325
+ /* @__PURE__ */ jsx(Code, {
326
+ color: "orange",
327
+ children: t2
328
+ }),
329
+ " ",
330
+ "does not exist or contains errors"
331
+ ]
332
+ });
333
+ $[1] = t2;
334
+ $[2] = t3;
335
+ } else t3 = $[2];
336
+ let t4;
337
+ if ($[3] !== resetErrorBoundary || $[4] !== router) {
338
+ t4 = /* @__PURE__ */ jsx(Button, {
339
+ onClick: () => {
340
+ resetErrorBoundary();
341
+ router.navigate({ to: "/" });
342
+ },
343
+ variant: "light",
344
+ color: "orange",
345
+ mt: "lg",
346
+ size: "xs",
347
+ children: "Go to overview"
348
+ });
349
+ $[3] = resetErrorBoundary;
350
+ $[4] = router;
351
+ $[5] = t4;
352
+ } else t4 = $[5];
353
+ let t5;
354
+ if ($[6] !== t3 || $[7] !== t4) {
355
+ t5 = /* @__PURE__ */ jsx(Container, {
356
+ my: "md",
357
+ children: /* @__PURE__ */ jsxs(Alert, {
358
+ variant: "light",
359
+ color: "orange",
360
+ children: [t3, t4]
361
+ })
362
+ });
363
+ $[6] = t3;
364
+ $[7] = t4;
365
+ $[8] = t5;
366
+ } else t5 = $[8];
367
+ return t5;
368
+ }
369
+ let t2;
370
+ if ($[9] !== resetErrorBoundary || $[10] !== router) {
371
+ t2 = /* @__PURE__ */ jsx(Button, {
372
+ size: "sm",
373
+ variant: "default",
374
+ onClick: () => {
375
+ router.invalidate().finally(() => {
376
+ resetErrorBoundary();
377
+ });
378
+ },
379
+ children: "Try again"
380
+ });
381
+ $[9] = resetErrorBoundary;
382
+ $[10] = router;
383
+ $[11] = t2;
384
+ } else t2 = $[11];
385
+ let t3;
386
+ if ($[12] !== resetErrorBoundary || $[13] !== router) {
387
+ t3 = /* @__PURE__ */ jsx(Button, {
388
+ size: "sm",
389
+ variant: "default",
390
+ onClick: () => {
391
+ resetErrorBoundary();
392
+ router.navigate({ to: "/" });
393
+ },
394
+ children: "Go to overview"
395
+ });
396
+ $[12] = resetErrorBoundary;
397
+ $[13] = router;
398
+ $[14] = t3;
399
+ } else t3 = $[14];
400
+ let t4;
401
+ if ($[15] !== error || $[16] !== resetErrorBoundary || $[17] !== t2 || $[18] !== t3) {
402
+ t4 = /* @__PURE__ */ jsxs(FallbackDialog, {
403
+ error,
404
+ resetErrorBoundary,
405
+ children: [t2, t3]
406
+ });
407
+ $[15] = error;
408
+ $[16] = resetErrorBoundary;
409
+ $[17] = t2;
410
+ $[18] = t3;
411
+ $[19] = t4;
412
+ } else t4 = $[19];
413
+ return t4;
414
+ }
415
+ function ErrorComponent(t0) {
416
+ const $ = c(3);
417
+ const { error, reset } = t0;
418
+ let t1;
419
+ if ($[0] !== error || $[1] !== reset) {
420
+ t1 = /* @__PURE__ */ jsx(Fallback, {
421
+ error,
422
+ resetErrorBoundary: reset
423
+ });
424
+ $[0] = error;
425
+ $[1] = reset;
426
+ $[2] = t1;
427
+ } else t1 = $[2];
428
+ return t1;
429
+ }
430
+ function ErrorBoundary(t0) {
431
+ const $ = c(2);
432
+ const { children } = t0;
433
+ let t1;
434
+ if ($[0] !== children) {
435
+ t1 = /* @__PURE__ */ jsx(C, {
436
+ FallbackComponent: Fallback,
437
+ children
438
+ });
439
+ $[0] = children;
440
+ $[1] = t1;
441
+ } else t1 = $[1];
442
+ return t1;
443
+ }
444
+ export { ErrorComponent as n, Fallback as r, ErrorBoundary as t };
@@ -0,0 +1,269 @@
1
+ import "./rolldown-runtime.mjs";
2
+ import { m as IconChevronDown, o as IconShare } from "./libs/@tabler/icons-react.mjs";
3
+ import { r as useMatches, s as Link } from "./libs/@tanstack.mjs";
4
+ import { r as useCurrentViewId, t as useCurrentProject } from "./hooks.mjs";
5
+ import { ColorSchemeToggle } from "../components/ColorSchemeToggle.mjs";
6
+ import { NavigationPanel } from "../components/NavigationPanel.mjs";
7
+ import { SelectProject } from "../components/view-page/SelectProject.mjs";
8
+ import { ShareModal } from "../components/view-page/ShareModal.mjs";
9
+ import { useHeaderVisible } from "../components/view-page/state.mjs";
10
+ import { memo, useCallback, useState } from "react";
11
+ import { c } from "react/compiler-runtime";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import { Button, Divider, Menu, MenuDropdown, MenuItem, MenuLabel, MenuTarget, useMantineTheme } from "@mantine/core";
14
+ import { useLikeC4Projects } from "likec4/react";
15
+ import { useDisclosure, useMediaQuery } from "@mantine/hooks";
16
+ import { AnimatePresence } from "motion/react";
17
+ // ../config/src/webapp-export-formats.ts
18
+ var WebappExportFormats = [
19
+ "png",
20
+ "jpg",
21
+ "dot",
22
+ "d2",
23
+ "mmd",
24
+ "puml",
25
+ "drawio"
26
+ ];
27
+ // src/export-formats.ts
28
+ /**
29
+ * Returns enabled webapp export formats in canonical menu order.
30
+ */
31
+ function enabledWebappExportFormats(project) {
32
+ const configured = project.exportFormats;
33
+ if (!configured) return [...WebappExportFormats];
34
+ const enabledFormats = new Set(configured);
35
+ return WebappExportFormats.filter((format) => enabledFormats.has(format));
36
+ }
37
+ // src/components/view-page/Header.tsx
38
+ var Header = memo(() => {
39
+ const $ = c(16);
40
+ const projects = useLikeC4Projects();
41
+ let t0;
42
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
43
+ t0 = { select(matches) {
44
+ return matches.some(_temp);
45
+ } };
46
+ $[0] = t0;
47
+ } else t0 = $[0];
48
+ const isReactDiagramRoute = useMatches(t0);
49
+ const { breakpoints } = useMantineTheme();
50
+ const isTablet = useMediaQuery(`(min-width: ${breakpoints.md})`) ?? false;
51
+ const [opened, t1] = useDisclosure(false);
52
+ const { open, close } = t1;
53
+ const headerVisible = useHeaderVisible();
54
+ let t2;
55
+ if ($[1] !== headerVisible || $[2] !== isReactDiagramRoute || $[3] !== isTablet || $[4] !== open || $[5] !== projects) {
56
+ t2 = headerVisible && /* @__PURE__ */ jsx(NavigationPanel.Root, {
57
+ panelPosition: "right",
58
+ hideBelow: "md",
59
+ initial: {
60
+ opacity: 0,
61
+ y: -20,
62
+ scale: .97
63
+ },
64
+ animate: {
65
+ opacity: 1,
66
+ y: 0,
67
+ scale: 1
68
+ },
69
+ exit: {
70
+ opacity: 0,
71
+ y: -50
72
+ },
73
+ children: /* @__PURE__ */ jsxs(NavigationPanel.Body, {
74
+ gap: "1",
75
+ children: [
76
+ isReactDiagramRoute ? /* @__PURE__ */ jsxs(Fragment, { children: [
77
+ /* @__PURE__ */ jsx(SelectProject, {}),
78
+ projects.length <= 1 && /* @__PURE__ */ jsx(Button, {
79
+ size: isTablet ? "compact-md" : "xs",
80
+ fz: isTablet ? "sm" : "xs",
81
+ leftSection: /* @__PURE__ */ jsx(IconShare, { size: 14 }),
82
+ onClick: open,
83
+ children: "Share"
84
+ }),
85
+ /* @__PURE__ */ jsx(ExportButton, {})
86
+ ] }) : /* @__PURE__ */ jsx(Button, {
87
+ component: Link,
88
+ to: "../",
89
+ size: isTablet ? "compact-md" : "xs",
90
+ fz: isTablet ? "sm" : "xs",
91
+ variant: "subtle",
92
+ color: "gray",
93
+ children: "Back to diagram"
94
+ }),
95
+ /* @__PURE__ */ jsx(Divider, {
96
+ orientation: "vertical",
97
+ visibleFrom: "md"
98
+ }),
99
+ /* @__PURE__ */ jsx(ColorSchemeToggle, {})
100
+ ]
101
+ })
102
+ });
103
+ $[1] = headerVisible;
104
+ $[2] = isReactDiagramRoute;
105
+ $[3] = isTablet;
106
+ $[4] = open;
107
+ $[5] = projects;
108
+ $[6] = t2;
109
+ } else t2 = $[6];
110
+ let t3;
111
+ if ($[7] !== t2) {
112
+ t3 = /* @__PURE__ */ jsx(AnimatePresence, {
113
+ initial: false,
114
+ children: t2
115
+ });
116
+ $[7] = t2;
117
+ $[8] = t3;
118
+ } else t3 = $[8];
119
+ let t4;
120
+ if ($[9] !== close || $[10] !== headerVisible || $[11] !== opened) {
121
+ t4 = headerVisible && opened && /* @__PURE__ */ jsx(ShareModal, { onClose: close });
122
+ $[9] = close;
123
+ $[10] = headerVisible;
124
+ $[11] = opened;
125
+ $[12] = t4;
126
+ } else t4 = $[12];
127
+ let t5;
128
+ if ($[13] !== t3 || $[14] !== t4) {
129
+ t5 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, t4] });
130
+ $[13] = t3;
131
+ $[14] = t4;
132
+ $[15] = t5;
133
+ } else t5 = $[15];
134
+ return t5;
135
+ });
136
+ var enableDownload = (params) => ({
137
+ ...params,
138
+ download: true
139
+ });
140
+ var enableJpegDownload = (params) => ({
141
+ ...params,
142
+ download: true,
143
+ format: "jpeg"
144
+ });
145
+ function ExportButton() {
146
+ const [isDrawioLoading, setIsDrawioLoading] = useState(false);
147
+ const project = useCurrentProject();
148
+ const viewId = useCurrentViewId();
149
+ const enabledFormats = new Set(enabledWebappExportFormats(project));
150
+ const handleDrawioExport = useCallback(async () => {
151
+ try {
152
+ setIsDrawioLoading(true);
153
+ const { loadDrawioSources } = await import("likec4:drawio");
154
+ const { drawioEditUrl } = await loadDrawioSources(project.id);
155
+ const url = drawioEditUrl(viewId);
156
+ window.open(url, "_blank", "noopener,noreferrer");
157
+ } catch (error) {
158
+ console.error("Failed to export to Draw.io:", error);
159
+ } finally {
160
+ setIsDrawioLoading(false);
161
+ }
162
+ }, [project.id, viewId]);
163
+ if (enabledFormats.size === 0) return null;
164
+ return /* @__PURE__ */ jsxs(Menu, {
165
+ shadow: "md",
166
+ width: 200,
167
+ trigger: "click-hover",
168
+ openDelay: 300,
169
+ children: [/* @__PURE__ */ jsx(MenuTarget, { children: /* @__PURE__ */ jsx(Button, {
170
+ variant: "subtle",
171
+ size: "compact-md",
172
+ fz: "sm",
173
+ color: "gray",
174
+ px: "sm",
175
+ rightSection: /* @__PURE__ */ jsx(IconChevronDown, {
176
+ opacity: .5,
177
+ size: 14
178
+ }),
179
+ visibleFrom: "md",
180
+ children: "Export"
181
+ }) }), /* @__PURE__ */ jsxs(MenuDropdown, { children: [
182
+ /* @__PURE__ */ jsx(MenuLabel, { children: "Current view" }),
183
+ enabledFormats.has("png") && /* @__PURE__ */ jsx(MenuItem, {
184
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
185
+ target: "_blank",
186
+ to: "/project/$projectId/export/$viewId/",
187
+ params: {
188
+ projectId: project.id,
189
+ viewId
190
+ },
191
+ search: enableDownload,
192
+ ...props
193
+ }),
194
+ children: "Export as .png"
195
+ }),
196
+ enabledFormats.has("jpg") && /* @__PURE__ */ jsx(MenuItem, {
197
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
198
+ target: "_blank",
199
+ to: "/project/$projectId/export/$viewId/",
200
+ params: {
201
+ projectId: project.id,
202
+ viewId
203
+ },
204
+ search: enableJpegDownload,
205
+ ...props
206
+ }),
207
+ children: "Export as .jpg"
208
+ }),
209
+ enabledFormats.has("dot") && /* @__PURE__ */ jsx(MenuItem, {
210
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
211
+ to: "/project/$projectId/view/$viewId/dot/",
212
+ params: {
213
+ projectId: project.id,
214
+ viewId
215
+ },
216
+ search: true,
217
+ ...props
218
+ }),
219
+ children: "Export as .dot"
220
+ }),
221
+ enabledFormats.has("d2") && /* @__PURE__ */ jsx(MenuItem, {
222
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
223
+ to: "/project/$projectId/view/$viewId/d2",
224
+ params: {
225
+ projectId: project.id,
226
+ viewId
227
+ },
228
+ search: true,
229
+ ...props
230
+ }),
231
+ children: "Export as .d2"
232
+ }),
233
+ enabledFormats.has("mmd") && /* @__PURE__ */ jsx(MenuItem, {
234
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
235
+ to: "/project/$projectId/view/$viewId/mmd",
236
+ params: {
237
+ projectId: project.id,
238
+ viewId
239
+ },
240
+ search: true,
241
+ ...props
242
+ }),
243
+ children: "Export as .mmd"
244
+ }),
245
+ enabledFormats.has("puml") && /* @__PURE__ */ jsx(MenuItem, {
246
+ renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
247
+ to: "/project/$projectId/view/$viewId/puml",
248
+ params: {
249
+ projectId: project.id,
250
+ viewId
251
+ },
252
+ search: true,
253
+ ...props
254
+ }),
255
+ children: "Export as .puml"
256
+ }),
257
+ enabledFormats.has("drawio") && /* @__PURE__ */ jsx(MenuItem, {
258
+ disabled: isDrawioLoading,
259
+ onClick: handleDrawioExport,
260
+ children: "Export to Draw.io"
261
+ })
262
+ ] })]
263
+ });
264
+ }
265
+ function _temp(t0) {
266
+ const { routeId } = t0;
267
+ return routeId === "/project/$projectId/view/$viewId/";
268
+ }
269
+ export { Header as t };