@fumadocs/cli 1.4.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/ai-BVuNjYXU.js +100 -0
  2. package/dist/ai-BVuNjYXU.js.map +1 -0
  3. package/dist/all-aUHxtoXL.js +27 -0
  4. package/dist/all-aUHxtoXL.js.map +1 -0
  5. package/dist/codemod/index.d.ts +2 -0
  6. package/dist/codemod/index.js +2 -0
  7. package/dist/codemod-auol-p4R.js +404 -0
  8. package/dist/codemod-auol-p4R.js.map +1 -0
  9. package/dist/config-CT2jj39D.d.ts +52 -0
  10. package/dist/config-CT2jj39D.d.ts.map +1 -0
  11. package/dist/config-D6uv73fs.js +94 -0
  12. package/dist/config-D6uv73fs.js.map +1 -0
  13. package/dist/config.d.ts +2 -52
  14. package/dist/config.js +1 -72
  15. package/dist/docs-DeIEl_Kt.js +738 -0
  16. package/dist/docs-DeIEl_Kt.js.map +1 -0
  17. package/dist/epub-CnQFJh09.js +52 -0
  18. package/dist/epub-CnQFJh09.js.map +1 -0
  19. package/dist/features/ai.d.ts +25 -0
  20. package/dist/features/ai.d.ts.map +1 -0
  21. package/dist/features/ai.js +2 -0
  22. package/dist/features/all.d.ts +5 -0
  23. package/dist/features/all.d.ts.map +1 -0
  24. package/dist/features/all.js +2 -0
  25. package/dist/features/docs/index.d.ts +10 -0
  26. package/dist/features/docs/index.d.ts.map +1 -0
  27. package/dist/features/docs/index.js +2 -0
  28. package/dist/features/epub.d.ts +5 -0
  29. package/dist/features/epub.d.ts.map +1 -0
  30. package/dist/features/epub.js +2 -0
  31. package/dist/features/feedback.d.ts +5 -0
  32. package/dist/features/feedback.d.ts.map +1 -0
  33. package/dist/features/feedback.js +2 -0
  34. package/dist/features/index.d.ts +2 -0
  35. package/dist/features/index.js +2 -0
  36. package/dist/features/lint.d.ts +7 -0
  37. package/dist/features/lint.d.ts.map +1 -0
  38. package/dist/features/lint.js +2 -0
  39. package/dist/features/llms.d.ts +27 -0
  40. package/dist/features/llms.d.ts.map +1 -0
  41. package/dist/features/llms.js +2 -0
  42. package/dist/features/mcp.d.ts +9 -0
  43. package/dist/features/mcp.d.ts.map +1 -0
  44. package/dist/features/mcp.js +2 -0
  45. package/dist/features/og.d.ts +8 -0
  46. package/dist/features/og.d.ts.map +1 -0
  47. package/dist/features/og.js +2 -0
  48. package/dist/features/search.d.ts +84 -0
  49. package/dist/features/search.d.ts.map +1 -0
  50. package/dist/features/search.js +2 -0
  51. package/dist/features/utils.d.ts +2 -0
  52. package/dist/features/utils.js +2 -0
  53. package/dist/features/webmcp.d.ts +12 -0
  54. package/dist/features/webmcp.d.ts.map +1 -0
  55. package/dist/features/webmcp.js +2 -0
  56. package/dist/features-C1kf2s8j.js +132 -0
  57. package/dist/features-C1kf2s8j.js.map +1 -0
  58. package/dist/feedback-COmWtc5C.js +37 -0
  59. package/dist/feedback-COmWtc5C.js.map +1 -0
  60. package/dist/fs-D6J9dOEx.js +14 -0
  61. package/dist/fs-D6J9dOEx.js.map +1 -0
  62. package/dist/index-BCVGQxn9.d.ts +64 -0
  63. package/dist/index-BCVGQxn9.d.ts.map +1 -0
  64. package/dist/index-CR9T40ox.d.ts +76 -0
  65. package/dist/index-CR9T40ox.d.ts.map +1 -0
  66. package/dist/index-Ck0EPdgu.d.ts +126 -0
  67. package/dist/index-Ck0EPdgu.d.ts.map +1 -0
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +198 -124
  70. package/dist/index.js.map +1 -1
  71. package/dist/{installer-Chjj_R2z.js → installer-D0Obb2Md.js} +21 -8
  72. package/dist/installer-D0Obb2Md.js.map +1 -0
  73. package/dist/lint-zkXUULgO.js +137 -0
  74. package/dist/lint-zkXUULgO.js.map +1 -0
  75. package/dist/llms-CONd8Vnn.js +228 -0
  76. package/dist/llms-CONd8Vnn.js.map +1 -0
  77. package/dist/mcp-BT8BLZZ-.js +67 -0
  78. package/dist/mcp-BT8BLZZ-.js.map +1 -0
  79. package/dist/og-DRDOyQ_t.js +142 -0
  80. package/dist/og-DRDOyQ_t.js.map +1 -0
  81. package/dist/project/index.d.ts +2 -0
  82. package/dist/project/index.js +2 -0
  83. package/dist/project-DwRVTm4p.js +110 -0
  84. package/dist/project-DwRVTm4p.js.map +1 -0
  85. package/dist/registry/installer.d.ts +4 -5
  86. package/dist/registry/installer.d.ts.map +1 -1
  87. package/dist/registry/installer.js +1 -1
  88. package/dist/schema.json +1 -1
  89. package/dist/search-iphnSVVY.js +381 -0
  90. package/dist/search-iphnSVVY.js.map +1 -0
  91. package/dist/utils-B1Xy4l_a.d.ts +43 -0
  92. package/dist/utils-B1Xy4l_a.d.ts.map +1 -0
  93. package/dist/utils-DbMe7h6c.js +98 -0
  94. package/dist/utils-DbMe7h6c.js.map +1 -0
  95. package/dist/webmcp-C2PM_9md.js +135 -0
  96. package/dist/webmcp-C2PM_9md.js.map +1 -0
  97. package/package.json +27 -7
  98. package/dist/config.d.ts.map +0 -1
  99. package/dist/config.js.map +0 -1
  100. package/dist/installer-Chjj_R2z.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-DeIEl_Kt.js","names":[],"sources":["../src/project/route.ts","../src/features/docs/templates.ts","../src/features/docs/index.ts"],"sourcesContent":["import type { I18nInfo, ReactFramework } from '@/project';\n\nexport type RouteSegment =\n /** static path, can contain multiple segments like `/llms.mdx/docs` */\n | string\n | {\n param: string;\n catchAll?: boolean;\n /** the catch-all also matches zero segments */\n optional?: boolean;\n /** static file name after the catch-all like `content.md`, part of the parameter when the framework can't express it */\n suffix?: string;\n };\n\nexport interface RouteDescriptor {\n segments: RouteSegment[];\n /** under the locale parameter when the project has i18n */\n locale?: boolean;\n}\n\nexport interface FormattedRoute {\n /** route file, relative to the base dir */\n file: string;\n /** route string of the framework, e.g. for `RouteContext<'...'>`, `createFileRoute('...')`, `route('...')` or `ApiContext<'...'>` */\n path: string;\n /** path-to-regexp pattern, for the Next.js proxy matcher and rewrites */\n pattern: string;\n}\n\ninterface Convention {\n locale: (optional: boolean) => string;\n param: (name: string, catchAll: boolean, optional: boolean, suffix?: string) => string;\n file: (segments: string[], ext: string) => string;\n path: (segments: string[]) => string;\n}\n\nconst conventions: Record<ReactFramework, Convention> = {\n next: {\n locale: () => '[lang]',\n param: (name, catchAll, optional) =>\n catchAll ? (optional ? `[[...${name}]]` : `[...${name}]`) : `[${name}]`,\n file: (segments, ext) => `app/${segments.join('/')}/route.${ext}`,\n path: (segments) => `/${segments.join('/')}`,\n },\n 'react-router': {\n locale: (optional) => (optional ? ':lang?' : ':lang'),\n param: (name, catchAll) => (catchAll ? '*' : `:${name}`),\n // `routes.ts` maps paths to files, name files after the static segments like flat routes\n file: (segments, ext) =>\n `routes/${segments.filter((segment) => !/^[:*]/.test(segment)).join('.')}.${ext}`,\n path: (segments) => segments.join('/'),\n },\n 'tanstack-start': {\n locale: (optional) => (optional ? '{-$lang}' : '$lang'),\n param: (name, catchAll) => (catchAll ? '$' : `$${name}`),\n file: (segments, ext) => `routes/${segments.join('/').replaceAll('.', '[.]')}.${ext}`,\n path: (segments) => `/${segments.join('/')}`,\n },\n waku: {\n locale: () => '[lang]',\n param: (name, catchAll, _optional, suffix) =>\n catchAll ? `[...${name}]${suffix ? `/${suffix}` : ''}` : `[${name}]`,\n file: (segments, ext) => `pages/_api/${segments.join('/')}.${ext}`,\n path: (segments) => `/${segments.join('/')}`,\n },\n};\n\n/** the locale segment of route files, with a trailing slash */\nexport function localeSegment(framework: ReactFramework, i18n: I18nInfo | null) {\n return i18n ? `${conventions[framework].locale(i18n.optionalLocale)}/` : '';\n}\n\nexport function formatRoute(\n route: RouteDescriptor,\n framework: ReactFramework,\n i18n: I18nInfo | null,\n ext = 'ts',\n): FormattedRoute {\n const convention = conventions[framework];\n const segments: string[] = [];\n const patterns: string[] = [];\n if (route.locale && i18n) {\n segments.push(convention.locale(i18n.optionalLocale));\n patterns.push(':lang');\n }\n\n for (const segment of route.segments) {\n if (typeof segment === 'string') {\n for (const part of segment.split('/')) {\n if (part.length === 0) continue;\n segments.push(part);\n patterns.push(part);\n }\n } else {\n const { param, catchAll = false, optional = false, suffix } = segment;\n segments.push(convention.param(param, catchAll, optional, suffix));\n patterns.push(catchAll ? `:${param}*` : `:${param}`);\n }\n }\n\n return {\n file: convention.file(segments, ext),\n path: convention.path(segments),\n pattern: `/${patterns.join('/')}`,\n };\n}\n\nexport interface RouteModule {\n /** import statements of the handler */\n imports: string;\n /** expression returning a `Response` */\n body: string;\n /** the handler reads `request` */\n request?: boolean;\n /** @defaultValue `['GET']` */\n methods?: string[];\n /** Next.js: never revalidate the route */\n revalidate?: boolean;\n /** Waku: prerender the route */\n static?: boolean;\n}\n\n/** the route module of a handler that only reads the request, per framework */\nexport function routeModule(\n framework: ReactFramework,\n route: FormattedRoute,\n mod: RouteModule,\n): string {\n const { imports, body, request, methods = ['GET'], revalidate, static: isStatic } = mod;\n const arg = request ? 'request: Request' : '';\n const head = `${imports.trim()}\\n\\n`;\n\n if (framework === 'react-router') {\n const out: string[] = [];\n // GET is the loader, every other method is the action\n out.push(handler('loader', 'Route.LoaderArgs'));\n if (methods.length > 1) out.push(handler('action', 'Route.ActionArgs'));\n\n return `${request ? `${reactRouterTypes(route)}\\n` : ''}${head}${out.join('\\n')}`;\n }\n\n if (framework === 'tanstack-start') {\n const out: string[] = [];\n for (const method of methods)\n out.push(` ${method}: async (${request ? '{ request }' : ''}) => ${body},`);\n\n return `import { createFileRoute } from '@tanstack/react-router';\n${head}export const Route = createFileRoute('${route.path}')({\n server: {\n handlers: {\n${out.join('\\n')}\n },\n },\n});\n`;\n }\n\n const out: string[] = [];\n if (framework === 'next' && revalidate) out.push('export const revalidate = false;\\n');\n for (const method of methods)\n out.push(`export async function ${method}(${arg}) {\n return ${body};\n}\n`);\n if (framework === 'waku' && isStatic)\n out.push(`export async function getConfig() {\n return {\n render: 'static' as const,\n } as const;\n}\n`);\n\n return `${head}${out.join('\\n')}`;\n\n function handler(name: string, type: string) {\n return `export async function ${name}(${request ? `{ request }: ${type}` : ''}) {\n return ${body};\n}\n`;\n }\n}\n\n/** import of the generated types of a React Router route module */\nexport const reactRouterTypes = (route: FormattedRoute) =>\n `import type { Route } from './+types/${route.file\n .split('/')\n .pop()!\n .replace(/\\.tsx?$/, '')}';`;\n","import type { I18nInfo, ReactFramework } from '@/project';\nimport { localeSegment } from '@/project/route';\n\nexport interface TemplateInput {\n static: boolean;\n i18n: I18nInfo | null;\n /** import specifier of `RootProvider` */\n provider: string;\n /** extra props of `RootProvider` */\n providerProps: string;\n}\n\n/** files relative to the base dir */\nexport type Template = (input: TemplateInput) => Record<string, string>;\n\nconst wrapper = (children: string) =>\n `<div className=\"flex flex-col min-h-screen\">${children}</div>`;\n\nconst i18nConfig = (optionalLocale: boolean) => `import { defineI18n } from 'fumadocs-core/i18n';\n\nexport const i18n = defineI18n({\n defaultLanguage: 'en',\n languages: ['en', 'cn'],${optionalLocale ? \"\\n hideLocale: 'default-locale',\" : ''}\n});\n`;\n\nconst sharedConstants = `export const docsRoute = '/docs';\n`;\n\nconst source = (async: boolean, i18n: boolean) => `import { loader } from 'fumadocs-core/source';\nimport { defineDocs } from 'fumadocs-mdx/macro';\nimport { docsRoute } from './shared';\n${i18n ? \"import { i18n } from '@/lib/i18n';\\n\" : ''}\nexport const docs = defineDocs({\n dir: 'content/docs',${async ? '\\n docs: {\\n async: true,\\n },' : ''}\n});\n\nexport const source = loader({\n baseUrl: docsRoute,\n source: docs.toFumadocsSource(),${i18n ? '\\n i18n,' : ''}\n});\n`;\n\nconst layoutShared = (i18n: boolean) =>\n i18n\n ? `import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';\nimport { uiTranslations } from 'fumadocs-ui/i18n';\nimport { i18n } from '@/lib/i18n';\n\nexport const translations = i18n.translations().extend(uiTranslations());\n\nexport function baseOptions(locale: string = i18n.defaultLanguage): BaseLayoutProps {\n return {\n nav: {\n title: 'My App',\n url: \\`/\\${locale}\\`,\n },\n };\n}\n`\n : `import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';\n\nexport function baseOptions(): BaseLayoutProps {\n return {\n nav: {\n title: 'My App',\n },\n };\n}\n`;\n\nconst mdx = `import defaultMdxComponents from 'fumadocs-ui/mdx';\nimport type { MDXComponents } from 'mdx/types';\n\nexport function getMDXComponents(components?: MDXComponents) {\n return {\n ...defaultMdxComponents,\n ...components,\n } satisfies MDXComponents;\n}\n\nexport const useMDXComponents = getMDXComponents;\n\ndeclare global {\n type MDXProvidedComponents = ReturnType<typeof getMDXComponents>;\n}\n`;\n\nconst search = (i18n: boolean) => `'use client';\nimport {\n SearchDialog,\n SearchDialogClose,\n SearchDialogContent,\n SearchDialogHeader,\n SearchDialogIcon,\n SearchDialogInput,\n SearchDialogList,\n SearchDialogOverlay,\n type SharedProps,\n} from 'fumadocs-ui/components/dialog/search';\nimport { useDocsSearch } from 'fumadocs-core/search/client';\nimport { staticClient } from 'fumadocs-core/search/client/orama-static';\n${i18n ? \"import { useI18n } from 'fumadocs-ui/contexts/i18n';\\n\" : ''}\nexport default function DefaultSearchDialog(props: SharedProps) {\n${i18n ? ' const { locale } = useI18n();\\n' : ''} const { search, setSearch, query } = useDocsSearch({\n client: staticClient(${i18n ? '{ locale }' : ''}),\n });\n\n return (\n <SearchDialog search={search} onSearchChange={setSearch} isLoading={query.isLoading} {...props}>\n <SearchDialogOverlay />\n <SearchDialogContent>\n <SearchDialogHeader>\n <SearchDialogIcon />\n <SearchDialogInput />\n <SearchDialogClose />\n </SearchDialogHeader>\n <SearchDialogList items={query.data !== 'empty' ? query.data : null} />\n </SearchDialogContent>\n </SearchDialog>\n );\n}\n`;\n\nfunction shared(input: TemplateInput, async: boolean): Record<string, string> {\n const i18n = input.i18n !== null;\n return {\n 'lib/shared.ts': sharedConstants,\n 'lib/source.ts': source(async, i18n),\n 'lib/layout.shared.tsx': layoutShared(i18n),\n 'components/mdx.tsx': mdx,\n ...(input.static ? { 'components/search.tsx': search(i18n) } : {}),\n ...(input.i18n ? { 'lib/i18n.ts': i18nConfig(input.i18n.optionalLocale) } : {}),\n };\n}\n\nconst searchImport = (input: TemplateInput) =>\n input.static ? `import SearchDialog from '@/components/search';\\n` : '';\n\n/** imports of the root provider, with the i18n provider */\nconst providerImports = (input: TemplateInput) =>\n `import { RootProvider } from '${input.provider}';\n${searchImport(input)}${\n input.i18n\n ? `import { i18nProvider } from 'fumadocs-ui/i18n';\nimport { translations } from '@/lib/layout.shared';\nimport { i18n } from '@/lib/i18n';\n`\n : ''\n }`;\n\nconst providerProps = (input: TemplateInput) =>\n `${input.i18n ? ' i18n={i18nProvider(translations, lang)}' : ''}${input.providerProps}`;\n\n/** the docs page for React Router & TanStack Start, where MDX content is loaded lazily on client */\nconst clientContent = `function Content({ path }: { path: string }) {\n const page = docs.getPage(path);\n if (!page) throw new Error(\\`unknown page: \\${path}\\`);\n\n const { toc } = use(page.load());\n const MDX = page.body;\n\n return (\n <DocsPage toc={toc}>\n <DocsTitle>{page.title}</DocsTitle>\n <DocsDescription>{page.description}</DocsDescription>\n <DocsBody>\n <MDX components={useMDXComponents()} />\n </DocsBody>\n </DocsPage>\n );\n}`;\n\nconst searchRoute = {\n next: (input: TemplateInput) => `import { source } from '@/lib/source';\nimport { createFromSource } from 'fumadocs-core/search/server';\n${input.static ? '\\nexport const revalidate = false;\\n' : ''}\nexport const { ${input.static ? 'staticGET: GET' : 'GET'} } = createFromSource(source);\n`,\n waku: `import { createFromSource } from 'fumadocs-core/search/server';\nimport { source } from '@/lib/source';\n\nexport const { GET } = createFromSource(source);\n`,\n};\n\nexport const templates: Record<ReactFramework, Template> = {\n next: (input) => {\n const i18n = input.i18n !== null;\n // route group with `[lang]` segment for i18n\n const dir = i18n ? 'app/(docs)/[lang]' : 'app/(docs)';\n const route = i18n ? '/[lang]' : '';\n const lang = i18n ? ', params.lang' : '';\n\n return {\n ...shared(input, false),\n [`${dir}/layout.tsx`]: input.static\n ? `'use client';\n${providerImports(input)}${i18n ? \"import { use } from 'react';\\n\" : ''}\nexport default function Layout({ ${i18n ? 'params, ' : ''}children }: LayoutProps<'${route || '/'}'>) {\n${i18n ? ' const { lang } = use(params);\\n\\n' : ''} return (\n <RootProvider${providerProps(input)}>\n ${wrapper('{children}')}\n </RootProvider>\n );\n}\n`\n : `${providerImports(input)}\nexport default ${i18n ? 'async ' : ''}function Layout({ ${i18n ? 'params, ' : ''}children }: LayoutProps<'${route || '/'}'>) {\n${i18n ? ' const { lang } = await params;\\n\\n' : ''} return (\n <RootProvider${providerProps(input)}>\n ${wrapper('{children}')}\n </RootProvider>\n );\n}\n`,\n [`${dir}/docs/layout.tsx`]: `import { source } from '@/lib/source';\nimport { DocsLayout } from 'fumadocs-ui/layouts/docs';\nimport { baseOptions } from '@/lib/layout.shared';\n\nexport default ${i18n ? 'async ' : ''}function Layout({ ${i18n ? 'params, ' : ''}children }: LayoutProps<'${route}/docs'>) {\n${i18n ? ' const { lang } = await params;\\n\\n' : ''} return (\n <DocsLayout tree={source.getPageTree(${i18n ? 'lang' : ''})} {...baseOptions(${i18n ? 'lang' : ''})}>\n {children}\n </DocsLayout>\n );\n}\n`,\n [`${dir}/docs/[[...slug]]/page.tsx`]: `import { source } from '@/lib/source';\nimport { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';\nimport { notFound } from 'next/navigation';\nimport { getMDXComponents } from '@/components/mdx';\nimport type { Metadata } from 'next';\nimport { createRelativeLink } from 'fumadocs-ui/mdx';\n\nexport default async function Page(props: PageProps<'${route}/docs/[[...slug]]'>) {\n const params = await props.params;\n const page = source.getPage(params.slug${lang});\n if (!page) notFound();\n\n const MDX = page.data.body;\n\n return (\n <DocsPage toc={page.data.toc} full={page.data.full}>\n <DocsTitle>{page.data.title}</DocsTitle>\n <DocsDescription>{page.data.description}</DocsDescription>\n <DocsBody>\n <MDX\n components={getMDXComponents({\n // this allows you to link to other pages with relative file paths\n a: createRelativeLink(source, page),\n })}\n />\n </DocsBody>\n </DocsPage>\n );\n}\n\nexport async function generateStaticParams() {\n return source.generateParams();\n}\n\nexport async function generateMetadata(props: PageProps<'${route}/docs/[[...slug]]'>): Promise<Metadata> {\n const params = await props.params;\n const page = source.getPage(params.slug${lang});\n if (!page) notFound();\n\n return {\n title: page.data.title,\n description: page.data.description,\n };\n}\n`,\n 'app/api/search/route.ts': searchRoute.next(input),\n };\n },\n\n 'react-router': (input) => {\n const i18n = input.i18n !== null;\n return {\n ...shared(input, true),\n 'routes/docs/layout.tsx': `import { Outlet${i18n ? ', useParams' : ''} } from 'react-router';\n${providerImports(input)}\nexport default function Layout() {\n${i18n ? ' const { lang = i18n.defaultLanguage } = useParams();\\n\\n' : ''} return (\n <RootProvider${providerProps(input)}>\n ${wrapper('\\n <Outlet />\\n ')}\n </RootProvider>\n );\n}\n`,\n 'routes/docs/page.tsx': `import type { Route } from './+types/page';\nimport { DocsLayout } from 'fumadocs-ui/layouts/docs';\nimport { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';\nimport { docs, source } from '@/lib/source';\nimport { baseOptions } from '@/lib/layout.shared';\nimport { useFumadocsLoader } from 'fumadocs-core/source/client';\nimport { useMDXComponents } from '@/components/mdx';\nimport { use } from 'react';\n\nexport async function loader({ params }: Route.LoaderArgs) {\n const slugs = params['*'].split('/').filter((v) => v.length > 0);\n const page = source.getPage(slugs${i18n ? ', params.lang' : ''});\n if (!page) throw new Response('Not found', { status: 404 });\n\n return {\n path: page.path,\n url: page.url,\n pageTree: await source.serializePageTree(source.getPageTree(${i18n ? 'params.lang' : ''})),\n };\n}\n\n${clientContent.replace('<DocsPage toc={toc}>', '<DocsPage toc={toc}>\\n <title>{page.title}</title>\\n <meta name=\"description\" content={page.description} />')}\n\nexport default function Page({ loaderData${i18n ? ', params' : ''} }: Route.ComponentProps) {\n const { path, pageTree } = useFumadocsLoader(loaderData);\n\n return (\n <DocsLayout {...baseOptions(${i18n ? 'params.lang' : ''})} tree={pageTree}>\n <Content path={path} />\n </DocsLayout>\n );\n}\n`,\n 'routes/docs/search.ts': `import type { Route } from './+types/search';\nimport { createFromSource } from 'fumadocs-core/search/server';\nimport { source } from '@/lib/source';\n\nconst server = createFromSource(source);\n\nexport async function loader(${input.static ? '' : '{ request }: Route.LoaderArgs'}) {\n return server.${input.static ? 'staticGET()' : 'GET(request)'};\n}\n`,\n };\n },\n\n 'tanstack-start': (input) => {\n const seg = localeSegment('tanstack-start', input.i18n);\n const i18n = input.i18n !== null;\n return {\n ...shared(input, true),\n 'routes/_docs.tsx': `import { createFileRoute, Outlet${i18n ? ', useParams' : ''} } from '@tanstack/react-router';\n${providerImports(input)}\nexport const Route = createFileRoute('/_docs')({\n component: Layout,\n});\n\nfunction Layout() {\n${i18n ? ' const { lang = i18n.defaultLanguage } = useParams({ strict: false });\\n\\n' : ''} return (\n <RootProvider${providerProps(input)}>\n ${wrapper('\\n <Outlet />\\n ')}\n </RootProvider>\n );\n}\n`,\n [`routes/_docs/${seg}docs/$.tsx`]: `import { createFileRoute, notFound } from '@tanstack/react-router';\nimport { DocsLayout } from 'fumadocs-ui/layouts/docs';\nimport { createServerFn } from '@tanstack/react-start';\nimport { docs, source } from '@/lib/source';\nimport { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';\nimport { baseOptions } from '@/lib/layout.shared';\nimport { useFumadocsLoader } from 'fumadocs-core/source/client';\nimport { Suspense, use } from 'react';\nimport { useMDXComponents } from '@/components/mdx';\n\nexport const Route = createFileRoute('/_docs/${seg}docs/$')({\n component: Page,\n loader: async ({ params }) => {\n const data = await serverLoader({\n data: {\n slugs: params._splat?.split('/') ?? [],${i18n ? '\\n lang: params.lang,' : ''}\n },\n });\n await docs.getPage(data.path)?.preload();\n return data;\n },\n});\n\nconst serverLoader = createServerFn({\n method: 'GET',\n})\n .validator((params: { slugs: string[]${i18n ? '; lang?: string' : ''} }) => params)\n .handler(async ({ data: { slugs${i18n ? ', lang' : ''} } }) => {\n const page = source.getPage(slugs${i18n ? ', lang' : ''});\n if (!page) throw notFound();\n\n return {\n path: page.path,\n pageTree: await source.serializePageTree(source.getPageTree(${i18n ? 'lang' : ''})),\n };\n });\n\n${clientContent}\n\nfunction Page() {\n${i18n ? ' const { lang } = Route.useParams();\\n' : ''} const data = useFumadocsLoader(Route.useLoaderData());\n\n return (\n <DocsLayout {...baseOptions(${i18n ? 'lang' : ''})} tree={data.pageTree}>\n <Suspense>\n <Content path={data.path} />\n </Suspense>\n </DocsLayout>\n );\n}\n`,\n 'routes/api/search.ts': `import { createFileRoute } from '@tanstack/react-router';\nimport { source } from '@/lib/source';\nimport { createFromSource } from 'fumadocs-core/search/server';\n\nconst server = createFromSource(source);\n\nexport const Route = createFileRoute('/api/search')({\n server: {\n handlers: {\n GET: ${input.static ? '() => server.staticGET()' : 'async ({ request }) => server.GET(request)'},\n },\n },\n});\n`,\n };\n },\n\n waku: (input) => {\n const i18n = input.i18n !== null;\n const page = `import { source } from '@/lib/source';\nimport type { PageProps } from 'waku/router';\nimport { unstable_notFound } from 'waku/router/server';\nimport { createRelativeLink } from 'fumadocs-ui/mdx';\nimport { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';\nimport { getMDXComponents } from '@/components/mdx';\n${i18n ? \"import { DocsLayout } from 'fumadocs-ui/layouts/docs';\\nimport { baseOptions } from '@/lib/layout.shared';\\n\" : ''}\nexport default function Page({ slug${i18n ? ', lang' : ''} }: PageProps<'${i18n ? '/[lang]' : ''}/docs/[...slug]'>) {\n const page = source.getPage(slug${i18n ? ', lang' : ''});\n if (!page) unstable_notFound();\n\n const MDX = page.data.body;\n const content = (\n <DocsPage toc={page.data.toc}>\n <DocsTitle>{page.data.title}</DocsTitle>\n <DocsDescription>{page.data.description}</DocsDescription>\n <DocsBody>\n <MDX\n components={getMDXComponents({\n // this allows you to link to other pages with relative file paths\n a: createRelativeLink(source, page),\n })}\n />\n </DocsBody>\n </DocsPage>\n );\n${\n i18n\n ? `\n // layouts don't receive the locale, render the docs layout here\n return (\n <DocsLayout {...baseOptions(lang)} tree={source.getPageTree(lang)}>\n {content}\n </DocsLayout>\n );`\n : `\n return content;`\n}\n}\n\nexport async function getConfig() {\n return {\n render: 'static',\n staticPaths: source.generateParams().map((item) => ${i18n ? '[item.lang, ...item.slug]' : 'item.slug'}),\n } as const;\n}\n`;\n\n return {\n ...shared(input, false),\n 'pages/(docs)/_layout.tsx': i18n\n ? `import type { ReactNode } from 'react';\nimport { Provider } from '@/components/provider';\n\nexport default function Layout({ children }: { children: ReactNode }) {\n return (\n <Provider>\n ${wrapper('{children}')}\n </Provider>\n );\n}\n`\n : `import type { ReactNode } from 'react';\n${providerImports(input)}\nexport default function Layout({ children }: { children: ReactNode }) {\n return (\n <RootProvider${providerProps(input)}>\n ${wrapper('{children}')}\n </RootProvider>\n );\n}\n`,\n ...(i18n\n ? {\n 'components/provider.tsx': `'use client';\nimport type { ReactNode } from 'react';\nimport { useRouter } from 'waku/router/client';\n${providerImports(input)}\nexport function Provider({ children }: { children: ReactNode }) {\n const router = useRouter();\n const lang = router.path.split('/')[1] || i18n.defaultLanguage;\n\n return <RootProvider${providerProps(input)}>{children}</RootProvider>;\n}\n`,\n 'pages/(docs)/[lang]/docs/[...slug].tsx': page,\n }\n : {\n 'pages/(docs)/docs/_layout.tsx': `import type { ReactNode } from 'react';\nimport { DocsLayout } from 'fumadocs-ui/layouts/docs';\nimport { source } from '@/lib/source';\nimport { baseOptions } from '@/lib/layout.shared';\n\nexport default function Layout({ children }: { children: ReactNode }) {\n return (\n <DocsLayout {...baseOptions()} tree={source.getPageTree()}>\n {children}\n </DocsLayout>\n );\n}\n`,\n 'pages/(docs)/docs/[...slug].tsx': page,\n }),\n 'pages/_api/api/search.ts': searchRoute.waku,\n };\n },\n};\n\nexport const nextProxy = `import { createI18nMiddleware } from 'fumadocs-core/i18n/middleware';\nimport { i18n } from '@/lib/i18n';\n\nexport default createI18nMiddleware(i18n);\n\nexport const config = {\n // only the docs routes, add the ones of other features here\n matcher: ['/docs/:path*', '/:lang/docs/:path*'],\n};\n`;\n\nexport const sampleContent = `---\ntitle: Hello World\ndescription: Your first document\n---\n\nWelcome to the docs! You can edit this page in \\`content/docs/index.mdx\\`.\n\n## Heading\n\n<Cards>\n <Card title=\"Learn more about Fumadocs\" href=\"https://fumadocs.dev\" />\n</Cards>\n`;\n\nexport const sampleContentCn = `---\ntitle: 你好,世界\ndescription: 你的第一份文檔\n---\n\n歡迎來到文檔!你可以在 \\`content/docs/index.cn.mdx\\` 編輯這個頁面。\n`;\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { Feature, FeatureContext } from '@/features';\nimport type { I18nInfo, Project } from '@/project';\nimport {\n addImport,\n addJsxAttribute,\n addVitePlugin,\n findJsxElement,\n wrapNextConfig,\n} from '@/codemod';\nimport { exists } from '@/utils/fs';\nimport { localeSegment } from '@/project/route';\nimport { nextProxy, sampleContent, sampleContentCn, templates } from './templates';\nimport { reactFramework, reactOnly, registerReactRouterRoutes } from '../utils';\n\nconst cssImports = (preset: string) => [\n `@import 'fumadocs-ui/css/${preset}.css';`,\n `@import 'fumadocs-ui/css/preset.css';`,\n];\n\nexport const docs: Feature<{ i18n: boolean }> = {\n id: 'docs',\n title: 'Docs',\n description: 'set up Fumadocs on your app, in a dedicated route group',\n supports: reactOnly,\n options: {\n i18n: { message: 'Enable internationalization?', initialValue: false },\n },\n async detect(project) {\n return exists(path.join(project.cwd, project.baseDir, 'lib/source.ts'));\n },\n async apply(ctx, options) {\n const { project } = ctx;\n const { baseDir, packageJson, config } = project;\n const framework = reactFramework(project);\n // Waku has no optional route segments, the locale is always in the URL\n const i18n = project.i18n ?? (options.i18n ? { optionalLocale: framework !== 'waku' } : null);\n const providerProps: string[] = [];\n if (project.static) providerProps.push('search={{ SearchDialog }}');\n if ('next-themes' in (packageJson.dependencies ?? {}))\n providerProps.push('theme={{ enabled: false }}');\n\n ctx.addDependencies({\n 'fumadocs-core': null,\n 'fumadocs-mdx': null,\n 'fumadocs-ui': config.uiLibrary === 'base-ui' ? 'npm:@fumadocs/base-ui' : null,\n });\n ctx.addDependencies({ '@types/mdx': null }, true);\n\n const files = templates[framework]({\n static: project.static,\n i18n,\n provider: project.info.provider,\n providerProps: providerProps.map((prop) => ` ${prop}`).join(''),\n });\n for (const [file, content] of Object.entries(files)) {\n await ctx.write(path.posix.join(baseDir, file), content);\n }\n await ctx.write('content/docs/index.mdx', sampleContent);\n if (i18n) await ctx.write('content/docs/index.cn.mdx', sampleContentCn);\n await ctx.append('.gitignore', ['.source']);\n if (i18n && framework === 'next') await configureProxy(ctx);\n\n await configureBundler(ctx);\n await configureCss(ctx);\n await suppressHydrationWarning(ctx);\n if (framework === 'react-router') await configureRoutes(ctx, i18n);\n\n const tsconfig = await fs\n .readFile(path.join(project.cwd, 'tsconfig.json'), 'utf-8')\n .catch(() => '');\n if (!tsconfig.includes('\"@/*\"')) {\n ctx.note(\n `Generated files import from the \\`@/*\\` alias, add it to \\`tsconfig.json\\`:\\n \"paths\": { \"@/*\": [\"./${baseDir ? `${baseDir}/` : ''}*\"] }`,\n );\n }\n if (project.static && framework === 'tanstack-start') {\n ctx.note(\n 'In SPA mode, prerender the docs pages and search index, see https://fumadocs.dev/docs/manual-installation/tanstack-start.',\n );\n }\n if (i18n && framework === 'react-router') {\n ctx.note(\n 'When prerendering, list the docs pages with `source.getPages().map((page) => page.url)` instead of globbing content files, see https://fumadocs.dev/docs/internationalization/react-router.',\n );\n }\n if (i18n) {\n ctx.note(\n `Languages are configured in \\`lib/i18n.ts\\`, translated content uses a locale suffix like \\`index.cn.mdx\\`.\\nUI translations: https://fumadocs.dev/docs/internationalization#translations`,\n );\n }\n ctx.note(\n `Start the dev server and open ${i18n && !i18n.optionalLocale ? '/en/docs' : '/docs'} to see your docs.`,\n );\n },\n};\n\n/** the Next.js proxy (middleware) file of the project, relative to cwd */\nexport async function findNextProxy({ cwd, baseDir }: Project) {\n for (const file of ['proxy.ts', 'middleware.ts']) {\n for (const dir of new Set([baseDir, ''])) {\n const target = path.join(dir, file);\n if (await exists(path.join(cwd, target))) return target;\n }\n }\n}\n\n/** the i18n middleware redirects & rewrites docs URLs without locale */\nasync function configureProxy(ctx: FeatureContext) {\n const existing = await findNextProxy(ctx.project);\n if (!existing) {\n await ctx.write(path.join(ctx.project.baseDir, 'proxy.ts'), nextProxy);\n return;\n }\n\n ctx.note(\n `A proxy already exists at ${existing}, handle the docs locale there. Fumadocs provides \\`createI18nMiddleware\\` from 'fumadocs-core/i18n/middleware', see https://fumadocs.dev/docs/internationalization/next.`,\n );\n}\n\nasync function configureBundler(ctx: FeatureContext) {\n const { framework, configFile } = ctx.project;\n const edited =\n configFile !== undefined &&\n (await ctx\n .source(configFile, (file) => {\n const ok =\n framework === 'next'\n ? wrapNextConfig(file)\n : addVitePlugin(\n file,\n { name: 'fumadocsMdx', from: 'fumadocs-mdx/vite' },\n framework === 'waku' ? ['vite', 'plugins'] : ['plugins'],\n );\n if (!ok) throw new Error(`cannot update ${configFile}`);\n })\n .catch(() => false));\n\n if (!edited) {\n ctx.note(\n framework === 'next'\n ? \"Wrap your Next.js config with `createMDX()` from 'fumadocs-mdx/next', see https://fumadocs.dev/docs/mdx/next.\"\n : \"Add `fumadocsMdx()` from 'fumadocs-mdx/vite' to the Vite plugins of your config file.\",\n );\n }\n}\n\n/** resolve the global CSS file imported by the root file */\nasync function findCssEntry({ cwd, baseDir, info }: Project): Promise<string | undefined> {\n const rootFile = path.join(baseDir, info.rootFile);\n const content = await fs.readFile(path.join(cwd, rootFile), 'utf-8').catch(() => '');\n const match = /import\\s+(?:\\w+\\s+from\\s+)?['\"]([^'\"]+\\.css)(?:\\?url)?['\"]/.exec(content);\n if (!match) return;\n const specifier = match[1];\n\n if (specifier.startsWith('@/')) return path.join(baseDir, specifier.slice(2));\n if (specifier.startsWith('.')) return path.join(path.dirname(rootFile), specifier);\n}\n\nasync function configureCss(ctx: FeatureContext) {\n const { cwd } = ctx.project;\n const preset = (await exists(path.join(cwd, 'components.json'))) ? 'shadcn' : 'neutral';\n const entry = await findCssEntry(ctx.project);\n if (entry && (await exists(path.join(cwd, entry)))) {\n await ctx.append(entry, cssImports(preset));\n return;\n }\n\n ctx.note(\n `Add the styles to your global CSS file (after \\`@import 'tailwindcss'\\`):\\n ${cssImports(preset).join('\\n ')}`,\n );\n}\n\n/** `next-themes` sets the theme class on `<html>`, React warns about the mismatch without this attribute */\nasync function suppressHydrationWarning(ctx: FeatureContext) {\n const { baseDir, info } = ctx.project;\n const edited = await ctx.source(path.join(baseDir, info.rootFile), (file) => {\n const html = findJsxElement(file, 'html')?.openingElement;\n if (!html || file.code.slice(html.start, html.end).includes('suppressHydrationWarning')) return;\n addJsxAttribute(file, html, 'suppressHydrationWarning');\n });\n\n if (!edited)\n ctx.note('Add `suppressHydrationWarning` to the `<html>` element of your root layout.');\n}\n\nasync function configureRoutes(ctx: FeatureContext, i18n: I18nInfo | null) {\n const added = await registerReactRouterRoutes(ctx, [\n `layout('routes/docs/layout.tsx', [route('${localeSegment('react-router', i18n)}docs/*', 'routes/docs/page.tsx')])`,\n { path: 'api/search', file: 'routes/docs/search.ts', pattern: '/api/search' },\n ]);\n if (!added) return;\n await ctx.source(path.join(ctx.project.baseDir, 'routes.ts'), (file) => {\n addImport(file, { from: '@react-router/dev/routes', named: ['layout', 'route'] });\n });\n}\n"],"mappings":";;;;;;AAoCA,MAAM,cAAkD;CACtD,MAAM;EACJ,cAAc;EACd,QAAQ,MAAM,UAAU,aACtB,WAAY,WAAW,QAAQ,KAAK,MAAM,OAAO,KAAK,KAAM,IAAI,KAAK;EACvE,OAAO,UAAU,QAAQ,OAAO,SAAS,KAAK,GAAG,EAAE,SAAS;EAC5D,OAAO,aAAa,IAAI,SAAS,KAAK,GAAG;CAC3C;CACA,gBAAgB;EACd,SAAS,aAAc,WAAW,WAAW;EAC7C,QAAQ,MAAM,aAAc,WAAW,MAAM,IAAI;EAEjD,OAAO,UAAU,QACf,UAAU,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kdown } from "./codemod-auol-p4R.js";
2
+ import { a as routeModule, r as formatRoute, t as docs } from "./docs-DeIEl_Kt.js";
3
+ import { a as reactFramework, c as requiresMarkdown, d as sourceRef, s as registerReactRouterRoutes } from "./utils-DbMe7h6c.js";
4
+ import path from "node:path";
5
+ //#region src/features/epub.ts
6
+ const api = ({ dynamic, ref }) => `import { ${ref} } from '@/lib/source';
7
+ import { createEpubExportAPI } from 'fumadocs-epub';
8
+
9
+ const api = createEpubExportAPI({
10
+ ${ref === "source" ? "source" : `source: ${ref}`},${dynamic ? "\n getMarkdown: (page) => page.data.content," : ""}
11
+ title: 'Documentation',
12
+ author: 'Your Team',
13
+ description: 'Exported documentation',
14
+ // guards the route, requests must send \`Authorization: Bearer <secret>\`
15
+ secret: process.env.EXPORT_SECRET,
16
+ });
17
+ `;
18
+ const templates = (framework, route, src) => routeModule(framework, route, {
19
+ imports: api(src),
20
+ body: "api.GET(request)",
21
+ request: true,
22
+ revalidate: true
23
+ });
24
+ const epub = {
25
+ id: "epub",
26
+ title: "EPUB Export",
27
+ description: "a route to export docs as an EPUB file, protected by EXPORT_SECRET",
28
+ requires: [docs],
29
+ supports: (project) => project.static ? "the export route needs a server at runtime" : requiresMarkdown(project),
30
+ async apply(ctx) {
31
+ const { baseDir, source } = ctx.project;
32
+ const framework = reactFramework(ctx.project);
33
+ ctx.addDependencies({ "fumadocs-epub": null });
34
+ if (source.collections) await ctx.source(source.collections, (file) => {
35
+ if (!enableProcessedMarkdown(file)) throw new Error(`cannot find \`defineDocs()\` in ${source.collections}`);
36
+ });
37
+ const route = formatRoute({ segments: ["export/epub"] }, framework, null);
38
+ await ctx.write(path.join(baseDir, route.file), templates(framework, route, sourceRef(ctx.project.source.dynamic)));
39
+ if (framework === "react-router") {
40
+ await registerReactRouterRoutes(ctx, [route]);
41
+ await ctx.source("react-router.config.ts", (file) => {
42
+ addReactRouterPrerenderArray(file, "excluded", [`/${route.path}`]);
43
+ });
44
+ }
45
+ ctx.env("EXPORT_SECRET", "");
46
+ ctx.note("Set EXPORT_SECRET in `.env.local`, then export with `fumadocs export epub` after a production build.");
47
+ }
48
+ };
49
+ //#endregion
50
+ export { epub as t };
51
+
52
+ //# sourceMappingURL=epub-CnQFJh09.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epub-CnQFJh09.js","names":[],"sources":["../src/features/epub.ts"],"sourcesContent":["import path from 'node:path';\nimport type { Feature } from '@/features';\nimport type { ReactFramework } from '@/project';\nimport { type FormattedRoute, formatRoute, routeModule } from '@/project/route';\nimport { addReactRouterPrerenderArray, enableProcessedMarkdown } from '@/codemod';\nimport { docs } from './docs';\nimport {\n reactFramework,\n registerReactRouterRoutes,\n requiresMarkdown,\n type SourceRef,\n sourceRef,\n} from './utils';\n\nconst api = ({ dynamic, ref }: SourceRef) => `import { ${ref} } from '@/lib/source';\nimport { createEpubExportAPI } from 'fumadocs-epub';\n\nconst api = createEpubExportAPI({\n ${ref === 'source' ? 'source' : `source: ${ref}`},${dynamic ? '\\n getMarkdown: (page) => page.data.content,' : ''}\n title: 'Documentation',\n author: 'Your Team',\n description: 'Exported documentation',\n // guards the route, requests must send \\`Authorization: Bearer <secret>\\`\n secret: process.env.EXPORT_SECRET,\n});\n`;\n\nconst templates = (framework: ReactFramework, route: FormattedRoute, src: SourceRef) =>\n routeModule(framework, route, {\n imports: api(src),\n body: 'api.GET(request)',\n request: true,\n revalidate: true,\n });\n\nexport const epub: Feature = {\n id: 'epub',\n title: 'EPUB Export',\n description: 'a route to export docs as an EPUB file, protected by EXPORT_SECRET',\n requires: [docs],\n supports: (project) =>\n project.static ? 'the export route needs a server at runtime' : requiresMarkdown(project),\n async apply(ctx) {\n const { baseDir, source } = ctx.project;\n const framework = reactFramework(ctx.project);\n ctx.addDependencies({ 'fumadocs-epub': null });\n\n if (source.collections) {\n await ctx.source(source.collections, (file) => {\n if (!enableProcessedMarkdown(file))\n throw new Error(`cannot find \\`defineDocs()\\` in ${source.collections}`);\n });\n }\n\n const route = formatRoute({ segments: ['export/epub'] }, framework, null);\n await ctx.write(\n path.join(baseDir, route.file),\n templates(framework, route, sourceRef(ctx.project.source.dynamic)),\n );\n if (framework === 'react-router') {\n await registerReactRouterRoutes(ctx, [route]);\n // the route needs a secret at runtime\n await ctx.source('react-router.config.ts', (file) => {\n addReactRouterPrerenderArray(file, 'excluded', [`/${route.path}`]);\n });\n }\n\n ctx.env('EXPORT_SECRET', '');\n ctx.note(\n 'Set EXPORT_SECRET in `.env.local`, then export with `fumadocs export epub` after a production build.',\n );\n },\n};\n"],"mappings":";;;;;AAcA,MAAM,OAAO,EAAE,SAAS,UAAqB,YAAY,IAAI;;;;IAIzD,QAAQ,WAAW,WAAW,WAAW,MAAM,GAAG,UAAU,kDAAkD,GAAG;;;;;;;;AASrH,MAAM,aAAa,WAA2B,OAAuB,QACnE,YAAY,WAAW,OAAO;CAC5B,SAAS,IAAI,GAAG;CAChB,MAAM;CACN,SAAS;CACT,YAAY;AACd,CAAC;AAEH,MAAa,OAAgB;CAC3B,IAAI;CACJ,OAAO;CACP,aAAa;CACb,UAAU,CAAC,IAAI;CACf,WAAW,YACT,QAAQ,SAAS,+CAA+C,iBAAiB,OAAO;CAC1F,MAAM,MAAM,KAAK;EACf,MAAM,EAAE,SAAS,WAAW,IAAI;EAChC,MAAM,YAAY,eAAe,IAAI,OAAO;EAC5C,IAAI,gBAAgB,EAAE,iBAAiB,KAAK,CAAC;EAE7C,IAAI,OAAO,aACT,MAAM,IAAI,OAAO,OAAO,cAAc,SAAS;GAC7C,IAAI,CAAC,wBAAwB,IAAI,GAC/B,MAAM,IAAI,MAAM,mCAAmC,OAAO,aAAa;EAC3E,CAAC;EAGH,MAAM,QAAQ,YAAY,EAAE,UAAU,CAAC,aAAa,EAAE,GAAG,WAAW,IAAI;EACxE,MAAM,IAAI,MACR,KAAK,KAAK,SAAS,MAAM,IAAI,GAC7B,UAAU,WAAW,OAAO,UAAU,IAAI,QAAQ,OAAO,OAAO,CAAC,CACnE;EACA,IAAI,cAAc,gBAAgB;GAChC,MAAM,0BAA0B,KAAK,CAAC,KAAK,CAAC;GAE5C,MAAM,IAAI,OAAO,2BAA2B,SAAS;IACnD,6BAA6B,MAAM,YAAY,CAAC,IAAI,MAAM,MAAM,CAAC;GACnE,CAAC;EACH;EAEA,IAAI,IAAI,iBAAiB,EAAE;EAC3B,IAAI,KACF,sGACF;CACF;AACF"}
@@ -0,0 +1,25 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/ai.d.ts
3
+ declare const providers: {
4
+ openrouter: {
5
+ label: string;
6
+ hint: string;
7
+ env: string;
8
+ };
9
+ llmgateway: {
10
+ label: string;
11
+ hint: string;
12
+ env: string;
13
+ };
14
+ inkeep: {
15
+ label: string;
16
+ hint: string;
17
+ env: string;
18
+ };
19
+ };
20
+ export type AIProvider = keyof typeof providers;
21
+ export declare const ai: Feature<{
22
+ provider: AIProvider;
23
+ }>;
24
+ //#endregion
25
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","names":[],"sources":["../../src/features/ai.ts"],"mappings":";;cAMM;EACJ;IAAc;IAAiB;IAA+B;;EAC9D;IACE;IACA;IACA;;EAEF;IAAU;IAAoB;IAA0B;;;YAG9C,0BAA0B;qBAEzB,IAAI;EAAU,UAAU"}
@@ -0,0 +1,2 @@
1
+ import { t as ai } from "../ai-BVuNjYXU.js";
2
+ export { ai };
@@ -0,0 +1,5 @@
1
+ import { t as AnyFeature } from "../index-CR9T40ox.js";
2
+ //#region src/features/all.d.ts
3
+ export declare const features: AnyFeature[];
4
+ //#endregion
5
+ //# sourceMappingURL=all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all.d.ts","names":[],"sources":["../../src/features/all.ts"],"mappings":";;qBAYa,UAAU"}
@@ -0,0 +1,2 @@
1
+ import { t as features } from "../all-aUHxtoXL.js";
2
+ export { features };
@@ -0,0 +1,10 @@
1
+ import { a as Project } from "../../index-BCVGQxn9.js";
2
+ import { r as Feature } from "../../index-CR9T40ox.js";
3
+ //#region src/features/docs/index.d.ts
4
+ export declare const docs: Feature<{
5
+ i18n: boolean;
6
+ }>;
7
+ /** the Next.js proxy (middleware) file of the project, relative to cwd */
8
+ export declare function findNextProxy({ cwd, baseDir }: Project): Promise<string | undefined>;
9
+ //#endregion
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/features/docs/index.ts"],"mappings":";;;qBAqBa,MAAM;EAAU;;;wBA8EP,gBAAgB,KAAK,WAAW,UAAO"}
@@ -0,0 +1,2 @@
1
+ import { n as findNextProxy, t as docs } from "../../docs-DeIEl_Kt.js";
2
+ export { docs, findNextProxy };
@@ -0,0 +1,5 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/epub.d.ts
3
+ export declare const epub: Feature;
4
+ //#endregion
5
+ //# sourceMappingURL=epub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epub.d.ts","names":[],"sources":["../../src/features/epub.ts"],"mappings":";;qBAmCa,MAAM"}
@@ -0,0 +1,2 @@
1
+ import { t as epub } from "../epub-CnQFJh09.js";
2
+ export { epub };
@@ -0,0 +1,5 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/feedback.d.ts
3
+ export declare const feedback: Feature;
4
+ //#endregion
5
+ //# sourceMappingURL=feedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback.d.ts","names":[],"sources":["../../src/features/feedback.ts"],"mappings":";;qBAMa,UAAU"}
@@ -0,0 +1,2 @@
1
+ import { t as feedback } from "../feedback-COmWtc5C.js";
2
+ export { feedback };
@@ -0,0 +1,2 @@
1
+ import { a as FeatureIO, c as RunOptions, i as FeatureContext, l as SelectOption, n as ConfirmOption, o as FeatureOption, r as Feature, s as PackageJson, t as AnyFeature, u as runFeature } from "../index-CR9T40ox.js";
2
+ export { AnyFeature, ConfirmOption, Feature, FeatureContext, FeatureIO, FeatureOption, PackageJson, RunOptions, SelectOption, runFeature };
@@ -0,0 +1,2 @@
1
+ import { t as runFeature } from "../features-C1kf2s8j.js";
2
+ export { runFeature };
@@ -0,0 +1,7 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/lint.d.ts
3
+ export declare const lint: Feature<{
4
+ linter: 'eslint' | 'biome' | 'oxlint';
5
+ }>;
6
+ //#endregion
7
+ //# sourceMappingURL=lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lint.d.ts","names":[],"sources":["../../src/features/lint.ts"],"mappings":";;qBAwEa,MAAM;EAAU"}
@@ -0,0 +1,2 @@
1
+ import { t as lint } from "../lint-zkXUULgO.js";
2
+ export { lint };
@@ -0,0 +1,27 @@
1
+ import { o as ReactFramework, r as I18nInfo } from "../index-BCVGQxn9.js";
2
+ import { i as FeatureContext, r as Feature } from "../index-CR9T40ox.js";
3
+ import { p as FormattedRoute, t as SourceRef } from "../utils-B1Xy4l_a.js";
4
+ //#region src/features/llms.d.ts
5
+ /** runtime content sources expose raw Markdown as `page.data.content`, Fumadocs MDX processes it */
6
+ export declare const docsLlms: ({ dynamic, ref }: SourceRef) => string;
7
+ /** the Markdown URL of a page, `/llms.mdx/docs/<slugs>/content.md` */
8
+ export declare const markdownUrl: (i18n: boolean) => string;
9
+ /** TanStack Start serves Markdown with a `.md` suffix under the docs route */
10
+ export declare const tanstackMarkdownUrl: (i18n: boolean) => string;
11
+ interface Routes {
12
+ index: FormattedRoute;
13
+ full: FormattedRoute;
14
+ markdown: FormattedRoute;
15
+ }
16
+ export declare function templates(framework: ReactFramework, routes: Routes, i18n: boolean, src: SourceRef): [route: FormattedRoute, content: string][];
17
+ export declare function llmsRoutes(framework: ReactFramework, i18n: I18nInfo | null, docsRoute: string, contentRoute: string): Routes;
18
+ export declare const llms: Feature;
19
+ /** `/docs/*.md` serves the Markdown of a page, like TanStack Start's `.md` route */
20
+ export declare const markdownRewrite: (docsRoute: string, markdown: FormattedRoute, i18n: boolean) => {
21
+ source: string;
22
+ destination: string;
23
+ };
24
+ /** routes under `[lang]` need the i18n middleware to resolve the locale */
25
+ export declare function extendNextProxy(ctx: FeatureContext, route: FormattedRoute): Promise<void>;
26
+ //#endregion
27
+ //# sourceMappingURL=llms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llms.d.ts","names":[],"sources":["../../src/features/llms.ts"],"mappings":";;;;;qBA8Ba,aAAQ,SAAA,OAAsB;;qBAQ9B,cAAW;;qBAUX,sBAAmB;UAgCtB;EACR,OAAO;EACP,MAAM;EACN,UAAU;;wBAqFI,UACd,WAAW,gBACX,QAAQ,QACR,eACA,KAAK,aACH,OAAO,gBAAgB;wBAgBX,WACd,WAAW,gBACX,MAAM,iBACN,mBACA,uBACC;qBAmBU,MAAM;;qBAiEN,kBAAe,mBAAqB,UAAY,gBAAc;EACzE;EACA;;;wBA2BoB,gBAAgB,KAAK,gBAAgB,OAAO,iBAAc"}
@@ -0,0 +1,2 @@
1
+ import { a as markdownRewrite, c as templates, i as llmsRoutes, n as extendNextProxy, o as markdownUrl, r as llms, s as tanstackMarkdownUrl, t as docsLlms } from "../llms-CONd8Vnn.js";
2
+ export { docsLlms, extendNextProxy, llms, llmsRoutes, markdownRewrite, markdownUrl, tanstackMarkdownUrl, templates };
@@ -0,0 +1,9 @@
1
+ import { o as ReactFramework } from "../index-BCVGQxn9.js";
2
+ import { r as Feature } from "../index-CR9T40ox.js";
3
+ import { p as FormattedRoute, t as SourceRef } from "../utils-B1Xy4l_a.js";
4
+ //#region src/features/mcp.d.ts
5
+ export declare const templates: (framework: ReactFramework, route: FormattedRoute, src: SourceRef) => string;
6
+ export declare const mcpRoute: (framework: ReactFramework) => FormattedRoute;
7
+ export declare const mcp: Feature;
8
+ //#endregion
9
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","names":[],"sources":["../../src/features/mcp.ts"],"mappings":";;;;qBAkCa,YAAS,WAAe,gBAAc,OAAS,gBAAc,KAAO;qBAQpE,WAAQ,WAAe,mBAAc;qBAGrC,KAAK"}
@@ -0,0 +1,2 @@
1
+ import { n as mcpRoute, r as templates, t as mcp } from "../mcp-BT8BLZZ-.js";
2
+ export { mcp, mcpRoute, templates };
@@ -0,0 +1,8 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/og.d.ts
3
+ type Engine = 'takumi' | 'next-og';
4
+ export declare const og: Feature<{
5
+ engine: Engine;
6
+ }>;
7
+ //#endregion
8
+ //# sourceMappingURL=og.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"og.d.ts","names":[],"sources":["../../src/features/og.ts"],"mappings":";;KAgBK;qBAsGQ,IAAI;EAAU,QAAQ"}
@@ -0,0 +1,2 @@
1
+ import { t as og } from "../og-DRDOyQ_t.js";
2
+ export { og };
@@ -0,0 +1,84 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ import { t as SourceRef } from "../utils-B1Xy4l_a.js";
3
+ //#region src/features/search.d.ts
4
+ /** how client code reads public env variables */
5
+ interface Env {
6
+ prefix: string;
7
+ read: string;
8
+ }
9
+ declare const providers: {
10
+ 'orama-cloud': {
11
+ label: string;
12
+ hint: string;
13
+ dependencies: {
14
+ '@orama/core': null;
15
+ };
16
+ publicEnv: string[];
17
+ privateEnv: string[];
18
+ static: true;
19
+ dialog: (env: Env) => string;
20
+ exportIndexes: ({ ref }: SourceRef) => {
21
+ imports: string;
22
+ documents: string;
23
+ };
24
+ sync: (env: Env) => string;
25
+ };
26
+ algolia: {
27
+ label: string;
28
+ hint: string;
29
+ dependencies: {
30
+ algoliasearch: null;
31
+ };
32
+ publicEnv: string[];
33
+ privateEnv: string[];
34
+ static: true;
35
+ dialog: (env: Env) => string;
36
+ exportIndexes: ({ ref }: SourceRef) => {
37
+ imports: string;
38
+ documents: string;
39
+ };
40
+ sync: (env: Env) => string;
41
+ };
42
+ typesense: {
43
+ label: string;
44
+ hint: string;
45
+ dependencies: {
46
+ typesense: null;
47
+ 'typesense-fumadocs-adapter': null;
48
+ };
49
+ publicEnv: string[];
50
+ privateEnv: string[];
51
+ static: true;
52
+ dialog: (env: Env) => string;
53
+ exportIndexes: (src: SourceRef) => {
54
+ imports: string;
55
+ documents: string;
56
+ file: (async: boolean) => string;
57
+ };
58
+ sync: (env: Env) => string;
59
+ };
60
+ mixedbread: {
61
+ label: string;
62
+ hint: string;
63
+ dependencies: {
64
+ '@mixedbread/sdk': null;
65
+ };
66
+ publicEnv: never[];
67
+ privateEnv: string[];
68
+ static: false;
69
+ dialog: () => string;
70
+ sync: (_env: Env, dir: string) => string;
71
+ searchRoute: {
72
+ next: string;
73
+ 'react-router': string;
74
+ 'tanstack-start': string;
75
+ waku: string;
76
+ };
77
+ };
78
+ };
79
+ export type SearchProvider = keyof typeof providers;
80
+ export declare const search: Feature<{
81
+ provider: SearchProvider;
82
+ }>;
83
+ //#endregion
84
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","names":[],"sources":["../../src/features/search.ts"],"mappings":";;;;UAwBU;EACR;EACA;;cA6GI;;;;;MAIc;;;;;;;;;;;;;;;;MA+CA;;;;;;;;;;;;;;;;MA+CA;MAAiB;;;;;;;;;;;;;;;;;MAgDjB;;;;;;;;;;;;;;;YAqER,8BAA8B;qBAe7B,QAAQ;EAAU,UAAU"}
@@ -0,0 +1,2 @@
1
+ import { t as search } from "../search-iphnSVVY.js";
2
+ export { search };
@@ -0,0 +1,2 @@
1
+ import { a as posix, c as registerReactRouterRoutes, d as sharedRoute, f as sourceRef, i as findSource, l as requiresMarkdown, n as addExport, o as reactFramework, r as addPageUrl, s as reactOnly, t as SourceRef, u as scripts } from "../utils-B1Xy4l_a.js";
2
+ export { SourceRef, addExport, addPageUrl, findSource, posix, reactFramework, reactOnly, registerReactRouterRoutes, requiresMarkdown, scripts, sharedRoute, sourceRef };
@@ -0,0 +1,2 @@
1
+ import { a as reactFramework, c as requiresMarkdown, d as sourceRef, i as posix, l as scripts, n as addPageUrl, o as reactOnly, r as findSource, s as registerReactRouterRoutes, t as addExport, u as sharedRoute } from "../utils-DbMe7h6c.js";
2
+ export { addExport, addPageUrl, findSource, posix, reactFramework, reactOnly, registerReactRouterRoutes, requiresMarkdown, scripts, sharedRoute, sourceRef };
@@ -0,0 +1,12 @@
1
+ import { r as Feature } from "../index-CR9T40ox.js";
2
+ //#region src/features/webmcp.d.ts
3
+ interface Input {
4
+ static: boolean;
5
+ i18n: boolean;
6
+ /** the Markdown route of TanStack Start is `/docs/*.md` */
7
+ tanstack: boolean;
8
+ }
9
+ export declare const component: ({ static: isStatic, i18n, tanstack }: Input) => string;
10
+ export declare const webmcp: Feature;
11
+ //#endregion
12
+ //# sourceMappingURL=webmcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webmcp.d.ts","names":[],"sources":["../../src/features/webmcp.ts"],"mappings":";;UAMU;EACR;EACA;;EAEA;;qBAGW,cAAS,QAAA,UAAA,MAAA,YAA0C;qBAuGnD,QAAQ"}
@@ -0,0 +1,2 @@
1
+ import { n as webmcp, t as component } from "../webmcp-C2PM_9md.js";
2
+ export { component, webmcp };
@@ -0,0 +1,132 @@
1
+ import { t as FumadocsComponentInstaller } from "./installer-D0Obb2Md.js";
2
+ import { t as exists } from "./fs-D6J9dOEx.js";
3
+ import { g as createSourceFile } from "./codemod-auol-p4R.js";
4
+ import fs from "node:fs/promises";
5
+ import path from "node:path";
6
+ import { x } from "tinyexec";
7
+ //#region src/features/index.ts
8
+ async function runFeature(feature, options, { project, connector, io, versions }) {
9
+ for (const dep of feature.requires ?? []) if (dep.detect && !await dep.detect(project)) throw new Error(`"${feature.id}" requires "${dep.id}", run \`fumadocs feature ${dep.id}\` first.`);
10
+ const supported = feature.supports?.(project) ?? true;
11
+ if (supported !== true) throw new Error(`"${feature.id}" is unavailable: ${supported}`);
12
+ const { cwd } = project;
13
+ const deps = {};
14
+ const devDeps = {};
15
+ const env = [];
16
+ const notes = [];
17
+ const installer = new FumadocsComponentInstaller(connector, project.config, cwd, {
18
+ onWarn: io.log,
19
+ confirmFileOverride: ({ path: file }) => io.confirmOverwrite(path.relative(cwd, file)),
20
+ onFileDownloaded: ({ path: file }) => io.log(`installed ${path.relative(cwd, file)}`)
21
+ });
22
+ const ctx = {
23
+ project,
24
+ log: io.log,
25
+ note: (text) => notes.push(text),
26
+ env: (key, value) => env.push(`${key}=${value}`),
27
+ addDependencies(input, dev) {
28
+ Object.assign(dev ? devDeps : deps, input);
29
+ },
30
+ async write(file, content) {
31
+ const target = path.join(cwd, file);
32
+ const current = await fs.readFile(target, "utf-8").catch(() => null);
33
+ if (current !== null) {
34
+ if (current.trim() === content.trim()) return;
35
+ if (!await io.confirmOverwrite(file)) return;
36
+ }
37
+ await fs.mkdir(path.dirname(target), { recursive: true });
38
+ await fs.writeFile(target, content);
39
+ io.log(`${current === null ? "created" : "updated"} ${file}`);
40
+ },
41
+ async source(file, edit) {
42
+ const target = path.join(cwd, file);
43
+ if (!await exists(target)) return false;
44
+ const source = await createSourceFile(target);
45
+ edit(source);
46
+ if (source.s.hasChanged()) {
47
+ await source.save();
48
+ io.log(`updated ${file}`);
49
+ }
50
+ return true;
51
+ },
52
+ async append(file, lines) {
53
+ const target = path.join(cwd, file);
54
+ const current = await fs.readFile(target, "utf-8").catch(() => "");
55
+ const missing = lines.filter((line) => !current.includes(line));
56
+ if (missing.length === 0) return;
57
+ const separator = current.length === 0 || current.endsWith("\n") ? "" : "\n";
58
+ await fs.mkdir(path.dirname(target), { recursive: true });
59
+ await fs.writeFile(target, `${current}${separator}${missing.join("\n")}\n`);
60
+ io.log(`updated ${file}`);
61
+ },
62
+ async remove(file) {
63
+ await fs.rm(path.join(cwd, file), { force: true });
64
+ io.log(`removed ${file}`);
65
+ },
66
+ async packageJson(edit) {
67
+ const target = path.join(cwd, "package.json");
68
+ const data = JSON.parse(await fs.readFile(target, "utf-8"));
69
+ edit(data);
70
+ await fs.writeFile(target, `${JSON.stringify(data, null, 2)}\n`);
71
+ io.log("updated package.json");
72
+ },
73
+ async install(name, subRegistry) {
74
+ const manager = await (await installer.install(name, subRegistry)).deps();
75
+ const decode = (target, dep) => {
76
+ const at = dep.indexOf("@", 1);
77
+ if (at === -1) target[dep] = null;
78
+ else target[dep.slice(0, at)] = dep.slice(at + 1);
79
+ };
80
+ for (const dep of manager.dependencies) decode(deps, dep);
81
+ for (const dep of manager.devDependencies) decode(devDeps, dep);
82
+ }
83
+ };
84
+ await feature.apply(ctx, options);
85
+ if (env.length > 0) await ctx.append(".env.local", env);
86
+ await installDependencies(project, deps, devDeps, io, versions);
87
+ return { notes };
88
+ }
89
+ async function installDependencies(project, deps, devDeps, io, versions = {}) {
90
+ const { dependencies = {}, devDependencies = {} } = project.packageJson;
91
+ const filter = (input) => Object.entries(input).filter(([name]) => !(name in dependencies) && !(name in devDependencies));
92
+ const missing = filter(deps);
93
+ const missingDev = filter(devDeps);
94
+ if (missing.length === 0 && missingDev.length === 0) return;
95
+ if (io.installDependencies) {
96
+ const pm = project.packageManager;
97
+ const run = async (flags, entries) => {
98
+ if (entries.length === 0) return;
99
+ const args = [
100
+ "add",
101
+ ...flags,
102
+ ...entries.map(([name, version]) => version ? `${name}@${version}` : name)
103
+ ];
104
+ io.log(`${pm} ${args.join(" ")}`);
105
+ await x(pm, args, {
106
+ nodeOptions: {
107
+ cwd: project.cwd,
108
+ stdio: "inherit"
109
+ },
110
+ throwOnError: true
111
+ });
112
+ };
113
+ await run([], missing);
114
+ await run(["-D"], missingDev);
115
+ return;
116
+ }
117
+ const file = path.join(project.cwd, "package.json");
118
+ const json = JSON.parse(await fs.readFile(file, "utf-8"));
119
+ const write = (field, entries) => {
120
+ if (entries.length === 0) return;
121
+ const target = json[field] ??= {};
122
+ for (const [name, version] of entries) target[name] = version ?? versions[name] ?? "latest";
123
+ };
124
+ write("dependencies", missing);
125
+ write("devDependencies", missingDev);
126
+ await fs.writeFile(file, `${JSON.stringify(json, null, 2)}\n`);
127
+ io.log("updated package.json");
128
+ }
129
+ //#endregion
130
+ export { runFeature as t };
131
+
132
+ //# sourceMappingURL=features-C1kf2s8j.js.map