@vite-hub/docs 0.3.1 → 0.4.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.
Files changed (42) hide show
  1. package/README.md +15 -13
  2. package/dist/{agent-copy-BJp_Yf5d.js → agent-copy-xPaWye_g.js} +1 -1
  3. package/dist/assistant-pages-BN7hNsSZ.js +37 -0
  4. package/dist/{assistant-shared-Dll_F_yy.d.ts → assistant-shared-CWIKRtBv.d.ts} +3 -2
  5. package/dist/{assistant-shared-CdtXowot.js → assistant-shared-WzButktj.js} +23 -7
  6. package/dist/assistant-worker.d.ts +1 -1
  7. package/dist/assistant-worker.js +1 -1
  8. package/dist/assistant.d.ts +1 -1
  9. package/dist/assistant.js +1 -1
  10. package/dist/{content-9CINWiRf.js → content-CPZGnn3S.js} +3 -33
  11. package/dist/{draft-DUBx--r9.js → draft-BjWmaiLn.js} +1 -1
  12. package/dist/error-diagnostics-B_ZOy7kF.js +93 -0
  13. package/dist/files-UY4h1_36.js +38 -0
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +1 -1
  16. package/dist/link-checker-redirects.js +1 -1
  17. package/dist/{manifest-Dzp5-_AJ.d.ts → manifest-CMoxcwPm.d.ts} +8 -2
  18. package/dist/{manifest-D66AEF8F.js → manifest-ZdxLrcvt.js} +47 -33
  19. package/dist/{markdown-Cn9-4oVG.js → markdown-DUWnEMPp.js} +1 -1
  20. package/dist/navigation.d.ts +1 -2
  21. package/dist/navigation.js +1 -2
  22. package/dist/{nuxt-B5LrERKc.d.ts → nuxt-CAGpKl_-.d.ts} +5 -4
  23. package/dist/nuxt.d.ts +1 -1
  24. package/dist/nuxt.js +465 -82
  25. package/dist/{page-BbmSfZO8.js → page-GPt09oex.js} +2 -1
  26. package/dist/primitive-rail.d.ts +1 -1
  27. package/dist/primitive-rail.js +7 -2
  28. package/dist/{raw-C03EUJKw.js → raw-BChwipz_.js} +6 -0
  29. package/dist/{redirects-BrbWFSzW.js → redirects-CmR1yu5A.js} +18 -6
  30. package/dist/runtime/app/components/content/McpClient.vue +170 -0
  31. package/dist/runtime/app/components/content/McpInstall.vue +238 -0
  32. package/dist/runtime/server/llms.js +1 -1
  33. package/dist/runtime/server/markdown.js +1 -1
  34. package/dist/runtime/server/mcp.js +1 -1
  35. package/dist/runtime/server/page.js +3 -3
  36. package/dist/runtime/server/raw.js +1 -1
  37. package/dist/runtime/server/search.js +2 -2
  38. package/dist/runtime/server/sitemap.js +1 -1
  39. package/dist/server.d.ts +1 -1
  40. package/dist/server.js +4 -4
  41. package/package.json +11 -11
  42. package/dist/error-diagnostics-BoOsP6Y4.js +0 -53
@@ -1,12 +1,12 @@
1
1
  import { docsManifestPages, docsPanelOf, docsPanelPages, normalizeDocsBase } from "./navigation.js";
2
2
  import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-DwpXW0VZ.js";
