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,105 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { s as Box$1 } from "../chunks/styled-system.mjs";
|
|
3
|
+
import { t as useAsync } from "../chunks/useAsync.mjs";
|
|
4
|
+
import { n as xo, r as yo, t as mo } from "../chunks/libs/react-resizable-panels.mjs";
|
|
5
|
+
import { CopyToClipboard } from "../components/CopyToClipboard.mjs";
|
|
6
|
+
import { cssCodeBlock, cssScrollArea, svgContainer, viewWithTopPadding } from "./styles.css.mjs";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { krokiD2SvgUrl } from "likec4:app-config";
|
|
10
|
+
import { Button, Code, ScrollArea } from "@mantine/core";
|
|
11
|
+
// src/pages/ViewAsD2.tsx
|
|
12
|
+
var fetchFromKroki = async (d2) => {
|
|
13
|
+
return await (await fetch(krokiD2SvgUrl, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
cache: "force-cache",
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
diagram_source: d2,
|
|
18
|
+
output_format: "svg"
|
|
19
|
+
}),
|
|
20
|
+
headers: { "Content-Type": "application/json" }
|
|
21
|
+
})).text();
|
|
22
|
+
};
|
|
23
|
+
function ViewAsD2(t0) {
|
|
24
|
+
const $ = c(18);
|
|
25
|
+
const { d2Source } = t0;
|
|
26
|
+
const [krokiSvg, t1] = useAsync(fetchFromKroki, null);
|
|
27
|
+
const { execute } = t1;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
30
|
+
t2 = { viewport: { borderRadius: 6 } };
|
|
31
|
+
$[0] = t2;
|
|
32
|
+
} else t2 = $[0];
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[1] !== d2Source) {
|
|
35
|
+
t3 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
36
|
+
className: cssScrollArea,
|
|
37
|
+
p: 5,
|
|
38
|
+
styles: t2,
|
|
39
|
+
children: [/* @__PURE__ */ jsx(Code, {
|
|
40
|
+
block: true,
|
|
41
|
+
className: cssCodeBlock,
|
|
42
|
+
children: d2Source
|
|
43
|
+
}), /* @__PURE__ */ jsx(CopyToClipboard, { text: d2Source })]
|
|
44
|
+
}) });
|
|
45
|
+
$[1] = d2Source;
|
|
46
|
+
$[2] = t3;
|
|
47
|
+
} else t3 = $[2];
|
|
48
|
+
let t4;
|
|
49
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
+
t4 = /* @__PURE__ */ jsx(xo, { style: { width: 10 } });
|
|
51
|
+
$[3] = t4;
|
|
52
|
+
} else t4 = $[3];
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[4] !== d2Source || $[5] !== execute || $[6] !== krokiSvg.error?.message || $[7] !== krokiSvg.status) {
|
|
55
|
+
t5 = krokiSvg.status !== "success" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
56
|
+
mt: "xs",
|
|
57
|
+
variant: "light",
|
|
58
|
+
disabled: krokiSvg.status === "loading",
|
|
59
|
+
onClick: () => void execute(d2Source),
|
|
60
|
+
children: krokiSvg.status === "loading" ? "Loading..." : "Render with Kroki"
|
|
61
|
+
}), krokiSvg.status === "error" && /* @__PURE__ */ jsx(Box$1, { children: krokiSvg.error?.message })] });
|
|
62
|
+
$[4] = d2Source;
|
|
63
|
+
$[5] = execute;
|
|
64
|
+
$[6] = krokiSvg.error?.message;
|
|
65
|
+
$[7] = krokiSvg.status;
|
|
66
|
+
$[8] = t5;
|
|
67
|
+
} else t5 = $[8];
|
|
68
|
+
let t6;
|
|
69
|
+
if ($[9] !== krokiSvg.result || $[10] !== krokiSvg.status) {
|
|
70
|
+
t6 = krokiSvg.status === "success" && /* @__PURE__ */ jsx(Box$1, {
|
|
71
|
+
className: svgContainer,
|
|
72
|
+
children: !krokiSvg.result ? /* @__PURE__ */ jsx(Box$1, { children: "Empty result" }) : /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: krokiSvg.result } })
|
|
73
|
+
});
|
|
74
|
+
$[9] = krokiSvg.result;
|
|
75
|
+
$[10] = krokiSvg.status;
|
|
76
|
+
$[11] = t6;
|
|
77
|
+
} else t6 = $[11];
|
|
78
|
+
let t7;
|
|
79
|
+
if ($[12] !== t5 || $[13] !== t6) {
|
|
80
|
+
t7 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
81
|
+
h: "100%",
|
|
82
|
+
children: [t5, t6]
|
|
83
|
+
}) });
|
|
84
|
+
$[12] = t5;
|
|
85
|
+
$[13] = t6;
|
|
86
|
+
$[14] = t7;
|
|
87
|
+
} else t7 = $[14];
|
|
88
|
+
let t8;
|
|
89
|
+
if ($[15] !== t3 || $[16] !== t7) {
|
|
90
|
+
t8 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(mo, {
|
|
91
|
+
className: viewWithTopPadding,
|
|
92
|
+
orientation: "horizontal",
|
|
93
|
+
children: [
|
|
94
|
+
t3,
|
|
95
|
+
t4,
|
|
96
|
+
t7
|
|
97
|
+
]
|
|
98
|
+
}) });
|
|
99
|
+
$[15] = t3;
|
|
100
|
+
$[16] = t7;
|
|
101
|
+
$[17] = t8;
|
|
102
|
+
} else t8 = $[17];
|
|
103
|
+
return t8;
|
|
104
|
+
}
|
|
105
|
+
export { ViewAsD2 };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { n as xo, r as yo, t as mo } from "../chunks/libs/react-resizable-panels.mjs";
|
|
3
|
+
import { CopyToClipboard } from "../components/CopyToClipboard.mjs";
|
|
4
|
+
import { cssCodeBlock, cssScrollArea, svgContainer, viewWithTopPadding } from "./styles.css.mjs";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Code, ScrollArea } from "@mantine/core";
|
|
8
|
+
// src/pages/ViewAsDot.tsx
|
|
9
|
+
function ViewAsDot(t0) {
|
|
10
|
+
const $ = c(9);
|
|
11
|
+
const { dot, dotSvg } = t0;
|
|
12
|
+
let t1;
|
|
13
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
14
|
+
t1 = { viewport: { borderRadius: 6 } };
|
|
15
|
+
$[0] = t1;
|
|
16
|
+
} else t1 = $[0];
|
|
17
|
+
let t2;
|
|
18
|
+
if ($[1] !== dot) {
|
|
19
|
+
t2 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
20
|
+
className: cssScrollArea,
|
|
21
|
+
p: 5,
|
|
22
|
+
styles: t1,
|
|
23
|
+
children: [/* @__PURE__ */ jsx(Code, {
|
|
24
|
+
block: true,
|
|
25
|
+
className: cssCodeBlock,
|
|
26
|
+
children: dot
|
|
27
|
+
}), /* @__PURE__ */ jsx(CopyToClipboard, { text: dot })]
|
|
28
|
+
}) });
|
|
29
|
+
$[1] = dot;
|
|
30
|
+
$[2] = t2;
|
|
31
|
+
} else t2 = $[2];
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
+
t3 = /* @__PURE__ */ jsx(xo, { style: { width: 10 } });
|
|
35
|
+
$[3] = t3;
|
|
36
|
+
} else t3 = $[3];
|
|
37
|
+
let t4;
|
|
38
|
+
if ($[4] !== dotSvg) {
|
|
39
|
+
t4 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
40
|
+
h: "100%",
|
|
41
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: svgContainer,
|
|
43
|
+
dangerouslySetInnerHTML: { __html: dotSvg }
|
|
44
|
+
})
|
|
45
|
+
}) });
|
|
46
|
+
$[4] = dotSvg;
|
|
47
|
+
$[5] = t4;
|
|
48
|
+
} else t4 = $[5];
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[6] !== t2 || $[7] !== t4) {
|
|
51
|
+
t5 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(mo, {
|
|
52
|
+
className: viewWithTopPadding,
|
|
53
|
+
children: [
|
|
54
|
+
t2,
|
|
55
|
+
t3,
|
|
56
|
+
t4
|
|
57
|
+
]
|
|
58
|
+
}) });
|
|
59
|
+
$[6] = t2;
|
|
60
|
+
$[7] = t4;
|
|
61
|
+
$[8] = t5;
|
|
62
|
+
} else t5 = $[8];
|
|
63
|
+
return t5;
|
|
64
|
+
}
|
|
65
|
+
export { ViewAsDot };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { s as Box$1 } from "../chunks/styled-system.mjs";
|
|
3
|
+
import { t as useAsync } from "../chunks/useAsync.mjs";
|
|
4
|
+
import { n as xo, r as yo, t as mo } from "../chunks/libs/react-resizable-panels.mjs";
|
|
5
|
+
import { CopyToClipboard } from "../components/CopyToClipboard.mjs";
|
|
6
|
+
import { cssCodeBlock, cssScrollArea, svgContainer, viewWithTopPadding } from "./styles.css.mjs";
|
|
7
|
+
import { useEffect } from "react";
|
|
8
|
+
import { c } from "react/compiler-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Code, ScrollArea, useMantineColorScheme } from "@mantine/core";
|
|
11
|
+
// src/pages/ViewAsMmd.tsx
|
|
12
|
+
var renderSvg = async (viewId, diagram, theme) => {
|
|
13
|
+
const { default: mermaid } = await import("https://cdn.jsdelivr.net/npm/mermaid@11.12/dist/mermaid.esm.min.mjs");
|
|
14
|
+
mermaid.initialize({ theme });
|
|
15
|
+
const { svg } = await mermaid.render(viewId, diagram);
|
|
16
|
+
return svg;
|
|
17
|
+
};
|
|
18
|
+
function ViewAsMmd(t0) {
|
|
19
|
+
const $ = c(20);
|
|
20
|
+
const { viewId, mmdSource } = t0;
|
|
21
|
+
const { colorScheme } = useMantineColorScheme();
|
|
22
|
+
const theme = colorScheme === "auto" ? "dark" : colorScheme;
|
|
23
|
+
const [mmdSvg, t1] = useAsync(renderSvg, null);
|
|
24
|
+
const { execute } = t1;
|
|
25
|
+
let t2;
|
|
26
|
+
if ($[0] !== execute || $[1] !== mmdSource || $[2] !== theme || $[3] !== viewId) {
|
|
27
|
+
t2 = () => {
|
|
28
|
+
execute(viewId, mmdSource, theme);
|
|
29
|
+
};
|
|
30
|
+
$[0] = execute;
|
|
31
|
+
$[1] = mmdSource;
|
|
32
|
+
$[2] = theme;
|
|
33
|
+
$[3] = viewId;
|
|
34
|
+
$[4] = t2;
|
|
35
|
+
} else t2 = $[4];
|
|
36
|
+
let t3;
|
|
37
|
+
if ($[5] !== mmdSource || $[6] !== theme || $[7] !== viewId) {
|
|
38
|
+
t3 = [
|
|
39
|
+
mmdSource,
|
|
40
|
+
theme,
|
|
41
|
+
viewId
|
|
42
|
+
];
|
|
43
|
+
$[5] = mmdSource;
|
|
44
|
+
$[6] = theme;
|
|
45
|
+
$[7] = viewId;
|
|
46
|
+
$[8] = t3;
|
|
47
|
+
} else t3 = $[8];
|
|
48
|
+
useEffect(t2, t3);
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
51
|
+
t4 = { viewport: { borderRadius: 6 } };
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
} else t4 = $[9];
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[10] !== mmdSource) {
|
|
56
|
+
t5 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
57
|
+
className: cssScrollArea,
|
|
58
|
+
p: 5,
|
|
59
|
+
styles: t4,
|
|
60
|
+
children: [/* @__PURE__ */ jsx(Code, {
|
|
61
|
+
block: true,
|
|
62
|
+
className: cssCodeBlock,
|
|
63
|
+
children: mmdSource
|
|
64
|
+
}), /* @__PURE__ */ jsx(CopyToClipboard, { text: mmdSource })]
|
|
65
|
+
}) });
|
|
66
|
+
$[10] = mmdSource;
|
|
67
|
+
$[11] = t5;
|
|
68
|
+
} else t5 = $[11];
|
|
69
|
+
let t6;
|
|
70
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
71
|
+
t6 = /* @__PURE__ */ jsx(xo, { style: { width: 10 } });
|
|
72
|
+
$[12] = t6;
|
|
73
|
+
} else t6 = $[12];
|
|
74
|
+
let t7;
|
|
75
|
+
if ($[13] !== mmdSvg.result) {
|
|
76
|
+
t7 = mmdSvg.result && /* @__PURE__ */ jsx(Box$1, {
|
|
77
|
+
className: svgContainer,
|
|
78
|
+
dangerouslySetInnerHTML: { __html: mmdSvg.result }
|
|
79
|
+
});
|
|
80
|
+
$[13] = mmdSvg.result;
|
|
81
|
+
$[14] = t7;
|
|
82
|
+
} else t7 = $[14];
|
|
83
|
+
let t8;
|
|
84
|
+
if ($[15] !== t7) {
|
|
85
|
+
t8 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
86
|
+
h: "100%",
|
|
87
|
+
children: t7
|
|
88
|
+
}) });
|
|
89
|
+
$[15] = t7;
|
|
90
|
+
$[16] = t8;
|
|
91
|
+
} else t8 = $[16];
|
|
92
|
+
let t9;
|
|
93
|
+
if ($[17] !== t5 || $[18] !== t8) {
|
|
94
|
+
t9 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(mo, {
|
|
95
|
+
className: viewWithTopPadding,
|
|
96
|
+
orientation: "horizontal",
|
|
97
|
+
children: [
|
|
98
|
+
t5,
|
|
99
|
+
t6,
|
|
100
|
+
t8
|
|
101
|
+
]
|
|
102
|
+
}) });
|
|
103
|
+
$[17] = t5;
|
|
104
|
+
$[18] = t8;
|
|
105
|
+
$[19] = t9;
|
|
106
|
+
} else t9 = $[19];
|
|
107
|
+
return t9;
|
|
108
|
+
}
|
|
109
|
+
export { ViewAsMmd };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { s as Box$1 } from "../chunks/styled-system.mjs";
|
|
3
|
+
import { t as useAsync } from "../chunks/useAsync.mjs";
|
|
4
|
+
import { n as xo, r as yo, t as mo } from "../chunks/libs/react-resizable-panels.mjs";
|
|
5
|
+
import { CopyToClipboard } from "../components/CopyToClipboard.mjs";
|
|
6
|
+
import { cssCodeBlock, cssScrollArea, svgContainer, viewWithTopPadding } from "./styles.css.mjs";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { krokiPumlSvgUrl } from "likec4:app-config";
|
|
10
|
+
import { Button, Code, ScrollArea } from "@mantine/core";
|
|
11
|
+
// src/pages/ViewAsPuml.tsx
|
|
12
|
+
var fetchFromKroki = async (puml) => {
|
|
13
|
+
return await (await fetch(krokiPumlSvgUrl, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
cache: "force-cache",
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
diagram_source: puml,
|
|
18
|
+
output_format: "svg"
|
|
19
|
+
}),
|
|
20
|
+
headers: { "Content-Type": "application/json" }
|
|
21
|
+
})).text();
|
|
22
|
+
};
|
|
23
|
+
function ViewAsPuml(t0) {
|
|
24
|
+
const $ = c(18);
|
|
25
|
+
const { pumlSource } = t0;
|
|
26
|
+
const [krokiSvg, t1] = useAsync(fetchFromKroki, null);
|
|
27
|
+
const { execute } = t1;
|
|
28
|
+
let t2;
|
|
29
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
30
|
+
t2 = { viewport: { borderRadius: 6 } };
|
|
31
|
+
$[0] = t2;
|
|
32
|
+
} else t2 = $[0];
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[1] !== pumlSource) {
|
|
35
|
+
t3 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
36
|
+
className: cssScrollArea,
|
|
37
|
+
p: 5,
|
|
38
|
+
styles: t2,
|
|
39
|
+
children: [/* @__PURE__ */ jsx(Code, {
|
|
40
|
+
block: true,
|
|
41
|
+
className: cssCodeBlock,
|
|
42
|
+
children: pumlSource
|
|
43
|
+
}), /* @__PURE__ */ jsx(CopyToClipboard, { text: pumlSource })]
|
|
44
|
+
}) });
|
|
45
|
+
$[1] = pumlSource;
|
|
46
|
+
$[2] = t3;
|
|
47
|
+
} else t3 = $[2];
|
|
48
|
+
let t4;
|
|
49
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
+
t4 = /* @__PURE__ */ jsx(xo, { style: { width: 10 } });
|
|
51
|
+
$[3] = t4;
|
|
52
|
+
} else t4 = $[3];
|
|
53
|
+
let t5;
|
|
54
|
+
if ($[4] !== execute || $[5] !== krokiSvg.error?.message || $[6] !== krokiSvg.status || $[7] !== pumlSource) {
|
|
55
|
+
t5 = krokiSvg.status !== "success" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
56
|
+
mt: "xs",
|
|
57
|
+
variant: "light",
|
|
58
|
+
disabled: krokiSvg.status === "loading",
|
|
59
|
+
onClick: () => void execute(pumlSource),
|
|
60
|
+
children: krokiSvg.status === "loading" ? "Loading..." : "Render with Kroki"
|
|
61
|
+
}), krokiSvg.status === "error" && /* @__PURE__ */ jsx(Box$1, { children: krokiSvg.error?.message })] });
|
|
62
|
+
$[4] = execute;
|
|
63
|
+
$[5] = krokiSvg.error?.message;
|
|
64
|
+
$[6] = krokiSvg.status;
|
|
65
|
+
$[7] = pumlSource;
|
|
66
|
+
$[8] = t5;
|
|
67
|
+
} else t5 = $[8];
|
|
68
|
+
let t6;
|
|
69
|
+
if ($[9] !== krokiSvg.result || $[10] !== krokiSvg.status) {
|
|
70
|
+
t6 = krokiSvg.status === "success" && /* @__PURE__ */ jsx(Box$1, {
|
|
71
|
+
className: svgContainer,
|
|
72
|
+
children: !krokiSvg.result ? /* @__PURE__ */ jsx(Box$1, { children: "Empty result" }) : /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: krokiSvg.result } })
|
|
73
|
+
});
|
|
74
|
+
$[9] = krokiSvg.result;
|
|
75
|
+
$[10] = krokiSvg.status;
|
|
76
|
+
$[11] = t6;
|
|
77
|
+
} else t6 = $[11];
|
|
78
|
+
let t7;
|
|
79
|
+
if ($[12] !== t5 || $[13] !== t6) {
|
|
80
|
+
t7 = /* @__PURE__ */ jsx(yo, { children: /* @__PURE__ */ jsxs(ScrollArea, {
|
|
81
|
+
h: "100%",
|
|
82
|
+
children: [t5, t6]
|
|
83
|
+
}) });
|
|
84
|
+
$[12] = t5;
|
|
85
|
+
$[13] = t6;
|
|
86
|
+
$[14] = t7;
|
|
87
|
+
} else t7 = $[14];
|
|
88
|
+
let t8;
|
|
89
|
+
if ($[15] !== t3 || $[16] !== t7) {
|
|
90
|
+
t8 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(mo, {
|
|
91
|
+
className: viewWithTopPadding,
|
|
92
|
+
orientation: "horizontal",
|
|
93
|
+
children: [
|
|
94
|
+
t3,
|
|
95
|
+
t4,
|
|
96
|
+
t7
|
|
97
|
+
]
|
|
98
|
+
}) });
|
|
99
|
+
$[15] = t3;
|
|
100
|
+
$[16] = t7;
|
|
101
|
+
$[17] = t8;
|
|
102
|
+
} else t8 = $[17];
|
|
103
|
+
return t8;
|
|
104
|
+
}
|
|
105
|
+
export { ViewAsPuml };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
import { c as useNavigate, l as useSearch } from "../chunks/libs/@tanstack.mjs";
|
|
3
|
+
import { LazyAIChat } from "../aichat/index.mjs";
|
|
4
|
+
import { CompareModelProvider } from "../components/model-diff/CompareModelProvider.mjs";
|
|
5
|
+
import { ModelDiffPanel, useCompareView } from "../components/model-diff/ModelDiffPanel.mjs";
|
|
6
|
+
import { NotFound } from "../components/NotFound.mjs";
|
|
7
|
+
import { useLikeC4ModelAtom } from "../context/safeCtx.mjs";
|
|
8
|
+
import { n as useCurrentView, t as useCurrentProject } from "../chunks/hooks.mjs";
|
|
9
|
+
import { t as useRelationshipBrowserScope } from "../chunks/scope.mjs";
|
|
10
|
+
import { n as ListenForDiagramStateChanges, r as OpenRelationshipBrowserFromUrl, t as FocusElementFromUrl } from "../chunks/ViewReact.mjs";
|
|
11
|
+
import { c } from "react/compiler-runtime";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { isDevelopment } from "likec4:app-config";
|
|
14
|
+
import { LikeC4Diagram, LikeC4EditorProvider } from "likec4/react";
|
|
15
|
+
import { useCallbackRef } from "@mantine/hooks";
|
|
16
|
+
import { isAIAvailable, likec4rpc } from "likec4:rpc";
|
|
17
|
+
// src/pages/ViewEditor.tsx
|
|
18
|
+
function ViewEditor() {
|
|
19
|
+
const $ = c(40);
|
|
20
|
+
const navigate = useNavigate();
|
|
21
|
+
const project = useCurrentProject();
|
|
22
|
+
const [view, setLayoutType] = useCurrentView();
|
|
23
|
+
const [relationshipBrowserScope, setRelationshipBrowserScope] = useRelationshipBrowserScope(project);
|
|
24
|
+
const $likec4model = useLikeC4ModelAtom();
|
|
25
|
+
let t0;
|
|
26
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
27
|
+
t0 = { strict: false };
|
|
28
|
+
$[0] = t0;
|
|
29
|
+
} else t0 = $[0];
|
|
30
|
+
const { dynamic } = useSearch(t0);
|
|
31
|
+
const compareView = useCompareView(view?.id);
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[1] !== navigate) {
|
|
34
|
+
t1 = (viewId) => {
|
|
35
|
+
navigate({
|
|
36
|
+
to: "./",
|
|
37
|
+
viewTransition: false,
|
|
38
|
+
params: (current) => ({
|
|
39
|
+
...current,
|
|
40
|
+
viewId
|
|
41
|
+
}),
|
|
42
|
+
search: true
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
$[1] = navigate;
|
|
46
|
+
$[2] = t1;
|
|
47
|
+
} else t1 = $[2];
|
|
48
|
+
const onNavigateTo = useCallbackRef(t1);
|
|
49
|
+
if (!view) {
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
52
|
+
t2 = /* @__PURE__ */ jsx(NotFound, {});
|
|
53
|
+
$[3] = t2;
|
|
54
|
+
} else t2 = $[3];
|
|
55
|
+
return t2;
|
|
56
|
+
}
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[4] !== view.notation?.nodes) {
|
|
59
|
+
t2 = view.notation?.nodes ?? [];
|
|
60
|
+
$[4] = view.notation?.nodes;
|
|
61
|
+
$[5] = t2;
|
|
62
|
+
} else t2 = $[5];
|
|
63
|
+
const hasNotations = t2.length > 0;
|
|
64
|
+
const isComparing = compareView !== null;
|
|
65
|
+
const t3 = compareView ?? view;
|
|
66
|
+
let t4;
|
|
67
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
+
t4 = {
|
|
69
|
+
top: "70px",
|
|
70
|
+
bottom: "32px",
|
|
71
|
+
left: "50px",
|
|
72
|
+
right: "32px"
|
|
73
|
+
};
|
|
74
|
+
$[6] = t4;
|
|
75
|
+
} else t4 = $[6];
|
|
76
|
+
const t5 = isDevelopment || hasNotations;
|
|
77
|
+
const t6 = !isComparing;
|
|
78
|
+
const t7 = !isComparing;
|
|
79
|
+
let t8;
|
|
80
|
+
if ($[7] !== navigate) {
|
|
81
|
+
t8 = () => {
|
|
82
|
+
navigate({ to: "/" });
|
|
83
|
+
};
|
|
84
|
+
$[7] = navigate;
|
|
85
|
+
$[8] = t8;
|
|
86
|
+
} else t8 = $[8];
|
|
87
|
+
let t9;
|
|
88
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
89
|
+
t9 = /* @__PURE__ */ jsx(ListenForDiagramStateChanges, {});
|
|
90
|
+
$[9] = t9;
|
|
91
|
+
} else t9 = $[9];
|
|
92
|
+
let t10;
|
|
93
|
+
if ($[10] !== relationshipBrowserScope) {
|
|
94
|
+
t10 = /* @__PURE__ */ jsx(OpenRelationshipBrowserFromUrl, { relationshipBrowserScope });
|
|
95
|
+
$[10] = relationshipBrowserScope;
|
|
96
|
+
$[11] = t10;
|
|
97
|
+
} else t10 = $[11];
|
|
98
|
+
let t11;
|
|
99
|
+
let t12;
|
|
100
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t11 = /* @__PURE__ */ jsx(FocusElementFromUrl, {});
|
|
102
|
+
t12 = /* @__PURE__ */ jsx(LazyAIChat, {});
|
|
103
|
+
$[12] = t11;
|
|
104
|
+
$[13] = t12;
|
|
105
|
+
} else {
|
|
106
|
+
t11 = $[12];
|
|
107
|
+
t12 = $[13];
|
|
108
|
+
}
|
|
109
|
+
let t13;
|
|
110
|
+
if ($[14] !== dynamic || $[15] !== onNavigateTo || $[16] !== relationshipBrowserScope || $[17] !== setLayoutType || $[18] !== setRelationshipBrowserScope || $[19] !== t10 || $[20] !== t3 || $[21] !== t5 || $[22] !== t6 || $[23] !== t7 || $[24] !== t8) {
|
|
111
|
+
t13 = /* @__PURE__ */ jsxs(LikeC4Diagram, {
|
|
112
|
+
view: t3,
|
|
113
|
+
zoomable: true,
|
|
114
|
+
pannable: true,
|
|
115
|
+
controls: true,
|
|
116
|
+
fitViewPadding: t4,
|
|
117
|
+
showNavigationButtons: true,
|
|
118
|
+
enableNotations: t5,
|
|
119
|
+
enableSearch: true,
|
|
120
|
+
enableDynamicViewWalkthrough: t6,
|
|
121
|
+
enableFocusMode: true,
|
|
122
|
+
enableElementDetails: true,
|
|
123
|
+
enableRelationshipDetails: true,
|
|
124
|
+
enableRelationshipBrowser: true,
|
|
125
|
+
relationshipBrowserScope,
|
|
126
|
+
onRelationshipBrowserScopeChange: setRelationshipBrowserScope,
|
|
127
|
+
enableElementTags: true,
|
|
128
|
+
enableCompareWithLatest: t7,
|
|
129
|
+
dynamicViewVariant: dynamic,
|
|
130
|
+
onNavigateTo,
|
|
131
|
+
onLayoutTypeChange: setLayoutType,
|
|
132
|
+
onLogoClick: t8,
|
|
133
|
+
children: [
|
|
134
|
+
t9,
|
|
135
|
+
t10,
|
|
136
|
+
t11,
|
|
137
|
+
t12
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
$[14] = dynamic;
|
|
141
|
+
$[15] = onNavigateTo;
|
|
142
|
+
$[16] = relationshipBrowserScope;
|
|
143
|
+
$[17] = setLayoutType;
|
|
144
|
+
$[18] = setRelationshipBrowserScope;
|
|
145
|
+
$[19] = t10;
|
|
146
|
+
$[20] = t3;
|
|
147
|
+
$[21] = t5;
|
|
148
|
+
$[22] = t6;
|
|
149
|
+
$[23] = t7;
|
|
150
|
+
$[24] = t8;
|
|
151
|
+
$[25] = t13;
|
|
152
|
+
} else t13 = $[25];
|
|
153
|
+
const diagram = t13;
|
|
154
|
+
let t14;
|
|
155
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
156
|
+
t14 = {
|
|
157
|
+
position: "relative",
|
|
158
|
+
width: "100%",
|
|
159
|
+
height: "100%"
|
|
160
|
+
};
|
|
161
|
+
$[26] = t14;
|
|
162
|
+
} else t14 = $[26];
|
|
163
|
+
let t15;
|
|
164
|
+
if ($[27] !== $likec4model || $[28] !== diagram || $[29] !== isComparing || $[30] !== project) {
|
|
165
|
+
t15 = isComparing ? diagram : /* @__PURE__ */ jsx(LikeC4EditorProvider, {
|
|
166
|
+
editor: {
|
|
167
|
+
fetchView: (id, layout) => {
|
|
168
|
+
const model = $likec4model.get().view(id);
|
|
169
|
+
return layout === "auto" ? model.$view : model.$layouted;
|
|
170
|
+
},
|
|
171
|
+
handleChange: (viewId_0, change) => {
|
|
172
|
+
const event = {
|
|
173
|
+
projectId: project.id,
|
|
174
|
+
viewId: viewId_0,
|
|
175
|
+
change
|
|
176
|
+
};
|
|
177
|
+
return likec4rpc.updateView(event);
|
|
178
|
+
},
|
|
179
|
+
...isAIAvailable && { applySemanticLayout: (viewId_1) => likec4rpc.applySemanticLayout({
|
|
180
|
+
projectId: project.id,
|
|
181
|
+
viewId: viewId_1
|
|
182
|
+
}) }
|
|
183
|
+
},
|
|
184
|
+
children: diagram
|
|
185
|
+
});
|
|
186
|
+
$[27] = $likec4model;
|
|
187
|
+
$[28] = diagram;
|
|
188
|
+
$[29] = isComparing;
|
|
189
|
+
$[30] = project;
|
|
190
|
+
$[31] = t15;
|
|
191
|
+
} else t15 = $[31];
|
|
192
|
+
let t16;
|
|
193
|
+
if ($[32] !== t15 || $[33] !== view.id) {
|
|
194
|
+
t16 = /* @__PURE__ */ jsx(CompareModelProvider, {
|
|
195
|
+
viewId: view.id,
|
|
196
|
+
children: t15
|
|
197
|
+
});
|
|
198
|
+
$[32] = t15;
|
|
199
|
+
$[33] = view.id;
|
|
200
|
+
$[34] = t16;
|
|
201
|
+
} else t16 = $[34];
|
|
202
|
+
let t17;
|
|
203
|
+
if ($[35] !== view.id) {
|
|
204
|
+
t17 = /* @__PURE__ */ jsx(ModelDiffPanel, { viewId: view.id });
|
|
205
|
+
$[35] = view.id;
|
|
206
|
+
$[36] = t17;
|
|
207
|
+
} else t17 = $[36];
|
|
208
|
+
let t18;
|
|
209
|
+
if ($[37] !== t16 || $[38] !== t17) {
|
|
210
|
+
t18 = /* @__PURE__ */ jsxs("div", {
|
|
211
|
+
style: t14,
|
|
212
|
+
children: [t16, t17]
|
|
213
|
+
});
|
|
214
|
+
$[37] = t16;
|
|
215
|
+
$[38] = t17;
|
|
216
|
+
$[39] = t18;
|
|
217
|
+
} else t18 = $[39];
|
|
218
|
+
return t18;
|
|
219
|
+
}
|
|
220
|
+
export { ViewEditor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as FocusElementFromUrl, n as ListenForDiagramStateChanges, r as OpenRelationshipBrowserFromUrl, i as ViewReact } from "../chunks/ViewReact.mjs";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import "../chunks/rolldown-runtime.mjs";
|
|
2
|
+
// src/pages/export-layout.ts
|
|
3
|
+
var EXPORT_EXTRA_PADDING = 16;
|
|
4
|
+
var EXPORT_DESCRIPTION_GAP = 16;
|
|
5
|
+
var EXPORT_DESCRIPTION_INSET = 16;
|
|
6
|
+
var EXPORT_DESCRIPTION_MIN_HEIGHT = 84;
|
|
7
|
+
var EXPORT_DESCRIPTION_MAX_HEIGHT = 240;
|
|
8
|
+
var EXPORT_NOTATION_GAP = 24;
|
|
9
|
+
var EXPORT_NOTATION_WIDTH = 320;
|
|
10
|
+
var EXPORT_NOTATION_INSET = 12;
|
|
11
|
+
var EXPORT_NOTATION_HEADER_HEIGHT = 36;
|
|
12
|
+
var EXPORT_NOTATION_ITEM_HEIGHT = 68;
|
|
13
|
+
var EXPORT_DESCRIPTION_TITLE_LINE_HEIGHT = 20;
|
|
14
|
+
var EXPORT_DESCRIPTION_BODY_LINE_HEIGHT = 19;
|
|
15
|
+
var EXPORT_DESCRIPTION_TOP_PADDING = 10;
|
|
16
|
+
var EXPORT_DESCRIPTION_BODY_TOP_GAP = 4;
|
|
17
|
+
var EXPORT_DESCRIPTION_BOTTOM_PADDING = 16;
|
|
18
|
+
var EXPORT_DESCRIPTION_AVERAGE_CHARACTER_WIDTH = 7.5;
|
|
19
|
+
/**
|
|
20
|
+
* Calculates the reserved height for the notation panel in exported images.
|
|
21
|
+
*/
|
|
22
|
+
function exportNotationHeight(entries) {
|
|
23
|
+
return 60 + entries * 68;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Estimates the description panel height for exported images and clamps it to export-friendly bounds.
|
|
27
|
+
*/
|
|
28
|
+
function exportDescriptionHeight({ title, text, width }) {
|
|
29
|
+
const availableWidth = Math.max(80, width - 32);
|
|
30
|
+
const charactersPerLine = Math.max(12, Math.floor(availableWidth / EXPORT_DESCRIPTION_AVERAGE_CHARACTER_WIDTH));
|
|
31
|
+
const titleLines = title.trim().length > 0 ? 1 : 0;
|
|
32
|
+
const bodyLines = estimateWrappedLines(text, charactersPerLine);
|
|
33
|
+
const bodyTopGap = bodyLines > 0 ? 4 : 0;
|
|
34
|
+
const preferredHeight = 10 + titleLines * 20 + bodyTopGap + bodyLines * EXPORT_DESCRIPTION_BODY_LINE_HEIGHT + 16;
|
|
35
|
+
return Math.min(240, Math.max(84, Math.ceil(preferredHeight)));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Estimates wrapped text lines from plain text using an average character width.
|
|
39
|
+
*/
|
|
40
|
+
function estimateWrappedLines(text, charactersPerLine) {
|
|
41
|
+
const lines = text.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
42
|
+
if (lines.length === 0) return 0;
|
|
43
|
+
return lines.reduce((sum, line) => sum + Math.max(1, Math.ceil(line.length / charactersPerLine)), 0);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Computes the export canvas size and non-overlapping bounds for the diagram, description, and notation areas.
|
|
47
|
+
*/
|
|
48
|
+
function computeExportPageLayout({ bounds, padding, description, notationEntries }) {
|
|
49
|
+
const diagramWidth = bounds.width + padding * 2 + 16;
|
|
50
|
+
const diagramHeight = bounds.height + padding * 2 + 16;
|
|
51
|
+
const hasNotation = notationEntries > 0;
|
|
52
|
+
const width = hasNotation ? diagramWidth + 24 + 320 + padding : diagramWidth;
|
|
53
|
+
const descriptionHeight = description ? exportDescriptionHeight({
|
|
54
|
+
...description,
|
|
55
|
+
width
|
|
56
|
+
}) : 0;
|
|
57
|
+
const contentTop = descriptionHeight > 0 ? descriptionHeight + 16 : 0;
|
|
58
|
+
const diagram = {
|
|
59
|
+
left: 0,
|
|
60
|
+
top: contentTop,
|
|
61
|
+
width: diagramWidth,
|
|
62
|
+
height: diagramHeight
|
|
63
|
+
};
|
|
64
|
+
if (!hasNotation) return {
|
|
65
|
+
width,
|
|
66
|
+
height: contentTop + diagram.height,
|
|
67
|
+
diagram,
|
|
68
|
+
description: description ? {
|
|
69
|
+
left: 0,
|
|
70
|
+
top: 0,
|
|
71
|
+
width,
|
|
72
|
+
height: descriptionHeight
|
|
73
|
+
} : null,
|
|
74
|
+
notation: null
|
|
75
|
+
};
|
|
76
|
+
const notationHeight = exportNotationHeight(notationEntries);
|
|
77
|
+
return {
|
|
78
|
+
width,
|
|
79
|
+
height: contentTop + Math.max(diagram.height, notationHeight + padding * 2),
|
|
80
|
+
diagram,
|
|
81
|
+
description: description ? {
|
|
82
|
+
left: 0,
|
|
83
|
+
top: 0,
|
|
84
|
+
width,
|
|
85
|
+
height: descriptionHeight
|
|
86
|
+
} : null,
|
|
87
|
+
notation: {
|
|
88
|
+
left: diagram.width + 24,
|
|
89
|
+
top: contentTop + padding,
|
|
90
|
+
width: 320,
|
|
91
|
+
height: notationHeight
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export { EXPORT_DESCRIPTION_BODY_TOP_GAP, EXPORT_DESCRIPTION_BOTTOM_PADDING, EXPORT_DESCRIPTION_GAP, EXPORT_DESCRIPTION_INSET, EXPORT_DESCRIPTION_MAX_HEIGHT, EXPORT_DESCRIPTION_MIN_HEIGHT, EXPORT_DESCRIPTION_TITLE_LINE_HEIGHT, EXPORT_DESCRIPTION_TOP_PADDING, EXPORT_EXTRA_PADDING, EXPORT_NOTATION_GAP, EXPORT_NOTATION_HEADER_HEIGHT, EXPORT_NOTATION_INSET, EXPORT_NOTATION_ITEM_HEIGHT, EXPORT_NOTATION_WIDTH, computeExportPageLayout, exportDescriptionHeight, exportNotationHeight };
|