likec4 1.60.0 → 1.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +2 -0
  2. package/__app__/codegen/react.mjs +4 -10
  3. package/__app__/codegen/webcomponent.mjs +5 -208
  4. package/__app__/index.html +15 -15
  5. package/__app__/src/aichat/index.mjs +1 -2
  6. package/__app__/src/chunks/AIChat.mjs +292 -117
  7. package/__app__/src/chunks/ErrorComponent.mjs +444 -0
  8. package/__app__/src/chunks/Header.mjs +269 -0
  9. package/__app__/src/chunks/ViewReact.mjs +438 -0
  10. package/__app__/src/chunks/find.mjs +38 -0
  11. package/__app__/src/chunks/hooks.mjs +18 -541
  12. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
  13. package/__app__/src/chunks/libs/@tanstack-ai.mjs +11101 -1797
  14. package/__app__/src/chunks/libs/@tanstack.mjs +4563 -3083
  15. package/__app__/src/chunks/libs/fast-equals.mjs +140 -71
  16. package/__app__/src/chunks/{es.mjs → libs/html-to-image.mjs} +16 -22
  17. package/__app__/src/chunks/libs/nanostores.mjs +4 -8
  18. package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
  19. package/__app__/src/chunks/react.mjs +22 -0
  20. package/__app__/src/chunks/rolldown-runtime.mjs +3 -32
  21. package/__app__/src/chunks/router.mjs +106 -0
  22. package/__app__/src/chunks/scope.mjs +106 -0
  23. package/__app__/src/chunks/searchParams.mjs +29 -0
  24. package/__app__/src/chunks/single-index.mjs +465 -0
  25. package/__app__/src/chunks/styled-system.mjs +1916 -2946
  26. package/__app__/src/chunks/useAsync.mjs +69 -0
  27. package/__app__/src/chunks/useSyncedRef.mjs +16 -0
  28. package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
  29. package/__app__/src/components/CopyToClipboard.mjs +53 -0
  30. package/__app__/src/components/ErrorComponent.mjs +1 -0
  31. package/__app__/src/components/NavigationPanel.mjs +63 -0
  32. package/__app__/src/components/NotFound.mjs +155 -0
  33. package/__app__/src/components/ViewOutlet.mjs +9 -0
  34. package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
  35. package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
  36. package/__app__/src/components/model-diff/compare-model.mjs +76 -0
  37. package/__app__/src/components/model-diff/state.mjs +45 -0
  38. package/__app__/src/components/search/OverviewSearch.mjs +92 -0
  39. package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
  40. package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
  41. package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
  42. package/__app__/src/components/sidebar/Drawer.mjs +178 -0
  43. package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
  44. package/__app__/src/components/sidebar/data.mjs +94 -0
  45. package/__app__/src/components/sidebar/state.mjs +16 -0
  46. package/__app__/src/components/view-page/Header.mjs +1 -0
  47. package/__app__/src/components/view-page/SelectProject.mjs +258 -0
  48. package/__app__/src/components/view-page/ShareModal.mjs +111 -0
  49. package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
  50. package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
  51. package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
  52. package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
  53. package/__app__/src/components/view-page/state.mjs +17 -0
  54. package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
  55. package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
  56. package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
  57. package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
  58. package/__app__/src/context/ModelDiffsContext.mjs +33 -0
  59. package/__app__/src/context/safeCtx.mjs +14 -0
  60. package/__app__/src/hooks.mjs +1 -0
  61. package/__app__/src/main.mjs +4 -48126
  62. package/__app__/src/pages/EmbedPage.mjs +93 -0
  63. package/__app__/src/pages/ExportPage.mjs +691 -0
  64. package/__app__/src/pages/ProjectsOverview.mjs +23 -0
  65. package/__app__/src/pages/ViewAsD2.mjs +105 -0
  66. package/__app__/src/pages/ViewAsDot.mjs +65 -0
  67. package/__app__/src/pages/ViewAsMmd.mjs +109 -0
  68. package/__app__/src/pages/ViewAsPuml.mjs +105 -0
  69. package/__app__/src/pages/ViewEditor.mjs +220 -0
  70. package/__app__/src/pages/ViewReact.mjs +1 -0
  71. package/__app__/src/pages/export-layout.mjs +95 -0
  72. package/__app__/src/pages/export-page-params.mjs +9 -0
  73. package/__app__/src/pages/styles.css.mjs +23 -0
  74. package/__app__/src/routeTree.gen.mjs +105 -0
  75. package/__app__/src/router.mjs +1 -0
  76. package/__app__/src/routes/__root.mjs +65 -0
  77. package/__app__/src/routes/index.css.mjs +29 -0
  78. package/__app__/src/routes/index.mjs +32 -0
  79. package/__app__/src/routes/project._projectId/-components.mjs +100 -0
  80. package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
  81. package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
  82. package/__app__/src/routes/project._projectId/index.mjs +14 -0
  83. package/__app__/src/routes/project._projectId/route.mjs +93 -0
  84. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
  85. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
  86. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
  87. package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
  88. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
  89. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
  90. package/__app__/src/routes/projects.mjs +36 -0
  91. package/__app__/src/routes/single-index.mjs +1 -0
  92. package/__app__/src/routes/webcomponent._.mjs +94 -0
  93. package/__app__/src/style.css +1156 -1147
  94. package/config/schema.json +26 -2
  95. package/dist/app/render-view-client.css +1 -1
  96. package/dist/app/render-view-client.js +375 -393
  97. package/dist/chunks/filenames.mjs +26 -20
  98. package/dist/chunks/generate-likec4.mjs +4 -4
  99. package/dist/chunks/index.d.mts +16 -15
  100. package/dist/chunks/index2.d.mts +7041 -3293
  101. package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
  102. package/dist/chunks/libs/@logtape/logtape.mjs +5 -5
  103. package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
  104. package/dist/chunks/libs/chevrotain.mjs +19 -19
  105. package/dist/chunks/libs/clone.mjs +1 -0
  106. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  107. package/dist/chunks/libs/fast-equals.mjs +1 -0
  108. package/dist/chunks/libs/fontkit.mjs +1 -0
  109. package/dist/chunks/libs/langium.d.mts +80 -2933
  110. package/dist/chunks/libs/langium.mjs +6 -6
  111. package/dist/chunks/libs/pako.mjs +1 -1
  112. package/dist/chunks/libs/pathe.mjs +1 -1
  113. package/dist/chunks/libs/remeda.mjs +1 -1
  114. package/dist/chunks/node.mjs +110 -77
  115. package/dist/chunks/rolldown-runtime.mjs +1 -1
  116. package/dist/chunks/sequence-view.mjs +1 -1
  117. package/dist/chunks/vite-plugin.mjs +183 -164
  118. package/dist/cli/index.mjs +157 -101
  119. package/dist/config/index.d.mts +65 -4
  120. package/dist/config/index.mjs +1 -1
  121. package/dist/generators/likec4.d.mts +16 -64
  122. package/dist/index.d.mts +2 -4
  123. package/dist/model/index.d.mts +0 -10
  124. package/dist/vite-plugin/index.d.mts +83 -61
  125. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -2
  126. package/dist/vite-plugin/internal/index.d.mts +91 -17
  127. package/dist/vite-plugin/internal/index.mjs +156 -110
  128. package/package.json +60 -55
  129. package/react/index.d.mts +3010 -4014
  130. package/react/index.mjs +170 -171
  131. package/react/rolldown-runtime-CfRud99p.js +1 -0
  132. package/skills/likec4-dsl/SKILL.md +71 -25
  133. package/skills/likec4-dsl/evals/evals-public.json +5 -0
  134. package/skills/likec4-dsl/evals/grading-spec.json +15 -1
  135. package/skills/likec4-dsl/references/cli.md +39 -10
  136. package/skills/likec4-dsl/references/configuration.md +5 -5
  137. package/skills/likec4-dsl/references/diffs.md +52 -0
  138. package/skills/likec4-dsl/references/examples.md +2 -2
  139. package/skills/likec4-dsl/references/identifier-validity.md +31 -31
  140. package/skills/likec4-dsl/references/include-predicates-wildcards.md +16 -15
  141. package/skills/likec4-dsl/references/model.md +42 -11
  142. package/skills/likec4-dsl/references/specification.md +11 -7
  143. package/skills/likec4-dsl/references/troubleshooting.md +47 -42
  144. package/skills/likec4-dsl/references/views.md +2 -2
  145. package/vite-plugin-modules.d.ts +126 -51
  146. package/__app__/src/chunks/LikeC4Styles.mjs +0 -4522
  147. package/__app__/src/chunks/ProjectsOverview.mjs +0 -827
  148. package/__app__/src/chunks/libs/@floating-ui.mjs +0 -3286
  149. package/__app__/src/chunks/libs/@mantine.mjs +0 -17731
  150. package/__app__/src/chunks/libs/@xstate/react.mjs +0 -3471
  151. package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -7927
  152. package/__app__/src/chunks/libs/bezier-js.mjs +0 -1593
  153. package/__app__/src/chunks/libs/d3.mjs +0 -4531
  154. package/__app__/src/chunks/libs/framer.mjs +0 -11331
  155. package/__app__/src/chunks/libs/zod.mjs +0 -5404
  156. package/dist/chunks/libs/@chevrotain/types.d.mts +0 -111
  157. package/react/rolldown-runtime-DnkiqaRY.js +0 -1
