likec4 1.59.4 → 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 (186) hide show
  1. package/README.md +2 -0
  2. package/__app__/codegen/react.mjs +4 -10
  3. package/__app__/codegen/webcomponent.mjs +6 -131
  4. package/__app__/index.html +15 -15
  5. package/__app__/src/aichat/index.mjs +11 -7
  6. package/__app__/src/chunks/AIChat.mjs +1355 -739
  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 +158 -472
  12. package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
  13. package/__app__/src/chunks/libs/@tanstack-ai.mjs +11841 -1417
  14. package/__app__/src/chunks/libs/@tanstack.mjs +5110 -2404
  15. package/__app__/src/chunks/libs/fast-equals.mjs +507 -214
  16. package/__app__/src/chunks/libs/html-to-image.mjs +613 -0
  17. package/__app__/src/chunks/libs/nanostores.mjs +170 -0
  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 +16 -29
  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 +1826 -2528
  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/fonts.css +112 -1
  61. package/__app__/src/hooks.mjs +1 -0
  62. package/__app__/src/main.mjs +6 -29151
  63. package/__app__/src/pages/EmbedPage.mjs +93 -0
  64. package/__app__/src/pages/ExportPage.mjs +691 -0
  65. package/__app__/src/pages/ProjectsOverview.mjs +23 -0
  66. package/__app__/src/pages/ViewAsD2.mjs +105 -0
  67. package/__app__/src/pages/ViewAsDot.mjs +65 -0
  68. package/__app__/src/pages/ViewAsMmd.mjs +109 -0
  69. package/__app__/src/pages/ViewAsPuml.mjs +105 -0
  70. package/__app__/src/pages/ViewEditor.mjs +220 -0
  71. package/__app__/src/pages/ViewReact.mjs +1 -0
  72. package/__app__/src/pages/export-layout.mjs +95 -0
  73. package/__app__/src/pages/export-page-params.mjs +9 -0
  74. package/__app__/src/pages/styles.css.mjs +23 -0
  75. package/__app__/src/routeTree.gen.mjs +105 -0
  76. package/__app__/src/router.mjs +1 -0
  77. package/__app__/src/routes/__root.mjs +65 -0
  78. package/__app__/src/routes/index.css.mjs +29 -0
  79. package/__app__/src/routes/index.mjs +32 -0
  80. package/__app__/src/routes/project._projectId/-components.mjs +100 -0
  81. package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
  82. package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
  83. package/__app__/src/routes/project._projectId/index.mjs +14 -0
  84. package/__app__/src/routes/project._projectId/route.mjs +93 -0
  85. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
  86. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
  87. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
  88. package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
  89. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
  90. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
  91. package/__app__/src/routes/projects.mjs +36 -0
  92. package/__app__/src/routes/single-index.mjs +1 -0
  93. package/__app__/src/routes/webcomponent._.mjs +94 -0
  94. package/__app__/src/style.css +18497 -1
  95. package/config/schema.json +146 -97
  96. package/dist/app/render-view-client.css +1 -1
  97. package/dist/app/render-view-client.js +394 -238
  98. package/dist/chunks/enableServer.mjs +1 -1
  99. package/dist/chunks/filenames.mjs +25 -17
  100. package/dist/chunks/generate-likec4.mjs +5 -0
  101. package/dist/chunks/index.d.mts +255 -194
  102. package/dist/chunks/index2.d.mts +8246 -3610
  103. package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
  104. package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
  105. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
  106. package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
  107. package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
  108. package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
  109. package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
  110. package/dist/chunks/libs/birpc.mjs +1 -1
  111. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
  112. package/dist/chunks/libs/chevrotain.mjs +88 -36
  113. package/dist/chunks/libs/clone.mjs +1 -0
  114. package/dist/chunks/libs/eventemitter3.mjs +1 -1
  115. package/dist/chunks/libs/fast-equals.mjs +1 -0
  116. package/dist/chunks/libs/fontkit.mjs +1 -0
  117. package/dist/chunks/libs/json5.mjs +4 -4
  118. package/dist/chunks/libs/langium.d.mts +6707 -6715
  119. package/dist/chunks/libs/langium.mjs +16 -24
  120. package/dist/chunks/libs/merge-error-cause.mjs +1 -1
  121. package/dist/chunks/libs/p-limit.mjs +1 -0
  122. package/dist/chunks/libs/p-queue.mjs +1 -1
  123. package/dist/chunks/libs/package-manager-detector.mjs +1 -1
  124. package/dist/chunks/libs/pako.mjs +1 -1
  125. package/dist/chunks/libs/pathe.mjs +1 -1
  126. package/dist/chunks/libs/pretty-ms.mjs +1 -1
  127. package/dist/chunks/libs/remeda.mjs +1 -1
  128. package/dist/chunks/libs/ufo.mjs +1 -1
  129. package/dist/chunks/libs/unstorage.mjs +1 -1
  130. package/dist/chunks/libs/which.mjs +1 -1
  131. package/dist/chunks/node.mjs +111 -77
  132. package/dist/chunks/rolldown-runtime.mjs +1 -1
  133. package/dist/chunks/sequence-view.mjs +1 -1
  134. package/dist/chunks/vite-plugin.mjs +185 -166
  135. package/dist/cli/index.mjs +254 -1306
  136. package/dist/config/index.d.mts +66 -5
  137. package/dist/config/index.mjs +1 -1
  138. package/dist/generators/likec4.d.mts +6530 -0
  139. package/dist/generators/likec4.mjs +1 -0
  140. package/dist/index.d.mts +2 -4
  141. package/dist/model/index.d.mts +0 -7
  142. package/dist/vite-plugin/index.d.mts +83 -58
  143. package/dist/vite-plugin/index.mjs +1 -1
  144. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +8 -0
  145. package/dist/vite-plugin/internal/index.d.mts +92 -17
  146. package/dist/vite-plugin/internal/index.mjs +225 -126
  147. package/generators/likec4/package.json +4 -0
  148. package/package.json +134 -122
  149. package/react/index.d.mts +7496 -26659
  150. package/react/index.mjs +533 -63936
  151. package/react/rolldown-runtime-CfRud99p.js +1 -0
  152. package/skills/likec4-dsl/SKILL.md +474 -0
  153. package/skills/likec4-dsl/evals/evals-public.json +207 -0
  154. package/skills/likec4-dsl/evals/grading-spec.json +603 -0
  155. package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
  156. package/skills/likec4-dsl/references/cli.md +168 -0
  157. package/skills/likec4-dsl/references/configuration.md +266 -0
  158. package/skills/likec4-dsl/references/deployment.md +160 -0
  159. package/skills/likec4-dsl/references/diffs.md +52 -0
  160. package/skills/likec4-dsl/references/dynamic-views.md +455 -0
  161. package/skills/likec4-dsl/references/examples.md +370 -0
  162. package/skills/likec4-dsl/references/identifier-validity.md +90 -0
  163. package/skills/likec4-dsl/references/include-predicates-wildcards.md +180 -0
  164. package/skills/likec4-dsl/references/model.md +182 -0
  165. package/skills/likec4-dsl/references/predicates.md +123 -0
  166. package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
  167. package/skills/likec4-dsl/references/specification.md +79 -0
  168. package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
  169. package/skills/likec4-dsl/references/troubleshooting.md +101 -0
  170. package/skills/likec4-dsl/references/views.md +329 -0
  171. package/vite-plugin-modules.d.ts +126 -51
  172. package/__app__/src/chunks/LikeC4Styles.mjs +0 -2306
  173. package/__app__/src/chunks/ProjectsOverview.mjs +0 -537
  174. package/__app__/src/chunks/es.mjs +0 -439
  175. package/__app__/src/chunks/libs/@floating-ui.mjs +0 -2532
  176. package/__app__/src/chunks/libs/@mantine.mjs +0 -13868
  177. package/__app__/src/chunks/libs/@xstate/react.mjs +0 -2015
  178. package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -5367
  179. package/__app__/src/chunks/libs/bezier-js.mjs +0 -1007
  180. package/__app__/src/chunks/libs/d3.mjs +0 -2817
  181. package/__app__/src/chunks/libs/framer.mjs +0 -5926
  182. package/__app__/src/chunks/libs/zod.mjs +0 -3176
  183. package/dist/chunks/libs/@chevrotain/types.d.mts +0 -108
  184. package/dist/chunks/libs/picomatch.mjs +0 -1
  185. package/dist/chunks/libs/zod.d.mts +0 -3840
  186. package/dist/chunks/libs/zod.mjs +0 -65
