@vite-hub/docs 0.0.0 → 0.3.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 (111) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +454 -0
  3. package/dist/agent-copy-BJp_Yf5d.js +33 -0
  4. package/dist/assistant-shared-CdtXowot.js +97 -0
  5. package/dist/assistant-shared-Dll_F_yy.d.ts +27 -0
  6. package/dist/assistant-worker.d.ts +11 -0
  7. package/dist/assistant-worker.js +16 -0
  8. package/dist/assistant.d.ts +14 -0
  9. package/dist/assistant.js +19 -0
  10. package/dist/content-9CINWiRf.js +171 -0
  11. package/dist/draft-DUBx--r9.js +45 -0
  12. package/dist/error-diagnostics-BoOsP6Y4.js +53 -0
  13. package/dist/index.d.ts +28 -0
  14. package/dist/index.js +27 -0
  15. package/dist/link-checker-redirects.d.ts +13 -0
  16. package/dist/link-checker-redirects.js +25 -0
  17. package/dist/manifest-D66AEF8F.js +420 -0
  18. package/dist/manifest-Dzp5-_AJ.d.ts +74 -0
  19. package/dist/markdown-Cn9-4oVG.js +378 -0
  20. package/dist/navigation.d.ts +284 -0
  21. package/dist/navigation.js +520 -0
  22. package/dist/nuxt-B5LrERKc.d.ts +240 -0
  23. package/dist/nuxt.d.ts +3 -0
  24. package/dist/nuxt.js +1485 -0
  25. package/dist/page-BbmSfZO8.js +81 -0
  26. package/dist/page-Dx2JD3y1.d.ts +74 -0
  27. package/dist/primitive-rail.d.ts +110 -0
  28. package/dist/primitive-rail.js +284 -0
  29. package/dist/raw-C03EUJKw.js +851 -0
  30. package/dist/redirects-BrbWFSzW.js +62 -0
  31. package/dist/runtime/app/app.vue +11 -0
  32. package/dist/runtime/app/assistant/DocsAssistant.vue +81 -0
  33. package/dist/runtime/app/assistant/DocsAssistantOff.vue +8 -0
  34. package/dist/runtime/app/assistant/DocsAssistantPanel.vue +322 -0
  35. package/dist/runtime/app/components/AppHeader.vue +368 -0
  36. package/dist/runtime/app/components/AppSearch.vue +68 -0
  37. package/dist/runtime/app/components/DocsAppShell.vue +62 -0
  38. package/dist/runtime/app/components/DocsArticle.vue +184 -0
  39. package/dist/runtime/app/components/DocsAsideFooter.vue +94 -0
  40. package/dist/runtime/app/components/DocsAsideLeftBody.vue +584 -0
  41. package/dist/runtime/app/components/DocsAsideLeftTop.vue +132 -0
  42. package/dist/runtime/app/components/DocsBrandMark.vue +52 -0
  43. package/dist/runtime/app/components/DocsCatalogFooter.vue +129 -0
  44. package/dist/runtime/app/components/DocsCodePanel.vue +388 -0
  45. package/dist/runtime/app/components/DocsCodePre.vue +120 -0
  46. package/dist/runtime/app/components/DocsHeaderActions.vue +4 -0
  47. package/dist/runtime/app/components/DocsLanding.vue +83 -0
  48. package/dist/runtime/app/components/DocsMarkdown.vue +64 -0
  49. package/dist/runtime/app/components/DocsPage.vue +149 -0
  50. package/dist/runtime/app/components/DocsPageCredits.vue +41 -0
  51. package/dist/runtime/app/components/DocsPageHeaderLinks.vue +120 -0
  52. package/dist/runtime/app/components/DocsRail.vue +239 -0
  53. package/dist/runtime/app/components/DocsSidebarStrip.vue +81 -0
  54. package/dist/runtime/app/components/DocsSidebars.vue +63 -0
  55. package/dist/runtime/app/components/OgImage/DocsPage.takumi.vue +33 -0
  56. package/dist/runtime/app/components/content/AgentOnly.vue +9 -0
  57. package/dist/runtime/app/components/content/CodeTree.vue +203 -0
  58. package/dist/runtime/app/components/content/ComarkHtml.vue +31 -0
  59. package/dist/runtime/app/components/content/Correct.vue +17 -0
  60. package/dist/runtime/app/components/content/Example.vue +260 -0
  61. package/dist/runtime/app/components/content/ExamplePreview.vue +6 -0
  62. package/dist/runtime/app/components/content/Examples.vue +71 -0
  63. package/dist/runtime/app/components/content/Incorrect.vue +17 -0
  64. package/dist/runtime/app/components/content/PageList.vue +206 -0
  65. package/dist/runtime/app/components/content/ProductFeatureItem.vue +43 -0
  66. package/dist/runtime/app/components/content/ProductFeatures.vue +17 -0
  67. package/dist/runtime/app/components/content/TutorialStep.vue +39 -0
  68. package/dist/runtime/app/composables/docs-assistant-problem.ts +59 -0
  69. package/dist/runtime/app/composables/docs-theme.ts +15 -0
  70. package/dist/runtime/app/composables/docs.ts +83 -0
  71. package/dist/runtime/app/composables/headerActions.ts +6 -0
  72. package/dist/runtime/app/composables/icons.ts +14 -0
  73. package/dist/runtime/app/composables/seo.ts +64 -0
  74. package/dist/runtime/app/composables/tutorial.ts +40 -0
  75. package/dist/runtime/app/composables/useDocsAssistant.ts +17 -0
  76. package/dist/runtime/app/error.vue +88 -0
  77. package/dist/runtime/app/layouts/default.vue +7 -0
  78. package/dist/runtime/app/layouts/docs.vue +104 -0
  79. package/dist/runtime/app/middleware/docs-layout.ts +23 -0
  80. package/dist/runtime/app/pages/docs-page.vue +3 -0
  81. package/dist/runtime/app/plugins/comark-css.ts +14 -0
  82. package/dist/runtime/app/plugins/icon-stroke.ts +12 -0
  83. package/dist/runtime/app/plugins/theme-color.ts +18 -0
  84. package/dist/runtime/app/utils/docs-theme.ts +43 -0
  85. package/dist/runtime/app/utils/file-tree.ts +40 -0
  86. package/dist/runtime/server/llms.d.ts +6 -0
  87. package/dist/runtime/server/llms.js +7 -0
  88. package/dist/runtime/server/markdown.d.ts +10 -0
  89. package/dist/runtime/server/markdown.js +11 -0
  90. package/dist/runtime/server/mcp.d.ts +6 -0
  91. package/dist/runtime/server/mcp.js +7 -0
  92. package/dist/runtime/server/page.d.ts +7 -0
  93. package/dist/runtime/server/page.js +27 -0
  94. package/dist/runtime/server/raw.d.ts +10 -0
  95. package/dist/runtime/server/raw.js +23 -0
  96. package/dist/runtime/server/search.d.ts +6 -0
  97. package/dist/runtime/server/search.js +32 -0
  98. package/dist/runtime/server/sitemap.d.ts +6 -0
  99. package/dist/runtime/server/sitemap.js +52 -0
  100. package/dist/runtime/server/trailing-slash.d.ts +10 -0
  101. package/dist/runtime/server/trailing-slash.js +28 -0
  102. package/dist/runtime/theme/design.css +464 -0
  103. package/dist/schema-DwpXW0VZ.js +98 -0
  104. package/dist/server.d.ts +15 -0
  105. package/dist/server.js +5 -0
  106. package/dist/theme-BXyu4uFL.d.ts +32 -0
  107. package/dist/theme-DzC8LtMH.js +237 -0
  108. package/dist/theme.d.ts +2 -0
  109. package/dist/theme.js +2 -0
  110. package/dist/types-BhG6vGfG.d.ts +212 -0
  111. package/package.json +144 -1
