@vite-hub/docs 0.3.1 → 0.5.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 +179 -19
- package/dist/{agent-copy-BJp_Yf5d.js → agent-copy-xPaWye_g.js} +1 -1
- package/dist/assistant-pages-CqNlHsx-.js +37 -0
- package/dist/{assistant-shared-Dll_F_yy.d.ts → assistant-shared-CWIKRtBv.d.ts} +3 -2
- package/dist/{assistant-shared-CdtXowot.js → assistant-shared-DhiLHKSl.js} +23 -7
- package/dist/assistant-worker.d.ts +1 -1
- package/dist/assistant-worker.js +1 -1
- package/dist/assistant.d.ts +1 -1
- package/dist/assistant.js +1 -1
- package/dist/{content-9CINWiRf.js → content-BQVlMshL.js} +57 -47
- package/dist/{draft-DUBx--r9.js → draft-CSsTYSeb.js} +2 -2
- package/dist/error-diagnostics-CmgtG9xa.js +157 -0
- package/dist/files-UY4h1_36.js +38 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +4 -4
- package/dist/link-checker-redirects.js +1 -1
- package/dist/{manifest-Dzp5-_AJ.d.ts → manifest-Drbdw1us.d.ts} +9 -3
- package/dist/{manifest-D66AEF8F.js → manifest-DvECmwX-.js} +101 -51
- package/dist/{markdown-Cn9-4oVG.js → markdown-1M1FbjCw.js} +1 -1
- package/dist/{page-Dx2JD3y1.d.ts → markdown-BiKrT08O.d.ts} +2 -25
- package/dist/navigation.d.ts +10 -5
- package/dist/navigation.js +23 -10
- package/dist/{nuxt-B5LrERKc.d.ts → nuxt-8O2OB_hI.d.ts} +84 -7
- package/dist/nuxt.d.ts +2 -2
- package/dist/nuxt.js +1699 -105
- package/dist/{page-BbmSfZO8.js → page-Bb0TfRKi.js} +21 -4
- package/dist/page-BryUCmYf.d.ts +26 -0
- package/dist/primitive-rail.d.ts +2 -5
- package/dist/primitive-rail.js +8 -6
- package/dist/{raw-C03EUJKw.js → raw-BChwipz_.js} +6 -0
- package/dist/redirects-BJj58IsY.js +87 -0
- package/dist/runnable.d.ts +37 -0
- package/dist/runnable.js +105 -0
- package/dist/runtime/app/components/DocsAsideLeftBody.vue +2 -8
- package/dist/runtime/app/components/DocsLearn.vue +215 -0
- package/dist/runtime/app/components/DocsLearnCodePre.vue +98 -0
- package/dist/runtime/app/components/DocsLearnFile.vue +21 -0
- package/dist/runtime/app/components/DocsPage.vue +11 -5
- package/dist/runtime/app/components/DocsPlayground.vue +117 -0
- package/dist/runtime/app/components/content/Example.vue +18 -49
- package/dist/runtime/app/components/content/McpClient.vue +170 -0
- package/dist/runtime/app/components/content/McpInstall.vue +238 -0
- package/dist/runtime/app/components/content/PageList.vue +1 -5
- package/dist/runtime/app/layouts/docs.vue +36 -8
- package/dist/runtime/app/middleware/docs-layout.ts +2 -2
- package/dist/runtime/app/utils/docs-learn.ts +31 -0
- package/dist/runtime/app/utils/docs-playground.ts +3 -0
- package/dist/runtime/server/llms.js +1 -1
- package/dist/runtime/server/markdown.d.ts +0 -5
- package/dist/runtime/server/markdown.js +10 -1
- package/dist/runtime/server/mcp.js +1 -1
- package/dist/runtime/server/page.d.ts +1 -1
- package/dist/runtime/server/page.js +3 -3
- package/dist/runtime/server/raw.js +2 -9
- package/dist/runtime/server/search.d.ts +1 -1
- package/dist/runtime/server/search.js +3 -2
- package/dist/runtime/server/sitemap.js +1 -1
- package/dist/{schema-DwpXW0VZ.js → schema-DcWZ3Q3M.js} +97 -5
- package/dist/server.d.ts +3 -2
- package/dist/server.js +4 -4
- package/dist/snapshot-worker.mjs +40 -0
- package/dist/steps-DBlkJwtD.d.ts +105 -0
- package/dist/steps-DF-11dJn.js +32 -0
- package/dist/{types-BhG6vGfG.d.ts → types-CHU_fy9l.d.ts} +69 -4
- package/package.json +18 -11
- package/dist/error-diagnostics-BoOsP6Y4.js +0 -53
- package/dist/redirects-BrbWFSzW.js +0 -62
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { docsManifestPages,
|
|
2
|
-
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-
|
|
3
|
-
import { n as docsPageOf, r as docsPagePath } from "./page-
|
|
4
|
-
import { t as docsErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { docsManifestPages, normalizeDocsBase } from "./navigation.js";
|
|
2
|
+
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-DcWZ3Q3M.js";
|
|
3
|
+
import { n as docsPageOf, r as docsPagePath } from "./page-Bb0TfRKi.js";
|
|
4
|
+
import { t as docsErrorDiagnostics } from "./error-diagnostics-CmgtG9xa.js";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
6
|
import { join, matchesGlob, posix, relative, resolve, sep } from "node:path";
|
|
7
|
-
import { ELEMENT_NODE, parse, walkSync } from "ultrahtml";
|
|
8
|
-
import { defineContent } from "@vite-hub/content";
|
|
9
|
-
import {
|
|
7
|
+
import { ELEMENT_NODE, parse as parse$1, walkSync } from "ultrahtml";
|
|
8
|
+
import { contentSource, defineContent } from "@vite-hub/content";
|
|
9
|
+
import { glob, useSource } from "@vite-hub/source";
|
|
10
10
|
import { parseFrontmatter } from "comark/parse";
|
|
11
11
|
import yaml from "comark-content/plugins/yaml";
|
|
12
12
|
//#region src/check-links.ts
|
|
@@ -32,6 +32,32 @@ function matcher(patterns) {
|
|
|
32
32
|
}
|
|
33
33
|
return (value) => paths.has(value) || tests.some((test) => test(value));
|
|
34
34
|
}
|
|
35
|
+
function docsLinkExclusion(patterns) {
|
|
36
|
+
const excluded = matcher(patterns);
|
|
37
|
+
return (url, href) => excluded(href) || excluded(url.pathname) || excluded(url.pathname + url.hash);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The output file that answers `pathname`. A path with a trailing slash matches only `<path>/index.html`: hosts such
|
|
41
|
+
* as Cloudflare redirect `/guide/` to `/guide` when the output has `guide.html`.
|
|
42
|
+
*/
|
|
43
|
+
function docsOutputFile(dir, base = "/") {
|
|
44
|
+
const root = resolve(dir);
|
|
45
|
+
const appBase = `/${base.replace(/^\/+|\/+$/g, "")}`.replace(/\/$/, "");
|
|
46
|
+
return (pathname) => {
|
|
47
|
+
if (appBase && pathname !== appBase && !pathname.startsWith(`${appBase}/`)) return;
|
|
48
|
+
let path;
|
|
49
|
+
try {
|
|
50
|
+
path = decodeURIComponent(pathname.slice(appBase.length));
|
|
51
|
+
} catch {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
return (path.endsWith("/") ? [`${path}index.html`] : [
|
|
55
|
+
path,
|
|
56
|
+
`${path}.html`,
|
|
57
|
+
`${path}/index.html`
|
|
58
|
+
]).map((candidate) => resolve(root, `.${candidate.startsWith("/") ? candidate : `/${candidate}`}`)).find((file) => file.startsWith(`${root}${sep}`) && existsSync(file) && statSync(file).isFile());
|
|
59
|
+
};
|
|
60
|
+
}
|
|
35
61
|
/** Check built HTML against the files and fragment ids in the same output, without fetching remote URLs. */
|
|
36
62
|
function checkDocsLinks(options) {
|
|
37
63
|
const root = resolve(options.dir);
|
|
@@ -39,7 +65,7 @@ function checkDocsLinks(options) {
|
|
|
39
65
|
const origin = new URL(options.siteUrl).origin;
|
|
40
66
|
const appBase = `/${(options.appBase ?? "/").replace(/^\/+|\/+$/g, "")}`.replace(/\/$/, "");
|
|
41
67
|
const excludedPage = matcher(options.excludePages);
|
|
42
|
-
const excludedLink =
|
|
68
|
+
const excludedLink = docsLinkExclusion(options.excludeLinks);
|
|
43
69
|
const ignoredFragment = matcher(options.ignoreFragments);
|
|
44
70
|
const cache = /* @__PURE__ */ new Map();
|
|
45
71
|
const document = (file) => {
|
|
@@ -49,7 +75,7 @@ function checkDocsLinks(options) {
|
|
|
49
75
|
ids: /* @__PURE__ */ new Set(),
|
|
50
76
|
links: []
|
|
51
77
|
};
|
|
52
|
-
walkSync(parse(readFileSync(file, "utf8")), (node) => {
|
|
78
|
+
walkSync(parse$1(readFileSync(file, "utf8")), (node) => {
|
|
53
79
|
if (node.type !== ELEMENT_NODE) return;
|
|
54
80
|
for (const key of ["id", "name"]) if (node.attributes[key]) result.ids.add(decode(node.attributes[key]));
|
|
55
81
|
if (node.name === "base" && node.attributes.href && !result.base) result.base = decode(node.attributes.href);
|
|
@@ -59,21 +85,15 @@ function checkDocsLinks(options) {
|
|
|
59
85
|
cache.set(file, result);
|
|
60
86
|
return result;
|
|
61
87
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return [
|
|
72
|
-
path,
|
|
73
|
-
`${page}.html`,
|
|
74
|
-
`${page}/index.html`
|
|
75
|
-
].map((candidate) => resolve(root, `.${candidate.startsWith("/") ? candidate : `/${candidate}`}`)).find((file) => file.startsWith(`${root}${sep}`) && existsSync(file) && statSync(file).isFile());
|
|
76
|
-
};
|
|
88
|
+
const outputFile = docsOutputFile(root, appBase);
|
|
89
|
+
const targets = /* @__PURE__ */ new Map();
|
|
90
|
+
function fileOf(path) {
|
|
91
|
+
const known = targets.get(path);
|
|
92
|
+
if (known !== void 0) return known;
|
|
93
|
+
const target = outputFile(path) ?? null;
|
|
94
|
+
targets.set(path, target);
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
77
97
|
const files = readdirSync(root, {
|
|
78
98
|
recursive: true,
|
|
79
99
|
withFileTypes: true
|
|
@@ -95,7 +115,7 @@ function checkDocsLinks(options) {
|
|
|
95
115
|
problems.add(`${path} has an invalid URL: ${link}`);
|
|
96
116
|
continue;
|
|
97
117
|
}
|
|
98
|
-
if (url.origin !== origin || excludedLink(
|
|
118
|
+
if (url.origin !== origin || excludedLink(url, link)) continue;
|
|
99
119
|
const redirect = options.redirect?.(url);
|
|
100
120
|
if (redirect) {
|
|
101
121
|
problems.add(`${path} links to ${url.pathname}${url.hash}, which redirects to ${redirect}`);
|
|
@@ -104,7 +124,9 @@ function checkDocsLinks(options) {
|
|
|
104
124
|
const target = fileOf(url.pathname);
|
|
105
125
|
if (!target) {
|
|
106
126
|
if (options.isRuntimePath?.(url.pathname)) continue;
|
|
107
|
-
|
|
127
|
+
const page = url.pathname.replace(/\/+$/, "");
|
|
128
|
+
if (page !== url.pathname && fileOf(page)) problems.add(`${path} links to ${url.pathname}, but the page is ${page}, without the trailing slash`);
|
|
129
|
+
else problems.add(`${path} links to ${url.pathname}, which has no page or file`);
|
|
108
130
|
continue;
|
|
109
131
|
}
|
|
110
132
|
if (url.hash.length <= 1 || !target.endsWith(".html") || ignoredFragment(url.pathname)) continue;
|
|
@@ -168,15 +190,20 @@ const contentName = (index) => `docs_${index}`;
|
|
|
168
190
|
* One Content Source per docs source, with its Markdown pages and its `.navigation.yml` files as YAML documents. A
|
|
169
191
|
* folder is a `glob()` Source of those files. A Content Source, such as `github()`, is read as it is, from `rootDir`.
|
|
170
192
|
*/
|
|
171
|
-
function createDocsContent(sources, rootDir = process.cwd()) {
|
|
193
|
+
function createDocsContent(sources, rootDir = process.cwd(), options = {}) {
|
|
172
194
|
return defineContent({
|
|
173
195
|
route: false,
|
|
174
196
|
live: false,
|
|
175
197
|
plugins: [yaml({ onError: "throw" })],
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
...options.check ? { check: options.check } : {},
|
|
199
|
+
sources: Object.fromEntries(sources.map(({ dir, source }, index) => {
|
|
200
|
+
const input = source ? () => useSource(source, { rootDir }) : dir && existsSync(dir) ? () => useSource(glob({
|
|
201
|
+
include: ["**/*.md", "**/.navigation.yml"],
|
|
202
|
+
dot: true
|
|
203
|
+
}), { rootDir: dir }) : { items: async () => [] };
|
|
204
|
+
const url = options.url;
|
|
205
|
+
return [contentName(index), url ? contentSource(input, { url: ({ id }) => url(index, id) }) : input];
|
|
206
|
+
}))
|
|
180
207
|
});
|
|
181
208
|
}
|
|
182
209
|
/**
|
|
@@ -253,7 +280,7 @@ function docsManifestOf(options, listed) {
|
|
|
253
280
|
markdown: entry.markdown ?? ""
|
|
254
281
|
}) : entry.data;
|
|
255
282
|
return {
|
|
256
|
-
...docsPageOf(parse$
|
|
283
|
+
...docsPageOf(parse$2(entry.label, docsPageSchema, docsFrontmatter(fields)), {
|
|
257
284
|
id,
|
|
258
285
|
path,
|
|
259
286
|
file: entry.file
|
|
@@ -263,18 +290,32 @@ function docsManifestOf(options, listed) {
|
|
|
263
290
|
};
|
|
264
291
|
const prefix = base === "/" ? "" : `${base.slice(1)}/`;
|
|
265
292
|
const rootFile = `${prefix}index.md`;
|
|
266
|
-
const
|
|
293
|
+
const sectionFiles = /* @__PURE__ */ new Map();
|
|
294
|
+
const standaloneFiles = [];
|
|
295
|
+
for (const file of files.keys()) {
|
|
296
|
+
if (file === rootFile) continue;
|
|
297
|
+
const slash = file.startsWith(prefix) ? file.indexOf("/", prefix.length) : -1;
|
|
298
|
+
if (slash === -1) {
|
|
299
|
+
standaloneFiles.push(file);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const id = file.slice(prefix.length, slash);
|
|
303
|
+
const group = sectionFiles.get(id);
|
|
304
|
+
if (group) group.push(file);
|
|
305
|
+
else sectionFiles.set(id, [file]);
|
|
306
|
+
}
|
|
307
|
+
const sections = [...sectionFiles].map(([id, entries], index) => {
|
|
267
308
|
const sectionPrefix = `${prefix}${id}/`;
|
|
268
|
-
const pages =
|
|
309
|
+
const pages = entries.map((file) => {
|
|
269
310
|
const pageId = idOf(file.slice(sectionPrefix.length));
|
|
270
311
|
return read(file, pageId, pageId === "index" ? joinPath(base, id) : joinPath(base, id, pageId));
|
|
271
312
|
}).sort((left, right) => left.id === "index" ? -1 : right.id === "index" ? 1 : left.order - right.order || left.id.localeCompare(right.id));
|
|
272
313
|
let fields = {};
|
|
273
314
|
for (const file of folders.get(sectionPrefix.slice(0, -1)) ?? []) fields = {
|
|
274
315
|
...fields,
|
|
275
|
-
...parse$
|
|
316
|
+
...parse$2(file.label, docsSectionSchema, file.data)
|
|
276
317
|
};
|
|
277
|
-
const navigation = parse$
|
|
318
|
+
const navigation = parse$2(id, docsSectionSchema, {
|
|
278
319
|
...fields,
|
|
279
320
|
...options.sections?.[id]
|
|
280
321
|
});
|
|
@@ -293,7 +334,7 @@ function docsManifestOf(options, listed) {
|
|
|
293
334
|
pages
|
|
294
335
|
};
|
|
295
336
|
}).sort((left, right) => left.order - right.order || left.title.localeCompare(right.title));
|
|
296
|
-
const pages =
|
|
337
|
+
const pages = standaloneFiles.map((file) => read(file, "", docsPagePath(file))).sort((left, right) => left.path.localeCompare(right.path));
|
|
297
338
|
const manifest = {
|
|
298
339
|
base,
|
|
299
340
|
root: files.has(rootFile) ? read(rootFile, "index", base) : null,
|
|
@@ -311,7 +352,7 @@ function docsManifestOf(options, listed) {
|
|
|
311
352
|
}
|
|
312
353
|
return manifest;
|
|
313
354
|
}
|
|
314
|
-
function parse$
|
|
355
|
+
function parse$2(file, schema, input) {
|
|
315
356
|
const result = schema.safeParse(input);
|
|
316
357
|
if (!result.success) throw docsContentError(file, result.error.issues);
|
|
317
358
|
return result.data;
|
|
@@ -350,24 +391,33 @@ function appPage(full) {
|
|
|
350
391
|
function docsAppManifest(manifest, options) {
|
|
351
392
|
const panels = [];
|
|
352
393
|
const sections = manifest.sections.map((section) => {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
394
|
+
const children = /* @__PURE__ */ new Map();
|
|
395
|
+
if (options.panels) {
|
|
396
|
+
for (const page of section.pages) if (page.panel) children.set(page.id, []);
|
|
397
|
+
}
|
|
398
|
+
function parentPanelPages(id) {
|
|
399
|
+
for (let slash = id.lastIndexOf("/"); slash >= 0; slash = id.lastIndexOf("/")) {
|
|
400
|
+
id = id.slice(0, slash);
|
|
401
|
+
const pages = children.get(id);
|
|
402
|
+
if (pages) return pages;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (!children.size || [...children.keys()].some((id) => parentPanelPages(id))) return {
|
|
356
406
|
...section,
|
|
357
407
|
pages: section.pages.map(appPage)
|
|
358
408
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
409
|
+
const pages = [];
|
|
410
|
+
for (const page of section.pages) (parentPanelPages(page.id) ?? pages).push(appPage(page));
|
|
411
|
+
for (const page of pages) {
|
|
412
|
+
const entries = children.get(page.id);
|
|
413
|
+
if (!entries) continue;
|
|
414
|
+
page.panelSize = entries.filter((entry) => entry.navigation).length;
|
|
415
|
+
if (entries.length) panels.push({
|
|
416
|
+
path: page.path,
|
|
363
417
|
section: section.id,
|
|
364
|
-
pages:
|
|
418
|
+
pages: entries
|
|
365
419
|
});
|
|
366
420
|
}
|
|
367
|
-
const pages = section.pages.filter((page) => page.panel || !docsPanelOf(section, page)).map((page) => page.panel ? {
|
|
368
|
-
...appPage(page),
|
|
369
|
-
panelSize: docsPanelPages(section, page).filter((candidate) => candidate.navigation && candidate.id !== page.id).length
|
|
370
|
-
} : appPage(page));
|
|
371
421
|
return {
|
|
372
422
|
...section,
|
|
373
423
|
pages
|
|
@@ -417,4 +467,4 @@ function titleCase(input) {
|
|
|
417
467
|
return input.split(/[-/]/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
418
468
|
}
|
|
419
469
|
//#endregion
|
|
420
|
-
export {
|
|
470
|
+
export { docsAppManifestSource as a, resolveDocsSources as c, docsLinkExclusion as d, docsOutputFile as f, docsAppManifest as i, checkDocsLinks as l, createDocsContent as n, docsAppPanelSource as o, createDocsManifest as r, readDocsContent as s, contentName as t, docsLinkError as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as docsErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as docsErrorDiagnostics } from "./error-diagnostics-CmgtG9xa.js";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { ELEMENT_NODE, parse, walkSync } from "ultrahtml";
|
|
4
4
|
import { contentSearchSections } from "@vite-hub/content";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as DocsSearchSection, s as DocsTocLink } from "./types-CHU_fy9l.js";
|
|
2
2
|
import { PresetOptions } from "comark-ui/vue";
|
|
3
3
|
import { Node, ParserOptions } from "comark";
|
|
4
4
|
//#region src/markdown.d.ts
|
|
@@ -48,27 +48,4 @@ declare function createDocsParser(options?: DocsParserOptions): (markdown: strin
|
|
|
48
48
|
/** Split a page into one search entry per h2 and h3, like Nuxt UI's content search expects. */
|
|
49
49
|
declare function docsSearchSections(path: string, title: string, nodes: Node[]): DocsSearchSection[];
|
|
50
50
|
//#endregion
|
|
51
|
-
|
|
52
|
-
interface DocsPageLink {
|
|
53
|
-
path: string;
|
|
54
|
-
title: string;
|
|
55
|
-
description: string | null;
|
|
56
|
-
}
|
|
57
|
-
/** What the page route returns for one URL. The client renders it as is. */
|
|
58
|
-
interface DocsPageResponse {
|
|
59
|
-
page: DocsPage;
|
|
60
|
-
/** Id of the section that owns the page, or `null` for the root page and pages outside the base. */
|
|
61
|
-
section: string | null;
|
|
62
|
-
document: DocsDocument;
|
|
63
|
-
/** The page's `credits`, parsed like its body, or `null` without them. */
|
|
64
|
-
credits: DocsDocument | null;
|
|
65
|
-
prev: DocsPageLink | null;
|
|
66
|
-
next: DocsPageLink | null;
|
|
67
|
-
}
|
|
68
|
-
/** Previous and next follow the sidebar order of the page's section, or of its panel for a page inside one. */
|
|
69
|
-
declare function docsPageResponse(manifest: DocsManifest, found: {
|
|
70
|
-
page: DocsPage;
|
|
71
|
-
section: DocsSection | null;
|
|
72
|
-
}, document: DocsDocument, credits?: DocsDocument | null): DocsPageResponse;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { DocsParserOptions as a, docsSearchSections as c, DocsDocument as i, DocsPageResponse as n, createDocsParser as o, docsPageResponse as r, docsMarkdown as s, DocsPageLink as t };
|
|
51
|
+
export { docsSearchSections as a, docsMarkdown as i, DocsParserOptions as n, createDocsParser as r, DocsDocument as t };
|
package/dist/navigation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as DocsSearchSection, l as DocsLayout, n as DocsManifest, o as DocsSection, r as DocsPage, t as DocsAppPage } from "./types-CHU_fy9l.js";
|
|
2
2
|
//#region src/navigation.d.ts
|
|
3
3
|
/** A link that the site options add to the shell, such as a tutorials page or a community chat. */
|
|
4
4
|
export interface DocsLink {
|
|
@@ -117,8 +117,9 @@ export type DocsStart = {
|
|
|
117
117
|
links?: Pick<DocsLink, "to">[];
|
|
118
118
|
} | "";
|
|
119
119
|
/**
|
|
120
|
-
* The first start link that opens a docs page outside the docs base, such as an Introduction outside every
|
|
121
|
-
* It leads the start section, so the links that open it begin there. `
|
|
120
|
+
* The first start link that opens a docs page to read outside the docs base, such as an Introduction outside every
|
|
121
|
+
* section. It leads the start section, so the links that open it begin there. A `home`, `playground` or `learn` page is
|
|
122
|
+
* not a page to read first. `null` when no start link is such a page.
|
|
122
123
|
*/
|
|
123
124
|
export declare function docsStartPage(manifest: DocsManifest<DocsAppPage>, start?: DocsStart): string | null;
|
|
124
125
|
/**
|
|
@@ -228,8 +229,7 @@ export declare function docsRailIcon(icons: DocsIcons, section: Pick<DocsSection
|
|
|
228
229
|
/**
|
|
229
230
|
* Draws a 2px line icon with `stroke` instead. @nuxt/icon passes only the icon body in its CSS mode, so the icon is
|
|
230
231
|
* recognized by its body: Lucide draws `stroke-width="2"` with round joins. Filled icons, such as brand logos, have no
|
|
231
|
-
* stroke and stay as they are.
|
|
232
|
-
* https://github.com/onmax/icon/tree/fix/customize-name-css-mode).
|
|
232
|
+
* stroke and stay as they are.
|
|
233
233
|
*/
|
|
234
234
|
export declare function docsIconStroke(body: string, stroke: number): string;
|
|
235
235
|
/** URL of the raw Markdown twin of a page path, such as `/raw/docs/kv.md`. `/` has `/raw/index.md`. */
|
|
@@ -250,6 +250,11 @@ export declare function docsRawSectionLinks(manifest: DocsManifest, path: string
|
|
|
250
250
|
* that serves prerendered HTML reads it.
|
|
251
251
|
*/
|
|
252
252
|
export declare const docsTutorialNavigationCookie = "vh-tutorial-navigation";
|
|
253
|
+
/**
|
|
254
|
+
* Whether a layout fills the page with a workspace: `playground` and `learn`. Such a page renders in the docs shell
|
|
255
|
+
* wherever it lives, and fills the viewport under the header.
|
|
256
|
+
*/
|
|
257
|
+
export declare function isDocsWorkspaceLayout(layout: DocsLayout | undefined): layout is "playground" | "learn";
|
|
253
258
|
/** Whether a docs page starts with its sidebar collapsed: `sidebar: "collapsed"`, or a code panel tutorial that keeps it. */
|
|
254
259
|
export declare function docsSidebarCollapses(page: Pick<DocsPage, "sidebar" | "codePanel">): boolean;
|
|
255
260
|
/** Links of the page actions: the Markdown twin and chat tools that read it. */
|
package/dist/navigation.js
CHANGED
|
@@ -9,7 +9,7 @@ function docsManifestPages(manifest) {
|
|
|
9
9
|
}
|
|
10
10
|
/** A URL path without a trailing slash or `/index`, as the manifest stores it. */
|
|
11
11
|
function normalizeDocsPath(path) {
|
|
12
|
-
return path.replace(
|
|
12
|
+
return path.replace(/\/+(?:index\/*)?$/, "") || "/";
|
|
13
13
|
}
|
|
14
14
|
/** A browser URL for an app-relative route or asset. Router links keep their app-relative paths. */
|
|
15
15
|
function docsAppPath(path, appBase = "/") {
|
|
@@ -76,12 +76,14 @@ function docsSectionHome(section) {
|
|
|
76
76
|
return (section.pages.find((page) => page.path === section.path) ?? section.pages.find((page) => page.navigation) ?? section.pages[0])?.path ?? section.path;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* The first start link that opens a docs page outside the docs base, such as an Introduction outside every
|
|
80
|
-
* It leads the start section, so the links that open it begin there. `
|
|
79
|
+
* The first start link that opens a docs page to read outside the docs base, such as an Introduction outside every
|
|
80
|
+
* section. It leads the start section, so the links that open it begin there. A `home`, `playground` or `learn` page is
|
|
81
|
+
* not a page to read first. `null` when no start link is such a page.
|
|
81
82
|
*/
|
|
82
83
|
function docsStartPage(manifest, start) {
|
|
83
|
-
|
|
84
|
-
const
|
|
84
|
+
if (!start || !start.links?.length) return null;
|
|
85
|
+
const pages = new Set(docsManifestPages(manifest).filter((page) => page !== manifest.root && page.layout !== "home" && !isDocsWorkspaceLayout(page.layout)).map((page) => page.path));
|
|
86
|
+
const link = start.links.find((candidate) => pages.has(normalizeDocsPath(candidate.to)));
|
|
85
87
|
return link ? normalizeDocsPath(link.to) : null;
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
@@ -162,7 +164,10 @@ function docsRailEntries(manifest, options) {
|
|
|
162
164
|
const members = /* @__PURE__ */ new Map();
|
|
163
165
|
for (const section of manifest.sections) {
|
|
164
166
|
const title = docsSectionGroup(section, options.groups);
|
|
165
|
-
if (title
|
|
167
|
+
if (title === null) continue;
|
|
168
|
+
const group = members.get(title);
|
|
169
|
+
if (group) group.push(section);
|
|
170
|
+
else members.set(title, [section]);
|
|
166
171
|
}
|
|
167
172
|
const placed = /* @__PURE__ */ new Set();
|
|
168
173
|
return railGroups.map((sections) => sections.flatMap((section) => {
|
|
@@ -246,7 +251,9 @@ function sidebarGroups(pages, fold) {
|
|
|
246
251
|
for (const page of pages) {
|
|
247
252
|
if (!page.navigation) continue;
|
|
248
253
|
const label = page.group?.trim() || null;
|
|
249
|
-
|
|
254
|
+
const group = groups.get(label);
|
|
255
|
+
if (group) group.push(page);
|
|
256
|
+
else groups.set(label, [page]);
|
|
250
257
|
}
|
|
251
258
|
return [...groups].map(([label, groupPages]) => {
|
|
252
259
|
const heading = groupPages.length > 1 ? label : null;
|
|
@@ -340,8 +347,7 @@ function docsRailIcon(icons, section) {
|
|
|
340
347
|
/**
|
|
341
348
|
* Draws a 2px line icon with `stroke` instead. @nuxt/icon passes only the icon body in its CSS mode, so the icon is
|
|
342
349
|
* recognized by its body: Lucide draws `stroke-width="2"` with round joins. Filled icons, such as brand logos, have no
|
|
343
|
-
* stroke and stay as they are.
|
|
344
|
-
* https://github.com/onmax/icon/tree/fix/customize-name-css-mode).
|
|
350
|
+
* stroke and stay as they are.
|
|
345
351
|
*/
|
|
346
352
|
function docsIconStroke(body, stroke) {
|
|
347
353
|
if (!body.includes("stroke-linejoin=\"round\"")) return body;
|
|
@@ -390,6 +396,13 @@ function docsRawSectionLinks(manifest, path, siteUrl) {
|
|
|
390
396
|
* that serves prerendered HTML reads it.
|
|
391
397
|
*/
|
|
392
398
|
const docsTutorialNavigationCookie = "vh-tutorial-navigation";
|
|
399
|
+
/**
|
|
400
|
+
* Whether a layout fills the page with a workspace: `playground` and `learn`. Such a page renders in the docs shell
|
|
401
|
+
* wherever it lives, and fills the viewport under the header.
|
|
402
|
+
*/
|
|
403
|
+
function isDocsWorkspaceLayout(layout) {
|
|
404
|
+
return layout === "playground" || layout === "learn";
|
|
405
|
+
}
|
|
393
406
|
/** Whether a docs page starts with its sidebar collapsed: `sidebar: "collapsed"`, or a code panel tutorial that keeps it. */
|
|
394
407
|
function docsSidebarCollapses(page) {
|
|
395
408
|
return page.sidebar === "collapsed" || page.codePanel === true && page.sidebar !== false;
|
|
@@ -517,4 +530,4 @@ function createDocsSearch(records) {
|
|
|
517
530
|
};
|
|
518
531
|
}
|
|
519
532
|
//#endregion
|
|
520
|
-
export { createDocsSearch, docsAppPath, docsCanonicalUrl, docsCatalog, docsHasRail, docsHomePath, docsIconStroke, docsIndexedPages, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsPageIndexed, docsPanelGroupWindow, docsPanelOf, docsPanelPages, docsPanelSidebarGroups, docsPanelWindow, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRailTarget, docsRawFile, docsRawPath, docsRawSectionLinks, docsRawSectionLinksMarker, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionHome, docsSectionIcon, docsSectionPanels, docsSidebarCollapses, docsSidebarGroup, docsSidebarGroups, docsSidebarSections, docsStartPage, docsTutorialNavigationCookie, docsUnindexedSearchSections, findDocsPage, isDocsPath, loadDocsPanels, normalizeDocsBase, normalizeDocsPath };
|
|
533
|
+
export { createDocsSearch, docsAppPath, docsCanonicalUrl, docsCatalog, docsHasRail, docsHomePath, docsIconStroke, docsIndexedPages, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsPageIndexed, docsPanelGroupWindow, docsPanelOf, docsPanelPages, docsPanelSidebarGroups, docsPanelWindow, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRailTarget, docsRawFile, docsRawPath, docsRawSectionLinks, docsRawSectionLinksMarker, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionHome, docsSectionIcon, docsSectionPanels, docsSidebarCollapses, docsSidebarGroup, docsSidebarGroups, docsSidebarSections, docsStartPage, docsTutorialNavigationCookie, docsUnindexedSearchSections, findDocsPage, isDocsPath, isDocsWorkspaceLayout, loadDocsPanels, normalizeDocsBase, normalizeDocsPath };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { h as DocsSectionFile, r as DocsPage } from "./types-CHU_fy9l.js";
|
|
2
|
+
import "./steps-DBlkJwtD.js";
|
|
3
|
+
import { i as DocsSourceInput, s as DocsLinkCheckOptions } from "./manifest-Drbdw1us.js";
|
|
3
4
|
import { DocsGroup, DocsIcons, DocsLink } from "./navigation.js";
|
|
4
5
|
import { ContentLlmsSection } from "@vite-hub/content";
|
|
5
6
|
import { PublicRuntimeConfig } from "nuxt/schema";
|
|
@@ -14,6 +15,72 @@ interface DocsCommentsOptions {
|
|
|
14
15
|
overlay?: false;
|
|
15
16
|
}
|
|
16
17
|
//#endregion
|
|
18
|
+
//#region src/runnable/build.d.ts
|
|
19
|
+
/** A lesson that runs in the reader's browser. */
|
|
20
|
+
interface RunnableTutorialSource {
|
|
21
|
+
/** The id of the lesson and of its snapshot, such as `first-agent`. */
|
|
22
|
+
slug: string;
|
|
23
|
+
/** The URL of the docs page, such as `/docs/getting-started/first-agent`. */
|
|
24
|
+
page: string;
|
|
25
|
+
/** The folder of the app after the last step, in the fixtures folder. */
|
|
26
|
+
fixture: string;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/runnable/playground.d.ts
|
|
30
|
+
/** A starting app of the playground. */
|
|
31
|
+
interface PlaygroundTemplateSource {
|
|
32
|
+
/** The `?template=` value and the id in share links. */
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
/** The heading of the example in the examples menu. */
|
|
37
|
+
group?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The folder in the fixtures folder, so an example and a lesson can share one copy of the code. An absolute path,
|
|
40
|
+
* such as the `dir` of a `layout: playground` example, works too.
|
|
41
|
+
*/
|
|
42
|
+
fixture: string;
|
|
43
|
+
/** The file that the editor opens first. */
|
|
44
|
+
open?: string;
|
|
45
|
+
/** The path that the preview opens when the dev server is ready. */
|
|
46
|
+
preview?: string;
|
|
47
|
+
/** The paths of the files that the editor does not let the reader change. */
|
|
48
|
+
readonly?: string[];
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/runnable/nuxt.d.ts
|
|
52
|
+
type DocsRunnableLesson = RunnableTutorialSource;
|
|
53
|
+
type DocsRunnableExample = PlaygroundTemplateSource;
|
|
54
|
+
/** `runnable` of the docs module options. */
|
|
55
|
+
interface DocsRunnableOptions {
|
|
56
|
+
/**
|
|
57
|
+
* The folder of the apps that lessons and examples run, relative to the app root. Defaults to `fixtures`. Each app
|
|
58
|
+
* is a folder in it. The npm lockfile that pins its snapshot sits beside it as `<folder>.package-lock.json`.
|
|
59
|
+
*/
|
|
60
|
+
fixtures?: string;
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Give each lesson a page with `layout: learn` instead, which sets its `fixture` in the frontmatter. This
|
|
63
|
+
* list is for an app page that renders the workspace itself and imports `#build/runnable-tutorials.mjs`.
|
|
64
|
+
*/
|
|
65
|
+
lessons?: DocsRunnableLesson[];
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated List the examples in the frontmatter of a page with `layout: playground` instead. This list is for an
|
|
68
|
+
* app page that renders the workspace itself and imports `#build/playground-templates.mjs`.
|
|
69
|
+
*/
|
|
70
|
+
examples?: DocsRunnableExample[];
|
|
71
|
+
/**
|
|
72
|
+
* A docs page, such as `/docs/getting-started/installation`, whose code blocks give the version of a file before the
|
|
73
|
+
* lesson step that writes it. Without it, a file that a step writes does not exist before that step.
|
|
74
|
+
*/
|
|
75
|
+
start?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The folder of `pnpm-workspace.yaml`, relative to the app root, when fixtures use `catalog:` or `workspace:`
|
|
78
|
+
* specifiers. The workspace packages that a fixture uses are built and packed into its snapshot. Without it, fixtures
|
|
79
|
+
* install from npm only.
|
|
80
|
+
*/
|
|
81
|
+
pnpmWorkspace?: string;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
17
84
|
//#region src/nuxt.d.ts
|
|
18
85
|
interface DocsSiteOptions {
|
|
19
86
|
/** Name in titles, the rail, and llms.txt. */
|
|
@@ -49,8 +116,8 @@ interface DocsModuleOptions {
|
|
|
49
116
|
dir?: string;
|
|
50
117
|
/**
|
|
51
118
|
* Pages from folders and Content Sources, replacing `dir`: a folder relative to the app root, a Source such as
|
|
52
|
-
* `github({ repo, root })` from `vite-hub/source`, or `{ source, mount?, exclude?, frontmatter? }`. The
|
|
53
|
-
*
|
|
119
|
+
* `github({ repo, root })` from `vite-hub/source`, or `{ source, mount?, exclude?, frontmatter? }`. The docs assistant
|
|
120
|
+
* reads the same pages.
|
|
54
121
|
*/
|
|
55
122
|
sources?: DocsSourceInput[];
|
|
56
123
|
/** Section metadata overrides, keyed by section id. */
|
|
@@ -59,7 +126,9 @@ interface DocsModuleOptions {
|
|
|
59
126
|
components?: string;
|
|
60
127
|
/**
|
|
61
128
|
* URL prefix whose folders are sections in the rail. Defaults to `/docs` when the content folder has a `docs/` folder,
|
|
62
|
-
* and to `/` when it has none, so the docs are the whole site.
|
|
129
|
+
* and to `/` when it has none, so the docs are the whole site. With `sources`, the default is always `/docs`.
|
|
130
|
+
* If the site has pages but none are at or below the default base, setup warns with `DOCS_BASE_EMPTY`.
|
|
131
|
+
* Set `base: '/docs'` to keep those pages standalone without the warning.
|
|
63
132
|
*/
|
|
64
133
|
base?: string;
|
|
65
134
|
site?: DocsSiteOptions;
|
|
@@ -114,7 +183,8 @@ interface DocsModuleOptions {
|
|
|
114
183
|
* Checks every prerendered page as a site audit does: a sitemap URL that is not a prerendered page, a missing or
|
|
115
184
|
* duplicate title or description, a title outside 10 to 60 characters or a description outside 70 to 160, not exactly
|
|
116
185
|
* one `h1`, a skipped heading level, fewer than 150 words, or a page that no other page links to. Pages with `noindex`
|
|
117
|
-
* or a canonical link to another page are left out. `"warn"`, the default,
|
|
186
|
+
* or a canonical link to another page are left out. `"warn"`, the default, reports one hint for each kind of problem,
|
|
187
|
+
* such as `DOCS_SEO_TITLE_INVALID`, in the build output and in `.vitehub/hints.json`. `"error"` or `true` stops the
|
|
118
188
|
* build with `DOCS_SEO_FAILED`. `false` turns the check off.
|
|
119
189
|
*/
|
|
120
190
|
seoAudit?: "warn" | "error" | boolean;
|
|
@@ -160,6 +230,13 @@ interface DocsModuleOptions {
|
|
|
160
230
|
* `examples`, so `::example{name="ButtonExample"}` renders `app/examples/ButtonExample.vue` beside its source.
|
|
161
231
|
*/
|
|
162
232
|
examples?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Lessons and playground examples that run in the reader's browser, in a WebContainer. Each one runs an app from the
|
|
235
|
+
* fixtures folder. The build writes `#build/runnable-tutorials.mjs`, `#build/playground-templates.mjs`,
|
|
236
|
+
* `#build/learn-facts.mjs`, and a `node_modules` snapshot of each app at `/_tutorials/snapshots/` under the app base.
|
|
237
|
+
* Each lesson names its page by URL, so the page can come from `dir` or from `sources`.
|
|
238
|
+
*/
|
|
239
|
+
runnable?: DocsRunnableOptions;
|
|
163
240
|
}
|
|
164
241
|
/** `llms` of the docs module options. */
|
|
165
242
|
interface DocsLlmsOptions {
|
|
@@ -237,4 +314,4 @@ interface DocsNuxtModule {
|
|
|
237
314
|
}
|
|
238
315
|
declare const docsNuxtModule: DocsNuxtModule;
|
|
239
316
|
//#endregion
|
|
240
|
-
export { DocsPublicConfig as a, docsNuxtModule as c, DocsNuxtModule as i,
|
|
317
|
+
export { DocsPublicConfig as a, docsNuxtModule as c, DocsRunnableOptions as d, DocsCommentsOptions as f, DocsNuxtModule as i, DocsRunnableExample as l, DocsLogo as n, DocsSiteOptions as o, DocsModuleOptions as r, DocsStartOptions as s, DocsLlmsOptions as t, DocsRunnableLesson as u };
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as DocsPublicConfig, c as docsNuxtModule, i as DocsNuxtModule, l as
|
|
1
|
+
import { a as DocsPublicConfig, c as docsNuxtModule, d as DocsRunnableOptions, f as DocsCommentsOptions, i as DocsNuxtModule, l as DocsRunnableExample, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions, t as DocsLlmsOptions, u as DocsRunnableLesson } from "./nuxt-8O2OB_hI.js";
|
|
2
2
|
import { a as DocsThemeScope } from "./theme-BXyu4uFL.js";
|
|
3
|
-
export { type DocsCommentsOptions, DocsLlmsOptions, DocsLogo, DocsModuleOptions, DocsNuxtModule, DocsPublicConfig, DocsSiteOptions, DocsStartOptions, type DocsThemeScope, docsNuxtModule as default };
|
|
3
|
+
export { type DocsCommentsOptions, DocsLlmsOptions, DocsLogo, DocsModuleOptions, DocsNuxtModule, DocsPublicConfig, type DocsRunnableExample, type DocsRunnableLesson, type DocsRunnableOptions, DocsSiteOptions, DocsStartOptions, type DocsThemeScope, docsNuxtModule as default };
|