@@ -1,487 +1,173 @@
1
- import { i as o } from "./rolldown-runtime.mjs";
2
- import { i as s, u as c } from "./libs/@tanstack.mjs";
3
- import { ut as l } from "./libs/@mantine.mjs";
4
- import { I as u, k as d, o as f } from "./styled-system.mjs";
5
- import { n as p, t as m } from "./libs/fast-equals.mjs";
6
- import { b as h } from "./libs/framer.mjs";
7
- import { n as g } from "./libs/@xstate/react.mjs";
8
- import { createContext as _, createElement as v, forwardRef as y, use as b, useCallback as x, useContext as S, useEffect as C, useLayoutEffect as w, useMemo as T, useRef as E, useState as D, useSyncExternalStore as O } from "react";
9
- import { c as k } from "react/compiler-runtime";
10
- import { jsx as A } from "react/jsx-runtime";
11
- import { useLikeC4Projects as j } from "likec4:projects";
12
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/lazyDataLastImpl--3B10z3s.js
13
- function e$2(o, s, c) {
14
- let r = (c) => o(c, ...s);
15
- return c === void 0 ? r : Object.assign(r, {
16
- lazy: c,
17
- lazyArgs: s
18
- });
19
- }
20
- o(e$2, "e");
21
- //#endregion
22
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/purry.js
23
- function t$3(o, s, c) {
24
- let l = o.length - s.length;
25
- if (l === 0) return o(...s);
26
- if (l === 1) return e$2(o, s, c);
27
- throw Error("Wrong number of arguments");
28
- }
29
- o(t$3, "t");
30
- //#endregion
31
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/utilityEvaluators-IxVD3t2o.js
32
- var M = {
33
- done: !1,
34
- hasNext: !1
35
- }, N = /* @__PURE__ */ o((o) => ({
36
- hasNext: !0,
37
- next: o,
38
- done: !1
39
- }), "r");
40
- //#endregion
41
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/pipe.js
42
- function t$1(o, ...s) {
43
- let c = o, l = s.map((o) => "lazy" in o ? {
44
- lazyEvaluator: o.lazy(...o.lazyArgs),
45
- isSingle: o.lazy.single ?? !1,
46
- index: 0,
47
- items: []
48
- } : void 0), u = 0;
49
- for (; u < s.length;) {
50
- if (l[u] === void 0 || !a$1(c)) {
51
- let o = s[u];
52
- c = o(c), u += 1;
53
- continue;
54
- }
55
- let o = n$1(l, u), d = r$2(c, o), { isSingle: f } = o.at(-1);
56
- c = f ? d[0] : d, u += o.length;
57
- }
58
- return c;
59
- }
60
- o(t$1, "t");
61
- function n$1(o, s) {
62
- let c = [];
63
- for (let l = s; l < o.length; l++) {
64
- let s = o[l];
65
- if (s === void 0 || (c.push(s), s.isSingle)) break;
66
- }
67
- return c;
68
- }
69
- o(n$1, "n");
70
- function r$2(o, s) {
71
- let c = [];
72
- for (let l of o) if (i$1(l, c, s)) break;
73
- return c;
74
- }
75
- o(r$2, "r");
76
- function i$1(o, s, c) {
77
- if (c.length === 0) return s.push(o), !1;
78
- let l = o, u = M, d = !1;
79
- for (let [o, { items: f, lazyEvaluator: p }] of c.entries()) if (f.push(l), u = p(l, f.length - 1, f), u.done && (d = !0), u.hasNext) {
80
- if (u.hasMany ?? !1) {
81
- for (let l of u.next) if (i$1(l, s, c.slice(o + 1))) return !0;
82
- return d;
83
- }
84
- l = u.next;
85
- } else break;
86
- return u.hasNext && s.push(l), d;
87
- }
88
- o(i$1, "i");
89
- function a$1(o) {
90
- return typeof o == "string" || typeof o == "object" && !!o && Symbol.iterator in o;
91
- }
92
- o(a$1, "a");
93
- //#endregion
94
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/toSingle-DiQSixar.js
95
- var P = /* @__PURE__ */ o((o) => Object.assign(o, { single: !0 }), "e");
96
- //#endregion
97
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/find.js
98
- function r$1(...o) {
99
- return t$3(i, o, P(a));
100
- }
101
- o(r$1, "r");
102
- var i = (o, s) => o.find(s), a = (o) => (s, c, l) => o(s, c, l) ? {
103
- done: !0,
104
- hasNext: !0,
105
- next: s
106
- } : M, e = (o) => typeof o == "function";
107
- //#endregion
108
- //#region ../../node_modules/.pnpm/remeda@2.45.0/node_modules/remeda/dist/map.js
109
- function t(...o) {
110
- return t$3(n, o, r);
111
- }
112
- var n = (o, s) => o.map(s), r = (o) => (s, c, l) => ({
113
- done: !1,
114
- hasNext: !0,
115
- next: o(s, c, l)
116
- }), F = {
117
- outline: {
118
- xmlns: "http://www.w3.org/2000/svg",
119
- width: 24,
120
- height: 24,
121
- viewBox: "0 0 24 24",
122
- fill: "none",
123
- stroke: "currentColor",
124
- strokeWidth: 2,
125
- strokeLinecap: "round",
126
- strokeLinejoin: "round"
127
- },
128
- filled: {
129
- xmlns: "http://www.w3.org/2000/svg",
130
- width: 24,
131
- height: 24,
132
- viewBox: "0 0 24 24",
133
- fill: "currentColor",
134
- stroke: "none"
135
- }
136
- }, createReactComponent = (o, s, c, l) => {
137
- let u = y(({ color: c = "currentColor", size: u = 24, stroke: d = 2, title: f, className: p, children: m, ...h }, g) => v("svg", {
138
- ref: g,
139
- ...F[o],
140
- width: u,
141
- height: u,
142
- className: [
143
- "tabler-icon",
144
- `tabler-icon-${s}`,
145
- p
146
- ].join(" "),
147
- ...o === "filled" ? { fill: c } : {
148
- strokeWidth: d,
149
- stroke: c
150
- },
151
- ...h
152
- }, [
153
- f && v("title", { key: "svg-title" }, f),
154
- ...l.map(([o, s]) => v(o, s)),
155
- ...Array.isArray(m) ? m : [m]
156
- ]));
157
- return u.displayName = `${c}`, u;
158
- }, I = createReactComponent("outline", "sparkles", "Sparkles", [["path", {
159
- 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",
160
- key: "svg-0"
161
- }]]), L = createReactComponent("filled", "player-stop-filled", "PlayerStopFilled", [["path", {
162
- 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",
163
- key: "svg-0"
164
- }]]);
165
- //#endregion
166
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.2.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@react-hookz/web/dist/useSyncedRef/index.js
167
- function useSyncedRef(o) {
168
- let s = E(o);
169
- return s.current = o, T(() => Object.freeze({ get current() {
170
- return s.current;
171
- } }), []);
172
- }
173
- //#endregion
174
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.2.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@react-hookz/web/dist/util/const.js
175
- var R = /* @__PURE__ */ o(() => {}, "noop"), z = typeof globalThis < "u" && typeof navigator < "u" && typeof document < "u", basicDepsComparator = (o, s) => {
176
- if (o === s) return !0;
177
- if (o.length !== s.length) return !1;
178
- for (let [c, l] of o.entries()) if (l !== s[c]) return !1;
179
- return !0;
180
- };
181
- //#endregion
182
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.2.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@react-hookz/web/dist/useCustomCompareEffect/index.js
183
- function useCustomCompareEffect(o, s, c = basicDepsComparator, l = C, ...u) {
184
- let d = E(void 0);
185
- (d.current === void 0 || z && !c(d.current, s)) && (d.current = s), l(o, d.current, ...u);
186
- }
187
- //#endregion
188
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.2.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@react-hookz/web/dist/useFirstMountState/index.js
189
- function useFirstMountState() {
190
- let o = E(!0);
191
- return C(() => {
192
- o.current = !1;
193
- }, []), o.current;
194
- }
195
- //#endregion
196
- //#region ../../node_modules/.pnpm/@react-hookz+web@25.2.0_react-dom@19.2.8_react@19.2.8__react@19.2.8/node_modules/@react-hookz/web/dist/useIsomorphicLayoutEffect/index.js
197
- var B = z ? w : C, cancelTimeout = (o) => {
198
- o && clearTimeout(o);
199
- };
200
- function useTimeoutEffect(o, s) {
201
- let c = useSyncedRef(o), l = useSyncedRef(s), u = E(null), d = x(() => {
202
- cancelTimeout(u.current);
203
- }, []), f = x(() => {
204
- l.current !== void 0 && (d(), u.current = setTimeout(() => {
205
- c.current();
206
- }, l.current));
207
- }, []);
208
- return C(() => (f(), d), [s]), [d, f];
209
- }
210
- //#endregion
211
- //#region ../diagram/src/hooks/useUpdateEffect.ts
212
- var noop = () => {}, depsShallowEqual = (o, s) => {
213
- if (o === s) return !0;
214
- if (o.length !== s.length) return !1;
215
- for (let [c, l] of o.entries()) if (!(l === s[c] || p(l, s[c]))) return !1;
216
- return !0;
217
- };
218
- function useUpdateEffect(o, s, c, l) {
219
- useCustomCompareEffect(useFirstMountState() ? noop : o, s, c ?? depsShallowEqual, l);
220
- }
221
- //#endregion
222
- //#region ../../node_modules/.pnpm/nanostores@1.5.3/node_modules/nanostores/atom/index.js
223
- var V = [], H = 0, U = null, W = 4, G = globalThis.nanostoresGlobal ||= { epoch: 0 }, drainQueue = () => {
224
- let o, s;
225
- for (; H < V.length;) {
226
- s = H, H += W;
227
- try {
228
- V[s](V[s + 1].value, V[s + 2], V[s + 3]);
229
- } catch (s) {
230
- o = s;
231
- }
232
- }
233
- if (V.length = H = 0, o) throw o;
234
- }, atom = /* @__NO_SIDE_EFFECTS__ */ (o) => {
235
- let s = [], c = {
236
- eq: Object.is,
237
- get() {
238
- return c.lc || c.listen(() => {})(), c.value;
239
- },
240
- init: o,
241
- lc: 0,
242
- listen(o) {
243
- return c.lc = s.push(o), () => {
244
- for (let s = H; s < V.length;) V[s] === o ? V.splice(s, W) : s += W;
245
- let l = s.indexOf(o);
246
- ~l && (s.splice(l, 1), --c.lc || c.off());
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";
6
+ import { c } from "react/compiler-runtime";
7
+ import { useLikeC4Projects } from "likec4:projects";
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
10
+ /**
11
+ * Alias for `useLayoutEffect` in browser, but for `useEffect` at server side. Helps to avoid
12
+ * warning shown during SSR.
13
+ */
14
+ var useIsomorphicLayoutEffect = typeof globalThis !== "undefined" && typeof navigator !== "undefined" && typeof document !== "undefined" ? useLayoutEffect : useEffect;
15
+ // src/hooks.ts
16
+ function useTransparentBackground(t0) {
17
+ const $ = c(3);
18
+ const enabled = t0 === void 0 ? true : t0;
19
+ let t1;
20
+ let t2;
21
+ if ($[0] !== enabled) {
22
+ t1 = () => {
23
+ const htmlEl = document.body.parentElement;
24
+ if (!htmlEl || enabled !== true) return;
25
+ htmlEl.classList.add("transparent-bg");
26
+ return () => {
27
+ htmlEl.classList.remove("transparent-bg");
247
28
  };
248
- },
249
- notify(o, l) {
250
- G.epoch++;
251
- let u = !V.length && !0;
252
- for (let u of s) U?.has(u) || (U?.add(u), V.push(u, c, o, l));
253
- u && drainQueue();
254
- },
255
- off() {},
256
- set(o) {
257
- let s = c.value;
258
- c.eq(s, o) || (c.value = o, c.notify(s));
259
- },
260
- subscribe(o) {
261
- let s = c.listen(o);
262
- return o(c.value), s;
263
- },
264
- value: o
265
- };
266
- return c;
267
- }, K = 5, q = 6, J = 10, on = (o, s, c, l) => (o.events = o.events || {}, o.events[c + J] || (o.events[c + J] = l((s) => {
268
- o.events[c].reduceRight((o, s) => (s(o), o), {
269
- shared: {},
270
- ...s
271
- });
272
- })), o.events[c] = o.events[c] || [], o.events[c].push(s), () => {
273
- let l = o.events[c], u = l.indexOf(s);
274
- ~u && (l.splice(u, 1), l.length || (o.events[c + J](), delete o.events[c + J]));
275
- }), Y = 1e3, onMount = (o, s) => {
276
- let listener = (c) => {
277
- let l = s(c);
278
- l && o.events[q].push(l);
279
- };
280
- return on(o, listener, K, (s) => {
281
- let c = o.listen;
282
- o.listen = (...l) => (!o.lc && !o.active && (o.active = !0, s()), c(...l));
283
- let l = o.off;
284
- return o.events[q] = [], o.off = () => {
285
- l(), setTimeout(() => {
286
- if (o.active && !o.lc) {
287
- o.active = !1;
288
- for (let s of o.events[q]) s();
289
- o.events[q] = [];
290
- }
291
- }, Y);
292
- }, () => {
293
- o.listen = c, o.off = l;
294
29
  };
295
- });
296
- };
297
- //#endregion
298
- //#region ../../node_modules/.pnpm/nanostores@1.5.3/node_modules/nanostores/deep-map/path.js
299
- function getPath(o, s) {
300
- let c = getAllKeysFromPath(s), l = o;
301
- for (let o of c) {
302
- if (l == null) return;
303
- l = l[o];
304
- }
305
- return l;
306
- }
307
- var X = /(.*)\[(\d+)\]/;
308
- function getAllKeysFromPath(o) {
309
- return o.split(".").flatMap((o) => getKeyAndIndicesFromKey(o));
310
- }
311
- function getKeyAndIndicesFromKey(o) {
312
- if (X.test(o)) {
313
- let [, s, c] = o.match(X);
314
- return [...getKeyAndIndicesFromKey(s), c];
30
+ t2 = [enabled];
31
+ $[0] = enabled;
32
+ $[1] = t1;
33
+ $[2] = t2;
34
+ } else {
35
+ t1 = $[1];
36
+ t2 = $[2];
315
37
  }
316
- return [o];
317
- }
318
- //#endregion
319
- //#region ../../node_modules/.pnpm/nanostores@1.5.3/node_modules/nanostores/listen-keys/index.js
320
- function listenKeys(o, s, c) {
321
- let l = new Set(s);
322
- return o.listen((o, u, d) => {
323
- (d === void 0 ? s.some((s) => u === void 0 || o[s] !== u[s] || getPath(o, s) !== getPath(u, s)) : l.has(d) || l.has(d.split(/\.|\[/)[0])) && c(o, u, d);
324
- });
325
- }
326
- //#endregion
327
- //#region ../../node_modules/.pnpm/@nanostores+react@1.1.0_nanostores@1.5.3_react@19.2.8/node_modules/@nanostores/react/index.js
328
- var emit = (o, s) => (c) => {
329
- o.current !== c && (o.current = c, s());
330
- };
331
- function useStore(o, { keys: s, deps: c = [o, s], ssr: l } = {}) {
332
- let u = E();
333
- u.current = o.get();
334
- let d = x((c) => (emit(u, c)(o.value), s?.length > 0 ? listenKeys(o, s, emit(u, c)) : o.listen(emit(u, c))), c), get = () => u.current, f = get;
335
- return l && "init" in o && (f = l === "initial" ? () => o.init : l), O(d, get, f);
336
- }
337
- //#endregion
338
- //#region ../diagram/src/hooks/safeContext.tsx
339
- var Z = _(null);
340
- Z.displayName = "DiagramApiSafeContext";
341
- var ee = Z.Provider;
342
- function useDiagram() {
343
- let o = b(Z);
344
- if (o === null) throw Error("DiagramApi is not provided");
345
- return o;
346
- }
347
- function createSafeContextForActor(o) {
348
- let s = _(null);
349
- function selectSnapshot(o, s) {
350
- return [o, s ?? p];
351
- }
352
- function selectContext(o, s) {
353
- return [(s) => o(s.context), s ?? p];
354
- }
355
- function useActorRef() {
356
- let c = S(s);
357
- if (c === null) throw Error(`${o}SafeContext is not provided `);
358
- return c;
359
- }
360
- function useActorSelector(o, s) {
361
- let c, l;
362
- return s === void 0 ? Array.isArray(o) ? [c, l] = o : (c = o, l = p) : [c, l] = [o, s], l ??= p, h(e(c), "selector must be a function"), g(useActorRef(), c, l);
363
- }
364
- return {
365
- ContextProvider: s.Provider,
366
- selectSnapshot,
367
- selectContext,
368
- useActorSelector,
369
- useActorRef
370
- };
371
- }
372
- var { ContextProvider: te, selectSnapshot: ne, selectContext: re, useActorSelector: ie, useActorRef: ae } = createSafeContextForActor("DiagramActor"), Q = y((o, s) => {
373
- let c = k(34), p, m, h, g, _, v, y, b, x;
374
- c[0] === o ? (p = c[1], m = c[2], h = c[3], g = c[4], _ = c[5], v = c[6], y = c[7], b = c[8], x = c[9]) : ({value: x, textScale: _, uselikec4palette: v, hideIfEmpty: y, emptyText: b, className: p, style: g, fontSize: m, ...h} = o, c[0] = o, c[1] = p, c[2] = m, c[3] = h, c[4] = g, c[5] = _, c[6] = v, c[7] = y, c[8] = b, c[9] = x);
375
- let S = _ === void 0 ? 1 : _, C = v !== void 0 && v, w = y !== void 0 && y, T = b === void 0 ? "no content" : b;
376
- if (x.isEmpty && w) return null;
377
- let E;
378
- c[10] !== T || c[11] !== x.html || c[12] !== x.isMarkdown || c[13] !== x.nonEmpty || c[14] !== x.text ? (E = x.nonEmpty ? x.isMarkdown ? { dangerouslySetInnerHTML: { __html: x.html } } : { children: /* @__PURE__ */ A("p", { children: x.text }) } : { children: /* @__PURE__ */ A(l, {
379
- component: "span",
380
- fz: "xs",
381
- c: "dimmed",
382
- style: { userSelect: "none" },
383
- children: T
384
- }) }, c[10] = T, c[11] = x.html, c[12] = x.isMarkdown, c[13] = x.nonEmpty, c[14] = x.text, c[15] = E) : E = c[15];
385
- let D = E, O;
386
- c[16] !== p || c[17] !== C || c[18] !== x.isMarkdown ? (O = u(f({
387
- uselikec4palette: C,
388
- value: x.isMarkdown ? "markdown" : "plaintext"
389
- }), p), c[16] = p, c[17] = C, c[18] = x.isMarkdown, c[19] = O) : O = c[19];
390
- let j;
391
- c[20] === m ? j = c[21] : (j = m && { "--text-fz": `var(--font-sizes-${m}, var(--font-sizes-md))` }, c[20] = m, c[21] = j);
392
- let M;
393
- c[22] === S ? M = c[23] : (M = S !== 1 && { "--mantine-scale": S }, c[22] = S, c[23] = M);
394
- let N;
395
- c[24] !== g || c[25] !== j || c[26] !== M ? (N = {
396
- ...g,
397
- ...j,
398
- ...M
399
- }, c[24] = g, c[25] = j, c[26] = M, c[27] = N) : N = c[27];
400
- let P;
401
- return c[28] !== D || c[29] !== h || c[30] !== s || c[31] !== O || c[32] !== N ? (P = /* @__PURE__ */ A(d, {
402
- ...h,
403
- ref: s,
404
- className: O,
405
- style: N,
406
- ...D
407
- }), c[28] = D, c[29] = h, c[30] = s, c[31] = O, c[32] = N, c[33] = P) : P = c[33], P;
408
- });
409
- Q.displayName = "Markdown";
410
- //#endregion
411
- //#region src/context/safeCtx.ts
412
- var $ = _(null), oe = $.Provider, useLikeC4ModelAtom = () => {
413
- let o = S($);
414
- if (o === null) throw Error("LikeC4ModelAtom is not provided");
415
- return o;
416
- };
417
- //#endregion
418
- //#region src/hooks.ts
419
- function useTransparentBackground(o) {
420
- let s = k(3), c = o === void 0 || o, t1, l;
421
- s[0] === c ? (t1 = s[1], l = s[2]) : (t1 = () => {
422
- let o = document.body.parentElement;
423
- if (o && c === !0) return o.classList.add("transparent-bg"), () => {
424
- o.classList.remove("transparent-bg");
425
- };
426
- }, l = [c], s[0] = c, s[1] = t1, s[2] = l), B(t1, l);
38
+ useIsomorphicLayoutEffect(t1, t2);
427
39
  }
428
40
  function useLikeC4Views() {
429
- let o = k(4), s = useLikeC4ModelAtom(), c;
430
- o[0] === Symbol.for("react.memo_cache_sentinel") ? (c = [], o[0] = c) : c = o[0];
431
- let [l, u] = D(c), t1, d;
432
- return o[1] === s ? (t1 = o[2], d = o[3]) : (t1 = () => s.subscribe((o) => {
433
- u((s) => {
434
- let c = [...o.views()].map((o) => {
435
- let c = o.$layouted, l = s.find((s) => s.id === o.id);
436
- return l && m(c, l) ? l : c;
437
- });
438
- return p(s, c) ? s : c;
41
+ const $ = c(4);
42
+ const $likec4model = useLikeC4ModelAtom();
43
+ let t0;
44
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
45
+ t0 = [];
46
+ $[0] = t0;
47
+ } else t0 = $[0];
48
+ const [views, setViews] = useState(t0);
49
+ let t1;
50
+ let t2;
51
+ if ($[1] !== $likec4model) {
52
+ t1 = () => $likec4model.subscribe((next) => {
53
+ setViews([...next.views()].map(_temp));
439
54
  });
440
- }), d = [s], o[1] = s, o[2] = t1, o[3] = d), C(t1, d), l;
55
+ t2 = [$likec4model];
56
+ $[1] = $likec4model;
57
+ $[2] = t1;
58
+ $[3] = t2;
59
+ } else {
60
+ t1 = $[2];
61
+ t2 = $[3];
62
+ }
63
+ useEffect(t1, t2);
64
+ return views;
65
+ }
66
+ function _temp(v) {
67
+ return v.$layouted;
441
68
  }
442
69
  function useCurrentViewId() {
443
- let o = k(1), s;
444
- return o[0] === Symbol.for("react.memo_cache_sentinel") ? (s = {
445
- select: _temp,
446
- strict: !1
447
- }, o[0] = s) : s = o[0], c(s) ?? "index";
70
+ const $ = c(1);
71
+ let t0;
72
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
73
+ t0 = {
74
+ select: _temp2,
75
+ strict: false
76
+ };
77
+ $[0] = t0;
78
+ } else t0 = $[0];
79
+ return useParams(t0) ?? "index";
448
80
  }
449
- function _temp(o) {
450
- return o.viewId;
81
+ function _temp2(params) {
82
+ return params.viewId;
451
83
  }
84
+ /**
85
+ * Returns the current view and a function to set the layout type.
86
+ */
452
87
  function useCurrentView() {
453
- let o = k(13), s = useCurrentViewId(), c = useLikeC4ModelAtom(), [l, u] = D("manual"), t0;
454
- o[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => {
455
- u("manual");
456
- }, o[0] = t0) : t0 = o[0];
457
- let d;
458
- o[1] === s ? d = o[2] : (d = [s], o[1] = s, o[2] = d), useUpdateEffect(t0, d);
88
+ const $ = c(13);
89
+ const viewId = useCurrentViewId();
90
+ const $likec4model = useLikeC4ModelAtom();
91
+ const [layoutType, setLayoutType] = useState("manual");
92
+ let t0;
93
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
94
+ t0 = () => {
95
+ setLayoutType("manual");
96
+ };
97
+ $[0] = t0;
98
+ } else t0 = $[0];
99
+ let t1;
100
+ if ($[1] !== viewId) {
101
+ t1 = [viewId];
102
+ $[1] = viewId;
103
+ $[2] = t1;
104
+ } else t1 = $[2];
105
+ useUpdateEffect(t0, t1);
459
106
  let t2;
460
- o[3] !== c || o[4] !== s ? (t2 = () => c.get().findView(s)?.$layouted ?? null, o[3] = c, o[4] = s, o[5] = t2) : t2 = o[5];
461
- let [f, p] = D(t2), t3, h;
462
- o[6] !== c || o[7] !== l || o[8] !== s ? (t3 = () => c.subscribe((o, c) => {
463
- p((c) => {
464
- let u = o.findView(s);
465
- if (!u) return c?.id === s ? c : null;
466
- let d = l === "auto" ? u.$view : u.$layouted;
467
- return m(c, d) ? c : d;
107
+ if ($[3] !== $likec4model || $[4] !== viewId) {
108
+ t2 = () => $likec4model.get().findView(viewId)?.$layouted ?? null;
109
+ $[3] = $likec4model;
110
+ $[4] = viewId;
111
+ $[5] = t2;
112
+ } else t2 = $[5];
113
+ const [view, setView] = useState(t2);
114
+ let t3;
115
+ let t4;
116
+ if ($[6] !== $likec4model || $[7] !== layoutType || $[8] !== viewId) {
117
+ t3 = () => $likec4model.subscribe((next) => {
118
+ setView((current) => {
119
+ const vm = next.findView(viewId);
120
+ if (!vm) return current?.id === viewId ? current : null;
121
+ const nextView = layoutType === "auto" ? vm.$view : vm.$layouted;
122
+ if (current && current.id === nextView.id && current._layout === nextView._layout && current.hash === nextView.hash && deepEqual(current, nextView)) return current;
123
+ return nextView;
124
+ });
468
125
  });
469
- }), h = [
470
- c,
471
- s,
472
- l
473
- ], o[6] = c, o[7] = l, o[8] = s, o[9] = t3, o[10] = h) : (t3 = o[9], h = o[10]), C(t3, h);
474
- let g;
475
- return o[11] === f ? g = o[12] : (g = [f, u], o[11] = f, o[12] = g), g;
126
+ t4 = [
127
+ $likec4model,
128
+ viewId,
129
+ layoutType
130
+ ];
131
+ $[6] = $likec4model;
132
+ $[7] = layoutType;
133
+ $[8] = viewId;
134
+ $[9] = t3;
135
+ $[10] = t4;
136
+ } else {
137
+ t3 = $[9];
138
+ t4 = $[10];
139
+ }
140
+ useEffect(t3, t4);
141
+ let t5;
142
+ if ($[11] !== view) {
143
+ t5 = [view, setLayoutType];
144
+ $[11] = view;
145
+ $[12] = t5;
146
+ } else t5 = $[12];
147
+ return t5;
476
148
  }
477
149
  function useCurrentProject() {
478
- let o = k(4), c = j(), l;
479
- o[0] === Symbol.for("react.memo_cache_sentinel") ? (l = { select: selectProjectIdFromContext }, o[0] = l) : l = o[0];
480
- let u = s(l), d;
481
- return o[1] !== u || o[2] !== c ? (d = u && c.find((o) => o.id === u) || c[0], o[1] = u, o[2] = c, o[3] = d) : d = o[3], d;
482
- }
483
- function selectProjectIdFromContext(o) {
484
- return o.find((o) => o.routeId === "/project/$projectId")?.params?.projectId ?? o.at(-1)?.context.projectId ?? void 0;
485
- }
486
- //#endregion
487
- export { createReactComponent as A, useTimeoutEffect as C, useSyncedRef as D, R as E, t$1 as F, N as I, M as L, e as M, r$1 as N, L as O, P, t$3 as R, useUpdateEffect as S, z as T, useStore as _, useTransparentBackground as a, G as b, Q as c, createSafeContextForActor as d, re as f, ie as g, ae as h, useLikeC4Views as i, t as j, I as k, te as l, useDiagram as m, useCurrentView as n, oe as o, ne as p, useCurrentViewId as r, useLikeC4ModelAtom as s, useCurrentProject as t, ee as u, onMount as v, useFirstMountState as w, depsShallowEqual as x, atom as y, e$2 as z };
150
+ const $ = c(4);
151
+ const projects = useLikeC4Projects();
152
+ let t0;
153
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
154
+ t0 = {
155
+ select: selectProjectIdFromContext,
156
+ structuralSharing: false
157
+ };
158
+ $[0] = t0;
159
+ } else t0 = $[0];
160
+ const projectId = useMatches(t0);
161
+ let t1;
162
+ if ($[1] !== projectId || $[2] !== projects) {
163
+ t1 = projectId && projects.find((p) => p.id === projectId) || projects[0];
164
+ $[1] = projectId;
165
+ $[2] = projects;
166
+ $[3] = t1;
167
+ } else t1 = $[3];
168
+ return t1;
169
+ }
170
+ function selectProjectIdFromContext(matches) {
171
+ return matches.find((m) => m.routeId === "/project/$projectId")?.params?.projectId ?? matches.at(-1)?.context.projectId ?? void 0;
172
+ }
173
+ export { useTransparentBackground as a, useLikeC4Views as i, useCurrentView as n, useCurrentViewId as r, useCurrentProject as t };