@@ -0,0 +1,62 @@
1
+ import { docsManifestPages, docsRawPath, docsSectionForPath, isDocsPath, normalizeDocsPath } from "./navigation.js";
2
+ import { t as docsErrorDiagnostics } from "./error-diagnostics-BoOsP6Y4.js";
3
+ //#region src/redirects.ts
4
+ /**
5
+ * The redirect route rules from an exact app path. Keep external targets so a chain can end at another site.
6
+ * A wildcard rule, such as `/docs/old/**`, has no single target page, so it is left out.
7
+ */
8
+ function docsRedirects(routeRules) {
9
+ return Object.entries(routeRules).flatMap(([from, rule]) => {
10
+ const to = typeof rule?.redirect === "string" ? rule.redirect : rule?.redirect ? rule.redirect.to : void 0;
11
+ if (!to || from.includes("*") || !from.startsWith("/")) return [];
12
+ return [{
13
+ from,
14
+ to
15
+ }];
16
+ });
17
+ }
18
+ /** A docs page or the Markdown copy of one that answers a URL path. */
19
+ function docsPaths(manifest) {
20
+ return new Set(docsManifestPages(manifest).flatMap((page) => [page.path, docsRawPath(page.path)]));
21
+ }
22
+ /**
23
+ * Redirects that break a link. A redirect from a docs page hides the page, as nobody can open it. A redirect into a
24
+ * section, the docs base, or `/raw/` must open a docs page or its Markdown copy, or another redirect. Other targets
25
+ * belong to the app, so they are not checked here. Each problem is one sentence that names the fix.
26
+ */
27
+ function docsRedirectProblems(manifest, redirects) {
28
+ const pages = docsPaths(manifest);
29
+ const next = new Map(redirects.map((redirect) => [normalizeDocsPath(redirect.from), redirect.to]));
30
+ const problems = [];
31
+ for (const { from, to } of redirects) {
32
+ const source = normalizeDocsPath(from);
33
+ const page = docsManifestPages(manifest).find((candidate) => candidate.path === source || docsRawPath(candidate.path) === source);
34
+ if (page) problems.push(`The redirect from ${from} hides the page ${page.file}. Remove the route rule, or move the page.`);
35
+ const seen = /* @__PURE__ */ new Set([source]);
36
+ let end = to;
37
+ let target = targetPath(end);
38
+ while (target !== void 0 && next.has(target) && !seen.has(target)) {
39
+ seen.add(target);
40
+ end = next.get(target);
41
+ target = targetPath(end);
42
+ }
43
+ if (target === void 0) continue;
44
+ if (seen.has(target)) {
45
+ problems.push(`The redirect from ${from} comes back to ${target} and never reaches a page. Point one of its route rules to a page.`);
46
+ continue;
47
+ }
48
+ if ((target.startsWith("/raw/") || docsSectionForPath(manifest, target) !== null || manifest.base !== "/" && isDocsPath(target, manifest.base)) && !pages.has(target)) problems.push(`The redirect from ${from} goes to ${end}, which is not a docs page. Point it to a page, or remove the route rule.`);
49
+ }
50
+ return problems;
51
+ }
52
+ function targetPath(to) {
53
+ if (!to.startsWith("/") || to.startsWith("//")) return void 0;
54
+ return normalizeDocsPath(to.replace(/[?#].*$/, ""));
55
+ }
56
+ /** Redirect route rules that break links. The build stops on them while the link checker is on. */
57
+ /** `DOCS_REDIRECTS_BROKEN`, with the list of problems in `problems`. */
58
+ function docsRedirectError(problems) {
59
+ return Object.assign(docsErrorDiagnostics.DOCS_REDIRECTS_BROKEN({ problems }), { problems });
60
+ }
61
+ //#endregion
62
+ export { docsRedirectProblems as n, docsRedirects as r, docsRedirectError as t };
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <UApp>
3
+ <NuxtLoadingIndicator color="var(--ui-primary)" />
4
+
5
+ <DocsAppShell>
6
+ <NuxtLayout>
7
+ <NuxtPage />
8
+ </NuxtLayout>
9
+ </DocsAppShell>
10
+ </UApp>
11
+ </template>
@@ -0,0 +1,81 @@
1
+ <script setup lang="ts">
2
+ import { onMounted, ref, watch } from "vue"
3
+
4
+ import { defineShortcuts } from "#imports"
5
+
6
+ import { useDocsAssistant } from "../composables/useDocsAssistant"
7
+
8
+ const { agent, open, toggle } = useDocsAssistant()
9
+ // Mount the panel on first open and keep it, so closing it keeps the conversation.
10
+ const mounted = ref(open.value)
11
+ watch(open, (value) => {
12
+ if (value) mounted.value = true
13
+ })
14
+
15
+ // `defineShortcuts` reads `meta` as Command on macOS and as Ctrl elsewhere. The attribute names the same key.
16
+ const shortcut = ref("Control+I")
17
+ onMounted(() => {
18
+ if (/Macintosh;/.test(navigator.userAgent)) shortcut.value = "Meta+I"
19
+ })
20
+
21
+ // The shortcut also works in the composer, so it closes the panel that it opened.
22
+ defineShortcuts({ meta_i: { usingInput: true, handler: () => agent.value && toggle() } })
23
+ </script>
24
+
25
+ <template>
26
+ <template v-if="agent">
27
+ <!-- The same pill as the ViteHub page tools. It stays in the page, so closing the panel can return focus to it. -->
28
+ <div class="vh-assistant-launcher" :class="{ 'is-open': open }">
29
+ <UTooltip text="Ask the docs" :kbds="['meta', 'i']" :content="{ side: 'top', sideOffset: 8 }">
30
+ <UButton
31
+ id="docs-assistant-trigger"
32
+ icon="i-lucide-message-circle"
33
+ label="Ask"
34
+ variant="ghost"
35
+ class="vh-assistant-launcher__button"
36
+ aria-controls="docs-assistant"
37
+ :aria-expanded="open"
38
+ :aria-keyshortcuts="shortcut"
39
+ @click="toggle()"
40
+ />
41
+ </UTooltip>
42
+ </div>
43
+ <ClientOnly>
44
+ <DocsAssistantPanel v-if="mounted" :agent="agent" />
45
+ </ClientOnly>
46
+ </template>
47
+ </template>
48
+
49
+ <style scoped>
50
+ /* A floating pill: the floating surface and shadow of the theme, one radius step above the button inside it. */
51
+ .vh-assistant-launcher {
52
+ position: fixed;
53
+ z-index: 30;
54
+ right: max(1rem, env(safe-area-inset-right));
55
+ bottom: max(1rem, env(safe-area-inset-bottom));
56
+ display: flex;
57
+ padding: 0.25rem;
58
+ border-radius: calc(var(--ui-radius) * 2.5);
59
+ background: var(--vh-floating);
60
+ box-shadow: var(--vh-shadow-floating);
61
+ backdrop-filter: blur(12px);
62
+ }
63
+
64
+ /* The open panel has its own Close button. Hidden, the launcher leaves the tab order but keeps its place. */
65
+ .vh-assistant-launcher.is-open {
66
+ visibility: hidden;
67
+ }
68
+
69
+ /* A 44px target on touch screens. The pill keeps its size. */
70
+ @media (pointer: coarse) {
71
+ .vh-assistant-launcher__button {
72
+ position: relative;
73
+ }
74
+
75
+ .vh-assistant-launcher__button::before {
76
+ position: absolute;
77
+ inset: -8px;
78
+ content: "";
79
+ }
80
+ }
81
+ </style>
@@ -0,0 +1,8 @@
1
+ <!-- `DocsAssistant` when `docs.assistant` is off: the shell renders it unconditionally, and it renders nothing. -->
2
+ <script lang="ts">
3
+ import { defineComponent } from "vue"
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
+ export default defineComponent({ name: "DocsAssistantOff", render: () => null })
8
+ </script>
@@ -0,0 +1,322 @@
1
+ <script setup lang="ts">
2
+ import { createReusableTemplate, useEventListener, usePreferredReducedMotion } from "@vueuse/core"
3
+ import { CopyButton } from "@vite-hub/ui"
4
+ import { computed, nextTick, onScopeDispose, ref, useId, watch, watchEffect } from "vue"
5
+
6
+ import { useAgent, useChat } from "vite-hub/agent/vue"
7
+
8
+ import { useCookie, useRoute } from "#imports"
9
+
10
+ import { docsAssistantProblem } from "../composables/docs-assistant-problem"
11
+ import { useDocsAssistant } from "../composables/useDocsAssistant"
12
+ import { useDocsConfig } from "../composables/docs"
13
+
14
+ import type { ComponentPublicInstance } from "vue"
15
+
16
+ const props = defineProps<{ agent: string }>()
17
+
18
+ const { open, toggle } = useDocsAssistant()
19
+ const { appBase } = useDocsConfig()
20
+ const route = useRoute()
21
+ const chat = useChat(useAgent(props.agent))
22
+ const draft = ref("")
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
+ const requestBody = () => ({ body: { page: route.path, appBase } })
26
+ const reducedMotion = usePreferredReducedMotion()
27
+ const headingId = useId()
28
+ const [DefineBody, ReuseBody] = createReusableTemplate()
29
+
30
+ // From `lg` the panel is a column beside the page. Narrower screens get a modal sheet above the sticky site header.
31
+ const wide = window.matchMedia("(min-width: 80rem)")
32
+ const docked = ref(wide.matches)
33
+ useEventListener(wide, "change", () => { docked.value = wide.matches })
34
+
35
+ // The width is in pixels: 20rem to 36rem at the default font size, and never more than half the window.
36
+ const minWidth = 320
37
+ const maxWidth = 576
38
+ const defaultWidth = 384
39
+ const widthCookie = useCookie<number>("vh-docs-assistant-width", { default: () => defaultWidth, maxAge: 60 * 60 * 24 * 365, sameSite: "lax" })
40
+ const clampWidth = (value: number) => Number.isFinite(value) ? Math.round(Math.min(maxWidth, Math.max(minWidth, value))) : defaultWidth
41
+ const width = ref(clampWidth(Number(widthCookie.value)))
42
+ const resizing = ref(false)
43
+
44
+ // The docked column is fixed, so the page needs padding on the right to keep its content clear of it.
45
+ watchEffect(() => {
46
+ const root = document.documentElement
47
+ if (open.value && docked.value) {
48
+ root.style.setProperty("--vh-assistant-width", `min(${width.value}px, 50vw)`)
49
+ root.dataset.docsAssistant = "docked"
50
+ }
51
+ else {
52
+ root.style.removeProperty("--vh-assistant-width")
53
+ delete root.dataset.docsAssistant
54
+ }
55
+ if (resizing.value) root.dataset.docsAssistantResizing = ""
56
+ else delete root.dataset.docsAssistantResizing
57
+ })
58
+ onScopeDispose(() => {
59
+ const root = document.documentElement
60
+ root.style.removeProperty("--vh-assistant-width")
61
+ delete root.dataset.docsAssistant
62
+ delete root.dataset.docsAssistantResizing
63
+ })
64
+
65
+ function saveWidth(value: number) {
66
+ width.value = clampWidth(value)
67
+ widthCookie.value = width.value
68
+ }
69
+
70
+ function startResize(event: PointerEvent) {
71
+ if (event.button !== 0 || !(event.currentTarget instanceof HTMLElement)) return
72
+ event.currentTarget.setPointerCapture(event.pointerId)
73
+ resizing.value = true
74
+ }
75
+
76
+ function moveResize(event: PointerEvent) {
77
+ if (resizing.value) width.value = clampWidth(document.documentElement.clientWidth - event.clientX)
78
+ }
79
+
80
+ function endResize() {
81
+ if (!resizing.value) return
82
+ resizing.value = false
83
+ saveWidth(width.value)
84
+ }
85
+
86
+ function resizeWithKeys(event: KeyboardEvent) {
87
+ const step = event.key === "ArrowLeft" ? 16 : event.key === "ArrowRight" ? -16 : 0
88
+ if (!step) return
89
+ event.preventDefault()
90
+ saveWidth(width.value + step)
91
+ }
92
+
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
+ const viewport = ref<{ top: number, height: number }>()
96
+ function readViewport() {
97
+ const visual = window.visualViewport
98
+ viewport.value = visual ? { top: visual.offsetTop, height: visual.height } : undefined
99
+ }
100
+ readViewport()
101
+ useEventListener(window.visualViewport, ["resize", "scroll"], readViewport)
102
+ const sheetStyle = computed(() => viewport.value ? { top: `${viewport.value.top}px`, bottom: "auto", height: `${viewport.value.height}px` } : undefined)
103
+
104
+ const heading = ref<HTMLElement>()
105
+ const composer = ref<HTMLTextAreaElement>()
106
+
107
+ /** Whether the device has only coarse pointers. There, Enter adds a line and the Send button sends. */
108
+ function touchOnly(): boolean {
109
+ return window.matchMedia("(pointer: coarse)").matches && !window.matchMedia("(any-pointer: fine)").matches
110
+ }
111
+
112
+ // PromptInput puts its attributes on the form, so the panel finds the textarea to focus it.
113
+ function composerRef(target: Element | ComponentPublicInstance | null) {
114
+ const element = target && "$el" in target ? target.$el : target
115
+ composer.value = element instanceof HTMLElement ? element.querySelector("textarea") ?? undefined : undefined
116
+ }
117
+
118
+ // A focused composer opens the on-screen keyboard over half the sheet, so touch devices focus the heading instead.
119
+ function focusInside() {
120
+ if (touchOnly()) heading.value?.focus()
121
+ else composer.value?.focus()
122
+ }
123
+
124
+ // Closing returns focus to the control that opened the panel, or to the Ask button after a keyboard shortcut.
125
+ let returnTo: HTMLElement | undefined
126
+ watch(open, async (value) => {
127
+ if (value) {
128
+ const active = document.activeElement
129
+ 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
+ if (docked.value) {
132
+ await nextTick()
133
+ focusInside()
134
+ }
135
+ return
136
+ }
137
+ await nextTick()
138
+ const target = returnTo?.isConnected ? returnTo : document.getElementById("docs-assistant-trigger")
139
+ target?.focus()
140
+ }, { immediate: true })
141
+
142
+ const sheetContent = computed(() => ({
143
+ style: sheetStyle.value,
144
+ onOpenAutoFocus: (event: Event) => {
145
+ event.preventDefault()
146
+ focusInside()
147
+ },
148
+ // The `open` watcher moves focus.
149
+ onCloseAutoFocus: (event: Event) => event.preventDefault(),
150
+ }))
151
+
152
+ function closeOnEscape(event: KeyboardEvent) {
153
+ if (event.isComposing) return
154
+ event.preventDefault()
155
+ toggle(false)
156
+ }
157
+
158
+ function submit({ text }: { text: string }) {
159
+ if (!text.trim()) return
160
+ draft.value = ""
161
+ void chat.sendMessage({ text }, requestBody())
162
+ }
163
+
164
+ async function restart() {
165
+ void chat.stop()
166
+ chat.messages.value = []
167
+ chat.clearError()
168
+ await nextTick()
169
+ composer.value?.focus()
170
+ }
171
+ </script>
172
+
173
+ <template>
174
+ <DefineBody>
175
+ <div id="docs-assistant" class="vh-assistant flex h-full min-h-0 flex-col bg-default">
176
+ <header class="flex h-10 shrink-0 items-center gap-0.5 border-b border-default pr-1.5 pl-3 pointer-coarse:h-12 pointer-coarse:pr-0.5">
177
+ <h2 :id="headingId" ref="heading" tabindex="-1" class="flex-1 text-sm font-medium text-highlighted">
178
+ Ask the docs
179
+ </h2>
180
+ <UButton
181
+ icon="i-lucide-square-pen"
182
+ variant="ghost"
183
+ size="xs"
184
+ class="justify-center pointer-coarse:size-11"
185
+ aria-label="New chat"
186
+ :disabled="!chat.messages.value.length"
187
+ @click="restart"
188
+ />
189
+ <UButton icon="i-lucide-x" variant="ghost" size="xs" class="justify-center pointer-coarse:size-11" aria-label="Close" @click="toggle(false)" />
190
+ </header>
191
+ <Chat v-if="chat.messages.value.length" :messages="chat.messages.value" :status="chat.status.value" class="min-h-0 flex-1" />
192
+ <p v-else class="min-h-0 flex-1 overflow-y-auto overscroll-contain p-3 text-sm text-muted">
193
+ Answers come from these docs, with links to the pages they use.
194
+ </p>
195
+ <div v-if="problem" role="alert" class="shrink-0 border-t border-default px-3 py-2 text-sm" :data-code="problem.code">
196
+ <p class="font-medium text-highlighted">
197
+ {{ problem.title }}
198
+ </p>
199
+ <p class="text-muted">
200
+ {{ problem.detail }}
201
+ </p>
202
+ <div v-if="problem.command" class="mt-1.5 flex items-start gap-1 bg-elevated py-1 pr-1 pl-2">
203
+ <code class="min-w-0 flex-1 py-0.5 font-mono text-xs/5 whitespace-pre-wrap text-highlighted [overflow-wrap:anywhere]">{{ problem.command }}</code>
204
+ <CopyButton
205
+ :value="problem.command"
206
+ label="Copy"
207
+ aria-label="Copy the command"
208
+ size="xs"
209
+ class="shrink-0 pointer-coarse:h-11"
210
+ />
211
+ </div>
212
+ </div>
213
+ <PromptInput
214
+ :ref="composerRef"
215
+ v-model="draft"
216
+ class="shrink-0 border-t border-default p-2"
217
+ placeholder="Ask a question"
218
+ :attachments="false"
219
+ :status="chat.status.value"
220
+ @submit="submit"
221
+ @stop="chat.stop()"
222
+ @reload="chat.regenerate(requestBody())"
223
+ />
224
+ </div>
225
+ </DefineBody>
226
+
227
+ <aside
228
+ v-if="docked"
229
+ v-show="open"
230
+ class="vh-assistant-dock"
231
+ :aria-labelledby="headingId"
232
+ @keydown.esc="closeOnEscape"
233
+ >
234
+ <div
235
+ role="separator"
236
+ aria-orientation="vertical"
237
+ aria-label="Resize the panel"
238
+ :aria-valuenow="width"
239
+ :aria-valuemin="minWidth"
240
+ :aria-valuemax="maxWidth"
241
+ tabindex="0"
242
+ class="vh-assistant-resize"
243
+ @pointerdown="startResize"
244
+ @pointermove="moveResize"
245
+ @pointerup="endResize"
246
+ @pointercancel="endResize"
247
+ @dblclick="saveWidth(defaultWidth)"
248
+ @keydown="resizeWithKeys"
249
+ />
250
+ <ReuseBody />
251
+ </aside>
252
+ <USlideover
253
+ v-else
254
+ v-model:open="open"
255
+ title="Ask the docs"
256
+ description="Answers come from these docs."
257
+ :transition="reducedMotion !== 'reduce'"
258
+ :content="sheetContent"
259
+ :ui="{ content: 'max-w-none pb-[env(safe-area-inset-bottom)] sm:max-w-[26rem]' }"
260
+ >
261
+ <template #content>
262
+ <ReuseBody />
263
+ </template>
264
+ </USlideover>
265
+ </template>
266
+
267
+ <style scoped>
268
+ .vh-assistant {
269
+ --vh-chat-content-padding: 1rem 0.75rem 1.5rem;
270
+ }
271
+
272
+ .vh-assistant-dock {
273
+ position: fixed;
274
+ z-index: 40;
275
+ inset-block: 0;
276
+ right: 0;
277
+ width: var(--vh-assistant-width);
278
+ border-left: 1px solid var(--ui-border);
279
+ }
280
+
281
+ /* An 8px strip over the left border. The border line shows the hover and drag state; the theme draws focus. */
282
+ .vh-assistant-resize {
283
+ position: absolute;
284
+ z-index: 1;
285
+ inset-block: 0;
286
+ left: -5px;
287
+ width: 9px;
288
+ cursor: col-resize;
289
+ touch-action: none;
290
+ }
291
+
292
+ .vh-assistant-resize::after {
293
+ position: absolute;
294
+ inset-block: 0;
295
+ left: 4px;
296
+ width: 1px;
297
+ content: "";
298
+ transition: background-color 150ms ease-out;
299
+ }
300
+
301
+ .vh-assistant-resize:hover::after {
302
+ background: var(--ui-border-accented);
303
+ }
304
+ </style>
305
+
306
+ <style>
307
+ /* The page keeps its content clear of the docked panel. Below 80rem the panel is a sheet, so prose keeps its width. */
308
+ @media (min-width: 80rem) {
309
+ html[data-docs-assistant="docked"] {
310
+ padding-right: var(--vh-assistant-width);
311
+ }
312
+ }
313
+
314
+ html[data-docs-assistant-resizing] {
315
+ cursor: col-resize;
316
+ user-select: none;
317
+ }
318
+
319
+ html[data-docs-assistant-resizing] .vh-assistant-resize::after {
320
+ background: var(--ui-border-accented);
321
+ }
322
+ </style>