ardo 3.0.5 → 3.2.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 (104) hide show
  1. package/README.md +9 -19
  2. package/dist/DocPage-BVibJR9O.js +997 -0
  3. package/dist/DocPage-BVibJR9O.js.map +1 -0
  4. package/dist/assets/src/ui/Breadcrumb.css.ts.vanilla-Dpgq-C_p.css +20 -0
  5. package/dist/assets/src/ui/DocPage.css.ts.vanilla-CXKuz4U-.css +34 -0
  6. package/dist/assets/src/ui/Footer.css.ts.vanilla-BSzPIPt4.css +100 -0
  7. package/dist/assets/src/ui/Header.css.ts.vanilla-8QL0Jzgk.css +156 -0
  8. package/dist/assets/src/ui/Layout.css.ts.vanilla-Bpx_-gJt.css +67 -0
  9. package/dist/assets/src/ui/Nav.css.ts.vanilla-CsAQjogy.css +51 -0
  10. package/dist/assets/src/ui/Sidebar.css.ts.vanilla-D70qXTEr.css +115 -0
  11. package/dist/assets/src/ui/TOC.css.ts.vanilla-435FKDcl.css +52 -0
  12. package/dist/assets/src/ui/components/ApiItem.css.ts.vanilla-B_DW-1iJ.css +218 -0
  13. package/dist/assets/src/ui/components/CodeBlock.css.ts.vanilla-lNKqskjQ.css +182 -0
  14. package/dist/assets/src/ui/components/Container.css.ts.vanilla-CUhRUA9t.css +80 -0
  15. package/dist/assets/src/ui/components/CopyButton.css.ts.vanilla-DZZ5jgTM.css +24 -0
  16. package/dist/assets/src/ui/components/Features.css.ts.vanilla-D-pNXM9Q.css +129 -0
  17. package/dist/assets/src/ui/components/Hero.css.ts.vanilla-DHJVZ6GX.css +134 -0
  18. package/dist/assets/src/ui/components/Search.css.ts.vanilla-BYpWHzky.css +135 -0
  19. package/dist/assets/src/ui/components/Steps.css.ts.vanilla-CisaxeNj.css +59 -0
  20. package/dist/assets/src/ui/components/Tabs.css.ts.vanilla-C4-vJSnf.css +30 -0
  21. package/dist/assets/src/ui/components/ThemeToggle.css.ts.vanilla---sSUELC.css +22 -0
  22. package/dist/assets/src/ui/content.css.ts.vanilla-O_RaSPXm.css +106 -0
  23. package/dist/assets/src/ui/theme/animations.css.ts.vanilla-D6ImVUKy.css +10 -0
  24. package/dist/assets/src/ui/theme/dark.css.ts.vanilla-2iJgcpbU.css +87 -0
  25. package/dist/assets/src/ui/theme/light.css.ts.vanilla-CwinfWSf.css +87 -0
  26. package/dist/assets/src/ui/theme/reset.css.ts.vanilla-0Q3pLjfC.css +34 -0
  27. package/dist/config/index.d.ts +5 -5
  28. package/dist/config/index.d.ts.map +1 -0
  29. package/dist/config/index.js +54 -11
  30. package/dist/config/index.js.map +1 -1
  31. package/dist/contract.css-QS0y3-CM.d.ts +105 -0
  32. package/dist/contract.css-QS0y3-CM.d.ts.map +1 -0
  33. package/dist/generator-DcUomVnD.js +1193 -0
  34. package/dist/generator-DcUomVnD.js.map +1 -0
  35. package/dist/icons/index.d.ts +1 -1
  36. package/dist/icons/index.js +1 -2
  37. package/dist/index-DNKCjxv5.d.ts +78 -0
  38. package/dist/index-DNKCjxv5.d.ts.map +1 -0
  39. package/dist/index-DSeJoaxz.d.ts +938 -0
  40. package/dist/index-DSeJoaxz.d.ts.map +1 -0
  41. package/dist/index.d.ts +5 -8
  42. package/dist/index.js +6 -101
  43. package/dist/mdx/provider.d.ts +61 -4
  44. package/dist/mdx/provider.d.ts.map +1 -0
  45. package/dist/mdx/provider.js +89 -116
  46. package/dist/mdx/provider.js.map +1 -1
  47. package/dist/runtime/index.d.ts +2 -41
  48. package/dist/runtime/index.js +2 -28
  49. package/dist/sidebar-utils-1Skqle1Q.js +109 -0
  50. package/dist/sidebar-utils-1Skqle1Q.js.map +1 -0
  51. package/dist/theme/index.d.ts +215 -0
  52. package/dist/theme/index.d.ts.map +1 -0
  53. package/dist/theme/index.js +295 -0
  54. package/dist/theme/index.js.map +1 -0
  55. package/dist/typedoc/components/index.d.ts +55 -0
  56. package/dist/typedoc/components/index.d.ts.map +1 -0
  57. package/dist/typedoc/components/index.js +328 -0
  58. package/dist/typedoc/components/index.js.map +1 -0
  59. package/dist/typedoc/index.d.ts +34 -303
  60. package/dist/typedoc/index.d.ts.map +1 -0
  61. package/dist/typedoc/index.js +97 -268
  62. package/dist/typedoc/index.js.map +1 -1
  63. package/dist/types-DAZHcySL.d.ts +182 -0
  64. package/dist/types-DAZHcySL.d.ts.map +1 -0
  65. package/dist/types-DVodb4lK.d.ts +198 -0
  66. package/dist/types-DVodb4lK.d.ts.map +1 -0
  67. package/dist/ui/index.d.ts +2 -198
  68. package/dist/ui/index.js +3 -98
  69. package/dist/ui/styles.css +1460 -2412
  70. package/dist/ui/styles.d.ts +1 -0
  71. package/dist/ui/styles.js +23 -0
  72. package/dist/ui-NhRDIFUN.js +1301 -0
  73. package/dist/ui-NhRDIFUN.js.map +1 -0
  74. package/dist/vite/index.d.ts +72 -78
  75. package/dist/vite/index.d.ts.map +1 -0
  76. package/dist/vite/index.js +2918 -1278
  77. package/dist/vite/index.js.map +1 -1
  78. package/package.json +33 -15
  79. package/dist/FileTree-qpT1ZVrW.d.ts +0 -655
  80. package/dist/Search-MXGJE6PQ.js +0 -9
  81. package/dist/Search-MXGJE6PQ.js.map +0 -1
  82. package/dist/chunk-BHHI2BO4.js +0 -194
  83. package/dist/chunk-BHHI2BO4.js.map +0 -1
  84. package/dist/chunk-FZP2AVJL.js +0 -43
  85. package/dist/chunk-FZP2AVJL.js.map +0 -1
  86. package/dist/chunk-MJQGGJQZ.js +0 -88
  87. package/dist/chunk-MJQGGJQZ.js.map +0 -1
  88. package/dist/chunk-NBRHGTR2.js +0 -79
  89. package/dist/chunk-NBRHGTR2.js.map +0 -1
  90. package/dist/chunk-PGHUPTGL.js +0 -1035
  91. package/dist/chunk-PGHUPTGL.js.map +0 -1
  92. package/dist/chunk-QELSOHIY.js +0 -46
  93. package/dist/chunk-QELSOHIY.js.map +0 -1
  94. package/dist/chunk-QKDVSW6Q.js +0 -378
  95. package/dist/chunk-QKDVSW6Q.js.map +0 -1
  96. package/dist/chunk-R2QKY6G3.js +0 -1
  97. package/dist/chunk-R2QKY6G3.js.map +0 -1
  98. package/dist/chunk-XK7YZAVP.js +0 -887
  99. package/dist/chunk-XK7YZAVP.js.map +0 -1
  100. package/dist/icons/index.js.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/runtime/index.js.map +0 -1
  103. package/dist/types-CLkHwCch.d.ts +0 -248
  104. package/dist/ui/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/vite/plugin.ts","../../src/markdown/shiki.ts","../../src/vite/routes-plugin.ts","../../src/vite/codeblock-plugin.ts","../../src/runtime/loader.ts","../../src/markdown/pipeline.ts","../../src/markdown/toc.ts","../../src/markdown/links.ts","../../src/runtime/sidebar.ts"],"sourcesContent":["import type { Plugin, UserConfig } from \"vite\"\nimport type { ArdoConfig, ProjectMeta, ResolvedConfig } from \"../config/types\"\nimport type { TypeDocConfig } from \"../typedoc/types\"\nimport { resolveConfig, defaultMarkdownConfig } from \"../config/index\"\nimport { generateApiDocs } from \"../typedoc/generator\"\nimport { reactRouter } from \"@react-router/dev/vite\"\nimport mdx from \"@mdx-js/rollup\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkMdxFrontmatter from \"remark-mdx-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport rehypeShiki from \"@shikijs/rehype\"\nimport { ardoLineTransformer, remarkCodeMeta } from \"../markdown/shiki\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\nimport { execSync } from \"child_process\"\nimport matter from \"gray-matter\"\nimport { ardoRoutesPlugin, type ArdoRoutesPluginOptions } from \"./routes-plugin\"\nimport { ardoCodeBlockPlugin } from \"./codeblock-plugin\"\n\n/**\n * Finds the package root by looking for package.json in parent directories.\n * Returns the path relative to cwd, or undefined if not found.\n */\nfunction findPackageRoot(cwd: string): string | undefined {\n let dir = path.resolve(cwd)\n const root = path.parse(dir).root\n\n while (dir !== root) {\n const parentDir = path.dirname(dir)\n const packageJsonPath = path.join(parentDir, \"package.json\")\n\n if (fsSync.existsSync(packageJsonPath)) {\n // Return relative path from cwd to parent\n return path.relative(cwd, parentDir) || \".\"\n }\n\n dir = parentDir\n }\n\n return undefined\n}\n\n/**\n * Detects the GitHub repository name from git remote URL.\n * Returns the repo name (e.g., 'ardo' from 'github.com/sebastian-software/ardo')\n * or undefined if not a GitHub repo.\n */\nfunction detectGitHubRepoName(cwd: string): string | undefined {\n try {\n const remoteUrl = execSync(\"git remote get-url origin\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n\n // Parse GitHub URL (supports both HTTPS and SSH)\n // https://github.com/user/repo.git\n // git@github.com:user/repo.git\n const match = remoteUrl.match(/github\\.com[/:][\\w-]+\\/([\\w.-]+?)(?:\\.git)?$/)\n return match?.[1]\n } catch {\n return undefined\n }\n}\n\n/**\n * Detects the current short git commit hash.\n */\nfunction detectGitHash(cwd: string): string | undefined {\n try {\n return execSync(\"git rev-parse --short HEAD\", {\n cwd,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n } catch {\n return undefined\n }\n}\n\n/**\n * Reads project metadata from the nearest package.json.\n */\nfunction readProjectMeta(root: string): ProjectMeta {\n const pkgPath = path.join(root, \"package.json\")\n try {\n const raw = fsSync.readFileSync(pkgPath, \"utf-8\")\n const pkg = JSON.parse(raw)\n\n let repository: string | undefined\n if (typeof pkg.repository === \"string\") {\n repository = pkg.repository\n } else if (pkg.repository?.url) {\n // Normalize git+https://... or git://... URLs\n repository = pkg.repository.url\n .replace(/^git\\+/, \"\")\n .replace(/^git:\\/\\//, \"https://\")\n .replace(/\\.git$/, \"\")\n }\n\n let author: string | undefined\n if (typeof pkg.author === \"string\") {\n author = pkg.author\n } else if (pkg.author?.name) {\n author = pkg.author.name\n }\n\n return {\n name: pkg.name,\n homepage: pkg.homepage,\n repository,\n version: pkg.version,\n author,\n license: pkg.license,\n }\n } catch {\n return {}\n }\n}\n\n/**\n * Recursively copies files from src to dest, overwriting existing files.\n */\nfunction copyRecursive(src: string, dest: string) {\n const stat = fsSync.statSync(src)\n\n if (stat.isDirectory()) {\n if (!fsSync.existsSync(dest)) {\n fsSync.mkdirSync(dest, { recursive: true })\n }\n for (const item of fsSync.readdirSync(src)) {\n copyRecursive(path.join(src, item), path.join(dest, item))\n }\n } else {\n fsSync.copyFileSync(src, dest)\n }\n}\n\n/**\n * Detects the GitHub Pages basename from the git remote URL.\n * Returns `\"/repo-name/\"` if a GitHub repo is detected, otherwise `undefined`.\n *\n * Use this in `react-router.config.ts` to synchronize client-side routing\n * with the Vite `base` path that Ardo auto-detects:\n *\n * ```ts\n * import { detectGitHubBasename } from \"ardo/vite\"\n *\n * export default {\n * ssr: false,\n * prerender: true,\n * basename: detectGitHubBasename(),\n * } satisfies Config\n * ```\n */\nexport function detectGitHubBasename(cwd?: string): string {\n if (process.env.NODE_ENV !== \"production\") {\n return \"/\"\n }\n const repoName = detectGitHubRepoName(cwd || process.cwd())\n return repoName ? `/${repoName}/` : \"/\"\n}\n\nconst VIRTUAL_MODULE_ID = \"virtual:ardo/config\"\nconst RESOLVED_VIRTUAL_MODULE_ID = \"\\0\" + VIRTUAL_MODULE_ID\n\nconst VIRTUAL_SIDEBAR_ID = \"virtual:ardo/sidebar\"\nconst RESOLVED_VIRTUAL_SIDEBAR_ID = \"\\0\" + VIRTUAL_SIDEBAR_ID\n\nconst VIRTUAL_SEARCH_ID = \"virtual:ardo/search-index\"\nconst RESOLVED_VIRTUAL_SEARCH_ID = \"\\0\" + VIRTUAL_SEARCH_ID\n\n// Module-level flags to prevent duplicate operations across plugin instances\n// This is necessary because React Router creates multiple Vite instances\nlet typedocGenerated = false\nlet flattenExecuted = false\n\nexport interface ArdoPluginOptions extends Partial<ArdoConfig> {\n /** Options for the routes generator plugin */\n routes?: ArdoRoutesPluginOptions | false\n /**\n * Auto-detect GitHub repository and set base path for GitHub Pages.\n * When true, automatically sets `base: '/repo-name/'` if deploying to GitHub Pages.\n * @default true\n */\n githubPages?: boolean\n /**\n * Directory where routes are located.\n * @default \"./app/routes\"\n */\n routesDir?: string\n}\n\nexport function ardoPlugin(options: ArdoPluginOptions = {}): Plugin[] {\n let resolvedConfig: ResolvedConfig\n let routesDir: string\n\n // Extract ardo-specific options from the rest (which is ArdoConfig)\n const {\n routes,\n typedoc,\n githubPages = true,\n routesDir: routesDirOption,\n ...pressConfig\n } = options\n\n const mainPlugin: Plugin = {\n name: \"ardo\",\n enforce: \"pre\",\n\n config(userConfig, env): UserConfig {\n const root = userConfig.root || process.cwd()\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n const result: UserConfig = {\n define: {\n __BUILD_TIME__: JSON.stringify(new Date().toISOString()),\n },\n optimizeDeps: {\n exclude: [\"ardo/ui/styles.css\"],\n },\n ssr: {\n noExternal: [\"ardo\"],\n },\n }\n\n // Auto-detect GitHub Pages base path for production builds\n if (githubPages && env.command === \"build\" && !userConfig.base) {\n const repoName = detectGitHubRepoName(root)\n if (repoName) {\n result.base = `/${repoName}/`\n console.log(`[ardo] GitHub Pages detected, using base: ${result.base}`)\n }\n }\n\n return result\n },\n\n async configResolved(config) {\n const root = config.root\n routesDir = routesDirOption || path.join(root, \"app\", \"routes\")\n\n // Auto-detect project metadata from package.json\n const detectedProject = readProjectMeta(root)\n const project: ProjectMeta = { ...detectedProject, ...pressConfig.project }\n\n const defaultConfig: ArdoConfig = {\n title: pressConfig.title ?? \"Ardo\",\n description: pressConfig.description ?? \"Documentation powered by Ardo\",\n }\n\n // For React Router, contentDir is the routes directory\n const configWithRoutes = {\n ...defaultConfig,\n ...pressConfig,\n project,\n srcDir: routesDir,\n }\n\n resolvedConfig = resolveConfig(configWithRoutes, root)\n },\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n if (id === VIRTUAL_SIDEBAR_ID) {\n return RESOLVED_VIRTUAL_SIDEBAR_ID\n }\n if (id === VIRTUAL_SEARCH_ID) {\n return RESOLVED_VIRTUAL_SEARCH_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n const clientConfig = {\n title: resolvedConfig.title,\n description: resolvedConfig.description,\n base: resolvedConfig.base,\n lang: resolvedConfig.lang,\n themeConfig: resolvedConfig.themeConfig,\n project: resolvedConfig.project,\n buildTime: new Date().toISOString(),\n buildHash: detectGitHash(resolvedConfig.root),\n }\n return `export default ${JSON.stringify(clientConfig)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SIDEBAR_ID) {\n const sidebar = await generateSidebar(resolvedConfig, routesDir)\n return `export default ${JSON.stringify(sidebar)}`\n }\n\n if (id === RESOLVED_VIRTUAL_SEARCH_ID) {\n const searchIndex = await generateSearchIndex(routesDir)\n return `export default ${JSON.stringify(searchIndex)}`\n }\n },\n\n transform(code, id) {\n // Only process .mdx/.md files inside the routes directory\n if (!/\\.(mdx|md)$/.test(id)) return\n if (!id.startsWith(routesDir)) return\n\n // Skip if the file already exports a meta function\n if (/export\\s+(const|function)\\s+meta\\b/.test(code)) return\n\n // Extract frontmatter values from the compiled MDX export\n const titleMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*title\\s*:\\s*\"([^\"]*)\"/\n )\n const descMatch = code.match(\n /export\\s+const\\s+frontmatter\\s*=\\s*\\{[^}]*description\\s*:\\s*\"([^\"]*)\"/\n )\n\n const pageTitle = titleMatch?.[1]\n if (!pageTitle) return\n\n const siteTitle = resolvedConfig.title\n const separator = resolvedConfig.titleSeparator\n const fullTitle = `${pageTitle}${separator}${siteTitle}`\n const description = descMatch?.[1]\n\n const metaEntries = [`{ title: ${JSON.stringify(fullTitle)} }`]\n if (description) {\n metaEntries.push(`{ name: \"description\", content: ${JSON.stringify(description)} }`)\n }\n\n return {\n code: `${code}\\nexport const meta = () => [${metaEntries.join(\", \")}];\\n`,\n map: null,\n }\n },\n }\n\n const plugins: Plugin[] = [mainPlugin]\n\n // Add routes plugin unless explicitly disabled\n if (routes !== false) {\n plugins.push(\n ardoRoutesPlugin({\n routesDir: routesDirOption,\n ...routes,\n })\n )\n }\n\n // Add TypeDoc plugin if enabled\n if (typedoc) {\n // Find package root to use as default entry point and tsconfig base\n const packageRoot = findPackageRoot(process.cwd())\n const defaultEntryPoint = packageRoot ? `${packageRoot}/src/index.ts` : \"./src/index.ts\"\n const defaultTsconfig = packageRoot ? `${packageRoot}/tsconfig.json` : \"./tsconfig.json\"\n\n const defaultTypedocConfig: TypeDocConfig = {\n enabled: true,\n entryPoints: [defaultEntryPoint],\n tsconfig: defaultTsconfig,\n out: \"api-reference\",\n excludePrivate: true,\n excludeInternal: true,\n }\n\n const typedocConfig: TypeDocConfig =\n typedoc === true ? defaultTypedocConfig : { ...defaultTypedocConfig, ...typedoc }\n\n const typedocPlugin: Plugin = {\n name: \"ardo:typedoc\",\n\n async buildStart() {\n // Use module-level flag to prevent duplicate generation across plugin instances\n if (typedocGenerated || !typedocConfig.enabled) {\n return\n }\n\n console.log(\"[ardo] Generating API documentation with TypeDoc...\")\n const startTime = Date.now()\n try {\n const outputDir = routesDirOption || \"./app/routes\"\n const docs = await generateApiDocs(typedocConfig, outputDir)\n const duration = Date.now() - startTime\n console.log(`[ardo] Generated ${docs.length} API documentation pages in ${duration}ms`)\n } catch (error) {\n console.warn(\"[ardo] TypeDoc generation failed. API documentation will not be available.\")\n console.warn(\"[ardo] Check your typedoc.entryPoints configuration.\")\n if (error instanceof Error) {\n console.warn(`[ardo] Error: ${error.message}`)\n }\n }\n typedocGenerated = true\n },\n }\n\n plugins.unshift(typedocPlugin)\n }\n\n // Add CodeBlock highlight plugin for .tsx/.jsx files\n plugins.push(ardoCodeBlockPlugin(pressConfig.markdown))\n\n // Add MDX plugin with Ardo's markdown pipeline\n // Apply default theme if user didn't configure one\n const themeConfig = pressConfig.markdown?.theme ?? defaultMarkdownConfig.theme\n const hasThemeObject = themeConfig && typeof themeConfig === \"object\" && \"light\" in themeConfig\n const lineNumbers = pressConfig.markdown?.lineNumbers || false\n\n // Build shiki options with Ardo's custom line transformer\n // Theme defaults are guaranteed by resolveConfig (defaultMarkdownConfig)\n const shikiOptions = hasThemeObject\n ? {\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false as const,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n : {\n theme: themeConfig as string,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n\n const mdxPlugin = mdx({\n include: /\\.(md|mdx)$/,\n remarkPlugins: [\n remarkFrontmatter,\n [remarkMdxFrontmatter, { name: \"frontmatter\" }],\n remarkGfm,\n remarkCodeMeta,\n ],\n rehypePlugins: [[rehypeShiki, shikiOptions]],\n providerImportSource: \"ardo/mdx-provider\",\n })\n plugins.push(mdxPlugin as Plugin)\n\n // Add React Router Framework plugin (includes React plugin internally)\n const reactRouterPlugin = reactRouter()\n const reactRouterPlugins = (\n Array.isArray(reactRouterPlugin) ? reactRouterPlugin : [reactRouterPlugin]\n ).filter((p): p is Plugin => p != null)\n plugins.push(...reactRouterPlugins)\n\n // Add flatten plugin for GitHub Pages (must run after React Router build)\n if (githubPages) {\n let detectedBase: string | undefined\n\n const flattenPlugin: Plugin = {\n name: \"ardo:flatten-github-pages\",\n enforce: \"post\",\n\n configResolved(config) {\n if (config.base && config.base !== \"/\") {\n detectedBase = config.base\n }\n },\n\n closeBundle() {\n if (flattenExecuted || !detectedBase) {\n return\n }\n\n // Strip leading/trailing slashes to get the directory name\n const baseName = detectedBase.replace(/^\\/|\\/$/g, \"\")\n if (!baseName) return\n\n const buildDir = path.join(process.cwd(), \"build\", \"client\")\n const nestedDir = path.join(buildDir, baseName)\n\n if (!fsSync.existsSync(nestedDir)) {\n return\n }\n\n console.log(`[ardo] Flattening build/client/${baseName}/ to build/client/ for GitHub Pages`)\n copyRecursive(nestedDir, buildDir)\n fsSync.rmSync(nestedDir, { recursive: true, force: true })\n console.log(\"[ardo] Build output flattened successfully.\")\n\n flattenExecuted = true\n },\n }\n\n plugins.push(flattenPlugin)\n }\n\n return plugins\n}\n\nasync function generateSidebar(config: ResolvedConfig, routesDir: string) {\n const { themeConfig } = config\n\n if (themeConfig.sidebar && !Array.isArray(themeConfig.sidebar)) {\n return themeConfig.sidebar\n }\n\n if (themeConfig.sidebar && Array.isArray(themeConfig.sidebar) && themeConfig.sidebar.length > 0) {\n return themeConfig.sidebar\n }\n\n try {\n const sidebar = await scanDirectory(routesDir, routesDir)\n return sidebar\n } catch {\n return []\n }\n}\n\nasync function scanDirectory(\n dir: string,\n rootDir: string\n): Promise<Array<{ text: string; link?: string; items?: unknown[] }>> {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n const items: Array<{ text: string; link?: string; items?: unknown[]; order?: number }> = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.isDirectory()) {\n const children = await scanDirectory(fullPath, rootDir)\n if (children.length > 0) {\n // Check for index.mdx in the directory\n const indexPath = path.join(fullPath, \"index.mdx\")\n let link: string | undefined\n\n try {\n await fs.access(indexPath)\n link = \"/\" + relativePath.replace(/\\\\/g, \"/\")\n } catch {\n // No index.mdx\n }\n\n items.push({\n text: formatTitle(entry.name),\n link,\n items: children,\n })\n }\n } else if (\n (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) &&\n entry.name !== \"index.mdx\" &&\n entry.name !== \"index.md\"\n ) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n const order: number | undefined =\n typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n const link = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\ninterface SearchDoc {\n id: string\n title: string\n content: string\n path: string\n section?: string\n}\n\nasync function generateSearchIndex(routesDir: string): Promise<SearchDoc[]> {\n const docs: SearchDoc[] = []\n\n async function scanForSearch(dir: string, section?: string): Promise<void> {\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Use directory name as section for nested content\n const newSection = section\n ? `${section} > ${formatTitle(entry.name)}`\n : formatTitle(entry.name)\n await scanForSearch(fullPath, newSection)\n } else if (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) {\n const relativePath = path.relative(routesDir, fullPath)\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n\n // Extract frontmatter\n const { data: frontmatter, content: rawContent } = matter(fileContent)\n const ext = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title = frontmatter.title || formatTitle(entry.name.replace(ext, \"\"))\n let content = rawContent\n\n // Clean up content: remove markdown/MDX syntax, keep text\n content = content\n .replace(/```[\\s\\S]*?```/g, \"\") // Remove code blocks\n .replace(/`[^`]+`/g, \"\") // Remove inline code\n .replace(/import\\s+.*?from\\s+['\"].*?['\"]/g, \"\") // Remove imports\n .replace(/<[^>]+>/g, \"\") // Remove JSX tags\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\") // Links to text\n .replace(/[#*_~>]/g, \"\") // Remove markdown symbols\n .replace(/\\n+/g, \" \") // Newlines to spaces\n .replace(/\\s+/g, \" \") // Multiple spaces to single\n .trim()\n .slice(0, 2000) // Limit content size\n\n // Generate path for the route\n const routePath =\n entry.name === \"index.mdx\" || entry.name === \"index.md\"\n ? \"/\" + path.dirname(relativePath).replace(/\\\\/g, \"/\")\n : \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n\n // Skip root index (use \"/\" as path)\n const finalPath = routePath === \"/.\" ? \"/\" : routePath\n\n docs.push({\n id: relativePath,\n title,\n content,\n path: finalPath,\n section,\n })\n }\n }\n } catch (error) {\n console.warn(\n \"[ardo] Failed to scan for search index:\",\n error instanceof Error ? error.message : error\n )\n }\n }\n\n await scanForSearch(routesDir)\n return docs\n}\n\nexport default ardoPlugin\n","import {\n createHighlighter,\n type Highlighter,\n type BundledTheme,\n type ShikiTransformer,\n} from \"shiki\"\nimport type { Root, Element, Text } from \"hast\"\nimport { visit } from \"unist-util-visit\"\nimport type { MarkdownConfig } from \"../config/types\"\n\nexport type ShikiHighlighter = Highlighter\n\n/** Default Ardo themes used when no config is provided */\nconst DEFAULT_THEMES = {\n light: \"github-light-default\" as BundledTheme,\n dark: \"github-dark-default\" as BundledTheme,\n}\n\nlet cachedHighlighter: ShikiHighlighter | undefined\n\n/**\n * Highlights code using Shiki with Ardo's default themes.\n * Creates and caches a highlighter instance for reuse.\n */\nexport async function highlightCode(\n code: string,\n language: string,\n options?: { theme?: MarkdownConfig[\"theme\"] }\n): Promise<string> {\n const themeConfig = options?.theme ?? DEFAULT_THEMES\n\n if (!cachedHighlighter) {\n cachedHighlighter = await createShikiHighlighter({\n theme: themeConfig,\n lineNumbers: false,\n anchor: false,\n toc: { level: [2, 3] },\n })\n }\n\n if (typeof themeConfig === \"string\") {\n return cachedHighlighter.codeToHtml(code, { lang: language, theme: themeConfig })\n }\n\n return cachedHighlighter.codeToHtml(code, {\n lang: language,\n themes: { light: themeConfig.light, dark: themeConfig.dark },\n defaultColor: false,\n })\n}\n\nexport async function createShikiHighlighter(config: MarkdownConfig): Promise<ShikiHighlighter> {\n const themeConfig = config.theme!\n\n const themes: BundledTheme[] =\n typeof themeConfig === \"string\" ? [themeConfig] : [themeConfig.light, themeConfig.dark]\n\n const highlighter = await createHighlighter({\n themes,\n langs: [\n // Web fundamentals\n \"javascript\",\n \"typescript\",\n \"jsx\",\n \"tsx\",\n \"html\",\n \"css\",\n \"scss\",\n\n // Data & config formats\n \"json\",\n \"jsonc\",\n \"yaml\",\n \"toml\",\n \"xml\",\n \"graphql\",\n\n // Markdown & docs\n \"markdown\",\n \"mdx\",\n\n // Shell & DevOps\n \"bash\",\n \"shell\",\n \"dockerfile\",\n\n // General purpose\n \"python\",\n \"rust\",\n \"go\",\n \"sql\",\n \"diff\",\n ],\n })\n\n return highlighter\n}\n\ninterface RehypeShikiOptions {\n highlighter: ShikiHighlighter\n config: MarkdownConfig\n}\n\nexport function rehypeShikiFromHighlighter(options: RehypeShikiOptions) {\n const { highlighter, config } = options\n\n const themeConfig = config.theme!\n\n return function (tree: Root) {\n visit(tree, \"element\", (node: Element, index, parent) => {\n if (\n node.tagName !== \"pre\" ||\n !node.children[0] ||\n (node.children[0] as Element).tagName !== \"code\"\n ) {\n return\n }\n\n const codeNode = node.children[0] as Element\n const className = (codeNode.properties?.className as string[]) || []\n const langClass = className.find((c) => c.startsWith(\"language-\"))\n const lang = langClass ? langClass.replace(\"language-\", \"\") : \"text\"\n\n const codeContent = getTextContent(codeNode)\n\n if (!codeContent.trim()) {\n return\n }\n\n try {\n let html: string\n\n if (typeof themeConfig === \"string\") {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n theme: themeConfig,\n })\n } else {\n html = highlighter.codeToHtml(codeContent, {\n lang,\n themes: {\n light: themeConfig.light,\n dark: themeConfig.dark,\n },\n defaultColor: false,\n })\n }\n\n const metaString = (codeNode.properties?.metastring as string) || \"\"\n const lineNumbers = config.lineNumbers || metaString.includes(\"showLineNumbers\")\n const highlightLines = parseHighlightLines(metaString)\n const title = parseTitle(metaString)\n\n const wrapperHtml = buildCodeBlockHtml(html, {\n lang,\n lineNumbers,\n highlightLines,\n title,\n })\n\n if (parent && typeof index === \"number\") {\n const newNode: Element = {\n type: \"element\",\n tagName: \"div\",\n properties: {\n className: [\"ardo-code-block\"],\n \"data-lang\": lang,\n },\n children: [\n {\n type: \"raw\",\n value: wrapperHtml,\n } as unknown as Element,\n ],\n }\n parent.children[index] = newNode\n }\n } catch {\n // If highlighting fails, leave the node unchanged\n }\n })\n }\n}\n\nfunction getTextContent(node: Element | Text): string {\n if (node.type === \"text\") {\n return node.value\n }\n if (\"children\" in node) {\n return node.children.map((child) => getTextContent(child as Element | Text)).join(\"\")\n }\n return \"\"\n}\n\nfunction parseHighlightLines(meta: string): number[] {\n const match = meta.match(/\\{([\\d,-]+)\\}/)\n if (!match) return []\n\n const ranges = match[1].split(\",\")\n const lines: number[] = []\n\n for (const range of ranges) {\n if (range.includes(\"-\")) {\n const [start, end] = range.split(\"-\").map(Number)\n for (let i = start; i <= end; i++) {\n lines.push(i)\n }\n } else {\n lines.push(Number(range))\n }\n }\n\n return lines\n}\n\nfunction parseTitle(meta: string): string | undefined {\n const match = meta.match(/title=\"([^\"]+)\"/)\n return match ? match[1] : undefined\n}\n\ninterface CodeBlockOptions {\n lang: string\n lineNumbers: boolean\n highlightLines: number[]\n title?: string\n}\n\nfunction buildCodeBlockHtml(shikiHtml: string, options: CodeBlockOptions): string {\n const { lang, lineNumbers, highlightLines, title } = options\n\n let html = \"\"\n\n if (title) {\n html += `<div class=\"ardo-code-title\">${escapeHtml(title)}</div>`\n }\n\n html += `<div class=\"ardo-code-wrapper\" data-lang=\"${lang}\">`\n\n if (lineNumbers || highlightLines.length > 0) {\n const lines = shikiHtml.split(\"\\n\")\n const processedHtml = lines\n .map((line, i) => {\n const lineNum = i + 1\n const isHighlighted = highlightLines.includes(lineNum)\n const classes = [\"ardo-code-line\"]\n if (isHighlighted) classes.push(\"highlighted\")\n\n let prefix = \"\"\n if (lineNumbers) {\n prefix = `<span class=\"ardo-line-number\">${lineNum}</span>`\n }\n\n return `<span class=\"${classes.join(\" \")}\">${prefix}${line}</span>`\n })\n .join(\"\\n\")\n\n html += processedHtml\n } else {\n html += shikiHtml\n }\n\n html += `<button class=\"ardo-copy-button\" data-code=\"${encodeURIComponent(extractCodeFromHtml(shikiHtml))}\">\n <span class=\"ardo-copy-icon\">Copy</span>\n <span class=\"ardo-copied-icon\" style=\"display:none\">Copied!</span>\n </button>`\n\n html += \"</div>\"\n\n return html\n}\n\nfunction extractCodeFromHtml(html: string): string {\n return html\n .replace(/<[^>]+>/g, \"\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&amp;/g, \"&\")\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n}\n\nfunction 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\n/**\n * Remark plugin that extracts code fence meta info and stores it as HAST\n * data attributes before MDX compilation can corrupt it.\n *\n * MDX treats `{...}` in code fence meta as JSX expressions, which corrupts\n * both the meta and the code content. This plugin strips the meta and\n * stores parsed info as `data-ardo-*` attributes that survive MDX.\n */\nexport function remarkCodeMeta() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return function (tree: any) {\n visit(tree, \"code\", (node: { meta?: string | null; data?: Record<string, unknown> }) => {\n if (!node.meta) return\n\n const meta = node.meta\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties as Record<string, unknown>) || {}\n\n // Preserve meta as metastring property on the <code> HAST element.\n // @shikijs/rehype reads head.properties.metastring and passes it\n // to Shiki as meta.__raw, which ardoLineTransformer reads.\n hProperties.metastring = meta\n data.hProperties = hProperties\n\n // Strip meta from the MDAST node to prevent MDX from\n // misinterpreting {expressions} like {2,4-5} as JSX\n node.meta = null\n })\n }\n}\n\n/**\n * Shiki transformer that adds Ardo-specific line classes, highlighting,\n * line numbers, and title attributes to code blocks.\n *\n * Used with @shikijs/rehype in the MDX pipeline where proper HAST nodes\n * are required (raw HTML nodes cause \"Cannot handle unknown node `raw`\" errors).\n */\ninterface ArdoLineTransformerOptions {\n globalLineNumbers?: boolean\n}\n\nexport function ardoLineTransformer(options: ArdoLineTransformerOptions = {}): ShikiTransformer {\n let highlightLines: number[] = []\n let showLineNumbers = false\n let metaRaw = \"\"\n\n return {\n name: \"ardo:lines\",\n // preprocess runs BEFORE line() hooks, so state is ready for line()\n preprocess(_code, shikiOptions) {\n metaRaw = (shikiOptions.meta?.__raw as string) || \"\"\n highlightLines = parseHighlightLines(metaRaw)\n showLineNumbers = options.globalLineNumbers || metaRaw.includes(\"showLineNumbers\")\n },\n // pre runs AFTER line() — used only for node property modifications\n pre(node) {\n node.properties = node.properties || {}\n const title = parseTitle(metaRaw)\n if (title) {\n node.properties[\"data-title\"] = title\n }\n const labelMatch = metaRaw.match(/\\[([^\\]]+)\\]/)\n if (labelMatch) {\n node.properties[\"data-label\"] = labelMatch[1]\n }\n },\n line(node, line) {\n const currentClass = (node.properties?.class as string) || \"\"\n const classes = currentClass ? currentClass.split(\" \") : []\n classes.push(\"ardo-code-line\")\n\n if (highlightLines.includes(line)) {\n classes.push(\"highlighted\")\n }\n\n node.properties = node.properties || {}\n node.properties.class = classes.join(\" \")\n\n if (showLineNumbers) {\n node.children.unshift({\n type: \"element\",\n tagName: \"span\",\n properties: { class: \"ardo-line-number\" },\n children: [{ type: \"text\", value: String(line) }],\n } as Element)\n }\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport fs from \"fs/promises\"\nimport fsSync from \"fs\"\nimport path from \"path\"\n\nexport interface ArdoRoutesPluginOptions {\n /** Directory where routes are located (default: \"./app/routes\") */\n routesDir?: string\n}\n\ninterface RouteInfo {\n /** URL path (e.g., \"/guide/getting-started\") */\n path: string\n /** File path relative to app directory (e.g., \"routes/guide/getting-started.mdx\") */\n file: string\n /** True if this is an index route */\n isIndex?: boolean\n}\n\n/**\n * Vite plugin that generates routes.ts for React Router Framework Mode.\n * Scans app/routes for .mdx and .tsx files and generates the route configuration.\n */\nexport function ardoRoutesPlugin(options: ArdoRoutesPluginOptions = {}): Plugin {\n let routesDir: string\n let appDir: string\n let routesFilePath: string\n\n function scanRoutesSync(dir: string, rootDir: string): RouteInfo[] {\n const routes: RouteInfo[] = []\n\n try {\n const entries = fsSync.readdirSync(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively scan subdirectories\n const children = scanRoutesSync(fullPath, rootDir)\n routes.push(...children)\n } else if (\n entry.name.endsWith(\".mdx\") ||\n entry.name.endsWith(\".md\") ||\n entry.name.endsWith(\".tsx\")\n ) {\n // Skip special files\n if (entry.name === \"root.tsx\" || entry.name.startsWith(\"_\")) {\n continue\n }\n\n const relativePath = path.relative(rootDir, fullPath)\n const ext = entry.name.endsWith(\".mdx\")\n ? \".mdx\"\n : entry.name.endsWith(\".md\")\n ? \".md\"\n : \".tsx\"\n const baseName = entry.name.replace(ext, \"\")\n\n // Calculate URL path\n let urlPath: string\n if (baseName === \"index\" || baseName === \"home\") {\n // Index route - use parent directory path\n const parentDir = path.dirname(relativePath)\n urlPath = parentDir === \".\" ? \"/\" : \"/\" + parentDir.replace(/\\\\/g, \"/\")\n } else {\n // Regular route\n urlPath = \"/\" + relativePath.replace(ext, \"\").replace(/\\\\/g, \"/\")\n }\n\n // Handle dynamic segments ($param -> :param)\n urlPath = urlPath.replace(/\\$(\\w+)/g, \":$1\")\n\n routes.push({\n path: urlPath,\n file: \"routes/\" + relativePath.replace(/\\\\/g, \"/\"),\n isIndex: baseName === \"index\" || baseName === \"home\",\n })\n }\n }\n } catch {\n // Directory may not exist yet\n }\n\n return routes\n }\n\n function generateRoutesFile(routes: RouteInfo[]): string {\n // Sort routes: index routes first, then alphabetically\n const sortedRoutes = [...routes].sort((a, b) => {\n if (a.path === \"/\" && b.path !== \"/\") return -1\n if (b.path === \"/\" && a.path !== \"/\") return 1\n if (a.isIndex && !b.isIndex) return -1\n if (b.isIndex && !a.isIndex) return 1\n return a.path.localeCompare(b.path)\n })\n\n const entries = sortedRoutes.map((r) => {\n if (r.path === \"/\") {\n return ` index(\"${r.file}\"),`\n }\n // Remove leading slash for route path\n const routePath = r.path.substring(1)\n return ` route(\"${routePath}\", \"${r.file}\"),`\n })\n\n return `// AUTO-GENERATED by Ardo - Do not edit manually\n\nimport { type RouteConfig, route, index } from \"@react-router/dev/routes\"\n\nexport default [\n${entries.join(\"\\n\")}\n] satisfies RouteConfig\n`\n }\n\n function writeRoutesFileSync(): void {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = fsSync.readFileSync(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n fsSync.mkdirSync(appDir, { recursive: true })\n fsSync.writeFileSync(routesFilePath, content, \"utf-8\")\n console.log(`[ardo] Generated routes.ts with ${routes.length} routes`)\n }\n\n async function writeRoutesFile(): Promise<void> {\n const routes = scanRoutesSync(routesDir, routesDir)\n\n // Skip if no routes found (directory might not exist yet)\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n\n // Only write if content changed\n try {\n const existing = await fs.readFile(routesFilePath, \"utf-8\")\n if (existing === content) {\n return\n }\n } catch {\n // File doesn't exist yet\n }\n\n // Ensure app directory exists\n await fs.mkdir(appDir, { recursive: true })\n await fs.writeFile(routesFilePath, content, \"utf-8\")\n }\n\n return {\n name: \"ardo:routes\",\n enforce: \"pre\",\n\n config(userConfig) {\n const root = userConfig.root || process.cwd()\n appDir = path.join(root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n\n // Generate routes synchronously during config phase\n // React Router needs routes.ts to exist before it starts\n try {\n writeRoutesFileSync()\n } catch (err) {\n console.warn(\"[ardo] Could not generate routes.ts in config phase:\", err)\n }\n },\n\n configResolved(config) {\n // Update paths if not set in config\n if (!appDir) {\n appDir = path.join(config.root, \"app\")\n routesDir = options.routesDir || path.join(appDir, \"routes\")\n routesFilePath = path.join(appDir, \"routes.ts\")\n }\n },\n\n async buildStart() {\n // Re-generate routes in buildStart for async support\n await writeRoutesFile()\n },\n\n configureServer(server) {\n // Watch for changes in routes directory\n server.watcher.add(routesDir)\n\n const handleChange = async (changedPath: string) => {\n if (\n changedPath.startsWith(routesDir) &&\n (changedPath.endsWith(\".mdx\") ||\n changedPath.endsWith(\".md\") ||\n changedPath.endsWith(\".tsx\"))\n ) {\n await writeRoutesFile()\n }\n }\n\n server.watcher.on(\"add\", handleChange)\n server.watcher.on(\"unlink\", handleChange)\n },\n }\n}\n","import type { Plugin } from \"vite\"\nimport type { MarkdownConfig } from \"../config/types\"\nimport { highlightCode } from \"../markdown/shiki\"\n\n/**\n * Strips leading/trailing blank lines and removes common leading whitespace.\n * Same logic as the runtime outdent in CodeBlock.tsx.\n */\nfunction outdent(text: string): string {\n const trimmed = text.replace(/^\\n+/, \"\").replace(/\\n\\s*$/, \"\")\n const lines = trimmed.split(\"\\n\")\n\n const indent = lines.reduce((min, line) => {\n if (line.trim().length === 0) return min\n const match = line.match(/^(\\s*)/)\n return match ? Math.min(min, match[1].length) : min\n }, Infinity)\n\n if (indent === 0 || indent === Infinity) return trimmed\n return lines.map((line) => line.slice(indent)).join(\"\\n\")\n}\n\n/**\n * Finds self-closing `<CodeBlock ... />` tags by scanning for balanced\n * quotes and braces. A simple `[^>]` regex fails when prop values contain\n * `>` characters (e.g. `code={'<Tip>Hello</Tip>'}`).\n */\nfunction findSelfClosingCodeBlocks(\n source: string\n): Array<{ fullMatch: string; propsStr: string; index: number }> {\n const results: Array<{ fullMatch: string; propsStr: string; index: number }> = []\n const tag = \"<CodeBlock\"\n let searchFrom = 0\n\n while (true) {\n const start = source.indexOf(tag, searchFrom)\n if (start === -1) break\n\n // Char after tag name must be whitespace (not > or /)\n const afterTag = start + tag.length\n if (afterTag >= source.length || !/\\s/.test(source[afterTag])) {\n searchFrom = afterTag\n continue\n }\n\n // Scan forward, skipping quoted strings and balanced braces\n let i = afterTag\n let depth = 0\n let inSingle = false\n let inDouble = false\n let inTemplate = false\n let found = false\n\n while (i < source.length) {\n const ch = source[i]\n\n // Handle escape sequences inside strings\n if ((inSingle || inDouble || inTemplate) && ch === \"\\\\\") {\n i += 2\n continue\n }\n\n if (inSingle) {\n if (ch === \"'\") inSingle = false\n i++\n continue\n }\n if (inDouble) {\n if (ch === '\"') inDouble = false\n i++\n continue\n }\n if (inTemplate) {\n if (ch === \"`\") inTemplate = false\n i++\n continue\n }\n\n if (ch === \"'\") {\n inSingle = true\n i++\n continue\n }\n if (ch === '\"') {\n inDouble = true\n i++\n continue\n }\n if (ch === \"`\") {\n inTemplate = true\n i++\n continue\n }\n if (ch === \"{\") {\n depth++\n i++\n continue\n }\n if (ch === \"}\") {\n depth--\n i++\n continue\n }\n\n // Look for /> at depth 0\n if (depth === 0 && ch === \"/\" && i + 1 < source.length && source[i + 1] === \">\") {\n const fullMatch = source.substring(start, i + 2)\n const propsStr = source.substring(afterTag, i).trim()\n results.push({ fullMatch, propsStr, index: start })\n found = true\n searchFrom = i + 2\n break\n }\n\n // If we hit > without / at depth 0, this is an opening tag, not self-closing\n if (depth === 0 && ch === \">\") {\n searchFrom = i + 1\n found = true\n break\n }\n\n i++\n }\n\n if (!found) break\n }\n\n return results\n}\n\n/**\n * Vite plugin that pre-highlights CodeBlock components at build time.\n *\n * Runs before the JSX parser, so children can contain arbitrary code\n * (including `<`, `{`, etc.) without causing syntax errors.\n *\n * Supports three patterns:\n * 1. `<CodeBlock code=\"...\" language=\"...\" />` — code prop\n * 2. `<CodeBlock language=\"...\">{\\`...\\`}</CodeBlock>` — template literal children\n * 3. `<CodeBlock language=\"...\">raw code here</CodeBlock>` — plain text children\n *\n * All patterns are rewritten to a self-closing tag with pre-rendered\n * Shiki HTML before the JSX parser ever sees them.\n */\nexport function ardoCodeBlockPlugin(markdownConfig?: MarkdownConfig): Plugin {\n return {\n name: \"ardo:codeblock-highlight\",\n enforce: \"pre\",\n\n async transform(code, id) {\n if (!/\\.[jt]sx$/.test(id)) return\n if (!code.includes(\"CodeBlock\")) return\n if (id.includes(\"node_modules\")) return\n\n let result = code\n let offset = 0\n\n // Pattern 1: Self-closing <CodeBlock code=\"...\" language=\"...\" />\n // Use a scanner instead of regex because [^>] fails when prop values\n // contain > characters (e.g. code={'<Tip>Hello</Tip>'}).\n const propMatches = findSelfClosingCodeBlocks(code)\n\n for (const match of propMatches) {\n const { fullMatch, propsStr } = match\n\n const codeMatch =\n propsStr.match(/\\bcode=\"((?:[^\"\\\\]|\\\\.)*)\"/s) ||\n propsStr.match(/\\bcode=\\{\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\}/s) ||\n propsStr.match(/\\bcode=\\{\\s*'((?:[^'\\\\]|\\\\.)*)'\\s*\\}/s)\n if (!codeMatch) continue\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n const codeContent = codeMatch[1]\n .replace(/\\\\n/g, \"\\n\")\n .replace(/\\\\\"/g, '\"')\n .replace(/\\\\\\\\/g, \"\\\\\")\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const newPropsStr = `__html={${escapedHtml}} ` + propsStr\n const newFullMatch = fullMatch.replace(propsStr, newPropsStr)\n\n result =\n result.slice(0, match.index + offset) +\n newFullMatch +\n result.slice(match.index + offset + fullMatch.length)\n\n offset += newFullMatch.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n // Pattern 2+3: <CodeBlock language=\"...\">...children...</CodeBlock>\n // Matches both template literal children {`...`} and raw text children.\n // Since this runs before JSX parsing, raw text with <, {, etc. is fine.\n const childrenRegex = /<CodeBlock\\s+([^>]*?)>([\\s\\S]*?)<\\/CodeBlock>/g\n\n offset = result.length - code.length\n let regexMatch: RegExpExecArray | null\n while ((regexMatch = childrenRegex.exec(code)) !== null) {\n const fullMatch = regexMatch[0]\n const propsStr = regexMatch[1]\n let rawChildren = regexMatch[2]\n\n const langMatch =\n propsStr.match(/\\blanguage=\"([^\"]*)\"/) ||\n propsStr.match(/\\blanguage=\\{\"([^\"]*)\"\\}/) ||\n propsStr.match(/\\blanguage=\\{'([^']*)'\\}/)\n if (!langMatch) continue\n\n if (propsStr.includes(\"__html\")) continue\n\n // Unwrap template literal braces if present: {`...`} → ...\n const templateMatch = rawChildren.match(/^\\s*\\{`([\\s\\S]*)`\\}\\s*$/)\n if (templateMatch) {\n rawChildren = templateMatch[1]\n }\n\n const codeContent = outdent(rawChildren)\n const language = langMatch[1]\n\n try {\n const html = await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n\n const escapedHtml = JSON.stringify(html)\n const escapedCode = JSON.stringify(codeContent)\n const newTag = `<CodeBlock __html={${escapedHtml}} code={${escapedCode}} ${propsStr} />`\n\n result =\n result.slice(0, regexMatch.index + offset) +\n newTag +\n result.slice(regexMatch.index + offset + fullMatch.length)\n\n offset += newTag.length - fullMatch.length\n } catch {\n // If highlighting fails, leave unchanged\n }\n }\n\n if (result !== code) {\n return { code: result, map: null }\n }\n },\n }\n}\n","import fs from \"fs/promises\"\nimport path from \"path\"\nimport type { PageData, PageFrontmatter, TOCItem, ResolvedConfig } from \"../config/types\"\nimport { transformMarkdown } from \"../markdown/pipeline\"\n\nexport interface LoadDocOptions {\n slug: string\n contentDir: string\n config: ResolvedConfig\n}\n\nexport interface LoadDocResult {\n content: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n filePath: string\n relativePath: string\n lastUpdated?: number\n}\n\nexport async function loadDoc(options: LoadDocOptions): Promise<LoadDocResult | null> {\n const { slug, contentDir, config } = options\n\n const possiblePaths = [\n path.join(contentDir, `${slug}.md`),\n path.join(contentDir, slug, \"index.md\"),\n ]\n\n let filePath: string | null = null\n let fileContent: string | null = null\n\n for (const tryPath of possiblePaths) {\n try {\n fileContent = await fs.readFile(tryPath, \"utf-8\")\n filePath = tryPath\n break\n } catch {\n continue\n }\n }\n\n if (!filePath || !fileContent) {\n return null\n }\n\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, filePath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(filePath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n return {\n content: result.html,\n frontmatter: result.frontmatter,\n toc: result.toc,\n filePath,\n relativePath,\n lastUpdated,\n }\n}\n\nexport async function loadAllDocs(contentDir: string, config: ResolvedConfig): Promise<PageData[]> {\n const docs: PageData[] = []\n\n async function scanDir(dir: string) {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n await scanDir(fullPath)\n } else if (entry.name.endsWith(\".md\")) {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, fullPath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(fullPath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n docs.push({\n title: result.frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\")),\n description: result.frontmatter.description,\n frontmatter: result.frontmatter,\n content: result.html,\n toc: result.toc,\n filePath: fullPath,\n relativePath,\n lastUpdated,\n })\n }\n }\n }\n\n await scanDir(contentDir)\n return docs\n}\n\nfunction formatTitle(name: string): string {\n return name.replace(/[-_]/g, \" \").replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nexport function getSlugFromPath(relativePath: string): string {\n return relativePath\n .replace(/\\.md$/, \"\")\n .replace(/\\/index$/, \"\")\n .replace(/\\\\/g, \"/\")\n}\n\nexport function getPageDataForRoute(docs: PageData[], slug: string): PageData | undefined {\n return docs.find((doc) => {\n const docSlug = getSlugFromPath(doc.relativePath)\n return docSlug === slug || docSlug === `${slug}/index`\n })\n}\n","import { unified } from \"unified\"\nimport remarkParse from \"remark-parse\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkRehype from \"remark-rehype\"\nimport rehypeStringify from \"rehype-stringify\"\nimport matter from \"gray-matter\"\nimport type { MarkdownConfig, TOCItem, PageFrontmatter } from \"../config/types\"\nimport { remarkExtractToc, type TocExtraction } from \"./toc\"\nimport { createShikiHighlighter, rehypeShikiFromHighlighter, type ShikiHighlighter } from \"./shiki\"\nimport { rehypeLinks } from \"./links\"\n\nexport interface TransformResult {\n html: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n}\n\nexport interface TransformOptions {\n basePath?: string\n highlighter?: ShikiHighlighter\n}\n\nexport async function transformMarkdown(\n content: string,\n config: MarkdownConfig,\n options: TransformOptions = {}\n): Promise<TransformResult> {\n const { data: frontmatter, content: markdownContent } = matter(content)\n const { basePath = \"/\", highlighter: providedHighlighter } = options\n\n const tocExtraction: TocExtraction = { toc: [] }\n const highlighter = providedHighlighter ?? (await createShikiHighlighter(config))\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, [\"yaml\"])\n .use(remarkGfm)\n .use(remarkExtractToc, { tocExtraction, levels: config.toc?.level ?? [2, 3] })\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeShikiFromHighlighter, { highlighter, config })\n .use(rehypeLinks, { basePath })\n .use(rehypeStringify, { allowDangerousHtml: true })\n\n if (config.remarkPlugins) {\n for (const plugin of config.remarkPlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n if (config.rehypePlugins) {\n for (const plugin of config.rehypePlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n const result = await processor.process(markdownContent)\n\n return {\n html: String(result),\n frontmatter: frontmatter as PageFrontmatter,\n toc: tocExtraction.toc,\n }\n}\n\nexport async function transformMarkdownToReact(\n content: string,\n config: MarkdownConfig\n): Promise<TransformResult> {\n return transformMarkdown(content, config)\n}\n","import type { Root, Heading } from \"mdast\"\nimport { visit } from \"unist-util-visit\"\nimport type { TOCItem } from \"../config/types\"\n\nexport interface TocExtraction {\n toc: TOCItem[]\n}\n\ninterface TocOptions {\n tocExtraction: TocExtraction\n levels: [number, number]\n}\n\nexport function remarkExtractToc(options: TocOptions) {\n const { tocExtraction, levels } = options\n const [minLevel, maxLevel] = levels\n\n return function (tree: Root) {\n const headings: Array<{ text: string; level: number; id: string }> = []\n let headingIndex = 0\n\n visit(tree, \"heading\", (node: Heading) => {\n if (node.depth < minLevel || node.depth > maxLevel) {\n return\n }\n\n const text = getHeadingText(node)\n const slug = slugify(text)\n const id = slug || `heading-${headingIndex}`\n headingIndex++\n\n headings.push({\n text,\n level: node.depth,\n id,\n })\n\n // Add id to the heading node for anchor links\n const data = node.data || (node.data = {})\n const hProperties = (data.hProperties || (data.hProperties = {})) as Record<string, string>\n hProperties.id = id\n })\n\n tocExtraction.toc = buildTocTree(headings, minLevel)\n }\n}\n\nfunction getHeadingText(node: Heading): string {\n const textParts: string[] = []\n\n function extractText(child: unknown) {\n if (!child || typeof child !== \"object\") return\n\n const typedChild = child as { type?: string; value?: string; children?: unknown[] }\n\n if (typedChild.type === \"text\") {\n textParts.push(typedChild.value || \"\")\n } else if (typedChild.type === \"inlineCode\") {\n textParts.push(typedChild.value || \"\")\n } else if (Array.isArray(typedChild.children)) {\n typedChild.children.forEach(extractText)\n }\n }\n\n node.children.forEach(extractText)\n return textParts.join(\"\")\n}\n\nfunction slugify(text: string): string {\n return text\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n}\n\nfunction buildTocTree(\n headings: Array<{ text: string; level: number; id: string }>,\n _minLevel: number\n): TOCItem[] {\n const result: TOCItem[] = []\n const stack: Array<{ item: TOCItem; level: number }> = []\n\n for (const heading of headings) {\n const item: TOCItem = {\n id: heading.id,\n text: heading.text,\n level: heading.level,\n }\n\n while (stack.length > 0 && stack[stack.length - 1].level >= heading.level) {\n stack.pop()\n }\n\n if (stack.length === 0) {\n result.push(item)\n } else {\n const parent = stack[stack.length - 1].item\n if (!parent.children) {\n parent.children = []\n }\n parent.children.push(item)\n }\n\n stack.push({ item, level: heading.level })\n }\n\n return result\n}\n\nexport function flattenToc(toc: TOCItem[]): TOCItem[] {\n const result: TOCItem[] = []\n\n function flatten(items: TOCItem[]) {\n for (const item of items) {\n result.push(item)\n if (item.children) {\n flatten(item.children)\n }\n }\n }\n\n flatten(toc)\n return result\n}\n","import { visit } from \"unist-util-visit\"\nimport type { Root, Element } from \"hast\"\n\nexport interface RehypeLinkOptions {\n basePath: string\n}\n\n/**\n * Rehype plugin that rewrites internal links to include the basePath.\n * This is needed for static sites deployed to subpaths (e.g., GitHub Pages).\n */\nexport function rehypeLinks(options: RehypeLinkOptions) {\n const { basePath } = options\n\n // Normalize basePath: ensure it starts with / and doesn't end with /\n const normalizedBase = basePath === \"/\" ? \"\" : basePath.replace(/\\/$/, \"\")\n\n return (tree: Root) => {\n if (!normalizedBase) {\n // No basePath to add\n return\n }\n\n visit(tree, \"element\", (node: Element) => {\n if (node.tagName === \"a\") {\n const href = node.properties?.href\n\n if (typeof href === \"string\") {\n // Only rewrite internal links that start with /\n // Don't rewrite: external URLs, anchors, relative paths, or already prefixed paths\n if (href.startsWith(\"/\") && !href.startsWith(\"//\") && !href.startsWith(normalizedBase)) {\n node.properties = node.properties || {}\n node.properties.href = normalizedBase + href\n }\n }\n }\n })\n }\n}\n","import fs from \"fs/promises\"\nimport type { Dirent } from \"fs\"\nimport path from \"path\"\nimport matter from \"gray-matter\"\nimport type { SidebarItem, ResolvedConfig } from \"../config/types\"\n\nexport interface SidebarGenerationOptions {\n contentDir: string\n basePath: string\n config: ResolvedConfig\n}\n\nexport async function generateSidebar(options: SidebarGenerationOptions): Promise<SidebarItem[]> {\n const { contentDir, basePath, config } = options\n\n const configSidebar = config.themeConfig.sidebar\n\n if (configSidebar) {\n if (Array.isArray(configSidebar) && configSidebar.length > 0) {\n return configSidebar\n }\n if (!Array.isArray(configSidebar)) {\n return []\n }\n }\n\n return await scanDirectoryForSidebar(contentDir, contentDir, basePath)\n}\n\nasync function scanDirectoryForSidebar(\n dir: string,\n rootDir: string,\n _basePath: string\n): Promise<SidebarItem[]> {\n let entries: Dirent[]\n\n try {\n entries = (await fs.readdir(dir, { withFileTypes: true })) as Dirent[]\n } catch {\n return []\n }\n\n interface SidebarItemWithOrder extends SidebarItem {\n order?: number\n }\n\n const items: SidebarItemWithOrder[] = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.name.startsWith(\".\") || entry.name.startsWith(\"_\")) {\n continue\n }\n\n if (entry.isDirectory()) {\n const children = await scanDirectoryForSidebar(fullPath, rootDir, _basePath)\n\n if (children.length > 0) {\n const indexPath = path.join(fullPath, \"index.md\")\n let link: string | undefined\n let title = formatTitle(entry.name)\n let order: number | undefined\n\n try {\n const indexContent = await fs.readFile(indexPath, \"utf-8\")\n const { data: frontmatter } = matter(indexContent)\n\n if (frontmatter.title) {\n title = frontmatter.title\n }\n if (typeof frontmatter.order === \"number\") {\n order = frontmatter.order\n }\n\n // Don't include basePath - React Router handles it automatically\n link = normalizePath(relativePath)\n } catch {\n // No index.md file\n }\n\n items.push({\n text: title,\n link,\n collapsed: false,\n items: children,\n order,\n })\n }\n } else if (entry.name.endsWith(\".md\") && entry.name !== \"index.md\") {\n const fileContent = await fs.readFile(fullPath, \"utf-8\")\n const { data: frontmatter } = matter(fileContent)\n\n if (frontmatter.sidebar === false) {\n continue\n }\n\n const title = frontmatter.title || formatTitle(entry.name.replace(/\\.md$/, \"\"))\n const order = typeof frontmatter.order === \"number\" ? frontmatter.order : undefined\n\n // Don't include basePath - React Router handles it automatically\n const link = normalizePath(relativePath.replace(/\\.md$/, \"\"))\n\n items.push({\n text: title,\n link,\n order,\n })\n }\n }\n\n items.sort((a, b) => {\n if (a.order !== undefined && b.order !== undefined) {\n return a.order - b.order\n }\n if (a.order !== undefined) return -1\n if (b.order !== undefined) return 1\n return a.text.localeCompare(b.text)\n })\n\n return items.map(({ order: _order, ...item }) => item)\n}\n\nfunction formatTitle(name: string): string {\n return name\n .replace(/^\\d+-/, \"\")\n .replace(/[-_]/g, \" \")\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nfunction normalizePath(p: string): string {\n return \"/\" + p.replace(/\\\\/g, \"/\").replace(/^\\/+/, \"\")\n}\n"],"mappings":";;;;;;;;;AAKA,SAAS,mBAAmB;AAC5B,OAAO,SAAS;AAChB,OAAO,uBAAuB;AAC9B,OAAO,0BAA0B;AACjC,OAAO,eAAe;AACtB,OAAO,iBAAiB;;;ACVxB;AAAA,EACE;AAAA,OAIK;AAEP,SAAS,aAAa;AAMtB,IAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AACR;AAEA,IAAI;AAMJ,eAAsB,cACpB,MACA,UACA,SACiB;AACjB,QAAM,cAAc,SAAS,SAAS;AAEtC,MAAI,CAAC,mBAAmB;AACtB,wBAAoB,MAAM,uBAAuB;AAAA,MAC/C,OAAO;AAAA,MACP,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;AAAA,IACvB,CAAC;AAAA,EACH;AAEA,MAAI,OAAO,gBAAgB,UAAU;AACnC,WAAO,kBAAkB,WAAW,MAAM,EAAE,MAAM,UAAU,OAAO,YAAY,CAAC;AAAA,EAClF;AAEA,SAAO,kBA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AU,OAAW,QAAO;AAClC,WAAO,EAAE,KAAK,cAAc,EAAE,IAAI;AAAA,EACpC,CAAC;AAED,SAAO,MAAM,IAAI,CAAC,EAAE,OAAO,QAAQ,GAAG,KAAK,MAAM,IAAI;AACvD;AAEA,SAASA,aAAY,MAAsB;AACzC,SAAO,KACJ,QAAQ,SAAS,EAAE,EACnB,QAAQ,SAAS,GAAG,EACpB,QAAQ,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC;AAC5C;AAEA,SAAS,cAAc,GAAmB;AACxC,SAAO,MAAM,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,EAAE;AACvD;","names":["fs","fsSync","path","path","fsSync","fs","fs","path","remarkGfm","remarkFrontmatter","matter","visit","visit","matter","remarkFrontmatter","remarkGfm","path","fs","formatTitle","fs","path","matter","generateSidebar","formatTitle"]}
