@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,6 +1,7 @@
|
|
|
1
|
-
import { docsManifestPages, docsRawPath
|
|
2
|
-
import { n as docsAgentPages, r as docsContentSource, t as docsAgentCopy } from "./agent-copy-
|
|
3
|
-
import { i as docsMarkdown, n as docsDocumentOf, r as docsImageSizes, t as createDocsParser } from "./markdown-
|
|
1
|
+
import { docsAppPath, docsManifestPages, docsRawPath } from "./navigation.js";
|
|
2
|
+
import { n as docsAgentPages, r as docsContentSource, t as docsAgentCopy } from "./agent-copy-xPaWye_g.js";
|
|
3
|
+
import { i as docsMarkdown, n as docsDocumentOf, r as docsImageSizes, t as createDocsParser } from "./markdown-1M1FbjCw.js";
|
|
4
|
+
import { n as readDocsFile } from "./files-UY4h1_36.js";
|
|
4
5
|
import "node:module";
|
|
5
6
|
import { defu } from "defu";
|
|
6
7
|
import { contentSource, defineContent } from "@vite-hub/content";
|
|
@@ -10,7 +11,6 @@ import { useRuntimeConfig } from "nitro/runtime-config";
|
|
|
10
11
|
import examples from "#docs/example-sources";
|
|
11
12
|
import imageSizes from "#docs/image-sizes";
|
|
12
13
|
import parser, { githubRepo } from "#docs/parser";
|
|
13
|
-
import files from "#docs/files";
|
|
14
14
|
//#region \0rolldown/runtime.js
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -37,39 +37,10 @@ const docsParserOptions = {
|
|
|
37
37
|
};
|
|
38
38
|
const parseDocsDocument = createDocsParser(docsParserOptions);
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region src/runtime/files.ts
|
|
41
|
-
const decoder = new TextDecoder();
|
|
42
|
-
let unpacked;
|
|
43
|
-
async function unpack(base64) {
|
|
44
|
-
const zlib = globalThis.process?.getBuiltinModule?.("node:zlib");
|
|
45
|
-
const buffer = globalThis.process?.getBuiltinModule?.("node:buffer");
|
|
46
|
-
if (zlib && buffer) {
|
|
47
|
-
const bytes = zlib.gunzipSync(buffer.Buffer.from(base64, "base64"));
|
|
48
|
-
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
49
|
-
}
|
|
50
|
-
const binary = atob(base64);
|
|
51
|
-
const gzip = new Uint8Array(binary.length);
|
|
52
|
-
for (let index = 0; index < binary.length; index++) gzip[index] = binary.charCodeAt(index);
|
|
53
|
-
return new Uint8Array(await new Response(new Response(gzip).body.pipeThrough(new DecompressionStream("gzip"))).arrayBuffer());
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* A Markdown file of a docs store: a content folder (`docs`, `docs-1`, ...) or the raw copies (`docs-raw`), or null.
|
|
57
|
-
* A production build packs every file into one module. Nitro server assets would add one module per file, and
|
|
58
|
-
* Cloudflare rejects a Worker upload with more than 5,000 modules. Development loads each file through Vite.
|
|
59
|
-
* Nitro gives no build warning for that limit (https://github.com/nitrojs/nitro/issues/5149).
|
|
60
|
-
*/
|
|
61
|
-
async function readDocsFile(store, file) {
|
|
62
|
-
if ("read" in files) return await files.read(store, file);
|
|
63
|
-
const ranges = Object.hasOwn(files.index, store) ? files.index[store] : void 0;
|
|
64
|
-
const range = ranges && Object.hasOwn(ranges, file) ? ranges[file] : void 0;
|
|
65
|
-
if (!range) return null;
|
|
66
|
-
const bytes = await (unpacked ??= unpack(files.packed));
|
|
67
|
-
return decoder.decode(bytes.subarray(range[0], range[1]));
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
40
|
//#region src/runtime/content.ts
|
|
71
41
|
var content_exports = /* @__PURE__ */ __exportAll({
|
|
72
42
|
docsContent: () => docsContent,
|
|
43
|
+
docsMarkdownContent: () => docsMarkdownContent,
|
|
73
44
|
readDocsPage: () => readDocsPage,
|
|
74
45
|
readDocsRawCopy: () => readDocsRawCopy
|
|
75
46
|
});
|
|
@@ -83,26 +54,65 @@ function bundledPages(base) {
|
|
|
83
54
|
};
|
|
84
55
|
}
|
|
85
56
|
let content;
|
|
57
|
+
let rawPages;
|
|
58
|
+
function docsRawPage(path) {
|
|
59
|
+
rawPages ??= new Map(docsManifestPages(manifest).map((page) => [docsRawPath(page.path), page]));
|
|
60
|
+
return rawPages.get(path);
|
|
61
|
+
}
|
|
62
|
+
function docsSiteUrl(config) {
|
|
63
|
+
return `${config.site.url}${config.appBase.replace(/\/+$/, "")}`;
|
|
64
|
+
}
|
|
86
65
|
/** The agent copy of a page from its file. The `rawMarkdown` option runs at build time, and the build keeps each page that it changed. */
|
|
87
66
|
async function docsPageCopy(page, text, siteUrl) {
|
|
88
67
|
const rewritten = await readDocsFile("docs-agent", `${docsContentSource(page)}/${page.file}`);
|
|
89
68
|
return docsAgentCopy(manifest, page, rewritten === null ? text : String(rewritten), siteUrl);
|
|
90
69
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* which costs a cold Worker about 250 ms on a large site. The manifest knows the file of each URL, so this reads the
|
|
94
|
-
* one file and renders it with the copy that Content serves in `llms-full.txt` and the MCP server.
|
|
95
|
-
*/
|
|
96
|
-
async function readDocsRawCopy(rawPath) {
|
|
97
|
-
const path = rawPath.replace(/^\/raw/, "").replace(/\.md$/, "");
|
|
98
|
-
const found = findDocsPage(manifest, path === "/index" ? "/" : path);
|
|
99
|
-
if (!found || docsRawPath(found.page.path) !== rawPath) return null;
|
|
100
|
-
const config = useRuntimeConfig().public.docs;
|
|
101
|
-
const text = await readDocsFile(found.page.source ?? "docs", found.page.file);
|
|
70
|
+
async function readDocsPageCopy(page) {
|
|
71
|
+
const text = await readDocsFile(page.source ?? "docs", page.file);
|
|
102
72
|
if (text === null) return null;
|
|
103
|
-
const copy = await docsPageCopy(
|
|
73
|
+
const copy = await docsPageCopy(page, text, docsSiteUrl(useRuntimeConfig().public.docs));
|
|
104
74
|
return `${copy.markdown}${copy.footer}`;
|
|
105
75
|
}
|
|
76
|
+
/** Read an exact manifest URL without listing or parsing the Content Sources. */
|
|
77
|
+
async function readDocsRawCopy(pathname) {
|
|
78
|
+
const prefix = docsAppPath("/raw/", useRuntimeConfig().public.docs.appBase);
|
|
79
|
+
if (!pathname.startsWith(prefix)) return null;
|
|
80
|
+
let rawPath;
|
|
81
|
+
try {
|
|
82
|
+
rawPath = `/raw/${decodeURIComponent(pathname.slice(prefix.length))}`;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (!(error instanceof URIError)) throw error;
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const page = docsRawPage(rawPath);
|
|
88
|
+
return page ? await readDocsPageCopy(page) : null;
|
|
89
|
+
}
|
|
90
|
+
/** Use the manifest for canonical Docs twins and Content for other page lookups. */
|
|
91
|
+
function docsMarkdownContent(raw = false) {
|
|
92
|
+
const runtime = docsContent();
|
|
93
|
+
const base = useRuntimeConfig().public.docs.appBase.replace(/\/+$/, "");
|
|
94
|
+
const relativePath = (path) => base && path.startsWith(`${base}/`) ? path.slice(base.length) : path;
|
|
95
|
+
function twin(path) {
|
|
96
|
+
const relative = relativePath(path);
|
|
97
|
+
try {
|
|
98
|
+
return docsRawPage(`/raw${decodeURI(relative)}`);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
if (!(error instanceof URIError)) throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
seo: runtime.seo,
|
|
105
|
+
async markdown(path, options) {
|
|
106
|
+
if (raw) return await readDocsRawCopy(path);
|
|
107
|
+
const page = twin(path);
|
|
108
|
+
return page ? await readDocsPageCopy(page) : await runtime.markdown(path, options);
|
|
109
|
+
},
|
|
110
|
+
async hasMarkdown(path) {
|
|
111
|
+
const page = twin(path);
|
|
112
|
+
return page ? await readDocsFile(page.source ?? "docs", page.file) !== null : await runtime.hasMarkdown(path);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
106
116
|
/**
|
|
107
117
|
* The docs pages as Content, parsed with the site's parser. The first read creates it. Each page has its URL from the
|
|
108
118
|
* manifest, so Content serves the agent files: the `/raw/<page>.md` copies, `llms.txt`, `llms-full.txt`, `sitemap.md`,
|
|
@@ -110,7 +120,7 @@ async function readDocsRawCopy(rawPath) {
|
|
|
110
120
|
*/
|
|
111
121
|
function docsContent() {
|
|
112
122
|
const config = useRuntimeConfig().public.docs;
|
|
113
|
-
const siteUrl =
|
|
123
|
+
const siteUrl = docsSiteUrl(config);
|
|
114
124
|
if (content?.siteUrl === siteUrl) return content.runtime;
|
|
115
125
|
const pages = docsAgentPages(manifest);
|
|
116
126
|
const assets = new Map(docsManifestPages(manifest).map((page) => [docsContentSource(page), page.source ?? "docs"]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { docsSectionForPath, findDocsPage, normalizeDocsPath } from "./navigation.js";
|
|
2
|
-
import { i as docsPageSchema, t as docsFrontmatter } from "./schema-
|
|
3
|
-
import { i as docsPageResponse, n as docsPageOf } from "./page-
|
|
2
|
+
import { i as docsPageSchema, t as docsFrontmatter } from "./schema-DcWZ3Q3M.js";
|
|
3
|
+
import { i as docsPageResponse, n as docsPageOf } from "./page-Bb0TfRKi.js";
|
|
4
4
|
//#region src/draft.ts
|
|
5
5
|
/**
|
|
6
6
|
* The draft of the page at `path`, parsed like a published page, or null when the request shows the published file.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { defineDiagnostics } from "nostics";
|
|
2
|
+
//#region src/error-diagnostics.ts
|
|
3
|
+
const docsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
4
|
+
docsBase: "https://vitehub.dev/docs/docs-site/diagnostics",
|
|
5
|
+
codes: {
|
|
6
|
+
DOCS_ASSISTANT_AGENTS_MISSING: {
|
|
7
|
+
why: ({ agent }) => `[@vite-hub/docs] docs.assistant needs ViteHub Agents to answer from the "${agent}" Agent.`,
|
|
8
|
+
fix: "Add `vite-hub/nuxt` to modules and set `vitehub: { agent: true, connections: true }` in nuxt.config.ts, or set `docs: { assistant: false }`."
|
|
9
|
+
},
|
|
10
|
+
DOCS_ASSISTANT_PAGE_MISSING: {
|
|
11
|
+
why: ({ path }) => `[@vite-hub/docs] The docs assistant's Workspace has no page at ${path}. The pages changed after the Workspace listed them.`,
|
|
12
|
+
fix: "Ask the question again. The next Invocation lists the current pages."
|
|
13
|
+
},
|
|
14
|
+
DOCS_BASE_EMPTY: {
|
|
15
|
+
why: ({ base, path }) => `[@vite-hub/docs] With docs.sources, the docs base defaults to ${base}. No page is at or below it, so pages such as ${path} render as standalone articles.`,
|
|
16
|
+
fix: "To show sections, set `docs: { base: '/' }` in nuxt.config.ts or mount the pages at `/docs`. To keep the pages standalone, set `docs: { base: '/docs' }`."
|
|
17
|
+
},
|
|
18
|
+
DOCS_COMMENTS_DATABASE_OFF: {
|
|
19
|
+
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which keeps threads in the Database, but vitehub sets database: false.",
|
|
20
|
+
fix: "Remove `database: false` from the `vitehub` options in nuxt.config.ts, or set `docs: { comments: false }`."
|
|
21
|
+
},
|
|
22
|
+
DOCS_COMMENTS_OFF_IGNORED: {
|
|
23
|
+
why: "[@vite-hub/docs] docs.comments is false, but the vitehub options turn Comments on, and they win. Comments stay on.",
|
|
24
|
+
fix: "Remove `comments: false` from the `docs` options in nuxt.config.ts. To turn Comments off, set `comments: false` in the `vitehub` options."
|
|
25
|
+
},
|
|
26
|
+
DOCS_COMMENTS_PACKAGE_MISSING: {
|
|
27
|
+
why: "[@vite-hub/docs] Docs sites on vite-hub/nuxt have Comments on, which needs @vite-hub/comments.",
|
|
28
|
+
fix: "Run `pnpm add @vite-hub/comments`, or set `docs: { comments: false }` in nuxt.config.ts."
|
|
29
|
+
},
|
|
30
|
+
DOCS_COMMENTS_VITEHUB_MISSING: {
|
|
31
|
+
why: "[@vite-hub/docs] docs.comments needs vite-hub/nuxt, which keeps the threads in a ViteHub Database.",
|
|
32
|
+
fix: "Add `vite-hub/nuxt` to modules in nuxt.config.ts, or set `docs: { comments: false }`."
|
|
33
|
+
},
|
|
34
|
+
DOCS_CONTENT_INVALID: {
|
|
35
|
+
why: ({ details, file }) => `Invalid docs frontmatter in ${file}: ${details}`,
|
|
36
|
+
fix: "Fix the field that the message names in the page frontmatter or the `.navigation.yml` file. The schemas are `docsPageSchema` and `docsSectionSchema` from `@vite-hub/docs`."
|
|
37
|
+
},
|
|
38
|
+
DOCS_EXAMPLE_MISSING: {
|
|
39
|
+
why: ({ name }) => `::example names "${name}", but the examples folder has no ${name}.vue.`,
|
|
40
|
+
fix: "Add the component that the message names to the examples folder of the docs, or correct the `name` of the `::example` block."
|
|
41
|
+
},
|
|
42
|
+
DOCS_LINKS_BROKEN: {
|
|
43
|
+
why: ({ problems }) => `Broken docs links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
44
|
+
fix: "Fix each link that the message lists in the page that it names, or add the target to `checkDocsLinks({ excludeLinks })` when it is served outside the docs output."
|
|
45
|
+
},
|
|
46
|
+
DOCS_OUTPUT_MISSING: {
|
|
47
|
+
why: ({ root }) => `Docs output does not exist: ${root}`,
|
|
48
|
+
fix: "Build the docs site first, or pass `checkDocsLinks({ dir })` the folder that the build writes."
|
|
49
|
+
},
|
|
50
|
+
DOCS_REDIRECTS_BROKEN: {
|
|
51
|
+
why: ({ problems }) => `Docs redirects break links:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
52
|
+
fix: "Point each redirect route rule that the message lists to a docs page, or remove the rule when the page that it hides still exists."
|
|
53
|
+
},
|
|
54
|
+
DOCS_RUNNABLE_CATALOG_VERSION_MISSING: {
|
|
55
|
+
why: ({ catalog, name }) => `[@vite-hub/docs] A fixture of docs.runnable uses catalog:, but the pnpm catalog "${catalog}" has no version of ${name}.`,
|
|
56
|
+
fix: "Set `docs.runnable.pnpmWorkspace` to the folder of pnpm-workspace.yaml, and add the package to the catalog that the specifier names."
|
|
57
|
+
},
|
|
58
|
+
DOCS_RUNNABLE_DEV_SERVER_MISSING: {
|
|
59
|
+
why: ({ fixture, name }) => `[@vite-hub/docs] The dev script of the fixture ${fixture} runs ${name}, but ${name} is in devDependencies. The snapshot of docs.runnable installs dependencies only, so the workspace cannot start.`,
|
|
60
|
+
fix: "Move the package that the message names from `devDependencies` to `dependencies` in the package.json of the fixture."
|
|
61
|
+
},
|
|
62
|
+
DOCS_RUNNABLE_FIXTURE_FILE_MISSING: {
|
|
63
|
+
why: ({ fixture, label, page }) => `[@vite-hub/docs] ${page} shows ${label}, but the fixture ${fixture} has no such file.`,
|
|
64
|
+
fix: "Add the file to the fixture folder, or correct the label of the code block in the lesson page."
|
|
65
|
+
},
|
|
66
|
+
DOCS_RUNNABLE_PACK_FAILED: {
|
|
67
|
+
why: ({ name }) => `[@vite-hub/docs] pnpm pack wrote no tarball for ${name}, so the snapshot of docs.runnable cannot install it.`,
|
|
68
|
+
fix: "Run `pnpm pack` in the folder of the package that the message names, and fix the error that it shows."
|
|
69
|
+
},
|
|
70
|
+
DOCS_RUNNABLE_PAGE_MISSING: {
|
|
71
|
+
why: ({ page }) => `[@vite-hub/docs] docs.runnable names the page ${page}, but the docs site has no page at that URL.`,
|
|
72
|
+
fix: "Set `page` of the lesson, or `docs.runnable.start`, to the URL of a docs page, such as `/docs/getting-started/first-agent`."
|
|
73
|
+
},
|
|
74
|
+
DOCS_RUNNABLE_STEPS_MISSING: {
|
|
75
|
+
why: ({ page }) => `[@vite-hub/docs] ${page} has no ::tutorial-step blocks, so docs.runnable cannot build its lesson.`,
|
|
76
|
+
fix: "Add `::tutorial-step{title=\"...\"}` blocks to the lesson page, or remove the lesson from `docs.runnable.lessons`."
|
|
77
|
+
},
|
|
78
|
+
DOCS_RUNNABLE_TITLE_MISSING: {
|
|
79
|
+
why: ({ block }) => `[@vite-hub/docs] A ::tutorial-step block has no title: ${block}`,
|
|
80
|
+
fix: "Give the block a title, such as `::tutorial-step{title=\"Add the route\"}`."
|
|
81
|
+
},
|
|
82
|
+
DOCS_RUNNABLE_WORKSPACE_PACKAGE_MISSING: {
|
|
83
|
+
why: ({ name }) => `[@vite-hub/docs] A fixture of docs.runnable uses workspace:, but the pnpm workspace has no package named ${name}.`,
|
|
84
|
+
fix: "Set `docs.runnable.pnpmWorkspace` to the folder of pnpm-workspace.yaml, and check that its `packages` patterns include the package."
|
|
85
|
+
},
|
|
86
|
+
DOCS_SEO_DESCRIPTION_INVALID: {
|
|
87
|
+
why: ({ problems }) => `Docs pages have no description, one of the wrong length, or the description of another page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
88
|
+
fix: "Set `description` in the frontmatter of each page that the message lists, with 70 to 160 characters, and give each page its own."
|
|
89
|
+
},
|
|
90
|
+
DOCS_SEO_FAILED: {
|
|
91
|
+
why: ({ problems }) => `Docs pages fail the search checks:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
92
|
+
fix: "Fix each page that the message lists, or set `docs: { seoAudit: \"warn\" }` to report them as hints in `.vitehub/hints.json` without stopping the build."
|
|
93
|
+
},
|
|
94
|
+
DOCS_SEO_HEADINGS_INVALID: {
|
|
95
|
+
why: ({ problems }) => `Docs pages have headings that search engines flag:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
96
|
+
fix: "Give each page that the message lists one `h1`, and go down one heading level at a time, such as `##` and then `###`."
|
|
97
|
+
},
|
|
98
|
+
DOCS_SEO_HTML_TOO_LARGE: {
|
|
99
|
+
why: ({ problems }) => `Docs pages have more HTML than the 2 MB that Googlebot reads:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
100
|
+
fix: "Split each page that the message lists, or show long lists with a component that renders less markup than a Markdown table."
|
|
101
|
+
},
|
|
102
|
+
DOCS_SEO_LINK_NOT_PAGE: {
|
|
103
|
+
why: ({ problems }) => `Docs pages link to a redirect or to an endpoint, not to a page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
104
|
+
fix: "Link to the page that the redirect goes to. Write the URL of an endpoint, such as `/mcp`, as code instead of a link."
|
|
105
|
+
},
|
|
106
|
+
DOCS_SEO_OPEN_GRAPH_INCOMPLETE: {
|
|
107
|
+
why: ({ problems }) => `Docs pages have incomplete Open Graph tags, so their share previews are incomplete:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
108
|
+
fix: "Set the head of each page that the message lists with `useDocsSeo()`. A page that writes its own head must set `og:title`, `og:type`, `og:image`, and `og:url`."
|
|
109
|
+
},
|
|
110
|
+
DOCS_SEO_PAGE_THIN: {
|
|
111
|
+
why: ({ problems }) => `Docs pages have fewer than 150 words, and site audits call them thin content:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
112
|
+
fix: "Write at least 150 words on each page that the message lists, or merge it into a related page."
|
|
113
|
+
},
|
|
114
|
+
DOCS_SEO_PAGE_UNLINKED: {
|
|
115
|
+
why: ({ problems }) => `No other page links to these docs pages, so crawlers find them only in the sitemap:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
116
|
+
fix: "Link each page that the message lists from the navigation, the footer, or a related page."
|
|
117
|
+
},
|
|
118
|
+
DOCS_SEO_SITEMAP_NOT_PAGE: {
|
|
119
|
+
why: ({ problems }) => `The sitemap lists URLs that are not prerendered pages:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
120
|
+
fix: "Remove each URL that the message lists from the sitemap, list the page that it redirects to, or make it a page."
|
|
121
|
+
},
|
|
122
|
+
DOCS_SEO_TITLE_INVALID: {
|
|
123
|
+
why: ({ problems }) => `Docs pages have no title, one of the wrong length, or the title of another page:\n${problems.map((problem) => `- ${problem}`).join("\n")}`,
|
|
124
|
+
fix: "Set `title` in the frontmatter of each page that the message lists, with 10 to 60 characters, and give each page its own. Use `seo.title` when the heading must stay."
|
|
125
|
+
},
|
|
126
|
+
DOCS_SOURCE_MOUNT_INVALID: {
|
|
127
|
+
why: ({ mount }) => `Invalid docs source mount: ${mount}`,
|
|
128
|
+
fix: "Set the `mount` of the docs source to a URL path such as `/guide`, without `.`, `..`, `?`, `#`, or backslash segments."
|
|
129
|
+
},
|
|
130
|
+
DOCS_WORKSPACE_DIR_MISSING: {
|
|
131
|
+
why: ({ dir, page }) => `The docs page ${page} runs the folder ${dir}, which does not exist.`,
|
|
132
|
+
fix: "Set `dir` of each example in `examples` to a folder of the app relative to the app root, or set `fixture` of a learn page to a folder in the `docs.runnable.fixtures` folder (`fixtures` by default)."
|
|
133
|
+
},
|
|
134
|
+
DOCS_WORKSPACE_ID_COLLISION: {
|
|
135
|
+
why: ({ id, owners }) => `${owners.join(" and ")} get the same workspace id ${id}, so their lessons, examples, or snapshots would overwrite each other.`,
|
|
136
|
+
fix: "Rename a page, or change the `slug` of a lesson or the `id` of an example in `docs.runnable`. A page's id is its path in lower case with each run of other characters as `-`, so `/docs/a/b` and `/docs/a-b` are both `docs-a-b`, and its examples are `<page id>--<example id>`. An example `kv` also takes the snapshot id `playground-kv`."
|
|
137
|
+
},
|
|
138
|
+
DOCS_WORKSPACE_READONLY_MISSING: {
|
|
139
|
+
why: ({ dir, example, page, path }) => `The example ${example} of the docs page ${page} marks ${path} read-only, but ${dir} has no text file at that path.`,
|
|
140
|
+
fix: "Set each path in `readonly` to a text file of the example's `dir`, relative to that folder, such as `model.ts`. Binary files, such as `weights.bin`, are never editable, so leave them out."
|
|
141
|
+
},
|
|
142
|
+
DOCS_WORKSPACE_RENDER_MISSING: {
|
|
143
|
+
why: ({ file, page }) => `The docs page ${page} renders with ${file}, which does not exist.`,
|
|
144
|
+
fix: "Set `render` to a module relative to the app root, such as `app/playground/render.ts`, whose default export takes the files and returns `{ html }`."
|
|
145
|
+
},
|
|
146
|
+
DOCS_WORKSPACE_TAB_MISSING: {
|
|
147
|
+
why: ({ file, page, tab }) => `The docs page ${page} has the tab \`${tab}\`, but ${file} does not exist.`,
|
|
148
|
+
fix: "Add the component that draws the tab, or remove the tab from `tabs`. The tab `messages` renders `app/components/playground/PlaygroundTabMessages.vue`, which reads the workspace with `useWorkspace()`."
|
|
149
|
+
},
|
|
150
|
+
DOCS_WORKSPACE_VITEHUB_MISSING: {
|
|
151
|
+
why: ({ pages }) => `[@vite-hub/docs] These pages run apps in a WebContainer, which needs vite-hub/nuxt for cross-origin isolation: ${pages.join(", ")}.`,
|
|
152
|
+
fix: "Add `vite-hub/nuxt` and `@vite-hub/web-container` to the app, or give each playground page a `render` module, which runs without a WebContainer."
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
//#endregion
|
|
157
|
+
export { docsErrorDiagnostics as t };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import files from "#docs/files";
|
|
2
|
+
//#region src/runtime/files.ts
|
|
3
|
+
const decoder = new TextDecoder();
|
|
4
|
+
let unpacked;
|
|
5
|
+
async function unpack(base64) {
|
|
6
|
+
const zlib = globalThis.process?.getBuiltinModule?.("node:zlib");
|
|
7
|
+
const buffer = globalThis.process?.getBuiltinModule?.("node:buffer");
|
|
8
|
+
if (zlib && buffer) {
|
|
9
|
+
const bytes = zlib.gunzipSync(buffer.Buffer.from(base64, "base64"));
|
|
10
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
11
|
+
}
|
|
12
|
+
const binary = atob(base64);
|
|
13
|
+
const gzip = new Uint8Array(binary.length);
|
|
14
|
+
for (let index = 0; index < binary.length; index++) gzip[index] = binary.charCodeAt(index);
|
|
15
|
+
return new Uint8Array(await new Response(new Response(gzip).body.pipeThrough(new DecompressionStream("gzip"))).arrayBuffer());
|
|
16
|
+
}
|
|
17
|
+
function packedFileRange(index, store, file) {
|
|
18
|
+
const ranges = Object.hasOwn(index, store) ? index[store] : void 0;
|
|
19
|
+
return ranges && Object.hasOwn(ranges, file) ? ranges[file] : void 0;
|
|
20
|
+
}
|
|
21
|
+
function hasDocsFile(store, file) {
|
|
22
|
+
return "read" in files ? files.has(store, file) : packedFileRange(files.index, store, file) !== void 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A Markdown file of a docs store: a content folder (`docs`, `docs-1`, ...) or the raw copies (`docs-raw`), or null.
|
|
26
|
+
* A production build packs every file into one module. Nitro server assets would add one module per file, and
|
|
27
|
+
* Cloudflare rejects a Worker upload with more than 5,000 modules. Development loads each file through Vite.
|
|
28
|
+
* Nitro gives no build warning for that limit (https://github.com/nitrojs/nitro/issues/5149).
|
|
29
|
+
*/
|
|
30
|
+
async function readDocsFile(store, file) {
|
|
31
|
+
if ("read" in files) return await files.read(store, file);
|
|
32
|
+
const range = packedFileRange(files.index, store, file);
|
|
33
|
+
if (!range) return null;
|
|
34
|
+
const bytes = await (unpacked ??= unpack(files.packed));
|
|
35
|
+
return decoder.decode(bytes.subarray(range[0], range[1]));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { readDocsFile as n, hasDocsFile as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { _ as docsPageFields, a as DocsSearchSection, b as expandDottedKeys, d as DocsPageFrontmatter, f as DocsPageNavigation, g as docsLayouts, h as DocsSectionFile, i as DocsPageWorkspace, l as DocsLayout, m as DocsPlaygroundTab, n as DocsManifest, o as DocsSection, p as DocsPlaygroundExample, r as DocsPage, s as DocsTocLink, t as DocsAppPage, u as DocsPageFile, v as docsPageSchema, y as docsSectionSchema } from "./types-CHU_fy9l.js";
|
|
2
|
+
import { t as DocsDocument } from "./markdown-BiKrT08O.js";
|
|
3
|
+
import { n as DocsPageResponse, t as DocsPageLink } from "./page-BryUCmYf.js";
|
|
4
|
+
import { a as DocsPublicConfig, d as DocsRunnableOptions, l as DocsRunnableExample, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions, u as DocsRunnableLesson } from "./nuxt-8O2OB_hI.js";
|
|
5
|
+
import { i as DocsSourceInput, r as DocsSource, t as DocsContentSource } from "./manifest-Drbdw1us.js";
|
|
6
|
+
import { DocsCatalogGroup, DocsGroup, DocsIcons, DocsLink, DocsMarkdownLinks, DocsPanelLoaders, DocsRailEntry, DocsSidebarGroup, DocsSidebarSection, DocsSidebarSectionBlock, docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
6
7
|
import { ContentLabel, DocumentsDefinition } from "@vite-hub/content";
|
|
7
8
|
//#region src/collection.d.ts
|
|
8
9
|
interface DocsCollectionOptions {
|
|
@@ -25,4 +26,4 @@ interface DocsCollectionOptions {
|
|
|
25
26
|
*/
|
|
26
27
|
export declare function docsCollection(options?: DocsCollectionOptions): DocumentsDefinition<typeof docsPageFields>;
|
|
27
28
|
//#endregion
|
|
28
|
-
export { type DocsAppPage, type DocsCatalogGroup, type DocsCollectionOptions, type DocsContentSource, type DocsDocument, type DocsGroup, type DocsIcons, type DocsLayout, type DocsLink, type DocsLogo, type DocsManifest, type DocsMarkdownLinks, type DocsModuleOptions, type DocsPage, type DocsPageFile, type DocsPageFrontmatter, type DocsPageLink, type DocsPageNavigation, type DocsPageResponse, type DocsPanelLoaders, type DocsPublicConfig, type DocsRailEntry, type DocsSearchSection, type DocsSection, type DocsSectionFile, type DocsSidebarGroup, type DocsSidebarSection, type DocsSidebarSectionBlock, type DocsSiteOptions, type DocsSource, type DocsSourceInput, type DocsStartOptions, type DocsTocLink, docsCatalog, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
|
|
29
|
+
export { type DocsAppPage, type DocsCatalogGroup, type DocsCollectionOptions, type DocsContentSource, type DocsDocument, type DocsGroup, type DocsIcons, type DocsLayout, type DocsLink, type DocsLogo, type DocsManifest, type DocsMarkdownLinks, type DocsModuleOptions, type DocsPage, type DocsPageFile, type DocsPageFrontmatter, type DocsPageLink, type DocsPageNavigation, type DocsPageResponse, type DocsPageWorkspace, type DocsPanelLoaders, type DocsPlaygroundExample, type DocsPlaygroundTab, type DocsPublicConfig, type DocsRailEntry, type DocsRunnableExample, type DocsRunnableLesson, type DocsRunnableOptions, type DocsSearchSection, type DocsSection, type DocsSectionFile, type DocsSidebarGroup, type DocsSidebarSection, type DocsSidebarSectionBlock, type DocsSiteOptions, type DocsSource, type DocsSourceInput, type DocsStartOptions, type DocsTocLink, docsCatalog, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
2
|
-
import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-
|
|
3
|
-
import { r as docsPagePath } from "./page-
|
|
1
|
+
import { docsCatalog, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageIcon, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
2
|
+
import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-DcWZ3Q3M.js";
|
|
3
|
+
import { r as docsPagePath } from "./page-Bb0TfRKi.js";
|
|
4
4
|
import { documents } from "@vite-hub/content/collections";
|
|
5
5
|
//#region src/collection.ts
|
|
6
6
|
/**
|
|
@@ -24,4 +24,4 @@ function docsCollection(options = {}) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
-
export { docsCatalog, docsCollection, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, normalizeDocsBase, normalizeDocsPath };
|
|
27
|
+
export { docsCatalog, docsCollection, docsLayouts, docsManifestPages, docsMarkdownLinks, docsMcpInstallLinks, docsPageFields, docsPageIcon, docsPageSchema, docsRailEntries, docsRailEntry, docsRailGroups, docsRailIcon, docsRawPath, docsRelatedSections, docsSectionForPath, docsSectionGroup, docsSectionIcon, docsSectionSchema, docsSidebarCollapses, docsSidebarGroups, docsSidebarSections, docsTutorialNavigationCookie, expandDottedKeys, findDocsPage, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { docsAppPath } from "./navigation.js";
|
|
2
|
-
import { r as docsRedirects } from "./redirects-
|
|
2
|
+
import { r as docsRedirects } from "./redirects-BJj58IsY.js";
|
|
3
3
|
import { defineNuxtModule } from "@nuxt/kit";
|
|
4
4
|
//#region src/link-checker-redirects.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as DocsSectionFile, n as DocsManifest } from "./types-CHU_fy9l.js";
|
|
2
2
|
import "nostics";
|
|
3
|
-
import { ContentRuntime } from "@vite-hub/content";
|
|
3
|
+
import { ContentCheckOptions, ContentRuntime } from "@vite-hub/content";
|
|
4
4
|
import { Source } from "@vite-hub/source";
|
|
5
5
|
//#region src/check-links.d.ts
|
|
6
6
|
interface DocsLinkCheckOptions {
|
|
@@ -67,7 +67,13 @@ interface DocsManifestOptions {
|
|
|
67
67
|
* One Content Source per docs source, with its Markdown pages and its `.navigation.yml` files as YAML documents. A
|
|
68
68
|
* folder is a `glob()` Source of those files. A Content Source, such as `github()`, is read as it is, from `rootDir`.
|
|
69
69
|
*/
|
|
70
|
-
declare function createDocsContent(sources: readonly Pick<ResolvedDocsSource, "dir" | "source">[], rootDir?: string): ContentRuntime;
|
|
70
|
+
declare function createDocsContent(sources: readonly Pick<ResolvedDocsSource, "dir" | "source">[], rootDir?: string, options?: DocsContentOptions): ContentRuntime;
|
|
71
|
+
/** What `createDocsContent()` adds for `content.check()`. */
|
|
72
|
+
interface DocsContentOptions {
|
|
73
|
+
/** The page URL of a document of the source at `index`, by its Content id, such as `guide/start`, or null for no page. */
|
|
74
|
+
url?: (index: number, id: string) => string | null;
|
|
75
|
+
check?: ContentCheckOptions;
|
|
76
|
+
}
|
|
71
77
|
/** Read every docs source through Content and compute sections, pages, and their order. */
|
|
72
78
|
declare function createDocsManifest(options: DocsManifestOptions): Promise<DocsManifest>;
|
|
73
79
|
//#endregion
|