@contentbit/studio 0.6.0 → 0.6.1

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.
@@ -1,9 +1,9 @@
1
- import { t as Route$1 } from "./document-DlS34LM6.js";
1
+ import { t as Route$1 } from "./document-BB_UYqNL.js";
2
2
  import { t as Route$2 } from "./routes-p0tk6PAr.js";
3
3
  import { HeadContent, Scripts, createRootRoute, createRouter } from "@tanstack/react-router";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/styles.css?url
6
- var styles_default = "/assets/styles-DxZJz8Oi.css";
6
+ var styles_default = "/assets/styles-DogO4Wcf.css";
7
7
  //#endregion
8
8
  //#region src/routes/__root.tsx
9
9
  var Route = createRootRoute({
@@ -1,138 +1,487 @@
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, searchForWorkspaceRoot } 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
- // Vite serves only files under `fs.allow`. We need:
14
- // - `root`: the Studio package itself (its built UI and source).
15
- // - `searchForWorkspaceRoot(root)`: the workspace that hoists Studio's deps,
16
- // so packaged fonts and other Vite-served dependency assets resolve when
17
- // Studio is installed into a monorepo.
18
- // - `cwd`: the consuming project, so Studio can read its content/blocks.
19
- // We deliberately do NOT add `searchForWorkspaceRoot(cwd)`: in a project with
20
- // no workspace marker, Vite walks up past the git root to the nearest ancestor
21
- // `package.json`, which can expose an unexpectedly broad directory over HTTP
22
- // (notably with `--host`).
23
- const fsAllow = [...new Set([root, searchForWorkspaceRoot(root), cwd])];
24
- const apiOptions = {
25
- globs: options.globs,
26
- cwd,
27
- registryPath: options.registryPath,
28
- includeGenericBlocks: options.includeGenericBlocks,
29
- linkOptions: options.linkOptions,
30
- minSectionWords: options.minSectionWords,
31
- seoConfig: options.seoConfig,
32
- seoConfigPath: options.seoConfigPath,
33
- };
34
- const vite = await createServer({
35
- root,
36
- configFile: join(root, 'vite.config.ts'),
37
- plugins: [studioApiPlugin(apiOptions)],
38
- server: {
39
- host,
40
- port,
41
- strictPort: options.port !== undefined && options.port !== 0,
42
- open: false,
43
- fs: {
44
- allow: fsAllow,
45
- },
46
- },
47
- });
48
- apiOptions.previewComponents = () => loadProjectComponents(vite, { cwd, registryPath: options.registryPath });
49
- await vite.listen();
50
- const address = vite.httpServer?.address();
51
- const resolvedPort = typeof address === 'object' && address ? address.port : port;
52
- const url = `http://${host}:${resolvedPort}/`;
53
- if (options.open !== false)
54
- openBrowser(url);
55
- return {
56
- url,
57
- vite,
58
- close: () => vite.close(),
59
- closed: new Promise((resolve) => {
60
- vite.httpServer?.once('close', () => resolve());
61
- }),
62
- };
1
+ // src/server/index.ts
2
+ import { spawn } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, isAbsolute as isAbsolute2, join as join2, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { createServer, searchForWorkspaceRoot } from "vite";
7
+
8
+ // src/server/scan.ts
9
+ import {
10
+ compareContentProjectFindings,
11
+ createLinkGraphView,
12
+ createSeoBrief,
13
+ readContentPageFacts,
14
+ summarizeContentProjectFindings
15
+ } from "@contentbit/core";
16
+
17
+ // ../project/dist/index.js
18
+ import { genericBlocks } from "@contentbit/blocks";
19
+ import { createBlockRegistry, scanContentProject } from "@contentbit/core";
20
+ import { readFile } from "node:fs/promises";
21
+ import { isAbsolute, join } from "node:path";
22
+ import { pathToFileURL } from "node:url";
23
+ import { glob } from "tinyglobby";
24
+ var ProjectLoadError = class extends Error {
25
+ exitCode;
26
+ constructor(exitCode, message) {
27
+ super(message);
28
+ this.exitCode = exitCode;
29
+ this.name = "ProjectLoadError";
30
+ }
31
+ };
32
+ async function resolveContentFiles(positionals, cmd, options = {}) {
33
+ if (positionals.length === 0) {
34
+ if (options.allowEmpty)
35
+ return [];
36
+ throw new ProjectLoadError(2, `${cmd}: provide at least one file or glob.`);
37
+ }
38
+ const files = (await glob(positionals, { absolute: true, cwd: options.cwd })).sort();
39
+ if (files.length === 0) {
40
+ if (options.allowEmpty)
41
+ return [];
42
+ throw new ProjectLoadError(2, `${cmd}: no files matched ${positionals.join(" ")}`);
43
+ }
44
+ return files;
45
+ }
46
+ async function loadRegistry(registryPath, options = {}) {
47
+ const registry = createBlockRegistry();
48
+ if (options.includeGenericBlocks !== false)
49
+ registry.use(genericBlocks());
50
+ if (!registryPath)
51
+ return registry;
52
+ const resolvedPath = isAbsolute(registryPath) ? registryPath : join(options.cwd ?? process.cwd(), registryPath);
53
+ let mod;
54
+ try {
55
+ mod = await import(pathToFileURL(resolvedPath).href);
56
+ } catch (err) {
57
+ if (err instanceof Error && "code" in err && err.code === "ERR_UNKNOWN_FILE_EXTENSION") {
58
+ throw new Error(`Importing a TypeScript registry needs Node 22.18+ (native type stripping): ${resolvedPath}`);
59
+ }
60
+ throw err;
61
+ }
62
+ if (!Array.isArray(mod.default)) {
63
+ throw new Error(`--registry module must default-export an array of block definitions: ${resolvedPath}`);
64
+ }
65
+ registry.use(mod.default);
66
+ return registry;
67
+ }
68
+ async function loadContentProject(input) {
69
+ const files = await resolveContentFiles(input.positionals, input.cmd, {
70
+ cwd: input.cwd,
71
+ allowEmpty: input.allowEmpty
72
+ });
73
+ const registry = await loadRegistry(input.registry, {
74
+ cwd: input.cwd,
75
+ includeGenericBlocks: input.includeGenericBlocks
76
+ });
77
+ const sources = await Promise.all(files.map(async (path) => ({ path, source: await readFile(path, "utf8") })));
78
+ const linkOptions = input.linkOptions ?? {};
79
+ const scan = scanContentProject(sources, registry, {
80
+ linkOptions,
81
+ ...input.scan
82
+ });
83
+ return { files, registry, sources, linkOptions, scan };
84
+ }
85
+
86
+ // src/server/scan.ts
87
+ import { basename, relative } from "node:path";
88
+
89
+ // src/server/preview.ts
90
+ import { ContentBlocks } from "@contentbit/react";
91
+ import { createElement } from "react";
92
+ import { renderToStaticMarkup } from "react-dom/server";
93
+ import ReactMarkdown from "react-markdown";
94
+ import remarkGfm from "remark-gfm";
95
+ function renderStudioPreview(document, components = {}, _options = {}) {
96
+ return renderToStaticMarkup(
97
+ createElement(ContentBlocks, {
98
+ document,
99
+ components,
100
+ renderMarkdown,
101
+ fallback: CustomBlockFallback
102
+ })
103
+ );
104
+ }
105
+ function renderMarkdown(markdown) {
106
+ return createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, markdown);
107
+ }
108
+ var CustomBlockFallback = ({ name, body }) => createElement(
109
+ "section",
110
+ { className: "cb-custom-block", "data-cb-custom": name },
111
+ createElement("div", { className: "cb-custom-block-label" }, name),
112
+ createElement(
113
+ "div",
114
+ { className: "cb-custom-block-body" },
115
+ body.trim().length > 0 ? renderMarkdown(body) : createElement("p", null, "No preview component for this custom block yet.")
116
+ )
117
+ );
118
+
119
+ // src/server/scan.ts
120
+ async function scanProject(options) {
121
+ const context = await scanContext(options);
122
+ const blockUsage = {};
123
+ let words = 0;
124
+ let blocks = 0;
125
+ let links = 0;
126
+ let missingAlt = 0;
127
+ let withPrimary = 0;
128
+ let withSecondary = 0;
129
+ for (const file of context.summaries) {
130
+ words += file.words;
131
+ blocks += file.blocks;
132
+ links += file.links;
133
+ missingAlt += file.missingAlt;
134
+ if (file.keywords?.primary) withPrimary++;
135
+ if ((file.keywords?.secondary?.length ?? 0) > 0) withSecondary++;
136
+ for (const [name, count] of Object.entries(file.blockNames)) {
137
+ blockUsage[name] = (blockUsage[name] ?? 0) + count;
138
+ }
139
+ }
140
+ const summary = summarize(context.findings);
141
+ return {
142
+ root: options.cwd ?? process.cwd(),
143
+ files: context.summaries,
144
+ summary: {
145
+ files: context.summaries.length,
146
+ errors: summary.errors,
147
+ warnings: summary.warnings,
148
+ suggestions: summary.suggestions,
149
+ words,
150
+ blocks,
151
+ links,
152
+ missingAlt
153
+ },
154
+ blockUsage,
155
+ keywordCoverage: {
156
+ total: context.summaries.length,
157
+ withPrimary,
158
+ withSecondary
159
+ },
160
+ ...context.scan.linkGraph ? { linkGraph: context.scan.linkGraph } : {},
161
+ ...context.scan.seo ? {
162
+ seo: {
163
+ schemaVersion: context.scan.seo.schemaVersion,
164
+ pages: context.scan.seo.pages.length,
165
+ existing: context.scan.seo.pages.filter((page) => page.source === "existing").length,
166
+ planned: context.scan.seo.pages.filter((page) => page.source === "planned").length,
167
+ findings: context.scan.seo.findings.length
168
+ }
169
+ } : {},
170
+ findings: context.findings
171
+ };
172
+ }
173
+ async function scanDocument(options, requestedPath) {
174
+ const context = await scanContext(options);
175
+ const file = findAllowedFile(context, options.cwd ?? process.cwd(), requestedPath);
176
+ if (!file) return null;
177
+ const scanned = context.scan.files.find((item) => item.path === file);
178
+ if (!scanned) return null;
179
+ const summary = context.summaries.find((item) => item.path === file);
180
+ if (!summary) return null;
181
+ const previewHtml = renderStudioPreview(
182
+ scanned.validation.document,
183
+ await options.previewComponents?.() ?? {},
184
+ { includeGenericComponents: options.includeGenericBlocks !== false }
185
+ );
186
+ const page = context.index ? [...context.index.pages.values()].find((entry) => entry.path === file) : void 0;
187
+ const seoPage = context.scan.seo?.pages.find((entry) => entry.path === file);
188
+ const seoBrief = context.scan.seo && seoPage ? createSeoBrief(context.scan.seo, seoPage.id) : void 0;
189
+ return {
190
+ file: summary,
191
+ source: scanned.source,
192
+ frontmatter: scanned.frontmatter,
193
+ stats: scanned.stats,
194
+ findings: context.findings.filter((finding) => finding.file === file),
195
+ linksTo: page ? page.linkRefs.length > 0 ? page.linkRefs : page.linksTo : [],
196
+ linkedFrom: page ? page.linkedFromRefs.length > 0 ? page.linkedFromRefs : page.linkedFrom : [],
197
+ ...seoBrief ? { seoBrief } : {},
198
+ previewHtml
199
+ };
200
+ }
201
+ async function scanGraph(options) {
202
+ const context = await scanContext(options);
203
+ if (!context.index) return { nodes: [], edges: [] };
204
+ const summaryByPath = new Map(context.summaries.map((summary) => [summary.path, summary]));
205
+ const view = createLinkGraphView(context.index, context.scan.linkDiagnostics ?? []);
206
+ const nodes = view.nodes.map((node) => ({
207
+ id: node.id,
208
+ label: node.label,
209
+ path: node.path,
210
+ status: summaryByPath.get(node.path)?.status ?? "healthy",
211
+ slug: node.slug,
212
+ ...node.key ? { key: node.key } : {},
213
+ ...node.locale ? { locale: node.locale } : {}
214
+ }));
215
+ const edges = view.edges;
216
+ return { nodes, edges };
217
+ }
218
+ async function scanContext(options) {
219
+ const cwd = options.cwd ?? process.cwd();
220
+ const project = await loadContentProject({
221
+ cmd: "studio",
222
+ positionals: options.globs,
223
+ cwd,
224
+ registry: options.registryPath,
225
+ includeGenericBlocks: options.includeGenericBlocks,
226
+ linkOptions: options.linkOptions,
227
+ scan: {
228
+ minSectionWords: options.minSectionWords,
229
+ seoConfig: options.seoConfig,
230
+ seoConfigPath: options.seoConfigPath
231
+ }
232
+ });
233
+ const { files, scan } = project;
234
+ const findings = scan.findings.map((finding) => findingFromProjectFinding(finding, cwd)).sort(compareFindings);
235
+ const summaries = scan.files.map(
236
+ (file) => fileSummary(
237
+ file.path,
238
+ cwd,
239
+ file.frontmatter,
240
+ file.stats,
241
+ findings.filter((finding) => finding.file === file.path),
242
+ options,
243
+ scan.seo?.pages.find((page) => page.path === file.path)
244
+ )
245
+ );
246
+ const index = scan.linkIndex;
247
+ findings.sort(compareFindings);
248
+ return { files, scan, findings, summaries, index };
249
+ }
250
+ function findingFromProjectFinding(finding, cwd) {
251
+ return {
252
+ severity: finding.severity,
253
+ source: finding.source,
254
+ code: finding.code,
255
+ file: finding.file,
256
+ relativePath: relativePath(cwd, finding.file),
257
+ ...finding.line !== void 0 ? { line: finding.line } : {},
258
+ ...finding.column !== void 0 ? { column: finding.column } : {},
259
+ message: finding.message,
260
+ ...finding.hint ? { hint: finding.hint } : {}
261
+ };
262
+ }
263
+ function fileSummary(file, cwd, frontmatter, stats, findings, options, seoPage) {
264
+ const counts = summarize(findings);
265
+ const facts = readContentPageFacts(frontmatter, options.linkOptions);
266
+ return {
267
+ path: file,
268
+ relativePath: relativePath(cwd, file),
269
+ title: titleFor(file, frontmatter, stats),
270
+ ...facts.slug ? { slug: facts.slug } : {},
271
+ ...facts.key ? { key: facts.key } : {},
272
+ ...facts.locale ? { locale: facts.locale } : {},
273
+ ...facts.keywords ? { keywords: facts.keywords } : {},
274
+ words: stats.length.words,
275
+ readingMinutes: stats.length.readingMinutes,
276
+ blocks: stats.blocks.total,
277
+ blockNames: stats.blocks.byName,
278
+ links: stats.links.total,
279
+ externalLinks: stats.links.external,
280
+ missingAlt: stats.images.missingAlt,
281
+ ...seoPage ? {
282
+ seo: {
283
+ id: seoPage.id,
284
+ source: seoPage.source,
285
+ ...seoPage.type ? { type: seoPage.type } : {},
286
+ ...seoPage.intent ? { intent: seoPage.intent } : {},
287
+ findings: findings.filter((finding) => finding.source === "seo").length
288
+ }
289
+ } : {},
290
+ findings: counts,
291
+ status: statusFor(counts)
292
+ };
293
+ }
294
+ function titleFor(file, frontmatter, stats) {
295
+ return stringValue(frontmatter.title) ?? stats.outline[0]?.text ?? basename(file);
296
+ }
297
+ function summarize(findings) {
298
+ return summarizeContentProjectFindings(findings);
299
+ }
300
+ function statusFor(findings) {
301
+ if (findings.errors > 0) return "error";
302
+ if (findings.warnings > 0) return "warning";
303
+ if (findings.suggestions > 0) return "suggestion";
304
+ return "healthy";
305
+ }
306
+ function findAllowedFile(context, cwd, requestedPath) {
307
+ return context.files.find(
308
+ (file) => file === requestedPath || relativePath(cwd, file) === requestedPath
309
+ ) ?? null;
310
+ }
311
+ function compareFindings(a, b) {
312
+ return compareContentProjectFindings(a, b) || a.relativePath.localeCompare(b.relativePath) || (a.line ?? 0) - (b.line ?? 0) || (a.column ?? 0) - (b.column ?? 0) || a.code.localeCompare(b.code);
313
+ }
314
+ function stringValue(value) {
315
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
316
+ }
317
+ function relativePath(cwd, file) {
318
+ const rel = relative(cwd, file);
319
+ return rel.startsWith("..") ? file : rel;
320
+ }
321
+
322
+ // src/server/api.ts
323
+ async function handleStudioApiRequest(options, req, res) {
324
+ if (!req.url) return false;
325
+ const url = new URL(req.url, "http://contentbit.local");
326
+ if (!url.pathname.startsWith("/api/")) return false;
327
+ try {
328
+ if (req.method !== "GET") {
329
+ sendJson(res, 405, { error: "Studio API is read-only." });
330
+ return true;
331
+ }
332
+ if (url.pathname === "/api/project") {
333
+ sendJson(res, 200, await scanProject(options));
334
+ return true;
335
+ }
336
+ if (url.pathname === "/api/graph") {
337
+ sendJson(res, 200, await scanGraph(options));
338
+ return true;
339
+ }
340
+ if (url.pathname === "/api/document") {
341
+ const path = url.searchParams.get("path");
342
+ if (!path) {
343
+ sendJson(res, 400, { error: "Missing ?path=" });
344
+ return true;
345
+ }
346
+ const document = await scanDocument(options, path);
347
+ if (!document) {
348
+ sendJson(res, 404, { error: "Document is not in the configured content set." });
349
+ return true;
350
+ }
351
+ sendJson(res, 200, document);
352
+ return true;
353
+ }
354
+ sendJson(res, 404, { error: "Unknown Studio API route." });
355
+ return true;
356
+ } catch (err) {
357
+ sendJson(res, 500, { error: err instanceof Error ? err.message : String(err) });
358
+ return true;
359
+ }
360
+ }
361
+ function sendJson(res, status, body) {
362
+ res.statusCode = status;
363
+ res.setHeader("content-type", "application/json; charset=utf-8");
364
+ res.end(JSON.stringify(body, null, 2));
365
+ }
366
+
367
+ // src/server/index.ts
368
+ async function startStudio(options) {
369
+ const root = findPackageRoot();
370
+ const host = options.host ?? "127.0.0.1";
371
+ const port = options.port ?? 4377;
372
+ const cwd = options.cwd ?? process.cwd();
373
+ const fsAllow = [.../* @__PURE__ */ new Set([root, searchForWorkspaceRoot(root), cwd])];
374
+ const apiOptions = {
375
+ globs: options.globs,
376
+ cwd,
377
+ registryPath: options.registryPath,
378
+ includeGenericBlocks: options.includeGenericBlocks,
379
+ linkOptions: options.linkOptions,
380
+ minSectionWords: options.minSectionWords,
381
+ seoConfig: options.seoConfig,
382
+ seoConfigPath: options.seoConfigPath
383
+ };
384
+ const vite = await createServer({
385
+ root,
386
+ configFile: join2(root, "vite.config.ts"),
387
+ plugins: [studioApiPlugin(apiOptions)],
388
+ server: {
389
+ host,
390
+ port,
391
+ strictPort: options.port !== void 0 && options.port !== 0,
392
+ open: false,
393
+ fs: {
394
+ allow: fsAllow
395
+ }
396
+ }
397
+ });
398
+ apiOptions.previewComponents = () => loadProjectComponents(vite, { cwd, registryPath: options.registryPath });
399
+ await vite.listen();
400
+ const address = vite.httpServer?.address();
401
+ const resolvedPort = typeof address === "object" && address ? address.port : port;
402
+ const url = `http://${host}:${resolvedPort}/`;
403
+ if (options.open !== false) openBrowser(url);
404
+ return {
405
+ url,
406
+ vite,
407
+ close: () => vite.close(),
408
+ closed: new Promise((resolve2) => {
409
+ vite.httpServer?.once("close", () => resolve2());
410
+ })
411
+ };
63
412
  }
