@vite-hub/docs 0.7.0 → 0.9.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 +1 -1
- package/dist/{assistant-shared-JcfjK-qg.js → assistant-shared-BmCHVfEd.js} +0 -1
- package/dist/assistant-worker.js +1 -1
- package/dist/assistant.js +1 -1
- package/dist/{content-Chgcvz1q.js → content-Df5eeqTg.js} +1 -3
- package/dist/{draft-rOGhtXch.js → draft-CYScbH80.js} +1 -2
- package/dist/index.js +1 -1
- package/dist/{manifest-CQMreQZ5.js → manifest-BgBIScEV.js} +1 -17
- package/dist/{markdown-BzZkYb24.js → markdown-DgQg53dB.js} +0 -28
- package/dist/navigation.js +0 -2
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +5 -44
- package/dist/object-ycNFay7F.js +6 -0
- package/dist/primitive-rail.js +0 -4
- package/dist/runtime/app/assistant/DocsAssistant.vue +0 -3
- package/dist/runtime/app/assistant/DocsAssistantOff.vue +0 -2
- package/dist/runtime/app/assistant/DocsAssistantPanel.vue +0 -12
- package/dist/runtime/app/components/DocsAppShell.vue +0 -7
- package/dist/runtime/app/components/DocsArticle.vue +0 -8
- package/dist/runtime/app/components/DocsAsideFooter.vue +0 -5
- package/dist/runtime/app/components/DocsAsideLeftBody.vue +0 -18
- package/dist/runtime/app/components/DocsBrandMark.vue +0 -6
- package/dist/runtime/app/components/DocsCodePanel.vue +0 -19
- package/dist/runtime/app/components/DocsMarkdown.vue +0 -9
- package/dist/runtime/app/components/DocsPage.vue +0 -10
- package/dist/runtime/app/components/DocsPageCredits.vue +0 -1
- package/dist/runtime/app/components/DocsSidebars.vue +0 -8
- package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +0 -2
- package/dist/runtime/app/components/content/AgentOnly.vue +0 -1
- package/dist/runtime/app/components/content/CodeTree.vue +0 -6
- package/dist/runtime/app/components/content/ComarkHtml.vue +0 -9
- package/dist/runtime/app/components/content/Correct.vue +0 -1
- package/dist/runtime/app/components/content/Example.vue +0 -11
- package/dist/runtime/app/components/content/Examples.vue +0 -4
- package/dist/runtime/app/components/content/Incorrect.vue +0 -1
- package/dist/runtime/app/components/content/McpClient.vue +0 -5
- package/dist/runtime/app/components/content/McpInstall.vue +0 -4
- package/dist/runtime/app/components/content/PageList.vue +0 -11
- package/dist/runtime/app/components/content/ProductFeatureItem.vue +0 -3
- package/dist/runtime/app/components/content/ProductFeatures.vue +0 -3
- package/dist/runtime/app/composables/docs-assistant-problem.ts +0 -8
- package/dist/runtime/app/composables/docs-theme.ts +0 -6
- package/dist/runtime/app/composables/headerActions.ts +0 -1
- package/dist/runtime/app/composables/icons.ts +0 -1
- package/dist/runtime/app/composables/seo.ts +0 -11
- package/dist/runtime/app/composables/tutorial.ts +0 -8
- package/dist/runtime/app/composables/useDocsAssistant.ts +0 -2
- package/dist/runtime/app/error.vue +0 -4
- package/dist/runtime/app/layouts/docs.vue +0 -6
- package/dist/runtime/app/middleware/docs-layout.ts +0 -9
- package/dist/runtime/app/plugins/comark-css.ts +0 -5
- package/dist/runtime/app/plugins/icon-stroke.ts +0 -3
- package/dist/runtime/app/plugins/theme-color.ts +0 -5
- package/dist/runtime/app/utils/docs-theme.ts +0 -9
- package/dist/runtime/app/utils/file-tree.ts +0 -4
- package/dist/runtime/server/llms.js +1 -1
- package/dist/runtime/server/markdown.js +2 -7
- package/dist/runtime/server/mcp.js +1 -1
- package/dist/runtime/server/page.js +2 -2
- package/dist/runtime/server/raw.js +1 -1
- package/dist/runtime/server/search.js +2 -3
- package/dist/runtime/server/sitemap.js +1 -1
- package/dist/runtime/theme/design.css +1 -1
- package/dist/runtime/theme/vitehub.css +386 -0
- package/dist/{schema-CmSiwC4t.js → schema-fumnVoRZ.js} +1 -3
- package/dist/server.js +2 -2
- package/dist/snapshot-worker.mjs +0 -5
- package/dist/theme-DowEsyAx.js +516 -0
- package/dist/{theme-CgJRnVdT.d.ts → theme-aPbJMLsc.d.ts} +0 -6
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +1 -1
- package/package.json +12 -12
- package/dist/theme-DRktv19v.js +0 -235
package/README.md
CHANGED
|
@@ -459,7 +459,7 @@ Set `docs: { parser: "./docs.parser.ts" }`. The page route, search, and Console
|
|
|
459
459
|
|
|
460
460
|
### Design
|
|
461
461
|
|
|
462
|
-
The design follows the comark-ui site on top of the ViteHub design system (
|
|
462
|
+
The design follows the comark-ui site on top of the ViteHub design system (`runtime/theme/vitehub.css` and `vitehubTheme` in `src/vitehub-theme.ts`): Geist, neutral grays, hairline rings, 6px controls and 8px cards, one blue focus ring, a faint grain on the page, and GitHub code colors. On docs pages the sidebar holds the brand, search, a rail of sections or groups next to the page list, and a row at its foot with GitHub, the socials, and the color mode button. Other pages, and phones, get a header with the same parts. Text, code, and focus rings pass WCAG AA in light and dark mode. Change it in two places:
|
|
463
463
|
|
|
464
464
|
- `app.config.ts` `ui` keys. Your values win over the design. The design wins over the Nuxt UI defaults, also when `@nuxt/ui` comes first in `modules`.
|
|
465
465
|
- CSS variables in your stylesheet, such as `--vh-content-width` (prose width), `--vh-toc-width`, `--vh-panel-width`, `--vh-grain` (`none` turns the grain off), `--font-sans`, and the Nuxt UI `--ui-*` colors.
|
|
@@ -21,7 +21,6 @@ A page URL is its file path without \`pages\` and \`.md\`. An \`index.md\` file
|
|
|
21
21
|
- Do not change files. Do not run commands that do not read the pages.
|
|
22
22
|
|
|
23
23
|
{{{ instructions }}}`;
|
|
24
|
-
/** Page paths only: the value goes into the instructions, so it must not carry Markdown or template syntax. */
|
|
25
24
|
const pagePathPattern = /^\/[\w\-./~%]{0,299}$/;
|
|
26
25
|
/** Returns the page path from a chat request body, or an empty string when it is missing or not a plain path. */
|
|
27
26
|
function docsPageFromBody(body) {
|
package/dist/assistant-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as docsPageFromBody, i as docsPageContextKey, n as docsAssistantModel, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-
|
|
1
|
+
import { a as docsPageFromBody, i as docsPageContextKey, n as docsAssistantModel, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-BmCHVfEd.js";
|
|
2
2
|
import { workspaceShell } from "@vite-hub/agent/capabilities";
|
|
3
3
|
import { chatgpt } from "@vite-hub/gateways";
|
|
4
4
|
// src/assistant-worker.ts
|
package/dist/assistant.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as docsPageFromBody, i as docsPageContextKey, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-
|
|
1
|
+
import { a as docsPageFromBody, i as docsPageContextKey, o as docsRateLimit, r as docsInstructions, t as defineDocsAssistant } from "./assistant-shared-BmCHVfEd.js";
|
|
2
2
|
import { chatgpt } from "@vite-hub/gateways";
|
|
3
3
|
import { codexDriver } from "@vite-hub/agent";
|
|
4
4
|
// src/assistant.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as docsAgentPages, r as docsContentSource, t as docsAgentCopy } from "./agent-copy-DTCo8cLy.js";
|
|
2
|
-
import { i as docsMarkdown, n as docsDocumentOf, r as docsImageSizes, t as createDocsParser } from "./markdown-
|
|
2
|
+
import { i as docsMarkdown, n as docsDocumentOf, r as docsImageSizes, t as createDocsParser } from "./markdown-DgQg53dB.js";
|
|
3
3
|
import { docsAppPath, docsManifestPages, docsRawPath } from "./navigation.js";
|
|
4
4
|
import { n as readDocsFile } from "./files-BBoAGhhM.js";
|
|
5
5
|
import "node:module";
|
|
@@ -37,7 +37,6 @@ const docsParserOptions = {
|
|
|
37
37
|
const parseDocsDocument = createDocsParser(docsParserOptions);
|
|
38
38
|
// src/runtime/content.ts
|
|
39
39
|
var content_exports = /* @__PURE__ */ __exportAll({ docsMarkdownContent: () => docsMarkdownContent });
|
|
40
|
-
/** One docs folder as a Content Source, from the production bundle or development server assets. */
|
|
41
40
|
function bundledPages(base) {
|
|
42
41
|
const read = (key) => readDocsFile(base, key);
|
|
43
42
|
return {
|
|
@@ -55,7 +54,6 @@ function docsRawPage(path) {
|
|
|
55
54
|
function docsSiteUrl(config) {
|
|
56
55
|
return `${config.site.url}${config.appBase.replace(/\/+$/, "")}`;
|
|
57
56
|
}
|
|
58
|
-
/** 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. */
|
|
59
57
|
async function docsPageCopy(page, text, siteUrl) {
|
|
60
58
|
const rewritten = await readDocsFile("docs-agent", `${docsContentSource(page)}/${page.file}`);
|
|
61
59
|
return docsAgentCopy(manifest, page, rewritten === null ? text : String(rewritten), siteUrl, agent.report);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { docsSectionForPath, findDocsPage, normalizeDocsPath } from "./navigation.js";
|
|
2
2
|
import { i as docsPageResponse, n as docsPageOf } from "./page-DWsretqk.js";
|
|
3
|
-
import { i as docsPageSchema, t as docsFrontmatter } from "./schema-
|
|
3
|
+
import { i as docsPageSchema, t as docsFrontmatter } from "./schema-fumnVoRZ.js";
|
|
4
4
|
// 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.
|
|
@@ -35,7 +35,6 @@ async function readDraft(content, path) {
|
|
|
35
35
|
const found = await content.resolve(path);
|
|
36
36
|
return found ? await content.collection(found.collection).get(found.id) : null;
|
|
37
37
|
}
|
|
38
|
-
/** The id that the manifest gives a page at `path`: its path inside its section, `index` for an overview or the root. */
|
|
39
38
|
function pageId(manifest, path, section) {
|
|
40
39
|
if (path === manifest.root?.path) return "index";
|
|
41
40
|
if (!section) return "";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-
|
|
1
|
+
import { a as docsSectionSchema, i as docsPageSchema, n as docsLayouts, o as expandDottedKeys, r as docsPageFields } from "./schema-fumnVoRZ.js";
|
|
2
2
|
import { r as docsPagePath } from "./page-DWsretqk.js";
|
|
3
3
|
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";
|
|
4
4
|
import { documents } from "@vite-hub/content/collections";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { docsManifestPages, normalizeDocsBase } from "./navigation.js";
|
|
2
|
-
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-
|
|
2
|
+
import { a as docsSectionSchema, i as docsPageSchema, t as docsFrontmatter } from "./schema-fumnVoRZ.js";
|
|
3
3
|
import { n as docsPageOf, r as docsPagePath } from "./page-DWsretqk.js";
|
|
4
4
|
import { t as docsErrorDiagnostics } from "./error-diagnostics-Daz9oBJS.js";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
@@ -14,11 +14,6 @@ import yaml from "comark-content/plugins/yaml";
|
|
|
14
14
|
function docsLinkError(problems) {
|
|
15
15
|
return Object.assign(docsErrorDiagnostics.DOCS_LINKS_BROKEN({ problems }), { problems });
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Tests a value against paths, globs, and regular expressions. A site passes one path per page, and a large site checks
|
|
19
|
-
* thousands of links against them, so a plain path is a set lookup and only a pattern with glob characters, extglobs
|
|
20
|
-
* such as `@(a|b)` included, is a glob.
|
|
21
|
-
*/
|
|
22
17
|
function matcher(patterns) {
|
|
23
18
|
const paths = /* @__PURE__ */ new Set();
|
|
24
19
|
const tests = [];
|
|
@@ -175,7 +170,6 @@ function resolveDocsSources(inputs, rootDir = process.cwd()) {
|
|
|
175
170
|
};
|
|
176
171
|
});
|
|
177
172
|
}
|
|
178
|
-
/** A page whose frontmatter or section file does not match the schema: `DOCS_CONTENT_INVALID`. The build stops on it. */
|
|
179
173
|
function docsContentError(file, issues) {
|
|
180
174
|
const details = issues.map((issue) => `${issue.path.map(String).join(".") || "(root)"}: ${issue.message}`).join("; ");
|
|
181
175
|
return docsErrorDiagnostics.DOCS_CONTENT_INVALID({
|
|
@@ -205,11 +199,6 @@ function createDocsContent(sources, rootDir = process.cwd(), options = {}) {
|
|
|
205
199
|
}))
|
|
206
200
|
});
|
|
207
201
|
}
|
|
208
|
-
/**
|
|
209
|
-
* The pages and `.navigation.yml` files of each docs source, from `content.list()`. Content rejects two files of one
|
|
210
|
-
* Source with the same URL, such as `guide.md` and `guide/index.md`, with `CONTENT_R0003`, and lists no empty file.
|
|
211
|
-
* Empty files are read from the Source, so the manifest still names them in a `DOCS_CONTENT_INVALID` error.
|
|
212
|
-
*/
|
|
213
202
|
async function listDocsContent(content, sources) {
|
|
214
203
|
const files = [];
|
|
215
204
|
for (const [index, source] of sources.entries()) {
|
|
@@ -255,7 +244,6 @@ async function readDocsContent(options) {
|
|
|
255
244
|
function docsManifestOf(options, listed) {
|
|
256
245
|
const base = normalizeDocsBase(options.base);
|
|
257
246
|
const files = /* @__PURE__ */ new Map();
|
|
258
|
-
/** The `.navigation.yml` files of each logical folder, such as `docs/kv`, in source order. */
|
|
259
247
|
const folders = /* @__PURE__ */ new Map();
|
|
260
248
|
for (const entry of listed) {
|
|
261
249
|
const logical = joinPath(normalizeDocsBase(entry.source.mount ?? "/"), entry.file).slice(1);
|
|
@@ -356,11 +344,9 @@ function parse$2(file, schema, input) {
|
|
|
356
344
|
if (!result.success) throw docsContentError(file, result.error.issues);
|
|
357
345
|
return result.data;
|
|
358
346
|
}
|
|
359
|
-
/** `index.md` is the folder's page: `operations/index.md` is `operations`. */
|
|
360
347
|
function idOf(file) {
|
|
361
348
|
return file.replaceAll("\\", "/").replace(/\.md$/, "").replace(/(^|\/)index$/, "") || "index";
|
|
362
349
|
}
|
|
363
|
-
/** A page with only its `DocsAppPage` fields. */
|
|
364
350
|
function appPage(full) {
|
|
365
351
|
return {
|
|
366
352
|
id: full.id,
|
|
@@ -432,7 +418,6 @@ function docsAppManifest(manifest, options) {
|
|
|
432
418
|
panels
|
|
433
419
|
};
|
|
434
420
|
}
|
|
435
|
-
/** JSON of app pages. A `sourceTitle` equal to `title` is left out, and the module fills it back when it loads. */
|
|
436
421
|
function appJson(value) {
|
|
437
422
|
const json = JSON.stringify(value, (_key, field) => field && typeof field === "object" && "sourceTitle" in field && "title" in field && field.sourceTitle === field.title ? {
|
|
438
423
|
...field,
|
|
@@ -458,7 +443,6 @@ function docsAppPanelSource(panel) {
|
|
|
458
443
|
""
|
|
459
444
|
].join("\n");
|
|
460
445
|
}
|
|
461
|
-
/** With the base `/`, the section `guide` is `/guide`, not `//guide`. */
|
|
462
446
|
function joinPath(base, ...segments) {
|
|
463
447
|
return `${base.replace(/\/+$/, "")}/${segments.join("/")}`;
|
|
464
448
|
}
|
|
@@ -32,17 +32,6 @@ const themes = {
|
|
|
32
32
|
light: githubLight,
|
|
33
33
|
dark: githubDark
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
36
|
-
* The blocks of comark-ui: callouts, tabs, steps, code with its toolbar, zoomable images, charts, Mermaid diagrams,
|
|
37
|
-
* and the rest. The site's CSS styles the prose, so comark-ui's typeset is off. Chips are off too: they turn every web
|
|
38
|
-
* link into a chip and fetch its favicon. A site turns them on with `comarkUi: { chips: true }`. Kroki diagrams are
|
|
39
|
-
* off: they send each D2, PlantUML, or Graphviz fence to kroki.io while the page parses. Mermaid stays on, since
|
|
40
|
-
* comark-pele draws it in the process. Remove the Kroki override when comark-ui turns drawing off by default
|
|
41
|
-
* (https://github.com/onmax/comark-ui/issues/446).
|
|
42
|
-
*
|
|
43
|
-
* The plugins are the HTML preset's, so annotate, comments, diff, and quiz parse too, with the Vue preset's copy of
|
|
44
|
-
* every plugin the two share.
|
|
45
|
-
*/
|
|
46
35
|
function docsBlocks(options = {}) {
|
|
47
36
|
const merged = defu(options, {
|
|
48
37
|
typeset: false,
|
|
@@ -62,7 +51,6 @@ const htmlOnly = new Set(Object.keys(htmlBlocks).filter((tag) => !vueTags.has(ta
|
|
|
62
51
|
const drawsAsHtml = (node) => htmlOnly.has(node[0]) || node[0] === "chart" && Array.isArray(node[1].marks) && node[1].marks.length > 0;
|
|
63
52
|
const isElement = (node) => Array.isArray(node) && typeof node[0] === "string";
|
|
64
53
|
const phrasing = /^(?:p|h[1-6]|a|span|em|strong|del|s|mark|sup|sub|small|label)$/;
|
|
65
|
-
/** Draw the page's HTML-only blocks in one context, so styles, fonts, and scripts are emitted once. */
|
|
66
54
|
async function renderHtmlBlocks(nodes) {
|
|
67
55
|
const blocks = /* @__PURE__ */ new Map();
|
|
68
56
|
const visit = (nodes, from = 0, parent) => {
|
|
@@ -202,7 +190,6 @@ function docsImageSizes(sizes) {
|
|
|
202
190
|
post: (state) => visit(state.tree.nodes)
|
|
203
191
|
};
|
|
204
192
|
}
|
|
205
|
-
/** The last step of a page parse, after every plugin: list items without paragraphs, example anchors, and HTML-only blocks. */
|
|
206
193
|
const docsPageStep = {
|
|
207
194
|
name: "docs-page",
|
|
208
195
|
async post(state) {
|
|
@@ -241,17 +228,11 @@ const markdownLanguages = /* @__PURE__ */ new Set([
|
|
|
241
228
|
"mdc",
|
|
242
229
|
"comark"
|
|
243
230
|
]);
|
|
244
|
-
/** `::correct` and `::incorrect` are examples with a title. */
|
|
245
231
|
const defaultExampleTags = [
|
|
246
232
|
"example",
|
|
247
233
|
"correct",
|
|
248
234
|
"incorrect"
|
|
249
235
|
];
|
|
250
|
-
/**
|
|
251
|
-
* `::example` shows a preview and its source, a switch apart. Around a Markdown code block, the preview is that
|
|
252
|
-
* Markdown, parsed here with the page's own plugins. With `name`, it is the Vue file of that name in the examples
|
|
253
|
-
* folder, and its source becomes the code block. Either way the page reaches the browser as nodes.
|
|
254
|
-
*/
|
|
255
236
|
function examples(parse, sources, options) {
|
|
256
237
|
const exampleTags = new Set(options.tags ?? defaultExampleTags);
|
|
257
238
|
const visit = async (nodes) => {
|
|
@@ -296,7 +277,6 @@ function examples(parse, sources, options) {
|
|
|
296
277
|
post: (state) => visit(state.tree.nodes)
|
|
297
278
|
};
|
|
298
279
|
}
|
|
299
|
-
/** Preview anchors belong to their own document, including links to headings in that preview. */
|
|
300
280
|
function isolateExampleHeadings(nodes) {
|
|
301
281
|
const used = /* @__PURE__ */ new Set();
|
|
302
282
|
const walk = (nodes, visit, skipPreviews = false) => {
|
|
@@ -338,10 +318,6 @@ function isolateExampleHeadings(nodes) {
|
|
|
338
318
|
});
|
|
339
319
|
return rewrite(nodes);
|
|
340
320
|
}
|
|
341
|
-
/**
|
|
342
|
-
* A list item holds its text directly, also in a loose list with blank lines between items. The prose theme spaces
|
|
343
|
-
* list items itself, and a paragraph margin inside each item doubled that space.
|
|
344
|
-
*/
|
|
345
321
|
function unwrapListParagraphs(nodes, inListItem = false) {
|
|
346
322
|
return nodes.flatMap((node) => {
|
|
347
323
|
if (typeof node === "string" || node[0] === null) return [node];
|
|
@@ -357,10 +333,6 @@ function unwrapListParagraphs(nodes, inListItem = false) {
|
|
|
357
333
|
function tocOf(document) {
|
|
358
334
|
return Reflect.get(document.meta, "toc")?.links ?? [];
|
|
359
335
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Blocks that search skips: `::agent-only`, which the site does not render, an example's preview, which repeats its
|
|
362
|
-
* source, and the styles that comark-ui adds.
|
|
363
|
-
*/
|
|
364
336
|
const searchIgnore = [
|
|
365
337
|
"agent-only",
|
|
366
338
|
"example-preview",
|
package/dist/navigation.js
CHANGED
|
@@ -450,14 +450,12 @@ function docsMcpInstallLinks(server) {
|
|
|
450
450
|
}))}`
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
|
-
/** Words of a search text: lowercase letters and digits. `KV_INVALID_TTL` has the words `kv`, `invalid`, and `ttl`. */
|
|
454
453
|
function searchWords(text) {
|
|
455
454
|
return text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
456
455
|
}
|
|
457
456
|
function allowedTypos(word) {
|
|
458
457
|
return word.length < 4 ? 0 : word.length < 8 ? 1 : 2;
|
|
459
458
|
}
|
|
460
|
-
/** Edit distance with swapped neighbors as one edit, so "chatgtp" is one edit from "chatgpt". Stops early past `max`. */
|
|
461
459
|
function editDistance(left, right, max) {
|
|
462
460
|
if (Math.abs(left.length - right.length) > max) return max + 1;
|
|
463
461
|
let before = [];
|
package/dist/nuxt.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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-B0kdfz6P.js";
|
|
2
|
-
import { a as DocsThemeScope } from "./theme-
|
|
2
|
+
import { a as DocsThemeScope } from "./theme-aPbJMLsc.js";
|
|
3
3
|
export { type DocsCommentsOptions, DocsLlmsOptions, DocsLogo, DocsModuleOptions, DocsNuxtModule, DocsPublicConfig, type DocsRunnableExample, type DocsRunnableLesson, type DocsRunnableOptions, DocsSiteOptions, DocsStartOptions, type DocsThemeScope, docsNuxtModule as default };
|
package/dist/nuxt.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { a as vitehubTheme, i as docsThemeScope, n as docsThemeAdditions, r as docsUi, t as docsAppConfigUi } from "./theme-DowEsyAx.js";
|
|
1
2
|
import { t as docsErrorDiagnostics } from "./error-diagnostics-Daz9oBJS.js";
|
|
2
3
|
import { t as dependencyKey } from "./steps-muDP1nYT.js";
|
|
3
|
-
import {
|
|
4
|
+
import { t as isRecord } from "./object-ycNFay7F.js";
|
|
5
|
+
import { a as docsAppManifestSource, c as resolveDocsSources, d as docsLinkExclusion, f as docsOutputFile, i as docsAppManifest, l as checkDocsLinks, n as createDocsContent, o as docsAppPanelSource, s as readDocsContent, t as contentName, u as docsLinkError } from "./manifest-BgBIScEV.js";
|
|
4
6
|
import { docsAppPath, docsIndexedPages, docsManifestPages, docsPageIcon, docsPageIndexed, docsRailIcon, docsRawPath, docsSectionIcon, isDocsPath, isDocsWorkspaceLayout, normalizeDocsBase, normalizeDocsPath } from "./navigation.js";
|
|
5
7
|
import { a as replacesDocsPage, o as routePaths, t as docsMount } from "./page-DWsretqk.js";
|
|
6
8
|
import { a as docsReportUrl, i as docsReportDetails, r as docsContentSource } from "./agent-copy-DTCo8cLy.js";
|
|
7
9
|
import { i as docsServerRoutes, n as docsRedirectProblems, r as docsRedirects, t as docsRedirectError } from "./redirects-BEFu4KLR.js";
|
|
8
|
-
import { i as docsThemeScope, n as docsThemeAdditions, r as docsUi, t as docsAppConfigUi } from "./theme-DRktv19v.js";
|
|
9
10
|
import { createRequire } from "node:module";
|
|
10
11
|
import { addComponent, addComponentsDir, addImportsDir, addPlugin, addRouteMiddleware, addServerHandler, addTemplate, addTypeTemplate, createResolver, defineNuxtModule, extendPages, updateTemplates, useLogger } from "@nuxt/kit";
|
|
11
12
|
import { addRoute, createRouter, findAllRoutes, routeToRegExp } from "rou3";
|
|
@@ -17,7 +18,6 @@ import { fileURLToPath } from "node:url";
|
|
|
17
18
|
import { basename, dirname, isAbsolute, join, matchesGlob, parse, posix, relative, resolve, sep } from "node:path";
|
|
18
19
|
import { tmpdir } from "node:os";
|
|
19
20
|
import { findContentEntry } from "@vite-hub/source/vite";
|
|
20
|
-
import { vitehubTheme } from "@vite-hub/ui/theme";
|
|
21
21
|
import { sizeOf } from "comark-zoom/size";
|
|
22
22
|
import { defu } from "defu";
|
|
23
23
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
@@ -156,7 +156,7 @@ function findPackageDir(file) {
|
|
|
156
156
|
function ownModule(importMetaUrl, modulePath) {
|
|
157
157
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
158
158
|
}
|
|
159
|
-
// ../internal/dist/vite-
|
|
159
|
+
// ../internal/dist/vite-C-_n6FDw.js
|
|
160
160
|
const projectRootDirectoryMarkers = [
|
|
161
161
|
["server", "agents"],
|
|
162
162
|
["server", "channels"],
|
|
@@ -238,10 +238,6 @@ const runs = shared[runsKey] ??= /* @__PURE__ */ new Map();
|
|
|
238
238
|
const startedKey = Symbol.for("vitehub.hints.started");
|
|
239
239
|
const startedShared = globalThis;
|
|
240
240
|
const started = startedShared[startedKey] ??= /* @__PURE__ */ new WeakSet();
|
|
241
|
-
/**
|
|
242
|
-
* The report of the ViteHub project root, where the other generated files go. A Nuxt app with `srcDir: "app"` has its
|
|
243
|
-
* Vite root in `app/`, one folder below.
|
|
244
|
-
*/
|
|
245
241
|
function hintsFile(config) {
|
|
246
242
|
const projectRoot = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
247
243
|
return resolve(typeof projectRoot === "string" ? projectRoot : resolveViteHubProjectRoot(config.root), viteHubHintsFile);
|
|
@@ -303,7 +299,6 @@ function startViteHubHints(config, owner = config) {
|
|
|
303
299
|
write(startRun(config));
|
|
304
300
|
}
|
|
305
301
|
// src/module-options.ts
|
|
306
|
-
/** The module name: a string entry, or the `getMeta()` name of an imported module function. */
|
|
307
302
|
async function moduleName(module) {
|
|
308
303
|
if (typeof module !== "function") return module;
|
|
309
304
|
const getMeta = Reflect.get(module, "getMeta");
|
|
@@ -359,7 +354,6 @@ function setupDocsAssistant(nuxt, config) {
|
|
|
359
354
|
});
|
|
360
355
|
}
|
|
361
356
|
// src/comments-nuxt.ts
|
|
362
|
-
/** Whether the app can import `name`, as `vite-hub` resolves its optional peers. */
|
|
363
357
|
function installed(name, rootDir) {
|
|
364
358
|
try {
|
|
365
359
|
createRequire(join(rootDir, "package.json")).resolve(`${name}/package.json`);
|
|
@@ -921,7 +915,6 @@ function snapshotSources(tutorials, examples, templates) {
|
|
|
921
915
|
}
|
|
922
916
|
// src/runnable/snapshots.ts
|
|
923
917
|
const SNAPSHOT_CONCURRENCY = 3;
|
|
924
|
-
/** Runs `snapshot-worker.mjs` and returns its stdout. Its warnings, such as an updated lockfile, go to stderr. */
|
|
925
918
|
function runSnapshotWorker(args) {
|
|
926
919
|
return new Promise((resolvePromise, reject) => {
|
|
927
920
|
const child = spawn(process.execPath, [resolve(import.meta.dirname, "snapshot-worker.mjs"), ...args], { stdio: [
|
|
@@ -941,7 +934,6 @@ function runSnapshotWorker(args) {
|
|
|
941
934
|
function tutorialLockfile(fixturesDir, fixture) {
|
|
942
935
|
return resolve(fixturesDir, `${fixture}.package-lock.json`);
|
|
943
936
|
}
|
|
944
|
-
const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
945
937
|
const stringRecord = (value) => isRecord(value) ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : {};
|
|
946
938
|
/** The fields of a `package.json` that a snapshot reads. Other values, and invalid JSON, read as empty. */
|
|
947
939
|
function readManifest(source) {
|
|
@@ -971,7 +963,6 @@ function devServerInDevDependencies(manifest) {
|
|
|
971
963
|
const command = manifest.scripts.dev?.trim().split(/\s+/)[0];
|
|
972
964
|
return command && command in manifest.devDependencies && !(command in manifest.dependencies) ? command : void 0;
|
|
973
965
|
}
|
|
974
|
-
/** The output line of `snapshot-worker.mjs`. */
|
|
975
966
|
function readWorkerResult(stdout) {
|
|
976
967
|
const result = JSON.parse(stdout.trim().split("\n").at(-1) ?? "");
|
|
977
968
|
if (isRecord(result) && Array.isArray(result.files) && result.files.every((file) => typeof file === "string") && typeof result.sha256 === "string" && typeof result.bytes === "number" && typeof result.compressed === "number") return {
|
|
@@ -1218,7 +1209,6 @@ async function buildTutorialSnapshots(input) {
|
|
|
1218
1209
|
return snapshots;
|
|
1219
1210
|
}
|
|
1220
1211
|
// src/runnable/nuxt.ts
|
|
1221
|
-
/** Where Nitro serves the snapshot parts, under the app base. */
|
|
1222
1212
|
const baseURL = "/_tutorials";
|
|
1223
1213
|
/**
|
|
1224
1214
|
* Runnable lessons and playground examples.
|
|
@@ -1458,7 +1448,6 @@ function docsContentSeoLocation(result, pages, appBase) {
|
|
|
1458
1448
|
}) : message;
|
|
1459
1449
|
};
|
|
1460
1450
|
}
|
|
1461
|
-
/** `docs/guide.md:12: <message> (CONTENT_R0062)`. */
|
|
1462
1451
|
function problem(finding) {
|
|
1463
1452
|
return `${finding.line === null ? finding.path : `${finding.path}:${finding.line}`}: ${finding.message} (${finding.code})`;
|
|
1464
1453
|
}
|
|
@@ -1471,7 +1460,6 @@ function docsAppPageLinks(routes) {
|
|
|
1471
1460
|
return [...new Set(routePaths(routes).filter((path) => !/\(\.\*\)\*?|\*$/.test(path)).map((path) => path.replace(/:\w+(?:\([^)]*\))?\??/g, "*") || "/"))];
|
|
1472
1461
|
}
|
|
1473
1462
|
// src/files.ts
|
|
1474
|
-
/** The Markdown files of a folder, without dot files or dot folders, as Nitro's server assets list them. */
|
|
1475
1463
|
function markdownFiles(dir) {
|
|
1476
1464
|
if (!existsSync(dir)) return [];
|
|
1477
1465
|
return readdirSync(dir, {
|
|
@@ -1479,10 +1467,6 @@ function markdownFiles(dir) {
|
|
|
1479
1467
|
withFileTypes: true
|
|
1480
1468
|
}).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => relative(dir, join(entry.parentPath, entry.name)).split(sep).join("/")).filter((file) => !file.split("/").some((part) => part.startsWith("."))).sort();
|
|
1481
1469
|
}
|
|
1482
|
-
/**
|
|
1483
|
-
* Packs the Markdown files of every store into one gzip stream. `order` lists `[store, file]` pairs to put first. Gzip
|
|
1484
|
-
* finds repeats only in the last 32 KB, so a page next to its raw copy packs a third smaller than the two folders apart.
|
|
1485
|
-
*/
|
|
1486
1470
|
function packDocsFiles(stores, order = []) {
|
|
1487
1471
|
const files = new Map(stores.map((store) => [store.name, new Map(markdownFiles(store.dir).map((file) => [file, join(store.dir, file)]))]));
|
|
1488
1472
|
const sequence = [];
|
|
@@ -1691,7 +1675,6 @@ function attribute(tag, name) {
|
|
|
1691
1675
|
const value = tag.match(new RegExp(`\\s${name}=(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
|
1692
1676
|
return value ? decode(value[1] ?? value[2] ?? value[3] ?? "") : void 0;
|
|
1693
1677
|
}
|
|
1694
|
-
/** The app path of a link, without the app base, or `null` for a link that leaves the site. */
|
|
1695
1678
|
function appPath(href, from, origin) {
|
|
1696
1679
|
if (!href || /^(?:[a-z][a-z\d+.-]*:(?!\/\/)|#)/i.test(href)) return null;
|
|
1697
1680
|
const site = new URL(origin || "http://docs.invalid");
|
|
@@ -2420,7 +2403,7 @@ const docsNuxtModule = defineNuxtModule({
|
|
|
2420
2403
|
const getContents = ui?.getContents;
|
|
2421
2404
|
if (ui && getContents) ui.getContents = async (data) => `${await getContents(data)}\n${cssSources}\n`;
|
|
2422
2405
|
});
|
|
2423
|
-
const sharedTheme =
|
|
2406
|
+
const sharedTheme = join(runtime, "theme/vitehub.css");
|
|
2424
2407
|
const scopedTheme = ownsApp ? null : addTemplate({
|
|
2425
2408
|
filename: "docs/theme.css",
|
|
2426
2409
|
write: true,
|
|
@@ -2768,7 +2751,6 @@ const docsNuxtModule = defineNuxtModule({
|
|
|
2768
2751
|
}]);
|
|
2769
2752
|
}
|
|
2770
2753
|
});
|
|
2771
|
-
/** Match Nitro's prerender policy, including the Console exclusions installed by vite-hub/nuxt. */
|
|
2772
2754
|
function docsRuntimePath(nitro, appBase, mount) {
|
|
2773
2755
|
const routes = createRouter();
|
|
2774
2756
|
for (const [path, rule] of Object.entries(nitro.routeRules ?? {})) addRoute(routes, void 0, path, rule);
|
|
@@ -2786,7 +2768,6 @@ function docsRuntimePath(nitro, appBase, mount) {
|
|
|
2786
2768
|
return findAllRoutes(routes, void 0, appPath).reverse().find((route) => route.data.prerender !== void 0)?.data.prerender === false;
|
|
2787
2769
|
};
|
|
2788
2770
|
}
|
|
2789
|
-
/** Icons of the shell components. The icons of the theme come from `vitehubTheme`. */
|
|
2790
2771
|
const shellIcons = [
|
|
2791
2772
|
"i-lucide-arrow-left",
|
|
2792
2773
|
"i-lucide-arrow-right",
|
|
@@ -2822,17 +2803,11 @@ const shellIcons = [
|
|
|
2822
2803
|
"i-vscode-icons-file-type-vue",
|
|
2823
2804
|
"i-vscode-icons-file-type-yaml"
|
|
2824
2805
|
];
|
|
2825
|
-
/** An icon name in Markdown, such as `i-lucide-sun`. A name that is no icon is dropped when @nuxt/icon cannot resolve it. */
|
|
2826
2806
|
const markdownIconName = /(?<![\w-])i-[a-z0-9]+(?:-[a-z0-9]+)+/g;
|
|
2827
|
-
/**
|
|
2828
|
-
* `i-lucide-sun` as @nuxt/icon bundles it: `lucide:sun`. Collection names with one hyphen end in `-icons`, such as
|
|
2829
|
-
* `simple-icons`. Rail icon names such as `kv` are not Iconify names and return `null`.
|
|
2830
|
-
*/
|
|
2831
2807
|
function iconifyName(icon) {
|
|
2832
2808
|
const match = /^i-([a-z0-9]+(?:-icons)?)-(.+)$/.exec(icon);
|
|
2833
2809
|
return match ? `${match[1]}:${match[2]}` : icon.includes(":") ? icon : null;
|
|
2834
2810
|
}
|
|
2835
|
-
/** The head of every page of a docs site. */
|
|
2836
2811
|
function setDocsHead(head, siteName) {
|
|
2837
2812
|
const meta = head.meta ??= [];
|
|
2838
2813
|
const viewport = meta.find((tag) => tag.name === "viewport");
|
|
@@ -2856,7 +2831,6 @@ function setDocsHead(head, siteName) {
|
|
|
2856
2831
|
head.titleTemplate ??= `%s · ${siteName}`;
|
|
2857
2832
|
}
|
|
2858
2833
|
const pictures = /\.(?:avif|gif|jpe?g|png|svg|webp)$/i;
|
|
2859
|
-
/** The size of each picture in the folders, by its URL path, such as `/screenshots/console.png`. The first folder wins. */
|
|
2860
2834
|
async function publicImageSizes(dirs) {
|
|
2861
2835
|
const sizes = {};
|
|
2862
2836
|
for (const dir of dirs) {
|
|
@@ -2870,18 +2844,15 @@ async function publicImageSizes(dirs) {
|
|
|
2870
2844
|
}
|
|
2871
2845
|
return sizes;
|
|
2872
2846
|
}
|
|
2873
|
-
/** Whether a layer has an `app.vue`, as Nuxt looks for it: `app` or `App` with any Nuxt extension. */
|
|
2874
2847
|
function hasAppComponent(srcDirs, extensions) {
|
|
2875
2848
|
return srcDirs.some((dir) => ["app", "App"].some((name) => extensions.some((extension) => existsSync(join(dir, `${name}${extension}`)))));
|
|
2876
2849
|
}
|
|
2877
|
-
/** The docs pages need Nuxt UI's `<UApp>` and a `<NuxtLayout>` in the app's own `app.vue`. Say so when one is missing. */
|
|
2878
2850
|
function warnAppComponent(file) {
|
|
2879
2851
|
if (!existsSync(file)) return;
|
|
2880
2852
|
const source = readFileSync(file, "utf8");
|
|
2881
2853
|
const missing = [/<(UApp|u-app)\b/.test(source) ? null : "`<UApp>`, which Nuxt UI needs for search, tooltips, and menus", /<(NuxtLayout|nuxt-layout)\b/.test(source) ? null : "`<NuxtLayout>`, which draws the docs navigation"].filter(Boolean);
|
|
2882
2854
|
if (missing.length) useLogger("@vite-hub/docs").warn(`${file} has no ${missing.join(", and no ")}. Wrap \`<NuxtPage />\` in both, or remove app.vue to use the docs one.`);
|
|
2883
2855
|
}
|
|
2884
|
-
/** Whether a stylesheet of the app imports Nuxt UI, and so starts a Tailwind build of its own. */
|
|
2885
2856
|
function importsNuxtUi(css, alias, docsCss) {
|
|
2886
2857
|
return css.some((entry) => {
|
|
2887
2858
|
const src = typeof entry === "string" ? entry : entry.src;
|
|
@@ -2891,15 +2862,12 @@ function importsNuxtUi(css, alias, docsCss) {
|
|
|
2891
2862
|
return existsSync(file) && /@import\s+["']@nuxt\/ui["']/.test(readFileSync(file, "utf8"));
|
|
2892
2863
|
});
|
|
2893
2864
|
}
|
|
2894
|
-
/** A module that this package depends on, by file path, so Nuxt finds it and transpiles its runtime. */
|
|
2895
2865
|
function dependency(name) {
|
|
2896
2866
|
return fileURLToPath(import.meta.resolve(name));
|
|
2897
2867
|
}
|
|
2898
|
-
/** The ESM proxy of `mocked-exports`, from the copy that nuxt-og-image depends on. */
|
|
2899
2868
|
function mockedExportsProxy() {
|
|
2900
2869
|
return createRequire(dependency("nuxt-og-image")).resolve("mocked-exports/proxy-mjs");
|
|
2901
2870
|
}
|
|
2902
|
-
/** The file a CSS `@import "<name>"` loads: the package's `style` export. */
|
|
2903
2871
|
function stylesheet(name) {
|
|
2904
2872
|
let root = dirname(fileURLToPath(import.meta.resolve(name)));
|
|
2905
2873
|
while (!existsSync(join(root, "package.json")) || JSON.parse(readFileSync(join(root, "package.json"), "utf8")).name !== name) {
|
|
@@ -2992,13 +2960,6 @@ function publicConfig(options, base, appBase) {
|
|
|
2992
2960
|
ogImage: options.ogImage === false ? false : { component: options.ogImage?.component ?? "DocsPage" }
|
|
2993
2961
|
};
|
|
2994
2962
|
}
|
|
2995
|
-
/**
|
|
2996
|
-
* comark-ui's `style.css` for the page to link, and the names to mark the link with. A comark-ui component adds its
|
|
2997
|
-
* styles on mount unless the page has a `link` or `style` with `data-comark-<name>`. The file holds the styles of every
|
|
2998
|
-
* comark-* package comark-ui depends on, the Mermaid wrapper's, and the issues box's. comark-time's component still adds
|
|
2999
|
-
* its own, since they hold a query the file leaves out. The file names the layer order first, the same as the app's CSS,
|
|
3000
|
-
* so it can load before or after it.
|
|
3001
|
-
*/
|
|
3002
2963
|
function comarkStylesheet() {
|
|
3003
2964
|
const layers = "@layer theme, base, kit, comark, components, utilities;";
|
|
3004
2965
|
const require = createRequire(import.meta.url);
|
package/dist/primitive-rail.js
CHANGED
|
@@ -208,10 +208,6 @@ label: {
|
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
-
/**
|
|
212
|
-
* Scrolls the rail body the least amount that shows the whole item, with no animation.
|
|
213
|
-
* It changes only the rail's own scroll position, never the page scroll.
|
|
214
|
-
*/
|
|
215
211
|
function revealInRail(item) {
|
|
216
212
|
const body = item.closest(".vh-primitive-rail__body");
|
|
217
213
|
if (!body) return;
|
|
@@ -6,19 +6,16 @@ import { defineShortcuts } from "#imports"
|
|
|
6
6
|
import { useDocsAssistant } from "../composables/useDocsAssistant"
|
|
7
7
|
|
|
8
8
|
const { agent, open, toggle } = useDocsAssistant()
|
|
9
|
-
// Mount the panel on first open and keep it, so closing it keeps the conversation.
|
|
10
9
|
const mounted = ref(open.value)
|
|
11
10
|
watch(open, (value) => {
|
|
12
11
|
if (value) mounted.value = true
|
|
13
12
|
})
|
|
14
13
|
|
|
15
|
-
// `defineShortcuts` reads `meta` as Command on macOS and as Ctrl elsewhere. The attribute names the same key.
|
|
16
14
|
const shortcut = ref("Control+I")
|
|
17
15
|
onMounted(() => {
|
|
18
16
|
if (/Macintosh;/.test(navigator.userAgent)) shortcut.value = "Meta+I"
|
|
19
17
|
})
|
|
20
18
|
|
|
21
|
-
// The shortcut also works in the composer, so it closes the panel that it opened.
|
|
22
19
|
defineShortcuts({ meta_i: { usingInput: true, handler: () => agent.value && toggle() } })
|
|
23
20
|
</script>
|
|
24
21
|
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { defineComponent } from "vue"
|
|
4
4
|
|
|
5
|
-
// Not a template with only a comment: production builds drop the comment, so the server renders nothing while the
|
|
6
|
-
// browser renders an empty placeholder, and every page fails hydration. A render function gives both the placeholder.
|
|
7
5
|
export default defineComponent({ name: "DocsAssistantOff", render: () => null })
|
|
8
6
|
</script>
|
|
@@ -21,18 +21,15 @@ const route = useRoute()
|
|
|
21
21
|
const chat = useChat({ name: props.agent })
|
|
22
22
|
const draft = ref("")
|
|
23
23
|
const problem = computed(() => chat.error.value ? docsAssistantProblem(chat.error.value, window.location.origin) : undefined)
|
|
24
|
-
// The server reads the page path from the request body and adds it to the Agent instructions.
|
|
25
24
|
const requestBody = () => ({ body: { page: route.path, appBase } })
|
|
26
25
|
const reducedMotion = usePreferredReducedMotion()
|
|
27
26
|
const headingId = useId()
|
|
28
27
|
const [DefineBody, ReuseBody] = createReusableTemplate()
|
|
29
28
|
|
|
30
|
-
// From `lg` the panel is a column beside the page. Narrower screens get a modal sheet above the sticky site header.
|
|
31
29
|
const wide = window.matchMedia("(min-width: 80rem)")
|
|
32
30
|
const docked = ref(wide.matches)
|
|
33
31
|
useEventListener(wide, "change", () => { docked.value = wide.matches })
|
|
34
32
|
|
|
35
|
-
// The width is in pixels: 20rem to 36rem at the default font size, and never more than half the window.
|
|
36
33
|
const minWidth = 320
|
|
37
34
|
const maxWidth = 576
|
|
38
35
|
const defaultWidth = 384
|
|
@@ -41,7 +38,6 @@ const clampWidth = (value: number) => Number.isFinite(value) ? Math.round(Math.m
|
|
|
41
38
|
const width = ref(clampWidth(Number(widthCookie.value)))
|
|
42
39
|
const resizing = ref(false)
|
|
43
40
|
|
|
44
|
-
// The docked column is fixed, so the page needs padding on the right to keep its content clear of it.
|
|
45
41
|
watchEffect(() => {
|
|
46
42
|
const root = document.documentElement
|
|
47
43
|
if (open.value && docked.value) {
|
|
@@ -90,8 +86,6 @@ function resizeWithKeys(event: KeyboardEvent) {
|
|
|
90
86
|
saveWidth(width.value + step)
|
|
91
87
|
}
|
|
92
88
|
|
|
93
|
-
// The phone keyboard shrinks the visual viewport but not the layout viewport, so the sheet follows the visual one and
|
|
94
|
-
// the composer stays above the keyboard.
|
|
95
89
|
const viewport = ref<{ top: number, height: number }>()
|
|
96
90
|
function readViewport() {
|
|
97
91
|
const visual = window.visualViewport
|
|
@@ -104,30 +98,25 @@ const sheetStyle = computed(() => viewport.value ? { top: `${viewport.value.top}
|
|
|
104
98
|
const heading = ref<HTMLElement>()
|
|
105
99
|
const composer = ref<HTMLTextAreaElement>()
|
|
106
100
|
|
|
107
|
-
/** Whether the device has only coarse pointers. There, Enter adds a line and the Send button sends. */
|
|
108
101
|
function touchOnly(): boolean {
|
|
109
102
|
return window.matchMedia("(pointer: coarse)").matches && !window.matchMedia("(any-pointer: fine)").matches
|
|
110
103
|
}
|
|
111
104
|
|
|
112
|
-
// PromptInput puts its attributes on the form, so the panel finds the textarea to focus it.
|
|
113
105
|
function composerRef(target: Element | ComponentPublicInstance | null) {
|
|
114
106
|
const element = target && "$el" in target ? target.$el : target
|
|
115
107
|
composer.value = element instanceof HTMLElement ? element.querySelector("textarea") ?? undefined : undefined
|
|
116
108
|
}
|
|
117
109
|
|
|
118
|
-
// A focused composer opens the on-screen keyboard over half the sheet, so touch devices focus the heading instead.
|
|
119
110
|
function focusInside() {
|
|
120
111
|
if (touchOnly()) heading.value?.focus()
|
|
121
112
|
else composer.value?.focus()
|
|
122
113
|
}
|
|
123
114
|
|
|
124
|
-
// Closing returns focus to the control that opened the panel, or to the Ask button after a keyboard shortcut.
|
|
125
115
|
let returnTo: HTMLElement | undefined
|
|
126
116
|
watch(open, async (value) => {
|
|
127
117
|
if (value) {
|
|
128
118
|
const active = document.activeElement
|
|
129
119
|
returnTo = active instanceof HTMLElement && active !== document.body && !active.closest("#docs-assistant") ? active : undefined
|
|
130
|
-
// The sheet focuses through `onOpenAutoFocus`, once its content is in the page.
|
|
131
120
|
if (docked.value) {
|
|
132
121
|
await nextTick()
|
|
133
122
|
focusInside()
|
|
@@ -145,7 +134,6 @@ const sheetContent = computed(() => ({
|
|
|
145
134
|
event.preventDefault()
|
|
146
135
|
focusInside()
|
|
147
136
|
},
|
|
148
|
-
// The `open` watcher moves focus.
|
|
149
137
|
onCloseAutoFocus: (event: Event) => event.preventDefault(),
|
|
150
138
|
}))
|
|
151
139
|
|
|
@@ -6,7 +6,6 @@ import design from "#docs/theme"
|
|
|
6
6
|
import { resolveDocsTheme } from "../utils/docs-theme"
|
|
7
7
|
|
|
8
8
|
const props = defineProps<{
|
|
9
|
-
/** Set by the docs layouts. They draw the shell only in an app with its own `app.vue`, where the docs `app.vue` does not. */
|
|
10
9
|
layout?: boolean
|
|
11
10
|
}>()
|
|
12
11
|
|
|
@@ -17,22 +16,16 @@ const { site, appBase } = useDocsConfig()
|
|
|
17
16
|
const appConfig = useAppConfig()
|
|
18
17
|
const theme = computed(() => resolveDocsTheme(design, appConfig.ui))
|
|
19
18
|
|
|
20
|
-
// The same URL that the sitemap lists and that a trailing slash redirects to.
|
|
21
19
|
const canonical = () => docsCanonicalUrl(site.url, route.path, appBase)
|
|
22
20
|
|
|
23
21
|
if (active) {
|
|
24
22
|
useHead({
|
|
25
|
-
// One title pattern for every page: "KV configuration · ViteHub". A title that already names the site stays as written.
|
|
26
|
-
// The check ignores case and punctuation, so "Comark UI" counts as naming `comark-ui`.
|
|
27
23
|
titleTemplate: title => !title ? site.name : words(title).includes(words(site.name)) ? title : `${title} · ${site.name}`,
|
|
28
24
|
link: site.url ? [{ rel: "canonical", href: canonical }] : [],
|
|
29
|
-
// In an app with its own `app.vue`, the app's head stays on its pages, and the docs pages add what they need.
|
|
30
25
|
meta: ownsApp ? [] : [{ name: "viewport", content: "width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" }],
|
|
31
|
-
// The theme's CSS applies below `.vh-docs`. A docs site sets it on every page in its head config.
|
|
32
26
|
htmlAttrs: ownsApp ? {} : { class: "vh-docs" },
|
|
33
27
|
})
|
|
34
28
|
|
|
35
|
-
// Open Graph needs `og:url` and `og:type` besides the title and image, or share previews and site audits call it incomplete.
|
|
36
29
|
useSeoMeta({
|
|
37
30
|
ogSiteName: site.name,
|
|
38
31
|
ogType: "website",
|