@@ -1,535 +1,18 @@
1
- import { i as __name } from "./rolldown-runtime.mjs";
2
- import { i as useMatches, u as useParams } from "./libs/@tanstack.mjs";
3
- import { ut as Text } from "./libs/@mantine.mjs";
4
- import { I as cx, k as Box, o as markdownBlock } from "./styled-system.mjs";
5
- import { n as shallowEqual, t as deepEqual } from "./libs/fast-equals.mjs";
6
- import { t as listenKeys } from "./libs/nanostores.mjs";
7
- import { b as invariant } from "./libs/framer.mjs";
8
- import { n as useSelector } from "./libs/@xstate/react.mjs";
9
- import { createContext, createElement, forwardRef, use, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
1
+ import "./rolldown-runtime.mjs";
2
+ import { r as useMatches, u as useParams } from "./libs/@tanstack.mjs";
3
+ import { t as deepEqual } from "./libs/fast-equals.mjs";
4
+ import { useLikeC4ModelAtom } from "../context/safeCtx.mjs";
5
+ import { useEffect, useLayoutEffect, useState } from "react";
10
6
  import { c } from "react/compiler-runtime";
11
- import { jsx } from "react/jsx-runtime";
12
7
  import { useLikeC4Projects } from "likec4:projects";
13
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/lazyDataLastImpl--3B10z3s.js
14
- function e$2(e, t, n) {
15
- let r = (n) => e(n, ...t);
16
- return n === void 0 ? r : Object.assign(r, {
17
- lazy: n,
18
- lazyArgs: t
19
- });
20
- }
21
- __name(e$2, "e");
22
- //#endregion
23
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/purry.js
24
- function t$3(t, n, r) {
25
- let i = t.length - n.length;
26
- if (i === 0) return t(...n);
27
- if (i === 1) return e$2(t, n, r);
28
- throw Error(`Wrong number of arguments`);
29
- }
30
- __name(t$3, "t");
31
- //#endregion
32
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/utilityEvaluators-IxVD3t2o.js
33
- var t$2 = {
34
- done: !1,
35
- hasNext: !1
36
- };
37
- var r$3 = /* @__PURE__ */ __name((e) => ({
38
- hasNext: !0,
39
- next: e,
40
- done: !1
41
- }), "r");
42
- //#endregion
43
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/pipe.js
44
- function t$1(e, ...t) {
45
- let i = e;
46
- let o = t.map((e) => `lazy` in e ? {
47
- lazyEvaluator: e.lazy(...e.lazyArgs),
48
- isSingle: e.lazy.single ?? !1,
49
- index: 0,
50
- items: []
51
- } : void 0);
52
- let s = 0;
53
- for (; s < t.length;) {
54
- if (o[s] === void 0 || !a$1(i)) {
55
- let e = t[s];
56
- i = e(i), s += 1;
57
- continue;
58
- }
59
- let e = n$1(o, s), c = r$2(i, e), { isSingle: l } = e.at(-1);
60
- i = l ? c[0] : c, s += e.length;
61
- }
62
- return i;
63
- }
64
- __name(t$1, "t");
65
- function n$1(e, t) {
66
- let n = [];
67
- for (let r = t; r < e.length; r++) {
68
- let t = e[r];
69
- if (t === void 0 || (n.push(t), t.isSingle)) break;
70
- }
71
- return n;
72
- }
73
- __name(n$1, "n");
74
- function r$2(e, t) {
75
- let n = [];
76
- for (let r of e) if (i$1(r, n, t)) break;
77
- return n;
78
- }
79
- __name(r$2, "r");
80
- function i$1(t, n, r) {
81
- if (r.length === 0) return n.push(t), !1;
82
- let a = t;
83
- let o = t$2;
84
- let s = !1;
85
- for (let [e, { items: t, lazyEvaluator: c }] of r.entries()) if (t.push(a), o = c(a, t.length - 1, t), o.done && (s = !0), o.hasNext) {
86
- if (o.hasMany ?? !1) {
87
- for (let t of o.next) if (i$1(t, n, r.slice(e + 1))) return !0;
88
- return s;
89
- }
90
- a = o.next;
91
- } else break;
92
- return o.hasNext && n.push(a), s;
93
- }
94
- __name(i$1, "i");
95
- function a$1(e) {
96
- return typeof e == `string` || typeof e == `object` && !!e && Symbol.iterator in e;
97
- }
98
- __name(a$1, "a");
99
- //#endregion
100
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/toSingle-DiQSixar.js
101
- var e$1 = /* @__PURE__ */ __name((e) => Object.assign(e, { single: !0 }), "e");
102
- //#endregion
103
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/find.js
104
- function r$1(...t) {
105
- return t$3(i, t, e$1(a));
106
- }
107
- __name(r$1, "r");
108
- var i = (e, t) => e.find(t);
109
- var a = (e) => (n, r, i) => e(n, r, i) ? {
110
- done: !0,
111
- hasNext: !0,
112
- next: n
113
- } : t$2;
114
- //#endregion
115
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/isFunction.js
116
- var e = (e) => typeof e == `function`;
117
- //#endregion
118
- //#region ../../node_modules/.pnpm/remeda@2.51.0/node_modules/remeda/dist/map.js
119
- function t(...t) {
120
- return t$3(n, t, r);
121
- }
122
- var n = (e, t) => e.map(t);
123
- var r = (e) => (t, n, r) => ({
124
- done: !1,
125
- hasNext: !0,
126
- next: e(t, n, r)
127
- });
128
- //#endregion
129
- //#region ../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.0/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
130
- /**
131
- * @license @tabler/icons-react v3.49.0 - MIT
132
- *
133
- * This source code is licensed under the MIT license.
134
- * See the LICENSE file in the root directory of this source tree.
135
- */
136
- var defaultAttributes = {
137
- outline: {
138
- xmlns: "http://www.w3.org/2000/svg",
139
- width: 24,
140
- height: 24,
141
- viewBox: "0 0 24 24",
142
- fill: "none",
143
- stroke: "currentColor",
144
- strokeWidth: 2,
145
- strokeLinecap: "round",
146
- strokeLinejoin: "round"
147
- },
148
- filled: {
149
- xmlns: "http://www.w3.org/2000/svg",
150
- width: 24,
151
- height: 24,
152
- viewBox: "0 0 24 24",
153
- fill: "currentColor",
154
- stroke: "none"
155
- }
156
- };
157
- //#endregion
158
- //#region ../../node_modules/.pnpm/@tabler+icons-react@3.49.0_react@19.3.0/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
159
- /**
160
- * @license @tabler/icons-react v3.49.0 - MIT
161
- *
162
- * This source code is licensed under the MIT license.
163
- * See the LICENSE file in the root directory of this source tree.
164
- */
165
- var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
166
- const Component = forwardRef(({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement("svg", {
167
- ref,
168
- ...defaultAttributes[type],
169
- width: size,
170
- height: size,
171
- className: [
172
- `tabler-icon`,
173
- `tabler-icon-${iconName}`,
174
- className
175
- ].filter(Boolean).join(" "),
176
- ...type === "filled" ? { fill: color } : {
177
- strokeWidth: stroke,
178
- stroke: color
179
- },
180
- ...rest
181
- }, [
182
- title && createElement("title", { key: "svg-title" }, title),
183
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
184
- ...Array.isArray(children) ? children : [children]
185
- ]));
186
- Component.displayName = `${iconNamePascal}`;
187
- return Component;
188
- };
189
- /**
190
- * @license @tabler/icons-react v3.49.0 - MIT
191
- *
192
- * This source code is licensed under the MIT license.
193
- * See the LICENSE file in the root directory of this source tree.
194
- */
195
- var IconSparkles = createReactComponent("outline", "sparkles", "Sparkles", [["path", {
196
- "d": "M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",
197
- "key": "svg-0"
198
- }]]);
199
- /**
200
- * @license @tabler/icons-react v3.49.0 - MIT
201
- *
202
- * This source code is licensed under the MIT license.
203
- * See the LICENSE file in the root directory of this source tree.
204
- */
205
- var IconPlayerStopFilled = createReactComponent("filled", "player-stop-filled", "PlayerStopFilled", [["path", {
206
- "d": "M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",
207
- "key": "svg-0"
208
- }]]);
209
- //#endregion
210
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/useSyncedRef/index.js
211
- /**
212
- * Like `useRef`, but it returns immutable ref that contains actual value.
213
- *
214
- * @param value
215
- */
216
- function useSyncedRef(value) {
217
- const ref = useRef(value);
218
- ref.current = value;
219
- return useMemo(() => Object.freeze({ get current() {
220
- return ref.current;
221
- } }), []);
222
- }
223
- //#endregion
224
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/util/const.js
225
- var noop$1 = /* @__PURE__ */ __name(() => {}, "noop");
226
- var isBrowser = typeof globalThis !== "undefined" && typeof navigator !== "undefined" && typeof document !== "undefined";
227
- //#endregion
228
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/util/misc.js
229
- var basicDepsComparator = (d1, d2) => {
230
- if (d1 === d2) return true;
231
- if (d1.length !== d2.length) return false;
232
- for (const [i, element] of d1.entries()) if (element !== d2[i]) return false;
233
- return true;
234
- };
235
- //#endregion
236
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/useCustomCompareEffect/index.js
237
- /**
238
- * Like `useEffect` but uses provided comparator function to validate dependency changes.
239
- *
240
- * @param callback Function that will be passed to the underlying effect hook.
241
- * @param deps Dependency list like the one passed to `useEffect`.
242
- * @param comparator Function that compares two dependency arrays,
243
- * and returns `true` if they're equal.
244
- * @param effectHook Effect hook that will be used to run
245
- * `callback`. Must match the type signature of `useEffect`, meaning that the `callback` should be
246
- * placed as the first argument and the dependency list as second.
247
- * @param effectHookRestArgs Extra arguments that are passed to the `effectHook`
248
- * after the `callback` and the dependency list.
249
- */
250
- function useCustomCompareEffect(callback, deps, comparator = basicDepsComparator, effectHook = useEffect, ...effectHookRestArgs) {
251
- const dependencies = useRef(void 0);
252
- if (dependencies.current === void 0 || isBrowser && !comparator(dependencies.current, deps)) dependencies.current = deps;
253
- effectHook(callback, dependencies.current, ...effectHookRestArgs);
254
- }
255
- //#endregion
256
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/useFirstMountState/index.js
257
- /**
258
- * Returns a boolean that is `true` only on first render.
259
- */
260
- function useFirstMountState() {
261
- const isFirstMount = useRef(true);
262
- useEffect(() => {
263
- isFirstMount.current = false;
264
- }, []);
265
- return isFirstMount.current;
266
- }
267
- //#endregion
268
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/useIsomorphicLayoutEffect/index.js
8
+ import { useUpdateEffect } from "likec4/react";
9
+ // ../../node_modules/.pnpm/@react-hookz+web@26.1.0_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/@react-hookz/web/dist/useIsomorphicLayoutEffect/index.js
269
10
  /**
270
11
  * Alias for `useLayoutEffect` in browser, but for `useEffect` at server side. Helps to avoid
271
12
  * warning shown during SSR.
272
13
  */
273
- var useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;
274
- //#endregion
275
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@react-hookz/web/dist/useTimeoutEffect/index.js
276
- var cancelTimeout = (id) => {
277
- if (id) clearTimeout(id);
278
- };
279
- /**
280
- * Like `setTimeout` but in the form of a react hook.
281
- *
282
- * @param callback Callback to be called after the timeout. Changing this
283
- * will not reset the timeout.
284
- * @param ms Timeout delay in milliseconds. `undefined` disables the timeout.
285
- * Keep in mind, that changing this parameter will re-set timeout, meaning
286
- * that it will be set as new after the change.
287
- */
288
- function useTimeoutEffect(callback, ms) {
289
- const cbRef = useSyncedRef(callback);
290
- const msRef = useSyncedRef(ms);
291
- const timeoutIdRef = useRef(null);
292
- const cancel = useCallback(() => {
293
- cancelTimeout(timeoutIdRef.current);
294
- }, []);
295
- const reset = useCallback(() => {
296
- if (msRef.current === void 0) return;
297
- cancel();
298
- timeoutIdRef.current = setTimeout(() => {
299
- cbRef.current();
300
- }, msRef.current);
301
- }, []);
302
- useEffect(() => {
303
- reset();
304
- return cancel;
305
- }, [ms]);
306
- return [cancel, reset];
307
- }
308
- //#endregion
309
- //#region ../diagram/src/hooks/useUpdateEffect.ts
310
- var noop = () => {};
311
- var depsShallowEqual = (d1, d2) => {
312
- if (d1 === d2) return true;
313
- if (d1.length !== d2.length) return false;
314
- for (const [i, element] of d1.entries()) {
315
- if (element === d2[i] || shallowEqual(element, d2[i])) continue;
316
- return false;
317
- }
318
- return true;
319
- };
320
- function useUpdateEffect(callback, deps, equalityFn, effectHook) {
321
- useCustomCompareEffect(useFirstMountState() ? noop : callback, deps, equalityFn ?? depsShallowEqual, effectHook);
322
- }
323
- //#endregion
324
- //#region ../../node_modules/.pnpm/@nanostores+react@2.0.1_nanostores@1.5.5_react@19.3.0/node_modules/@nanostores/react/index.js
325
- var emit = (snapshotRef, onChange) => (value) => {
326
- if (snapshotRef.current === value) return;
327
- snapshotRef.current = value;
328
- onChange();
329
- };
330
- function useStore(store, { keys, deps = [store, keys], ssr } = {}) {
331
- let snapshotRef = useRef();
332
- snapshotRef.current = store.get();
333
- let subscribe = useCallback((onChange) => {
334
- emit(snapshotRef, onChange)(store.value);
335
- return keys?.length > 0 ? listenKeys(store, keys, emit(snapshotRef, onChange)) : store.listen(emit(snapshotRef, onChange));
336
- }, deps);
337
- let get = () => snapshotRef.current;
338
- let server = get;
339
- if (ssr && "init" in store) server = ssr === "initial" ? () => store.init : ssr;
340
- return useSyncExternalStore(subscribe, get, server);
341
- }
342
- //#endregion
343
- //#region ../diagram/src/hooks/safeContext.tsx
344
- var DiagramApiSafeContext = createContext(null);
345
- DiagramApiSafeContext.displayName = "DiagramApiSafeContext";
346
- var DiagramApiContextProvider = DiagramApiSafeContext.Provider;
347
- function useDiagram() {
348
- const ctx = use(DiagramApiSafeContext);
349
- if (ctx === null) throw new Error("DiagramApi is not provided");
350
- return ctx;
351
- }
352
- /**
353
- * Helper to create a safe context for an actor
354
- * @example
355
- * ```tsx
356
- * const {
357
- * ContextProvider: MyActorContext,
358
- * useActorRef,
359
- * selectSnapshot,
360
- * useActorSelector
361
- * } = createSafeContextForActor<MyActorRef>()
362
- *
363
- * const select = selectSnapshot(
364
- * s => ....,
365
- * (a, b) => a === b
366
- * )
367
- *
368
- * // Later in component:
369
- * const value = useActorSelector(select)
370
- * ```
371
- */
372
- function createSafeContextForActor(name) {
373
- const Ctx = createContext(null);
374
- function selectSnapshot(selector, compare) {
375
- return [selector, compare ?? shallowEqual];
376
- }
377
- function selectContext(selector, compare) {
378
- return [(snapshot) => selector(snapshot.context), compare ?? shallowEqual];
379
- }
380
- function useActorRef() {
381
- const actorRef = useContext(Ctx);
382
- if (actorRef === null) throw new Error(`${name}SafeContext is not provided `);
383
- return actorRef;
384
- }
385
- function useActorSelector(arg1, arg2) {
386
- let selector;
387
- let compare;
388
- if (arg2 !== void 0) [selector, compare] = [arg1, arg2];
389
- else if (Array.isArray(arg1)) [selector, compare] = arg1;
390
- else {
391
- selector = arg1;
392
- compare = shallowEqual;
393
- }
394
- compare ??= shallowEqual;
395
- invariant(e(selector), "selector must be a function");
396
- return useSelector(useActorRef(), selector, compare);
397
- }
398
- return {
399
- ContextProvider: Ctx.Provider,
400
- selectSnapshot,
401
- selectContext,
402
- useActorSelector,
403
- useActorRef
404
- };
405
- }
406
- var { ContextProvider: DiagramActorContextProvider, selectSnapshot: selectDiagramSnapshot, selectContext: selectDiagramContext, useActorSelector: useDiagramSelector, useActorRef: useDiagramActorRef } = createSafeContextForActor("DiagramActor");
407
- //#endregion
408
- //#region ../diagram/src/base-primitives/Markdown.tsx
409
- var Markdown = forwardRef((t0, ref) => {
410
- const $ = c(34);
411
- let className;
412
- let fontSize;
413
- let props;
414
- let style;
415
- let t1;
416
- let t2;
417
- let t3;
418
- let t4;
419
- let value;
420
- if ($[0] !== t0) {
421
- ({value, textScale: t1, uselikec4palette: t2, hideIfEmpty: t3, emptyText: t4, className, style, fontSize, ...props} = t0);
422
- $[0] = t0;
423
- $[1] = className;
424
- $[2] = fontSize;
425
- $[3] = props;
426
- $[4] = style;
427
- $[5] = t1;
428
- $[6] = t2;
429
- $[7] = t3;
430
- $[8] = t4;
431
- $[9] = value;
432
- } else {
433
- className = $[1];
434
- fontSize = $[2];
435
- props = $[3];
436
- style = $[4];
437
- t1 = $[5];
438
- t2 = $[6];
439
- t3 = $[7];
440
- t4 = $[8];
441
- value = $[9];
442
- }
443
- const textScale = t1 === void 0 ? 1 : t1;
444
- const uselikec4palette = t2 === void 0 ? false : t2;
445
- const hideIfEmpty = t3 === void 0 ? false : t3;
446
- const emptyText = t4 === void 0 ? "no content" : t4;
447
- if (value.isEmpty && hideIfEmpty) return null;
448
- let t5;
449
- if ($[10] !== emptyText || $[11] !== value.html || $[12] !== value.isMarkdown || $[13] !== value.nonEmpty || $[14] !== value.text) {
450
- t5 = value.nonEmpty ? value.isMarkdown ? { dangerouslySetInnerHTML: { __html: value.html } } : { children: /* @__PURE__ */ jsx("p", { children: value.text }) } : { children: /* @__PURE__ */ jsx(Text, {
451
- component: "span",
452
- fz: "xs",
453
- c: "dimmed",
454
- style: { userSelect: "none" },
455
- children: emptyText
456
- }) };
457
- $[10] = emptyText;
458
- $[11] = value.html;
459
- $[12] = value.isMarkdown;
460
- $[13] = value.nonEmpty;
461
- $[14] = value.text;
462
- $[15] = t5;
463
- } else t5 = $[15];
464
- const content = t5;
465
- let t6;
466
- if ($[16] !== className || $[17] !== uselikec4palette || $[18] !== value.isMarkdown) {
467
- t6 = cx(markdownBlock({
468
- uselikec4palette,
469
- value: value.isMarkdown ? "markdown" : "plaintext"
470
- }), className);
471
- $[16] = className;
472
- $[17] = uselikec4palette;
473
- $[18] = value.isMarkdown;
474
- $[19] = t6;
475
- } else t6 = $[19];
476
- let t7;
477
- if ($[20] !== fontSize) {
478
- t7 = fontSize && { "--text-fz": `var(--font-sizes-${fontSize}, var(--font-sizes-md))` };
479
- $[20] = fontSize;
480
- $[21] = t7;
481
- } else t7 = $[21];
482
- let t8;
483
- if ($[22] !== textScale) {
484
- t8 = textScale !== 1 && { "--mantine-scale": textScale };
485
- $[22] = textScale;
486
- $[23] = t8;
487
- } else t8 = $[23];
488
- let t9;
489
- if ($[24] !== style || $[25] !== t7 || $[26] !== t8) {
490
- t9 = {
491
- ...style,
492
- ...t7,
493
- ...t8
494
- };
495
- $[24] = style;
496
- $[25] = t7;
497
- $[26] = t8;
498
- $[27] = t9;
499
- } else t9 = $[27];
500
- let t10;
501
- if ($[28] !== content || $[29] !== props || $[30] !== ref || $[31] !== t6 || $[32] !== t9) {
502
- t10 = /* @__PURE__ */ jsx(Box, {
503
- ...props,
504
- ref,
505
- className: t6,
506
- style: t9,
507
- ...content
508
- });
509
- $[28] = content;
510
- $[29] = props;
511
- $[30] = ref;
512
- $[31] = t6;
513
- $[32] = t9;
514
- $[33] = t10;
515
- } else t10 = $[33];
516
- return t10;
517
- });
518
- Markdown.displayName = "Markdown";
519
- //#endregion
520
- //#region src/context/safeCtx.ts
521
- /**
522
- * To improve experience with HMR, we move context to separate files and use as a boundary for hooks
523
- */
524
- var LikeC4ModelDataContext = createContext(null);
525
- var LikeC4ModelDataContextProvider = LikeC4ModelDataContext.Provider;
526
- var useLikeC4ModelAtom = () => {
527
- const ctx = useContext(LikeC4ModelDataContext);
528
- if (ctx === null) throw new Error("LikeC4ModelAtom is not provided");
529
- return ctx;
530
- };
531
- //#endregion
532
- //#region src/hooks.ts
14
+ var useIsomorphicLayoutEffect = typeof globalThis !== "undefined" && typeof navigator !== "undefined" && typeof document !== "undefined" ? useLayoutEffect : useEffect;
15
+ // src/hooks.ts
533
16
  function useTransparentBackground(t0) {
534
17
  const $ = c(3);
535
18
  const enabled = t0 === void 0 ? true : t0;
@@ -567,15 +50,7 @@ function useLikeC4Views() {
567
50
  let t2;
568
51
  if ($[1] !== $likec4model) {
569
52
  t1 = () => $likec4model.subscribe((next) => {
570
- setViews((prev) => {
571
- const nextViews = [...next.views()].map((v) => {
572
- const n = v.$layouted;
573
- const p = prev.find((_) => _.id === v.id);
574
- return !!p && deepEqual(n, p) ? p : n;
575
- });
576
- if (shallowEqual(prev, nextViews)) return prev;
577
- return nextViews;
578
- });
53
+ setViews([...next.views()].map(_temp));
579
54
  });
580
55
  t2 = [$likec4model];
581
56
  $[1] = $likec4model;
@@ -588,19 +63,22 @@ function useLikeC4Views() {
588
63
  useEffect(t1, t2);
589
64
  return views;
590
65
  }
66
+ function _temp(v) {
67
+ return v.$layouted;
68
+ }
591
69
  function useCurrentViewId() {
592
70
  const $ = c(1);
593
71
  let t0;
594
72
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
595
73
  t0 = {
596
- select: _temp,
74
+ select: _temp2,
597
75
  strict: false
598
76
  };
599
77
  $[0] = t0;
600
78
  } else t0 = $[0];
601
79
  return useParams(t0) ?? "index";
602
80
  }
603
- function _temp(params) {
81
+ function _temp2(params) {
604
82
  return params.viewId;
605
83
  }
606
84
  /**
@@ -636,12 +114,12 @@ function useCurrentView() {
636
114
  let t3;
637
115
  let t4;
638
116
  if ($[6] !== $likec4model || $[7] !== layoutType || $[8] !== viewId) {
639
- t3 = () => $likec4model.subscribe((next, old) => {
117
+ t3 = () => $likec4model.subscribe((next) => {
640
118
  setView((current) => {
641
119
  const vm = next.findView(viewId);
642
120
  if (!vm) return current?.id === viewId ? current : null;
643
121
  const nextView = layoutType === "auto" ? vm.$view : vm.$layouted;
644
- if (deepEqual(current, nextView)) return current;
122
+ if (current && current.id === nextView.id && current._layout === nextView._layout && current.hash === nextView.hash && deepEqual(current, nextView)) return current;
645
123
  return nextView;
646
124
  });
647
125
  });
@@ -692,5 +170,4 @@ function useCurrentProject() {
692
170
  function selectProjectIdFromContext(matches) {
693
171
  return matches.find((m) => m.routeId === "/project/$projectId")?.params?.projectId ?? matches.at(-1)?.context.projectId ?? void 0;
694
172
  }
695
- //#endregion
696
- export { r$1 as A, noop$1 as C, createReactComponent as D, IconSparkles as E, t$3 as F, e$2 as I, t$1 as M, r$3 as N, t as O, t$2 as P, isBrowser as S, IconPlayerStopFilled as T, useStore as _, useTransparentBackground as a, useTimeoutEffect as b, Markdown as c, createSafeContextForActor as d, selectDiagramContext as f, useDiagramSelector as g, useDiagramActorRef as h, useLikeC4Views as i, e$1 as j, e as k, DiagramActorContextProvider as l, useDiagram as m, useCurrentView as n, LikeC4ModelDataContextProvider as o, selectDiagramSnapshot as p, useCurrentViewId as r, useLikeC4ModelAtom as s, useCurrentProject as t, DiagramApiContextProvider as u, depsShallowEqual as v, useSyncedRef as w, useFirstMountState as x, useUpdateEffect as y };
173
+ export { useTransparentBackground as a, useLikeC4Views as i, useCurrentView as n, useCurrentViewId as r, useCurrentProject as t };