likec4 1.25.0 → 1.26.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.
@@ -0,0 +1,88 @@
1
+ declare module 'likec4:projects' {
2
+ export const isSingleProject: boolean
3
+ export const projects: readonly [string, ...string[]]
4
+ }
5
+
6
+ declare module 'likec4:icons' {
7
+ import type { ReactNode } from 'react'
8
+ type ElementIconRendererProps = {
9
+ node: {
10
+ id: string
11
+ title: string
12
+ icon?: string | null | undefined
13
+ }
14
+ }
15
+
16
+ export type ElementIconRenderer = (props: ElementIconRendererProps) => ReactNode
17
+
18
+ export const ProjectIcons: (projectId: string) => ElementIconRenderer
19
+ }
20
+
21
+ declare module 'likec4:model' {
22
+ import type { DiagramView, LayoutedLikeC4ModelData, LikeC4Model } from 'likec4/model'
23
+ import type { nano } from 'likec4/react'
24
+
25
+ export type Atom<T> = nano.Atom<T>
26
+
27
+ export type { DiagramView, LayoutedLikeC4ModelData, LikeC4Model }
28
+
29
+ export function loadModel(projectId: string): Promise<{
30
+ $likec4data: Atom<LayoutedLikeC4ModelData>
31
+ $likec4model: Atom<LikeC4Model.Layouted>
32
+ useLikeC4Model: () => LikeC4Model.Layouted
33
+ useLikeC4Views: () => ReadonlyArray<DiagramView>
34
+ useLikeC4View: (viewId: string) => DiagramView | null
35
+ }>
36
+ }
37
+
38
+ declare module 'likec4:single-project' {
39
+ import type { ElementIconRenderer } from 'likec4:icons'
40
+ import type { Atom, DiagramView, LayoutedLikeC4ModelData, LikeC4Model } from 'likec4:model'
41
+
42
+ export const $likec4data: Atom<LayoutedLikeC4ModelData>
43
+ export const $likec4model: Atom<LikeC4Model.Layouted>
44
+ export function useLikeC4Model(): LikeC4Model.Layouted
45
+ export function useLikeC4Views(): ReadonlyArray<DiagramView>
46
+ export function useLikeC4View(viewId: string): DiagramView | null
47
+
48
+ export const IconRenderer: ElementIconRenderer
49
+
50
+ export const projectId: string
51
+ }
52
+
53
+ declare module 'likec4:react' {
54
+ import type { Aux, DiagramView, LikeC4Model } from 'likec4/model'
55
+ import type { LikeC4ViewProps, ReactLikeC4Props } from 'likec4/react'
56
+ import type { JSX, PropsWithChildren } from 'react'
57
+
58
+ // This will be used later for augmenting the types
59
+ interface Types extends Aux<string, string, string, DiagramView> {
60
+ }
61
+
62
+ export type LikeC4ViewId = Types['View']
63
+
64
+ export function useLikeC4Model(): LikeC4Model<Types>
65
+ export function useLikeC4Views(): ReadonlyArray<DiagramView<LikeC4ViewId>>
66
+ export function useLikeC4View(viewId: LikeC4ViewId): DiagramView | null
67
+
68
+ export function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element
69
+ export function LikeC4View({ viewId, ...props }: LikeC4ViewProps<LikeC4ViewId>): JSX.Element
70
+ export function ReactLikeC4({ viewId, ...props }: ReactLikeC4Props<LikeC4ViewId>): JSX.Element
71
+ }
72
+
73
+ declare module 'likec4:dot' {
74
+ export function loadDotSources(projectId: string): Promise<{
75
+ dotSource(viewId: string): string
76
+ svgSource(viewId: string): string
77
+ }>
78
+ }
79
+ declare module 'likec4:d2' {
80
+ export function loadD2Sources(projectId: string): Promise<{
81
+ d2Source(viewId: string): string
82
+ }>
83
+ }
84
+ declare module 'likec4:mmd' {
85
+ export function loadMmdSources(projectId: string): Promise<{
86
+ mmdSource(viewId: string): string
87
+ }>
88
+ }
@@ -1,310 +0,0 @@
1
- import { jsx as t, jsxs as u, Fragment as z } from "react/jsx-runtime";
2
- import { useOverviewGraph as L } from "virtual:likec4/overview-graph";
3
- import { nonexhaustive as R } from "@likec4/core";
4
- import { u as V } from "./tanstack-router-MjA2OK6n.js";
5
- import { B as G, H as v, P as g, u as $, a as K, i as U, b as A, c as X } from "./likec4-DRDnYFvy.js";
6
- import { memo as k, useRef as Y, useMemo as B } from "react";
7
- import { c as b, I as q, n as S, u as j, i as J } from "./main-iM8EmCL0.js";
8
- import { P as O, c as I, G as C, T as F, a as y, C as Q, b as W, d as ee, I as te, B as P, u as se } from "./mantine-B7q9iXnB.js";
9
- import { usePreviewUrl as ae } from "virtual:likec4/previews";
10
- /**
11
- * @license @tabler/icons-react v3.29.0 - MIT
12
- *
13
- * This source code is licensed under the MIT license.
14
- * See the LICENSE file in the root directory of this source tree.
15
- */
16
- var oe = b("outline", "loader", "IconLoader", [["path", { d: "M12 6l0 -3", key: "svg-0" }], ["path", { d: "M16.25 7.75l2.15 -2.15", key: "svg-1" }], ["path", { d: "M18 12l3 0", key: "svg-2" }], ["path", { d: "M16.25 16.25l2.15 2.15", key: "svg-3" }], ["path", { d: "M12 18l0 3", key: "svg-4" }], ["path", { d: "M7.75 16.25l-2.15 2.15", key: "svg-5" }], ["path", { d: "M6 12l-3 0", key: "svg-6" }], ["path", { d: "M7.75 7.75l-2.15 -2.15", key: "svg-7" }]]);
17
- /**
18
- * @license @tabler/icons-react v3.29.0 - MIT
19
- *
20
- * This source code is licensed under the MIT license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */
23
- var re = b("filled", "file-filled", "IconFileFilled", [["path", { d: "M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h5z", key: "svg-0" }], ["path", { d: "M19 7h-4l-.001 -4.001z", key: "svg-1" }]]), ie = "mxt2a80";
24
- function ne(r) {
25
- return r.reduce((e, [s, a], o) => e + `${o === 0 ? "M" : " L"} ${s},${a}`, "");
26
- }
27
- function de({
28
- id: r,
29
- data: e,
30
- ...s
31
- }) {
32
- if (!e)
33
- return null;
34
- const a = ne(e.points);
35
- return /* @__PURE__ */ t(
36
- G,
37
- {
38
- id: r,
39
- path: a,
40
- ...s
41
- }
42
- );
43
- }
44
- var h = "_1n8mzjc0", _ = "_1n8mzjc1", D = "_1n8mzjc2", M = "_1n8mzjc3", le = "_1n8mzjc4", ce = "_1n8mzjc5", me = "_1n8mzjc6", ue = "_1n8mzjc7", pe = "_1n8mzjc8";
45
- const fe = /* @__PURE__ */ k(function({
46
- data: e,
47
- parentId: s,
48
- id: a
49
- }) {
50
- const o = S(s);
51
- return /* @__PURE__ */ u(z, { children: [
52
- /* @__PURE__ */ t(v, { type: "target", position: g.Top, className: h }),
53
- /* @__PURE__ */ t(
54
- O,
55
- {
56
- p: "sm",
57
- pt: "xs",
58
- radius: "md",
59
- withBorder: !0,
60
- shadow: o ? "lg" : "xs",
61
- className: I(
62
- le,
63
- o ? _ : D,
64
- e.dimmed && M
65
- ),
66
- children: /* @__PURE__ */ u(C, { gap: 8, children: [
67
- /* @__PURE__ */ t(F, { size: 24, variant: "transparent", color: "dark.4", children: /* @__PURE__ */ t(q, { size: "100%" }) }),
68
- /* @__PURE__ */ t(y, { size: "lg", fw: 500, children: e.label })
69
- ] })
70
- }
71
- ),
72
- /* @__PURE__ */ t(v, { type: "source", position: g.Bottom, className: h })
73
- ] });
74
- }), ve = /* @__PURE__ */ k(function({
75
- data: e,
76
- parentId: s,
77
- id: a
78
- }) {
79
- const o = S(s);
80
- return /* @__PURE__ */ u(z, { children: [
81
- /* @__PURE__ */ t(v, { type: "target", position: g.Top, className: h }),
82
- /* @__PURE__ */ t(
83
- O,
84
- {
85
- p: "sm",
86
- pt: "xs",
87
- radius: "md",
88
- withBorder: !0,
89
- shadow: o ? "lg" : "xs",
90
- className: I(
91
- ce,
92
- o ? _ : D,
93
- e.dimmed && M
94
- ),
95
- children: /* @__PURE__ */ u(C, { gap: 8, children: [
96
- /* @__PURE__ */ t(F, { size: 24, variant: "transparent", color: "dark.3", children: /* @__PURE__ */ t(re, { size: "100%" }) }),
97
- /* @__PURE__ */ t(y, { size: "lg", fw: 500, children: e.label })
98
- ] })
99
- }
100
- ),
101
- /* @__PURE__ */ t(v, { type: "source", position: g.Bottom, className: h })
102
- ] });
103
- }), ge = /* @__PURE__ */ k(function({
104
- data: e,
105
- height: s = 320
106
- }) {
107
- const o = ae(e.viewId);
108
- return /* @__PURE__ */ u(z, { children: [
109
- /* @__PURE__ */ t(v, { type: "target", position: g.Top, className: h }),
110
- /* @__PURE__ */ u(
111
- Q,
112
- {
113
- className: I(
114
- me,
115
- e.dimmed && M
116
- ),
117
- withBorder: !0,
118
- shadow: "xs",
119
- padding: 0,
120
- children: [
121
- /* @__PURE__ */ t(W, { className: ue, children: o ? /* @__PURE__ */ t(
122
- te,
123
- {
124
- src: o,
125
- fit: "contain",
126
- h: s - 60
127
- }
128
- ) : /* @__PURE__ */ t(ee, { h: s - 60, children: /* @__PURE__ */ u(C, { children: [
129
- /* @__PURE__ */ t(F, { size: 60, variant: "transparent", color: "dark", children: /* @__PURE__ */ t(oe, { stroke: 1.5, size: "100%" }) }),
130
- /* @__PURE__ */ t(y, { size: "xl", fw: 500, c: "dimmed", children: "Preview not available" })
131
- ] }) }) }),
132
- /* @__PURE__ */ t(P, { className: pe, h: 60, p: "sm", pl: "md", children: /* @__PURE__ */ t(y, { component: "div", size: "lg", fw: 500, children: e.label }) })
133
- ]
134
- }
135
- ),
136
- /* @__PURE__ */ t(v, { type: "source", position: g.Bottom, className: h })
137
- ] });
138
- }), he = {
139
- folder: fe,
140
- file: ve,
141
- view: ge
142
- }, we = {
143
- link: de
144
- }, ye = (r) => ({
145
- nodes: r.nodes.map(({ id: e, parentId: s, position: a, width: o, height: c, ...l }) => {
146
- const i = s ? r.nodes.find((N) => N.id === s) : null, w = {
147
- ...a,
148
- width: o,
149
- height: c
150
- };
151
- i && (a = {
152
- x: a.x - i.position.x,
153
- y: a.y - i.position.y
154
- });
155
- const p = i ? { parentId: i.id } : {};
156
- switch (l.type) {
157
- case "file":
158
- case "folder":
159
- return {
160
- id: e,
161
- type: l.type,
162
- data: {
163
- dimmed: !1,
164
- label: l.label,
165
- path: l.path,
166
- rect: w
167
- },
168
- deletable: !1,
169
- position: a,
170
- width: o,
171
- height: c,
172
- zIndex: 1,
173
- ...p
174
- };
175
- case "view":
176
- return {
177
- id: e,
178
- type: "view",
179
- data: {
180
- dimmed: !1,
181
- label: l.label,
182
- viewId: l.viewId,
183
- rect: w
184
- },
185
- selectable: !1,
186
- deletable: !1,
187
- position: a,
188
- width: o,
189
- height: c,
190
- zIndex: 3,
191
- ...p
192
- };
193
- default:
194
- R(l);
195
- }
196
- }),
197
- edges: r.edges.map((e) => ({
198
- id: e.id,
199
- source: e.source,
200
- target: e.target,
201
- type: "link",
202
- zIndex: 2,
203
- hidden: !0,
204
- data: {
205
- points: e.points
206
- }
207
- }))
208
- });
209
- function Ne({
210
- graph: r,
211
- fitViewPadding: e = 0.1,
212
- zoomable: s = !0,
213
- pannable: a = !0
214
- }) {
215
- const o = V(), c = Y(void 0), { colorScheme: l } = se(), i = B(() => ye(r), [r]), [w, p, N] = $(i.nodes), [E, H, Z] = K(i.edges);
216
- j(() => {
217
- p(
218
- (n) => i.nodes.map((d) => {
219
- const f = n.find((m) => m.id === d.id);
220
- return f ? { ...J(f, ["selected", "hidden"]), ...d } : d;
221
- })
222
- ), H(i.edges);
223
- }, [i.nodes, i.edges]);
224
- const x = w.find((n) => n.selected);
225
- return j(() => {
226
- const n = c.current;
227
- n && (x ? n.fitView({
228
- maxZoom: 1,
229
- padding: e,
230
- nodes: [x],
231
- duration: 450
232
- }) : n.fitView({
233
- maxZoom: 1,
234
- padding: e,
235
- duration: 800
236
- }));
237
- }, [x?.id ?? null]), /* @__PURE__ */ t(
238
- U,
239
- {
240
- colorMode: l === "auto" ? "system" : l,
241
- className: ie,
242
- nodeTypes: he,
243
- edgeTypes: we,
244
- nodes: w,
245
- onNodesChange: N,
246
- edges: E,
247
- onEdgesChange: Z,
248
- fitView: !0,
249
- fitViewOptions: B(() => ({
250
- minZoom: 0.05,
251
- maxZoom: 1,
252
- padding: e,
253
- includeHiddenNodes: !0
254
- }), [e]),
255
- nodesDraggable: !1,
256
- nodesConnectable: !1,
257
- nodesFocusable: !0,
258
- edgesReconnectable: !1,
259
- edgesFocusable: !1,
260
- multiSelectionKeyCode: null,
261
- zoomOnPinch: s,
262
- zoomOnScroll: !a && s,
263
- zoomOnDoubleClick: !1,
264
- ...!s && {
265
- zoomActivationKeyCode: null
266
- },
267
- maxZoom: s ? 2 : 1,
268
- minZoom: s ? 0.01 : 1,
269
- preventScrolling: s || a,
270
- noDragClassName: "nodrag",
271
- noPanClassName: "nopan",
272
- panOnScroll: a,
273
- panOnDrag: a,
274
- ...!a && {
275
- selectionKeyCode: null
276
- },
277
- onInit: (n) => c.current = n,
278
- onNodeClick: (n, d) => {
279
- if (d.type === "view") {
280
- n.stopPropagation(), p((f) => f.map(({ data: m, ...T }) => ({ ...T, data: { ...m, dimmed: T.id !== d.id } }))), c.current?.fitView({
281
- maxZoom: 10,
282
- padding: 0,
283
- nodes: [d],
284
- duration: 1200
285
- }), setTimeout(() => {
286
- c.current?.updateNodeData(d.id, { dimmed: !0 });
287
- }, 400), setTimeout(() => {
288
- o.navigate({
289
- to: "/view/$viewId/",
290
- params: {
291
- viewId: d.data.viewId
292
- },
293
- search: !0
294
- });
295
- }, 800);
296
- return;
297
- }
298
- d.selected && (n.stopPropagation(), p((f) => f.map((m) => m.id === d.id ? { ...m, selected: !1 } : m)));
299
- },
300
- children: /* @__PURE__ */ t(A, { variant: X.Dots, size: 4, gap: 50 })
301
- }
302
- );
303
- }
304
- function je() {
305
- const r = L();
306
- return /* @__PURE__ */ t(P, { pos: "fixed", inset: 0, children: /* @__PURE__ */ t(Ne, { graph: r }) });
307
- }
308
- export {
309
- je as default
310
- };
@@ -1,9 +0,0 @@
1
- import { d2Source as e } from "virtual:likec4/d2-sources";
2
- import { dotSource as c, svgSource as t } from "virtual:likec4/dot-sources";
3
- import { mmdSource as S } from "virtual:likec4/mmd-sources";
4
- export {
5
- e as d2Source,
6
- c as dotSource,
7
- S as mmdSource,
8
- t as svgSource
9
- };