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,22 @@
|
|
|
1
|
+
import "./rolldown-runtime.mjs";
|
|
2
|
+
import { t as listenKeys } from "./libs/nanostores.mjs";
|
|
3
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
4
|
+
// ../../node_modules/.pnpm/@nanostores+react@2.0.1_nanostores@1.5.5_react@19.3.1/node_modules/@nanostores/react/index.js
|
|
5
|
+
var emit = (snapshotRef, onChange) => (value) => {
|
|
6
|
+
if (snapshotRef.current === value) return;
|
|
7
|
+
snapshotRef.current = value;
|
|
8
|
+
onChange();
|
|
9
|
+
};
|
|
10
|
+
function useStore(store, { keys, deps = [store, keys], ssr } = {}) {
|
|
11
|
+
let snapshotRef = useRef();
|
|
12
|
+
snapshotRef.current = store.get();
|
|
13
|
+
let subscribe = useCallback((onChange) => {
|
|
14
|
+
emit(snapshotRef, onChange)(store.value);
|
|
15
|
+
return keys?.length > 0 ? listenKeys(store, keys, emit(snapshotRef, onChange)) : store.listen(emit(snapshotRef, onChange));
|
|
16
|
+
}, deps);
|
|
17
|
+
let get = () => snapshotRef.current;
|
|
18
|
+
let server = get;
|
|
19
|
+
if (ssr && "init" in store) server = ssr === "initial" ? () => store.init : ssr;
|
|
20
|
+
return useSyncExternalStore(subscribe, get, server);
|
|
21
|
+
}
|
|
22
|
+
export { useStore as t };
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
1
|
+
// \0rolldown/runtime.js
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __name = (target, value) => __defProp(target, "name", {
|
|
5
4
|
value,
|
|
6
5
|
configurable: true
|
|
7
6
|
});
|
|
8
|
-
var
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __esmMin = (fn, res, err) => () => {
|
|
13
|
-
if (err) throw err[0];
|
|
14
|
-
try {
|
|
15
|
-
return fn && (res = fn(fn = 0)), res;
|
|
16
|
-
} catch (e) {
|
|
17
|
-
throw err = [e], e;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
7
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
21
8
|
var __exportAll = (all, no_symbols) => {
|
|
22
9
|
let target = {};
|
|
23
10
|
for (var name in all) __defProp(target, name, {
|
|
@@ -27,20 +14,4 @@ var __exportAll = (all, no_symbols) => {
|
|
|
27
14
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
28
15
|
return target;
|
|
29
16
|
};
|
|
30
|
-
|
|
31
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
32
|
-
key = keys[i];
|
|
33
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
34
|
-
get: ((k) => from[k]).bind(null, key),
|
|
35
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return to;
|
|
39
|
-
};
|
|
40
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
41
|
-
value: mod,
|
|
42
|
-
enumerable: true
|
|
43
|
-
}) : target, mod));
|
|
44
|
-
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
-
//#endregion
|
|
46
|
-
export { __toCommonJS as a, __name as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t };
|
|
17
|
+
export { __exportAll as n, __name as r, __commonJSMin as t };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { r as __name } from "./rolldown-runtime.mjs";
|
|
2
|
+
import { m as createHashHistory, n as createRouter, p as createBrowserHistory, t as RouterProvider } from "./libs/@tanstack.mjs";
|
|
3
|
+
import { u as e } from "./find.mjs";
|
|
4
|
+
import { NotFound } from "../components/NotFound.mjs";
|
|
5
|
+
import { LikeC4ProjectsContext } from "../context/LikeC4ProjectsContext.mjs";
|
|
6
|
+
import { routeTree } from "../routeTree.gen.mjs";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { basepath, useHashHistory } from "likec4:app-config";
|
|
10
|
+
import { isSingleProject, projects } from "likec4:projects";
|
|
11
|
+
// ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/purry.js
|
|
12
|
+
var t$1 = /* @__PURE__ */ __name((t, n) => n.length >= t.length ? t(...n) : e(t, n), "t");
|
|
13
|
+
// ../../node_modules/.pnpm/remeda@2.52.0/node_modules/remeda/dist/hasAtLeast.js
|
|
14
|
+
function t(...t) {
|
|
15
|
+
return t$1(n, t);
|
|
16
|
+
}
|
|
17
|
+
var n = (e, t) => e.length >= t;
|
|
18
|
+
// src/rewrite-single-project.ts
|
|
19
|
+
var REWRITTEN_SEGMENTS = [
|
|
20
|
+
"view",
|
|
21
|
+
"embed",
|
|
22
|
+
"export"
|
|
23
|
+
];
|
|
24
|
+
function projectPrefix(firstProjectId) {
|
|
25
|
+
return `/project/${firstProjectId}`;
|
|
26
|
+
}
|
|
27
|
+
function shouldRewriteInputPath(pathname) {
|
|
28
|
+
for (const segment of REWRITTEN_SEGMENTS) if (pathname === `/${segment}` || pathname.startsWith(`/${segment}/`)) return true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Maps public single-project URLs (`/view/...`, `/embed/...`, `/export/...`)
|
|
33
|
+
* onto the canonical multi-project tree under `/project/<id>/...`.
|
|
34
|
+
*
|
|
35
|
+
* Leaves `/`, `/projects`, `/project/...`, `/single-index`, `/webcomponent` alone.
|
|
36
|
+
* Does not rewrite `/` → `/project/<id>/` (avoids a root redirect loop).
|
|
37
|
+
* Does not add/strip trailing slashes; preserves search and hash.
|
|
38
|
+
*/
|
|
39
|
+
function rewriteSingleProjectInput(url, options) {
|
|
40
|
+
if (!options.enabled) return;
|
|
41
|
+
const { pathname } = url;
|
|
42
|
+
if (!shouldRewriteInputPath(pathname)) return;
|
|
43
|
+
const next = new URL(url.href);
|
|
44
|
+
next.pathname = `${projectPrefix(options.firstProjectId)}${pathname}`;
|
|
45
|
+
return next;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Strips `/project/<id>` from internal locations so the public URL stays
|
|
49
|
+
* without the project prefix in single-project mode.
|
|
50
|
+
*
|
|
51
|
+
* Maps bare `prefix` / `prefix/` → `/`.
|
|
52
|
+
* Does not add/strip trailing slashes on other paths; preserves search and hash.
|
|
53
|
+
*/
|
|
54
|
+
function rewriteSingleProjectOutput(url, options) {
|
|
55
|
+
if (!options.enabled) return;
|
|
56
|
+
const prefix = projectPrefix(options.firstProjectId);
|
|
57
|
+
const { pathname } = url;
|
|
58
|
+
if (pathname === prefix || pathname === `${prefix}/`) {
|
|
59
|
+
const next = new URL(url.href);
|
|
60
|
+
next.pathname = "/";
|
|
61
|
+
return next;
|
|
62
|
+
}
|
|
63
|
+
if (pathname.startsWith(`${prefix}/`)) {
|
|
64
|
+
const next = new URL(url.href);
|
|
65
|
+
next.pathname = pathname.slice(prefix.length);
|
|
66
|
+
return next;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// src/router.tsx
|
|
70
|
+
var projectIds = projects.map((p) => p.id);
|
|
71
|
+
var _projects = t(projectIds, 1) ? projectIds : ["default"];
|
|
72
|
+
var firstProjectId = _projects[0];
|
|
73
|
+
var rewriteOptions = {
|
|
74
|
+
enabled: isSingleProject,
|
|
75
|
+
firstProjectId
|
|
76
|
+
};
|
|
77
|
+
var router = createRouter({
|
|
78
|
+
routeTree,
|
|
79
|
+
context: {
|
|
80
|
+
projectId: firstProjectId,
|
|
81
|
+
projects: _projects
|
|
82
|
+
},
|
|
83
|
+
InnerWrap: LikeC4ProjectsContext,
|
|
84
|
+
basepath,
|
|
85
|
+
trailingSlash: "always",
|
|
86
|
+
defaultViewTransition: false,
|
|
87
|
+
history: useHashHistory ? createHashHistory() : createBrowserHistory(),
|
|
88
|
+
defaultStaleTime: Infinity,
|
|
89
|
+
defaultNotFoundComponent: () => {
|
|
90
|
+
return /* @__PURE__ */ jsx(NotFound, {});
|
|
91
|
+
},
|
|
92
|
+
...isSingleProject ? { rewrite: {
|
|
93
|
+
input: ({ url }) => rewriteSingleProjectInput(url, rewriteOptions),
|
|
94
|
+
output: ({ url }) => rewriteSingleProjectOutput(url, rewriteOptions)
|
|
95
|
+
} } : {}
|
|
96
|
+
});
|
|
97
|
+
function Routes() {
|
|
98
|
+
const $ = c(1);
|
|
99
|
+
let t0;
|
|
100
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t0 = /* @__PURE__ */ jsx(RouterProvider, { router });
|
|
102
|
+
$[0] = t0;
|
|
103
|
+
} else t0 = $[0];
|
|
104
|
+
return t0;
|
|
105
|
+
}
|
|
106
|
+
export { Routes as t };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "./rolldown-runtime.mjs";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
4
|
+
// src/relationship-browser/scope.ts
|
|
5
|
+
function isRelationshipBrowserScope(value) {
|
|
6
|
+
return value === "global" || value === "view";
|
|
7
|
+
}
|
|
8
|
+
function relationshipBrowserScopeStorageKey(projectId) {
|
|
9
|
+
return `likec4.relationshipsBrowser.scope:${projectId}`;
|
|
10
|
+
}
|
|
11
|
+
function resolveRelationshipBrowserScope(input) {
|
|
12
|
+
return input.urlScope ?? input.savedScope ?? input.configuredScope ?? "view";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Reads the relationship browser scope saved for one project.
|
|
16
|
+
*
|
|
17
|
+
* Storage is optional to keep server rendering and unavailable browser storage safe.
|
|
18
|
+
*/
|
|
19
|
+
function readRelationshipBrowserScope(projectId, storage = browserLocalStorage()) {
|
|
20
|
+
if (!storage) return void 0;
|
|
21
|
+
try {
|
|
22
|
+
const value = storage.getItem(relationshipBrowserScopeStorageKey(projectId));
|
|
23
|
+
return isRelationshipBrowserScope(value) ? value : void 0;
|
|
24
|
+
} catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Saves a user-selected relationship browser scope for one project.
|
|
30
|
+
*/
|
|
31
|
+
function saveRelationshipBrowserScope(projectId, scope, storage = browserLocalStorage()) {
|
|
32
|
+
if (!storage || !isRelationshipBrowserScope(scope)) return false;
|
|
33
|
+
try {
|
|
34
|
+
storage.setItem(relationshipBrowserScopeStorageKey(projectId), scope);
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the saved project scope, or its configured default when no preference exists.
|
|
42
|
+
*
|
|
43
|
+
* Only calls to `setScope` save a value. Initial values and configuration updates do not.
|
|
44
|
+
*/
|
|
45
|
+
function useRelationshipBrowserScope(project) {
|
|
46
|
+
const $ = c(12);
|
|
47
|
+
const configuredScope = project.relationshipBrowserDefaultScope;
|
|
48
|
+
let t0;
|
|
49
|
+
if ($[0] !== project) {
|
|
50
|
+
t0 = () => resolveProjectRelationshipBrowserScope(project);
|
|
51
|
+
$[0] = project;
|
|
52
|
+
$[1] = t0;
|
|
53
|
+
} else t0 = $[1];
|
|
54
|
+
const [scope, setScope] = useState(t0);
|
|
55
|
+
let t1;
|
|
56
|
+
if ($[2] !== project) {
|
|
57
|
+
t1 = () => {
|
|
58
|
+
setScope(resolveProjectRelationshipBrowserScope(project));
|
|
59
|
+
};
|
|
60
|
+
$[2] = project;
|
|
61
|
+
$[3] = t1;
|
|
62
|
+
} else t1 = $[3];
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[4] !== configuredScope || $[5] !== project.id) {
|
|
65
|
+
t2 = [project.id, configuredScope];
|
|
66
|
+
$[4] = configuredScope;
|
|
67
|
+
$[5] = project.id;
|
|
68
|
+
$[6] = t2;
|
|
69
|
+
} else t2 = $[6];
|
|
70
|
+
useEffect(t1, t2);
|
|
71
|
+
let t3;
|
|
72
|
+
if ($[7] !== project.id) {
|
|
73
|
+
t3 = (nextScope) => {
|
|
74
|
+
if (!isRelationshipBrowserScope(nextScope)) return;
|
|
75
|
+
setScope(nextScope);
|
|
76
|
+
saveRelationshipBrowserScope(project.id, nextScope);
|
|
77
|
+
};
|
|
78
|
+
$[7] = project.id;
|
|
79
|
+
$[8] = t3;
|
|
80
|
+
} else t3 = $[8];
|
|
81
|
+
const setUserScope = t3;
|
|
82
|
+
let t4;
|
|
83
|
+
if ($[9] !== scope || $[10] !== setUserScope) {
|
|
84
|
+
t4 = [scope, setUserScope];
|
|
85
|
+
$[9] = scope;
|
|
86
|
+
$[10] = setUserScope;
|
|
87
|
+
$[11] = t4;
|
|
88
|
+
} else t4 = $[11];
|
|
89
|
+
return t4;
|
|
90
|
+
}
|
|
91
|
+
function resolveProjectRelationshipBrowserScope(project) {
|
|
92
|
+
const savedScope = readRelationshipBrowserScope(project.id);
|
|
93
|
+
return resolveRelationshipBrowserScope({
|
|
94
|
+
...savedScope ? { savedScope } : {},
|
|
95
|
+
configuredScope: project.relationshipBrowserDefaultScope
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function browserLocalStorage() {
|
|
99
|
+
if (typeof window === "undefined") return void 0;
|
|
100
|
+
try {
|
|
101
|
+
return window.localStorage;
|
|
102
|
+
} catch {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export { useRelationshipBrowserScope as t };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "./rolldown-runtime.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/searchParams.ts
|
|
4
|
+
var searchParamsSchema = z.object({
|
|
5
|
+
theme: z.enum([
|
|
6
|
+
"light",
|
|
7
|
+
"dark",
|
|
8
|
+
"auto"
|
|
9
|
+
]).optional().catch(void 0),
|
|
10
|
+
dynamic: z.enum(["diagram", "sequence"]).optional().catch(void 0),
|
|
11
|
+
padding: z.number().min(0).default(20).catch(20),
|
|
12
|
+
relationshipsScope: z.enum(["global", "view"]).optional().catch(void 0),
|
|
13
|
+
relationships: z.string().nonempty().optional().catch(void 0).transform((v) => v),
|
|
14
|
+
focusOnElement: z.string().nonempty().optional().catch(void 0).transform((v) => v)
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Derives the Mantine `forceColorScheme` value from the parsed `?theme=` param.
|
|
18
|
+
*
|
|
19
|
+
* - `'light'` / `'dark'` → force that scheme (overrides localStorage, read-only)
|
|
20
|
+
* - `'auto'` or `undefined` → no force (Mantine uses localStorage / system preference)
|
|
21
|
+
*/
|
|
22
|
+
function resolveForceColorScheme(theme) {
|
|
23
|
+
switch (theme) {
|
|
24
|
+
case "light":
|
|
25
|
+
case "dark": return theme;
|
|
26
|
+
default: return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export { searchParamsSchema as n, resolveForceColorScheme as t };
|