@contentbit/studio 0.4.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 +46 -0
- package/dist/client/assets/api-C-Xwc2aB.js +1 -0
- package/dist/client/assets/document-Yk8nlK-k.js +1 -0
- package/dist/client/assets/index-BwvfKCmy.js +12 -0
- package/dist/client/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/client/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/client/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/client/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/client/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/client/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/client/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/client/assets/routes-DHIbdBYB.js +1 -0
- package/dist/client/assets/styles-BGHadX26.css +2 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/manifest.json +25 -0
- package/dist/client/robots.txt +3 -0
- package/dist/server/api.d.ts +4 -0
- package/dist/server/api.d.ts.map +1 -0
- package/dist/server/api.js +47 -0
- package/dist/server/assets/_tanstack-start-manifest_v-Djlrg1a7.js +25 -0
- package/dist/server/assets/api-Bqt_atjc.js +72 -0
- package/dist/server/assets/document-CxPFBdxd.js +265 -0
- package/dist/server/assets/document-DjmCb_Rp.js +9 -0
- package/dist/server/assets/empty-plugin-adapters-DKUlnwwl.js +5 -0
- package/dist/server/assets/router-D3JhQdql.js +63 -0
- package/dist/server/assets/routes-6jOjWQ0D.js +20 -0
- package/dist/server/assets/routes-BVJt9Z6a.js +386 -0
- package/dist/server/assets/start-q50h9Mc3.js +4 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +108 -0
- package/dist/server/preview.d.ts +4 -0
- package/dist/server/preview.d.ts.map +1 -0
- package/dist/server/preview.js +19 -0
- package/dist/server/scan.d.ts +5 -0
- package/dist/server/scan.d.ts.map +1 -0
- package/dist/server/scan.js +352 -0
- package/dist/server/server.js +5520 -0
- package/dist/server/types.d.ts +111 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { t as Route$1 } from "./document-DjmCb_Rp.js";
|
|
2
|
+
import { t as Route$2 } from "./routes-6jOjWQ0D.js";
|
|
3
|
+
import { HeadContent, Scripts, createRootRoute, createRouter } from "@tanstack/react-router";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/styles.css?url
|
|
6
|
+
var styles_default = "/assets/styles-BGHadX26.css";
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/routes/__root.tsx
|
|
9
|
+
var Route = createRootRoute({
|
|
10
|
+
head: () => ({
|
|
11
|
+
meta: [
|
|
12
|
+
{ charSet: "utf-8" },
|
|
13
|
+
{
|
|
14
|
+
name: "viewport",
|
|
15
|
+
content: "width=device-width, initial-scale=1"
|
|
16
|
+
},
|
|
17
|
+
{ title: "contentbit Studio" }
|
|
18
|
+
],
|
|
19
|
+
links: [{
|
|
20
|
+
rel: "stylesheet",
|
|
21
|
+
href: styles_default
|
|
22
|
+
}]
|
|
23
|
+
}),
|
|
24
|
+
notFoundComponent: () => /* @__PURE__ */ jsxs("main", {
|
|
25
|
+
className: "container mx-auto p-4 pt-16",
|
|
26
|
+
children: [/* @__PURE__ */ jsx("h1", { children: "404" }), /* @__PURE__ */ jsx("p", { children: "The requested page could not be found." })]
|
|
27
|
+
}),
|
|
28
|
+
shellComponent: RootDocument
|
|
29
|
+
});
|
|
30
|
+
function RootDocument({ children }) {
|
|
31
|
+
return /* @__PURE__ */ jsxs("html", {
|
|
32
|
+
lang: "en",
|
|
33
|
+
children: [/* @__PURE__ */ jsx("head", { children: /* @__PURE__ */ jsx(HeadContent, {}) }), /* @__PURE__ */ jsxs("body", { children: [children, /* @__PURE__ */ jsx(Scripts, {})] })]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/routeTree.gen.ts
|
|
38
|
+
var DocumentRoute = Route$1.update({
|
|
39
|
+
id: "/document",
|
|
40
|
+
path: "/document",
|
|
41
|
+
getParentRoute: () => Route
|
|
42
|
+
});
|
|
43
|
+
var rootRouteChildren = {
|
|
44
|
+
IndexRoute: Route$2.update({
|
|
45
|
+
id: "/",
|
|
46
|
+
path: "/",
|
|
47
|
+
getParentRoute: () => Route
|
|
48
|
+
}),
|
|
49
|
+
DocumentRoute
|
|
50
|
+
};
|
|
51
|
+
var routeTree = Route._addFileChildren(rootRouteChildren)._addFileTypes();
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/router.tsx
|
|
54
|
+
function getRouter() {
|
|
55
|
+
return createRouter({
|
|
56
|
+
routeTree,
|
|
57
|
+
scrollRestoration: true,
|
|
58
|
+
defaultPreload: "intent",
|
|
59
|
+
defaultPreloadStaleTime: 0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { getRouter };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createFileRoute, lazyRouteComponent } from "@tanstack/react-router";
|
|
2
|
+
//#region src/routes/index.tsx
|
|
3
|
+
var $$splitComponentImporter = () => import("./routes-BVJt9Z6a.js");
|
|
4
|
+
var Route = createFileRoute("/")({
|
|
5
|
+
validateSearch: (search) => ({
|
|
6
|
+
q: typeof search.q === "string" ? search.q : "",
|
|
7
|
+
status: isStatus(search.status) ? search.status : "all",
|
|
8
|
+
sort: isSortKey(search.sort) ? search.sort : "status",
|
|
9
|
+
dir: search.dir === "asc" || search.dir === "desc" ? search.dir : "asc"
|
|
10
|
+
}),
|
|
11
|
+
component: lazyRouteComponent($$splitComponentImporter, "component")
|
|
12
|
+
});
|
|
13
|
+
function isStatus(value) {
|
|
14
|
+
return value === "all" || value === "error" || value === "warning" || value === "suggestion" || value === "healthy";
|
|
15
|
+
}
|
|
16
|
+
function isSortKey(value) {
|
|
17
|
+
return value === "document" || value === "status" || value === "blocks" || value === "keywords" || value === "findings";
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Route as t };
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { t as Route } from "./routes-6jOjWQ0D.js";
|
|
2
|
+
import { i as Button, n as fetchGraph, r as fetchProject } from "./api-Bqt_atjc.js";
|
|
3
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { Link, useNavigate } from "@tanstack/react-router";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { AlertTriangle, ArrowRight, Blocks, ChevronsUpDown, FileText, Filter, Link2, RefreshCw, Search } from "lucide-react";
|
|
7
|
+
//#region src/routes/index.tsx?tsr-split=component
|
|
8
|
+
function Dashboard() {
|
|
9
|
+
const search = Route.useSearch();
|
|
10
|
+
const navigate = useNavigate({ from: "/" });
|
|
11
|
+
const [project, setProject] = useState(null);
|
|
12
|
+
const [graph, setGraph] = useState(null);
|
|
13
|
+
const [error, setError] = useState(null);
|
|
14
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
15
|
+
async function refresh() {
|
|
16
|
+
setRefreshing(true);
|
|
17
|
+
setError(null);
|
|
18
|
+
try {
|
|
19
|
+
const [project, graph] = await Promise.all([fetchProject(), fetchGraph()]);
|
|
20
|
+
setProject(project);
|
|
21
|
+
setGraph(graph);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
24
|
+
} finally {
|
|
25
|
+
setRefreshing(false);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
refresh();
|
|
30
|
+
}, []);
|
|
31
|
+
const files = useMemo(() => {
|
|
32
|
+
if (!project) return [];
|
|
33
|
+
const query = search.q.toLowerCase().trim();
|
|
34
|
+
return project.files.filter((file) => {
|
|
35
|
+
const haystack = [
|
|
36
|
+
file.relativePath,
|
|
37
|
+
file.title,
|
|
38
|
+
file.slug,
|
|
39
|
+
file.key,
|
|
40
|
+
file.locale,
|
|
41
|
+
file.keywords?.primary,
|
|
42
|
+
...file.keywords?.secondary ?? []
|
|
43
|
+
].filter(Boolean).join(" ").toLowerCase();
|
|
44
|
+
return (search.status === "all" || file.status === search.status) && haystack.includes(query);
|
|
45
|
+
}).sort((a, b) => compareFiles(a, b, search.sort, search.dir));
|
|
46
|
+
}, [
|
|
47
|
+
project,
|
|
48
|
+
search.dir,
|
|
49
|
+
search.q,
|
|
50
|
+
search.sort,
|
|
51
|
+
search.status
|
|
52
|
+
]);
|
|
53
|
+
function setSearch(next) {
|
|
54
|
+
navigate({
|
|
55
|
+
to: "/",
|
|
56
|
+
search: (prev) => ({
|
|
57
|
+
...prev,
|
|
58
|
+
...next
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function setSort(sort) {
|
|
63
|
+
setSearch({
|
|
64
|
+
sort,
|
|
65
|
+
dir: search.sort === sort && search.dir === "asc" ? "desc" : "asc"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ jsxs("main", {
|
|
69
|
+
className: "min-h-svh bg-background text-foreground",
|
|
70
|
+
children: [/* @__PURE__ */ jsx("section", {
|
|
71
|
+
className: "border-b bg-muted/30",
|
|
72
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "mx-auto flex max-w-7xl flex-col gap-6 px-5 py-6",
|
|
74
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
75
|
+
className: "flex flex-col gap-4 md:flex-row md:items-end md:justify-between",
|
|
76
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [
|
|
77
|
+
/* @__PURE__ */ jsx("p", {
|
|
78
|
+
className: "font-mono text-xs uppercase text-muted-foreground",
|
|
79
|
+
children: "contentbit studio"
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ jsx("h1", {
|
|
82
|
+
className: "mt-1 text-3xl font-semibold tracking-tight",
|
|
83
|
+
children: "Content dashboard"
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx("p", {
|
|
86
|
+
className: "mt-2 max-w-2xl text-sm text-muted-foreground",
|
|
87
|
+
children: "Read-only view of content health, structure, links, keywords, and previews."
|
|
88
|
+
})
|
|
89
|
+
] }), /* @__PURE__ */ jsxs(Button, {
|
|
90
|
+
onClick: refresh,
|
|
91
|
+
disabled: refreshing,
|
|
92
|
+
className: "w-fit gap-2",
|
|
93
|
+
children: [/* @__PURE__ */ jsx(RefreshCw, { className: refreshing ? "size-4 animate-spin" : "size-4" }), "Refresh"]
|
|
94
|
+
})]
|
|
95
|
+
}), project && /* @__PURE__ */ jsxs("div", {
|
|
96
|
+
className: "grid gap-px overflow-hidden rounded-sm border bg-border md:grid-cols-4",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
99
|
+
label: "files",
|
|
100
|
+
value: project.summary.files,
|
|
101
|
+
icon: /* @__PURE__ */ jsx(FileText, { className: "size-4" })
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
104
|
+
label: "findings",
|
|
105
|
+
value: project.summary.errors + project.summary.warnings + project.summary.suggestions,
|
|
106
|
+
icon: /* @__PURE__ */ jsx(AlertTriangle, { className: "size-4" }),
|
|
107
|
+
tone: project.summary.errors > 0 ? "bad" : project.summary.warnings > 0 ? "warn" : "ok"
|
|
108
|
+
}),
|
|
109
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
110
|
+
label: "blocks",
|
|
111
|
+
value: project.summary.blocks,
|
|
112
|
+
icon: /* @__PURE__ */ jsx(Blocks, { className: "size-4" })
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
115
|
+
label: "graph",
|
|
116
|
+
value: project.linkGraph ? `${project.linkGraph.pages}/${project.linkGraph.links}` : "off",
|
|
117
|
+
icon: /* @__PURE__ */ jsx(Link2, { className: "size-4" })
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})]
|
|
121
|
+
})
|
|
122
|
+
}), /* @__PURE__ */ jsxs("section", {
|
|
123
|
+
className: "mx-auto grid max-w-7xl gap-5 px-5 py-5 lg:grid-cols-[minmax(0,1fr)_320px]",
|
|
124
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
125
|
+
className: "min-w-0",
|
|
126
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
127
|
+
className: "mb-3 flex flex-col gap-2 md:flex-row",
|
|
128
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
129
|
+
className: "relative flex min-w-0 flex-1 items-center",
|
|
130
|
+
children: [/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-3 size-4 text-muted-foreground" }), /* @__PURE__ */ jsx("input", {
|
|
131
|
+
value: search.q,
|
|
132
|
+
onChange: (event) => setSearch({ q: event.target.value }),
|
|
133
|
+
placeholder: "Search path, title, slug, keyword...",
|
|
134
|
+
className: "h-10 w-full border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-foreground"
|
|
135
|
+
})]
|
|
136
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
137
|
+
className: "flex items-center gap-1 border bg-background p-1",
|
|
138
|
+
children: [/* @__PURE__ */ jsx(Filter, { className: "mx-2 size-4 text-muted-foreground" }), [
|
|
139
|
+
"all",
|
|
140
|
+
"error",
|
|
141
|
+
"warning",
|
|
142
|
+
"suggestion",
|
|
143
|
+
"healthy"
|
|
144
|
+
].map((status) => /* @__PURE__ */ jsx("button", {
|
|
145
|
+
onClick: () => setSearch({ status }),
|
|
146
|
+
className: search.status === status ? "bg-foreground px-2.5 py-1.5 text-xs font-medium text-background" : "px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground",
|
|
147
|
+
children: status
|
|
148
|
+
}, status))]
|
|
149
|
+
})]
|
|
150
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
151
|
+
className: "overflow-hidden border",
|
|
152
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
153
|
+
className: "grid grid-cols-[1.4fr_0.6fr_0.6fr_0.6fr_2rem] gap-px border-b bg-border text-xs font-medium uppercase text-muted-foreground",
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx(SortHeader, {
|
|
156
|
+
label: "Document",
|
|
157
|
+
active: search.sort === "document",
|
|
158
|
+
onClick: () => setSort("document")
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx(SortHeader, {
|
|
161
|
+
label: "Status",
|
|
162
|
+
active: search.sort === "status",
|
|
163
|
+
onClick: () => setSort("status")
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ jsx(SortHeader, {
|
|
166
|
+
label: "Blocks",
|
|
167
|
+
active: search.sort === "blocks",
|
|
168
|
+
onClick: () => setSort("blocks")
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx(SortHeader, {
|
|
171
|
+
label: "Keywords",
|
|
172
|
+
active: search.sort === "keywords",
|
|
173
|
+
onClick: () => setSort("keywords")
|
|
174
|
+
}),
|
|
175
|
+
/* @__PURE__ */ jsx("div", { className: "bg-muted/50 px-2 py-2" })
|
|
176
|
+
]
|
|
177
|
+
}), error ? /* @__PURE__ */ jsx("div", {
|
|
178
|
+
className: "p-4 text-sm text-destructive",
|
|
179
|
+
children: error
|
|
180
|
+
}) : project ? /* @__PURE__ */ jsxs("div", {
|
|
181
|
+
className: "divide-y",
|
|
182
|
+
children: [files.map((file) => /* @__PURE__ */ jsx(FileRow, { file }, file.path)), files.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
183
|
+
className: "p-4 text-sm text-muted-foreground",
|
|
184
|
+
children: "No documents match the current filters."
|
|
185
|
+
})]
|
|
186
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
187
|
+
className: "p-4 text-sm text-muted-foreground",
|
|
188
|
+
children: "Scanning content..."
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
}), /* @__PURE__ */ jsxs("aside", {
|
|
192
|
+
className: "flex flex-col gap-4",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsxs(Panel, {
|
|
195
|
+
title: "Link graph",
|
|
196
|
+
children: [project?.linkGraph ? /* @__PURE__ */ jsxs("div", {
|
|
197
|
+
className: "grid grid-cols-3 gap-px overflow-hidden border bg-border text-center",
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsx(TinyMetric, {
|
|
200
|
+
value: project.linkGraph.pages,
|
|
201
|
+
label: "pages"
|
|
202
|
+
}),
|
|
203
|
+
/* @__PURE__ */ jsx(TinyMetric, {
|
|
204
|
+
value: project.linkGraph.links,
|
|
205
|
+
label: "links"
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ jsx(TinyMetric, {
|
|
208
|
+
value: project.linkGraph.orphans,
|
|
209
|
+
label: "orphans"
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
213
|
+
className: "text-sm text-muted-foreground",
|
|
214
|
+
children: "No slug frontmatter detected."
|
|
215
|
+
}), graph && graph.edges.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
216
|
+
className: "mt-3 flex max-h-56 flex-col gap-2 overflow-auto text-xs",
|
|
217
|
+
children: graph.edges.slice(0, 12).map((edge, index) => /* @__PURE__ */ jsxs("li", {
|
|
218
|
+
className: "flex items-center gap-2",
|
|
219
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
220
|
+
className: edge.status === "unresolved" ? "text-destructive" : "text-muted-foreground",
|
|
221
|
+
children: edge.status
|
|
222
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
223
|
+
className: "truncate",
|
|
224
|
+
children: edge.target
|
|
225
|
+
})]
|
|
226
|
+
}, `${edge.from}-${edge.target}-${index}`))
|
|
227
|
+
})]
|
|
228
|
+
}),
|
|
229
|
+
/* @__PURE__ */ jsx(Panel, {
|
|
230
|
+
title: "Block usage",
|
|
231
|
+
children: project && Object.keys(project.blockUsage).length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
232
|
+
className: "flex flex-wrap gap-1",
|
|
233
|
+
children: Object.entries(project.blockUsage).map(([name, count]) => /* @__PURE__ */ jsxs("span", {
|
|
234
|
+
className: "border bg-muted px-2 py-1 font-mono text-xs",
|
|
235
|
+
children: [
|
|
236
|
+
name,
|
|
237
|
+
" x",
|
|
238
|
+
count
|
|
239
|
+
]
|
|
240
|
+
}, name))
|
|
241
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
242
|
+
className: "text-sm text-muted-foreground",
|
|
243
|
+
children: "No blocks found yet."
|
|
244
|
+
})
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ jsx(Panel, {
|
|
247
|
+
title: "Keyword coverage",
|
|
248
|
+
children: project && /* @__PURE__ */ jsxs("div", {
|
|
249
|
+
className: "space-y-2 text-sm",
|
|
250
|
+
children: [/* @__PURE__ */ jsx(Coverage, {
|
|
251
|
+
label: "primary",
|
|
252
|
+
value: project.keywordCoverage.withPrimary,
|
|
253
|
+
total: project.keywordCoverage.total
|
|
254
|
+
}), /* @__PURE__ */ jsx(Coverage, {
|
|
255
|
+
label: "secondary",
|
|
256
|
+
value: project.keywordCoverage.withSecondary,
|
|
257
|
+
total: project.keywordCoverage.total
|
|
258
|
+
})]
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
})]
|
|
263
|
+
})]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function FileRow({ file }) {
|
|
267
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
268
|
+
to: "/document",
|
|
269
|
+
search: { path: file.path },
|
|
270
|
+
className: "grid grid-cols-[1.4fr_0.6fr_0.6fr_0.6fr_2rem] gap-px bg-border text-sm transition-colors hover:bg-foreground/20",
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsxs("div", {
|
|
273
|
+
className: "min-w-0 bg-background px-3 py-3",
|
|
274
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
275
|
+
className: "truncate font-medium",
|
|
276
|
+
children: file.title
|
|
277
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
278
|
+
className: "truncate font-mono text-xs text-muted-foreground",
|
|
279
|
+
children: file.relativePath
|
|
280
|
+
})]
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ jsx("div", {
|
|
283
|
+
className: "bg-background px-3 py-3",
|
|
284
|
+
children: /* @__PURE__ */ jsx(StatusBadge, { status: file.status })
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ jsx("div", {
|
|
287
|
+
className: "bg-background px-3 py-3 font-mono text-xs",
|
|
288
|
+
children: file.blocks
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("div", {
|
|
291
|
+
className: "bg-background px-3 py-3 text-xs text-muted-foreground",
|
|
292
|
+
children: file.keywords?.primary ? "primary" : "missing"
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ jsx("div", {
|
|
295
|
+
className: "flex items-center justify-center bg-background px-2 py-3",
|
|
296
|
+
children: /* @__PURE__ */ jsx(ArrowRight, { className: "size-4 text-muted-foreground" })
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function Metric({ label, value, icon, tone }) {
|
|
302
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
303
|
+
className: "bg-background p-4",
|
|
304
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: "mb-3 flex items-center justify-between text-muted-foreground",
|
|
306
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
307
|
+
className: "text-xs uppercase",
|
|
308
|
+
children: label
|
|
309
|
+
}), icon]
|
|
310
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
311
|
+
className: `font-mono text-3xl font-semibold ${tone === "bad" ? "text-destructive" : tone === "warn" ? "text-amber-600" : tone === "ok" ? "text-emerald-600" : "text-foreground"}`,
|
|
312
|
+
children: value
|
|
313
|
+
})]
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function TinyMetric({ value, label }) {
|
|
317
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
318
|
+
className: "bg-background px-2 py-2",
|
|
319
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
320
|
+
className: "font-mono text-lg font-semibold",
|
|
321
|
+
children: value
|
|
322
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
323
|
+
className: "text-[0.65rem] uppercase text-muted-foreground",
|
|
324
|
+
children: label
|
|
325
|
+
})]
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function Panel({ title, children }) {
|
|
329
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
330
|
+
className: "border bg-background p-4",
|
|
331
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
332
|
+
className: "mb-3 text-sm font-semibold",
|
|
333
|
+
children: title
|
|
334
|
+
}), children]
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function Coverage({ label, value, total }) {
|
|
338
|
+
const pct = total === 0 ? 0 : Math.round(value / total * 100);
|
|
339
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
340
|
+
className: "mb-1 flex justify-between text-xs",
|
|
341
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
342
|
+
className: "text-muted-foreground",
|
|
343
|
+
children: label
|
|
344
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
345
|
+
className: "font-mono",
|
|
346
|
+
children: [pct, "%"]
|
|
347
|
+
})]
|
|
348
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
349
|
+
className: "h-2 bg-muted",
|
|
350
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
351
|
+
className: "h-full bg-foreground",
|
|
352
|
+
style: { width: `${pct}%` }
|
|
353
|
+
})
|
|
354
|
+
})] });
|
|
355
|
+
}
|
|
356
|
+
function StatusBadge({ status }) {
|
|
357
|
+
return /* @__PURE__ */ jsx("span", {
|
|
358
|
+
className: `inline-flex border px-2 py-0.5 text-xs ${status === "error" ? "border-destructive/40 bg-destructive/10 text-destructive" : status === "warning" ? "border-amber-500/40 bg-amber-500/10 text-amber-700" : status === "suggestion" ? "border-blue-500/40 bg-blue-500/10 text-blue-700" : "border-emerald-500/40 bg-emerald-500/10 text-emerald-700"}`,
|
|
359
|
+
children: status
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function SortHeader({ label, active, onClick }) {
|
|
363
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
364
|
+
className: active ? "flex items-center gap-1 bg-muted px-3 py-2 text-foreground" : "flex items-center gap-1 bg-muted/50 px-3 py-2 hover:text-foreground",
|
|
365
|
+
onClick,
|
|
366
|
+
children: [label, /* @__PURE__ */ jsx(ChevronsUpDown, { className: "size-3" })]
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function compareFiles(a, b, sort, dir) {
|
|
370
|
+
const direction = dir === "asc" ? 1 : -1;
|
|
371
|
+
const statusOrder = {
|
|
372
|
+
error: 0,
|
|
373
|
+
warning: 1,
|
|
374
|
+
suggestion: 2,
|
|
375
|
+
healthy: 3
|
|
376
|
+
};
|
|
377
|
+
return ((sort === "status" ? statusOrder[a.status] - statusOrder[b.status] : sort === "blocks" ? a.blocks - b.blocks : sort === "keywords" ? keywordScore(a) - keywordScore(b) : sort === "findings" ? findingScore(a) - findingScore(b) : a.relativePath.localeCompare(b.relativePath)) || a.relativePath.localeCompare(b.relativePath)) * direction;
|
|
378
|
+
}
|
|
379
|
+
function keywordScore(file) {
|
|
380
|
+
return (file.keywords?.primary ? 1 : 0) + (file.keywords?.secondary?.length ? 1 : 0);
|
|
381
|
+
}
|
|
382
|
+
function findingScore(file) {
|
|
383
|
+
return file.findings.errors * 100 + file.findings.warnings * 10 + file.findings.suggestions;
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
export { Dashboard as component };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@tanstack+react-start@1.168.26_react-dom@19.2.7_react@19.2.7__react@19.2.7_vite@8.0.16__ab3bb52b22b1abc10e7023e1ae4545d9/node_modules/@tanstack/react-start/dist/plugin/default-entry/start.ts
|
|
2
|
+
var startInstance = void 0;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { startInstance };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ViteDevServer } from 'vite';
|
|
2
|
+
import type { StartStudioOptions } from './types.js';
|
|
3
|
+
export type { StartStudioOptions, StudioDocument, StudioFileSummary, StudioFinding, StudioGraph, StudioProject, } from './types.js';
|
|
4
|
+
export { scanDocument, scanGraph, scanProject } from './scan.js';
|
|
5
|
+
export interface StudioServer {
|
|
6
|
+
url: string;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
closed: Promise<void>;
|
|
9
|
+
vite: ViteDevServer;
|
|
10
|
+
}
|
|
11
|
+
export declare function startStudio(options: StartStudioOptions): Promise<StudioServer>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,MAAM,CAAA;AAIpE,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,YAAY,CAAA;AAEnE,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEhE,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IACrB,IAAI,EAAE,aAAa,CAAA;CACpB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4CpF"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createServer } from 'vite';
|
|
6
|
+
import { handleStudioApiRequest } from './api.js';
|
|
7
|
+
export { scanDocument, scanGraph, scanProject } from './scan.js';
|
|
8
|
+
export async function startStudio(options) {
|
|
9
|
+
const root = findPackageRoot();
|
|
10
|
+
const host = options.host ?? '127.0.0.1';
|
|
11
|
+
const port = options.port ?? 4377;
|
|
12
|
+
const cwd = options.cwd ?? process.cwd();
|
|
13
|
+
const apiOptions = {
|
|
14
|
+
globs: options.globs,
|
|
15
|
+
cwd,
|
|
16
|
+
registryPath: options.registryPath,
|
|
17
|
+
linkOptions: options.linkOptions,
|
|
18
|
+
minSectionWords: options.minSectionWords,
|
|
19
|
+
};
|
|
20
|
+
const vite = await createServer({
|
|
21
|
+
root,
|
|
22
|
+
configFile: join(root, 'vite.config.ts'),
|
|
23
|
+
plugins: [studioApiPlugin(apiOptions)],
|
|
24
|
+
server: {
|
|
25
|
+
host,
|
|
26
|
+
port,
|
|
27
|
+
strictPort: options.port !== undefined && options.port !== 0,
|
|
28
|
+
open: false,
|
|
29
|
+
fs: {
|
|
30
|
+
allow: [root, cwd],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
apiOptions.previewComponents = () => loadProjectComponents(vite, { cwd, registryPath: options.registryPath });
|
|
35
|
+
await vite.listen();
|
|
36
|
+
const address = vite.httpServer?.address();
|
|
37
|
+
const resolvedPort = typeof address === 'object' && address ? address.port : port;
|
|
38
|
+
const url = `http://${host}:${resolvedPort}/`;
|
|
39
|
+
if (options.open !== false)
|
|
40
|
+
openBrowser(url);
|
|
41
|
+
return {
|
|
42
|
+
url,
|
|
43
|
+
vite,
|
|
44
|
+
close: () => vite.close(),
|
|
45
|
+
closed: new Promise((resolve) => {
|
|
46
|
+
vite.httpServer?.once('close', () => resolve());
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function loadProjectComponents(vite, options) {
|
|
51
|
+
for (const candidate of componentCandidates(options)) {
|
|
52
|
+
if (!existsSync(candidate))
|
|
53
|
+
continue;
|
|
54
|
+
const mod = (await vite.ssrLoadModule(candidate));
|
|
55
|
+
const components = mod.blockComponents ?? mod.components ?? mod.default;
|
|
56
|
+
if (components && typeof components === 'object')
|
|
57
|
+
return components;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
function componentCandidates(options) {
|
|
62
|
+
const dirs = new Set();
|
|
63
|
+
if (options.registryPath) {
|
|
64
|
+
const registryPath = isAbsolute(options.registryPath)
|
|
65
|
+
? options.registryPath
|
|
66
|
+
: resolve(options.cwd, options.registryPath);
|
|
67
|
+
dirs.add(dirname(registryPath));
|
|
68
|
+
}
|
|
69
|
+
dirs.add(join(options.cwd, 'blocks'));
|
|
70
|
+
return [...dirs].flatMap((dir) => [
|
|
71
|
+
join(dir, 'components.tsx'),
|
|
72
|
+
join(dir, 'components.ts'),
|
|
73
|
+
join(dir, 'preview.tsx'),
|
|
74
|
+
join(dir, 'preview.ts'),
|
|
75
|
+
join(dir, 'renderers.tsx'),
|
|
76
|
+
join(dir, 'renderers.ts'),
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
function studioApiPlugin(options) {
|
|
80
|
+
return {
|
|
81
|
+
name: 'contentbit-studio-api',
|
|
82
|
+
configureServer(server) {
|
|
83
|
+
server.middlewares.use((req, res, next) => {
|
|
84
|
+
void handleStudioApiRequest(options, req, res).then((handled) => {
|
|
85
|
+
if (!handled)
|
|
86
|
+
next();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function findPackageRoot() {
|
|
93
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
94
|
+
for (;;) {
|
|
95
|
+
if (existsSync(join(dir, 'package.json')))
|
|
96
|
+
return dir;
|
|
97
|
+
const next = dirname(dir);
|
|
98
|
+
if (next === dir)
|
|
99
|
+
throw new Error('Could not locate @contentbit/studio package root.');
|
|
100
|
+
dir = next;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function openBrowser(url) {
|
|
104
|
+
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
105
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
106
|
+
const child = spawn(command, args, { detached: true, stdio: 'ignore' });
|
|
107
|
+
child.unref();
|
|
108
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlockComponent } from '@contentbit/react';
|
|
2
|
+
import type { DocumentNode } from '@contentbit/core';
|
|
3
|
+
export declare function renderStudioPreview(document: DocumentNode, components?: Record<string, BlockComponent>): string;
|
|
4
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/server/preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAcpD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EACtB,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAM,GAC9C,MAAM,CASR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ContentBlocks } from '@contentbit/react';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
+
import ReactMarkdown from 'react-markdown';
|
|
5
|
+
import remarkGfm from 'remark-gfm';
|
|
6
|
+
export function renderStudioPreview(document, components = {}) {
|
|
7
|
+
return renderToStaticMarkup(createElement(ContentBlocks, {
|
|
8
|
+
document,
|
|
9
|
+
components,
|
|
10
|
+
renderMarkdown,
|
|
11
|
+
fallback: CustomBlockFallback,
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function renderMarkdown(markdown) {
|
|
15
|
+
return createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, markdown);
|
|
16
|
+
}
|
|
17
|
+
const CustomBlockFallback = ({ name, body }) => createElement('section', { className: 'cb-custom-block', 'data-cb-custom': name }, createElement('div', { className: 'cb-custom-block-label' }, name), createElement('div', { className: 'cb-custom-block-body' }, body.trim().length > 0
|
|
18
|
+
? renderMarkdown(body)
|
|
19
|
+
: createElement('p', null, 'No preview component for this custom block yet.')));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StudioDocument, StudioGraph, StudioOptions, StudioProject } from './types.js';
|
|
2
|
+
export declare function scanProject(options: StudioOptions): Promise<StudioProject>;
|
|
3
|
+
export declare function scanDocument(options: StudioOptions, requestedPath: string): Promise<StudioDocument | null>;
|
|
4
|
+
export declare function scanGraph(options: StudioOptions): Promise<StudioGraph>;
|
|
5
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/server/scan.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,cAAc,EAGd,WAAW,EAIX,aAAa,EACb,aAAa,EAEd,MAAM,YAAY,CAAA;AAgBnB,wBAAsB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CA6ChF;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAgChC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAoD5E"}
|