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.
- package/README.md +2 -0
- package/__app__/codegen/react.mjs +4 -10
- package/__app__/codegen/webcomponent.mjs +5 -208
- package/__app__/index.html +15 -15
- package/__app__/src/aichat/index.mjs +1 -2
- package/__app__/src/chunks/AIChat.mjs +292 -117
- package/__app__/src/chunks/ErrorComponent.mjs +444 -0
- package/__app__/src/chunks/Header.mjs +269 -0
- package/__app__/src/chunks/ViewReact.mjs +438 -0
- package/__app__/src/chunks/find.mjs +38 -0
- package/__app__/src/chunks/hooks.mjs +18 -541
- package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +11101 -1797
- package/__app__/src/chunks/libs/@tanstack.mjs +4563 -3083
- package/__app__/src/chunks/libs/fast-equals.mjs +140 -71
- package/__app__/src/chunks/{es.mjs → libs/html-to-image.mjs} +16 -22
- package/__app__/src/chunks/libs/nanostores.mjs +4 -8
- package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
- package/__app__/src/chunks/react.mjs +22 -0
- package/__app__/src/chunks/rolldown-runtime.mjs +3 -32
- package/__app__/src/chunks/router.mjs +106 -0
- package/__app__/src/chunks/scope.mjs +106 -0
- package/__app__/src/chunks/searchParams.mjs +29 -0
- package/__app__/src/chunks/single-index.mjs +465 -0
- package/__app__/src/chunks/styled-system.mjs +1916 -2946
- package/__app__/src/chunks/useAsync.mjs +69 -0
- package/__app__/src/chunks/useSyncedRef.mjs +16 -0
- package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
- package/__app__/src/components/CopyToClipboard.mjs +53 -0
- package/__app__/src/components/ErrorComponent.mjs +1 -0
- package/__app__/src/components/NavigationPanel.mjs +63 -0
- package/__app__/src/components/NotFound.mjs +155 -0
- package/__app__/src/components/ViewOutlet.mjs +9 -0
- package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
- package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
- package/__app__/src/components/model-diff/compare-model.mjs +76 -0
- package/__app__/src/components/model-diff/state.mjs +45 -0
- package/__app__/src/components/search/OverviewSearch.mjs +92 -0
- package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
- package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
- package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
- package/__app__/src/components/sidebar/Drawer.mjs +178 -0
- package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
- package/__app__/src/components/sidebar/data.mjs +94 -0
- package/__app__/src/components/sidebar/state.mjs +16 -0
- package/__app__/src/components/view-page/Header.mjs +1 -0
- package/__app__/src/components/view-page/SelectProject.mjs +258 -0
- package/__app__/src/components/view-page/ShareModal.mjs +111 -0
- package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
- package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
- package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
- package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
- package/__app__/src/components/view-page/state.mjs +17 -0
- package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
- package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
- package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
- package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
- package/__app__/src/context/ModelDiffsContext.mjs +33 -0
- package/__app__/src/context/safeCtx.mjs +14 -0
- package/__app__/src/hooks.mjs +1 -0
- package/__app__/src/main.mjs +4 -48126
- package/__app__/src/pages/EmbedPage.mjs +93 -0
- package/__app__/src/pages/ExportPage.mjs +691 -0
- package/__app__/src/pages/ProjectsOverview.mjs +23 -0
- package/__app__/src/pages/ViewAsD2.mjs +105 -0
- package/__app__/src/pages/ViewAsDot.mjs +65 -0
- package/__app__/src/pages/ViewAsMmd.mjs +109 -0
- package/__app__/src/pages/ViewAsPuml.mjs +105 -0
- package/__app__/src/pages/ViewEditor.mjs +220 -0
- package/__app__/src/pages/ViewReact.mjs +1 -0
- package/__app__/src/pages/export-layout.mjs +95 -0
- package/__app__/src/pages/export-page-params.mjs +9 -0
- package/__app__/src/pages/styles.css.mjs +23 -0
- package/__app__/src/routeTree.gen.mjs +105 -0
- package/__app__/src/router.mjs +1 -0
- package/__app__/src/routes/__root.mjs +65 -0
- package/__app__/src/routes/index.css.mjs +29 -0
- package/__app__/src/routes/index.mjs +32 -0
- package/__app__/src/routes/project._projectId/-components.mjs +100 -0
- package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
- package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
- package/__app__/src/routes/project._projectId/index.mjs +14 -0
- package/__app__/src/routes/project._projectId/route.mjs +93 -0
- package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
- package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
- package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
- package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
- package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
- package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
- package/__app__/src/routes/projects.mjs +36 -0
- package/__app__/src/routes/single-index.mjs +1 -0
- package/__app__/src/routes/webcomponent._.mjs +94 -0
- package/__app__/src/style.css +1156 -1147
- package/config/schema.json +26 -2
- package/dist/app/render-view-client.css +1 -1
- package/dist/app/render-view-client.js +375 -393
- package/dist/chunks/filenames.mjs +26 -20
- package/dist/chunks/generate-likec4.mjs +4 -4
- package/dist/chunks/index.d.mts +16 -15
- package/dist/chunks/index2.d.mts +7041 -3293
- package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
- package/dist/chunks/libs/@logtape/logtape.mjs +5 -5
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
- package/dist/chunks/libs/chevrotain.mjs +19 -19
- package/dist/chunks/libs/clone.mjs +1 -0
- package/dist/chunks/libs/eventemitter3.mjs +1 -1
- package/dist/chunks/libs/fast-equals.mjs +1 -0
- package/dist/chunks/libs/fontkit.mjs +1 -0
- package/dist/chunks/libs/langium.d.mts +80 -2933
- package/dist/chunks/libs/langium.mjs +6 -6
- package/dist/chunks/libs/pako.mjs +1 -1
- package/dist/chunks/libs/pathe.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/node.mjs +110 -77
- package/dist/chunks/rolldown-runtime.mjs +1 -1
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +183 -164
- package/dist/cli/index.mjs +157 -101
- package/dist/config/index.d.mts +65 -4
- package/dist/config/index.mjs +1 -1
- package/dist/generators/likec4.d.mts +16 -64
- package/dist/index.d.mts +2 -4
- package/dist/model/index.d.mts +0 -10
- package/dist/vite-plugin/index.d.mts +83 -61
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -2
- package/dist/vite-plugin/internal/index.d.mts +91 -17
- package/dist/vite-plugin/internal/index.mjs +156 -110
- package/package.json +60 -55
- package/react/index.d.mts +3010 -4014
- package/react/index.mjs +170 -171
- package/react/rolldown-runtime-CfRud99p.js +1 -0
- package/skills/likec4-dsl/SKILL.md +71 -25
- package/skills/likec4-dsl/evals/evals-public.json +5 -0
- package/skills/likec4-dsl/evals/grading-spec.json +15 -1
- package/skills/likec4-dsl/references/cli.md +39 -10
- package/skills/likec4-dsl/references/configuration.md +5 -5
- package/skills/likec4-dsl/references/diffs.md +52 -0
- package/skills/likec4-dsl/references/examples.md +2 -2
- package/skills/likec4-dsl/references/identifier-validity.md +31 -31
- package/skills/likec4-dsl/references/include-predicates-wildcards.md +16 -15
- package/skills/likec4-dsl/references/model.md +42 -11
- package/skills/likec4-dsl/references/specification.md +11 -7
- package/skills/likec4-dsl/references/troubleshooting.md +47 -42
- package/skills/likec4-dsl/references/views.md +2 -2
- package/vite-plugin-modules.d.ts +126 -51
- package/__app__/src/chunks/LikeC4Styles.mjs +0 -4522
- package/__app__/src/chunks/ProjectsOverview.mjs +0 -827
- package/__app__/src/chunks/libs/@floating-ui.mjs +0 -3286
- package/__app__/src/chunks/libs/@mantine.mjs +0 -17731
- package/__app__/src/chunks/libs/@xstate/react.mjs +0 -3471
- package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -7927
- package/__app__/src/chunks/libs/bezier-js.mjs +0 -1593
- package/__app__/src/chunks/libs/d3.mjs +0 -4531
- package/__app__/src/chunks/libs/framer.mjs +0 -11331
- package/__app__/src/chunks/libs/zod.mjs +0 -5404
- package/dist/chunks/libs/@chevrotain/types.d.mts +0 -111
- package/react/rolldown-runtime-DnkiqaRY.js +0 -1
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import "../../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { s as Box$1 } from "../../chunks/styled-system.mjs";
|
|
3
|
+
import { a as IconStack2, d as IconFileCode, l as IconLayoutDashboard, n as IconFolderFilled, t as IconStarFilled, u as IconFolderOpen } from "../../chunks/libs/@tabler/icons-react.mjs";
|
|
4
|
+
import { c as useNavigate } from "../../chunks/libs/@tanstack.mjs";
|
|
5
|
+
import { i as useLikeC4Views, n as useCurrentView, t as useCurrentProject } from "../../chunks/hooks.mjs";
|
|
6
|
+
import { isTreeNodeData, useDiagramsTreeData } from "./data.mjs";
|
|
7
|
+
import { SidebarDrawerOps } from "./state.mjs";
|
|
8
|
+
import { memo, useEffect } from "react";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Button, HoverCard, HoverCardDropdown, HoverCardTarget, ThemeIcon, Tree, useComputedColorScheme, useTree } from "@mantine/core";
|
|
12
|
+
import { StaticLikeC4Diagram, pickViewBounds, useUpdateEffect } from "likec4/react";
|
|
13
|
+
// src/components/sidebar/DiagramsTree.tsx
|
|
14
|
+
var isFile = (node) => isTreeNodeData(node) && node.type === "file";
|
|
15
|
+
var FolderIcon = (t0) => {
|
|
16
|
+
const $ = c(3);
|
|
17
|
+
const { node, expanded } = t0;
|
|
18
|
+
if (isFile(node)) {
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
21
|
+
t1 = /* @__PURE__ */ jsx(ThemeIcon, {
|
|
22
|
+
size: "sm",
|
|
23
|
+
variant: "transparent",
|
|
24
|
+
color: "indigo",
|
|
25
|
+
children: /* @__PURE__ */ jsx(IconFileCode, { size: 16 })
|
|
26
|
+
});
|
|
27
|
+
$[0] = t1;
|
|
28
|
+
} else t1 = $[0];
|
|
29
|
+
return t1;
|
|
30
|
+
}
|
|
31
|
+
let t1;
|
|
32
|
+
if ($[1] !== expanded) {
|
|
33
|
+
t1 = /* @__PURE__ */ jsx(ThemeIcon, {
|
|
34
|
+
size: "sm",
|
|
35
|
+
variant: "transparent",
|
|
36
|
+
color: "violet",
|
|
37
|
+
children: expanded ? /* @__PURE__ */ jsx(IconFolderOpen, { size: 16 }) : /* @__PURE__ */ jsx(IconFolderFilled, { size: 16 })
|
|
38
|
+
});
|
|
39
|
+
$[1] = expanded;
|
|
40
|
+
$[2] = t1;
|
|
41
|
+
} else t1 = $[2];
|
|
42
|
+
return t1;
|
|
43
|
+
};
|
|
44
|
+
var DiagramsTree = /* @__PURE__ */ memo((t0) => {
|
|
45
|
+
const $ = c(28);
|
|
46
|
+
const { groupBy } = t0;
|
|
47
|
+
const views = useLikeC4Views();
|
|
48
|
+
const data = useDiagramsTreeData(groupBy);
|
|
49
|
+
const navigate = useNavigate();
|
|
50
|
+
const { id: projectId } = useCurrentProject();
|
|
51
|
+
let t1;
|
|
52
|
+
if ($[0] !== navigate || $[1] !== projectId) {
|
|
53
|
+
t1 = (viewId) => {
|
|
54
|
+
SidebarDrawerOps.close();
|
|
55
|
+
navigate({
|
|
56
|
+
to: "/project/$projectId/view/$viewId/",
|
|
57
|
+
viewTransition: false,
|
|
58
|
+
params: {
|
|
59
|
+
projectId,
|
|
60
|
+
viewId
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
$[0] = navigate;
|
|
65
|
+
$[1] = projectId;
|
|
66
|
+
$[2] = t1;
|
|
67
|
+
} else t1 = $[2];
|
|
68
|
+
const navigateTo = t1;
|
|
69
|
+
const [diagram] = useCurrentView();
|
|
70
|
+
const viewId_0 = diagram?.id ?? null;
|
|
71
|
+
let t2;
|
|
72
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
73
|
+
t2 = { multiple: false };
|
|
74
|
+
$[3] = t2;
|
|
75
|
+
} else t2 = $[3];
|
|
76
|
+
const tree = useTree(t2);
|
|
77
|
+
const sourcePath = diagram?.sourcePath ?? null;
|
|
78
|
+
let t3;
|
|
79
|
+
if ($[4] !== tree) {
|
|
80
|
+
t3 = () => {
|
|
81
|
+
tree.collapseAllNodes();
|
|
82
|
+
};
|
|
83
|
+
$[4] = tree;
|
|
84
|
+
$[5] = t3;
|
|
85
|
+
} else t3 = $[5];
|
|
86
|
+
let t4;
|
|
87
|
+
if ($[6] !== groupBy) {
|
|
88
|
+
t4 = [groupBy];
|
|
89
|
+
$[6] = groupBy;
|
|
90
|
+
$[7] = t4;
|
|
91
|
+
} else t4 = $[7];
|
|
92
|
+
useUpdateEffect(t3, t4);
|
|
93
|
+
let t5;
|
|
94
|
+
if ($[8] !== sourcePath || $[9] !== tree) {
|
|
95
|
+
t5 = () => {
|
|
96
|
+
if (sourcePath) {
|
|
97
|
+
const segments = sourcePath.split("/");
|
|
98
|
+
let path = "@fs";
|
|
99
|
+
for (const segment of segments) {
|
|
100
|
+
path = path + `/${segment}`;
|
|
101
|
+
tree.expand(path);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
$[8] = sourcePath;
|
|
106
|
+
$[9] = tree;
|
|
107
|
+
$[10] = t5;
|
|
108
|
+
} else t5 = $[10];
|
|
109
|
+
let t6;
|
|
110
|
+
if ($[11] !== groupBy || $[12] !== sourcePath) {
|
|
111
|
+
t6 = [sourcePath, groupBy];
|
|
112
|
+
$[11] = groupBy;
|
|
113
|
+
$[12] = sourcePath;
|
|
114
|
+
$[13] = t6;
|
|
115
|
+
} else t6 = $[13];
|
|
116
|
+
useEffect(t5, t6);
|
|
117
|
+
let t7;
|
|
118
|
+
if ($[14] !== tree || $[15] !== viewId_0) {
|
|
119
|
+
t7 = () => {
|
|
120
|
+
if (viewId_0) tree.select(viewId_0);
|
|
121
|
+
};
|
|
122
|
+
$[14] = tree;
|
|
123
|
+
$[15] = viewId_0;
|
|
124
|
+
$[16] = t7;
|
|
125
|
+
} else t7 = $[16];
|
|
126
|
+
let t8;
|
|
127
|
+
if ($[17] !== viewId_0) {
|
|
128
|
+
t8 = [viewId_0];
|
|
129
|
+
$[17] = viewId_0;
|
|
130
|
+
$[18] = t8;
|
|
131
|
+
} else t8 = $[18];
|
|
132
|
+
useEffect(t7, t8);
|
|
133
|
+
const theme = useComputedColorScheme();
|
|
134
|
+
let t9;
|
|
135
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
136
|
+
t9 = { node: {
|
|
137
|
+
marginTop: 2,
|
|
138
|
+
marginBottom: 2
|
|
139
|
+
} };
|
|
140
|
+
$[19] = t9;
|
|
141
|
+
} else t9 = $[19];
|
|
142
|
+
let t10;
|
|
143
|
+
if ($[20] !== navigateTo || $[21] !== theme || $[22] !== views) {
|
|
144
|
+
t10 = (t11) => {
|
|
145
|
+
const { node, selected, expanded, elementProps, hasChildren } = t11;
|
|
146
|
+
return /* @__PURE__ */ jsx(DiagramPreviewHoverCard, {
|
|
147
|
+
diagram: !hasChildren ? views.find((v) => v.id === node.value) : void 0,
|
|
148
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
149
|
+
fullWidth: true,
|
|
150
|
+
color: theme === "light" ? "dark" : "gray",
|
|
151
|
+
variant: selected ? "transparent" : "subtle",
|
|
152
|
+
size: "sm",
|
|
153
|
+
fz: "sm",
|
|
154
|
+
fw: hasChildren ? "600" : "500",
|
|
155
|
+
justify: "flex-start",
|
|
156
|
+
styles: { section: { opacity: .5 } },
|
|
157
|
+
leftSection: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
158
|
+
!hasChildren && node.value === "index" && /* @__PURE__ */ jsx(IconStarFilled, {
|
|
159
|
+
size: 14,
|
|
160
|
+
opacity: .7
|
|
161
|
+
}),
|
|
162
|
+
!hasChildren && node.value !== "index" && isTreeNodeData(node) && /* @__PURE__ */ jsxs(Fragment, { children: [node.type === "deployment-view" && /* @__PURE__ */ jsx(IconStack2, { size: 14 }), node.type === "view" && /* @__PURE__ */ jsx(IconLayoutDashboard, { size: 14 })] }),
|
|
163
|
+
hasChildren && /* @__PURE__ */ jsx(FolderIcon, {
|
|
164
|
+
node,
|
|
165
|
+
expanded
|
|
166
|
+
})
|
|
167
|
+
] }),
|
|
168
|
+
...elementProps,
|
|
169
|
+
...!hasChildren && { onClick: (e) => {
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
navigateTo(node.value);
|
|
172
|
+
} },
|
|
173
|
+
children: node.label
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
$[20] = navigateTo;
|
|
178
|
+
$[21] = theme;
|
|
179
|
+
$[22] = views;
|
|
180
|
+
$[23] = t10;
|
|
181
|
+
} else t10 = $[23];
|
|
182
|
+
let t11;
|
|
183
|
+
if ($[24] !== data || $[25] !== t10 || $[26] !== tree) {
|
|
184
|
+
t11 = /* @__PURE__ */ jsx(Box$1, { children: /* @__PURE__ */ jsx(Tree, {
|
|
185
|
+
allowRangeSelection: false,
|
|
186
|
+
tree,
|
|
187
|
+
data,
|
|
188
|
+
styles: t9,
|
|
189
|
+
levelOffset: "md",
|
|
190
|
+
renderNode: t10
|
|
191
|
+
}) });
|
|
192
|
+
$[24] = data;
|
|
193
|
+
$[25] = t10;
|
|
194
|
+
$[26] = tree;
|
|
195
|
+
$[27] = t11;
|
|
196
|
+
} else t11 = $[27];
|
|
197
|
+
return t11;
|
|
198
|
+
}, (prev, next) => prev.groupBy === next.groupBy);
|
|
199
|
+
function DiagramPreviewHoverCard(t0) {
|
|
200
|
+
const $ = c(16);
|
|
201
|
+
const { diagram, children } = t0;
|
|
202
|
+
let t1;
|
|
203
|
+
if ($[0] !== diagram) {
|
|
204
|
+
t1 = diagram ? pickViewBounds(diagram) : null;
|
|
205
|
+
$[0] = diagram;
|
|
206
|
+
$[1] = t1;
|
|
207
|
+
} else t1 = $[1];
|
|
208
|
+
const bounds = t1;
|
|
209
|
+
const ratio = bounds ? Math.max(bounds.width / 400, bounds.height / 300) : 1;
|
|
210
|
+
let t2;
|
|
211
|
+
if ($[2] !== bounds || $[3] !== ratio) {
|
|
212
|
+
t2 = bounds ? Math.round(bounds.width / ratio) : 0;
|
|
213
|
+
$[2] = bounds;
|
|
214
|
+
$[3] = ratio;
|
|
215
|
+
$[4] = t2;
|
|
216
|
+
} else t2 = $[4];
|
|
217
|
+
const width = t2;
|
|
218
|
+
let t3;
|
|
219
|
+
if ($[5] !== bounds || $[6] !== ratio) {
|
|
220
|
+
t3 = bounds ? Math.round(bounds.height / ratio) : 0;
|
|
221
|
+
$[5] = bounds;
|
|
222
|
+
$[6] = ratio;
|
|
223
|
+
$[7] = t3;
|
|
224
|
+
} else t3 = $[7];
|
|
225
|
+
const height = t3;
|
|
226
|
+
let t4;
|
|
227
|
+
if ($[8] !== children || $[9] !== diagram || $[10] !== height || $[11] !== width) {
|
|
228
|
+
t4 = diagram && /* @__PURE__ */ jsxs(HoverCard, {
|
|
229
|
+
position: "right-start",
|
|
230
|
+
openDelay: 400,
|
|
231
|
+
closeDelay: 100,
|
|
232
|
+
keepMounted: false,
|
|
233
|
+
shadow: "lg",
|
|
234
|
+
children: [/* @__PURE__ */ jsx(HoverCardTarget, { children }), /* @__PURE__ */ jsx(HoverCardDropdown, {
|
|
235
|
+
style: {
|
|
236
|
+
width,
|
|
237
|
+
height
|
|
238
|
+
},
|
|
239
|
+
p: "xs",
|
|
240
|
+
children: /* @__PURE__ */ jsx(DiagramPreview, { diagram })
|
|
241
|
+
})]
|
|
242
|
+
});
|
|
243
|
+
$[8] = children;
|
|
244
|
+
$[9] = diagram;
|
|
245
|
+
$[10] = height;
|
|
246
|
+
$[11] = width;
|
|
247
|
+
$[12] = t4;
|
|
248
|
+
} else t4 = $[12];
|
|
249
|
+
const t5 = !diagram && children;
|
|
250
|
+
let t6;
|
|
251
|
+
if ($[13] !== t4 || $[14] !== t5) {
|
|
252
|
+
t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] });
|
|
253
|
+
$[13] = t4;
|
|
254
|
+
$[14] = t5;
|
|
255
|
+
$[15] = t6;
|
|
256
|
+
} else t6 = $[15];
|
|
257
|
+
return t6;
|
|
258
|
+
}
|
|
259
|
+
var DiagramPreview = memo((t0) => {
|
|
260
|
+
const $ = c(12);
|
|
261
|
+
const { diagram } = t0;
|
|
262
|
+
let t1;
|
|
263
|
+
if ($[0] !== diagram) {
|
|
264
|
+
t1 = pickViewBounds(diagram);
|
|
265
|
+
$[0] = diagram;
|
|
266
|
+
$[1] = t1;
|
|
267
|
+
} else t1 = $[1];
|
|
268
|
+
const bounds = t1;
|
|
269
|
+
const ratio = Math.max(bounds.width / 400, bounds.height / 300);
|
|
270
|
+
let t2;
|
|
271
|
+
if ($[2] !== bounds.width || $[3] !== ratio) {
|
|
272
|
+
t2 = Math.round(bounds.width / ratio);
|
|
273
|
+
$[2] = bounds.width;
|
|
274
|
+
$[3] = ratio;
|
|
275
|
+
$[4] = t2;
|
|
276
|
+
} else t2 = $[4];
|
|
277
|
+
const width = t2;
|
|
278
|
+
let t3;
|
|
279
|
+
if ($[5] !== bounds.height || $[6] !== ratio) {
|
|
280
|
+
t3 = Math.round(bounds.height / ratio);
|
|
281
|
+
$[5] = bounds.height;
|
|
282
|
+
$[6] = ratio;
|
|
283
|
+
$[7] = t3;
|
|
284
|
+
} else t3 = $[7];
|
|
285
|
+
const height = t3;
|
|
286
|
+
let t4;
|
|
287
|
+
if ($[8] !== diagram || $[9] !== height || $[10] !== width) {
|
|
288
|
+
t4 = /* @__PURE__ */ jsx(StaticLikeC4Diagram, {
|
|
289
|
+
view: diagram,
|
|
290
|
+
fitView: true,
|
|
291
|
+
fitViewPadding: "4px",
|
|
292
|
+
enableElementDetails: false,
|
|
293
|
+
reduceGraphics: true,
|
|
294
|
+
initialWidth: width,
|
|
295
|
+
initialHeight: height
|
|
296
|
+
});
|
|
297
|
+
$[8] = diagram;
|
|
298
|
+
$[9] = height;
|
|
299
|
+
$[10] = width;
|
|
300
|
+
$[11] = t4;
|
|
301
|
+
} else t4 = $[11];
|
|
302
|
+
return t4;
|
|
303
|
+
}, (prev, next) => prev.diagram.id === next.diagram.id);
|
|
304
|
+
export { DiagramsTree };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import "../../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { g as IconArrowLeft, t as IconStarFilled } from "../../chunks/libs/@tabler/icons-react.mjs";
|
|
3
|
+
import { s as Link } from "../../chunks/libs/@tanstack.mjs";
|
|
4
|
+
import { t as useCurrentProject } from "../../chunks/hooks.mjs";
|
|
5
|
+
import { DiagramsTree } from "./DiagramsTree.mjs";
|
|
6
|
+
import { SidebarDrawerOps, useDrawerOpened } from "./state.mjs";
|
|
7
|
+
import { memo } from "react";
|
|
8
|
+
import { c } from "react/compiler-runtime";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { isSingleProject } from "likec4:projects";
|
|
11
|
+
import { Button, Drawer, Group, ScrollArea, SegmentedControl, rem } from "@mantine/core";
|
|
12
|
+
import { useLocalStorage } from "@mantine/hooks";
|
|
13
|
+
// src/components/sidebar/Drawer.tsx
|
|
14
|
+
var SidebarDrawer = memo(() => {
|
|
15
|
+
const $ = c(27);
|
|
16
|
+
const opened = useDrawerOpened();
|
|
17
|
+
const { id: projectId } = useCurrentProject();
|
|
18
|
+
let t0;
|
|
19
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
20
|
+
t0 = {
|
|
21
|
+
key: "sidebar-drawer-grouping",
|
|
22
|
+
defaultValue: "by-files"
|
|
23
|
+
};
|
|
24
|
+
$[0] = t0;
|
|
25
|
+
} else t0 = $[0];
|
|
26
|
+
const [grouping, setGrouping] = useLocalStorage(t0);
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t1 = /* @__PURE__ */ jsx(Drawer.Overlay, { blur: 2 });
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else t1 = $[1];
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
+
t2 = /* @__PURE__ */ jsx(IconArrowLeft, { size: 14 });
|
|
35
|
+
$[2] = t2;
|
|
36
|
+
} else t2 = $[2];
|
|
37
|
+
let t3;
|
|
38
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
39
|
+
t3 = /* @__PURE__ */ jsx(Button, {
|
|
40
|
+
component: Link,
|
|
41
|
+
to: "/",
|
|
42
|
+
leftSection: t2,
|
|
43
|
+
color: "dimmed",
|
|
44
|
+
variant: "subtle",
|
|
45
|
+
px: rem(5),
|
|
46
|
+
styles: { section: { marginInlineEnd: 4 } },
|
|
47
|
+
size: "xs",
|
|
48
|
+
children: "Overview"
|
|
49
|
+
});
|
|
50
|
+
$[3] = t3;
|
|
51
|
+
} else t3 = $[3];
|
|
52
|
+
const t4 = setGrouping;
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
55
|
+
t5 = [
|
|
56
|
+
{
|
|
57
|
+
label: "By files",
|
|
58
|
+
value: "by-files"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "By folders",
|
|
62
|
+
value: "by-folders"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "List",
|
|
66
|
+
value: "none"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
$[4] = t5;
|
|
70
|
+
} else t5 = $[4];
|
|
71
|
+
let t6;
|
|
72
|
+
if ($[5] !== grouping || $[6] !== t4) {
|
|
73
|
+
t6 = /* @__PURE__ */ jsx(SegmentedControl, {
|
|
74
|
+
size: "xs",
|
|
75
|
+
withItemsBorders: false,
|
|
76
|
+
value: grouping,
|
|
77
|
+
onChange: t4,
|
|
78
|
+
data: t5
|
|
79
|
+
});
|
|
80
|
+
$[5] = grouping;
|
|
81
|
+
$[6] = t4;
|
|
82
|
+
$[7] = t6;
|
|
83
|
+
} else t6 = $[7];
|
|
84
|
+
let t7;
|
|
85
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
86
|
+
t7 = /* @__PURE__ */ jsx(IconStarFilled, {
|
|
87
|
+
size: 12,
|
|
88
|
+
stroke: 2
|
|
89
|
+
});
|
|
90
|
+
$[8] = t7;
|
|
91
|
+
} else t7 = $[8];
|
|
92
|
+
let t8;
|
|
93
|
+
let t9;
|
|
94
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
95
|
+
t8 = rem(5);
|
|
96
|
+
t9 = { section: { marginInlineEnd: 4 } };
|
|
97
|
+
$[9] = t8;
|
|
98
|
+
$[10] = t9;
|
|
99
|
+
} else {
|
|
100
|
+
t8 = $[9];
|
|
101
|
+
t9 = $[10];
|
|
102
|
+
}
|
|
103
|
+
let t10;
|
|
104
|
+
if ($[11] !== projectId) {
|
|
105
|
+
t10 = /* @__PURE__ */ jsx(Button, {
|
|
106
|
+
leftSection: t7,
|
|
107
|
+
color: "dimmed",
|
|
108
|
+
variant: "subtle",
|
|
109
|
+
px: t8,
|
|
110
|
+
styles: t9,
|
|
111
|
+
size: "xs",
|
|
112
|
+
renderRoot: (props) => /* @__PURE__ */ jsx(Link, {
|
|
113
|
+
to: "/project/$projectId/view/$viewId/",
|
|
114
|
+
params: {
|
|
115
|
+
projectId,
|
|
116
|
+
viewId: "index"
|
|
117
|
+
},
|
|
118
|
+
...props
|
|
119
|
+
}),
|
|
120
|
+
children: "Open index"
|
|
121
|
+
});
|
|
122
|
+
$[11] = projectId;
|
|
123
|
+
$[12] = t10;
|
|
124
|
+
} else t10 = $[12];
|
|
125
|
+
let t11;
|
|
126
|
+
if ($[13] !== t10 || $[14] !== t6) {
|
|
127
|
+
t11 = /* @__PURE__ */ jsxs(Group, {
|
|
128
|
+
gap: "xs",
|
|
129
|
+
children: [
|
|
130
|
+
t3,
|
|
131
|
+
t6,
|
|
132
|
+
t10
|
|
133
|
+
]
|
|
134
|
+
});
|
|
135
|
+
$[13] = t10;
|
|
136
|
+
$[14] = t6;
|
|
137
|
+
$[15] = t11;
|
|
138
|
+
} else t11 = $[15];
|
|
139
|
+
let t12;
|
|
140
|
+
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
141
|
+
t12 = /* @__PURE__ */ jsx(Drawer.CloseButton, {});
|
|
142
|
+
$[16] = t12;
|
|
143
|
+
} else t12 = $[16];
|
|
144
|
+
let t13;
|
|
145
|
+
if ($[17] !== t11) {
|
|
146
|
+
t13 = /* @__PURE__ */ jsxs(Drawer.Header, { children: [t11, t12] });
|
|
147
|
+
$[17] = t11;
|
|
148
|
+
$[18] = t13;
|
|
149
|
+
} else t13 = $[18];
|
|
150
|
+
let t14;
|
|
151
|
+
if ($[19] !== grouping) {
|
|
152
|
+
t14 = /* @__PURE__ */ jsx(Drawer.Body, { children: /* @__PURE__ */ jsx(DiagramsTree, { groupBy: grouping }) });
|
|
153
|
+
$[19] = grouping;
|
|
154
|
+
$[20] = t14;
|
|
155
|
+
} else t14 = $[20];
|
|
156
|
+
let t15;
|
|
157
|
+
if ($[21] !== t13 || $[22] !== t14) {
|
|
158
|
+
t15 = /* @__PURE__ */ jsxs(Drawer.Content, { children: [t13, t14] });
|
|
159
|
+
$[21] = t13;
|
|
160
|
+
$[22] = t14;
|
|
161
|
+
$[23] = t15;
|
|
162
|
+
} else t15 = $[23];
|
|
163
|
+
let t16;
|
|
164
|
+
if ($[24] !== opened || $[25] !== t15) {
|
|
165
|
+
t16 = /* @__PURE__ */ jsxs(Drawer.Root, {
|
|
166
|
+
keepMounted: isSingleProject,
|
|
167
|
+
opened,
|
|
168
|
+
scrollAreaComponent: ScrollArea.Autosize,
|
|
169
|
+
onClose: SidebarDrawerOps.close,
|
|
170
|
+
children: [t1, t15]
|
|
171
|
+
});
|
|
172
|
+
$[24] = opened;
|
|
173
|
+
$[25] = t15;
|
|
174
|
+
$[26] = t16;
|
|
175
|
+
} else t16 = $[26];
|
|
176
|
+
return t16;
|
|
177
|
+
});
|
|
178
|
+
export { SidebarDrawer };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "../../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { s as Box$1 } from "../../chunks/styled-system.mjs";
|
|
3
|
+
import { SidebarDrawerOps } from "./state.mjs";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Burger } from "@mantine/core";
|
|
7
|
+
// src/components/sidebar/SidebarBurger.tsx
|
|
8
|
+
function SidebarBurger() {
|
|
9
|
+
const $ = c(1);
|
|
10
|
+
let t0;
|
|
11
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
12
|
+
t0 = /* @__PURE__ */ jsx(Box$1, {
|
|
13
|
+
css: {
|
|
14
|
+
position: "fixed",
|
|
15
|
+
top: "[14px]",
|
|
16
|
+
left: "[10px]"
|
|
17
|
+
},
|
|
18
|
+
children: /* @__PURE__ */ jsx(Burger, {
|
|
19
|
+
size: "sm",
|
|
20
|
+
onClick: SidebarDrawerOps.open,
|
|
21
|
+
"aria-label": "Toggle navigation"
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
$[0] = t0;
|
|
25
|
+
} else t0 = $[0];
|
|
26
|
+
return t0;
|
|
27
|
+
}
|
|
28
|
+
export { SidebarBurger };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "../../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { t as a } from "../../chunks/find.mjs";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
import { useLikeC4Model } from "likec4/react";
|
|
5
|
+
import { compareNatural, nonexhaustive } from "@likec4/core/utils";
|
|
6
|
+
// src/components/sidebar/data.ts
|
|
7
|
+
var isTreeNodeData = (node) => "type" in node && [
|
|
8
|
+
"file",
|
|
9
|
+
"folder",
|
|
10
|
+
"view",
|
|
11
|
+
"deployment-view"
|
|
12
|
+
].includes(node.type);
|
|
13
|
+
function dropFilename(relativePath) {
|
|
14
|
+
if (relativePath === "") return "";
|
|
15
|
+
return relativePath.split("/").slice(0, -1).join("/");
|
|
16
|
+
}
|
|
17
|
+
function compareTreeNodes(a, b) {
|
|
18
|
+
const aChildren = a.children?.length ?? 0;
|
|
19
|
+
const bChildren = b.children?.length ?? 0;
|
|
20
|
+
if (aChildren === 0 && bChildren > 0) return 1;
|
|
21
|
+
if (aChildren > 0 && bChildren === 0) return -1;
|
|
22
|
+
return compareNatural(a.label, b.label);
|
|
23
|
+
}
|
|
24
|
+
function buildDiagramTreeData(views, groupBy) {
|
|
25
|
+
const root = {
|
|
26
|
+
value: "",
|
|
27
|
+
label: "Diagrams",
|
|
28
|
+
type: "folder",
|
|
29
|
+
children: []
|
|
30
|
+
};
|
|
31
|
+
const findParent = (path) => {
|
|
32
|
+
let parent = root;
|
|
33
|
+
if (path === "") return parent;
|
|
34
|
+
const segments = path.split("/");
|
|
35
|
+
const traversed = ["@fs"];
|
|
36
|
+
while (segments.length) {
|
|
37
|
+
const label = segments.shift();
|
|
38
|
+
traversed.push(label);
|
|
39
|
+
const value = traversed.join("/");
|
|
40
|
+
let node = a(parent.children, (n) => n.value === value);
|
|
41
|
+
if (!node) {
|
|
42
|
+
node = {
|
|
43
|
+
label,
|
|
44
|
+
value,
|
|
45
|
+
type: "folder",
|
|
46
|
+
children: []
|
|
47
|
+
};
|
|
48
|
+
parent.children.push(node);
|
|
49
|
+
}
|
|
50
|
+
parent = node;
|
|
51
|
+
}
|
|
52
|
+
return parent;
|
|
53
|
+
};
|
|
54
|
+
for (const view of views) {
|
|
55
|
+
let relativePath;
|
|
56
|
+
switch (groupBy) {
|
|
57
|
+
case "by-files":
|
|
58
|
+
relativePath = view.$view.sourcePath ?? "";
|
|
59
|
+
break;
|
|
60
|
+
case "by-folders":
|
|
61
|
+
relativePath = dropFilename(view.$view.sourcePath ?? "");
|
|
62
|
+
break;
|
|
63
|
+
case "none":
|
|
64
|
+
relativePath = "";
|
|
65
|
+
break;
|
|
66
|
+
default: nonexhaustive(groupBy);
|
|
67
|
+
}
|
|
68
|
+
const parent = findParent(relativePath);
|
|
69
|
+
parent.children.push({
|
|
70
|
+
value: view.id,
|
|
71
|
+
label: view.title ?? view.id,
|
|
72
|
+
type: view.isDeploymentView() ? "deployment-view" : "view"
|
|
73
|
+
});
|
|
74
|
+
if (parent !== root) {
|
|
75
|
+
parent.children.sort(compareTreeNodes);
|
|
76
|
+
if (groupBy === "by-files" && parent.type !== "file") parent.type = "file";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return root.children.sort(compareTreeNodes);
|
|
80
|
+
}
|
|
81
|
+
function useDiagramsTreeData(t0) {
|
|
82
|
+
const $ = c(3);
|
|
83
|
+
const groupBy = t0 === void 0 ? "by-files" : t0;
|
|
84
|
+
const model = useLikeC4Model();
|
|
85
|
+
let t1;
|
|
86
|
+
if ($[0] !== groupBy || $[1] !== model) {
|
|
87
|
+
t1 = buildDiagramTreeData([...model.views()], groupBy);
|
|
88
|
+
$[0] = groupBy;
|
|
89
|
+
$[1] = model;
|
|
90
|
+
$[2] = t1;
|
|
91
|
+
} else t1 = $[2];
|
|
92
|
+
return t1;
|
|
93
|
+
}
|
|
94
|
+
export { isTreeNodeData, useDiagramsTreeData };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { t as useStore } from "../../chunks/react.mjs";
|
|
3
|
+
import { n as onMount, r as atom } from "../../chunks/libs/nanostores.mjs";
|
|
4
|
+
// src/components/sidebar/state.ts
|
|
5
|
+
var drawerOpenedAtom = /* @__PURE__ */ atom(false);
|
|
6
|
+
onMount(drawerOpenedAtom, () => {
|
|
7
|
+
drawerOpenedAtom.set(false);
|
|
8
|
+
});
|
|
9
|
+
var useDrawerOpened = () => {
|
|
10
|
+
return useStore(drawerOpenedAtom);
|
|
11
|
+
};
|
|
12
|
+
var SidebarDrawerOps = {
|
|
13
|
+
open: () => drawerOpenedAtom.set(true),
|
|
14
|
+
close: () => drawerOpenedAtom.set(false)
|
|
15
|
+
};
|
|
16
|
+
export { SidebarDrawerOps, useDrawerOpened };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as Header } from "../../chunks/Header.mjs";
|