64
413
  async function loadProjectComponents(vite, options) {
65
- const merged = {};
66
- for (const candidate of componentCandidates(options)) {
67
- if (!existsSync(candidate.path))
68
- continue;
69
- let mod;
70
- try {
71
- mod = (await vite.ssrLoadModule(candidate.path));
72
- }
73
- catch {
74
- if (!candidate.bestEffort)
75
- throw new Error(`Failed to load block components: ${candidate.path}`);
76
- continue;
77
- }
78
- const maps = [mod.styledComponents, mod.blockComponents, mod.components, mod.default];
79
- for (const components of maps) {
80
- if (components && typeof components === 'object')
81
- Object.assign(merged, components);
82
- }
414
+ const merged = {};
415
+ for (const candidate of componentCandidates(options)) {
416
+ if (!existsSync(candidate.path)) continue;
417
+ let mod;
418
+ try {
419
+ mod = await vite.ssrLoadModule(candidate.path);
420
+ } catch {
421
+ if (!candidate.bestEffort)
422
+ throw new Error(`Failed to load block components: ${candidate.path}`);
423
+ continue;
83
424
  }
84
- return Object.keys(merged).length > 0 ? merged : undefined;
425
+ const maps = [mod.styledComponents, mod.blockComponents, mod.components, mod.default];
426
+ for (const components of maps) {
427
+ if (components && typeof components === "object") Object.assign(merged, components);
428
+ }
429
+ }
430
+ return Object.keys(merged).length > 0 ? merged : void 0;
85
431
  }
86
432
  function componentCandidates(options) {
87
- const dirs = new Set();
88
- if (options.registryPath) {
89
- const registryPath = isAbsolute(options.registryPath)
90
- ? options.registryPath
91
- : resolve(options.cwd, options.registryPath);
92
- dirs.add(dirname(registryPath));
93
- }
94
- dirs.add(join(options.cwd, 'blocks'));
95
- const rendererCandidates = [
96
- join(options.cwd, 'components/content-blocks/content-renderer.tsx'),
97
- join(options.cwd, 'src/components/content-blocks/content-renderer.tsx'),
98
- ].map((path) => ({ path, bestEffort: true }));
99
- const blockComponentCandidates = [...dirs].flatMap((dir) => [
100
- join(dir, 'components.tsx'),
101
- join(dir, 'components.ts'),
102
- join(dir, 'preview.tsx'),
103
- join(dir, 'preview.ts'),
104
- join(dir, 'renderers.tsx'),
105
- join(dir, 'renderers.ts'),
106
- ].map((path) => ({ path, bestEffort: false })));
107
- return [...rendererCandidates, ...blockComponentCandidates];
433
+ const dirs = /* @__PURE__ */ new Set();
434
+ if (options.registryPath) {
435
+ const registryPath = isAbsolute2(options.registryPath) ? options.registryPath : resolve(options.cwd, options.registryPath);
436
+ dirs.add(dirname(registryPath));
437
+ }
438
+ dirs.add(join2(options.cwd, "blocks"));
439
+ const rendererCandidates = [
440
+ join2(options.cwd, "components/content-blocks/content-renderer.tsx"),
441
+ join2(options.cwd, "src/components/content-blocks/content-renderer.tsx")
442
+ ].map((path) => ({ path, bestEffort: true }));
443
+ const blockComponentCandidates = [...dirs].flatMap(
444
+ (dir) => [
445
+ join2(dir, "components.tsx"),
446
+ join2(dir, "components.ts"),
447
+ join2(dir, "preview.tsx"),
448
+ join2(dir, "preview.ts"),
449
+ join2(dir, "renderers.tsx"),
450
+ join2(dir, "renderers.ts")
451
+ ].map((path) => ({ path, bestEffort: false }))
452
+ );
453
+ return [...rendererCandidates, ...blockComponentCandidates];
108
454
  }
109
455
  function studioApiPlugin(options) {
110
- return {
111
- name: 'contentbit-studio-api',
112
- configureServer(server) {
113
- server.middlewares.use((req, res, next) => {
114
- void handleStudioApiRequest(options, req, res).then((handled) => {
115
- if (!handled)
116
- next();
117
- });
118
- });
119
- },
120
- };
456
+ return {
457
+ name: "contentbit-studio-api",
458
+ configureServer(server) {
459
+ server.middlewares.use((req, res, next) => {
460
+ void handleStudioApiRequest(options, req, res).then((handled) => {
461
+ if (!handled) next();
462
+ });
463
+ });
464
+ }
465
+ };
121
466
  }
122
467
  function findPackageRoot() {
123
- let dir = dirname(fileURLToPath(import.meta.url));
124
- for (;;) {
125
- if (existsSync(join(dir, 'package.json')))
126
- return dir;
127
- const next = dirname(dir);
128
- if (next === dir)
129
- throw new Error('Could not locate @contentbit/studio package root.');
130
- dir = next;
131
- }
468
+ let dir = dirname(fileURLToPath(import.meta.url));
469
+ for (; ; ) {
470
+ if (existsSync(join2(dir, "package.json"))) return dir;
471
+ const next = dirname(dir);
472
+ if (next === dir) throw new Error("Could not locate @contentbit/studio package root.");
473
+ dir = next;
474
+ }
132
475
  }
133
476
  function openBrowser(url) {
134
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
135
- const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
136
- const child = spawn(command, args, { detached: true, stdio: 'ignore' });
137
- child.unref();
477
+ const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
478
+ const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
479
+ const child = spawn(command, args, { detached: true, stdio: "ignore" });
480
+ child.unref();
138
481
  }
482
+ export {
483
+ scanDocument,
484
+ scanGraph,
485
+ scanProject,
486
+ startStudio
487
+ };
@@ -3415,7 +3415,7 @@ var defaultSerovalPlugins = [
3415
3415
  * the dev styles URL for route-scoped CSS collection.
3416
3416
  */
3417
3417
  async function getStartManifest(matchedRoutes) {
3418
- const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-BSt6T4tK.js");
3418
+ const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-DyPYRepF.js");
3419
3419
  const startManifest = tsrStartManifest();
3420
3420
  let routes = startManifest.routes;
3421
3421
  routes[rootRouteId];
@@ -5130,7 +5130,7 @@ var getBaseManifest = getProdBaseManifest;
5130
5130
  var createEarlyHintsForRequest = createEarlyHintsCollector;
5131
5131
  async function loadEntries() {
5132
5132
  const [routerEntry, startEntry, pluginAdapters] = await Promise.all([
5133
- import("./assets/router-734kIJxk.js"),
5133
+ import("./assets/router-BJiN6b7L.js"),
5134
5134
  import("./assets/start-q50h9Mc3.js"),
5135
5135
  import("./assets/empty-plugin-adapters-DKUlnwwl.js")
5136
5136
  ]);