@clarify-labs/cli 0.7.2 → 0.8.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-D5EF3pYl.js","names":[],"sources":["../source/core/utils.ts","../source/parsers/mdx.ts","../source/plugins/content-artifacts/artifacts.ts","../source/plugins/content-artifacts/server.ts","../source/plugins/content-artifacts/index.ts","../source/plugins/html-shell/index.ts","../source/parsers/frontmatter.ts","../source/parsers/content.ts","../source/core/hooks.ts","../source/core/content.ts","../source/parsers/routes.ts","../source/plugins/openapi/parser.ts","../source/core/virtual-modules.ts","../source/plugins/openapi/virtual-modules.ts","../source/plugins/openapi/index.ts","../source/core/search-language.ts","../source/core/temp-dir.ts","../source/plugins/search-index/index.ts","../source/plugins/seo/artifacts.ts","../source/plugins/seo/index.ts","../source/plugins/source-links/source-links.ts","../source/plugins/source-links/index.ts","../source/parsers/variables.ts","../source/plugins/variables/index.ts","../source/core/builtin.ts","../source/core/config-schema.ts","../source/core/theme.ts","../source/core/config.ts","../source/core/env-types.ts","../source/core/options.ts","../source/core/site.ts","../source/core/runtime-deps.ts","../source/core/ssg.ts","../source/core/user-config.ts","../source/core/plugin.ts"],"sourcesContent":["export function escapeHtml(text: string): string {\n return text\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n}\n","import GithubSlugger from 'github-slugger'\nimport { toString } from 'mdast-util-to-string'\nimport shiki, { type Highlighter } from 'shiki'\nimport { visit } from 'unist-util-visit'\n\nimport { markdownRemarkPlugins } from '@clarify-labs/renderer'\n\nimport { escapeHtml } from '../core/utils.js'\n\ntype HastNode = {\n type: string\n tagName?: string\n value?: string\n properties?: Record<string, unknown>\n children?: HastNode[]\n}\n\ntype HastParent = HastNode & {\n children: HastNode[]\n}\n\ntype ShikiRenderElementArgs = {\n children: string\n}\n\nfunction getLanguage(className: unknown): string {\n const classes = Array.isArray(className) ? className : typeof className === 'string' ? className.split(/\\s+/) : []\n const languageClass = classes.find((item): item is string => typeof item === 'string' && item.startsWith('language-'))\n return languageClass?.replace(/^language-/, '') || 'txt'\n}\n\nfunction getTextContent(node: HastNode | undefined): string {\n if (!node) return ''\n if (typeof node.value === 'string') return node.value\n return node.children?.map(getTextContent).join('') ?? ''\n}\n\nfunction renderPlainCode(code: string): string {\n return code\n .split('\\n')\n .map(line => `<span>${escapeHtml(line)}</span>`)\n .join('\\n')\n}\n\nlet highlighter: Highlighter | undefined\n\nasync function getHighlighter(): Promise<Highlighter> {\n highlighter = highlighter ?? await shiki.getHighlighter({ theme: 'css-variables' })\n return highlighter\n}\n\nexport function rehypeParseCodeBlocks() {\n return (tree: HastNode) => {\n visit(tree, 'element', (node: HastNode, _nodeIndex: number | undefined, parentNode: HastParent | undefined) => {\n if (node.tagName !== 'code' || !parentNode) return\n parentNode.properties = parentNode.properties ?? {}\n node.properties = node.properties ?? {}\n const language = getLanguage(node.properties.className)\n parentNode.properties.language = language\n node.properties.language = language\n\n for (const key of ['title', 'tag', 'label']) {\n if (node.properties[key] !== undefined) parentNode.properties[key] = node.properties[key]\n }\n })\n }\n}\n\nexport function rehypeShiki() {\n return async (tree: HastNode) => {\n const shikiHighlighter = await getHighlighter()\n\n visit(tree, 'element', (node: HastNode) => {\n if (node.tagName !== 'pre') return\n const codeNode = node.children?.[0]\n if (codeNode?.tagName !== 'code') return\n\n node.properties = node.properties ?? {}\n codeNode.properties = codeNode.properties ?? {}\n\n const code = getTextContent(codeNode)\n const language = typeof node.properties.language === 'string' ? node.properties.language : getLanguage(codeNode.properties.className)\n node.properties.code = code\n codeNode.properties.code = code\n codeNode.properties.language = language\n\n let highlighted = renderPlainCode(code)\n\n if (language && language !== 'txt') {\n try {\n const tokens = shikiHighlighter.codeToThemedTokens(code, language)\n highlighted = shiki.renderToHtml(tokens, {\n elements: {\n pre: ({ children }: ShikiRenderElementArgs) => children,\n code: ({ children }: ShikiRenderElementArgs) => children,\n line: ({ children }: ShikiRenderElementArgs) => `<span>${children}</span>`,\n },\n })\n } catch {\n highlighted = renderPlainCode(code)\n }\n }\n\n codeNode.children = [{ type: 'text', value: highlighted }]\n })\n }\n}\n\nexport function rehypeSlugSections() {\n return (tree: HastNode) => {\n const slugger = new GithubSlugger()\n\n visit(tree, 'element', (node: HastNode) => {\n if (node.tagName !== 'h2' && node.tagName !== 'h3') return\n\n node.properties = node.properties ?? {}\n if (node.properties.id) return\n\n node.properties.id = slugger.slug(toString(node))\n })\n }\n}\n\nexport const remarkPlugins: unknown[] = markdownRemarkPlugins\nexport const rehypePlugins = [rehypeSlugSections, rehypeParseCodeBlocks, rehypeShiki]\n","import type { ContentRoute, ResolvedProjectConfig } from '../../types.js'\n\nconst UTF8_SIGNATURE = '\\uFEFF'\n\nfunction normalizeBasePath(basePath: string): string {\n if (!basePath || basePath === '/') return ''\n return '/' + basePath.replace(/^\\/+|\\/+$/g, '')\n}\n\nfunction containsNonAscii(content: string): boolean {\n return [...content].some(character => character.codePointAt(0)! > 0x7F)\n}\n\nfunction withUtf8Signature(content: string): string {\n if (!containsNonAscii(content) || content.startsWith(UTF8_SIGNATURE)) return content\n return `${UTF8_SIGNATURE}${content}`\n}\n\nfunction shouldUseUtf8Signature(route: ContentRoute): boolean {\n if (route.kind === 'mdx') return true\n return false\n}\n\nexport function routeToMarkdownArtifactUrl(routePath: string): string {\n const normalizedPath = routePath === '/' ? '/index' : routePath.replace(/\\/$/, '')\n return `${normalizedPath}.md`\n}\n\nexport function routeToOpenAPIArtifactUrl(routePath: string): string {\n const normalizedPath = routePath === '/' ? '/index' : routePath.replace(/\\/$/, '')\n return `${normalizedPath}.openapi.json`\n}\n\nexport function attachContentArtifactUrls(routes: ContentRoute[]): void {\n for (const route of routes) {\n route.contentArtifactUrl = route.kind === 'openapi'\n ? routeToOpenAPIArtifactUrl(route.path)\n : routeToMarkdownArtifactUrl(route.path)\n }\n}\n\nexport function readRouteContent(route: ContentRoute): string {\n if (route.content !== undefined) return route.content\n throw new Error(`Route content is missing from route context: ${route.filePath}`)\n}\n\nexport function readRouteArtifactContent(route: ContentRoute): string {\n const content = readRouteContent(route)\n return shouldUseUtf8Signature(route) ? withUtf8Signature(content) : content\n}\n\nfunction isLlmsTxtRoute(route: ContentRoute): boolean {\n return !route.path.split('/').includes('404')\n}\n\nfunction llmsTxtDescription(route: ContentRoute): string | undefined {\n if (route.description) return route.description\n\n const sections = route.sections?.filter(section => section.level === 2).slice(0, 3).map(section => section.title)\n if (sections?.length) return `Covers ${sections.join(', ')}.`\n\n if (route.keywords?.length) return `Related topics: ${route.keywords.join(', ')}.`\n\n if (route.kind === 'openapi') return 'OpenAPI artifact for machine-readable API reference data.'\n\n return undefined\n}\n\nfunction llmsTxtListItem(route: ContentRoute, basePath: string): string | undefined {\n if (!route.contentArtifactUrl) return undefined\n\n const description = llmsTxtDescription(route)\n return description\n ? `- [${route.title}](${basePath}${route.contentArtifactUrl}): ${description}`\n : `- [${route.title}](${basePath}${route.contentArtifactUrl})`\n}\n\nfunction llmsTxtLocaleLabel(locale: string, projectConfig: ResolvedProjectConfig): string {\n return projectConfig.i18n?.locales.find(item => item.code === locale)?.label ?? locale\n}\n\nfunction groupRoutesByLocale(routes: ContentRoute[]): Map<string, ContentRoute[]> {\n const groups = new Map<string, ContentRoute[]>()\n for (const route of routes) {\n const key = route.locale ?? 'default'\n groups.set(key, [...(groups.get(key) ?? []), route])\n }\n return groups\n}\n\nfunction groupLlmsTxtRoutesByLocale(routes: ContentRoute[], projectConfig: ResolvedProjectConfig): Map<string, ContentRoute[]> {\n const routesBySource = new Map<string, ContentRoute>()\n const defaultLocale = projectConfig.i18n?.defaultLocale\n\n for (const route of routes) {\n const sourceKey = `${route.locale ?? defaultLocale ?? 'default'}:${route.basePath ?? route.contentArtifactUrl ?? route.path}`\n const previousRoute = routesBySource.get(sourceKey)\n\n if (!previousRoute || (previousRoute.locale && !route.locale)) {\n routesBySource.set(sourceKey, route)\n }\n }\n\n return groupRoutesByLocale([...routesBySource.values()].map(route => ({\n ...route,\n locale: route.locale ?? defaultLocale,\n })))\n}\n\nfunction llmsTxtDocsSectionTitle(locale: string, groupCount: number, projectConfig: ResolvedProjectConfig): string {\n if (groupCount <= 1) return 'Docs'\n return `Docs - ${locale === 'default' ? 'Default' : llmsTxtLocaleLabel(locale, projectConfig)}`\n}\n\nexport function createLlmsTxt(routes: ContentRoute[], projectConfig: ResolvedProjectConfig): string {\n const basePath = normalizeBasePath(projectConfig.routePrefix)\n const lines = [\n `# ${projectConfig.title}`,\n '',\n ]\n\n if (projectConfig.description) {\n lines.push(`> ${projectConfig.description}`, '')\n }\n\n lines.push('This file lists the source-ready Markdown and OpenAPI artifacts for this documentation site.', '')\n\n const mdxRoutes = routes.filter(route => route.kind === 'mdx' && isLlmsTxtRoute(route))\n if (mdxRoutes.length > 0) {\n const localizedGroups = groupLlmsTxtRoutesByLocale(mdxRoutes, projectConfig)\n for (const [locale, localeRoutes] of localizedGroups) {\n lines.push(`## ${llmsTxtDocsSectionTitle(locale, localizedGroups.size, projectConfig)}`)\n\n for (const route of localeRoutes) {\n const item = llmsTxtListItem(route, basePath)\n if (item) lines.push(item)\n }\n\n lines.push('')\n }\n }\n\n const openApiRoutes = routes.filter(route => route.kind === 'openapi' && isLlmsTxtRoute(route))\n if (openApiRoutes.length > 0) {\n if (lines.at(-1) !== '') lines.push('')\n lines.push('## OpenAPI')\n for (const route of openApiRoutes) {\n const item = llmsTxtListItem(route, basePath)\n if (item) lines.push(item)\n }\n }\n\n while (lines.at(-1) === '') lines.pop()\n return `${lines.join('\\n')}\\n`\n}\n\nexport function createLlmsTxtArtifact(routes: ContentRoute[], projectConfig: ResolvedProjectConfig): string {\n return withUtf8Signature(createLlmsTxt(routes, projectConfig))\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http'\n\nimport { stringify as yamlStringify } from 'yaml'\n\nimport type { ContentRoute, ResolvedProjectConfig } from '../../types.js'\n\nimport { createLlmsTxtArtifact, readRouteArtifactContent } from './artifacts.js'\n\nfunction normalizeRoutePrefix(routePrefix: string): string {\n if (!routePrefix || routePrefix === '/') return ''\n return `/${routePrefix.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nexport function resolveContentArtifactPath(url: string | undefined, projectConfig: ResolvedProjectConfig): string {\n const requestPath = url?.split('?')[0] ?? ''\n const basePath = normalizeRoutePrefix(projectConfig.routePrefix)\n return basePath && requestPath.startsWith(basePath)\n ? requestPath.slice(basePath.length) || '/'\n : requestPath\n}\n\nexport function resolveContentArtifactType(route: ContentRoute): string {\n return route.kind === 'openapi'\n ? 'application/json; charset=utf-8'\n : 'text/markdown; charset=utf-8'\n}\n\nexport function serveContentArtifacts(req: IncomingMessage, res: ServerResponse, projectConfig: ResolvedProjectConfig, routes: ContentRoute[]): boolean {\n const contentPath = resolveContentArtifactPath(req.url, projectConfig)\n\n if (contentPath === '/llms.txt') {\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/plain; charset=utf-8')\n res.end(createLlmsTxtArtifact(routes, projectConfig), 'utf8')\n return true\n }\n\n // Handle YAML variant for OpenAPI routes: /api.openapi.yaml → serve YAML\n if (contentPath.endsWith('.openapi.yaml')) {\n const jsonPath = contentPath.replace(/\\.yaml$/, '.json')\n const route = routes.find(r => r.contentArtifactUrl === jsonPath)\n if (route?.kind === 'openapi' && route.content) {\n const spec = JSON.parse(route.content)\n res.statusCode = 200\n res.setHeader('Content-Type', 'text/yaml; charset=utf-8')\n res.end(yamlStringify(spec, { lineWidth: 0 }), 'utf8')\n return true\n }\n return false\n }\n\n const route = routes.find(route => route.contentArtifactUrl === contentPath)\n if (!route) return false\n\n res.statusCode = 200\n res.setHeader('Content-Type', resolveContentArtifactType(route))\n res.end(readRouteArtifactContent(route), 'utf8')\n return true\n}\n","import type { ViteDevServer } from 'vite'\nimport { stringify as yamlStringify } from 'yaml'\n\nimport type { ClarifyEmitAsset, ClarifyPlugin } from '../../types.js'\n\nimport { attachContentArtifactUrls, createLlmsTxtArtifact, readRouteArtifactContent } from './artifacts.js'\nimport { serveContentArtifacts } from './server.js'\n\nexport function createContentArtifactsPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:content-artifacts',\n hooks: {\n 'routes:resolved': (input) => {\n attachContentArtifactUrls(input.routes)\n return input\n },\n 'dev:configureServer': (server: ViteDevServer, ctx) => {\n server.middlewares.use((req, res, next) => {\n if (serveContentArtifacts(req, res, ctx.projectConfig, ctx.routes)) return\n next()\n })\n },\n 'build:assets': (ctx) => {\n const assets: ClarifyEmitAsset[] = []\n\n for (const route of ctx.routes) {\n if (!route.contentArtifactUrl) continue\n\n assets.push({\n fileName: route.contentArtifactUrl.replace(/^\\//, ''),\n source: readRouteArtifactContent(route),\n })\n\n // For OpenAPI routes, also emit a YAML variant\n if (route.kind === 'openapi' && route.content) {\n const yamlFileName = route.contentArtifactUrl.replace(/\\.json$/, '.yaml')\n const spec = JSON.parse(route.content)\n assets.push({\n fileName: yamlFileName.replace(/^\\//, ''),\n source: yamlStringify(spec, { lineWidth: 0 }),\n })\n }\n }\n\n assets.push({\n fileName: 'llms.txt',\n source: createLlmsTxtArtifact(ctx.routes, ctx.projectConfig),\n })\n\n return assets\n },\n },\n }\n}\n","import type { HtmlTagDescriptor } from 'vite'\n\nimport { themeBootstrapScript } from '@clarify-labs/renderer'\n\nimport type { ClarifyFaviconConfig, ClarifyPlugin } from '../../types.js'\n\nconst REL_ICON_RE = /<link\\s+[^>]*rel=[\"'][^\"']*\\bicon\\b[^\"']*[\"'][^>]*>/i\n\nfunction inferIconType(href: string): string | undefined {\n const path = href.split(/[?#]/, 1)[0]?.toLowerCase() ?? href.toLowerCase()\n\n if (path.endsWith('.svg')) return 'image/svg+xml'\n if (path.endsWith('.png')) return 'image/png'\n if (path.endsWith('.ico')) return 'image/x-icon'\n if (path.endsWith('.webp')) return 'image/webp'\n\n return undefined\n}\n\nfunction createIconTag(href: string, media?: string): HtmlTagDescriptor {\n return {\n tag: 'link',\n attrs: {\n rel: 'icon',\n ...(inferIconType(href) ? { type: inferIconType(href) } : {}),\n href,\n ...(media ? { media } : {}),\n },\n injectTo: 'head',\n }\n}\n\nfunction createIconTags(icon?: ClarifyFaviconConfig): HtmlTagDescriptor[] {\n if (!icon) return []\n\n if (typeof icon === 'string') return [createIconTag(icon)]\n\n const lightIcon = icon.light ?? icon.dark\n const darkIcon = icon.dark ?? icon.light\n\n if (!lightIcon || !darkIcon) return []\n if (lightIcon === darkIcon) return [createIconTag(lightIcon)]\n\n return [\n createIconTag(lightIcon, '(prefers-color-scheme: light)'),\n createIconTag(darkIcon, '(prefers-color-scheme: dark)'),\n ]\n}\n\nexport function createHtmlShellPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:html-shell',\n hooks: {\n 'html:transform': (input, ctx) => ({\n html: input.html,\n tags: [\n ...input.tags,\n ...(REL_ICON_RE.test(input.html) ? [] : createIconTags(ctx.projectConfig.favicon ?? ctx.projectConfig.logo)),\n {\n tag: 'script',\n children: themeBootstrapScript(ctx.projectConfig.theme),\n injectTo: 'head-prepend',\n },\n {\n tag: 'script',\n attrs: { type: 'module', src: input.clientEntryId },\n injectTo: 'body',\n },\n ],\n clientEntryId: input.clientEntryId,\n dev: input.dev,\n }),\n },\n }\n}\n","import matter from 'gray-matter'\n\nexport type ParsedFrontmatter = {\n frontmatter: Record<string, unknown>\n content: string\n}\n\n/**\n * 在内容入口统一解析 MDX frontmatter,并返回可供后续流程复用的标准化正文。\n */\nexport function parseFrontmatter(content: string): ParsedFrontmatter {\n const parsed = matter(content)\n return {\n frontmatter: parsed.data,\n content: parsed.content.replace(/^\\r?\\n/, ''),\n }\n}\n\n/**\n * 从 MDX 文件内容中提取 frontmatter。\n * 使用 gray-matter 支持 YAML frontmatter 的标准语法和类型解析。\n */\nexport function extractFrontmatter(content: string): Record<string, unknown> {\n return parseFrontmatter(content).frontmatter\n}\n\n/**\n * 移除 MDX 文件开头的 YAML frontmatter,保留页面正文。\n */\nexport function stripFrontmatter(content: string): string {\n return parseFrontmatter(content).content\n}\n","import type { ClarifyContentKind, ClarifyContentTransformInput } from '../types.js'\n\nimport { parseFrontmatter } from './frontmatter.js'\n\nexport type ProcessedMdxContent = {\n frontmatter: Record<string, unknown>\n content: string\n}\n\nexport type ContentTransform = (input: ClarifyContentTransformInput) => Promise<ClarifyContentTransformInput> | ClarifyContentTransformInput\n\nexport type ContentProcessor = {\n processMdx(source: string, filePath?: string): Promise<ProcessedMdxContent>\n processText(source: string, kind: Exclude<ClarifyContentKind, 'mdx'>, filePath?: string): Promise<string>\n}\n\nasync function transformContent(transform: ContentTransform | undefined, input: ClarifyContentTransformInput): Promise<ClarifyContentTransformInput> {\n return transform ? await transform(input) : input\n}\n\nexport function createContentProcessor(transform?: ContentTransform): ContentProcessor {\n return {\n async processMdx(source, filePath) {\n const { frontmatter, content } = parseFrontmatter(source)\n const transformed = await transformContent(transform, {\n kind: 'mdx',\n source,\n filePath,\n frontmatter,\n content,\n })\n\n return {\n frontmatter: transformed.frontmatter,\n content: transformed.content,\n }\n },\n async processText(source, kind, filePath) {\n const transformed = await transformContent(transform, {\n kind,\n source,\n filePath,\n frontmatter: {},\n content: source,\n })\n return transformed.content\n },\n }\n}\n","import type { ViteDevServer } from 'vite'\n\nimport type { ClarifyEmitAsset, ClarifyHookContext, ClarifyHooks, ClarifyPlugin } from '../types.js'\n\nexport async function runHooks<K extends Exclude<keyof ClarifyHooks, 'build:assets' | 'build:done' | 'dev:configureServer'>>(plugins: ClarifyPlugin[], hookName: K, input: Parameters<NonNullable<ClarifyHooks[K]>>[0], ctx: ClarifyHookContext): Promise<Parameters<NonNullable<ClarifyHooks[K]>>[0]> {\n let result = input\n for (const plugin of plugins) {\n const hook = plugin.hooks?.[hookName]\n if (!hook) continue\n try {\n result = await hook(result as never, ctx) as Parameters<NonNullable<ClarifyHooks[K]>>[0]\n } catch (err) {\n throw new Error(`[clarify] plugin \"${plugin.name}\" hook \"${hookName}\" failed: ${err}`, { cause: err })\n }\n }\n return result\n}\n\nexport async function runDevConfigureServerHooks(plugins: ClarifyPlugin[], server: ViteDevServer, ctx: ClarifyHookContext): Promise<void> {\n for (const plugin of plugins) {\n const hook = plugin.hooks?.['dev:configureServer']\n if (!hook) continue\n try {\n await hook(server, ctx)\n } catch (err) {\n throw new Error(`[clarify] plugin \"${plugin.name}\" hook \"dev:configureServer\" failed: ${err}`, { cause: err })\n }\n }\n}\n\nexport async function runBuildAssetsHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<ClarifyEmitAsset[]> {\n const assets: ClarifyEmitAsset[] = []\n for (const plugin of plugins) {\n const hook = plugin.hooks?.['build:assets']\n if (!hook) continue\n try {\n const pluginAssets = await hook(ctx)\n assets.push(...pluginAssets)\n } catch (err) {\n throw new Error(`[clarify] plugin \"${plugin.name}\" hook \"build:assets\" failed: ${err}`, { cause: err })\n }\n }\n return assets\n}\n\nexport async function runBuildDoneHooks(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<void> {\n for (const plugin of plugins) {\n const hook = plugin.hooks?.['build:done']\n if (!hook) continue\n try {\n await hook(ctx)\n } catch (err) {\n throw new Error(`[clarify] plugin \"${plugin.name}\" hook \"build:done\" failed: ${err}`, { cause: err })\n }\n }\n}\n","import { createContentProcessor, type ContentProcessor } from '../parsers/content.js'\nimport type { ClarifyHookContext, ClarifyPlugin } from '../types.js'\n\nimport { runHooks } from './hooks.js'\n\nconst contentProcessors = new WeakMap<ClarifyHookContext, ContentProcessor>()\n\nexport function createProjectContentProcessor(plugins: ClarifyPlugin[], ctx: ClarifyHookContext): ContentProcessor {\n return createContentProcessor(input => runHooks(plugins, 'content:transform', input, ctx))\n}\n\nexport function setProjectContentProcessor(ctx: ClarifyHookContext, processor: ContentProcessor): void {\n contentProcessors.set(ctx, processor)\n}\n\nexport function getProjectContentProcessor(ctx: ClarifyHookContext): ContentProcessor | undefined {\n return contentProcessors.get(ctx)\n}\n","import { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\n\nimport GithubSlugger from 'github-slugger'\nimport { toString } from 'mdast-util-to-string'\nimport { remark } from 'remark'\nimport { visit } from 'unist-util-visit'\n\nimport type { ContentRoute, ContentSection, ClarifyNavigationNode, ClarifyPagesConfig, ClarifyPagesGroup, ClarifyPagesItem, ClarifyLocalizedText, ClarifyTabsConfig, LocalizedNavigation, LocalizedTabbedNavigation, ResolvedClarifyI18nConfig, TabbedNavigation } from '../types.js'\n\nimport { createContentProcessor, type ContentProcessor } from './content.js'\n\nexport type FindContentRoutesOptions = {\n contentProcessor?: ContentProcessor\n}\n\nexport function kebabToTitle(str: string): string {\n return str\n .split('-')\n .map(w => w.charAt(0).toUpperCase() + w.slice(1))\n .join(' ')\n}\n\nfunction parseMdxTree(content: string) {\n return remark.parse(content)\n}\n\n/** 从内容中提取第一个 H1 标题 */\nfunction extractH1(content: string): string {\n const tree = parseMdxTree(content)\n let title = ''\n visit(tree, 'heading', (node) => {\n if (!title && node.depth === 1) {\n title = toString(node)\n }\n })\n return title\n}\n\n/** 从 MDX/Markdown 内容中提取 H2/H3 章节 */\nexport function extractMdxSections(content: string): ContentSection[] {\n const sections: ContentSection[] = []\n const slugger = new GithubSlugger()\n const tree = parseMdxTree(content)\n visit(tree, 'heading', (node) => {\n if (node.depth !== 2 && node.depth !== 3) return\n const title = toString(node)\n sections.push({ id: slugger.slug(title), title, level: node.depth })\n })\n return sections\n}\n\nfunction navigationSections(sections: ContentSection[]) {\n return sections.map(s => ({ id: s.id, title: s.title, level: s.level, badge: s.badge, tags: s.tags }))\n}\n\nexport function normalizePath(path: string): string {\n const clean = '/' + path.replace(/^\\/+|\\/+$/g, '')\n return clean === '/' ? '/' : clean.replace(/\\/+/g, '/')\n}\n\nfunction pathSegmentFromOpenAPITag(tag: string): string {\n return tag\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'tag'\n}\n\nexport function openAPITagsPathSegment(tags: string[]): string {\n return tags.map(pathSegmentFromOpenAPITag).join('-')\n}\n\nexport function basePathFromRef(ref: string): string {\n const withoutExtension = ref.replace(/\\.mdx?$/, '').replace(/\\.openapi\\.(json|yaml|yml)$/, '')\n return normalizePath(withoutExtension === 'index' ? '/' : withoutExtension.replace(/\\/index$/, ''))\n}\n\nexport function openAPIPagePathFromRef(ref: string, tagFilter?: string[], explicitPath?: string): string {\n if (explicitPath) return normalizePath(explicitPath)\n const basePath = basePathFromRef(ref)\n if (!tagFilter?.length) return basePath\n return normalizePath(`${basePath}/${openAPITagsPathSegment(tagFilter)}`)\n}\n\nexport function routePathFromRef(ref: string, explicitPath?: string): string {\n return explicitPath ? normalizePath(explicitPath) : basePathFromRef(ref)\n}\n\nexport function virtualModuleIdFromRef(ref: string): string {\n return 'virtual:clarify-page/' + ref\n .replace(/\\.mdx?$/, '')\n .replace(/\\.openapi\\.(json|yaml|yml)$/, '')\n .replace(/\\/+/g, '/')\n}\n\nexport function localizedRoutePath(basePath: string, locale: string, _i18n: ResolvedClarifyI18nConfig): string {\n const normalizedBasePath = normalizePath(basePath)\n const prefix = normalizePath(locale)\n return normalizedBasePath === '/' ? prefix : normalizePath(`${prefix}${normalizedBasePath}`)\n}\n\nexport function resolveLocalizedText(text: ClarifyLocalizedText | undefined, locale: string, fallbackLocale?: string): string | undefined {\n if (typeof text === 'string') return text\n if (text === undefined) return undefined\n return text[locale] ?? (fallbackLocale ? text[fallbackLocale] : undefined) ?? Object.values(text)[0]\n}\n\nexport async function findContentRoutes(dir: string, base: string = dir, options: FindContentRoutesOptions = {}): Promise<ContentRoute[]> {\n const routes: ContentRoute[] = []\n if (!existsSync(dir)) return routes\n\n const entries = readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n const fullPath = join(dir, entry.name)\n if (entry.isDirectory()) {\n routes.push(...await findContentRoutes(fullPath, base, options))\n } else if (entry.isFile() && /\\.mdx?$/.test(entry.name)) {\n const relativePath = relative(base, fullPath)\n const pathParts = relativePath.replace(/\\.mdx?$/, '').split('/')\n const path = '/' + pathParts.map(p => p === 'index' ? '' : p).filter(Boolean).join('/')\n const cleanPath = path.replace(/\\/+/g, '/').replace(/\\/$/, '') || '/'\n\n const source = readFileSync(fullPath, 'utf-8')\n const { frontmatter, content } = await (options.contentProcessor ?? createContentProcessor()).processMdx(source, fullPath)\n\n let title = typeof frontmatter.title === 'string' ? frontmatter.title : ''\n if (!title) {\n const lastPart = pathParts[pathParts.length - 1] ?? ''\n const stem = lastPart === 'index'\n ? (pathParts.length >= 2 ? pathParts[pathParts.length - 2]! : extractH1(content))\n : lastPart\n title = kebabToTitle(stem) || 'Untitled'\n }\n\n routes.push({\n path: cleanPath,\n basePath: cleanPath,\n filePath: fullPath,\n virtualModuleId: 'virtual:clarify-page/' + relativePath.replace(/\\.mdx?$/, '').replace(/\\/+/g, '/'),\n title,\n description: typeof frontmatter.description === 'string' ? frontmatter.description : undefined,\n keywords: frontmatterKeywords(frontmatter),\n kind: 'mdx',\n frontmatter,\n content,\n sections: extractMdxSections(content),\n })\n }\n }\n return routes\n}\n\nfunction virtualModuleIdForLocalizedRoute(contentRoot: string, filePath: string): string {\n return 'virtual:clarify-page/' + relative(contentRoot, filePath)\n .replace(/\\.mdx?$/, '')\n .replace(/\\.openapi\\.(json|yaml|yml)$/, '')\n .replace(/\\/+/g, '/')\n}\n\nfunction frontmatterKeywords(frontmatter: Record<string, unknown>): string[] | undefined {\n const value = frontmatter.keywords ?? frontmatter.keyword ?? frontmatter.tags\n const keywords = Array.isArray(value)\n ? value.filter((item): item is string => typeof item === 'string')\n : typeof value === 'string'\n ? value.split(',').map(keyword => keyword.trim()).filter(Boolean)\n : []\n\n return keywords.length > 0 ? keywords : undefined\n}\n\nexport function withAlternates(route: ContentRoute, routes: ContentRoute[], i18n: ResolvedClarifyI18nConfig): ContentRoute {\n const basePath = route.basePath ?? route.path\n // 排除裸路径别名,避免覆盖带 locale 前缀的路径\n const routeByLocaleAndBase = new Map(\n routes\n .filter(r => !r.locale || r.path === `/${r.locale}` || r.path.startsWith(`/${r.locale}/`))\n .map(r => [`${r.locale ?? ''}:${r.basePath ?? r.path}`, r]),\n )\n const alternates = Object.fromEntries(\n i18n.locales.flatMap((locale) => {\n const alternate = routeByLocaleAndBase.get(`${locale.code}:${basePath}`)\n return alternate ? [[locale.code, alternate.path]] : []\n })\n )\n return { ...route, alternates }\n}\n\nexport async function findLocalizedContentRoutes(contentRoot: string, i18n?: ResolvedClarifyI18nConfig, options: FindContentRoutesOptions = {}): Promise<ContentRoute[]> {\n if (!i18n) return findContentRoutes(contentRoot, contentRoot, options)\n\n const localizedRoutes: ContentRoute[] = []\n for (const locale of i18n.locales) {\n const localeRoot = join(contentRoot, locale.code)\n const discovered = await findContentRoutes(localeRoot, localeRoot, options)\n for (const route of discovered) {\n const basePath = route.basePath ?? route.path\n localizedRoutes.push({\n ...route,\n path: localizedRoutePath(basePath, locale.code, i18n),\n basePath,\n locale: locale.code,\n virtualModuleId: virtualModuleIdForLocalizedRoute(contentRoot, route.filePath),\n })\n }\n }\n\n if (i18n.missing === 'fallback') {\n const routeByLocaleAndBase = new Map(localizedRoutes.map(route => [`${route.locale ?? ''}:${route.basePath ?? route.path}`, route]))\n const defaultRoutes = localizedRoutes.filter(route => route.locale === i18n.defaultLocale)\n for (const sourceRoute of defaultRoutes) {\n const basePath = sourceRoute.basePath ?? sourceRoute.path\n for (const locale of i18n.locales) {\n const key = `${locale.code}:${basePath}`\n if (routeByLocaleAndBase.has(key)) continue\n localizedRoutes.push({\n ...sourceRoute,\n path: localizedRoutePath(basePath, locale.code, i18n),\n locale: locale.code,\n isFallback: true,\n })\n }\n }\n }\n\n const routesWithAlternates = localizedRoutes.map(route => withAlternates(route, localizedRoutes, i18n))\n\n // 为默认语言生成无前缀的裸路径别名,方便不带语言前缀的 URL 也能访问\n const bareRoutes: ContentRoute[] = []\n const seenBare = new Set(routesWithAlternates.map(r => r.path))\n for (const route of routesWithAlternates) {\n if (route.locale !== i18n.defaultLocale) continue\n const bp = route.basePath ?? route.path\n if (bp === route.path || seenBare.has(bp)) continue\n seenBare.add(bp)\n bareRoutes.push({ ...route, path: bp })\n }\n\n return [...routesWithAlternates, ...bareRoutes]\n}\n\nexport function buildNavigation(routes: ContentRoute[]): ClarifyNavigationNode[] {\n const root: ClarifyNavigationNode[] = []\n\n for (const route of routes) {\n if (route.path === '/' || (route.basePath ?? route.path) === '/404') continue // 首页和 404 不放入侧边栏\n\n const parts = route.path.replace(/^\\//, '').split('/')\n let current = root\n\n for (let i = 0; i < parts.length; i++) {\n const pathSoFar = '/' + parts.slice(0, i + 1).join('/')\n let node = current.find(n => n.path === pathSoFar)\n if (!node) {\n node = { path: pathSoFar, title: i === parts.length - 1 ? route.title : kebabToTitle(parts[i]), children: [] }\n current.push(node)\n }\n if (i === parts.length - 1 && route.sections) {\n node.sections = navigationSections(route.sections)\n }\n if (i < parts.length - 1) {\n node.children = node.children ?? []\n current = node.children\n }\n }\n }\n\n return root\n}\n\nfunction resolvePageItem(\n item: ClarifyPagesItem\n): { pageRef?: string; openapiRef?: string; openapiTagFilter?: string[]; path?: string; redirect?: string; title?: ClarifyLocalizedText; icon?: string } {\n if (typeof item === 'string') return { pageRef: item }\n if ('openapi' in item) return { openapiRef: item.openapi, openapiTagFilter: item.filter?.tags, path: item.path, title: item.title, icon: item.icon }\n return { pageRef: item.page, path: item.path, redirect: item.redirect, title: item.title, icon: item.icon }\n}\n\nfunction firstNavigationPath(nodes: ClarifyNavigationNode[]): string {\n for (const node of nodes) {\n if (node.path) return node.path\n const childPath = node.children ? firstNavigationPath(node.children) : undefined\n if (childPath) return childPath\n }\n return '/'\n}\n\nfunction collectExplicitPagePathItems(tabs?: ClarifyTabsConfig): Array<{ pageRef: string; path: string }> {\n const items: Array<{ pageRef: string; path: string }> = []\n\n for (const tab of tabs ?? []) {\n if (!tab.pages || tab.pages === 'FileTree') continue\n for (const group of tab.pages) {\n for (const item of group.pages) {\n if (typeof item !== 'string' && 'page' in item && item.path) {\n items.push({ pageRef: item.page, path: item.path })\n }\n }\n }\n }\n\n return items\n}\n\nexport function applyConfiguredPageRoutePaths(routes: ContentRoute[], tabs?: ClarifyTabsConfig, i18n?: ResolvedClarifyI18nConfig): ContentRoute[] {\n const pageItems = collectExplicitPagePathItems(tabs)\n if (!pageItems.length) return routes\n\n const additions: ContentRoute[] = []\n const existingKeys = new Set(routes.map(route => `${route.locale ?? ''}:${route.basePath ?? route.path}`))\n\n for (const item of pageItems) {\n const sourceBasePath = routePathFromRef(item.pageRef)\n const targetBasePath = routePathFromRef(item.pageRef, item.path)\n if (sourceBasePath === targetBasePath) continue\n\n for (const route of routes) {\n if (route.kind !== 'mdx' || (route.basePath ?? route.path) !== sourceBasePath) continue\n\n const key = `${route.locale ?? ''}:${targetBasePath}`\n if (existingKeys.has(key)) continue\n existingKeys.add(key)\n\n additions.push({\n ...route,\n path: route.locale && i18n ? localizedRoutePath(targetBasePath, route.locale, i18n) : targetBasePath,\n basePath: targetBasePath,\n })\n }\n }\n\n const nextRoutes = [...routes, ...additions]\n const routesWithAlternates = i18n ? nextRoutes.map(route => withAlternates(route, nextRoutes, i18n)) : nextRoutes\n\n if (!i18n) return routesWithAlternates\n\n // 为默认语言生成无前缀的裸路径别名,方便不带语言前缀的 URL 也能访问\n const bareRoutes: ContentRoute[] = []\n const seenBare = new Set(routesWithAlternates.map(r => r.path))\n for (const route of routesWithAlternates) {\n if (route.locale !== i18n.defaultLocale) continue\n const bp = route.basePath ?? route.path\n if (bp === route.path || seenBare.has(bp)) continue\n seenBare.add(bp)\n bareRoutes.push({ ...route, path: bp })\n }\n\n return [...routesWithAlternates, ...bareRoutes]\n}\n\nfunction buildNavigationFromPagesConfig(routes: ContentRoute[], config?: ClarifyPagesConfig): ClarifyNavigationNode[] {\n if (!config || config === 'FileTree') return buildNavigation(routes)\n return buildNavigationFromConfig(routes, config)\n}\n\nexport function buildNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig): TabbedNavigation {\n return {\n tabs: tabs.map(tab => {\n const children = buildNavigationFromPagesConfig(routes, tab.pages)\n return {\n type: 'tab',\n path: firstNavigationPath(children),\n title: resolveLocalizedText(tab.tab, '', '') ?? '',\n icon: tab.icon,\n children,\n }\n }),\n }\n}\n\nexport function buildNavigationFromConfig(routes: ContentRoute[], config: ClarifyPagesGroup[]): ClarifyNavigationNode[] {\n const routeMap = new Map(routes.map(r => [r.path, r]))\n\n return config.map(group => {\n const children = group.pages.map(item => {\n const { pageRef, openapiRef, openapiTagFilter, path: explicitPath, redirect, title, icon } = resolvePageItem(item)\n\n if (openapiRef) {\n const path = openAPIPagePathFromRef(openapiRef, openapiTagFilter, explicitPath)\n const route = routeMap.get(path)\n return {\n path,\n title: resolveLocalizedText(title, '', '') ?? route?.title ?? kebabToTitle(path.split('/').pop() ?? openapiRef),\n icon,\n sections: route?.sections ? navigationSections(route.sections) : undefined,\n }\n }\n\n const ref = pageRef ?? ''\n const path = routePathFromRef(ref, explicitPath)\n const route = routeMap.get(path)\n return {\n path: redirect ? normalizePath(redirect) : path,\n title: resolveLocalizedText(title, '', '') ?? route?.title ?? kebabToTitle(path.split('/').pop() ?? ref),\n icon,\n sections: route?.sections ? navigationSections(route.sections) : undefined,\n }\n })\n\n return {\n path: children[0]?.path ?? '/',\n title: resolveLocalizedText(group.group, '', '') ?? '',\n icon: group.icon,\n children,\n }\n })\n}\n\nfunction localizeNavigationPaths(nodes: ClarifyNavigationNode[], locale: string, i18n: ResolvedClarifyI18nConfig): ClarifyNavigationNode[] {\n return nodes.map(node => ({\n ...node,\n path: localizedRoutePath(node.path, locale, i18n),\n children: node.children ? localizeNavigationPaths(node.children, locale, i18n) : undefined,\n }))\n}\n\nexport function buildLocalizedNavigation(routes: ContentRoute[], config: ClarifyPagesConfig | undefined, i18n?: ResolvedClarifyI18nConfig): LocalizedNavigation | undefined {\n if (!i18n) return undefined\n\n const result: LocalizedNavigation = {}\n for (const locale of i18n.locales) {\n const localeRoutes = routes.filter(route => route.locale === locale.code)\n result[locale.code] = buildLocalizedNavigationForLocale(localeRoutes, config, locale.code, i18n)\n }\n\n return result\n}\n\nfunction buildLocalizedNavigationForLocale(routes: ContentRoute[], config: ClarifyPagesConfig | undefined, locale: string, i18n: ResolvedClarifyI18nConfig): ClarifyNavigationNode[] {\n if (!config || config === 'FileTree') {\n const baseNavigation = buildNavigation(routes.map(route => ({ ...route, path: route.basePath ?? route.path })))\n return localizeNavigationPaths(baseNavigation, locale, i18n)\n }\n\n const routeMap = new Map(routes.map(route => [route.basePath ?? route.path, route]))\n return config.map(group => {\n const children = group.pages.map(item => {\n const { pageRef, openapiRef, openapiTagFilter, path: explicitPath, redirect, title, icon } = resolvePageItem(item)\n const ref = openapiRef ?? pageRef ?? ''\n const basePath = openapiRef ? openAPIPagePathFromRef(openapiRef, openapiTagFilter, explicitPath) : routePathFromRef(ref, explicitPath)\n const route = routeMap.get(basePath)\n const path = route?.path ?? localizedRoutePath(basePath, locale, i18n)\n const redirectPath = redirect ? localizedRoutePath(routePathFromRef(redirect), locale, i18n) : undefined\n\n return {\n path: redirectPath ?? path,\n title: resolveLocalizedText(title, locale, i18n.defaultLocale) ?? route?.title ?? kebabToTitle(basePath.split('/').pop() ?? ref),\n icon,\n sections: route?.sections ? navigationSections(route.sections) : undefined,\n }\n })\n\n return {\n path: children[0]?.path ?? localizedRoutePath('/', locale, i18n),\n title: resolveLocalizedText(group.group, locale, i18n.defaultLocale) ?? '',\n icon: group.icon,\n children,\n }\n })\n}\n\nexport function buildLocalizedNavigationFromTabsConfig(routes: ContentRoute[], tabs: ClarifyTabsConfig, i18n?: ResolvedClarifyI18nConfig): LocalizedTabbedNavigation | undefined {\n if (!i18n) return undefined\n\n const result: LocalizedTabbedNavigation = {}\n for (const locale of i18n.locales) {\n const localeRoutes = routes.filter(route => route.locale === locale.code)\n result[locale.code] = {\n tabs: tabs.map(tab => {\n const children = buildLocalizedNavigationForLocale(localeRoutes, tab.pages, locale.code, i18n)\n return {\n type: 'tab',\n path: firstNavigationPath(children),\n title: resolveLocalizedText(tab.tab, locale.code, i18n.defaultLocale) ?? '',\n icon: tab.icon,\n children,\n }\n }),\n }\n }\n\n return result\n}\n","import { existsSync, readFileSync, readdirSync } from 'node:fs'\nimport { join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport SwaggerParser from '@apidevtools/swagger-parser'\nimport { slug } from 'github-slugger'\n\nimport type { ContentProcessor } from '../../parsers/content.js'\nimport { kebabToTitle, routePathFromRef, virtualModuleIdFromRef } from '../../parsers/routes.js'\nimport type { ContentDiagnostic, ContentRoute, ContentSection, OpenAPISpec } from '../../types.js'\n\nconst OPENAPI_HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const\n\ntype ResolverFileInfo = { url: string }\n\nexport type OpenAPIParseResult =\n | { ok: true; spec: OpenAPISpec }\n | { ok: false; diagnostic: ContentDiagnostic }\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nfunction isSameOpenAPIFile(url: string, filePath: string): boolean {\n try {\n return resolve(fileURLToPath(url)) === resolve(filePath)\n } catch {\n return resolve(url) === resolve(filePath)\n }\n}\n\nexport function findOpenAPIRoutes(dir: string, base: string = dir): ContentRoute[] {\n const routes: ContentRoute[] = []\n if (!existsSync(dir)) return routes\n\n const entries = readdirSync(dir, { withFileTypes: true })\n for (const entry of entries) {\n const fullPath = join(dir, entry.name)\n if (entry.isDirectory()) {\n routes.push(...findOpenAPIRoutes(fullPath, base))\n continue\n }\n if (!entry.isFile() || !/\\.openapi\\.(json|yaml|yml)$/.test(entry.name)) continue\n\n const ref = relative(base, fullPath)\n const cleanPath = routePathFromRef(ref)\n routes.push({\n path: cleanPath,\n basePath: cleanPath,\n filePath: fullPath,\n virtualModuleId: virtualModuleIdFromRef(ref),\n title: kebabToTitle(cleanPath.split('/').pop() ?? 'API'),\n kind: 'openapi',\n })\n }\n\n return routes\n}\n\nfunction operationMatchesTags(operationTags: string[] | undefined, filterTags: string[] | undefined): boolean {\n if (!filterTags?.length) return true\n return operationTags?.some(tag => filterTags.includes(tag)) ?? false\n}\n\n/** Filter an OpenAPI spec to only include paths that have at least one operation matching the given tags. */\nexport function filterSpecByTags(spec: OpenAPISpec, tags: string[]): OpenAPISpec {\n const filteredPaths: Record<string, unknown> = {}\n const paths = (spec.paths ?? {}) as Record<string, unknown>\n for (const path of Object.keys(paths)) {\n const pathItem = paths[path] as Record<string, unknown> | undefined\n if (!pathItem) continue\n const ops = Object.values(pathItem)\n const hasMatch = ops.some(op => op && typeof op === 'object' && operationMatchesTags((op as Record<string, unknown>).tags as string[] | undefined, tags))\n if (hasMatch) filteredPaths[path] = pathItem\n }\n return { ...spec, paths: filteredPaths } as OpenAPISpec\n}\n\n/** Extract endpoint operations from an OpenAPI spec as page sections. */\nexport function extractOpenAPISections(spec: OpenAPISpec, filterTags?: string[]): ContentSection[] {\n const sections: ContentSection[] = []\n const paths = spec.paths ?? {}\n for (const [path, pathItem] of Object.entries(paths)) {\n if (!pathItem) continue\n for (const method of OPENAPI_HTTP_METHODS) {\n const op = pathItem[method]\n if (!op || !operationMatchesTags(op.tags, filterTags)) continue\n const title = op.summary ?? `${method.toUpperCase()} ${path}`\n sections.push({ id: slug(`${method} ${path}`), title, level: 2, badge: method.toUpperCase(), tags: op.tags })\n }\n }\n return sections\n}\n\nexport async function readOpenAPISpec(filePath: string, contentProcessor?: ContentProcessor): Promise<OpenAPIParseResult> {\n try {\n if (!contentProcessor) return { ok: true, spec: await SwaggerParser.dereference(filePath) as OpenAPISpec }\n\n const source = readFileSync(filePath, 'utf-8')\n const transformedSource = await contentProcessor.processText(source, 'openapi', filePath)\n if (transformedSource === source) return { ok: true, spec: await SwaggerParser.dereference(filePath) as OpenAPISpec }\n\n return {\n ok: true,\n spec: await SwaggerParser.dereference(filePath, {\n resolve: {\n transformedOpenAPISource: {\n order: 1,\n canRead: (file: ResolverFileInfo) => isSameOpenAPIFile(file.url, filePath),\n read: () => transformedSource,\n },\n },\n }) as OpenAPISpec,\n }\n } catch (error) {\n return {\n ok: false,\n diagnostic: {\n title: 'OpenAPI spec parse failed',\n message: `Clarify could not parse ${filePath}.`,\n filePath,\n cause: errorMessage(error),\n },\n }\n }\n}\n","import type { UISlotRegistration } from '@clarify-labs/renderer'\n\nimport { buildLocalizedNavigationFromTabsConfig, buildNavigation, buildNavigationFromTabsConfig } from '../parsers/routes.js'\nimport type { ClarifyPlugin, ContentRoute, NavigationTree, ResolvedBuildOptions, ResolvedProjectConfig } from '../types.js'\n\n// 新的虚拟模块命名 - 更清晰的职责划分\nexport const VIRTUAL_CONFIG = 'virtual:clarify/config'\nexport const VIRTUAL_ROUTES = 'virtual:clarify/routes'\nexport const VIRTUAL_SERVER_ROUTES = 'virtual:clarify/routes/server'\nexport const VIRTUAL_OPENAPI = 'virtual:clarify/openapi'\nexport const VIRTUAL_SLOTS = 'virtual:clarify/slots'\nexport const VIRTUAL_SLOT = 'virtual:clarify/slot'\nexport const VIRTUAL_CLIENT_ENTRY = 'virtual:clarify/entry-client'\nexport const RESOLVED_CLIENT_ENTRY = '\\0' + VIRTUAL_CLIENT_ENTRY\n\nexport type VirtualModules = Map<string, string>\n\ntype BuildVirtualModulesArgs = {\n projectConfig: ResolvedProjectConfig\n generateOptions: ResolvedBuildOptions\n routes: ContentRoute[]\n navigation?: NavigationTree\n plugins?: ClarifyPlugin[]\n themeEditor?: boolean\n}\n\ntype CreateClientEntryModuleOptions = {\n themeEditor?: boolean\n}\n\nexport function resolveVirtualId(id: string): string {\n return '\\0' + id\n}\n\nexport function stripVirtualPrefix(id: string): string {\n return id.startsWith('\\0') ? id.slice(1) : id\n}\n\nexport function generateConfigModule(projectConfig: ResolvedProjectConfig, buildOptions: ResolvedBuildOptions): string {\n return `export const config = ${JSON.stringify({ ...projectConfig, ...buildOptions })};`\n}\n\nfunction moduleSpecifier(value: string): string {\n return JSON.stringify(value)\n}\n\nexport function generateRoutesModule(routes: ContentRoute[], resolvedNavigation?: NavigationTree, projectConfig?: ResolvedProjectConfig, mode: 'client' | 'server' = 'client'): string {\n const imports = mode === 'server'\n ? routes.map((r, i) => `import Page${i} from ${moduleSpecifier(r.virtualModuleId)};`).join('\\n')\n : ''\n const routesArray = routes.map((r, i) => {\n const sections = r.sections && r.sections.length > 0\n ? `, sections: ${JSON.stringify(r.sections.map(s => ({ id: s.id, title: s.title, level: s.level, badge: s.badge, tags: s.tags })))}`\n : ''\n const contentArtifactUrl = r.contentArtifactUrl ? `, contentArtifactUrl: ${JSON.stringify(r.contentArtifactUrl)}` : ''\n const basePath = r.basePath ? `, basePath: ${JSON.stringify(r.basePath)}` : ''\n const locale = r.locale ? `, locale: ${JSON.stringify(r.locale)}` : ''\n const isFallback = r.isFallback ? ', isFallback: true' : ''\n const alternates = r.alternates ? `, alternates: ${JSON.stringify(r.alternates)}` : ''\n const description = r.description ? `, description: ${JSON.stringify(r.description)}` : ''\n const keywords = r.keywords && r.keywords.length > 0 ? `, keywords: ${JSON.stringify(r.keywords)}` : ''\n const sourceUrl = r.sourceUrl ? `, sourceUrl: ${JSON.stringify(r.sourceUrl)}` : ''\n const component = mode === 'server' ? `Page${i}` : `() => import(${moduleSpecifier(r.virtualModuleId)})`\n const lazy = mode === 'client' ? ', lazy: true' : ''\n return ` { path: ${JSON.stringify(r.path)}, title: ${JSON.stringify(r.title)}, component: ${component}${lazy}, kind: ${JSON.stringify(r.kind)}${basePath}${locale}${isFallback}${alternates}${description}${keywords}${sections}${contentArtifactUrl}${sourceUrl} }`\n }).join(',\\n')\n\n const navigation = resolvedNavigation ?? (projectConfig?.tabs\n ? projectConfig.i18n\n ? (buildLocalizedNavigationFromTabsConfig(routes, projectConfig.tabs, projectConfig.i18n) ?? {})\n : buildNavigationFromTabsConfig(routes, projectConfig.tabs)\n : buildNavigation(routes))\n\n return `${imports}\\n\\nexport const routes = [\\n${routesArray}\\n];\\n\\nexport const navigation = ${JSON.stringify(navigation, null, 2)};\\n`\n}\n\nexport function createClientEntryModule(options: CreateClientEntryModuleOptions = {}): string {\n return `\nimport '@clarify-labs/renderer/style.css';\nimport { render } from '@clarify-labs/renderer/client';\nimport { routes, navigation } from '${VIRTUAL_ROUTES}';\nimport { config } from '${VIRTUAL_CONFIG}';\nimport { openApis } from '${VIRTUAL_OPENAPI}';\nimport { runtimeSlots } from '${VIRTUAL_SLOTS}';\nrender({ config, routes, navigation, openApis, runtimeSlots, themeEditor: ${JSON.stringify(options.themeEditor ?? false)} });`\n}\n\n/**\n * Collect every plugin's `slots` declarations into a single runtime registry\n * module. Component modules are exported as lazy import factories so the\n * renderer can decide whether to code-split (client) or pre-resolve (SSR).\n *\n * Relative component paths are resolved against the project `root` so that\n * the generated `import()` call uses an absolute specifier — Vite cannot\n * resolve relative imports from virtual modules.\n *\n * Slot name validity is enforced at compile time by the `UISlotName`\n * type — no runtime validation is needed.\n */\nexport function createRuntimeSlotsModule(plugins: ClarifyPlugin[] = [], root: string = process.cwd()): string {\n const registrations: { plugin: string; slot: UISlotRegistration }[] = []\n for (const plugin of plugins) {\n for (const slot of plugin.slots ?? []) {\n registrations.push({ plugin: plugin.name, slot })\n }\n }\n\n if (registrations.length === 0) {\n return 'export const runtimeSlots = {};\\n'\n }\n\n const grouped = new Map<string, string[]>()\n for (const { plugin, slot } of registrations) {\n // Warn when multiple plugins register the same replace slot — only the\n // last one takes effect, which is almost certainly a configuration error.\n if (slot.name.endsWith('.replace')) {\n const existing = grouped.get(slot.name)\n if (existing) {\n console.warn(`[clarify] Multiple plugins register slot \"${slot.name}\": \"${plugin}\" overrides \"${existing[existing.length - 1]}\". Only the last registration is used.`)\n }\n }\n\n // Resolve `/`-prefixed paths relative to the project root so that\n // Vite can resolve the import from the virtual module.\n if (!slot.component.startsWith('/')) {\n throw new Error(`[clarify] Plugin \"${plugin}\" slot \"${slot.name}\" has an invalid component path \"${slot.component}\". Component paths must start with \"/\" to reference the project root.`)\n }\n const componentPath = root + slot.component\n const entry = `{ plugin: ${JSON.stringify(plugin)}, component: () => import(${moduleSpecifier(componentPath)}) }`\n const list = grouped.get(slot.name) ?? []\n list.push(entry)\n grouped.set(slot.name, list)\n }\n\n const entries = [...grouped.entries()]\n .map(([name, list]) => ` ${JSON.stringify(name)}: [\\n ${list.join(',\\n ')}\\n ]`)\n .join(',\\n')\n\n return `export const runtimeSlots = {\\n${entries}\\n};\\n`\n}\n\n/**\n * Re-exports the slot context hook from the renderer so plugin components can\n * `import { useSlot } from 'virtual:clarify/slot'` without depending on\n * renderer internals directly.\n */\nexport function createSlotModule(): string {\n return `export { useSlot } from '@clarify-labs/renderer';\\n`\n}\n\nexport function buildVirtualModules(args: BuildVirtualModulesArgs): VirtualModules {\n const modules: VirtualModules = new Map()\n const clientEntryModule = createClientEntryModule({ themeEditor: args.themeEditor })\n \n // Collect all plugins\n const allPlugins: ClarifyPlugin[] = [...(args.plugins ?? [])]\n \n modules.set(VIRTUAL_CONFIG, generateConfigModule(args.projectConfig, args.generateOptions))\n modules.set(VIRTUAL_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, 'client'))\n modules.set(VIRTUAL_SERVER_ROUTES, generateRoutesModule(args.routes, args.navigation, args.projectConfig, 'server'))\n modules.set(VIRTUAL_SLOTS, createRuntimeSlotsModule(allPlugins, args.generateOptions.projectRoot))\n modules.set(VIRTUAL_OPENAPI, generateOpenApiModule())\n modules.set(VIRTUAL_SLOT, createSlotModule())\n modules.set(VIRTUAL_CLIENT_ENTRY, clientEntryModule)\n modules.set(RESOLVED_CLIENT_ENTRY, clientEntryModule)\n\n for (const route of args.routes) {\n modules.set(route.virtualModuleId, `export { default } from ${moduleSpecifier(route.filePath)};`)\n }\n\n return modules\n}\n\n// 新的 OpenAPI 模块生成函数 - 独立出来\nexport function generateOpenApiModule(): string {\n return `export const openApis = {};`\n}\n","import { VIRTUAL_OPENAPI } from '../../core/virtual-modules.js'\nimport type { ContentDiagnostic, OpenAPISpec } from '../../types.js'\n\nexport const openApiRegistryModuleId = VIRTUAL_OPENAPI\nexport const OPENAPI_SPEC_PREFIX = 'virtual:clarify/openapi-spec/'\n\nexport function specVirtualModuleId(specKey: string): string {\n return `${OPENAPI_SPEC_PREFIX}${specKey}`\n}\n\nexport function generateOpenAPIRegistryModule(openApis: Record<string, OpenAPISpec>): string {\n return `export const openApis = ${JSON.stringify(openApis)};`\n}\n\n/** Generate a virtual module that exports a single spec as default. */\nexport function generateOpenAPISpecModule(spec: OpenAPISpec): string {\n return `export default ${JSON.stringify(spec)};`\n}\n\ntype OpenAPIPageModuleOptions = {\n /** specFileKey used for per-spec virtual module lazy-loading (namespace 2). */\n specKey: string\n /** virtual:clarify-page/… key used for OpenApisContext registry lookup (namespace 3). */\n specRegistryKey: string\n tagFilter?: string[]\n}\n\nexport function generateOpenAPIPageModule(opts: OpenAPIPageModuleOptions): string {\n const { specKey, specRegistryKey, tagFilter } = opts\n\n return [\n `import { createElement, useState, useEffect, useRef } from 'react';`,\n `import { OpenApiDocument, useOpenApis } from '@clarify-labs/renderer';`,\n `const SPEC_KEY = ${JSON.stringify(specRegistryKey)};`,\n `const TAG_FILTER = ${JSON.stringify(tagFilter ?? undefined)};`,\n `let loadPromise = null;`,\n `function loadSpec() {`,\n ` if (!loadPromise) loadPromise = import(${JSON.stringify(specVirtualModuleId(specKey))}).then(function(m) { return m.default; });`,\n ` return loadPromise;`,\n `}`,\n `export default function OpenApiRoutePage() {`,\n ` const specs = useOpenApis();`,\n ` const serverSpec = specs[SPEC_KEY];`,\n ` const [spec, setSpec] = useState(serverSpec || null);`,\n ` const mountedRef = useRef(false);`,\n ` useEffect(function() {`,\n ` if (mountedRef.current) return;`,\n ` mountedRef.current = true;`,\n ` if (spec) return;`,\n ` loadSpec().then(setSpec);`,\n ` }, []);`,\n ` if (!spec) return null;`,\n ` return createElement(OpenApiDocument, { spec: spec, tagFilter: TAG_FILTER });`,\n `}`,\n ].join('\\n')\n}\n\nexport function generateOpenAPIErrorModule(diagnostic: ContentDiagnostic): string {\n return `import { createElement } from 'react';\nconst diagnostic = ${JSON.stringify(diagnostic)};\nexport default function OpenApiErrorRoutePage() {\n return createElement('article', { className: 'flex h-full flex-col pt-16 pb-10' },\n createElement('div', { className: 'prose max-w-none flex-auto dark:prose-invert' },\n createElement('p', { className: 'mb-3 text-xs/6 font-medium tracking-widest text-red-500 uppercase dark:text-red-400' }, 'OpenAPI Error'),\n createElement('h1', null, diagnostic.title),\n createElement('p', { className: 'lead' }, diagnostic.message),\n diagnostic.filePath ? createElement('div', { className: 'not-prose mt-6 rounded-lg border border-zinc-200 bg-zinc-50 p-4 text-sm dark:border-white/10 dark:bg-white/5' },\n createElement('div', { className: 'mb-1 font-semibold text-zinc-900 dark:text-white' }, 'File'),\n createElement('code', { className: 'break-all text-zinc-700 dark:text-zinc-300' }, diagnostic.filePath)\n ) : null,\n diagnostic.cause ? createElement('div', { className: 'not-prose mt-4 rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200' },\n createElement('div', { className: 'mb-1 font-semibold' }, 'Why it happened'),\n createElement('pre', { className: 'whitespace-pre-wrap break-words text-xs' }, diagnostic.cause)\n ) : null\n )\n );\n}`\n}\n","import { relative } from 'node:path'\n\nimport { getProjectContentProcessor } from '../../core/content.js'\nimport { localizedRoutePath, openAPIPagePathFromRef, withAlternates } from '../../parsers/routes.js'\nimport type { ClarifyPagesConfig, ClarifyPagesItem, ClarifyPlugin, ContentRoute, OpenAPISpec, ResolvedProjectConfig } from '../../types.js'\n\nimport { extractOpenAPISections, filterSpecByTags, findOpenAPIRoutes, readOpenAPISpec } from './parser.js'\nimport { generateOpenAPIErrorModule, generateOpenAPIPageModule, generateOpenAPIRegistryModule, generateOpenAPISpecModule, openApiRegistryModuleId, specVirtualModuleId } from './virtual-modules.js'\n\ntype OpenAPISpecEntry = {\n spec: OpenAPISpec\n /** Source spec file path – used as deduplication key across routes. */\n filePath: string\n}\n\nfunction collectOpenAPIPageItems(config: ResolvedProjectConfig): Array<Extract<ClarifyPagesItem, { openapi: string }>> {\n const items: Array<Extract<ClarifyPagesItem, { openapi: string }>> = []\n\n function visitPages(pages?: ClarifyPagesConfig) {\n if (!pages || pages === 'FileTree') return\n for (const group of pages) {\n for (const item of group.pages) {\n if (typeof item !== 'string' && 'openapi' in item && (item.path || item.filter?.tags?.length)) items.push(item)\n }\n }\n }\n\n for (const tab of config.tabs ?? []) visitPages(tab.pages)\n\n return items\n}\n\nfunction virtualModuleIdFromPath(path: string): string {\n return `virtual:clarify-page/${path.replace(/^\\/+/, '') || 'index'}`\n}\n\nfunction createConfiguredOpenAPIRoutes(routes: ContentRoute[], config: ResolvedProjectConfig): ContentRoute[] {\n const pageItems = collectOpenAPIPageItems(config)\n if (!pageItems.length) return routes\n\n const additions: ContentRoute[] = []\n const existingKeys = new Set(routes.map(route => `${route.locale ?? ''}:${route.basePath ?? route.path}`))\n\n for (const item of pageItems) {\n const tagFilter = item.filter?.tags?.filter(Boolean)\n const sourceBasePath = openAPIPagePathFromRef(item.openapi)\n const targetBasePath = openAPIPagePathFromRef(item.openapi, tagFilter, item.path)\n if (sourceBasePath === targetBasePath && !tagFilter?.length) continue\n\n for (const route of routes) {\n if (route.kind !== 'openapi' || (route.basePath ?? route.path) !== sourceBasePath) continue\n\n const key = `${route.locale ?? ''}:${targetBasePath}`\n if (existingKeys.has(key)) continue\n existingKeys.add(key)\n\n additions.push({\n ...route,\n path: route.locale && config.i18n ? localizedRoutePath(targetBasePath, route.locale, config.i18n) : targetBasePath,\n basePath: targetBasePath,\n title: route.title,\n virtualModuleId: virtualModuleIdFromPath(targetBasePath),\n openapiTagFilter: tagFilter?.length ? tagFilter : undefined,\n })\n }\n }\n\n const nextRoutes = [...routes, ...additions]\n return config.i18n ? nextRoutes.map(route => withAlternates(route, nextRoutes, config.i18n!)) : nextRoutes\n}\n\n/** Derive a stable, deduplicated key from an absolute spec file path. */\nfunction specFileKeyFromPath(filePath: string, projectRoot: string): string {\n return relative(projectRoot, filePath).replace(/[^a-zA-Z0-9_-]/g, '_').replace(/_+/g, '_').replace(/^_|_$/g, '')\n}\n\nexport function createOpenAPIPlugin(): ClarifyPlugin {\n /** specs keyed by specFileKey (deduplicated per source file). */\n const specs = new Map<string, OpenAPISpecEntry>()\n\n return {\n name: 'clarify:openapi',\n hooks: {\n 'routes:discover': (input) => ({\n ...input,\n routes: [...input.routes, ...findOpenAPIRoutes(input.contentRoot)],\n }),\n 'routes:discovered': async (routes, ctx) => {\n specs.clear()\n\n const nextRoutes = createConfiguredOpenAPIRoutes(routes, ctx.projectConfig)\n const specByFilePath = new Map<string, OpenAPISpec>()\n\n for (const route of nextRoutes.filter(route => route.kind === 'openapi')) {\n const specFromCache = specByFilePath.get(route.filePath)\n const result = specFromCache ? { ok: true as const, spec: specFromCache } : await readOpenAPISpec(route.filePath, getProjectContentProcessor(ctx))\n if (!result.ok) {\n route.diagnostic = result.diagnostic\n route.title = route.title || 'OpenAPI parse error'\n route.sections = []\n continue\n }\n\n const spec = result.spec\n specByFilePath.set(route.filePath, spec)\n\n // Derive a stable dedup key from the spec file path\n const specKey = specFileKeyFromPath(route.filePath, ctx.generateOptions.projectRoot)\n route.specFileKey = specKey\n\n specs.set(specKey, { spec, filePath: route.filePath })\n route.title = spec.info?.title ?? route.title\n route.description = spec.info?.description ?? route.description\n route.sections = extractOpenAPISections(spec, route.openapiTagFilter)\n\n // Set route.content to filtered or full JSON for the content-artifacts plugin\n const pageSpec = route.openapiTagFilter?.length\n ? filterSpecByTags(spec, route.openapiTagFilter)\n : spec\n route.content = JSON.stringify(pageSpec)\n }\n\n return nextRoutes\n },\n 'modules:before': (modules, ctx) => {\n // ── Registry module (used by SSR to populate OpenApisContext) ──\n // Keys are unified in namespace 3 (virtual:clarify-page/…)\n // so both page modules and embedded components (useOpenApiSpec)\n // look up specs the same way.\n const registryEntries: Record<string, OpenAPISpec> = {}\n\n for (const route of ctx.routes) {\n if (route.kind !== 'openapi' || !route.specFileKey) continue\n const spec = specs.get(route.specFileKey)?.spec\n if (!spec) continue\n\n const base = (route.basePath ?? route.path).replace(/^\\//, '')\n\n // Always use an explicit locale-prefixed key so no two routes\n // can overwrite each other. Falls back to bare path only when\n // i18n is disabled (no locale on the route).\n const registryKey = route.locale\n ? `virtual:clarify-page/${route.locale}/${base}`\n : `virtual:clarify-page/${base}`\n registryEntries[registryKey] = spec\n }\n\n modules.set(openApiRegistryModuleId, generateOpenAPIRegistryModule(registryEntries))\n\n // ── Per-spec virtual modules (lazy-loaded by page modules at runtime) ──\n for (const [specKey, entry] of specs) {\n modules.set(specVirtualModuleId(specKey), generateOpenAPISpecModule(entry.spec))\n }\n\n // ── Per-route page modules ──\n for (const route of ctx.routes) {\n if (route.kind !== 'openapi') continue\n if (route.diagnostic) {\n modules.set(route.virtualModuleId, generateOpenAPIErrorModule(route.diagnostic))\n } else if (route.specFileKey) {\n const base = (route.basePath ?? route.path).replace(/^\\//, '')\n const specRegistryKey = route.locale\n ? `virtual:clarify-page/${route.locale}/${base}`\n : `virtual:clarify-page/${base}`\n modules.set(route.virtualModuleId, generateOpenAPIPageModule({\n specKey: route.specFileKey,\n specRegistryKey,\n tagFilter: route.openapiTagFilter,\n }))\n }\n }\n\n return modules\n },\n },\n }\n}\n","export function toPagefindLanguage(locale: string | undefined): string {\n const normalizedLocale = locale\n ?.trim()\n .replace(/_/g, '-')\n .split('-')\n .filter(Boolean)\n .join('-')\n // Pagefind's browser runtime lowercases the detected <html lang> value\n // before resolving the language-specific index. Keep Clarify's public\n // locale codes canonical (for example en-US / zh-CN), but use lowercase\n // BCP 47 tags internally so custom dev indexes match Pagefind runtime.\n .toLowerCase()\n\n return normalizedLocale || 'en'\n}\n","import { mkdtempSync, rmSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\n\nexport function createClarifyTempDir(name: string): string {\n return mkdtempSync(join(tmpdir(), `clarify-${name}-`))\n}\n\nexport function removeClarifyTempDir(path: string | undefined): void {\n if (!path) return\n rmSync(path, { recursive: true, force: true })\n}\n","import { createReadStream, existsSync } from 'node:fs'\nimport { extname, join, relative, resolve } from 'node:path'\n\nimport type { ViteDevServer } from 'vite'\n\nimport { toPagefindLanguage } from '../../core/search-language.js'\nimport { createClarifyTempDir, removeClarifyTempDir } from '../../core/temp-dir.js'\nimport type { ClarifyHookContext, ClarifyPlugin, ContentRoute } from '../../types.js'\n\ntype PagefindModule = typeof import('pagefind')\n\ntype GeneratePagefindIndexOptions = {\n outputRoot: string\n sourceRoot?: string\n}\n\nconst pagefindContentTypes: Record<string, string> = {\n '.css': 'text/css; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.wasm': 'application/wasm',\n}\n\nfunction assertNoPagefindErrors(action: string, errors: string[] | undefined): void {\n if (!errors?.length) return\n throw new Error(`[clarify] Pagefind ${action} failed:\\n${errors.join('\\n')}`)\n}\n\nasync function generatePagefindIndex(options: GeneratePagefindIndexOptions): Promise<number> {\n const pagefind = await import('pagefind') as PagefindModule\n const { errors, index } = await pagefind.createIndex({\n excludeSelectors: [\n '[data-pagefind-ignore]',\n 'script',\n 'style',\n 'svg',\n ],\n includeCharacters: '._-/#:@',\n keepIndexUrl: false,\n verbose: false,\n writePlayground: false,\n })\n\n assertNoPagefindErrors('createIndex', errors)\n if (!index) throw new Error('[clarify] Pagefind did not create an index.')\n\n try {\n const addResult = await index.addDirectory({ path: options.sourceRoot ?? options.outputRoot, glob: '**/*.html' })\n assertNoPagefindErrors('addDirectory', addResult.errors)\n\n const writeResult = await index.writeFiles({ outputPath: join(options.outputRoot, 'pagefind') })\n assertNoPagefindErrors('writeFiles', writeResult.errors)\n\n return addResult.page_count\n } finally {\n await index.deleteIndex()\n await pagefind.close()\n }\n}\n\nfunction routeSearchContent(route: ContentRoute): string {\n return [\n route.title,\n route.description,\n route.keywords?.join(' '),\n route.sections?.map(section => section.title).join(' '),\n route.content,\n ].filter(Boolean).join('\\n\\n')\n}\n\nasync function generateDevSearchIndex(ctx: ClarifyHookContext, root: string): Promise<void> {\n const pagefind = await import('pagefind') as PagefindModule\n const { errors, index } = await pagefind.createIndex({\n includeCharacters: '._-/#:@',\n keepIndexUrl: false,\n verbose: false,\n writePlayground: false,\n })\n\n assertNoPagefindErrors('createIndex', errors)\n if (!index) throw new Error('[clarify] Pagefind did not create an index.')\n\n try {\n let pageCount = 0\n for (const route of ctx.routes) {\n const content = routeSearchContent(route)\n if (!content.trim()) continue\n const result = await index.addCustomRecord({\n url: route.path,\n content,\n language: toPagefindLanguage(route.locale ?? ctx.projectConfig.i18n?.defaultLocale),\n meta: {\n title: route.title,\n },\n })\n assertNoPagefindErrors(`addCustomRecord ${route.path}`, result.errors)\n pageCount += 1\n }\n\n const writeResult = await index.writeFiles({ outputPath: join(root, 'pagefind') })\n assertNoPagefindErrors('writeFiles', writeResult.errors)\n console.log(`[clarify] Dev search index generated for ${pageCount} pages.`)\n } finally {\n await index.deleteIndex()\n await pagefind.close()\n }\n}\n\nfunction normalizeDevPagefindPath(rawUrl: string | undefined, routePrefix: string): string | undefined {\n const pathname = rawUrl?.split('?')[0]\n if (!pathname) return undefined\n\n const normalizedPrefix = routePrefix && routePrefix !== '/' ? `/${routePrefix.replace(/^\\/+|\\/+$/g, '')}` : ''\n const pagefindPath = normalizedPrefix && pathname.startsWith(`${normalizedPrefix}/pagefind/`)\n ? pathname.slice(normalizedPrefix.length)\n : pathname\n\n return pagefindPath.startsWith('/pagefind/') ? pagefindPath : undefined\n}\n\nfunction serveDevPagefind(server: ViteDevServer, getRoot: () => string | undefined, ctx: ClarifyHookContext): void {\n server.middlewares.use((req, res, next) => {\n const root = getRoot()\n const pagefindPath = normalizeDevPagefindPath(req.url, ctx.projectConfig.routePrefix)\n if (!root || !pagefindPath) {\n next()\n return\n }\n\n const filePath = join(root, pagefindPath)\n const relativePath = relative(root, filePath)\n if (relativePath.startsWith('..') || relativePath === '' || !existsSync(filePath)) {\n next()\n return\n }\n\n const contentType = pagefindContentTypes[extname(filePath)] ?? 'application/octet-stream'\n res.setHeader('Content-Type', contentType)\n createReadStream(filePath).pipe(res)\n })\n}\n\nexport function createSearchIndexPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:search-index',\n hooks: {\n async 'dev:configureServer'(server, ctx) {\n let currentRoot: string | undefined\n const staleRoots = new Set<string>()\n\n const replaceDevIndex = async () => {\n const nextRoot = createClarifyTempDir('pagefind')\n await generateDevSearchIndex(ctx, nextRoot)\n const previousRoot = currentRoot\n currentRoot = nextRoot\n if (previousRoot) {\n staleRoots.add(previousRoot)\n setTimeout(() => {\n staleRoots.delete(previousRoot)\n removeClarifyTempDir(previousRoot)\n }, 30_000).unref?.()\n }\n }\n\n serveDevPagefind(server, () => currentRoot, ctx)\n await replaceDevIndex()\n\n let regenerateTimer: ReturnType<typeof setTimeout> | undefined\n const regenerate = (filePath: string) => {\n if (!/\\.(md|mdx|json|ya?ml)$/i.test(filePath)) return\n if (regenerateTimer) clearTimeout(regenerateTimer)\n regenerateTimer = setTimeout(() => {\n void replaceDevIndex().catch((err: unknown) => {\n console.error('[clarify] Failed to regenerate dev search index:', err)\n })\n }, 100)\n }\n\n server.watcher.on('add', regenerate)\n server.watcher.on('change', regenerate)\n server.watcher.on('unlink', regenerate)\n\n server.httpServer?.once('close', () => {\n if (regenerateTimer) clearTimeout(regenerateTimer)\n removeClarifyTempDir(currentRoot)\n for (const staleRoot of staleRoots) removeClarifyTempDir(staleRoot)\n })\n },\n async 'build:done'(ctx) {\n const outputDirectory = ctx.generateOptions.outputDirectory\n if (!outputDirectory) return\n\n const outputRoot = resolve(ctx.generateOptions.projectRoot, outputDirectory)\n const pageCount = await generatePagefindIndex({ outputRoot })\n console.log(`[clarify] Search index generated for ${pageCount} pages.`)\n },\n },\n }\n}\n","import type { ContentRoute, ResolvedProjectConfig } from '../../types.js'\n\nfunction trimTrailingSlash(value: string): string {\n return value.replace(/\\/+$/, '')\n}\n\nfunction normalizeRoutePrefix(routePrefix: string): string {\n if (!routePrefix || routePrefix === '/') return ''\n return `/${routePrefix.replace(/^\\/+|\\/+$/g, '')}`\n}\n\nfunction routeUrl(siteUrl: string, routePrefix: string, routePath: string): string {\n const base = trimTrailingSlash(siteUrl)\n const prefix = normalizeRoutePrefix(routePrefix)\n const path = routePath === '/' ? '' : routePath.replace(/^\\/+/, '/')\n return `${base}${prefix}${path}` || base\n}\n\nfunction escapeXml(value: string): string {\n return value\n .replaceAll('&', '&amp;')\n .replaceAll('<', '&lt;')\n .replaceAll('>', '&gt;')\n .replaceAll('\"', '&quot;')\n .replaceAll(\"'\", '&apos;')\n}\n\nfunction publicRoutes(routes: ContentRoute[]): ContentRoute[] {\n return routes.filter(route => route.path !== '/404')\n}\n\nexport function createSitemapXml(routes: ContentRoute[], config: ResolvedProjectConfig): string | undefined {\n if (!config.siteUrl) return undefined\n\n const urls = publicRoutes(routes)\n .map(route => routeUrl(config.siteUrl!, config.routePrefix, route.path))\n .filter((url, index, list) => list.indexOf(url) === index)\n .sort()\n\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">',\n ...urls.map(url => ` <url><loc>${escapeXml(url)}</loc></url>`),\n '</urlset>',\n '',\n ].join('\\n')\n}\n\nexport function createRobotsTxt(config: ResolvedProjectConfig): string | undefined {\n if (!config.siteUrl) return undefined\n const sitemapUrl = routeUrl(config.siteUrl, config.routePrefix, '/sitemap.xml')\n return [\n 'User-agent: *',\n 'Allow: /',\n `Sitemap: ${sitemapUrl}`,\n '',\n ].join('\\n')\n}\n","import type { ClarifyEmitAsset, ClarifyPlugin } from '../../types.js'\n\nimport { createRobotsTxt, createSitemapXml } from './artifacts.js'\n\nexport function createSeoPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:seo',\n hooks: {\n 'build:assets'(ctx) {\n const sitemap = createSitemapXml(ctx.routes, ctx.projectConfig)\n const robots = createRobotsTxt(ctx.projectConfig)\n if (!sitemap || !robots) return []\n\n const assets: ClarifyEmitAsset[] = [\n { fileName: 'sitemap.xml', source: sitemap },\n { fileName: 'robots.txt', source: robots },\n ]\n return assets\n },\n },\n }\n}\n","import { relative } from 'node:path'\n\nimport type { ClarifySourceConfig, ContentRoute } from '../../types.js'\n\nfunction trimSlashes(value: string): string {\n return value.replace(/^\\/+|\\/+$/g, '')\n}\n\nfunction normalizeRepositoryUrl(repository: string): string {\n return repository.replace(/\\.git$/, '').replace(/\\/+$/, '')\n}\n\nfunction encodePath(path: string): string {\n return path\n .split('/')\n .filter(Boolean)\n .map(segment => encodeURIComponent(segment))\n .join('/')\n}\n\nexport function createSourceUrl(filePath: string, contentRoot: string, source: ClarifySourceConfig): string {\n const repository = normalizeRepositoryUrl(source.repository)\n const branch = source.branch ?? 'main'\n const directory = source.directory ? trimSlashes(source.directory) : ''\n const relativePath = relative(contentRoot, filePath).replaceAll('\\\\', '/')\n const sourcePath = [directory, relativePath].filter(Boolean).join('/')\n return `${repository}/edit/${encodeURIComponent(branch)}/${encodePath(sourcePath)}`\n}\n\nexport function attachSourceUrls(routes: ContentRoute[], contentRoot: string, source?: ClarifySourceConfig): void {\n if (!source) return\n for (const route of routes) {\n route.sourceUrl = createSourceUrl(route.filePath, contentRoot, source)\n }\n}\n","import { join } from 'node:path'\n\nimport type { ClarifyPlugin } from '../../types.js'\n\nimport { attachSourceUrls } from './source-links.js'\n\nexport function createSourceLinksPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:source-links',\n hooks: {\n 'routes:discovered': (routes, ctx) => {\n const contentRoot = join(ctx.generateOptions.projectRoot, ctx.generateOptions.rootDirectory)\n attachSourceUrls(routes, contentRoot, ctx.projectConfig.source)\n return routes\n },\n },\n }\n}\n","import type { ClarifyVariablesConfig, ClarifyVariableValue } from '../types.js'\n\nconst variablePattern = /{{\\s*([A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*)\\s*}}/g\n\nfunction getVariableValue(variables: ClarifyVariablesConfig, path: string): ClarifyVariableValue | undefined {\n let current: ClarifyVariableValue | undefined = variables\n for (const segment of path.split('.')) {\n if (!current || typeof current !== 'object' || Array.isArray(current)) return undefined\n current = current[segment]\n }\n return current\n}\n\nfunction stringifyVariableValue(variables: ClarifyVariablesConfig, path: string, stack: string[]): string | undefined {\n if (stack.includes(path)) {\n throw new Error(`[clarify] variable \"${path}\" contains a circular reference: ${[...stack, path].join(' -> ')}`)\n }\n\n const value = getVariableValue(variables, path)\n if (value === undefined || typeof value === 'object') return undefined\n if (typeof value !== 'string') return String(value)\n\n return value.replace(variablePattern, (match, nestedPath: string) => stringifyVariableValue(variables, nestedPath, [...stack, path]) ?? match)\n}\n\nexport function applyVariables(content: string, variables: ClarifyVariablesConfig = {}): string {\n return content.replace(variablePattern, (match, path: string) => stringifyVariableValue(variables, path, []) ?? match)\n}\n","import { applyVariables } from '../../parsers/variables.js'\nimport type { ClarifyVariablesConfig, ClarifyPlugin } from '../../types.js'\n\nfunction applyVariablesToFrontmatter(frontmatter: Record<string, unknown>, variables: ClarifyVariablesConfig): Record<string, unknown> {\n const nextFrontmatter = { ...frontmatter }\n for (const key of ['title', 'description'] as const) {\n if (typeof nextFrontmatter[key] !== 'string') continue\n nextFrontmatter[key] = applyVariables(nextFrontmatter[key], variables)\n }\n return nextFrontmatter\n}\n\nexport function createVariablesPlugin(): ClarifyPlugin {\n return {\n name: 'clarify:variables',\n hooks: {\n 'content:transform': (input, ctx) => ({\n ...input,\n frontmatter: applyVariablesToFrontmatter(input.frontmatter, ctx.projectConfig.variables),\n content: applyVariables(input.content, ctx.projectConfig.variables),\n }),\n },\n }\n}\n","import { createContentArtifactsPlugin } from '../plugins/content-artifacts/index.js'\nimport { createHtmlShellPlugin } from '../plugins/html-shell/index.js'\nimport { createOpenAPIPlugin } from '../plugins/openapi/index.js'\nimport { createSearchIndexPlugin } from '../plugins/search-index/index.js'\nimport { createSeoPlugin } from '../plugins/seo/index.js'\nimport { createSourceLinksPlugin } from '../plugins/source-links/index.js'\nimport { createVariablesPlugin } from '../plugins/variables/index.js'\nimport type { ClarifyPlugin } from '../types.js'\n\nexport type BuiltinPluginOptions = {\n htmlShell?: boolean\n}\n\nexport function createBuiltinPlugins(options: BuiltinPluginOptions = {}): ClarifyPlugin[] {\n const plugins = [createVariablesPlugin(), createOpenAPIPlugin(), createSourceLinksPlugin(), createContentArtifactsPlugin(), createSeoPlugin(), createSearchIndexPlugin()]\n if (options.htmlShell ?? true) plugins.push(createHtmlShellPlugin())\n return plugins\n}\n","import { z } from 'zod'\n\nimport type { ClarifyVariableValue, ClarifyProjectConfig } from '../types.js'\n\nexport const clarifyLogoConfigSchema = z.union([\n z.string(),\n z.object({\n light: z.string().optional(),\n dark: z.string().optional(),\n }),\n])\n\nexport const clarifyFaviconConfigSchema = z.union([\n z.string(),\n z.object({\n light: z.string().optional(),\n dark: z.string().optional(),\n }),\n])\n\nexport const clarifyLocalizedTextSchema = z.union([\n z.string(),\n z.record(z.string(), z.string()),\n])\n\nexport const clarifyLocaleConfigSchema = z.object({\n code: z.string(),\n label: z.string(),\n dir: z.union([z.literal('ltr'), z.literal('rtl')]).optional(),\n})\n\nexport const clarifyI18nConfigSchema = z.object({\n defaultLocale: z.string().optional(),\n missing: z.union([z.literal('fallback'), z.literal('404'), z.literal('hide')]).optional(),\n locales: z.array(clarifyLocaleConfigSchema).min(1),\n}).superRefine((config, ctx) => {\n const localeCodes = new Set<string>()\n for (const [index, locale] of config.locales.entries()) {\n if (localeCodes.has(locale.code)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `Duplicate locale code \"${locale.code}\"`,\n path: ['locales', index, 'code'],\n })\n }\n localeCodes.add(locale.code)\n }\n\n if (config.defaultLocale && !localeCodes.has(config.defaultLocale)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'defaultLocale must be one of i18n.locales',\n path: ['defaultLocale'],\n })\n }\n})\n\nexport const clarifyNavbarLinkSchema = z.object({\n label: clarifyLocalizedTextSchema,\n href: z.string(),\n external: z.boolean().optional(),\n})\n\nexport const clarifyBannerConfigOptionsSchema = z.object({\n content: clarifyLocalizedTextSchema,\n dismissible: z.boolean().optional(),\n link: clarifyNavbarLinkSchema.optional(),\n}).strict()\n\nexport const clarifyBannerConfigSchema = clarifyBannerConfigOptionsSchema\n\nexport const clarifyFooterConfigSchema = z.object({\n links: z.array(clarifyNavbarLinkSchema).optional(),\n socials: z.record(z.string(), z.string()).optional(),\n copyright: clarifyLocalizedTextSchema.optional(),\n}).strict()\n\nexport const clarifyVariableValueSchema: z.ZodType<ClarifyVariableValue> = z.lazy(() => z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.record(z.string(), clarifyVariableValueSchema),\n]))\n\nexport const clarifyVariablesConfigSchema = z.record(z.string(), clarifyVariableValueSchema)\n\nexport const clarifySourceConfigSchema = z.object({\n repository: z.string(),\n branch: z.string().optional(),\n directory: z.string().optional(),\n})\n\nexport const clarifyPagesItemSchema = z.union([\n z.string(),\n z.object({\n page: z.string(),\n path: z.string().optional(),\n title: clarifyLocalizedTextSchema.optional(),\n icon: z.string().optional(),\n redirect: z.string().optional(),\n }),\n z.object({\n openapi: z.string(),\n path: z.string().optional(),\n icon: z.string().optional(),\n title: clarifyLocalizedTextSchema.optional(),\n filter: z.object({\n tags: z.array(z.string()).optional(),\n }).optional(),\n }),\n])\n\nexport const clarifyPagesGroupSchema = z.object({\n group: clarifyLocalizedTextSchema,\n icon: z.string().optional(),\n pages: z.array(clarifyPagesItemSchema),\n})\n\nexport const clarifyPagesConfigSchema = z.union([\n z.array(clarifyPagesGroupSchema),\n z.literal('FileTree'),\n])\n\nexport const clarifyTabItemSchema = z.object({\n tab: clarifyLocalizedTextSchema,\n icon: z.string().optional(),\n pages: clarifyPagesConfigSchema.optional(),\n})\n\nexport const clarifyTabsConfigSchema = z.array(clarifyTabItemSchema)\n\nexport const clarifyThemePresetSchema = z.enum(['default', 'base'])\n\nexport const clarifyThemeModeColorValueSchema = z.object({\n light: z.string().optional(),\n dark: z.string().optional(),\n})\n\nexport const clarifyThemeColorValueSchema = z.union([z.string(), clarifyThemeModeColorValueSchema])\n\nexport const clarifyThemeColorTokensConfigSchema = z.object({\n primary: clarifyThemeColorValueSchema.optional(),\n accent: clarifyThemeColorValueSchema.optional(),\n background: clarifyThemeColorValueSchema.optional(),\n foreground: clarifyThemeColorValueSchema.optional(),\n surface: clarifyThemeColorValueSchema.optional(),\n muted: clarifyThemeColorValueSchema.optional(),\n border: clarifyThemeColorValueSchema.optional(),\n codeBackground: clarifyThemeColorValueSchema.optional(),\n})\n\nexport const clarifyThemeRadiusTokensConfigSchema = z.object({\n sm: z.string().optional(),\n md: z.string().optional(),\n lg: z.string().optional(),\n xl: z.string().optional(),\n})\n\nexport const clarifyThemeTokensConfigSchema = z.object({\n colors: clarifyThemeColorTokensConfigSchema.optional(),\n radius: clarifyThemeRadiusTokensConfigSchema.optional(),\n})\n\nexport const clarifyThemeLayoutConfigSchema = z.object({\n maxWidth: z.string().optional(),\n})\n\nexport const clarifyThemeConfigSchema = z.object({\n preset: clarifyThemePresetSchema.optional(),\n tokens: clarifyThemeTokensConfigSchema.optional(),\n layout: clarifyThemeLayoutConfigSchema.optional(),\n editor: z.boolean().optional(),\n})\n\nexport const clarifyProjectConfigSchema = z.object({\n title: z.string().optional(),\n description: z.string().optional(),\n siteUrl: z.string().optional(),\n source: clarifySourceConfigSchema.optional(),\n logo: clarifyLogoConfigSchema.optional(),\n homeUrl: z.string().optional(),\n favicon: clarifyFaviconConfigSchema.optional(),\n theme: clarifyThemeConfigSchema.optional(),\n routePrefix: z.string().optional(),\n assetPrefix: z.string().optional(),\n navbar: z.object({\n links: z.array(clarifyNavbarLinkSchema).optional(),\n }).optional(),\n banner: clarifyBannerConfigSchema.optional(),\n footer: clarifyFooterConfigSchema.optional(),\n variables: clarifyVariablesConfigSchema.optional(),\n i18n: clarifyI18nConfigSchema.optional(),\n tabs: clarifyTabsConfigSchema.optional(),\n}) satisfies z.ZodType<ClarifyProjectConfig>\n\nexport type ClarifyProjectConfigInput = z.input<typeof clarifyProjectConfigSchema>\n","import { themePresets } from '@clarify-labs/renderer'\n\nimport type { ClarifyThemeConfig, ResolvedClarifyThemeConfig } from '../types.js'\n\nexport { themePresets }\n\nexport function resolveThemeConfig(theme: ClarifyThemeConfig = {}): ResolvedClarifyThemeConfig {\n const preset = theme.preset ?? 'default'\n const presetTheme = themePresets[preset] as ResolvedClarifyThemeConfig\n\n return {\n preset,\n tokens: {\n colors: {\n ...presetTheme.tokens.colors,\n ...theme.tokens?.colors,\n },\n radius: {\n ...presetTheme.tokens.radius,\n ...theme.tokens?.radius,\n },\n },\n layout: {\n ...presetTheme.layout,\n ...theme.layout,\n },\n editor: theme.editor ?? presetTheme.editor,\n }\n}\n","import type { ZodError } from 'zod'\n\nimport type { ClarifyI18nConfig, ClarifyProjectConfig, ResolvedClarifyI18nConfig, ResolvedProjectConfig } from '../types.js'\n\nimport { clarifyProjectConfigSchema } from './config-schema.js'\nimport { resolveThemeConfig } from './theme.js'\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n return path.reduce<string>((result, segment) => {\n if (typeof segment === 'number') return `${result}[${segment}]`\n const key = String(segment)\n return result ? `${result}.${key}` : key\n }, '')\n}\n\nfunction formatProjectConfigError(error: ZodError): string {\n const issue = error.issues[0]\n if (!issue) return '[clarify] config is invalid'\n\n const path = formatIssuePath(issue.path)\n if (!path) return `[clarify] config must contain an object: ${issue.message}`\n\n return `[clarify] config field \"${path}\" is invalid: ${issue.message}`\n}\n\nexport function validateProjectConfig(value: unknown): ClarifyProjectConfig {\n const result = clarifyProjectConfigSchema.safeParse(value)\n if (!result.success) {\n throw new Error(formatProjectConfigError(result.error))\n }\n return result.data\n}\n\nfunction resolveI18nConfig(i18n?: ClarifyI18nConfig): ResolvedClarifyI18nConfig | undefined {\n if (!i18n) return undefined\n\n const firstLocale = i18n.locales[0]?.code\n const defaultLocale = i18n.defaultLocale ?? firstLocale\n if (!defaultLocale) return undefined\n\n return {\n defaultLocale,\n missing: i18n.missing ?? 'fallback',\n locales: i18n.locales,\n }\n}\n\nfunction resolveRoutePrefix(routePrefix?: string): string {\n const trimmed = routePrefix?.trim()\n if (!trimmed || trimmed === '/') return '/'\n\n return `/${trimmed.replace(/^\\/+|\\/+$/g, '')}/`\n}\n\nfunction resolveAssetPrefix(assetPrefix: string | undefined, routePrefix: string): string {\n const trimmed = assetPrefix?.trim()\n if (trimmed === undefined) return routePrefix\n if (trimmed === './' || trimmed === '') return trimmed || '/'\n if (!trimmed || trimmed === '/') return '/'\n if (/^[a-z][a-z\\d+.-]*:\\/\\//i.test(trimmed)) return trimmed.endsWith('/') ? trimmed : `${trimmed}/`\n if (trimmed.startsWith('./') || trimmed.startsWith('../')) return trimmed.endsWith('/') ? trimmed : `${trimmed}/`\n\n return `/${trimmed.replace(/^\\/+|\\/+$/g, '')}/`\n}\n\nexport function resolveProjectConfig(config: ClarifyProjectConfig = {}): ResolvedProjectConfig {\n const routePrefix = resolveRoutePrefix(config.routePrefix)\n\n return {\n title: config.title ?? 'Clarify Docs',\n description: config.description ?? '',\n siteUrl: config.siteUrl,\n source: config.source,\n logo: config.logo,\n homeUrl: config.homeUrl,\n favicon: config.favicon,\n routePrefix,\n assetPrefix: resolveAssetPrefix(config.assetPrefix, routePrefix),\n theme: resolveThemeConfig(config.theme),\n navbar: config.navbar,\n banner: config.banner,\n footer: config.footer,\n variables: config.variables ?? {},\n i18n: resolveI18nConfig(config.i18n),\n tabs: config.tabs,\n }\n}\n","import { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport type { ClarifyPlugin } from '../types.js'\n\nconst GENERATED_FILE_NAME = 'clarify-env.d.ts'\n\n/**\n * Template for the generated `clarify-env.d.ts` file.\n * Edit this template directly if you need to change the type declarations.\n * This avoids the complexity of reading external files at runtime after bundling.\n */\nconst CLARIFY_ENV_TEMPLATE = `// This file is generated by Clarify. Do not edit it manually.\n// It provides ambient type declarations for Clarify virtual modules used in\n// plugin and slot code, so the TypeScript language service can resolve them.\n\ndeclare module 'virtual:clarify/slot' {\n import type { SlotContext } from '@clarify-labs/cli'\n\n export function useSlot(): SlotContext\n}\n\ndeclare module 'virtual:clarify/slots' {\n import type { ComponentType } from 'react'\n\n export type RuntimeSlotEntry = {\n plugin: string\n /** Lazy import factory — yields the default-exported React component. */\n component: () => Promise<{ default: ComponentType }>\n }\n\n export const runtimeSlots: Record<string, RuntimeSlotEntry[]>\n}\n`\n\nexport function generateClarifyEnvDts(_plugins: ClarifyPlugin[]): string {\n return CLARIFY_ENV_TEMPLATE\n}\n\n/**\n * Writes `clarify-env.d.ts` into the project root. Only rewrites when content\n * changes to avoid triggering unnecessary file watchers, and never overwrites a\n * user-authored file that does not carry the generated marker.\n */\nexport function writeClarifyEnvDts(projectRoot: string, plugins: ClarifyPlugin[]): void {\n const filePath = join(projectRoot, GENERATED_FILE_NAME)\n const next = generateClarifyEnvDts(plugins)\n\n if (existsSync(filePath)) {\n const current = readFileSync(filePath, 'utf-8')\n if (current === next) return\n // Guard against clobbering a hand-written file that happens to share the name.\n if (!current.startsWith('// This file is generated by Clarify.')) return\n }\n\n writeFileSync(filePath, next, 'utf-8')\n}\n","import type { ClarifyPlugin, ClarifyProjectConfig } from '../types.js'\n\nexport type ClarifyBuildOptions = ClarifyProjectConfig & {\n /** Project root directory. Defaults to the current working directory. */\n projectRoot?: string\n /** Root directory for content sources. Default: 'source' */\n rootDirectory?: string\n /** Output directory for the built docs site. When omitted, Vite's build.outDir is used. */\n outputDirectory?: string\n /** Static generation behavior. */\n ssg?: {\n /** Fail the build when SSG fails. Default: true. */\n failOnError?: boolean\n }\n\n /** Clarify plugin extensions for translation, search, and other build-time features. */\n plugins?: ClarifyPlugin[]\n}\n\nexport type ResolvedBuildOptions = {\n projectRoot: string\n rootDirectory: string\n outputDirectory?: string\n ssg: {\n failOnError: boolean\n }\n}\n\nexport function resolveBuildOptions(options: ClarifyBuildOptions = {}): ResolvedBuildOptions {\n return {\n projectRoot: options.projectRoot ?? process.cwd(),\n rootDirectory: options.rootDirectory ?? 'source',\n outputDirectory: options.outputDirectory,\n ssg: {\n failOnError: options.ssg?.failOnError ?? true,\n },\n }\n}\n","import { join, relative } from 'node:path'\n\nimport { applyConfiguredPageRoutePaths, buildLocalizedNavigationFromTabsConfig, buildNavigation, buildNavigationFromTabsConfig, findContentRoutes, localizedRoutePath, virtualModuleIdFromRef, withAlternates } from '../parsers/routes.js'\nimport type { ClarifyHookContext, ClarifyPlugin, ContentRoute, NavigationTree } from '../types.js'\n\nimport { createBuiltinPlugins } from './builtin.js'\nimport { resolveProjectConfig } from './config.js'\nimport { createProjectContentProcessor, getProjectContentProcessor, setProjectContentProcessor } from './content.js'\nimport { runHooks } from './hooks.js'\nimport { resolveBuildOptions, type ClarifyBuildOptions, type ResolvedBuildOptions } from './options.js'\n\nexport type ResolvedClarifySite = {\n root: string\n contentRoot: string\n projectConfig: ReturnType<typeof resolveProjectConfig>\n generateOptions: ResolvedBuildOptions\n plugins: ClarifyPlugin[]\n ctx: ClarifyHookContext\n routes: ContentRoute[]\n navigation: NavigationTree\n}\n\nexport type ResolveClarifySiteOptions = {\n includeHtmlShellPlugin?: boolean\n}\n\nasync function discoverRoutesForRoot(routeRoot: string, locale: string | undefined, plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<ContentRoute[]> {\n const discovered = await runHooks(plugins, 'routes:discover', {\n contentRoot: routeRoot,\n locale,\n routes: await findContentRoutes(routeRoot, routeRoot, { contentProcessor: getProjectContentProcessor(ctx) }),\n }, ctx)\n return discovered.routes\n}\n\nasync function discoverRoutes(root: string, contentRoot: string, plugins: ClarifyPlugin[], ctx: ClarifyHookContext): Promise<ContentRoute[]> {\n const i18n = ctx.projectConfig.i18n\n if (!i18n) return discoverRoutesForRoot(contentRoot, undefined, plugins, ctx)\n\n const localizedRoutes: ContentRoute[] = []\n for (const locale of i18n.locales) {\n const localeRoot = join(contentRoot, locale.code)\n const discovered = await discoverRoutesForRoot(localeRoot, locale.code, plugins, ctx)\n for (const route of discovered) {\n const basePath = route.basePath ?? route.path\n localizedRoutes.push({\n ...route,\n path: localizedRoutePath(basePath, locale.code, i18n),\n basePath,\n locale: locale.code,\n virtualModuleId: virtualModuleIdFromRef(relative(contentRoot, route.filePath)),\n })\n }\n }\n\n if (i18n.missing === 'fallback') {\n const routeByLocaleAndBase = new Map(localizedRoutes.map(route => [`${route.locale ?? ''}:${route.basePath ?? route.path}`, route]))\n const defaultRoutes = localizedRoutes.filter(route => route.locale === i18n.defaultLocale)\n for (const sourceRoute of defaultRoutes) {\n const basePath = sourceRoute.basePath ?? sourceRoute.path\n for (const locale of i18n.locales) {\n const key = `${locale.code}:${basePath}`\n if (routeByLocaleAndBase.has(key)) continue\n localizedRoutes.push({\n ...sourceRoute,\n path: localizedRoutePath(basePath, locale.code, i18n),\n locale: locale.code,\n isFallback: true,\n })\n }\n }\n }\n\n const routesWithAlternates = localizedRoutes.map(route => withAlternates(route, localizedRoutes, i18n))\n\n // 为默认语言生成无前缀的裸路径别名 (/example),方便不带语言前缀的 URL 也能访问\n const defaultLocale = i18n.defaultLocale\n const bareRoutes: ContentRoute[] = []\n const seenBare = new Set(routesWithAlternates.map(r => r.path))\n for (const route of routesWithAlternates) {\n if (route.locale !== defaultLocale) continue\n const bp = route.basePath ?? route.path\n if (bp === route.path || seenBare.has(bp)) continue\n seenBare.add(bp)\n bareRoutes.push({ ...route, path: bp })\n }\n\n return [...routesWithAlternates, ...bareRoutes]\n}\n\nexport async function resolveClarifySite(options: ClarifyBuildOptions = {}, resolveOptions: ResolveClarifySiteOptions = {}): Promise<ResolvedClarifySite> {\n const root = options.projectRoot ?? process.cwd()\n const projectConfig = resolveProjectConfig(options)\n const generateOptions = resolveBuildOptions(options)\n const contentRoot = join(root, generateOptions.rootDirectory)\n const plugins = [...createBuiltinPlugins({ htmlShell: resolveOptions.includeHtmlShellPlugin }), ...(options.plugins ?? [])]\n const ctx: ClarifyHookContext = { projectConfig, generateOptions, routes: [], navigation: [] }\n setProjectContentProcessor(ctx, createProjectContentProcessor(plugins, ctx))\n\n let routes = await discoverRoutes(root, contentRoot, plugins, ctx)\n routes = await runHooks(plugins, 'routes:discovered', routes, ctx)\n routes = applyConfiguredPageRoutePaths(routes, projectConfig.tabs, projectConfig.i18n)\n\n const defaultNavigation = projectConfig.tabs\n ? projectConfig.i18n\n ? (buildLocalizedNavigationFromTabsConfig(routes, projectConfig.tabs, projectConfig.i18n) ?? {})\n : buildNavigationFromTabsConfig(routes, projectConfig.tabs)\n : buildNavigation(routes)\n const resolved = await runHooks(plugins, 'routes:resolved', { routes, navigation: defaultNavigation }, ctx)\n routes = resolved.routes\n const navigation = resolved.navigation\n ctx.routes = routes\n ctx.navigation = navigation\n\n return {\n root,\n contentRoot,\n projectConfig,\n generateOptions,\n plugins,\n ctx,\n routes,\n navigation,\n }\n}\n","import { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\n\nimport type { AliasOptions } from 'vite'\n\nconst requireFromCli = createRequire(import.meta.url)\n\nfunction resolveCliDependency(id: string): string {\n return requireFromCli.resolve(id)\n}\n\nfunction resolvePackageExport(packageName: string, subpath: string, condition: 'import' | 'require' = 'import'): string {\n const packageJsonPath = requireFromCli.resolve(`${packageName}/package.json`)\n const packageRoot = dirname(packageJsonPath)\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n exports?: Record<string, string | Record<string, string>>\n }\n const exportKey = subpath ? `./${subpath}` : '.'\n const exportEntry = packageJson.exports?.[exportKey]\n const target = typeof exportEntry === 'string'\n ? exportEntry\n : exportEntry?.[condition] ?? exportEntry?.default\n\n if (!target) {\n throw new Error(`[clarify] Unable to resolve ${packageName}/${subpath}`)\n }\n\n return join(packageRoot, target)\n}\n\n/**\n * Resolve Clarify's framework/runtime dependencies from the CLI package instead\n * of from the user's documentation project. This keeps content-only projects\n * free from React, renderer, and tsconfig requirements.\n */\nexport function createClarifyRuntimeAliases(): AliasOptions {\n return [\n { find: /^@clarify-labs\\/renderer\\/style\\.css$/, replacement: resolvePackageExport('@clarify-labs/renderer', 'style.css') },\n { find: /^@clarify-labs\\/renderer\\/client$/, replacement: resolvePackageExport('@clarify-labs/renderer', 'client') },\n { find: /^@clarify-labs\\/renderer\\/server$/, replacement: resolvePackageExport('@clarify-labs/renderer', 'server') },\n { find: /^@clarify-labs\\/renderer$/, replacement: resolvePackageExport('@clarify-labs/renderer', '') },\n { find: /^react\\/jsx-dev-runtime$/, replacement: resolveCliDependency('react/jsx-dev-runtime') },\n { find: /^react\\/jsx-runtime$/, replacement: resolveCliDependency('react/jsx-runtime') },\n { find: /^mermaid$/, replacement: resolveCliDependency('mermaid') },\n { find: /^react-zoom-pan-pinch$/, replacement: resolveCliDependency('react-zoom-pan-pinch') },\n { find: /^react$/, replacement: resolveCliDependency('react') },\n ]\n}\n","import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { join, dirname } from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nimport { build } from 'vite'\nimport type { Plugin } from 'vite'\n\nimport type { ResolvedProjectConfig, ContentRoute } from '../types.js'\n\nimport { createClarifyRuntimeAliases } from './runtime-deps.js'\nimport { createClarifyTempDir } from './temp-dir.js'\nimport { escapeHtml } from './utils.js'\n\nexport function readIndexHtml(outputDirectory: string): string | undefined {\n const indexPath = join(outputDirectory, 'index.html')\n if (!existsSync(indexPath)) return undefined\n try {\n return readFileSync(indexPath, 'utf-8')\n } catch {\n return undefined\n }\n}\n\nfunction injectHtmlLocaleAttributes(html: string, projectConfig: ResolvedProjectConfig, route?: ContentRoute): string {\n const localeCode = route?.locale ?? projectConfig.i18n?.defaultLocale\n if (!localeCode) return html\n\n const localeConfig = projectConfig.i18n?.locales.find(locale => locale.code === localeCode)\n const dir = localeConfig?.dir\n\n return html.replace(/<html\\b([^>]*)>/i, (_match, attributes: string) => {\n let nextAttributes = attributes\n .replace(/\\s+lang=(\"[^\"]*\"|'[^']*'|[^\\s>]*)/i, '')\n .replace(/\\s+dir=(\"[^\"]*\"|'[^']*'|[^\\s>]*)/i, '')\n\n nextAttributes = `${nextAttributes} lang=\"${escapeHtml(localeCode)}\"`\n if (dir) nextAttributes = `${nextAttributes} dir=\"${escapeHtml(dir)}\"`\n return `<html${nextAttributes}>`\n })\n}\n\nfunction routeTitle(projectConfig: ResolvedProjectConfig, route?: ContentRoute): string {\n const title = route?.title?.trim()\n if (!title || title === projectConfig.title) return projectConfig.title\n return `${title} - ${projectConfig.title}`\n}\n\nfunction setNamedMeta(html: string, name: string, content: string | undefined): string {\n const metaPattern = new RegExp(`<meta\\\\b(?=[^>]*\\\\bname=[\"']${name}[\"'])[^>]*>\\\\n?`, 'i')\n if (!content) return html.replace(metaPattern, '')\n\n const meta = `<meta name=\"${name}\" content=\"${escapeHtml(content)}\" />`\n if (metaPattern.test(html)) return html.replace(metaPattern, meta)\n return html.replace('</head>', ` ${meta}\\n </head>`)\n}\n\nfunction canonicalUrl(projectConfig: ResolvedProjectConfig, route: ContentRoute): string | undefined {\n if (!projectConfig.siteUrl || !route.alternates || !route.locale) return undefined\n const prefixedPath = route.alternates[route.locale]\n if (!prefixedPath || prefixedPath === route.path) return undefined\n\n const base = projectConfig.siteUrl.replace(/\\/+$/, '')\n const prefix = (!projectConfig.routePrefix || projectConfig.routePrefix === '/')\n ? ''\n : `/${projectConfig.routePrefix.replace(/^\\/+|\\/+$/g, '')}`\n return `${base}${prefix}${prefixedPath}`\n}\n\nfunction injectCanonicalUrl(html: string, projectConfig: ResolvedProjectConfig, route?: ContentRoute): string {\n const url = route ? canonicalUrl(projectConfig, route) : undefined\n // Remove any existing canonical link\n html = html.replace(/<link\\b[^>]*\\brel=[\"']canonical[\"'][^>]*\\/?>\\n?/gi, '')\n if (!url) return html\n return html.replace('</head>', ` <link rel=\"canonical\" href=\"${escapeHtml(url)}\" />\\n </head>`)\n}\n\nexport function injectSSRIntoTemplate(template: string, appHtml: string, projectConfig: ResolvedProjectConfig, route?: ContentRoute): string {\n let html = injectHtmlLocaleAttributes(template, projectConfig, route)\n\n // Replace <title>...</title>\n html = html.replace(/<title>.*?<\\/title>/, `<title>${escapeHtml(routeTitle(projectConfig, route))}</title>`)\n\n html = setNamedMeta(html, 'description', route?.description ?? projectConfig.description)\n html = setNamedMeta(html, 'keywords', route?.keywords?.join(', '))\n html = injectCanonicalUrl(html, projectConfig, route)\n\n // Replace <div id=\"root\">...</div> with SSR rendered content\n html = html.replace(/<div id=\"root\">[\\s\\S]*?<\\/div>/, `<div id=\"root\">${appHtml}</div>`)\n\n return html\n}\n\nexport function isNotFoundRoute(route: ContentRoute): boolean {\n return (route.basePath ?? route.path) === '/404'\n}\n\nexport function routeOutputFiles(outputDirectory: string, route: ContentRoute): string[] {\n const files = [join(outputDirectory, route.path, 'index.html')]\n if (isNotFoundRoute(route) && (!route.locale || route.path === '/404')) {\n files.push(join(outputDirectory, '404.html'))\n }\n return files\n}\n\nexport const SSR_ENTRY_CODE = `import { renderToHTML } from '@clarify-labs/renderer/server';\nimport { routes, navigation } from 'virtual:clarify/routes/server';\nimport { config } from 'virtual:clarify/config';\nimport { openApis } from 'virtual:clarify/openapi';\nimport { runtimeSlots } from 'virtual:clarify/slots';\n\nexport async function render(url) {\n // Pre-resolve every slot component factory so renderToString can use\n // them synchronously (renderToString has no Suspense support).\n const entries = Object.values(runtimeSlots).flat()\n await Promise.all(entries.map(async (entry) => {\n const mod = await entry.component()\n entry._resolved = mod.default\n }))\n return renderToHTML({ config, routes, navigation, openApis, runtimeSlots, url, themeEditor: config.theme.editor });\n}`\n\nexport function createTempEntryFile(content: string): string {\n const tempDir = createClarifyTempDir('ssr')\n const entryPath = join(tempDir, 'entry-server.ts')\n writeFileSync(entryPath, content, 'utf-8')\n return entryPath\n}\n\nexport async function buildSSRBundle(root: string, ssrEntry: string, ssrOutDir: string, plugins: Plugin[]): Promise<void> {\n await build({\n root,\n configFile: false,\n resolve: {\n alias: createClarifyRuntimeAliases(),\n },\n ssr: {\n noExternal: true,\n },\n plugins,\n build: {\n ssr: ssrEntry,\n outDir: ssrOutDir,\n emptyOutDir: true,\n rolldownOptions: {\n input: ssrEntry,\n checks: {\n pluginTimings: false,\n },\n },\n },\n })\n}\n\nexport async function renderSSGRoutes(routes: ContentRoute[], projectConfig: ResolvedProjectConfig, outputDirectory: string, ssrBundlePath: string, failOnError: boolean = true): Promise<void> {\n const { render } = await import(pathToFileURL(ssrBundlePath).href)\n\n const template = readIndexHtml(outputDirectory)\n if (!template) {\n throw new Error(\n `[clarify] index.html not found in outputDirectory \"${outputDirectory}\". Make sure Vite build produces it.`\n )\n }\n\n for (const route of routes) {\n try {\n const appHtml = await render(route.path)\n const finalHtml = injectSSRIntoTemplate(template, appHtml, projectConfig, route)\n\n for (const outFile of routeOutputFiles(outputDirectory, route)) {\n mkdirSync(dirname(outFile), { recursive: true })\n writeFileSync(outFile, finalHtml, 'utf-8')\n }\n } catch (err) {\n console.error(`[clarify] Failed to render route \"${route.path}\":`, err)\n if (failOnError) {\n throw err\n }\n }\n }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nimport { loadConfigFromFile } from 'vite'\nimport type { ConfigEnv } from 'vite'\n\nimport type { ClarifyProjectConfig } from '../types.js'\n\nimport { validateProjectConfig } from './config.js'\nimport type { ClarifyBuildOptions } from './options.js'\n\nexport type ClarifyConfig = ClarifyProjectConfig & Pick<ClarifyBuildOptions, 'plugins' | 'ssg'>\n\nexport function defineConfig(config: ClarifyConfig): ClarifyConfig {\n validateProjectConfig(config)\n return config\n}\n\nconst CONFIG_FILENAMES = [\n 'clarify.ts',\n 'clarify.js',\n 'clarify.json',\n]\n\nexport function findClarifyConfigFile(root: string): string | undefined {\n for (const filename of CONFIG_FILENAMES) {\n const filePath = resolve(root, filename)\n if (existsSync(filePath)) return filePath\n }\n return undefined\n}\n\nfunction assertConfigObject(config: unknown, configFile: string): Record<string, unknown> {\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new Error(`[clarify] ${configFile} must export a configuration object`)\n }\n return config as Record<string, unknown>\n}\n\nfunction loadJsonConfig(configFile: string): ClarifyConfig {\n const config = assertConfigObject(JSON.parse(readFileSync(configFile, 'utf-8')), configFile)\n const projectConfig = validateProjectConfig(config)\n const ssg = config.ssg && typeof config.ssg === 'object' && !Array.isArray(config.ssg)\n ? config.ssg as ClarifyConfig['ssg']\n : undefined\n return {\n ...projectConfig,\n ...(ssg ? { ssg } : {}),\n }\n}\n\nexport async function loadClarifyConfig(root: string, env: ConfigEnv): Promise<ClarifyConfig> {\n const configFile = findClarifyConfigFile(root)\n if (!configFile) return {}\n\n if (configFile.endsWith('.json')) {\n return loadJsonConfig(configFile)\n }\n\n const loaded = await loadConfigFromFile(env, configFile, root, 'silent')\n const config = assertConfigObject(loaded?.config, configFile)\n return config as ClarifyConfig\n}\n","import { rmSync } from 'node:fs'\nimport { isAbsolute, join, relative, resolve } from 'node:path'\n\nimport mdxPlugin, { type Options as MdxPluginOptions } from '@mdx-js/rollup'\nimport tailwindcss from '@tailwindcss/vite'\nimport react from '@vitejs/plugin-react'\nimport type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'\n\nimport { rehypePlugins, remarkPlugins } from '../parsers/mdx.js'\nimport type { ClarifyHookContext, ClarifyPlugin, ContentRoute, NavigationTree } from '../types.js'\n\nimport { createBuiltinPlugins } from './builtin.js'\nimport { resolveProjectConfig } from './config.js'\nimport { writeClarifyEnvDts } from './env-types.js'\nimport { runBuildAssetsHooks, runBuildDoneHooks, runDevConfigureServerHooks, runHooks } from './hooks.js'\nimport { resolveBuildOptions, type ClarifyBuildOptions } from './options.js'\nimport { resolveClarifySite } from './site.js'\nimport {\n SSR_ENTRY_CODE,\n createTempEntryFile,\n buildSSRBundle,\n renderSSGRoutes,\n} from './ssg.js'\nimport { findClarifyConfigFile, loadClarifyConfig } from './user-config.js'\nimport {\n RESOLVED_CLIENT_ENTRY,\n VIRTUAL_CLIENT_ENTRY,\n VIRTUAL_CONFIG,\n VIRTUAL_ROUTES,\n VIRTUAL_SERVER_ROUTES,\n VIRTUAL_OPENAPI,\n VIRTUAL_SLOTS,\n VIRTUAL_SLOT,\n buildVirtualModules,\n resolveVirtualId,\n stripVirtualPrefix,\n type VirtualModules,\n} from './virtual-modules.js'\n\nfunction loadVirtualModule(id: string, modules: VirtualModules): string | null {\n const bareId = stripVirtualPrefix(id)\n return modules.get(bareId) ?? modules.get(id) ?? null\n}\n\nexport function clarifyPlugin(options: ClarifyBuildOptions = {}): Plugin[] {\n const root = resolve(options.projectRoot ?? process.cwd())\n let projectConfig = resolveProjectConfig(options)\n let generateOptions = resolveBuildOptions(options)\n const contentRoot = join(root, generateOptions.rootDirectory)\n const configFilePath = findClarifyConfigFile(root)\n let routes: ContentRoute[] = []\n\n let clarifyPlugins: ClarifyPlugin[] = [...createBuiltinPlugins(), ...(options.plugins ?? [])]\n const ctx: ClarifyHookContext = { projectConfig, generateOptions, routes, navigation: [] }\n let viteConfig: ResolvedConfig\n let resolvedNavigation: NavigationTree = []\n let virtualModules: VirtualModules = new Map()\n\n async function resolveRoutesAndSpecs(overrides?: ClarifyBuildOptions) {\n const site = await resolveClarifySite(overrides ?? options)\n projectConfig = site.projectConfig\n generateOptions = site.generateOptions\n routes = site.routes\n resolvedNavigation = site.navigation\n clarifyPlugins = site.plugins\n ctx.projectConfig = projectConfig\n ctx.generateOptions = generateOptions\n ctx.routes = routes\n ctx.navigation = resolvedNavigation\n }\n\n async function rebuildVirtualModules() {\n virtualModules = buildVirtualModules({\n projectConfig,\n generateOptions,\n routes,\n navigation: resolvedNavigation,\n plugins: clarifyPlugins,\n themeEditor: viteConfig.command === 'serve' || projectConfig.theme.editor,\n })\n virtualModules = await runHooks(clarifyPlugins, 'modules:before', virtualModules, ctx)\n }\n\n function invalidateVirtualModules(server: ViteDevServer) {\n for (const id of virtualModules.keys()) {\n const moduleNode = server.moduleGraph.getModuleById(resolveVirtualId(id))\n if (moduleNode) server.moduleGraph.invalidateModule(moduleNode)\n }\n }\n\n async function refreshDevServer(server: ViteDevServer) {\n await resolveRoutesAndSpecs()\n await rebuildVirtualModules()\n invalidateVirtualModules(server)\n server.ws.send({ type: 'full-reload' })\n }\n\n function hasContentRouteForFile(filePath: string): boolean {\n return routes.some(route => route.filePath === filePath)\n }\n\n const normalizedMdxContentPlugin: Plugin = {\n name: 'clarify:normalized-mdx-content',\n enforce: 'pre',\n transform(_code, id) {\n if (!/\\.mdx?(?:\\?|$)/.test(id)) return null\n const filePath = id.replace(/\\?.*$/, '')\n const route = routes.find(route => route.kind === 'mdx' && route.filePath === filePath)\n if (!route || route.content === undefined) return null\n return { code: route.content, map: null }\n },\n }\n\n const mdx = mdxPlugin({\n include: ['**/*.{md,mdx}'],\n jsxImportSource: 'react',\n providerImportSource: '@clarify-labs/renderer',\n remarkPlugins: remarkPlugins as MdxPluginOptions['remarkPlugins'],\n rehypePlugins,\n })\n\n const clarifyCorePlugin: Plugin = {\n name: 'clarify:core',\n async config() {\n await resolveRoutesAndSpecs()\n\n return {\n base: projectConfig.assetPrefix,\n build: {\n ...(generateOptions.outputDirectory ? { outDir: generateOptions.outputDirectory } : {}),\n manifest: true,\n },\n }\n },\n configResolved(config) {\n viteConfig = config\n // If user didn't specify outputDirectory, read it from Vite's resolved config\n if (!generateOptions.outputDirectory) {\n generateOptions.outputDirectory = config.build.outDir\n }\n },\n async buildStart() {\n await rebuildVirtualModules()\n writeClarifyEnvDts(root, clarifyPlugins)\n },\n async handleHotUpdate(ctx) {\n const changedFile = isAbsolute(ctx.file) ? ctx.file : join(root, ctx.file)\n if (configFilePath && changedFile === configFilePath) {\n const userConfig = await loadClarifyConfig(root, { command: 'serve', mode: viteConfig.mode })\n const newOptions: ClarifyBuildOptions = {\n ...userConfig,\n projectRoot: options.projectRoot,\n rootDirectory: options.rootDirectory,\n outputDirectory: options.outputDirectory,\n }\n await resolveRoutesAndSpecs(newOptions)\n await rebuildVirtualModules()\n invalidateVirtualModules(ctx.server)\n ctx.server.ws.send({ type: 'full-reload' })\n return []\n }\n\n const relativeContentFile = relative(contentRoot, changedFile)\n const isContentFile = relativeContentFile && !relativeContentFile.startsWith('..') && !isAbsolute(relativeContentFile)\n if (!isContentFile || !hasContentRouteForFile(changedFile)) return\n\n await refreshDevServer(ctx.server)\n return []\n },\n resolveId(id) {\n if (id === VIRTUAL_CLIENT_ENTRY || id === RESOLVED_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY\n if (id === VIRTUAL_CONFIG || id === resolveVirtualId(VIRTUAL_CONFIG)) return resolveVirtualId(VIRTUAL_CONFIG)\n if (id === VIRTUAL_ROUTES || id === resolveVirtualId(VIRTUAL_ROUTES)) return resolveVirtualId(VIRTUAL_ROUTES)\n if (id === VIRTUAL_SERVER_ROUTES || id === resolveVirtualId(VIRTUAL_SERVER_ROUTES)) return resolveVirtualId(VIRTUAL_SERVER_ROUTES)\n if (id === VIRTUAL_OPENAPI || id === resolveVirtualId(VIRTUAL_OPENAPI)) return resolveVirtualId(VIRTUAL_OPENAPI)\n if (id === VIRTUAL_SLOTS || id === resolveVirtualId(VIRTUAL_SLOTS)) return resolveVirtualId(VIRTUAL_SLOTS)\n if (id === VIRTUAL_SLOT || id === resolveVirtualId(VIRTUAL_SLOT)) return resolveVirtualId(VIRTUAL_SLOT)\n const moduleId = stripVirtualPrefix(id)\n if (virtualModules.has(moduleId)) return resolveVirtualId(moduleId)\n const route = routes.find(r => r.virtualModuleId === id || r.virtualModuleId === moduleId)\n if (route) return resolveVirtualId(route.virtualModuleId)\n return null\n },\n load(id) {\n return loadVirtualModule(id, virtualModules)\n },\n async configureServer(server) {\n server.watcher.add(contentRoot)\n if (configFilePath) {\n server.watcher.add(configFilePath)\n }\n\n const handleContentTreeChange = async (filePath: string) => {\n const changedFile = isAbsolute(filePath) ? filePath : join(root, filePath)\n const relativeContentFile = relative(contentRoot, changedFile)\n const isContentFile = relativeContentFile && !relativeContentFile.startsWith('..') && !isAbsolute(relativeContentFile)\n if (!isContentFile) return\n await refreshDevServer(server)\n }\n\n server.watcher.on('add', handleContentTreeChange)\n server.watcher.on('unlink', handleContentTreeChange)\n await runDevConfigureServerHooks(clarifyPlugins, server, ctx)\n },\n transformIndexHtml: {\n order: 'pre',\n async handler(html, transformCtx) {\n // In dev mode, use /@id/ prefix so Vite dev server can resolve the virtual module.\n // In build mode, use the bare virtual: ID so Vite's HTML build pipeline resolves it via resolveId.\n const clientEntryId = transformCtx.server\n ? `/@id/${VIRTUAL_CLIENT_ENTRY}`\n : VIRTUAL_CLIENT_ENTRY\n const result = await runHooks(clarifyPlugins, 'html:transform', {\n html,\n tags: [],\n clientEntryId,\n dev: Boolean(transformCtx.server),\n }, ctx)\n return {\n html: result.html,\n tags: result.tags,\n }\n }\n },\n async generateBundle(_opts, _bundle) {\n // Collect assets from all plugins and emit them through Rollup so they\n // appear in the Vite manifest and build log.\n const assets = await runBuildAssetsHooks(clarifyPlugins, ctx)\n for (const asset of assets) {\n this.emitFile({\n type: 'asset',\n fileName: asset.fileName,\n source: asset.source,\n })\n }\n },\n async closeBundle() {\n // ── Phase 1: Static HTML Generation ──\n if (process.env.SKIP_CLARIFY_SSG) {\n await runBuildDoneHooks(clarifyPlugins, ctx)\n return\n }\n\n const outputDir = viteConfig.build.outDir\n const ssrOutputDir = join(outputDir, '.ssr')\n let tempEntryPath: string | undefined\n\n try {\n tempEntryPath = createTempEntryFile(SSR_ENTRY_CODE)\n\n await buildSSRBundle(root, tempEntryPath, ssrOutputDir, [\n {\n name: 'clarify:virtual-ssg',\n resolveId(id) {\n if (id === VIRTUAL_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY\n if (id === RESOLVED_CLIENT_ENTRY) return RESOLVED_CLIENT_ENTRY\n if (id === VIRTUAL_SERVER_ROUTES) return id\n if (id === VIRTUAL_OPENAPI) return id\n if (id === VIRTUAL_CONFIG) return id\n if (id === VIRTUAL_ROUTES) return id\n if (id === VIRTUAL_SLOTS) return id\n if (id === VIRTUAL_SLOT) return id\n if (virtualModules.has(stripVirtualPrefix(id))) return stripVirtualPrefix(id)\n const route = routes.find(r => r.virtualModuleId === id)\n if (route) return id\n return null\n },\n load: id => loadVirtualModule(id, virtualModules),\n },\n normalizedMdxContentPlugin,\n mdx,\n ])\n\n const ssrBundlePath = join(ssrOutputDir, 'entry-server.js')\n await renderSSGRoutes(routes, projectConfig, outputDir, ssrBundlePath, generateOptions.ssg.failOnError)\n } catch (err) {\n console.error('[clarify] SSG failed:', err)\n if (generateOptions.ssg.failOnError) {\n throw err\n }\n } finally {\n if (tempEntryPath) {\n try {\n rmSync(tempEntryPath, { force: true })\n } catch {\n // ignore cleanup errors\n }\n }\n }\n\n await runBuildDoneHooks(clarifyPlugins, ctx)\n },\n }\n\n return [react(), tailwindcss(), normalizedMdxContentPlugin, clarifyCorePlugin, mdx].flat().filter(Boolean) as Plugin[]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,WAAW,MAAsB;CAC/C,OAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,OAAO;AAC1B;;;ACkBA,SAAS,YAAY,WAA4B;CAG/C,QAFgB,MAAM,QAAQ,SAAS,IAAI,YAAY,OAAO,cAAc,WAAW,UAAU,MAAM,KAAK,IAAI,CAAC,GACnF,MAAM,SAAyB,OAAO,SAAS,YAAY,KAAK,WAAW,WAAW,CAC7G,GAAe,QAAQ,cAAc,EAAE,KAAK;AACrD;AAEA,SAAS,eAAe,MAAoC;CAC1D,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,OAAO,KAAK,UAAU,UAAU,OAAO,KAAK;CAChD,OAAO,KAAK,UAAU,IAAI,cAAc,EAAE,KAAK,EAAE,KAAK;AACxD;AAEA,SAAS,gBAAgB,MAAsB;CAC7C,OAAO,KACJ,MAAM,IAAI,EACV,KAAI,SAAQ,SAAS,WAAW,IAAI,EAAE,QAAQ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