3
- import { n as docsPageOf, r as docsPagePath } from "./page-BbmSfZO8.js";
4
- import { t as docsErrorDiagnostics } from "./error-diagnostics-BoOsP6Y4.js";
3
+ import { n as docsPageOf, r as docsPagePath } from "./page-GPt09oex.js";
4
+ import { t as docsErrorDiagnostics } from "./error-diagnostics-B_ZOy7kF.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 { createSource, glob } from "@vite-hub/source";
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,29 @@ 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
+ function docsOutputFile(dir, base = "/") {
40
+ const root = resolve(dir);
41
+ const appBase = `/${base.replace(/^\/+|\/+$/g, "")}`.replace(/\/$/, "");
42
+ return (pathname) => {
43
+ if (appBase && pathname !== appBase && !pathname.startsWith(`${appBase}/`)) return;
44
+ let path;
45
+ try {
46
+ path = decodeURIComponent(pathname.slice(appBase.length));
47
+ } catch {
48
+ return;
49
+ }
50
+ const page = path.replace(/\/$/, "");
51
+ return [
52
+ path,
53
+ `${page}.html`,
54
+ `${page}/index.html`
55
+ ].map((candidate) => resolve(root, `.${candidate.startsWith("/") ? candidate : `/${candidate}`}`)).find((file) => file.startsWith(`${root}${sep}`) && existsSync(file) && statSync(file).isFile());
56
+ };
57
+ }
35
58
  /** Check built HTML against the files and fragment ids in the same output, without fetching remote URLs. */