1
+ {"version":3,"file":"index.js","names":["isRecord","isRecord","getHeadingText","slugify","formatTitle","readDirectoryEntries","formatTitle","readFrontmatter","fs","fs","name","isIdentifierName","fs","formatTitle","generateSidebar","generateSidebar"],"sources":["../../src/markdown/links.ts","../../src/markdown/shiki-theme.ts","../../src/ui/components/code-block-classes.ts","../../src/markdown/shiki-html.ts","../../src/markdown/shiki-meta.ts","../../src/markdown/shiki-rehype.ts","../../src/markdown/shiki-transformer.ts","../../src/markdown/shiki.ts","../../src/markdown/toc.ts","../../src/markdown/pipeline.ts","../../src/runtime/loader.ts","../../src/runtime/sidebar.ts","../../src/vite/codeblock-scan.ts","../../src/vite/codeblock-transform.ts","../../src/vite/codeblock-plugin.ts","../../src/vite/git-utils.ts","../../src/vite/flatten-plugin.ts","../../../../node_modules/.pnpm/estree-util-value-to-estree@3.5.0/node_modules/estree-util-value-to-estree/dist/estree-util-value-to-estree.js","../../../../node_modules/.pnpm/estree-util-is-identifier-name@3.0.0/node_modules/estree-util-is-identifier-name/lib/index.js","../../../../node_modules/.pnpm/devlop@1.1.0/node_modules/devlop/lib/default.js","../../../../node_modules/.pnpm/estree-util-scope@1.0.0/node_modules/estree-util-scope/lib/index.js","../../../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/walker.js","../../../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/sync.js","../../../../node_modules/.pnpm/estree-walker@3.0.3/node_modules/estree-walker/src/index.js","../../../../node_modules/.pnpm/unist-util-mdx-define@1.1.2/node_modules/unist-util-mdx-define/dist/unist-util-mdx-define.js","../../src/markdown/remark-mdx-toc.ts","../../src/vite/recma-wrap-export.ts","../../src/vite/mdx-plugin.ts","../../src/vite/project-meta.ts","../../src/vite/routes-core.ts","../../src/vite/routes-plugin.ts","../../src/vite/search-index.ts","../../src/vite/sidebar-index.ts","../../src/vite/plugin.ts"],"sourcesContent":["import type { Element, Root } from \"hast\"\n\nimport { visit } from \"unist-util-visit\"\n\nexport interface RehypeLinkOptions {\n basePath: string\n}\n\n/**\n * Rehype plugin that rewrites internal links to include the basePath.\n * This is needed for static sites deployed to subpaths (e.g., GitHub Pages).\n */\nexport function rehypeLinks(options: RehypeLinkOptions) {\n const { basePath } = options\n\n // Normalize basePath: ensure it starts with / and doesn't end with /\n const normalizedBase = basePath === \"/\" ? \"\" : basePath.replace(/\\/$/, \"\")\n\n return (tree: Root) => {\n if (!normalizedBase) {\n // No basePath to add\n return\n }\n\n visit(tree, \"element\", (node: Element) => {\n if (node.tagName !== \"a\") {\n return\n }\n\n const href = node.properties.href\n\n // Only rewrite internal links that start with /\n // Don't rewrite: external URLs, anchors, relative paths, or already prefixed paths\n if (\n typeof href === \"string\" &&\n href.startsWith(\"/\") &&\n !href.startsWith(\"//\") &&\n !href.startsWith(normalizedBase)\n ) {\n node.properties.href = normalizedBase + href\n }\n })\n }\n}\n","import type { BundledTheme, Highlighter } from \"shiki\"\n\nimport type { MarkdownConfig } from \"../config/types\"\n\n/** Default Ardo themes used when no config is provided */\nexport const DEFAULT_THEMES = {\n light: \"github-light-default\" as BundledTheme,\n dark: \"github-dark-default\" as BundledTheme,\n}\n\nexport function resolveThemeConfig(\n theme: MarkdownConfig[\"theme\"] | undefined\n): MarkdownConfig[\"theme\"] {\n return theme ?? DEFAULT_THEMES\n}\n\nexport function getBundledThemes(themeConfig: MarkdownConfig[\"theme\"]): BundledTheme[] {\n if (themeConfig == null) return [DEFAULT_THEMES.light, DEFAULT_THEMES.dark]\n return typeof themeConfig === \"string\" ? [themeConfig] : [themeConfig.light, themeConfig.dark]\n}\n\nexport function highlightWithTheme(params: {\n code: string\n highlighter: Highlighter\n language: string\n themeConfig: MarkdownConfig[\"theme\"]\n}): string {\n const { code, highlighter, language, themeConfig } = params\n\n const resolved = themeConfig ?? DEFAULT_THEMES\n\n if (typeof resolved === \"string\") {\n return highlighter.codeToHtml(code, { lang: language, theme: resolved })\n }\n\n return highlighter.codeToHtml(code, {\n defaultColor: false,\n lang: language,\n themes: { dark: resolved.dark, light: resolved.light },\n })\n}\n","export const shikiContainerClassName = \"ardo-shiki\"\n","interface CodeBlockOptions {\n highlightLines: number[]\n lang: string\n lineNumbers: boolean\n title?: string\n}\n\nexport function buildCodeBlockHtml(shikiHtml: string, options: CodeBlockOptions): string {\n const titleHtml = renderTitle(options.title)\n const codeHtml = renderCodeLines({\n highlightLines: options.highlightLines,\n lineNumbers: options.lineNumbers,\n shikiHtml,\n })\n const copyButton = renderCopyButton(shikiHtml)\n\n return `${titleHtml}<div data-lang=\"${options.lang}\">${codeHtml}${copyButton}</div>`\n}\n\nfunction renderTitle(title: string | undefined): string {\n if (title == null || title.length === 0) {\n return \"\"\n }\n\n return `<div data-title>${escapeHtml(title)}</div>`\n}\n\nfunction renderCodeLines(params: {\n highlightLines: number[]\n lineNumbers: boolean\n shikiHtml: string\n}): string {\n const { highlightLines, lineNumbers, shikiHtml } = params\n if (!lineNumbers && highlightLines.length === 0) {\n return shikiHtml\n }\n\n return shikiHtml\n .split(\"\\n\")\n .map((lineHtml, index) =>\n renderSingleCodeLine({\n highlightLines,\n lineHtml,\n lineNumber: index + 1,\n lineNumbers,\n })\n )\n .join(\"\\n\")\n}\n\nfunction renderSingleCodeLine(params: {\n highlightLines: number[]\n lineHtml: string\n lineNumber: number\n lineNumbers: boolean\n}): string {\n const { highlightLines, lineHtml, lineNumber, lineNumbers } = params\n const isHighlighted = highlightLines.includes(lineNumber)\n const className = isHighlighted ? \"line highlighted\" : \"line\"\n const lineNumberAttribute = lineNumbers ? ` data-ln=\"${lineNumber}\"` : \"\"\n\n return `<span class=\"${className}\"${lineNumberAttribute}>${lineHtml}</span>`\n}\n\nfunction renderCopyButton(shikiHtml: string): string {\n const code = encodeURIComponent(extractCodeFromHtml(shikiHtml))\n return `<button data-code=\"${code}\">\n <span>Copy</span>\n <span style=\"display:none\">Copied!</span>\n </button>`\n}\n\nfunction extractCodeFromHtml(html: string): string {\n return decodeCommonEntities(stripTags(html))\n}\n\nfunction stripTags(html: string): string {\n let result = \"\"\n let inTag = false\n\n for (const char of html) {\n if (char === \"<\") {\n inTag = true\n continue\n }\n\n if (inTag && char === \">\") {\n inTag = false\n continue\n }\n\n if (!inTag) {\n result += char\n }\n }\n\n return result\n}\n\nfunction decodeCommonEntities(text: string): string {\n return text\n .replaceAll(\"&lt;\", \"<\")\n .replaceAll(\"&gt;\", \">\")\n .replaceAll(\"&amp;\", \"&\")\n .replaceAll(\"&quot;\", '\"')\n .replaceAll(\"&#39;\", \"'\")\n}\n\nfunction escapeHtml(text: string): string {\n return text\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"'\", \"&#39;\")\n}\n","export function parseHighlightLines(meta: string): number[] {\n const match = /\\{([\\d,-]+)\\}/u.exec(meta)\n if (match?.[1] == null) {\n return []\n }\n\n const lines: number[] = []\n for (const range of match[1].split(\",\")) {\n appendRangeLines(lines, range)\n }\n\n return lines\n}\n\nfunction appendRangeLines(lines: number[], range: string): void {\n if (range.includes(\"-\")) {\n appendRangeSet(lines, range)\n return\n }\n\n const lineNumber = Number(range)\n if (Number.isFinite(lineNumber)) {\n lines.push(lineNumber)\n }\n}\n\nfunction appendRangeSet(lines: number[], range: string): void {\n const [start, end] = range.split(\"-\").map(Number)\n if (!Number.isFinite(start) || !Number.isFinite(end)) {\n return\n }\n\n for (let line = start; line <= end; line++) {\n lines.push(line)\n }\n}\n\nexport function parseTitle(meta: string): string | undefined {\n const match = /title=\"([^\"]+)\"/u.exec(meta)\n return match?.[1]\n}\n\nexport function parseLabel(meta: string): string | undefined {\n const start = meta.indexOf(\"[\")\n if (start === -1) {\n return undefined\n }\n\n const end = meta.indexOf(\"]\", start + 1)\n if (end === -1) {\n return undefined\n }\n\n const label = meta.slice(start + 1, end).trim()\n return label.length > 0 ? label : undefined\n}\n","import type { Element, Root, Text } from \"hast\"\nimport type { Highlighter } from \"shiki\"\n\nimport { visit } from \"unist-util-visit\"\n\nimport type { MarkdownConfig } from \"../config/types\"\n\nimport { shikiContainerClassName } from \"../ui/components/code-block-classes\"\nimport { buildCodeBlockHtml } from \"./shiki-html\"\nimport { parseHighlightLines, parseTitle } from \"./shiki-meta\"\nimport { highlightWithTheme, resolveThemeConfig } from \"./shiki-theme\"\n\ninterface RehypeShikiOptions {\n config: MarkdownConfig\n highlighter: Highlighter\n}\n\ninterface TransformCodeNodeContext {\n config: MarkdownConfig\n highlighter: Highlighter\n index: number | undefined\n node: Element\n parent: unknown\n themeConfig: MarkdownConfig[\"theme\"]\n}\n\nexport function rehypeShikiFromHighlighter(options: RehypeShikiOptions) {\n const themeConfig = resolveThemeConfig(options.config.theme)\n\n return function (tree: Root): void {\n visit(tree, \"element\", (node: Element, index, parent) => {\n transformCodeNode({\n config: options.config,\n highlighter: options.highlighter,\n index,\n node,\n parent,\n themeConfig,\n })\n })\n }\n}\n\nfunction transformCodeNode(context: TransformCodeNodeContext): void {\n const codeNode = getCodeNode(context.node)\n if (codeNode == null) {\n return\n }\n\n const codeContent = getTextContent(codeNode)\n if (codeContent.trim().length === 0) {\n return\n }\n\n const metaString = getMetaString(codeNode)\n const language = getLanguage(codeNode)\n const innerHtml = tryRenderHighlightedHtml({\n codeContent,\n context,\n language,\n metaString,\n })\n if (innerHtml == null) {\n return\n }\n\n replaceNodeWithShikiContainer(context.parent, context.index, innerHtml)\n}\n\nfunction tryRenderHighlightedHtml(params: {\n codeContent: string\n context: TransformCodeNodeContext\n language: string\n metaString: string\n}): null | string {\n const { codeContent, context, language, metaString } = params\n try {\n const html = highlightWithTheme({\n code: codeContent,\n highlighter: context.highlighter,\n language,\n themeConfig: context.themeConfig,\n })\n\n return buildCodeBlockHtml(html, {\n highlightLines: parseHighlightLines(metaString),\n lang: language,\n lineNumbers: (context.config.lineNumbers ?? false) || metaString.includes(\"showLineNumbers\"),\n title: parseTitle(metaString),\n })\n } catch {\n return null\n }\n}\n\nfunction getCodeNode(node: Element): Element | null {\n if (node.tagName !== \"pre\") {\n return null\n }\n\n const firstChild = node.children.at(0)\n if (!isElementNode(firstChild) || firstChild.tagName !== \"code\") {\n return null\n }\n\n return firstChild\n}\n\nfunction isElementNode(node: unknown): node is Element {\n return isRecord(node) && node.type === \"element\"\n}\n\nfunction getMetaString(codeNode: Element): string {\n const properties = toRecord(codeNode.properties)\n return typeof properties.metastring === \"string\" ? properties.metastring : \"\"\n}\n\nfunction getLanguage(codeNode: Element): string {\n const properties = toRecord(codeNode.properties)\n const classNames = toClassNameList(properties.className)\n const languageClass = classNames.find((className) => className.startsWith(\"language-\"))\n\n return languageClass == null ? \"text\" : languageClass.replace(\"language-\", \"\")\n}\n\nfunction toClassNameList(className: unknown): string[] {\n if (Array.isArray(className)) {\n return className.filter((entry): entry is string => typeof entry === \"string\")\n }\n\n if (typeof className === \"string\") {\n return [className]\n }\n\n return []\n}\n\nfunction getTextContent(node: Element | Text): string {\n if (node.type === \"text\") {\n return node.value\n }\n\n const parts: string[] = []\n for (const child of node.children) {\n if (child.type === \"text\" || child.type === \"element\") {\n parts.push(getTextContent(child))\n }\n }\n\n return parts.join(\"\")\n}\n\nfunction replaceNodeWithShikiContainer(\n parent: unknown,\n index: number | undefined,\n innerHtml: string\n): void {\n if (index == null || !hasChildrenArray(parent)) {\n return\n }\n\n parent.children[index] = {\n type: \"element\",\n tagName: \"div\",\n properties: {\n className: [shikiContainerClassName],\n },\n children: [\n {\n type: \"raw\",\n value: innerHtml,\n } as unknown as Element,\n ],\n } satisfies Element\n}\n\nfunction hasChildrenArray(value: unknown): value is { children: unknown[] } {\n return isRecord(value) && Array.isArray(value.children)\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> {\n return isRecord(value) ? value : {}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value != null && typeof value === \"object\"\n}\n","import type { Root } from \"hast\"\nimport type { ShikiTransformer } from \"shiki\"\n\nimport { visit } from \"unist-util-visit\"\n\nimport { parseHighlightLines, parseLabel, parseTitle } from \"./shiki-meta\"\n\n/**\n * Remark plugin that extracts code fence meta info and stores it as HAST\n * data attributes before MDX compilation can corrupt it.\n */\nexport function remarkCodeMeta() {\n return function (tree: Root): void {\n visit(tree, \"code\", (node: { data?: Record<string, unknown>; meta?: null | string }) => {\n const meta = node.meta\n if (meta == null || meta.length === 0) {\n return\n }\n\n const data = ensureNodeData(node)\n const hProperties = ensureRecord(data.hProperties)\n\n // Preserve meta as metastring property on the <code> HAST element.\n // @shikijs/rehype reads head.properties.metastring and passes it\n // to Shiki as meta.__raw, which ardoLineTransformer reads.\n hProperties.metastring = meta\n data.hProperties = hProperties\n\n // Strip meta from the MDAST node to prevent MDX from\n // misinterpreting {expressions} like {2,4-5} as JSX.\n node.meta = null\n })\n }\n}\n\nfunction ensureNodeData(node: { data?: Record<string, unknown> }): Record<string, unknown> {\n node.data ??= {}\n return node.data\n}\n\nfunction ensureRecord(value: unknown): Record<string, unknown> {\n return isRecord(value) ? value : {}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value != null && typeof value === \"object\"\n}\n\ninterface ArdoLineTransformerOptions {\n globalLineNumbers?: boolean\n}\n\ninterface LineTransformerState {\n highlightLines: number[]\n metaRaw: string\n showLineNumbers: boolean\n}\n\ninterface TransformerNode {\n properties?: Record<string, unknown>\n}\n\n/**\n * Shiki transformer that adds line highlighting, line numbers, and title\n * attributes to code blocks in the MDX pipeline.\n */\nexport function ardoLineTransformer(options: ArdoLineTransformerOptions = {}): ShikiTransformer {\n const state: LineTransformerState = {\n highlightLines: [],\n metaRaw: \"\",\n showLineNumbers: false,\n }\n\n return {\n name: \"ardo:lines\",\n preprocess(_code, shikiOptions) {\n const metaRaw = getMetaRaw(shikiOptions.meta)\n state.metaRaw = metaRaw\n state.highlightLines = parseHighlightLines(metaRaw)\n state.showLineNumbers =\n (options.globalLineNumbers ?? false) || metaRaw.includes(\"showLineNumbers\")\n },\n pre(node) {\n const properties = ensureNodeProperties(node as TransformerNode)\n applyTitleProperty(properties, state.metaRaw)\n applyLabelProperty(properties, state.metaRaw)\n },\n line(node, line) {\n const properties = ensureNodeProperties(node as TransformerNode)\n applyHighlightedLineClass(properties, state.highlightLines, line)\n\n if (state.showLineNumbers) {\n properties[\"data-ln\"] = String(line)\n }\n },\n }\n}\n\nfunction getMetaRaw(meta: unknown): string {\n if (!isRecord(meta)) {\n return \"\"\n }\n\n const raw = meta.__raw\n return typeof raw === \"string\" ? raw : \"\"\n}\n\nfunction ensureNodeProperties(node: TransformerNode): Record<string, unknown> {\n node.properties ??= {}\n return node.properties\n}\n\nfunction applyTitleProperty(properties: Record<string, unknown>, metaRaw: string): void {\n const title = parseTitle(metaRaw)\n if (title != null && title.length > 0) {\n properties[\"data-title\"] = title\n }\n}\n\nfunction applyLabelProperty(properties: Record<string, unknown>, metaRaw: string): void {\n const label = parseLabel(metaRaw)\n if (label != null && label.length > 0) {\n properties[\"data-label\"] = label\n }\n}\n\nfunction applyHighlightedLineClass(\n properties: Record<string, unknown>,\n highlightLines: number[],\n line: number\n): void {\n if (!highlightLines.includes(line)) {\n return\n }\n\n const currentClass = typeof properties.class === \"string\" ? properties.class : \"\"\n properties.class = currentClass.length > 0 ? `${currentClass} highlighted` : \"highlighted\"\n}\n","import { createHighlighter, type Highlighter } from \"shiki\"\n\nimport type { MarkdownConfig } from \"../config/types\"\n\nimport { getBundledThemes, highlightWithTheme, resolveThemeConfig } from \"./shiki-theme\"\n\nexport { rehypeShikiFromHighlighter } from \"./shiki-rehype\"\nexport { ardoLineTransformer, remarkCodeMeta } from \"./shiki-transformer\"\n\nexport type ShikiHighlighter = Highlighter\n\nlet cachedHighlighterPromise: Promise<ShikiHighlighter> | undefined\n\n/**\n * Highlights code using Shiki with Ardo's default themes.\n * Creates and caches a highlighter instance for reuse.\n */\nexport async function highlightCode(\n code: string,\n language: string,\n options?: { theme?: MarkdownConfig[\"theme\"] }\n): Promise<string> {\n const themeConfig = resolveThemeConfig(options?.theme)\n const highlighter = await getCachedHighlighter(themeConfig)\n\n return highlightWithTheme({\n code,\n highlighter,\n language,\n themeConfig,\n })\n}\n\nasync function getCachedHighlighter(\n themeConfig: MarkdownConfig[\"theme\"]\n): Promise<ShikiHighlighter> {\n cachedHighlighterPromise ??= createShikiHighlighter({\n anchor: false,\n lineNumbers: false,\n theme: themeConfig,\n toc: { level: [2, 3] },\n })\n\n return cachedHighlighterPromise\n}\n\nexport async function createShikiHighlighter(config: MarkdownConfig): Promise<ShikiHighlighter> {\n const themeConfig = resolveThemeConfig(config.theme)\n\n return createHighlighter({\n themes: getBundledThemes(themeConfig),\n langs: [\n // Web fundamentals\n \"javascript\",\n \"typescript\",\n \"jsx\",\n \"tsx\",\n \"html\",\n \"css\",\n \"scss\",\n\n // Data & config formats\n \"json\",\n \"jsonc\",\n \"yaml\",\n \"toml\",\n \"xml\",\n \"graphql\",\n\n // Markdown & docs\n \"markdown\",\n \"mdx\",\n\n // Shell & DevOps\n \"bash\",\n \"shell\",\n \"dockerfile\",\n\n // General purpose\n \"python\",\n \"rust\",\n \"go\",\n \"sql\",\n \"diff\",\n ],\n })\n}\n","import type { Heading, Root } from \"mdast\"\n\nimport { visit } from \"unist-util-visit\"\n\nimport type { TOCItem } from \"../config/types\"\n\nexport interface TocExtraction {\n toc: TOCItem[]\n}\n\ninterface TocOptions {\n tocExtraction: TocExtraction\n levels: [number, number]\n}\n\nexport function remarkExtractToc(options: TocOptions) {\n const { tocExtraction, levels } = options\n const [minLevel, maxLevel] = levels\n\n return function (tree: Root) {\n const headings: Array<{ text: string; level: number; id: string }> = []\n let headingIndex = 0\n\n visit(tree, \"heading\", (node: Heading) => {\n if (node.depth < minLevel || node.depth > maxLevel) {\n return\n }\n\n const text = getHeadingText(node)\n const slug = slugify(text)\n const id = slug === \"\" ? `heading-${headingIndex}` : slug\n headingIndex++\n\n headings.push({\n text,\n level: node.depth,\n id,\n })\n\n // Add id to the heading node for anchor links\n const data = node.data ?? (node.data = {})\n const hProperties = (data.hProperties ?? (data.hProperties = {})) as Record<string, string>\n hProperties.id = id\n })\n\n tocExtraction.toc = buildTocTree(headings)\n }\n}\n\nfunction getHeadingText(node: Heading): string {\n const textParts: string[] = []\n\n function extractText(child: unknown) {\n if (typeof child !== \"object\" || child === null) return\n\n const typedChild = child as { type?: string; value?: string; children?: unknown[] }\n\n if (typedChild.type === \"text\") {\n textParts.push(typedChild.value ?? \"\")\n } else if (typedChild.type === \"inlineCode\") {\n textParts.push(typedChild.value ?? \"\")\n } else if (Array.isArray(typedChild.children)) {\n typedChild.children.forEach((nestedChild) => {\n extractText(nestedChild)\n })\n }\n }\n\n node.children.forEach((child) => {\n extractText(child)\n })\n return textParts.join(\"\")\n}\n\nfunction slugify(text: string): string {\n let slug = text\n .toLowerCase()\n .trim()\n .replaceAll(/[^\\s\\w-]/g, \"\")\n .replaceAll(/[\\s_]/g, \"-\")\n\n while (slug.includes(\"--\")) {\n slug = slug.replaceAll(\"--\", \"-\")\n }\n\n if (slug.startsWith(\"-\")) {\n slug = slug.slice(1)\n }\n\n if (slug.endsWith(\"-\")) {\n slug = slug.slice(0, -1)\n }\n\n return slug\n}\n\nfunction popStackUntilParent(stack: Array<{ item: TOCItem; level: number }>, level: number): void {\n while (stack.length > 0) {\n const last = stack.at(-1)\n if (last === undefined || last.level < level) break\n stack.pop()\n }\n}\n\nfunction insertIntoTree(\n result: TOCItem[],\n stack: Array<{ item: TOCItem; level: number }>,\n item: TOCItem\n): void {\n const parent = stack.at(-1)?.item\n if (parent === undefined) {\n result.push(item)\n } else {\n parent.children ??= []\n parent.children.push(item)\n }\n}\n\nfunction buildTocTree(headings: Array<{ text: string; level: number; id: string }>): TOCItem[] {\n const result: TOCItem[] = []\n const stack: Array<{ item: TOCItem; level: number }> = []\n\n for (const heading of headings) {\n const item: TOCItem = { id: heading.id, text: heading.text, level: heading.level }\n popStackUntilParent(stack, heading.level)\n insertIntoTree(result, stack, item)\n stack.push({ item, level: heading.level })\n }\n\n return result\n}\n\nexport function flattenToc(toc: TOCItem[]): TOCItem[] {\n const result: TOCItem[] = []\n\n function flatten(items: TOCItem[]) {\n for (const item of items) {\n result.push(item)\n if (item.children !== undefined) {\n flatten(item.children)\n }\n }\n }\n\n flatten(toc)\n return result\n}\n","import matter from \"gray-matter\"\nimport rehypeStringify from \"rehype-stringify\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkParse from \"remark-parse\"\nimport remarkRehype from \"remark-rehype\"\nimport { unified } from \"unified\"\n\nimport type { MarkdownConfig, PageFrontmatter, TOCItem } from \"../config/types\"\n\nimport { rehypeLinks } from \"./links\"\nimport { createShikiHighlighter, rehypeShikiFromHighlighter, type ShikiHighlighter } from \"./shiki\"\nimport { remarkExtractToc, type TocExtraction } from \"./toc\"\n\nexport interface TransformResult {\n html: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n}\n\nexport interface TransformOptions {\n basePath?: string\n highlighter?: ShikiHighlighter\n}\n\nexport async function transformMarkdown(\n content: string,\n config: MarkdownConfig,\n options: TransformOptions = {}\n): Promise<TransformResult> {\n const { data: frontmatter, content: markdownContent } = matter(content)\n const { basePath = \"/\", highlighter: providedHighlighter } = options\n\n const tocExtraction: TocExtraction = { toc: [] }\n const highlighter = providedHighlighter ?? (await createShikiHighlighter(config))\n\n const processor = unified()\n .use(remarkParse)\n .use(remarkFrontmatter, [\"yaml\"])\n .use(remarkGfm)\n .use(remarkExtractToc, { tocExtraction, levels: config.toc?.level ?? [2, 3] })\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeShikiFromHighlighter, { highlighter, config })\n .use(rehypeLinks, { basePath })\n .use(rehypeStringify, { allowDangerousHtml: true })\n\n if (config.remarkPlugins) {\n for (const plugin of config.remarkPlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n if (config.rehypePlugins) {\n for (const plugin of config.rehypePlugins) {\n processor.use(plugin as Parameters<typeof processor.use>[0])\n }\n }\n\n const result = await processor.process(markdownContent)\n\n return {\n html: String(result),\n frontmatter: frontmatter as PageFrontmatter,\n toc: tocExtraction.toc,\n }\n}\n\nexport async function transformMarkdownToReact(\n content: string,\n config: MarkdownConfig\n): Promise<TransformResult> {\n return transformMarkdown(content, config)\n}\n","import fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport type { PageData, PageFrontmatter, ResolvedConfig, TOCItem } from \"../config/types\"\n\nimport { transformMarkdown } from \"../markdown/pipeline\"\n\nexport interface LoadDocOptions {\n slug: string\n contentDir: string\n config: ResolvedConfig\n}\n\nexport interface LoadDocResult {\n content: string\n frontmatter: PageFrontmatter\n toc: TOCItem[]\n filePath: string\n relativePath: string\n lastUpdated?: number\n}\n\nasync function findFile(\n contentDir: string,\n slug: string\n): Promise<{ filePath: string; fileContent: string } | null> {\n const possiblePaths = [\n path.join(contentDir, `${slug}.md`),\n path.join(contentDir, slug, \"index.md\"),\n ]\n\n for (const tryPath of possiblePaths) {\n try {\n const fileContent = await fs.readFile(tryPath, \"utf8\")\n return { filePath: tryPath, fileContent }\n } catch {\n continue\n }\n }\n return null\n}\n\nasync function getLastUpdated(filePath: string): Promise<number | undefined> {\n try {\n const stat = await fs.stat(filePath)\n return stat.mtimeMs\n } catch {\n return undefined\n }\n}\n\nexport async function loadDoc(options: LoadDocOptions): Promise<LoadDocResult | null> {\n const { slug, contentDir, config } = options\n const found = await findFile(contentDir, slug)\n if (found === null) return null\n\n const result = await transformMarkdown(found.fileContent, config.markdown)\n return {\n content: result.html,\n frontmatter: result.frontmatter,\n toc: result.toc,\n filePath: found.filePath,\n relativePath: path.relative(contentDir, found.filePath),\n lastUpdated: await getLastUpdated(found.filePath),\n }\n}\n\nexport async function loadAllDocs(contentDir: string, config: ResolvedConfig): Promise<PageData[]> {\n const docs: PageData[] = []\n\n async function scanDir(dir: string) {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n await scanDir(fullPath)\n } else if (entry.name.endsWith(\".md\")) {\n const fileContent = await fs.readFile(fullPath, \"utf8\")\n const result = await transformMarkdown(fileContent, config.markdown)\n const relativePath = path.relative(contentDir, fullPath)\n\n let lastUpdated: number | undefined\n try {\n const stat = await fs.stat(fullPath)\n lastUpdated = stat.mtimeMs\n } catch {\n // Ignore stat errors\n }\n\n docs.push({\n title: result.frontmatter.title ?? formatTitle(entry.name.replace(/\\.md$/, \"\")),\n description: result.frontmatter.description,\n frontmatter: result.frontmatter,\n content: result.html,\n toc: result.toc,\n filePath: fullPath,\n relativePath,\n lastUpdated,\n })\n }\n }\n }\n\n await scanDir(contentDir)\n return docs\n}\n\nfunction formatTitle(name: string): string {\n return name.replaceAll(/[_-]/g, \" \").replaceAll(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\nexport function getSlugFromPath(relativePath: string): string {\n return relativePath\n .replace(/\\.md$/, \"\")\n .replace(/\\/index$/, \"\")\n .replaceAll(\"\\\\\", \"/\")\n}\n\nexport function getPageDataForRoute(docs: PageData[], slug: string): PageData | undefined {\n return docs.find((doc) => {\n const docSlug = getSlugFromPath(doc.relativePath)\n return docSlug === slug || docSlug === `${slug}/index`\n })\n}\n","import type { Dirent } from \"node:fs\"\n\nimport matter from \"gray-matter\"\nimport fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport type { ResolvedConfig, SidebarItem } from \"../config/types\"\n\nexport interface SidebarGenerationOptions {\n basePath: string\n config: ResolvedConfig\n contentDir: string\n}\n\ninterface SidebarItemWithOrder extends SidebarItem {\n order?: number\n}\n\ninterface SidebarFrontmatter {\n order?: number\n sidebar?: boolean\n title?: string\n}\n\nexport async function generateSidebar(options: SidebarGenerationOptions): Promise<SidebarItem[]> {\n const { contentDir } = options\n return scanDirectoryForSidebar(contentDir, contentDir)\n}\n\nasync function scanDirectoryForSidebar(dir: string, rootDir: string): Promise<SidebarItem[]> {\n const entries = await readDirectoryEntries(dir)\n const items: SidebarItemWithOrder[] = []\n\n for (const entry of entries) {\n const sidebarItem = await createSidebarItemFromEntry({\n dir,\n entry,\n rootDir,\n })\n\n if (sidebarItem != null) {\n items.push(sidebarItem)\n }\n }\n\n sortSidebarItems(items)\n return items.map(({ order: _order, ...item }) => item)\n}\n\nasync function readDirectoryEntries(dir: string): Promise<Dirent[]> {\n try {\n return await fs.readdir(dir, { withFileTypes: true })\n } catch {\n return []\n }\n}\n\nasync function createSidebarItemFromEntry(params: {\n dir: string\n entry: Dirent\n rootDir: string\n}): Promise<null | SidebarItemWithOrder> {\n const { dir, entry, rootDir } = params\n if (isIgnoredEntry(entry.name)) {\n return null\n }\n\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.isDirectory()) {\n return createDirectorySidebarItem(fullPath, relativePath, rootDir)\n }\n\n if (isMarkdownPage(entry.name)) {\n return createMarkdownSidebarItem(fullPath, relativePath, entry.name)\n }\n\n return null\n}\n\nfunction isIgnoredEntry(entryName: string): boolean {\n return entryName.startsWith(\".\") || entryName.startsWith(\"_\")\n}\n\nfunction isMarkdownPage(entryName: string): boolean {\n return entryName.endsWith(\".md\") && entryName !== \"index.md\"\n}\n\nasync function createDirectorySidebarItem(\n fullPath: string,\n relativePath: string,\n rootDir: string\n): Promise<null | SidebarItemWithOrder> {\n const children = await scanDirectoryForSidebar(fullPath, rootDir)\n if (children.length === 0) {\n return null\n }\n\n const metadata = await readDirectoryIndexMetadata(fullPath, relativePath)\n const title = metadata.title ?? formatTitle(path.basename(fullPath))\n\n return {\n collapsed: false,\n items: children,\n link: metadata.link,\n order: metadata.order,\n text: title,\n }\n}\n\nasync function readDirectoryIndexMetadata(\n fullPath: string,\n relativePath: string\n): Promise<{ link?: string; order?: number; title?: string }> {\n const indexPath = path.join(fullPath, \"index.md\")\n const frontmatter = await readFrontmatter(indexPath)\n\n return {\n link: frontmatter == null ? undefined : normalizePath(relativePath),\n order: frontmatter?.order,\n title: frontmatter?.title,\n }\n}\n\nasync function createMarkdownSidebarItem(\n fullPath: string,\n relativePath: string,\n fileName: string\n): Promise<null | SidebarItemWithOrder> {\n const frontmatter = await readFrontmatter(fullPath)\n if (frontmatter?.sidebar === false) {\n return null\n }\n\n const fallbackTitle = formatTitle(fileName.replace(/\\.md$/u, \"\"))\n const title = frontmatter?.title ?? fallbackTitle\n\n return {\n link: normalizePath(relativePath.replace(/\\.md$/u, \"\")),\n order: frontmatter?.order,\n text: title,\n }\n}\n\nasync function readFrontmatter(filePath: string): Promise<null | SidebarFrontmatter> {\n try {\n const fileContent = await fs.readFile(filePath, \"utf8\")\n const parsed = matter(fileContent)\n return toSidebarFrontmatter(parsed.data)\n } catch {\n return null\n }\n}\n\nfunction toSidebarFrontmatter(data: unknown): SidebarFrontmatter {\n if (!isRecord(data)) {\n return {}\n }\n\n return {\n order: typeof data.order === \"number\" ? data.order : undefined,\n sidebar: typeof data.sidebar === \"boolean\" ? data.sidebar : undefined,\n title: typeof data.title === \"string\" ? data.title : undefined,\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value != null && typeof value === \"object\"\n}\n\nfunction sortSidebarItems(items: SidebarItemWithOrder[]): void {\n items.sort((left, right) => {\n if (left.order != null && right.order != null) {\n return left.order - right.order\n }\n\n if (left.order != null) {\n return -1\n }\n\n if (right.order != null) {\n return 1\n }\n\n return left.text.localeCompare(right.text)\n })\n}\n\nfunction formatTitle(name: string): string {\n return name\n .replace(/^\\d+-/u, \"\")\n .replaceAll(/[_-]/gu, \" \")\n .replaceAll(/\\b\\w/gu, (char) => char.toUpperCase())\n}\n\nfunction normalizePath(p: string): string {\n return `/${p.replaceAll(\"\\\\\", \"/\").replace(/^\\/+/u, \"\")}`\n}\n","export interface ScannedCodeBlock {\n children: null | string\n end: number\n fullMatch: string\n props: string\n start: number\n}\n\nconst OPENING_TAG = \"<ArdoCodeBlock\"\nconst CLOSING_TAG = \"</ArdoCodeBlock>\"\n\n/**\n * Strips leading/trailing blank lines and removes common leading whitespace.\n * Same logic as the runtime outdent in CodeBlock.tsx.\n */\nexport function outdent(text: string): string {\n const trimmedLines = trimBlankLines(text.split(\"\\n\"))\n if (trimmedLines.length === 0) {\n return \"\"\n }\n\n const commonIndent = getCommonIndent(trimmedLines)\n if (commonIndent === 0) {\n return trimmedLines.join(\"\\n\")\n }\n\n return trimmedLines.map((line) => stripIndent(line, commonIndent)).join(\"\\n\")\n}\n\nfunction trimBlankLines(lines: string[]): string[] {\n const result = [...lines]\n\n while (result.length > 0 && result[0].trim().length === 0) {\n result.shift()\n }\n\n while (result.length > 0 && result.at(-1)?.trim().length === 0) {\n result.pop()\n }\n\n return result\n}\n\nfunction getCommonIndent(lines: string[]): number {\n let minIndent = Number.POSITIVE_INFINITY\n\n for (const line of lines) {\n if (line.trim().length === 0) {\n continue\n }\n\n const indent = getLeadingWhitespaceLength(line)\n if (indent < minIndent) {\n minIndent = indent\n }\n }\n\n return Number.isFinite(minIndent) ? minIndent : 0\n}\n\nfunction stripIndent(line: string, commonIndent: number): string {\n const availableIndent = getLeadingWhitespaceLength(line)\n const removeCount = Math.min(commonIndent, availableIndent)\n return line.slice(removeCount)\n}\n\nfunction getLeadingWhitespaceLength(line: string): number {\n let index = 0\n while (index < line.length) {\n const char = line[index]\n if (char !== \" \" && char !== \"\\t\") {\n break\n }\n index++\n }\n return index\n}\n\n/**\n * Finds all `<ArdoCodeBlock ... />` and `<ArdoCodeBlock ...>...</ArdoCodeBlock>` tags\n * by scanning for balanced quotes and braces.\n */\nexport function scanArdoCodeBlocks(source: string): ScannedCodeBlock[] {\n const blocks: ScannedCodeBlock[] = []\n let cursor = 0\n\n while (cursor < source.length) {\n const scanResult = scanNextCodeBlock(source, cursor)\n if (scanResult == null) {\n break\n }\n\n const { block, nextCursor } = scanResult\n if (block != null) {\n blocks.push(block)\n }\n\n cursor = nextCursor\n }\n\n return blocks\n}\n\nfunction scanNextCodeBlock(\n source: string,\n cursor: number\n): { block: null | ScannedCodeBlock; nextCursor: number } | null {\n const start = source.indexOf(OPENING_TAG, cursor)\n if (start === -1) {\n return null\n }\n\n const opening = scanOpeningTag(source, start)\n if (opening == null) {\n return { block: null, nextCursor: start + OPENING_TAG.length }\n }\n\n const block = createScannedBlock(source, start, opening)\n if (block == null) {\n return null\n }\n\n return { block, nextCursor: block.end }\n}\n\ninterface OpeningTag {\n end: number\n isSelfClosing: boolean\n props: string\n}\n\nfunction scanOpeningTag(source: string, start: number): null | OpeningTag {\n const afterTag = start + OPENING_TAG.length\n if (!isWhitespaceChar(source[afterTag])) {\n return null\n }\n\n let index = afterTag\n let braceDepth = 0\n let quote: null | QuoteChar = null\n\n while (index < source.length) {\n const step = advanceOpeningTagScan(source, {\n braceDepth,\n index,\n quote,\n })\n if (step.tagEndIndex != null) {\n return finalizeOpeningTag(source, afterTag, step.tagEndIndex)\n }\n\n index = step.nextIndex\n braceDepth = step.nextBraceDepth\n quote = step.nextQuote\n }\n\n return null\n}\n\nfunction finalizeOpeningTag(source: string, afterTag: number, endBracketIndex: number): OpeningTag {\n const isSelfClosing = source[endBracketIndex - 1] === \"/\"\n const propsEnd = isSelfClosing ? endBracketIndex - 1 : endBracketIndex\n const props = source.slice(afterTag, propsEnd).trim()\n\n return {\n end: endBracketIndex + 1,\n isSelfClosing,\n props,\n }\n}\n\nconst QUOTE_CHARS = [\"'\", '\"', \"`\"] as const\ntype QuoteChar = (typeof QUOTE_CHARS)[number]\n\ninterface OpeningTagScanStep {\n nextBraceDepth: number\n nextIndex: number\n nextQuote: null | QuoteChar\n tagEndIndex: null | number\n}\n\ninterface ScanCursorState {\n braceDepth: number\n index: number\n quote: null | QuoteChar\n}\n\nfunction advanceOpeningTagScan(source: string, state: ScanCursorState): OpeningTagScanStep {\n const { braceDepth, index, quote } = state\n if (quote != null) {\n return scanQuotedStep(source, {\n braceDepth,\n index,\n quote,\n })\n }\n\n return scanUnquotedStep(source, index, braceDepth)\n}\n\nfunction scanQuotedStep(source: string, state: ScanCursorState): OpeningTagScanStep {\n const { braceDepth, index, quote } = state\n if (source[index] === \"\\\\\") {\n return {\n nextBraceDepth: braceDepth,\n nextIndex: Math.min(source.length, index + 2),\n nextQuote: quote,\n tagEndIndex: null,\n }\n }\n\n const closesQuote = source[index] === quote\n return {\n nextBraceDepth: braceDepth,\n nextIndex: index + 1,\n nextQuote: closesQuote ? null : quote,\n tagEndIndex: null,\n }\n}\n\nfunction scanUnquotedStep(source: string, index: number, braceDepth: number): OpeningTagScanStep {\n const char = source[index]\n if (isQuote(char)) {\n return makeScanStep(index + 1, braceDepth, char)\n }\n\n if (char === \"{\") {\n return makeScanStep(index + 1, braceDepth + 1, null)\n }\n\n if (char === \"}\") {\n return makeScanStep(index + 1, Math.max(0, braceDepth - 1), null)\n }\n\n if (braceDepth === 0 && char === \">\") {\n return {\n nextBraceDepth: braceDepth,\n nextIndex: index + 1,\n nextQuote: null,\n tagEndIndex: index,\n }\n }\n\n return makeScanStep(index + 1, braceDepth, null)\n}\n\nfunction makeScanStep(\n nextIndex: number,\n nextBraceDepth: number,\n nextQuote: null | QuoteChar\n): OpeningTagScanStep {\n return {\n nextBraceDepth,\n nextIndex,\n nextQuote,\n tagEndIndex: null,\n }\n}\n\nfunction createScannedBlock(\n source: string,\n start: number,\n opening: OpeningTag\n): null | ScannedCodeBlock {\n if (opening.isSelfClosing) {\n return {\n children: null,\n end: opening.end,\n fullMatch: source.slice(start, opening.end),\n props: opening.props,\n start,\n }\n }\n\n const closeStart = source.indexOf(CLOSING_TAG, opening.end)\n if (closeStart === -1) {\n return null\n }\n\n const end = closeStart + CLOSING_TAG.length\n return {\n children: source.slice(opening.end, closeStart),\n end,\n fullMatch: source.slice(start, end),\n props: opening.props,\n start,\n }\n}\n\nfunction isQuote(char: string): char is QuoteChar {\n return QUOTE_CHARS.includes(char as QuoteChar)\n}\n\nfunction isWhitespaceChar(char: string | undefined): boolean {\n return char === \" \" || char === \"\\n\" || char === \"\\r\" || char === \"\\t\"\n}\n","import type { MarkdownConfig } from \"../config/types\"\n\nimport { highlightCode } from \"../markdown/shiki\"\nimport { outdent, scanArdoCodeBlocks, type ScannedCodeBlock } from \"./codeblock-scan\"\n\nexport async function transformArdoCodeBlocks(\n source: string,\n markdownConfig?: MarkdownConfig\n): Promise<string> {\n let result = source\n let offset = 0\n const blocks = scanArdoCodeBlocks(source)\n\n for (const block of blocks) {\n const replacement = await createReplacement(block, markdownConfig)\n if (replacement == null) {\n continue\n }\n\n const adjustedStart = block.start + offset\n const adjustedEnd = block.end + offset\n result = result.slice(0, adjustedStart) + replacement + result.slice(adjustedEnd)\n offset += replacement.length - block.fullMatch.length\n }\n\n return result\n}\n\nasync function createReplacement(\n block: ScannedCodeBlock,\n markdownConfig?: MarkdownConfig\n): Promise<null | string> {\n if (block.props.includes(\"__html\")) {\n return null\n }\n\n if (block.children == null) {\n return createSelfClosingReplacement(block, markdownConfig)\n }\n\n return createChildrenReplacement(block, markdownConfig)\n}\n\nasync function createSelfClosingReplacement(\n block: ScannedCodeBlock,\n markdownConfig?: MarkdownConfig\n): Promise<null | string> {\n const codeValue = extractCodeValue(block.props)\n const language = extractPropValue(block.props, \"language\")\n if (codeValue == null || language == null) {\n return null\n }\n\n const html = await safeHighlightCode(codeValue, language, markdownConfig)\n if (html == null) {\n return null\n }\n\n const escapedHtml = JSON.stringify(html)\n const newProps = `__html={${escapedHtml}} ${block.props}`\n return block.fullMatch.replace(block.props, newProps)\n}\n\nasync function createChildrenReplacement(\n block: ScannedCodeBlock,\n markdownConfig?: MarkdownConfig\n): Promise<null | string> {\n const language = extractPropValue(block.props, \"language\")\n if (language == null || block.children == null) {\n return null\n }\n\n const rawChildren = unwrapTemplateChildren(block.children)\n const codeContent = outdent(rawChildren)\n const html = await safeHighlightCode(codeContent, language, markdownConfig)\n if (html == null) {\n return null\n }\n\n const escapedHtml = JSON.stringify(html)\n const escapedCode = JSON.stringify(codeContent)\n return `<ArdoCodeBlock __html={${escapedHtml}} code={${escapedCode}} ${block.props} />`\n}\n\nfunction unwrapTemplateChildren(rawChildren: string): string {\n const trimmed = rawChildren.trim()\n if (!trimmed.startsWith(\"{`\") || !trimmed.endsWith(\"`}\")) {\n return rawChildren\n }\n\n return trimmed.slice(2, -2)\n}\n\nfunction extractCodeValue(props: string): null | string {\n const code = extractPropValue(props, \"code\")\n if (code == null) {\n return null\n }\n\n return decodeEscapedString(code)\n}\n\nfunction decodeEscapedString(value: string): string {\n return value.replaceAll(\"\\\\n\", \"\\n\").replaceAll('\\\\\"', '\"').replaceAll(\"\\\\\\\\\", \"\\\\\")\n}\n\nfunction extractPropValue(props: string, propName: string): null | string {\n const patterns = getPropPatterns(propName)\n\n for (const pattern of patterns) {\n const match = pattern.exec(props)\n if (match?.[1] != null) {\n return match[1]\n }\n }\n\n return null\n}\n\nfunction getPropPatterns(propName: string): RegExp[] {\n return [\n new RegExp(`\\\\b${propName}=\"((?:[^\"\\\\\\\\]|\\\\\\\\.)*)\"`, \"su\"),\n new RegExp(`\\\\b${propName}=\\\\{\\\\s*\"((?:[^\"\\\\\\\\]|\\\\\\\\.)*)\"\\\\s*\\\\}`, \"su\"),\n new RegExp(`\\\\b${propName}=\\\\{\\\\s*'((?:[^'\\\\\\\\]|\\\\\\\\.)*)'\\\\s*\\\\}`, \"su\"),\n ]\n}\n\nasync function safeHighlightCode(\n codeContent: string,\n language: string,\n markdownConfig?: MarkdownConfig\n): Promise<null | string> {\n try {\n return await highlightCode(codeContent, language, {\n theme: markdownConfig?.theme,\n })\n } catch {\n return null\n }\n}\n","import type { Plugin } from \"vite\"\n\nimport type { MarkdownConfig } from \"../config/types\"\n\nimport { transformArdoCodeBlocks } from \"./codeblock-transform\"\n\n/**\n * Vite plugin that pre-highlights ArdoCodeBlock components at build time.\n *\n * Runs before the JSX parser, so children can contain arbitrary code\n * (including `<`, `{`, etc.) without causing syntax errors.\n */\nexport function ardoCodeBlockPlugin(markdownConfig?: MarkdownConfig): Plugin {\n return {\n enforce: \"pre\",\n name: \"ardo:codeblock-highlight\",\n\n async transform(code, id) {\n if (!shouldProcessFile(code, id)) {\n return\n }\n\n const transformed = await transformArdoCodeBlocks(code, markdownConfig)\n if (transformed === code) {\n return\n }\n\n return {\n code: transformed,\n map: null,\n }\n },\n }\n}\n\nfunction shouldProcessFile(code: string, id: string): boolean {\n if (!/\\.[jt]sx$/u.test(id)) {\n return false\n }\n\n if (id.includes(\"node_modules\")) {\n return false\n }\n\n return code.includes(\"ArdoCodeBlock\")\n}\n","import { execSync } from \"node:child_process\"\nimport fs from \"node:fs\"\nimport path from \"node:path\"\n\n/**\n * Finds the package root by looking for package.json in parent directories.\n * Returns the path relative to cwd, or undefined if not found.\n */\nexport function findPackageRoot(cwd: string): string | undefined {\n let currentDir = path.resolve(cwd)\n const filesystemRoot = path.parse(currentDir).root\n\n while (currentDir !== filesystemRoot) {\n const parentDir = path.dirname(currentDir)\n const packageJsonPath = path.join(parentDir, \"package.json\")\n if (fs.existsSync(packageJsonPath)) {\n const relativePath = path.relative(cwd, parentDir)\n return relativePath === \"\" ? \".\" : relativePath\n }\n\n currentDir = parentDir\n }\n\n return undefined\n}\n\n/**\n * Detects the GitHub repository name from git remote URL.\n * Returns the repo name (e.g., \"ardo\" from \"github.com/sebastian-software/ardo\")\n * or undefined if not a GitHub repo.\n */\nexport function detectGitHubRepoName(cwd: string): string | undefined {\n const remoteUrl = runGitCommand(cwd, \"git remote get-url origin\")\n if (remoteUrl == null) {\n return undefined\n }\n\n return parseGitHubRepoName(remoteUrl)\n}\n\n/**\n * Detects the current short git commit hash.\n */\nexport function detectGitHash(cwd: string): string | undefined {\n return runGitCommand(cwd, \"git rev-parse --short HEAD\")\n}\n\n/**\n * Detects the GitHub Pages basename from the git remote URL.\n * Returns \"/\" in dev mode or when no GitHub repo is detected.\n */\nexport function detectGitHubBasename(cwd?: string): string {\n if (process.env.NODE_ENV !== \"production\") {\n return \"/\"\n }\n\n const repoName = detectGitHubRepoName(cwd ?? process.cwd())\n return repoName != null ? `/${repoName}/` : \"/\"\n}\n\n/**\n * Recursively copies files from src to dest, overwriting existing files.\n */\nexport function copyRecursive(src: string, dest: string): void {\n const stat = fs.statSync(src)\n if (!stat.isDirectory()) {\n fs.copyFileSync(src, dest)\n return\n }\n\n if (!fs.existsSync(dest)) {\n fs.mkdirSync(dest, { recursive: true })\n }\n\n for (const item of fs.readdirSync(src)) {\n copyRecursive(path.join(src, item), path.join(dest, item))\n }\n}\n\nfunction runGitCommand(cwd: string, command: string): string | undefined {\n try {\n const commandResult = execSync(command, {\n cwd,\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim()\n\n return commandResult === \"\" ? undefined : commandResult\n } catch {\n return undefined\n }\n}\n\nfunction parseGitHubRepoName(remoteUrl: string): string | undefined {\n const normalizedUrl = remoteUrl.trim()\n if (!normalizedUrl.includes(\"github.com\")) {\n return undefined\n }\n\n const withoutGitSuffix = normalizedUrl.endsWith(\".git\")\n ? normalizedUrl.slice(0, -4)\n : normalizedUrl\n const slashSeparatedUrl = withoutGitSuffix.replace(\":\", \"/\")\n const urlSegments = slashSeparatedUrl.split(\"/\")\n const repoName = urlSegments.at(-1)\n const ownerName = urlSegments.at(-2)\n\n if (repoName == null || repoName === \"\" || ownerName == null || ownerName === \"\") {\n return undefined\n }\n\n return repoName\n}\n","import type { Plugin } from \"vite\"\n\nimport fs from \"node:fs\"\nimport path from \"node:path\"\n\nimport { copyRecursive } from \"./git-utils\"\n\nlet flattenExecuted = false\n\nexport function createFlattenPlugin(): Plugin {\n let detectedBase: string | undefined\n\n return {\n name: \"ardo:flatten-github-pages\",\n enforce: \"post\",\n configResolved(config) {\n detectedBase = config.base === \"/\" ? undefined : config.base\n },\n closeBundle() {\n if (flattenExecuted || detectedBase == null) {\n return\n }\n\n const baseName = trimSlashes(detectedBase)\n if (baseName === \"\") {\n return\n }\n\n const buildDir = path.join(process.cwd(), \"build\", \"client\")\n const nestedDir = path.join(buildDir, baseName)\n if (!fs.existsSync(nestedDir)) {\n return\n }\n\n console.log(`[ardo] Flattening build/client/${baseName}/ to build/client/ for GitHub Pages`)\n copyRecursive(nestedDir, buildDir)\n fs.rmSync(nestedDir, { recursive: true, force: true })\n console.log(\"[ardo] Build output flattened successfully.\")\n flattenExecuted = true\n },\n }\n}\n\nfunction trimSlashes(value: string): string {\n let trimmed = value\n\n while (trimmed.startsWith(\"/\")) {\n trimmed = trimmed.slice(1)\n }\n\n while (trimmed.endsWith(\"/\")) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n}\n","/**\n * Create an ESTree identifier node for a given name.\n *\n * @param name\n * The name of the identifier.\n * @returns\n * The identifier node.\n */\nfunction identifier(name) {\n return { type: 'Identifier', name };\n}\n/**\n * Create an ESTree literal node for a given value.\n *\n * @param value\n * The value for which to create a literal.\n * @returns\n * The literal node.\n */\nfunction literal(value) {\n return { type: 'Literal', value };\n}\n/**\n * Create an ESTree call expression on an object member.\n *\n * @param object\n * The object to call the method on.\n * @param name\n * The name of the method to call.\n * @param args\n * Arguments to pass to the function call\n * @returns\n * The call expression node.\n */\nfunction methodCall(object, name, args) {\n return {\n type: 'CallExpression',\n optional: false,\n callee: {\n type: 'MemberExpression',\n computed: false,\n optional: false,\n object,\n property: identifier(name)\n },\n arguments: args\n };\n}\n/**\n * Turn a number or bigint into an ESTree expression. This handles positive and negative numbers and\n * bigints as well as special numbers.\n *\n * @param number\n * The value to turn into an ESTree expression.\n * @returns\n * An expression that represents the given value.\n */\nfunction processNumber(number) {\n if (number < 0 || Object.is(number, -0)) {\n return {\n type: 'UnaryExpression',\n operator: '-',\n prefix: true,\n argument: processNumber(-number)\n };\n }\n if (typeof number === 'bigint') {\n return { type: 'Literal', bigint: String(number) };\n }\n if (number === Number.POSITIVE_INFINITY || Number.isNaN(number)) {\n return identifier(String(number));\n }\n return literal(number);\n}\n/**\n * Process an array of numbers. This is a shortcut for iterables whose constructor takes an array of\n * numbers as input.\n *\n * @param numbers\n * The numbers to add to the array expression.\n * @returns\n * An ESTree array expression whose elements match the input numbers.\n */\nfunction processNumberArray(numbers) {\n return { type: 'ArrayExpression', elements: Array.from(numbers, processNumber) };\n}\n/**\n * Check whether a value can be constructed from its string representation.\n *\n * @param value\n * The value to check\n * @returns\n * Whether or not the value can be constructed from its string representation.\n */\nfunction isStringReconstructable(value) {\n return value instanceof URL || value instanceof URLSearchParams;\n}\n/**\n * Check whether a value can be constructed from its `valueOf()` result.\n *\n * @param value\n * The value to check\n * @returns\n * Whether or not the value can be constructed from its `valueOf()` result.\n */\nfunction isValueReconstructable(value) {\n return (value instanceof Boolean ||\n value instanceof Date ||\n value instanceof Number ||\n value instanceof String);\n}\nconst wellKnownSymbols = new Map();\nfor (const name of Reflect.ownKeys(Symbol)) {\n const value = Symbol[name];\n if (typeof value === 'symbol') {\n wellKnownSymbols.set(value, name);\n }\n}\n/**\n * Check whether a value is a Temporal value.\n *\n * @param value\n * The value to check\n * @returns\n * Whether or not the value is a Temporal value.\n */\nfunction isTemporal(value) {\n return (typeof Temporal !== 'undefined' &&\n (value instanceof Temporal.Duration ||\n value instanceof Temporal.Instant ||\n value instanceof Temporal.PlainDate ||\n value instanceof Temporal.PlainDateTime ||\n value instanceof Temporal.PlainYearMonth ||\n value instanceof Temporal.PlainMonthDay ||\n value instanceof Temporal.PlainTime ||\n value instanceof Temporal.ZonedDateTime));\n}\n/**\n * Check whether a value is a typed array.\n *\n * @param value\n * The value to check\n * @returns\n * Whether or not the value is a typed array.\n */\nfunction isTypedArray(value) {\n return (value instanceof BigInt64Array ||\n value instanceof BigUint64Array ||\n (typeof Float16Array !== 'undefined' && value instanceof Float16Array) ||\n value instanceof Float32Array ||\n value instanceof Float64Array ||\n value instanceof Int8Array ||\n value instanceof Int16Array ||\n value instanceof Int32Array ||\n value instanceof Uint8Array ||\n value instanceof Uint8ClampedArray ||\n value instanceof Uint16Array ||\n value instanceof Uint32Array);\n}\n/**\n * Compare two value contexts for sorting them based on reference count.\n *\n * @param a\n * The first context to compare.\n * @param b\n * The second context to compare.\n * @returns\n * The count of context a minus the count of context b.\n */\nfunction compareContexts(a, b) {\n const aReferencedByB = a.referencedBy.has(b.value);\n const bReferencedByA = b.referencedBy.has(a.value);\n if (aReferencedByB) {\n if (bReferencedByA) {\n return a.count - b.count;\n }\n return -1;\n }\n if (bReferencedByA) {\n return 1;\n }\n return a.count - b.count;\n}\n/**\n * Replace the assigned right hand expression with the new expression.\n *\n * If there is no assignment expression, the original expression is returned. Otherwise the\n * assignment is modified and returned.\n *\n * @param expression\n * The expression to use for the assignment.\n * @param assignment\n * The existing assignmentexpression\n * @returns\n * The new expression.\n */\nfunction replaceAssignment(expression, assignment) {\n if (!assignment || assignment.type !== 'AssignmentExpression') {\n return expression;\n }\n let node = assignment;\n while (node.right.type === 'AssignmentExpression') {\n node = node.right;\n }\n node.right = expression;\n return assignment;\n}\n/**\n * Create an ESTree epxression to represent a symbol. Global and well-known symbols are supported.\n *\n * @param symbol\n * The symbol to represent.\n * @returns\n * An ESTree expression to represent the symbol.\n */\nfunction symbolToEstree(symbol) {\n const name = wellKnownSymbols.get(symbol);\n if (name) {\n return {\n type: 'MemberExpression',\n computed: false,\n optional: false,\n object: identifier('Symbol'),\n property: identifier(name)\n };\n }\n if (symbol.description && symbol === Symbol.for(symbol.description)) {\n return methodCall(identifier('Symbol'), 'for', [literal(symbol.description)]);\n }\n throw new TypeError(`Only global symbols are supported, got: ${String(symbol)}`, {\n cause: symbol\n });\n}\n/**\n * Create an ESTree property from a key and a value expression.\n *\n * @param key\n * The property key value\n * @param value\n * The property value as an ESTree expression.\n * @returns\n * The ESTree properry node.\n */\nfunction property(key, value) {\n const isString = typeof key === 'string';\n return {\n type: 'Property',\n method: false,\n shorthand: false,\n computed: key === '__proto__' || !isString,\n kind: 'init',\n key: isString ? literal(key) : symbolToEstree(key),\n value\n };\n}\n/**\n * Convert a value to an ESTree node.\n *\n * @param value\n * The value to convert.\n * @param options\n * Additional options to configure the output.\n * @returns\n * The ESTree node.\n */\nexport function valueToEstree(value, options = {}) {\n const stack = [];\n const collectedContexts = new Map();\n const namedContexts = [];\n const customTrees = new Map();\n /**\n * Analyze a value and collect all reference contexts.\n *\n * @param val\n * The value to analyze.\n */\n function analyze(val) {\n if (typeof val !== 'object' && typeof val !== 'function') {\n return;\n }\n if (val == null) {\n return;\n }\n const context = collectedContexts.get(val);\n if (context) {\n if (options.preserveReferences) {\n context.count += 1;\n }\n for (const ancestor of stack) {\n context.referencedBy.add(ancestor);\n }\n if (stack.includes(val)) {\n if (!options.preserveReferences) {\n throw new Error(`Found circular reference: ${val}`, { cause: val });\n }\n const parent = stack.at(-1);\n const parentContext = collectedContexts.get(parent);\n parentContext.recursive = true;\n context.recursive = true;\n }\n return;\n }\n collectedContexts.set(val, {\n count: 1,\n recursive: false,\n referencedBy: new Set(stack),\n value: val\n });\n const estree = options?.replacer?.(val);\n if (estree) {\n customTrees.set(val, estree);\n return;\n }\n if (typeof val === 'function') {\n throw new TypeError(`Unsupported value: ${val}`, { cause: val });\n }\n if (isTypedArray(val)) {\n return;\n }\n if (isStringReconstructable(val)) {\n return;\n }\n if (isValueReconstructable(val)) {\n return;\n }\n if (value instanceof RegExp) {\n return;\n }\n if (isTemporal(value)) {\n return;\n }\n stack.push(val);\n if (val instanceof Map) {\n for (const pair of val) {\n analyze(pair[0]);\n analyze(pair[1]);\n }\n }\n else if (Array.isArray(val) || val instanceof Set) {\n for (const entry of val) {\n analyze(entry);\n }\n }\n else {\n const proto = Object.getPrototypeOf(val);\n if (proto != null && proto !== Object.prototype && !options.instanceAsObject) {\n throw new TypeError(`Unsupported value: ${val}`, { cause: val });\n }\n for (const key of Reflect.ownKeys(val)) {\n analyze(val[key]);\n }\n }\n stack.pop();\n }\n /**\n * Recursively generate the ESTree expression needed to reconstruct the value.\n *\n * @param val\n * The value to process.\n * @param isDeclaration\n * Whether or not this is for a variable declaration.\n * @returns\n * The ESTree expression to reconstruct the value.\n */\n function generate(val, isDeclaration) {\n if (val === undefined) {\n return identifier(String(val));\n }\n if (val == null || typeof val === 'string' || typeof val === 'boolean') {\n return literal(val);\n }\n if (typeof val === 'bigint' || typeof val === 'number') {\n return processNumber(val);\n }\n if (typeof val === 'symbol') {\n return symbolToEstree(val);\n }\n const context = collectedContexts.get(val);\n if (!isDeclaration && context?.name) {\n return identifier(context.name);\n }\n const tree = customTrees.get(val);\n if (tree) {\n return tree;\n }\n if (isValueReconstructable(val)) {\n return {\n type: 'NewExpression',\n callee: identifier(val.constructor.name),\n arguments: [generate(val.valueOf())]\n };\n }\n if (val instanceof RegExp) {\n return {\n type: 'Literal',\n regex: { pattern: val.source, flags: val.flags }\n };\n }\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(val)) {\n return methodCall(identifier('Buffer'), 'from', [processNumberArray(val)]);\n }\n if (isTypedArray(val)) {\n return {\n type: 'NewExpression',\n callee: identifier(val.constructor.name),\n arguments: [processNumberArray(val)]\n };\n }\n if (isStringReconstructable(val)) {\n return {\n type: 'NewExpression',\n callee: identifier(val.constructor.name),\n arguments: [literal(String(val))]\n };\n }\n if (isTemporal(val)) {\n return methodCall({\n type: 'MemberExpression',\n computed: false,\n optional: false,\n object: identifier('Temporal'),\n property: identifier(val.constructor.name)\n }, 'from', [literal(String(val))]);\n }\n if (Array.isArray(val)) {\n const elements = Array.from({ length: val.length });\n let trimmable;\n for (let index = 0; index < val.length; index += 1) {\n if (!(index in val)) {\n elements[index] = null;\n trimmable = undefined;\n continue;\n }\n const child = val[index];\n const childContext = collectedContexts.get(child);\n if (context &&\n childContext &&\n namedContexts.indexOf(childContext) >= namedContexts.indexOf(context)) {\n elements[index] = null;\n trimmable ||= index;\n childContext.assignment = {\n type: 'AssignmentExpression',\n operator: '=',\n left: {\n type: 'MemberExpression',\n computed: true,\n optional: false,\n object: identifier(context.name),\n property: literal(index)\n },\n right: childContext.assignment || identifier(childContext.name)\n };\n }\n else {\n elements[index] = generate(child);\n trimmable = undefined;\n }\n }\n if (trimmable != null) {\n elements.splice(trimmable);\n }\n return {\n type: 'ArrayExpression',\n elements\n };\n }\n if (val instanceof Set) {\n const elements = [];\n let finalizer;\n for (const child of val) {\n if (finalizer) {\n finalizer = methodCall(finalizer, 'add', [generate(child)]);\n }\n else {\n const childContext = collectedContexts.get(child);\n if (context &&\n childContext &&\n namedContexts.indexOf(childContext) >= namedContexts.indexOf(context)) {\n finalizer = methodCall(identifier(context.name), 'add', [generate(child)]);\n }\n else {\n elements.push(generate(child));\n }\n }\n }\n if (context && finalizer) {\n context.assignment = replaceAssignment(finalizer, context.assignment);\n }\n return {\n type: 'NewExpression',\n callee: identifier('Set'),\n arguments: elements.length ? [{ type: 'ArrayExpression', elements }] : []\n };\n }\n if (val instanceof Map) {\n const elements = [];\n let finalizer;\n for (const [key, item] of val) {\n if (finalizer) {\n finalizer = methodCall(finalizer, 'set', [generate(key), generate(item)]);\n }\n else {\n const keyContext = collectedContexts.get(key);\n const itemContext = collectedContexts.get(item);\n if (context &&\n ((keyContext && namedContexts.indexOf(keyContext) >= namedContexts.indexOf(context)) ||\n (itemContext && namedContexts.indexOf(itemContext) >= namedContexts.indexOf(context)))) {\n finalizer = methodCall(identifier(context.name), 'set', [\n generate(key),\n generate(item)\n ]);\n }\n else {\n elements.push({\n type: 'ArrayExpression',\n elements: [generate(key), generate(item)]\n });\n }\n }\n }\n if (context && finalizer) {\n context.assignment = replaceAssignment(finalizer, context.assignment);\n }\n return {\n type: 'NewExpression',\n callee: identifier('Map'),\n arguments: elements.length ? [{ type: 'ArrayExpression', elements }] : []\n };\n }\n const properties = [];\n if (Object.getPrototypeOf(val) == null) {\n properties.push({\n type: 'Property',\n method: false,\n shorthand: false,\n computed: false,\n kind: 'init',\n key: identifier('__proto__'),\n value: literal(null)\n });\n }\n const object = val;\n const propertyDescriptors = [];\n for (const key of Reflect.ownKeys(val)) {\n // TODO [>=4] Throw an error for getters.\n const child = object[key];\n const { configurable, enumerable, writable } = Object.getOwnPropertyDescriptor(val, key);\n const childContext = collectedContexts.get(child);\n if (!configurable || !enumerable || !writable) {\n const propertyDescriptor = [property('value', generate(child))];\n if (configurable) {\n propertyDescriptor.push(property('configurable', literal(true)));\n }\n if (enumerable) {\n propertyDescriptor.push(property('enumerable', literal(true)));\n }\n if (writable) {\n propertyDescriptor.push(property('writable', literal(true)));\n }\n propertyDescriptors.push([\n key,\n { type: 'ObjectExpression', properties: propertyDescriptor }\n ]);\n }\n else if (context &&\n childContext &&\n namedContexts.indexOf(childContext) >= namedContexts.indexOf(context)) {\n if (key === '__proto__') {\n propertyDescriptors.push([\n key,\n {\n type: 'ObjectExpression',\n properties: [\n property('value', generate(child)),\n property('configurable', literal(true)),\n property('enumerable', literal(true)),\n property('writable', literal(true))\n ]\n }\n ]);\n }\n else {\n childContext.assignment = {\n type: 'AssignmentExpression',\n operator: '=',\n left: {\n type: 'MemberExpression',\n computed: true,\n optional: false,\n object: identifier(context.name),\n property: generate(key)\n },\n right: childContext.assignment || generate(child)\n };\n }\n }\n else {\n properties.push(property(key, generate(child)));\n }\n }\n const objectExpression = {\n type: 'ObjectExpression',\n properties\n };\n if (propertyDescriptors.length) {\n let name;\n let args;\n if (propertyDescriptors.length === 1) {\n const [[key, expression]] = propertyDescriptors;\n name = 'defineProperty';\n args = [typeof key === 'string' ? literal(key) : symbolToEstree(key), expression];\n }\n else {\n name = 'defineProperties';\n args = [\n {\n type: 'ObjectExpression',\n properties: propertyDescriptors.map(([key, expression]) => property(key, expression))\n }\n ];\n }\n if (!context) {\n return methodCall(identifier('Object'), name, [objectExpression, ...args]);\n }\n context.assignment = replaceAssignment(methodCall(identifier('Object'), name, [identifier(context.name), ...args]), context.assignment);\n }\n return objectExpression;\n }\n analyze(value);\n for (const [val, context] of collectedContexts) {\n if (context.recursive || context.count > 1) {\n // Assign reused or recursive references to a variable.\n context.name = `$${namedContexts.length}`;\n namedContexts.push(context);\n }\n else {\n // Otherwise don’t treat it as a reference.\n collectedContexts.delete(val);\n }\n }\n if (!namedContexts.length) {\n return generate(value);\n }\n const params = namedContexts.sort(compareContexts).map((context) => ({\n type: 'AssignmentPattern',\n left: identifier(context.name),\n right: generate(context.value, true)\n }));\n const rootContext = collectedContexts.get(value);\n const finalizers = [];\n for (const context of collectedContexts.values()) {\n if (context !== rootContext && context.assignment) {\n finalizers.push(context.assignment);\n }\n }\n finalizers.push(rootContext ? rootContext.assignment || identifier(rootContext.name) : generate(value));\n return {\n type: 'CallExpression',\n optional: false,\n arguments: [],\n callee: {\n type: 'ArrowFunctionExpression',\n expression: false,\n params,\n body: {\n type: 'SequenceExpression',\n expressions: finalizers\n }\n }\n };\n}\n//# sourceMappingURL=estree-util-value-to-estree.js.map","/**\n * @typedef Options\n * Configuration.\n * @property {boolean | null | undefined} [jsx=false]\n * Support JSX identifiers (default: `false`).\n */\n\nconst startRe = /[$_\\p{ID_Start}]/u\nconst contRe = /[$_\\u{200C}\\u{200D}\\p{ID_Continue}]/u\nconst contReJsx = /[-$_\\u{200C}\\u{200D}\\p{ID_Continue}]/u\nconst nameRe = /^[$_\\p{ID_Start}][$_\\u{200C}\\u{200D}\\p{ID_Continue}]*$/u\nconst nameReJsx = /^[$_\\p{ID_Start}][-$_\\u{200C}\\u{200D}\\p{ID_Continue}]*$/u\n\n/** @type {Options} */\nconst emptyOptions = {}\n\n/**\n * Checks if the given code point can start an identifier.\n *\n * @param {number | undefined} code\n * Code point to check.\n * @returns {boolean}\n * Whether `code` can start an identifier.\n */\n// Note: `undefined` is supported so you can pass the result from `''.codePointAt`.\nexport function start(code) {\n return code ? startRe.test(String.fromCodePoint(code)) : false\n}\n\n/**\n * Checks if the given code point can continue an identifier.\n *\n * @param {number | undefined} code\n * Code point to check.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {boolean}\n * Whether `code` can continue an identifier.\n */\n// Note: `undefined` is supported so you can pass the result from `''.codePointAt`.\nexport function cont(code, options) {\n const settings = options || emptyOptions\n const re = settings.jsx ? contReJsx : contRe\n return code ? re.test(String.fromCodePoint(code)) : false\n}\n\n/**\n * Checks if the given value is a valid identifier name.\n *\n * @param {string} name\n * Identifier to check.\n * @param {Options | null | undefined} [options]\n * Configuration (optional).\n * @returns {boolean}\n * Whether `name` can be an identifier.\n */\nexport function name(name, options) {\n const settings = options || emptyOptions\n const re = settings.jsx ? nameReJsx : nameRe\n return re.test(name)\n}\n","export function deprecate(fn) {\n return fn\n}\n\nexport function equal() {}\n\nexport function ok() {}\n\nexport function unreachable() {}\n","/**\n * @import {Node, Pattern} from 'estree'\n * @import {Scope, Visitors} from './types.js'\n */\n\nimport {ok as assert} from 'devlop'\n\n/**\n * Create state to track what’s defined.\n *\n * @returns {Visitors}\n * State.\n */\nexport function createVisitors() {\n /** @type {[topLevel: Scope, ...rest: Array<Scope>]} */\n const scopes = [{block: false, defined: []}]\n\n return {enter, exit, scopes}\n\n /**\n * @param {Node} node\n * Node.\n * @returns {undefined}\n * Nothing.\n */\n function enter(node) {\n // On arrow functions, create scope, add parameters.\n if (node.type === 'ArrowFunctionExpression') {\n scopes.push({block: false, defined: []})\n\n for (const parameter of node.params) {\n definePattern(parameter, false)\n }\n }\n // On block statements, create scope.\n // Not sure why `periscopic` only does `Block`/`For`/`ForIn`/`ForOf`.\n // I added `DoWhile`/`While` here just to be sure.\n else if (\n node.type === 'BlockStatement' ||\n node.type === 'DoWhileStatement' ||\n node.type === 'ForInStatement' ||\n node.type === 'ForOfStatement' ||\n node.type === 'ForStatement' ||\n node.type === 'WhileStatement'\n ) {\n scopes.push({block: true, defined: []})\n }\n\n // On catch clauses, create scope, add param.\n else if (node.type === 'CatchClause') {\n scopes.push({block: true, defined: []})\n if (node.param) definePattern(node.param, true)\n }\n\n // Add identifier of class declaration.\n else if (node.type === 'ClassDeclaration') {\n defineIdentifier(node.id.name, false)\n }\n\n // On function declarations, add name, create scope, add parameters.\n else if (node.type === 'FunctionDeclaration') {\n defineIdentifier(node.id.name, false)\n scopes.push({block: false, defined: []})\n\n for (const parameter of node.params) {\n definePattern(parameter, false)\n }\n }\n\n // On function expressions, add name, create scope, add parameters.\n else if (node.type === 'FunctionExpression') {\n if (node.id) defineIdentifier(node.id.name, false)\n scopes.push({block: false, defined: []})\n\n for (const parameter of node.params) {\n definePattern(parameter, false)\n }\n }\n\n // Add specifiers of import declarations.\n else if (node.type === 'ImportDeclaration') {\n for (const specifier of node.specifiers) {\n defineIdentifier(specifier.local.name, false)\n }\n }\n\n // Add patterns of variable declarations.\n else if (node.type === 'VariableDeclaration') {\n for (const declaration of node.declarations) {\n definePattern(declaration.id, node.kind !== 'var')\n }\n }\n }\n\n /**\n * @param {Node} node\n * Node.\n * @returns {undefined}\n * Nothing.\n */\n function exit(node) {\n if (\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression'\n ) {\n const scope = scopes.pop()\n assert(scope, 'expected scope')\n assert(!scope.block, 'expected non-block')\n } else if (\n node.type === 'BlockStatement' ||\n node.type === 'CatchClause' ||\n node.type === 'DoWhileStatement' ||\n node.type === 'ForInStatement' ||\n node.type === 'ForOfStatement' ||\n node.type === 'ForStatement' ||\n node.type === 'WhileStatement'\n ) {\n const scope = scopes.pop()\n assert(scope, 'expected scope')\n assert(scope.block, 'expected block')\n }\n }\n\n /**\n * Define an identifier in a scope.\n *\n * @param {string} id\n * @param {boolean} block\n * @returns {undefined}\n */\n function defineIdentifier(id, block) {\n let index = scopes.length\n /** @type {Scope | undefined} */\n let scope\n\n while (index--) {\n scope = scopes[index]\n\n if (block || !scope.block) {\n break\n }\n }\n\n assert(scope)\n scope.defined.push(id)\n }\n\n /**\n * Define a pattern in a scope.\n *\n * @param {Pattern} pattern\n * @param {boolean} block\n */\n function definePattern(pattern, block) {\n // `[, x]`\n if (pattern.type === 'ArrayPattern') {\n for (const element of pattern.elements) {\n if (element) {\n definePattern(element, block)\n }\n }\n }\n\n // `{x=y}`\n else if (pattern.type === 'AssignmentPattern') {\n definePattern(pattern.left, block)\n }\n\n // `x`\n else if (pattern.type === 'Identifier') {\n defineIdentifier(pattern.name, block)\n }\n\n // `{x}`\n else if (pattern.type === 'ObjectPattern') {\n for (const property of pattern.properties) {\n // `{key}`, `{key = value}`, `{key: value}`\n if (property.type === 'Property') {\n definePattern(property.value, block)\n }\n // `{...x}`\n else {\n assert(property.type === 'RestElement')\n definePattern(property, block)\n }\n }\n }\n\n // `...x`\n else {\n assert(pattern.type === 'RestElement')\n definePattern(pattern.argument, block)\n }\n }\n}\n","/**\n * @typedef { import('estree').Node} Node\n * @typedef {{\n * skip: () => void;\n * remove: () => void;\n * replace: (node: Node) => void;\n * }} WalkerContext\n */\n\nexport class WalkerBase {\n\tconstructor() {\n\t\t/** @type {boolean} */\n\t\tthis.should_skip = false;\n\n\t\t/** @type {boolean} */\n\t\tthis.should_remove = false;\n\n\t\t/** @type {Node | null} */\n\t\tthis.replacement = null;\n\n\t\t/** @type {WalkerContext} */\n\t\tthis.context = {\n\t\t\tskip: () => (this.should_skip = true),\n\t\t\tremove: () => (this.should_remove = true),\n\t\t\treplace: (node) => (this.replacement = node)\n\t\t};\n\t}\n\n\t/**\n\t * @template {Node} Parent\n\t * @param {Parent | null | undefined} parent\n\t * @param {keyof Parent | null | undefined} prop\n\t * @param {number | null | undefined} index\n\t * @param {Node} node\n\t */\n\treplace(parent, prop, index, node) {\n\t\tif (parent && prop) {\n\t\t\tif (index != null) {\n\t\t\t\t/** @type {Array<Node>} */ (parent[prop])[index] = node;\n\t\t\t} else {\n\t\t\t\t/** @type {Node} */ (parent[prop]) = node;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @template {Node} Parent\n\t * @param {Parent | null | undefined} parent\n\t * @param {keyof Parent | null | undefined} prop\n\t * @param {number | null | undefined} index\n\t */\n\tremove(parent, prop, index) {\n\t\tif (parent && prop) {\n\t\t\tif (index !== null && index !== undefined) {\n\t\t\t\t/** @type {Array<Node>} */ (parent[prop]).splice(index, 1);\n\t\t\t} else {\n\t\t\t\tdelete parent[prop];\n\t\t\t}\n\t\t}\n\t}\n}\n","import { WalkerBase } from './walker.js';\n\n/**\n * @typedef { import('estree').Node} Node\n * @typedef { import('./walker.js').WalkerContext} WalkerContext\n * @typedef {(\n * this: WalkerContext,\n * node: Node,\n * parent: Node | null,\n * key: string | number | symbol | null | undefined,\n * index: number | null | undefined\n * ) => void} SyncHandler\n */\n\nexport class SyncWalker extends WalkerBase {\n\t/**\n\t *\n\t * @param {SyncHandler} [enter]\n\t * @param {SyncHandler} [leave]\n\t */\n\tconstructor(enter, leave) {\n\t\tsuper();\n\n\t\t/** @type {boolean} */\n\t\tthis.should_skip = false;\n\n\t\t/** @type {boolean} */\n\t\tthis.should_remove = false;\n\n\t\t/** @type {Node | null} */\n\t\tthis.replacement = null;\n\n\t\t/** @type {WalkerContext} */\n\t\tthis.context = {\n\t\t\tskip: () => (this.should_skip = true),\n\t\t\tremove: () => (this.should_remove = true),\n\t\t\treplace: (node) => (this.replacement = node)\n\t\t};\n\n\t\t/** @type {SyncHandler | undefined} */\n\t\tthis.enter = enter;\n\n\t\t/** @type {SyncHandler | undefined} */\n\t\tthis.leave = leave;\n\t}\n\n\t/**\n\t * @template {Node} Parent\n\t * @param {Node} node\n\t * @param {Parent | null} parent\n\t * @param {keyof Parent} [prop]\n\t * @param {number | null} [index]\n\t * @returns {Node | null}\n\t */\n\tvisit(node, parent, prop, index) {\n\t\tif (node) {\n\t\t\tif (this.enter) {\n\t\t\t\tconst _should_skip = this.should_skip;\n\t\t\t\tconst _should_remove = this.should_remove;\n\t\t\t\tconst _replacement = this.replacement;\n\t\t\t\tthis.should_skip = false;\n\t\t\t\tthis.should_remove = false;\n\t\t\t\tthis.replacement = null;\n\n\t\t\t\tthis.enter.call(this.context, node, parent, prop, index);\n\n\t\t\t\tif (this.replacement) {\n\t\t\t\t\tnode = this.replacement;\n\t\t\t\t\tthis.replace(parent, prop, index, node);\n\t\t\t\t}\n\n\t\t\t\tif (this.should_remove) {\n\t\t\t\t\tthis.remove(parent, prop, index);\n\t\t\t\t}\n\n\t\t\t\tconst skipped = this.should_skip;\n\t\t\t\tconst removed = this.should_remove;\n\n\t\t\t\tthis.should_skip = _should_skip;\n\t\t\t\tthis.should_remove = _should_remove;\n\t\t\t\tthis.replacement = _replacement;\n\n\t\t\t\tif (skipped) return node;\n\t\t\t\tif (removed) return null;\n\t\t\t}\n\n\t\t\t/** @type {keyof Node} */\n\t\t\tlet key;\n\n\t\t\tfor (key in node) {\n\t\t\t\t/** @type {unknown} */\n\t\t\t\tconst value = node[key];\n\n\t\t\t\tif (value && typeof value === 'object') {\n\t\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t\tconst nodes = /** @type {Array<unknown>} */ (value);\n\t\t\t\t\t\tfor (let i = 0; i < nodes.length; i += 1) {\n\t\t\t\t\t\t\tconst item = nodes[i];\n\t\t\t\t\t\t\tif (isNode(item)) {\n\t\t\t\t\t\t\t\tif (!this.visit(item, node, key, i)) {\n\t\t\t\t\t\t\t\t\t// removed\n\t\t\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (isNode(value)) {\n\t\t\t\t\t\tthis.visit(value, node, key, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.leave) {\n\t\t\t\tconst _replacement = this.replacement;\n\t\t\t\tconst _should_remove = this.should_remove;\n\t\t\t\tthis.replacement = null;\n\t\t\t\tthis.should_remove = false;\n\n\t\t\t\tthis.leave.call(this.context, node, parent, prop, index);\n\n\t\t\t\tif (this.replacement) {\n\t\t\t\t\tnode = this.replacement;\n\t\t\t\t\tthis.replace(parent, prop, index, node);\n\t\t\t\t}\n\n\t\t\t\tif (this.should_remove) {\n\t\t\t\t\tthis.remove(parent, prop, index);\n\t\t\t\t}\n\n\t\t\t\tconst removed = this.should_remove;\n\n\t\t\t\tthis.replacement = _replacement;\n\t\t\t\tthis.should_remove = _should_remove;\n\n\t\t\t\tif (removed) return null;\n\t\t\t}\n\t\t}\n\n\t\treturn node;\n\t}\n}\n\n/**\n * Ducktype a node.\n *\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction isNode(value) {\n\treturn (\n\t\tvalue !== null && typeof value === 'object' && 'type' in value && typeof value.type === 'string'\n\t);\n}\n","import { SyncWalker } from './sync.js';\nimport { AsyncWalker } from './async.js';\n\n/**\n * @typedef {import('estree').Node} Node\n * @typedef {import('./sync.js').SyncHandler} SyncHandler\n * @typedef {import('./async.js').AsyncHandler} AsyncHandler\n */\n\n/**\n * @param {Node} ast\n * @param {{\n * enter?: SyncHandler\n * leave?: SyncHandler\n * }} walker\n * @returns {Node | null}\n */\nexport function walk(ast, { enter, leave }) {\n\tconst instance = new SyncWalker(enter, leave);\n\treturn instance.visit(ast, null);\n}\n\n/**\n * @param {Node} ast\n * @param {{\n * enter?: AsyncHandler\n * leave?: AsyncHandler\n * }} walker\n * @returns {Promise<Node | null>}\n */\nexport async function asyncWalk(ast, { enter, leave }) {\n\tconst instance = new AsyncWalker(enter, leave);\n\treturn await instance.visit(ast, null);\n}\n","import { name as isIdentifierName } from 'estree-util-is-identifier-name';\nimport { createVisitors } from 'estree-util-scope';\nimport { walk } from 'estree-walker';\n/**\n * @param program\n * The ESTree program to scan.\n * @param file\n * The {@link VFile} to emit warnings to.\n * @param variables\n * The variables that should be injected.\n * @param options\n * {@link define}.options\n * @returns\n * The position in the body where the export may be injected.\n */\nfunction scan(program, file, variables, options) {\n const visitors = createVisitors();\n const [scope] = visitors.scopes;\n const identifiers = new Map();\n let injectIndex = 0;\n walk(program, {\n enter(node, parent) {\n visitors.enter(node);\n switch (node.type) {\n case 'Identifier':\n if (scope.defined.includes(node.name) && !identifiers.has(node.name)) {\n identifiers.set(node.name, node);\n }\n break;\n case 'ArrowFunctionExpression':\n case 'ClassDeclaration':\n case 'ClassExpression':\n case 'FunctionExpression':\n case 'FunctionDeclaration':\n this.skip();\n break;\n // Don’t insert before directives.\n case 'ExpressionStatement':\n if (parent === program &&\n node.expression.type === 'Literal' &&\n typeof node.expression.value === 'string') {\n injectIndex = program.body.indexOf(node) + 1;\n }\n break;\n default:\n }\n },\n leave: visitors.exit\n });\n for (const name of scope.defined) {\n if (variables.has(name)) {\n if (options?.conflict !== 'skip') {\n const identifier = identifiers.get(name);\n const message = file.message(`Variable name conflict: ${name}`, {\n place: identifier?.loc,\n ruleId: 'conflict',\n source: 'unist-util-mdx-define'\n });\n message.url = 'https://github.com/remcohaszing/unist-util-mdx-define';\n if (options?.conflict !== 'warn') {\n message.fatal = true;\n throw message;\n }\n }\n variables.delete(name);\n }\n }\n return injectIndex;\n}\n/**\n * Generate an export named declaration.\n *\n * @param variables\n * The variables for which to generate an declaration.\n * @param options\n * {@link define} options\n * @param returnStatement\n * The return statement of the program to inject into.\n * @returns\n * The export named declaration.\n */\nfunction generate(variables, options, returnStatement) {\n if (options?.export === 'namespace') {\n const statements = [];\n for (const [name, right] of variables) {\n const isIdentifier = isIdentifierName(name);\n statements.push({\n type: 'ExpressionStatement',\n expression: {\n type: 'AssignmentExpression',\n left: {\n type: 'MemberExpression',\n computed: !isIdentifier,\n object: { type: 'Identifier', name: 'MDXContent' },\n optional: false,\n property: isIdentifier ? { type: 'Identifier', name } : { type: 'Literal', value: name }\n },\n operator: '=',\n right\n }\n });\n }\n return statements;\n }\n const declarations = [];\n for (const [name, init] of variables) {\n declarations.push({\n type: 'VariableDeclaration',\n kind: 'const',\n declarations: [\n {\n type: 'VariableDeclarator',\n id: { type: 'Identifier', name },\n init\n }\n ]\n });\n }\n if (options?.export === false) {\n return declarations;\n }\n if (!returnStatement) {\n return declarations.map((declaration) => ({\n type: 'ExportNamedDeclaration',\n declaration,\n specifiers: []\n }));\n }\n if (returnStatement.argument?.type === 'ObjectExpression') {\n returnStatement.argument.properties.splice(-1, 0, ...Array.from(variables.keys(), (name) => ({\n type: 'Property',\n computed: false,\n kind: 'init',\n method: false,\n shorthand: true,\n key: { type: 'Identifier', name },\n value: { type: 'Identifier', name }\n })));\n }\n return declarations;\n}\n/**\n * Define variables in an MDX related AST.\n *\n * @param ast\n * The AST in which to define an export\n * @param file\n * The {@link VFile} to emit warnings to.\n * @param variables\n * A mapping of variables to define. They keys are the names. The values are the ESTree expression\n * to represent them.\n * @param options\n * Additional options to configure behaviour.\n */\nexport function define(ast, file, variables, options) {\n const map = new Map(Object.entries(variables));\n if (options?.export !== 'namespace') {\n for (const name of map.keys()) {\n if (name === '_createMdxContent' ||\n name === '_Fragment' ||\n name === '_jsx' ||\n name === '_jsxs' ||\n name === '_missingMdxReference' ||\n name === 'MDXContent') {\n const message = file.message(`MDX internal name conflict: ${name}`, {\n ruleId: 'internal',\n source: 'unist-util-mdx-define'\n });\n message.url = 'https://github.com/remcohaszing/unist-util-mdx-define';\n message.fatal = true;\n throw message;\n }\n if (!isIdentifierName(name)) {\n const message = file.message(`Invalid identifier name: ${name}`, {\n ruleId: 'invalid-identifier',\n source: 'unist-util-mdx-define'\n });\n message.url = 'https://github.com/remcohaszing/unist-util-mdx-define';\n message.fatal = true;\n throw message;\n }\n }\n }\n if (ast.type === 'root') {\n for (const child of ast.children) {\n if (child.type !== 'mdxjsEsm') {\n continue;\n }\n const program = child.data?.estree;\n /* c8 ignore start */\n if (!program) {\n continue;\n }\n /* c8 ignore stop */\n scan(program, file, map, options);\n }\n if (map.size) {\n ast.children.unshift({\n type: 'mdxjsEsm',\n value: '',\n data: {\n estree: {\n type: 'Program',\n sourceType: 'module',\n body: generate(map, options)\n }\n }\n });\n }\n }\n else {\n const returnStatement = ast.body.find((node) => node.type === 'ReturnStatement');\n const injectIndex = scan(ast, file, map, options);\n if (map.size) {\n ast.body.splice(injectIndex, 0, ...generate(map, options, returnStatement));\n }\n }\n}\n//# sourceMappingURL=unist-util-mdx-define.js.map","/**\n * Remark plugin that extracts headings from MDX and exports them as `toc`.\n *\n * Adds `export const toc = [...]` to the MDX module, similar to how\n * `remark-mdx-frontmatter` exports frontmatter.\n */\nimport type { Heading, Root } from \"mdast\"\n\nimport { valueToEstree } from \"estree-util-value-to-estree\"\nimport { define } from \"unist-util-mdx-define\"\nimport { visit } from \"unist-util-visit\"\n\nimport type { TOCItem } from \"../config/types\"\n\ninterface RemarkMdxTocOptions {\n /** Export name (default: \"toc\") */\n name?: string\n /** Heading levels to include (default: [2, 3]) */\n levels?: [number, number]\n}\n\nexport function remarkMdxToc(options: RemarkMdxTocOptions = {}) {\n const { name = \"toc\", levels = [2, 3] } = options\n const [minLevel, maxLevel] = levels\n\n return function (tree: Root, file: unknown) {\n const items: TOCItem[] = []\n let headingIndex = 0\n\n visit(tree, \"heading\", (node: Heading) => {\n if (node.depth < minLevel || node.depth > maxLevel) return\n\n const text = getHeadingText(node)\n const slug = slugify(text)\n const id = slug === \"\" ? `heading-${String(headingIndex)}` : slug\n headingIndex++\n\n items.push({ id, text, level: node.depth })\n\n // Add id to the heading node for anchor links\n const data = node.data ?? (node.data = {})\n const hProperties = (data.hProperties ?? (data.hProperties = {})) as Record<string, string>\n hProperties.id = id\n })\n\n // Use the same approach as remark-mdx-frontmatter: valueToEstree + define\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n define(tree, file as any, { [name]: valueToEstree(items) })\n }\n}\n\nfunction getHeadingText(node: Heading): string {\n const parts: string[] = []\n\n function extract(child: unknown) {\n if (typeof child !== \"object\" || child === null) return\n const typed = child as { type?: string; value?: string; children?: unknown[] }\n if (typed.type === \"text\" || typed.type === \"inlineCode\") {\n parts.push(typed.value ?? \"\")\n } else if (Array.isArray(typed.children)) {\n for (const nested of typed.children) extract(nested)\n }\n }\n\n for (const child of node.children) extract(child)\n return parts.join(\"\")\n}\n\nfunction slugify(text: string): string {\n let slug = text\n .toLowerCase()\n .trim()\n .replaceAll(/[^\\s\\w-]/g, \"\")\n .replaceAll(/[\\s_]/g, \"-\")\n\n while (slug.includes(\"--\")) {\n slug = slug.replaceAll(\"--\", \"-\")\n }\n\n return slug.replaceAll(/^-|-$/g, \"\")\n}\n","/**\n * Recma plugin that wraps the MDX default export with ArdoPageDataProvider\n * to inject frontmatter + toc into the React context for TOC and content.\n */\n\n// eslint-disable-next-line @cspell/spellchecker\ninterface EstreeProgram {\n type: string\n body: EstreeNode[]\n}\n\ninterface EstreeNode {\n type: string\n declaration?: EstreeNode\n id?: { type?: string; name: string }\n [key: string]: unknown\n}\n\nfunction findDefaultExport(body: EstreeNode[]): { index: number; name: string } {\n for (let i = 0; i < body.length; i++) {\n const node = body[i]\n if (\n node.type === \"ExportDefaultDeclaration\" &&\n node.declaration?.type === \"FunctionDeclaration\" &&\n node.declaration.id?.name !== undefined &&\n node.declaration.id.name !== \"\"\n ) {\n return { index: i, name: node.declaration.id.name }\n }\n }\n return { index: -1, name: \"\" }\n}\n\nfunction createImport(imported: string, local: string, source: string): EstreeNode {\n return {\n type: \"ImportDeclaration\",\n specifiers: [\n {\n type: \"ImportSpecifier\",\n imported: { type: \"Identifier\", name: imported },\n local: { type: \"Identifier\", name: local },\n },\n ],\n source: { type: \"Literal\", value: source },\n }\n}\n\nfunction createShorthandProp(name: string): EstreeNode {\n return {\n type: \"Property\",\n key: { type: \"Identifier\", name },\n value: { type: \"Identifier\", name },\n kind: \"init\",\n shorthand: true,\n computed: false,\n method: false,\n }\n}\n\nfunction createWrapperFunction(fnName: string): EstreeNode {\n return {\n type: \"FunctionDeclaration\",\n id: { type: \"Identifier\", name: \"_ArdoWrapped\" },\n params: [{ type: \"Identifier\", name: \"props\" }],\n body: {\n type: \"BlockStatement\",\n body: [\n {\n type: \"ReturnStatement\",\n argument: {\n type: \"CallExpression\",\n callee: { type: \"Identifier\", name: \"_ardoJsx\" },\n arguments: [\n { type: \"Identifier\", name: \"_ArdoPageDP\" },\n {\n type: \"ObjectExpression\",\n properties: [\n createShorthandProp(\"frontmatter\"),\n createShorthandProp(\"toc\"),\n {\n type: \"Property\",\n key: { type: \"Identifier\", name: \"children\" },\n value: {\n type: \"CallExpression\",\n callee: { type: \"Identifier\", name: \"_ardoJsx\" },\n arguments: [\n { type: \"Identifier\", name: fnName },\n { type: \"Identifier\", name: \"props\" },\n ],\n optional: false,\n },\n kind: \"init\",\n shorthand: false,\n computed: false,\n method: false,\n },\n ],\n },\n ],\n optional: false,\n },\n },\n ],\n },\n generator: false,\n async: false,\n }\n}\n\n// eslint-disable-next-line @cspell/spellchecker\nexport function recmaWrapExport() {\n return (tree: EstreeProgram) => {\n const { index, name } = findDefaultExport(tree.body)\n if (index === -1) return\n\n // Remove `export default` — keep just the function declaration\n const decl = tree.body[index].declaration\n if (decl == null) return\n tree.body[index] = decl\n\n // Add imports, wrapper, and new default export\n tree.body.unshift(\n createImport(\"ArdoPageDataProvider\", \"_ArdoPageDP\", \"ardo/runtime\"),\n createImport(\"jsx\", \"_ardoJsx\", \"react/jsx-runtime\")\n )\n tree.body.push(createWrapperFunction(name), {\n type: \"ExportDefaultDeclaration\",\n declaration: { type: \"Identifier\", name: \"_ArdoWrapped\" },\n })\n }\n}\n","import type { Plugin } from \"vite\"\n\nimport mdx from \"@mdx-js/rollup\"\nimport { reactRouter } from \"@react-router/dev/vite\"\nimport rehypeShiki from \"@shikijs/rehype\"\nimport remarkFrontmatter from \"remark-frontmatter\"\nimport remarkGfm from \"remark-gfm\"\nimport remarkMdxFrontmatter from \"remark-mdx-frontmatter\"\n\nimport type { ArdoConfig } from \"../config/types\"\n\nimport { defaultMarkdownConfig } from \"../config/index\"\nimport { remarkMdxToc } from \"../markdown/remark-mdx-toc\"\nimport { ardoLineTransformer, remarkCodeMeta } from \"../markdown/shiki\"\nimport { recmaWrapExport } from \"./recma-wrap-export\"\n\nexport function createMdxPlugin(markdownConfig: ArdoConfig[\"markdown\"]): Plugin {\n const themeConfig = markdownConfig?.theme ?? defaultMarkdownConfig.theme\n const lineNumbers = markdownConfig?.lineNumbers ?? false\n const shikiOptions = isShikiThemeObject(themeConfig)\n ? {\n themes: { light: themeConfig.light, dark: themeConfig.dark },\n defaultColor: false as const,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n : {\n theme: themeConfig,\n transformers: [ardoLineTransformer({ globalLineNumbers: lineNumbers })],\n }\n\n return mdx({\n include: /\\.(md|mdx)$/,\n remarkPlugins: [\n remarkFrontmatter,\n [remarkMdxFrontmatter, { name: \"frontmatter\" }],\n remarkGfm,\n remarkCodeMeta,\n [remarkMdxToc, { levels: markdownConfig?.toc?.level ?? [2, 3] }],\n ],\n rehypePlugins: [[rehypeShiki, shikiOptions]],\n recmaPlugins: [recmaWrapExport],\n providerImportSource: \"ardo/mdx-provider\",\n }) as Plugin\n}\n\nexport function getReactRouterPlugins(): Plugin[] {\n const routerPlugin = reactRouter()\n return Array.isArray(routerPlugin) ? routerPlugin : [routerPlugin]\n}\n\nfunction isShikiThemeObject(themeConfig: unknown): themeConfig is { dark: string; light: string } {\n return (\n typeof themeConfig === \"object\" &&\n themeConfig != null &&\n \"light\" in themeConfig &&\n \"dark\" in themeConfig\n )\n}\n","import fs from \"node:fs\"\nimport path from \"node:path\"\n\nimport type { ProjectMeta } from \"../config/types\"\n\ninterface PackageJsonShape {\n author?: { name?: string } | string\n homepage?: string\n license?: string\n name?: string\n repository?: { url?: string } | string\n version?: string\n}\n\n/**\n * Reads project metadata from package.json.\n */\nexport function readProjectMeta(root: string): ProjectMeta {\n const packageJsonPath = path.join(root, \"package.json\")\n\n try {\n const rawPackageJson = fs.readFileSync(packageJsonPath, \"utf8\")\n const parsedPackageJson: unknown = JSON.parse(rawPackageJson)\n if (!isPackageJsonShape(parsedPackageJson)) {\n return {}\n }\n\n const repository = extractRepository(parsedPackageJson.repository)\n const author = extractAuthor(parsedPackageJson.author)\n\n return {\n name: parsedPackageJson.name,\n homepage: parsedPackageJson.homepage,\n repository,\n version: parsedPackageJson.version,\n author,\n license: parsedPackageJson.license,\n }\n } catch {\n return {}\n }\n}\n\nfunction extractRepository(repository: PackageJsonShape[\"repository\"]): string | undefined {\n if (typeof repository === \"string\") {\n return normalizeRepository(repository)\n }\n\n if (repository == null || typeof repository.url !== \"string\") {\n return undefined\n }\n\n return normalizeRepository(repository.url)\n}\n\nfunction extractAuthor(author: PackageJsonShape[\"author\"]): string | undefined {\n if (typeof author === \"string\") {\n return author\n }\n\n if (author == null || typeof author.name !== \"string\") {\n return undefined\n }\n\n return author.name\n}\n\nfunction normalizeRepository(repository: string): string {\n return repository\n .replace(/^git\\+/, \"\")\n .replace(/^git:\\/\\//, \"https://\")\n .replace(/\\.git$/, \"\")\n}\n\nfunction isPackageJsonShape(value: unknown): value is PackageJsonShape {\n return typeof value === \"object\" && value != null\n}\n","import fsSync from \"node:fs\"\nimport fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nexport interface RouteInfo {\n /** File path relative to app directory (e.g., \"routes/guide/getting-started.mdx\") */\n file: string\n /** True if this is an index route */\n isIndex?: boolean\n /** URL path (e.g., \"/guide/getting-started\") */\n path: string\n}\n\nexport function scanRoutesSync(params: { dir: string; rootDir: string }): RouteInfo[] {\n const { dir, rootDir } = params\n const routes: RouteInfo[] = []\n const entries = readDirectoryEntries(dir)\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n routes.push(...scanRoutesSync({ dir: fullPath, rootDir }))\n continue\n }\n\n const route = createRouteInfo({ entryName: entry.name, fullPath, rootDir })\n if (route != null) {\n routes.push(route)\n }\n }\n\n return routes\n}\n\nfunction readDirectoryEntries(dir: string): fsSync.Dirent[] {\n try {\n return fsSync.readdirSync(dir, { withFileTypes: true })\n } catch {\n return []\n }\n}\n\nfunction createRouteInfo(params: {\n entryName: string\n fullPath: string\n rootDir: string\n}): null | RouteInfo {\n const { entryName, fullPath, rootDir } = params\n if (!isRouteFile(entryName) || isIgnoredRouteFile(entryName)) {\n return null\n }\n\n const extension = getRouteExtension(entryName)\n if (extension == null) {\n return null\n }\n\n const relativePath = path.relative(rootDir, fullPath)\n const baseName = entryName.replace(extension, \"\")\n const urlPath = toRoutePath({\n baseName,\n extension,\n relativePath,\n })\n\n return {\n file: `routes/${relativePath.replaceAll(\"\\\\\", \"/\")}`,\n isIndex: isIndexRoute(baseName),\n path: urlPath,\n }\n}\n\nfunction isRouteFile(entryName: string): boolean {\n return entryName.endsWith(\".md\") || entryName.endsWith(\".mdx\") || entryName.endsWith(\".tsx\")\n}\n\nfunction isIgnoredRouteFile(entryName: string): boolean {\n return entryName === \"root.tsx\" || entryName.startsWith(\"_\")\n}\n\nfunction getRouteExtension(entryName: string): \".md\" | \".mdx\" | \".tsx\" | null {\n if (entryName.endsWith(\".mdx\")) {\n return \".mdx\"\n }\n\n if (entryName.endsWith(\".md\")) {\n return \".md\"\n }\n\n if (entryName.endsWith(\".tsx\")) {\n return \".tsx\"\n }\n\n return null\n}\n\nfunction toRoutePath(params: {\n baseName: string\n extension: \".md\" | \".mdx\" | \".tsx\"\n relativePath: string\n}): string {\n const { baseName, extension, relativePath } = params\n\n if (isIndexRoute(baseName)) {\n const parentDir = path.dirname(relativePath)\n const normalizedParent = parentDir === \".\" ? \"\" : parentDir.replaceAll(\"\\\\\", \"/\")\n return applyDynamicSegments(`/${normalizedParent}`)\n }\n\n const withoutExtension = relativePath.replace(extension, \"\")\n return applyDynamicSegments(`/${withoutExtension.replaceAll(\"\\\\\", \"/\")}`)\n}\n\nfunction isIndexRoute(baseName: string): boolean {\n return baseName === \"index\" || baseName === \"home\"\n}\n\nfunction applyDynamicSegments(urlPath: string): string {\n return urlPath.replaceAll(/\\$(\\w+)/gu, \":$1\")\n}\n\nexport function generateRoutesFile(routes: RouteInfo[]): string {\n const sortedRoutes = sortRoutes(routes)\n const entries = sortedRoutes.map((routeInfo) => renderRouteEntry(routeInfo))\n\n return `// AUTO-GENERATED by Ardo - Do not edit manually\n\nimport { type RouteConfig, route, index } from \"@react-router/dev/routes\"\n\nexport default [\n${entries.join(\"\\n\")}\n] satisfies RouteConfig\n`\n}\n\nfunction sortRoutes(routes: RouteInfo[]): RouteInfo[] {\n return [...routes].sort((left, right) => {\n if (left.path === \"/\" && right.path !== \"/\") {\n return -1\n }\n\n if (right.path === \"/\" && left.path !== \"/\") {\n return 1\n }\n\n if (left.isIndex && !right.isIndex) {\n return -1\n }\n\n if (right.isIndex && !left.isIndex) {\n return 1\n }\n\n return left.path.localeCompare(right.path)\n })\n}\n\nfunction renderRouteEntry(routeInfo: RouteInfo): string {\n if (routeInfo.path === \"/\") {\n return ` index(\"${routeInfo.file}\"),`\n }\n\n const routePath = routeInfo.path.slice(1)\n return ` route(\"${routePath}\", \"${routeInfo.file}\"),`\n}\n\nexport function writeRoutesFileSync(params: {\n appDir: string\n routesDir: string\n routesFilePath: string\n}): void {\n const { appDir, routesDir, routesFilePath } = params\n const routes = scanRoutesSync({ dir: routesDir, rootDir: routesDir })\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n const hasChanges = hasRoutesContentChangedSync(routesFilePath, content)\n if (!hasChanges) {\n return\n }\n\n fsSync.mkdirSync(appDir, { recursive: true })\n fsSync.writeFileSync(routesFilePath, content, \"utf8\")\n console.log(`[ardo] Generated routes.ts with ${routes.length} routes`)\n}\n\nfunction hasRoutesContentChangedSync(routesFilePath: string, nextContent: string): boolean {\n try {\n const existing = fsSync.readFileSync(routesFilePath, \"utf8\")\n return existing !== nextContent\n } catch {\n return true\n }\n}\n\nexport async function writeRoutesFile(params: {\n appDir: string\n routesDir: string\n routesFilePath: string\n}): Promise<void> {\n const { appDir, routesDir, routesFilePath } = params\n const routes = scanRoutesSync({ dir: routesDir, rootDir: routesDir })\n if (routes.length === 0) {\n return\n }\n\n const content = generateRoutesFile(routes)\n const hasChanges = await hasRoutesContentChanged(routesFilePath, content)\n if (!hasChanges) {\n return\n }\n\n await fs.mkdir(appDir, { recursive: true })\n await fs.writeFile(routesFilePath, content, \"utf8\")\n}\n\nasync function hasRoutesContentChanged(\n routesFilePath: string,\n nextContent: string\n): Promise<boolean> {\n try {\n const existing = await fs.readFile(routesFilePath, \"utf8\")\n return existing !== nextContent\n } catch {\n return true\n }\n}\n","import type { Plugin } from \"vite\"\n\nimport path from \"node:path\"\n\nimport { writeRoutesFile, writeRoutesFileSync } from \"./routes-core\"\n\nexport interface ArdoRoutesPluginOptions {\n /** Directory where routes are located (default: \"./app/routes\") */\n routesDir?: string\n}\n\ninterface ResolvedRoutePaths {\n appDir: string\n routesDir: string\n routesFilePath: string\n}\n\n/**\n * Vite plugin that generates routes.ts for React Router Framework Mode.\n */\nexport function ardoRoutesPlugin(options: ArdoRoutesPluginOptions = {}): Plugin {\n let paths = createDefaultPaths(process.cwd(), options)\n\n return {\n name: \"ardo:routes\",\n enforce: \"pre\",\n\n config(userConfig) {\n const root = userConfig.root ?? process.cwd()\n paths = createDefaultPaths(root, options)\n\n try {\n writeRoutesFileSync(paths)\n } catch (error) {\n console.warn(\"[ardo] Could not generate routes.ts in config phase:\", error)\n }\n },\n\n configResolved(resolvedConfig) {\n paths = createDefaultPaths(resolvedConfig.root, options)\n },\n\n async buildStart() {\n await writeRoutesFile(paths)\n },\n\n configureServer(server) {\n server.watcher.add(paths.routesDir)\n\n const handleChange = (changedPath: string) => {\n if (shouldHandleRouteChange(changedPath, paths.routesDir)) {\n void writeRoutesFile(paths)\n }\n }\n\n server.watcher.on(\"add\", handleChange)\n server.watcher.on(\"unlink\", handleChange)\n },\n }\n}\n\nfunction createDefaultPaths(root: string, options: ArdoRoutesPluginOptions): ResolvedRoutePaths {\n const appDir = path.join(root, \"app\")\n const routesDir = options.routesDir ?? path.join(appDir, \"routes\")\n const routesFilePath = path.join(appDir, \"routes.ts\")\n return { appDir, routesDir, routesFilePath }\n}\n\nfunction shouldHandleRouteChange(changedPath: string, routesDir: string): boolean {\n if (!changedPath.startsWith(routesDir)) {\n return false\n }\n\n return changedPath.endsWith(\".md\") || changedPath.endsWith(\".mdx\") || changedPath.endsWith(\".tsx\")\n}\n","import type { Dirent } from \"node:fs\"\n\nimport matter from \"gray-matter\"\nimport fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\nexport interface SearchDoc {\n id: string\n title: string\n content: string\n path: string\n section?: string\n}\n\ninterface SearchScanContext {\n docs: SearchDoc[]\n routesDir: string\n}\n\ninterface SearchDocBuildContext {\n routesDir: string\n section?: string\n}\n\ninterface SearchEntryContext {\n dir: string\n section?: string\n scanContext: SearchScanContext\n}\n\nexport async function generateSearchIndex(routesDir: string): Promise<SearchDoc[]> {\n const context: SearchScanContext = { docs: [], routesDir }\n await scanDirectoryForSearch(routesDir, undefined, context)\n return context.docs\n}\n\nasync function scanDirectoryForSearch(\n dir: string,\n section: string | undefined,\n context: SearchScanContext\n): Promise<void> {\n let entries: Dirent[]\n\n try {\n entries = await fs.readdir(dir, { withFileTypes: true })\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error)\n console.warn(\"[ardo] Failed to scan for search index:\", errorMessage)\n return\n }\n\n for (const entry of entries) {\n await processSearchEntry(entry, { dir, section, scanContext: context })\n }\n}\n\nasync function processSearchEntry(entry: Dirent, context: SearchEntryContext): Promise<void> {\n const fullPath = path.join(context.dir, entry.name)\n if (entry.isDirectory()) {\n const nestedSection = createNestedSection(context.section, entry.name)\n await scanDirectoryForSearch(fullPath, nestedSection, context.scanContext)\n return\n }\n\n if (entry.name.endsWith(\".mdx\") || entry.name.endsWith(\".md\")) {\n const doc = await createSearchDocFromFile(entry.name, fullPath, {\n routesDir: context.scanContext.routesDir,\n section: context.section,\n })\n if (doc != null) {\n context.scanContext.docs.push(doc)\n }\n }\n}\n\nasync function createSearchDocFromFile(\n fileName: string,\n filePath: string,\n context: SearchDocBuildContext\n): Promise<null | SearchDoc> {\n const fileContent = await fs.readFile(filePath, \"utf8\")\n const parsed = matter(fileContent)\n const extension = fileName.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const title =\n typeof parsed.data.title === \"string\"\n ? parsed.data.title\n : formatTitle(fileName.replace(extension, \"\"))\n\n const relativePath = path.relative(context.routesDir, filePath)\n const routePath = buildRoutePath(relativePath, fileName, extension)\n const content = sanitizeSearchContent(parsed.content)\n\n return {\n id: relativePath,\n title,\n content,\n path: routePath,\n section: context.section,\n }\n}\n\nfunction sanitizeSearchContent(content: string): string {\n const withoutCodeFences = removeCodeFences(content)\n const withoutImportLines = removeImportLines(withoutCodeFences)\n const normalizedText = replacePunctuationWithSpaces(withoutImportLines)\n const collapsedWhitespace = collapseWhitespace(normalizedText)\n return collapsedWhitespace.slice(0, 2000)\n}\n\nfunction removeCodeFences(content: string): string {\n const lines = content.split(\"\\n\")\n const keptLines: string[] = []\n let isInsideFence = false\n\n for (const line of lines) {\n if (line.trimStart().startsWith(\"```\")) {\n isInsideFence = !isInsideFence\n continue\n }\n\n if (!isInsideFence) {\n keptLines.push(line)\n }\n }\n\n return keptLines.join(\"\\n\")\n}\n\nfunction removeImportLines(content: string): string {\n const lines = content.split(\"\\n\")\n const keptLines: string[] = []\n\n for (const line of lines) {\n if (!line.trimStart().startsWith(\"import \")) {\n keptLines.push(line)\n }\n }\n\n return keptLines.join(\"\\n\")\n}\n\nfunction replacePunctuationWithSpaces(content: string): string {\n let normalized = content\n for (const token of [\"`\", \"#\", \"*\", \"_\", \"~\", \"[\", \"]\", \"(\", \")\", \"<\", \">\", \"|\", \"!\"]) {\n normalized = normalized.replaceAll(token, \" \")\n }\n\n return normalized\n}\n\nfunction collapseWhitespace(content: string): string {\n let result = \"\"\n let previousWasSpace = false\n\n for (const character of content) {\n const isSpace =\n character === \" \" || character === \"\\n\" || character === \"\\t\" || character === \"\\r\"\n if (isSpace) {\n if (!previousWasSpace) {\n result += \" \"\n }\n previousWasSpace = true\n continue\n }\n\n result += character\n previousWasSpace = false\n }\n\n return result.trim()\n}\n\nfunction buildRoutePath(relativePath: string, fileName: string, extension: string): string {\n if (fileName === \"index.mdx\" || fileName === \"index.md\") {\n const directoryPath = path.dirname(relativePath).replaceAll(\"\\\\\", \"/\")\n return directoryPath === \".\" ? \"/\" : `/${directoryPath}`\n }\n\n return `/${relativePath.replace(extension, \"\").replaceAll(\"\\\\\", \"/\")}`\n}\n\nfunction createNestedSection(section: string | undefined, directoryName: string): string {\n const currentTitle = formatTitle(directoryName)\n return section != null ? `${section} > ${currentTitle}` : currentTitle\n}\n\nfunction formatTitle(name: string): string {\n return name.replaceAll(/[_-]/g, \" \").replaceAll(/\\b\\w/g, (char) => char.toUpperCase())\n}\n","import type { Dirent } from \"node:fs\"\n\nimport matter from \"gray-matter\"\nimport fs from \"node:fs/promises\"\nimport path from \"node:path\"\n\ninterface SidebarNode {\n text: string\n link?: string\n items?: SidebarNode[]\n order?: number\n}\n\nexport interface SidebarItem {\n text: string\n link?: string\n items?: SidebarItem[]\n}\n\nexport async function generateSidebar(routesDir: string): Promise<SidebarItem[]> {\n try {\n const nodes = await scanSidebarDirectory(routesDir, routesDir)\n return nodes.map((node) => stripOrderFromNode(node))\n } catch {\n return []\n }\n}\n\nasync function scanSidebarDirectory(dir: string, rootDir: string): Promise<SidebarNode[]> {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n const nodes: SidebarNode[] = []\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n const relativePath = path.relative(rootDir, fullPath)\n\n if (entry.isDirectory()) {\n const directoryNode = await createDirectoryNode(entry, fullPath, rootDir)\n if (directoryNode != null) {\n nodes.push(directoryNode)\n }\n continue\n }\n\n const fileNode = await createMarkdownNode(entry, fullPath, relativePath)\n if (fileNode != null) {\n nodes.push(fileNode)\n }\n }\n\n sortNodes(nodes)\n return nodes\n}\n\nasync function createDirectoryNode(\n entry: Dirent,\n fullPath: string,\n rootDir: string\n): Promise<null | SidebarNode> {\n const relativePath = path.relative(rootDir, fullPath)\n const children = await scanSidebarDirectory(fullPath, rootDir)\n if (children.length === 0) {\n return null\n }\n\n const indexPath = path.join(fullPath, \"index.mdx\")\n const link = (await fileExists(indexPath)) ? `/${relativePath.replaceAll(\"\\\\\", \"/\")}` : undefined\n\n return {\n text: formatTitle(entry.name),\n link,\n items: children,\n }\n}\n\nasync function createMarkdownNode(\n entry: Dirent,\n fullPath: string,\n relativePath: string\n): Promise<null | SidebarNode> {\n if (!isSidebarMarkdownFile(entry.name)) {\n return null\n }\n\n const extension = entry.name.endsWith(\".mdx\") ? \".mdx\" : \".md\"\n const fileContent = await fs.readFile(fullPath, \"utf8\")\n const frontmatter = readFrontmatter(fileContent)\n\n const title = frontmatter.title ?? formatTitle(entry.name.replace(extension, \"\"))\n const link = `/${relativePath.replace(extension, \"\").replaceAll(\"\\\\\", \"/\")}`\n\n return {\n text: title,\n link,\n order: frontmatter.order,\n }\n}\n\nfunction readFrontmatter(fileContent: string): { order?: number; title?: string } {\n const parsed = matter(fileContent)\n const title = typeof parsed.data.title === \"string\" ? parsed.data.title : undefined\n const order = typeof parsed.data.order === \"number\" ? parsed.data.order : undefined\n return { title, order }\n}\n\nfunction sortNodes(nodes: SidebarNode[]): void {\n nodes.sort((leftNode, rightNode) => {\n if (leftNode.order != null && rightNode.order != null) {\n return leftNode.order - rightNode.order\n }\n\n if (leftNode.order != null) {\n return -1\n }\n\n if (rightNode.order != null) {\n return 1\n }\n\n return leftNode.text.localeCompare(rightNode.text)\n })\n}\n\nfunction isSidebarMarkdownFile(fileName: string): boolean {\n const isMarkdownFile = fileName.endsWith(\".mdx\") || fileName.endsWith(\".md\")\n const isIndexFile = fileName === \"index.mdx\" || fileName === \"index.md\"\n return isMarkdownFile && !isIndexFile\n}\n\nfunction formatTitle(name: string): string {\n return name.replaceAll(/[_-]/g, \" \").replaceAll(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\nfunction stripOrderFromNode(node: SidebarNode): SidebarItem {\n return {\n text: node.text,\n link: node.link,\n items: node.items?.map((item) => stripOrderFromNode(item)),\n }\n}\n\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath)\n return true\n } catch {\n return false\n }\n}\n","import type { Plugin, UserConfig } from \"vite\"\n\nimport { vanillaExtractPlugin } from \"@vanilla-extract/vite-plugin\"\nimport path from \"node:path\"\n\nimport type { ArdoConfig, ProjectMeta, ResolvedConfig } from \"../config/types\"\nimport type { TypeDocConfig } from \"../typedoc/types\"\n\nimport { resolveConfig } from \"../config/index\"\nimport { generateApiDocs } from \"../typedoc/generator\"\nimport { ardoCodeBlockPlugin } from \"./codeblock-plugin\"\nimport { createFlattenPlugin } from \"./flatten-plugin\"\nimport {\n detectGitHash,\n detectGitHubBasename,\n detectGitHubRepoName,\n findPackageRoot,\n} from \"./git-utils\"\nimport { createMdxPlugin, getReactRouterPlugins } from \"./mdx-plugin\"\nimport { readProjectMeta } from \"./project-meta\"\nimport { ardoRoutesPlugin, type ArdoRoutesPluginOptions } from \"./routes-plugin\"\nimport { generateSearchIndex } from \"./search-index\"\nimport { generateSidebar } from \"./sidebar-index\"\n\nconst VIRTUAL_MODULE_ID = \"virtual:ardo/config\"\nconst VIRTUAL_SIDEBAR_ID = \"virtual:ardo/sidebar\"\nconst VIRTUAL_SEARCH_ID = \"virtual:ardo/search-index\"\nconst RESOLVED_IDS: Record<string, string> = {\n [VIRTUAL_MODULE_ID]: `\\0${VIRTUAL_MODULE_ID}`,\n [VIRTUAL_SIDEBAR_ID]: `\\0${VIRTUAL_SIDEBAR_ID}`,\n [VIRTUAL_SEARCH_ID]: `\\0${VIRTUAL_SEARCH_ID}`,\n}\n\nlet typedocGenerated = false\n\ninterface PluginState {\n resolvedConfig?: ResolvedConfig\n routesDir: string\n}\n\ninterface MainPluginOptions {\n githubPages: boolean\n pressConfig: PressConfigOptions\n routesDirOption: string | undefined\n}\n\ntype PressConfigOptions = Omit<\n ArdoPluginOptions,\n \"githubPages\" | \"routes\" | \"routesDir\" | \"typedoc\"\n>\n\nexport interface ArdoPluginOptions extends Partial<ArdoConfig> {\n /** Options for the routes generator plugin */\n routes?: ArdoRoutesPluginOptions | false\n /**\n * Auto-detect GitHub repository and set base path for GitHub Pages.\n * @default true\n */\n githubPages?: boolean\n /**\n * Directory where routes are located.\n * @default \"./app/routes\"\n */\n routesDir?: string\n}\n\nexport { detectGitHubBasename }\n\nexport function ardoPlugin(options: ArdoPluginOptions = {}): Plugin[] {\n const {\n routes,\n typedoc,\n githubPages = true,\n routesDir: routesDirOption,\n ...pressConfig\n } = options\n const state: PluginState = { routesDir: resolveRoutesDir(process.cwd(), routesDirOption) }\n\n const mainPluginOptions: MainPluginOptions = { githubPages, pressConfig, routesDirOption }\n const plugins: Plugin[] = [createMainPlugin(state, mainPluginOptions)]\n addRoutesPlugin(plugins, routes, routesDirOption)\n addTypeDocPlugin(plugins, typedoc, state)\n\n plugins.push(ardoCodeBlockPlugin(pressConfig.markdown))\n plugins.push(createMdxPlugin(pressConfig.markdown))\n plugins.push(...vanillaExtractPlugin({ identifiers: \"short\" }))\n plugins.push(...getReactRouterPlugins())\n\n if (githubPages) {\n plugins.push(createFlattenPlugin())\n }\n\n return plugins\n}\n\nfunction addRoutesPlugin(\n plugins: Plugin[],\n routes: ArdoPluginOptions[\"routes\"],\n routesDirOption: string | undefined\n): void {\n if (routes === false) {\n return\n }\n\n const routePluginOptions = routes ?? {}\n plugins.push(ardoRoutesPlugin({ routesDir: routesDirOption, ...routePluginOptions }))\n}\n\nfunction addTypeDocPlugin(\n plugins: Plugin[],\n typedoc: ArdoPluginOptions[\"typedoc\"],\n state: PluginState\n): void {\n const typedocConfig = resolveTypedocConfig(typedoc)\n if (typedocConfig != null) {\n plugins.unshift(createTypeDocPlugin(typedocConfig, state))\n }\n}\n\nfunction createMainPlugin(state: PluginState, options: MainPluginOptions): Plugin {\n return {\n name: \"ardo\",\n enforce: \"pre\",\n config(userConfig, env): UserConfig {\n return createMainConfig(state, {\n userConfig,\n command: env.command,\n githubPages: options.githubPages,\n routesDirOption: options.routesDirOption,\n })\n },\n configResolved(config) {\n state.routesDir = resolveRoutesDir(config.root, options.routesDirOption)\n state.resolvedConfig = resolveArdoConfig(config.root, state.routesDir, options.pressConfig)\n },\n resolveId(id) {\n return resolveVirtualModuleId(id)\n },\n async load(id) {\n return loadVirtualModule(id, state)\n },\n transform(code, id) {\n return transformMarkdownMeta(code, id, state)\n },\n }\n}\n\nfunction createMainConfig(\n state: PluginState,\n input: {\n command: string\n githubPages: boolean\n routesDirOption: string | undefined\n userConfig: UserConfig\n }\n): UserConfig {\n const { command, githubPages, routesDirOption, userConfig } = input\n const root = userConfig.root ?? process.cwd()\n state.routesDir = resolveRoutesDir(root, routesDirOption)\n\n const config: UserConfig = {\n define: { __BUILD_TIME__: JSON.stringify(new Date().toISOString()) },\n optimizeDeps: { exclude: [\"ardo/ui/styles.css\"] },\n ssr: { noExternal: [\"ardo\"] },\n }\n\n if (githubPages && command === \"build\" && userConfig.base == null) {\n const repoName = detectGitHubRepoName(root)\n if (repoName != null) {\n config.base = `/${repoName}/`\n console.log(`[ardo] GitHub Pages detected, using base: ${config.base}`)\n }\n }\n\n return config\n}\n\nfunction resolveArdoConfig(\n root: string,\n routesDir: string,\n pressConfig: PressConfigOptions\n): ResolvedConfig {\n const detectedProject = readProjectMeta(root)\n const project: ProjectMeta = { ...detectedProject, ...pressConfig.project }\n const configWithDefaults: ArdoConfig = {\n title: pressConfig.title ?? \"Ardo\",\n description: pressConfig.description ?? \"Documentation powered by Ardo\",\n }\n\n return resolveConfig(\n {\n ...configWithDefaults,\n ...pressConfig,\n project,\n srcDir: routesDir,\n },\n root\n )\n}\n\nfunction resolveVirtualModuleId(id: string): string | undefined {\n return RESOLVED_IDS[id]\n}\n\nasync function loadVirtualModule(id: string, state: PluginState): Promise<string | undefined> {\n if (state.resolvedConfig == null) {\n return undefined\n }\n\n if (id === RESOLVED_IDS[VIRTUAL_MODULE_ID]) {\n const clientConfig = {\n title: state.resolvedConfig.title,\n description: state.resolvedConfig.description,\n base: state.resolvedConfig.base,\n lang: state.resolvedConfig.lang,\n project: state.resolvedConfig.project,\n buildTime: new Date().toISOString(),\n buildHash: detectGitHash(state.resolvedConfig.root),\n }\n return `export default ${JSON.stringify(clientConfig)}`\n }\n\n if (id === RESOLVED_IDS[VIRTUAL_SIDEBAR_ID]) {\n const sidebar = await generateSidebar(state.routesDir)\n return `export default ${JSON.stringify(sidebar)}`\n }\n\n if (id === RESOLVED_IDS[VIRTUAL_SEARCH_ID]) {\n const searchIndex = await generateSearchIndex(state.routesDir)\n return `export default ${JSON.stringify(searchIndex)}`\n }\n\n return undefined\n}\n\nfunction transformMarkdownMeta(\n code: string,\n id: string,\n state: PluginState\n): { code: string; map: null } | undefined {\n if (!shouldInjectMeta(code, id, state)) {\n return undefined\n }\n\n const pageTitle = extractFrontmatterValue(code, \"title\")\n if (pageTitle == null || pageTitle === \"\") {\n return undefined\n }\n\n const siteTitle = state.resolvedConfig?.title ?? \"Ardo\"\n const titleSeparator = state.resolvedConfig?.titleSeparator ?? \" | \"\n const description = extractFrontmatterValue(code, \"description\")\n const entries = buildMetaEntries({\n pageTitle,\n siteTitle,\n titleSeparator,\n description,\n })\n return { code: `${code}\\nexport const meta = () => [${entries.join(\", \")}];\\n`, map: null }\n}\n\nfunction shouldInjectMeta(code: string, id: string, state: PluginState): boolean {\n return isMarkdownFile(id) && id.startsWith(state.routesDir) && !hasMetaExport(code)\n}\n\nfunction buildMetaEntries(input: {\n pageTitle: string\n siteTitle: string\n titleSeparator: string\n description?: string\n}): string[] {\n const fullTitle = `${input.pageTitle}${input.titleSeparator}${input.siteTitle}`\n const entries = [`{ title: ${JSON.stringify(fullTitle)} }`]\n if (input.description != null && input.description !== \"\") {\n entries.push(`{ name: \"description\", content: ${JSON.stringify(input.description)} }`)\n }\n\n return entries\n}\n\nfunction isMarkdownFile(id: string): boolean {\n return id.endsWith(\".md\") || id.endsWith(\".mdx\")\n}\n\nfunction hasMetaExport(code: string): boolean {\n return code.includes(\"export const meta\") || code.includes(\"export function meta\")\n}\n\nfunction extractFrontmatterValue(code: string, key: string): string | undefined {\n const frontmatterStart = code.indexOf(\"export const frontmatter\")\n if (frontmatterStart === -1) {\n return undefined\n }\n\n const valuePrefix = `${key}: \"`\n const valueStart = code.indexOf(valuePrefix, frontmatterStart)\n if (valueStart === -1) {\n return undefined\n }\n\n const startIndex = valueStart + valuePrefix.length\n const endIndex = code.indexOf('\"', startIndex)\n if (endIndex === -1) {\n return undefined\n }\n\n return code.slice(startIndex, endIndex)\n}\n\nfunction resolveTypedocConfig(typedoc: ArdoPluginOptions[\"typedoc\"]): TypeDocConfig | undefined {\n if (typedoc == null) {\n return undefined\n }\n\n const packageRoot = findPackageRoot(process.cwd())\n const defaultEntryPoint = packageRoot != null ? `${packageRoot}/src/index.ts` : \"./src/index.ts\"\n const defaultTsconfig = packageRoot != null ? `${packageRoot}/tsconfig.json` : \"./tsconfig.json\"\n const defaults: TypeDocConfig = {\n enabled: true,\n entryPoints: [defaultEntryPoint],\n tsconfig: defaultTsconfig,\n out: \"api-reference\",\n excludePrivate: true,\n excludeInternal: true,\n }\n\n return typedoc === true ? defaults : { ...defaults, ...typedoc }\n}\n\nfunction createTypeDocPlugin(typedocConfig: TypeDocConfig, state: PluginState): Plugin {\n return {\n name: \"ardo:typedoc\",\n async buildStart() {\n if (!typedocConfig.enabled || typedocGenerated) {\n return\n }\n\n typedocGenerated = true\n console.log(\"[ardo] Generating API documentation with TypeDoc...\")\n const startTime = Date.now()\n\n try {\n const docs = await generateApiDocs(typedocConfig, state.routesDir)\n const duration = Date.now() - startTime\n console.log(`[ardo] Generated ${docs.length} API documentation pages in ${duration}ms`)\n } catch (error) {\n console.warn(\"[ardo] TypeDoc generation failed. API documentation will not be available.\")\n console.warn(\"[ardo] Check your typedoc.entryPoints configuration.\")\n if (error instanceof Error) {\n console.warn(`[ardo] Error: ${error.message}`)\n }\n }\n },\n }\n}\n\nfunction resolveRoutesDir(root: string, routesDirOption: string | undefined): string {\n return routesDirOption ?? path.join(root, \"app\", \"routes\")\n}\n"],"x_google_ignoreList":[17,18,19,20,21,22,23,24],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAgB,YAAY,SAA4B;CACtD,MAAM,EAAE,aAAa;CAGrB,MAAM,iBAAiB,aAAa,MAAM,KAAK,SAAS,QAAQ,OAAO,GAAG;AAE1E,SAAQ,SAAe;AACrB,MAAI,CAAC,eAEH;AAGF,QAAM,MAAM,YAAY,SAAkB;AACxC,OAAI,KAAK,YAAY,IACnB;GAGF,MAAM,OAAO,KAAK,WAAW;AAI7B,OACE,OAAO,SAAS,YAChB,KAAK,WAAW,IAAI,IACpB,CAAC,KAAK,WAAW,KAAK,IACtB,CAAC,KAAK,WAAW,eAAe,CAEhC,MAAK,WAAW,OAAO,iBAAiB;IAE1C;;;;;;ACpCN,MAAa,iBAAiB;CAC5B,OAAO;CACP,MAAM;CACP;AAED,SAAgB,mBACd,OACyB;AACzB,QAAO,SAAS;;AAGlB,SAAgB,iBAAiB,aAAsD;AACrF,KAAI,eAAe,KAAM,QAAO,CAAC,eAAe,OAAO,eAAe,KAAK;AAC3E,QAAO,OAAO,gBAAgB,WAAW,CAAC,YAAY,GAAG,CAAC,YAAY,OAAO,YAAY,KAAK;;AAGhG,SAAgB,mBAAmB,QAKxB;CACT,MAAM,EAAE,MAAM,aAAa,UAAU,gBAAgB;CAErD,MAAM,WAAW,eAAe;AAEhC,KAAI,OAAO,aAAa,SACtB,QAAO,YAAY,WAAW,MAAM;EAAE,MAAM;EAAU,OAAO;EAAU,CAAC;AAG1E,QAAO,YAAY,WAAW,MAAM;EAClC,cAAc;EACd,MAAM;EACN,QAAQ;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