36
59
  function checkDocsLinks(options) {
37
60
  const root = resolve(options.dir);
@@ -39,7 +62,7 @@ function checkDocsLinks(options) {
39
62
  const origin = new URL(options.siteUrl).origin;
40
63
  const appBase = `/${(options.appBase ?? "/").replace(/^\/+|\/+$/g, "")}`.replace(/\/$/, "");
41
64
  const excludedPage = matcher(options.excludePages);
42
- const excludedLink = matcher(options.excludeLinks);
65
+ const excludedLink = docsLinkExclusion(options.excludeLinks);
43
66
  const ignoredFragment = matcher(options.ignoreFragments);
44
67
  const cache = /* @__PURE__ */ new Map();
45
68
  const document = (file) => {
@@ -49,7 +72,7 @@ function checkDocsLinks(options) {
49
72
  ids: /* @__PURE__ */ new Set(),
50
73
  links: []
51
74
  };
52
- walkSync(parse(readFileSync(file, "utf8")), (node) => {
75
+ walkSync(parse$1(readFileSync(file, "utf8")), (node) => {
53
76
  if (node.type !== ELEMENT_NODE) return;
54
77
  for (const key of ["id", "name"]) if (node.attributes[key]) result.ids.add(decode(node.attributes[key]));
55
78
  if (node.name === "base" && node.attributes.href && !result.base) result.base = decode(node.attributes.href);
@@ -59,21 +82,7 @@ function checkDocsLinks(options) {
59
82
  cache.set(file, result);
60
83
  return result;
61
84
  };
62
- const fileOf = (pathname) => {
63
- if (appBase && pathname !== appBase && !pathname.startsWith(`${appBase}/`)) return;
64
- let path;
65
- try {
66
- path = decodeURIComponent(pathname.slice(appBase.length));
67
- } catch {
68
- return;
69
- }
70
- const page = path.replace(/\/$/, "");
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
- };
85
+ const fileOf = docsOutputFile(root, appBase);
77
86
  const files = readdirSync(root, {
78
87
  recursive: true,
79
88
  withFileTypes: true
@@ -95,7 +104,7 @@ function checkDocsLinks(options) {
95
104
  problems.add(`${path} has an invalid URL: ${link}`);
96
105
  continue;
97
106
  }
98
- if (url.origin !== origin || excludedLink(link) || excludedLink(url.pathname) || excludedLink(url.pathname + url.hash)) continue;
107
+ if (url.origin !== origin || excludedLink(url, link)) continue;
99
108
  const redirect = options.redirect?.(url);
100
109
  if (redirect) {
101
110
  problems.add(`${path} links to ${url.pathname}${url.hash}, which redirects to ${redirect}`);
@@ -168,15 +177,20 @@ const contentName = (index) => `docs_${index}`;
168
177
  * One Content Source per docs source, with its Markdown pages and its `.navigation.yml` files as YAML documents. A
169
178
  * folder is a `glob()` Source of those files. A Content Source, such as `github()`, is read as it is, from `rootDir`.
170
179
  */
171
- function createDocsContent(sources, rootDir = process.cwd()) {
180
+ function createDocsContent(sources, rootDir = process.cwd(), options = {}) {
172
181
  return defineContent({
173
182
  route: false,
174
183
  live: false,
175
184
  plugins: [yaml({ onError: "throw" })],
176
- sources: Object.fromEntries(sources.map(({ dir, source }, index) => [contentName(index), source ? () => createSource(source, { rootDir }) : dir && existsSync(dir) ? () => createSource(glob({
177
- include: ["**/*.md", "**/.navigation.yml"],
178
- dot: true
179
- }), { rootDir: dir }) : { items: async () => [] }]))
185
+ ...options.check ? { check: options.check } : {},
186
+ sources: Object.fromEntries(sources.map(({ dir, source }, index) => {
187
+ const input = source ? () => useSource(source, { rootDir }) : dir && existsSync(dir) ? () => useSource(glob({
188
+ include: ["**/*.md", "**/.navigation.yml"],
189
+ dot: true
190
+ }), { rootDir: dir }) : { items: async () => [] };
191
+ const url = options.url;
192
+ return [contentName(index), url ? contentSource(input, { url: ({ id }) => url(index, id) }) : input];
193
+ }))
180
194
  });
181
195
  }
182
196
  /**
@@ -253,7 +267,7 @@ function docsManifestOf(options, listed) {
253
267
  markdown: entry.markdown ?? ""
254
268
  }) : entry.data;
255
269
  return {
256
- ...docsPageOf(parse$1(entry.label, docsPageSchema, docsFrontmatter(fields)), {
270
+ ...docsPageOf(parse$2(entry.label, docsPageSchema, docsFrontmatter(fields)), {
257
271
  id,
258
272
  path,
259
273
  file: entry.file
@@ -272,9 +286,9 @@ function docsManifestOf(options, listed) {
272
286
  let fields = {};
273
287
  for (const file of folders.get(sectionPrefix.slice(0, -1)) ?? []) fields = {
274
288
  ...fields,
275
- ...parse$1(file.label, docsSectionSchema, file.data)
289
+ ...parse$2(file.label, docsSectionSchema, file.data)
276
290
  };
277
- const navigation = parse$1(id, docsSectionSchema, {
291
+ const navigation = parse$2(id, docsSectionSchema, {
278
292
  ...fields,
279
293
  ...options.sections?.[id]
280
294
  });
@@ -311,7 +325,7 @@ function docsManifestOf(options, listed) {
311
325
  }
312
326
  return manifest;
313
327
  }
314
- function parse$1(file, schema, input) {
328
+ function parse$2(file, schema, input) {
315
329
  const result = schema.safeParse(input);
316
330
  if (!result.success) throw docsContentError(file, result.error.issues);
317
331
  return result.data;
@@ -417,4 +431,4 @@ function titleCase(input) {
417
431
  return input.split(/[-/]/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
418
432
  }
419
433
  //#endregion
420
- export { docsAppPanelSource as a, checkDocsLinks as c, docsAppManifestSource as i, createDocsManifest as n, readDocsContent as o, docsAppManifest as r, resolveDocsSources as s, createDocsContent as t };
434
+ 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-BoOsP6Y4.js";
1
+ import { t as docsErrorDiagnostics } from "./error-diagnostics-B_ZOy7kF.js";
2
2
  import { defu } from "defu";
3
3
  import { ELEMENT_NODE, parse, walkSync } from "ultrahtml";
4
4
  import { contentSearchSections } from "@vite-hub/content";
@@ -228,8 +228,7 @@ export declare function docsRailIcon(icons: DocsIcons, section: Pick<DocsSection
228
228
  /**
229
229
  * Draws a 2px line icon with `stroke` instead. @nuxt/icon passes only the icon body in its CSS mode, so the icon is
230
230
  * 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. Not reported upstream yet (fix branch:
232
- * https://github.com/onmax/icon/tree/fix/customize-name-css-mode).
231
+ * stroke and stay as they are.
233
232
  */
234
233
  export declare function docsIconStroke(body: string, stroke: number): string;
235
234
  /** URL of the raw Markdown twin of a page path, such as `/raw/docs/kv.md`. `/` has `/raw/index.md`. */
@@ -340,8 +340,7 @@ function docsRailIcon(icons, section) {
340
340
  /**
341
341
  * Draws a 2px line icon with `stroke` instead. @nuxt/icon passes only the icon body in its CSS mode, so the icon is
342
342
  * 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. Not reported upstream yet (fix branch:
344
- * https://github.com/onmax/icon/tree/fix/customize-name-css-mode).
343
+ * stroke and stay as they are.
345
344
  */
346
345
  function docsIconStroke(body, stroke) {
347
346
  if (!body.includes("stroke-linejoin=\"round\"")) return body;
@@ -1,5 +1,5 @@
1
1
  import { d as DocsSectionFile, r as DocsPage } from "./types-BhG6vGfG.js";
2
- import { i as DocsSourceInput, s as DocsLinkCheckOptions } from "./manifest-Dzp5-_AJ.js";
2
+ import { i as DocsSourceInput, s as DocsLinkCheckOptions } from "./manifest-CMoxcwPm.js";
3
3
  import { DocsGroup, DocsIcons, DocsLink } from "./navigation.js";
4
4
  import { ContentLlmsSection } from "@vite-hub/content";
5
5
  import { PublicRuntimeConfig } from "nuxt/schema";
@@ -49,8 +49,8 @@ interface DocsModuleOptions {
49
49
  dir?: string;
50
50
  /**
51
51
  * 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 app-owned
53
- * docsAssistant Workspace is configured separately.
52
+ * `github({ repo, root })` from `vite-hub/source`, or `{ source, mount?, exclude?, frontmatter? }`. The docs assistant
53
+ * reads the same pages.
54
54
  */
55
55
  sources?: DocsSourceInput[];
56
56
  /** Section metadata overrides, keyed by section id. */
@@ -114,7 +114,8 @@ interface DocsModuleOptions {
114
114
  * Checks every prerendered page as a site audit does: a sitemap URL that is not a prerendered page, a missing or
115
115
  * duplicate title or description, a title outside 10 to 60 characters or a description outside 70 to 160, not exactly
116
116
  * 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, logs the problems. `"error"` or `true` stops the
117
+ * or a canonical link to another page are left out. `"warn"`, the default, reports one hint for each kind of problem,
118
+ * such as `DOCS_SEO_TITLE_INVALID`, in the build output and in `.vitehub/hints.json`. `"error"` or `true` stops the
118
119
  * build with `DOCS_SEO_FAILED`. `false` turns the check off.
119
120
  */
120
121
  seoAudit?: "warn" | "error" | boolean;
package/dist/nuxt.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as DocsPublicConfig, c as docsNuxtModule, i as DocsNuxtModule, l as DocsCommentsOptions, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions, t as DocsLlmsOptions } from "./nuxt-B5LrERKc.js";
1
+ import { a as DocsPublicConfig, c as docsNuxtModule, i as DocsNuxtModule, l as DocsCommentsOptions, n as DocsLogo, o as DocsSiteOptions, r as DocsModuleOptions, s as DocsStartOptions, t as DocsLlmsOptions } from "./nuxt-CAGpKl_-.js";
2
2
  import { a as DocsThemeScope } from "./theme-BXyu4uFL.js";
3
3
  export { type DocsCommentsOptions, DocsLlmsOptions, DocsLogo, DocsModuleOptions, DocsNuxtModule, DocsPublicConfig, DocsSiteOptions, DocsStartOptions, type DocsThemeScope, docsNuxtModule as default };