boltdocs 2.9.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/boltdocs.js +2 -1
- package/dist/{adapters-uGz-UKQa.cjs → adapters-C5AWWGfb.cjs} +1 -1
- package/dist/{adapters-HVuXENAe.mjs → adapters-DEXNIv3x.mjs} +1 -1
- package/dist/{banner-D2NddBfF.d.ts → banner-CfdalYLL.d.ts} +1 -1
- package/dist/{banner-C_xkGxzI.d.cts → banner-DNSkgUsO.d.cts} +1 -1
- package/dist/{cache-B19MLTpN.cjs → cache-DETwlACe.cjs} +1 -1
- package/dist/{cache-CfhOTR3Q.mjs → cache-SF59enb3.mjs} +1 -1
- package/dist/client/index.cjs +260 -147
- package/dist/client/index.d.cts +4 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +259 -147
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +2 -2
- package/dist/client/primitives.d.cts +10 -8
- package/dist/client/primitives.d.ts +10 -8
- package/dist/client/primitives.js +2 -2
- package/dist/config-B5uVv5q4.cjs +7 -0
- package/dist/config-D3_zDkHh.mjs +7 -0
- package/dist/{config-CnmfjOE4.cjs → config-JGkMJoJQ.cjs} +1 -1
- package/dist/csp-gaZ51xzq.mjs +6 -0
- package/dist/doctor-3MheVMwd.mjs +7 -0
- package/dist/{parser-CHsNUEhU.cjs → doctor-BR1B2Mkz.cjs} +1 -1
- package/dist/doctor-DQxLM202.cjs +7 -0
- package/dist/handler-Btd4t_67.mjs +28 -0
- package/dist/{headers-DuCAOgYX.cjs → headers-BXKxiPUv.cjs} +1 -1
- package/dist/headers-CXyf0auY.mjs +6 -0
- package/dist/{image-BCDyLHyD.js → image-C9md50h2.js} +14 -6
- package/dist/{image-DWdmichO.cjs → image-CR6UlaI5.cjs} +14 -6
- package/dist/{mdx-9QJoSITt.cjs → mdx-DJBg5DuL.cjs} +10 -23
- package/dist/{mdx-DFbspTP9.js → mdx-DhyMkc35.js} +10 -23
- package/dist/node/cli-entry.cjs +3 -3
- package/dist/node/cli-entry.mjs +3 -3
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +40 -19
- package/dist/node/index.d.mts +41 -20
- package/dist/node/index.mjs +1 -1
- package/dist/node-BUAMwxuS.cjs +105 -0
- package/dist/node-Clh72alT.mjs +105 -0
- package/dist/{package-D6O7a8qA.mjs → package-1GvyLw7z.mjs} +1 -1
- package/dist/{package-CVw_u5VT.cjs → package-3jQEMIvy.cjs} +1 -1
- package/dist/pages-external-BYa4JSda.mjs +6 -0
- package/dist/pages-external-CX2uyW95.cjs +6 -0
- package/dist/parser-CNIPHx4s.cjs +8 -0
- package/dist/parser-D0QHIQsi.mjs +8 -0
- package/dist/plugin-D9gURy-9.mjs +68 -0
- package/dist/plugin-N3zGyZXw.cjs +68 -0
- package/dist/rolldown-runtime-fkIsjY3S.mjs +6 -0
- package/dist/routes-BajCwrvX.cjs +6 -0
- package/dist/routes-CyrnmVuG.mjs +6 -0
- package/dist/routes-D6Tuu7Fs.cjs +6 -0
- package/dist/{search-dialog-DRNJsxOv.js → search-dialog-CQneRo8T.js} +1 -1
- package/dist/{search-dialog-BsAiQgnx.cjs → search-dialog-CwNh8lIN.cjs} +27 -30
- package/dist/{search-dialog-BhXg05Ri.cjs → search-dialog-D4rplZMv.cjs} +1 -0
- package/dist/{search-dialog-DaR66wl0.js → search-dialog-DaeSPvEo.js} +1 -0
- package/dist/{search-dialog-CaOO1Q4i.js → search-dialog-DoGobmuG.js} +28 -31
- package/dist/{search-dialog-CzwvKoLW.cjs → search-dialog-cHJoKjts.cjs} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/{shiki-adapter-BB71nVsG.cjs → shiki-adapter-CGTmrR6S.cjs} +1 -1
- package/dist/shiki-adapter-CXEGRnjr.mjs +6 -0
- package/dist/{doctor-BL6c8x2Q.cjs → shiki-adapter-Mr8_oT_9.cjs} +1 -1
- package/dist/{sidebar-BtJyWHy4.d.cts → sidebar-7gIifpBX.d.cts} +21 -4
- package/dist/{sidebar-C4fuRYYS.d.ts → sidebar-BAKgJ-Er.d.ts} +21 -4
- package/dist/types-generator-DVOnRVKU.mjs +26 -0
- package/dist/{utils-DexBrwiP.mjs → utils-B3xYMrpK.mjs} +1 -1
- package/dist/{utils-BWy_8ASj.cjs → utils-Bz1tG9Dg.cjs} +1 -1
- package/package.json +2 -1
- package/src/shared/types.ts +22 -3
- package/dist/config-BCqkPkjC.mjs +0 -7
- package/dist/config-BPWGa2W3.mjs +0 -6
- package/dist/config-D7ERJhqe.cjs +0 -7
- package/dist/csp-CUAEgrxR.mjs +0 -6
- package/dist/doctor-A17UhTRn.cjs +0 -7
- package/dist/doctor-hKOBLhBF.mjs +0 -7
- package/dist/handler-CyIBbZdb.mjs +0 -28
- package/dist/handler-eNNcucnf.mjs +0 -6
- package/dist/headers-DBzZ9yC6.mjs +0 -6
- package/dist/node/routes/worker.cjs +0 -6
- package/dist/node/routes/worker.d.cts +0 -2
- package/dist/node/routes/worker.d.mts +0 -2
- package/dist/node/routes/worker.mjs +0 -6
- package/dist/node-B-I15rGR.cjs +0 -105
- package/dist/node-FkxzriO7.mjs +0 -105
- package/dist/parser-8u0xHVc7.mjs +0 -6
- package/dist/parser-CLtGv_XH.cjs +0 -6
- package/dist/plugin-CHa0IT49.mjs +0 -61
- package/dist/plugin-Dqj9plKB.cjs +0 -61
- package/dist/routes-B2joDAlC.cjs +0 -6
- package/dist/routes-BTx0ngdX.mjs +0 -6
- package/dist/routes-Bm0CQvyL.mjs +0 -6
- package/dist/routes-CyKj3dzf.cjs +0 -6
- package/dist/shiki-adapter-CL-IQwKI.cjs +0 -6
- package/dist/shiki-adapter-CxTLkjew.mjs +0 -6
- package/dist/shiki-adapter-rQ087Lx3.mjs +0 -6
- package/dist/types-generator-BRyf4o9F.mjs +0 -26
- package/dist/types-generator-Cu2jQP-V.mjs +0 -6
- package/dist/worker-pool-CgOMozUz.cjs +0 -6
- package/dist/worker-pool-v6tW2MDQ.mjs +0 -6
- /package/dist/{csp-DbbF3R9Q.cjs → csp-CBysWlAf.cjs} +0 -0
- /package/dist/{generator-BaSvGlxR.mjs → generator-CcOBN5vI.mjs} +0 -0
- /package/dist/{generator-DsajVrDx.cjs → generator-DtUU3Cfk.cjs} +0 -0
- /package/dist/{handler-1LRMYeI4.cjs → handler-Dzf4dSnV.cjs} +0 -0
- /package/dist/{index-ZqgZUvwp.d.mts → index-CdJv4ocW.d.mts} +0 -0
- /package/dist/{meta-loader-CD3Yptr5.mjs → meta-loader-C4Hu9RN9.mjs} +0 -0
- /package/dist/{meta-loader-CjphwtS7.cjs → meta-loader-C9MKjAs0.cjs} +0 -0
- /package/dist/{types-generator-BqNKCbrx.cjs → types-generator-CYcHkDzZ.cjs} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import { A as BoltdocsRoutePathWithFallback, a as SidebarItem, c as SidebarItemsProps, d as SidebarMobile, f as SidebarRoot, i as SidebarHeader, l as SidebarLink, m as ComponentBase, n as SidebarContent, o as SidebarItemProps, p as SidebarSubGroup, r as SidebarGroup, s as SidebarItems, t as Sidebar, u as SidebarLinkProps } from "../sidebar-
|
|
2
|
+
import { A as BoltdocsRoutePathWithFallback, a as SidebarItem, c as SidebarItemsProps, d as SidebarMobile, f as SidebarRoot, i as SidebarHeader, l as SidebarLink, m as ComponentBase, n as SidebarContent, o as SidebarItemProps, p as SidebarSubGroup, r as SidebarGroup, s as SidebarItems, t as Sidebar, u as SidebarLinkProps } from "../sidebar-BAKgJ-Er.js";
|
|
3
3
|
import * as React$2 from "react";
|
|
4
4
|
import { Component, ComponentProps, ComponentType, ErrorInfo, ImgHTMLAttributes, ReactNode, RefObject } from "react";
|
|
5
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
6
|
import * as RAC from "react-aria-components";
|
|
7
|
-
import {
|
|
7
|
+
import { PopoverProps as PopoverProps$1 } from "react-aria-components";
|
|
8
8
|
|
|
9
9
|
//#region src/client/components/primitives/docs-layout.d.ts
|
|
10
10
|
/**
|
|
@@ -527,7 +527,7 @@ declare function MenuSeparator(props: RAC.SeparatorProps): _$react_jsx_runtime0.
|
|
|
527
527
|
//#endregion
|
|
528
528
|
//#region src/client/components/primitives/page-nav.d.ts
|
|
529
529
|
interface PageNavProps extends ComponentBase {
|
|
530
|
-
to:
|
|
530
|
+
to: BoltdocsRoutePathWithFallback;
|
|
531
531
|
direction: 'prev' | 'next';
|
|
532
532
|
}
|
|
533
533
|
declare function PageNav({
|
|
@@ -706,8 +706,10 @@ declare function BreadcrumbsLink({
|
|
|
706
706
|
href,
|
|
707
707
|
className,
|
|
708
708
|
...props
|
|
709
|
-
}:
|
|
709
|
+
}: {
|
|
710
|
+
href: BoltdocsRoutePathWithFallback;
|
|
710
711
|
className?: string;
|
|
712
|
+
children?: React.ReactNode;
|
|
711
713
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
712
714
|
declare function BreadcrumbsSeparator({
|
|
713
715
|
className
|
|
@@ -716,7 +718,7 @@ declare function BreadcrumbsSeparator({
|
|
|
716
718
|
//#region src/client/components/primitives/navbar.d.ts
|
|
717
719
|
interface NavbarLinkProps extends Omit<ComponentBase, 'children'> {
|
|
718
720
|
label: ReactNode;
|
|
719
|
-
href:
|
|
721
|
+
href: BoltdocsRoutePathWithFallback;
|
|
720
722
|
to?: 'internal' | 'external';
|
|
721
723
|
}
|
|
722
724
|
interface NavbarLogoProps extends Omit<ComponentBase, 'children'> {
|
|
@@ -724,7 +726,7 @@ interface NavbarLogoProps extends Omit<ComponentBase, 'children'> {
|
|
|
724
726
|
alt: string;
|
|
725
727
|
width?: number;
|
|
726
728
|
height?: number;
|
|
727
|
-
href?:
|
|
729
|
+
href?: BoltdocsRoutePathWithFallback;
|
|
728
730
|
}
|
|
729
731
|
interface NavbarSearchTriggerProps extends ComponentBase {
|
|
730
732
|
onPress: () => void;
|
|
@@ -796,7 +798,7 @@ declare function NavbarTitle({
|
|
|
796
798
|
className,
|
|
797
799
|
href
|
|
798
800
|
}: {
|
|
799
|
-
href?:
|
|
801
|
+
href?: BoltdocsRoutePathWithFallback;
|
|
800
802
|
} & ComponentBase): _$react_jsx_runtime0.JSX.Element;
|
|
801
803
|
declare function NavbarLinks({
|
|
802
804
|
children,
|
|
@@ -822,7 +824,7 @@ declare function NavbarDropdownItem({
|
|
|
822
824
|
label,
|
|
823
825
|
className
|
|
824
826
|
}: {
|
|
825
|
-
href:
|
|
827
|
+
href: BoltdocsRoutePathWithFallback;
|
|
826
828
|
label: string;
|
|
827
829
|
className?: string;
|
|
828
830
|
}): _$react_jsx_runtime0.JSX.Element;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
import { _ as Link, v as NavLink, y as cn } from "../icons-dev-kJyGWNeg.js";
|
|
7
|
-
import { a as CodeBlockGroup, i as CodeBlockContent, n as Tooltip, o as CodeBlockHeader, r as CodeBlock, s as Heading, t as Image } from "../image-
|
|
7
|
+
import { a as CodeBlockGroup, i as CodeBlockContent, n as Tooltip, o as CodeBlockHeader, r as CodeBlock, s as Heading, t as Image } from "../image-C9md50h2.js";
|
|
8
8
|
import { D as ButtonGroup, E as Popover, O as Breadcrumbs, T as Menu, _ as ScrollProvider, a as SidebarHeader, b as useItems, c as SidebarLink, d as SidebarSubGroup, f as PageNav, g as OnThisPageTree, h as OnThisPageItems, i as SidebarGroup, l as SidebarMobile, m as OnThisPage, n as Sidebar, o as SidebarItem, p as AnchorProvider, r as SidebarContent, s as SidebarItems, t as DocsLayout, u as SidebarRoot, v as useActiveAnchor, w as Tabs, y as useActiveAnchors } from "../docs-layout-6FQ8__ok.js";
|
|
9
|
-
import { a as Button, i as ErrorBoundaryFallback, n as Navbar, r as ErrorBoundary, t as SearchDialog } from "../search-dialog-
|
|
9
|
+
import { a as Button, i as ErrorBoundaryFallback, n as Navbar, r as ErrorBoundary, t as SearchDialog } from "../search-dialog-DaeSPvEo.js";
|
|
10
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/client/components/primitives/skeleton.tsx
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./errors-Dx6JHoKE.cjs`),n=require(`./types-generator-CYcHkDzZ.cjs`);let r=require(`node:path`);r=e.n(r);let i=require(`node:fs`);i=e.n(i);let a=require(`zod`),o=require(`@bdocs/dui`);function s(e){return e}const c=a.z.object({icon:a.z.string().max(50),link:a.z.string().url()});a.z.object({text:a.z.string().max(2e3).optional()});const l=a.z.object({name:a.z.string(),enforce:a.z.enum([`pre`,`post`]).optional(),version:a.z.string().optional(),boltdocsVersion:a.z.string().optional(),remarkPlugins:a.z.array(a.z.unknown()).optional(),rehypePlugins:a.z.array(a.z.unknown()).optional(),vitePlugins:a.z.array(a.z.unknown()).optional(),components:a.z.record(a.z.string(),a.z.string()).optional(),hooks:a.z.record(a.z.string(),a.z.unknown()).optional()}),u=a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),description:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),logo:a.z.union([a.z.string(),a.z.object({dark:a.z.string(),light:a.z.string(),alt:a.z.string().optional(),width:a.z.number().optional(),height:a.z.number().optional()})]).optional(),navbar:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string(),items:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string()})).optional()})).optional(),sidebar:a.z.record(a.z.string(),a.z.array(a.z.object({text:a.z.string(),link:a.z.string()}))).optional(),sidebarGroups:a.z.record(a.z.string(),a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),icon:a.z.string().optional()})).optional(),socialLinks:a.z.array(c).optional(),editLink:a.z.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:a.z.string().url().optional(),version:a.z.string().max(50).optional(),githubRepo:a.z.string().max(100).optional(),favicon:a.z.string().optional(),tabs:a.z.array(a.z.object({id:a.z.string(),text:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),icon:a.z.string().optional()})).optional(),codeTheme:a.z.union([a.z.string(),a.z.object({light:a.z.string(),dark:a.z.string()})]).optional()}),d=a.z.union([a.z.string(),a.z.object({rules:a.z.array(a.z.object({userAgent:a.z.string(),allow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional(),disallow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional()})).optional(),sitemaps:a.z.array(a.z.string().url()).optional()})]),f=a.z.object({defaultLocale:a.z.string(),locales:a.z.union([a.z.record(a.z.string(),a.z.string()),a.z.array(a.z.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:a.z.record(a.z.string(),a.z.object({label:a.z.string().optional(),direction:a.z.enum([`ltr`,`rtl`]).optional(),htmlLang:a.z.string().optional(),calendar:a.z.string().optional()})).optional()}),p=a.z.object({defaultVersion:a.z.string(),prefix:a.z.string().optional(),versions:a.z.array(a.z.object({label:a.z.string(),path:a.z.string()}))}),m=a.z.object({headers:a.z.record(a.z.string(),a.z.string()).optional(),enableCSP:a.z.boolean().optional(),customHeaders:a.z.record(a.z.string(),a.z.string()).optional()}),h=a.z.object({google:a.z.string().optional(),bing:a.z.string().optional(),yandex:a.z.string().optional(),pinterest:a.z.string().optional(),facebook:a.z.string().optional()}),g=a.z.object({metatags:a.z.record(a.z.string(),a.z.string()).optional(),indexing:a.z.enum([`all`,`public`]).optional(),thumbnails:a.z.object({background:a.z.string().optional()}).optional(),verification:h.optional()}),_=a.z.object({measurementId:a.z.string().min(1,`Measurement ID is required for GA4`),debug:a.z.boolean().optional(),anonymizeIp:a.z.boolean().optional(),sendPageView:a.z.boolean().optional(),cookieFlags:a.z.string().optional(),autoTrack:a.z.object({pageViews:a.z.boolean().optional(),downloads:a.z.boolean().optional(),externalLinks:a.z.boolean().optional(),search:a.z.boolean().optional()}).optional()}),v=a.z.object({tagId:a.z.string().min(1,`Tag ID is required for GTM`),dataLayerName:a.z.string().optional(),preview:a.z.string().optional()}),y=a.z.object({appId:a.z.string().min(1,`Algolia App ID is required`),apiKey:a.z.string().min(1,`Algolia API Key is required`),indexName:a.z.string().min(1,`Algolia Index Name is required`)}),b=a.z.object({repo:a.z.string().min(1,`Giscus repository is required`),repoId:a.z.string().min(1,`Giscus repository ID is required`),category:a.z.string().optional(),categoryId:a.z.string().optional(),mapping:a.z.enum([`pathname`,`url`,`title`,`og:title`,`specific`,`number`]).optional(),strict:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),reactionsEnabled:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),emitMetadata:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),inputPosition:a.z.enum([`top`,`bottom`]).optional(),theme:a.z.string().optional(),darkTheme:a.z.string().optional(),lang:a.z.string().optional(),loading:a.z.enum([`lazy`,`eager`]).optional()}),x=a.z.object({enabled:a.z.boolean(),owner:a.z.string().min(1,`GitHub owner is required`),repo:a.z.string().min(1,`GitHub repository name is required`),categorySlug:a.z.string().optional(),endpoint:a.z.string().optional()}),S=a.z.object({analytics:a.z.boolean().optional(),speedInsights:a.z.boolean().optional()}),C=a.z.object({ga4:_.optional(),gtm:v.optional(),vercel:S.optional()}),w=a.z.object({algolia:y.optional()}),T=a.z.object({giscus:b.optional(),custom:x.optional()}),E=a.z.object({analytics:C.optional(),search:w.optional(),feedback:T.optional()}),D=a.z.object({siteUrl:a.z.string().url().optional(),docsDir:a.z.string().optional(),base:a.z.string().optional(),theme:u.optional(),i18n:f.optional(),versions:p.optional(),plugins:a.z.array(l).optional(),robots:d.optional(),security:m.optional(),seo:g.optional(),integrations:E.optional(),vite:a.z.record(a.z.string(),a.z.unknown()).optional()}),O=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function k(e,n=process.cwd()){let a=n,s={docsDir:r.default.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},c={};for(let e of O){let t=r.default.resolve(a,e);if(i.default.existsSync(t))try{let{loadConfigFromFile:e}=await import(`vite`),n=await e({command:`serve`,mode:`development`},t,a);if(n){c=n.config;break}}catch(t){(0,o.warn)(`Failed to load config from ${e}:`,t)}}let l={title:c.title,description:c.description,logo:c.logo,favicon:c.favicon,navbar:c.navbar,sidebar:c.sidebar,sidebarGroups:c.theme?.sidebarGroups,socialLinks:c.socialLinks,githubRepo:c.githubRepo,tabs:c.tabs,codeTheme:c.codeTheme,communityHelp:c.communityHelp,version:c.version,editLink:c.editLink,...c.theme||{}},u=Object.fromEntries(Object.entries(l).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``,items:e.items}));let d={docsDir:r.default.resolve(e),theme:{...s.theme,...u},i18n:c.i18n?{...c.i18n,locales:Array.isArray(c.i18n.locales)?Object.fromEntries(c.i18n.locales.map(e=>[e,e])):c.i18n.locales}:void 0,versions:c.versions,siteUrl:c.siteUrl,base:c.base,seo:c.seo,plugins:c.plugins||[],robots:c.robots,security:c.security,integrations:c.integrations,vite:c.vite},f=D.safeParse(d);if(!f.success)throw new t.r(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
7
|
+
`)}`);return f.data}async function A(e,t=process.cwd()){let r=await k(e,t);return n.t(r,e,t),r}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return O}});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{r as t}from"./errors-C0Hx15Ag.mjs";import{t as n}from"./types-generator-DVOnRVKU.mjs";import r from"node:path";import i from"node:fs";import{z as a}from"zod";import{warn as o}from"@bdocs/dui";function s(e){return e}const c=a.object({icon:a.string().max(50),link:a.string().url()});a.object({text:a.string().max(2e3).optional()});const l=a.object({name:a.string(),enforce:a.enum([`pre`,`post`]).optional(),version:a.string().optional(),boltdocsVersion:a.string().optional(),remarkPlugins:a.array(a.unknown()).optional(),rehypePlugins:a.array(a.unknown()).optional(),vitePlugins:a.array(a.unknown()).optional(),components:a.record(a.string(),a.string()).optional(),hooks:a.record(a.string(),a.unknown()).optional()}),u=a.object({title:a.union([a.string(),a.record(a.string(),a.string())]).optional(),description:a.union([a.string(),a.record(a.string(),a.string())]).optional(),logo:a.union([a.string(),a.object({dark:a.string(),light:a.string(),alt:a.string().optional(),width:a.number().optional(),height:a.number().optional()})]).optional(),navbar:a.array(a.object({label:a.union([a.string(),a.record(a.string(),a.string())]),href:a.string(),items:a.array(a.object({label:a.union([a.string(),a.record(a.string(),a.string())]),href:a.string()})).optional()})).optional(),sidebar:a.record(a.string(),a.array(a.object({text:a.string(),link:a.string()}))).optional(),sidebarGroups:a.record(a.string(),a.object({title:a.union([a.string(),a.record(a.string(),a.string())]).optional(),icon:a.string().optional()})).optional(),socialLinks:a.array(c).optional(),editLink:a.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:a.string().url().optional(),version:a.string().max(50).optional(),githubRepo:a.string().max(100).optional(),favicon:a.string().optional(),tabs:a.array(a.object({id:a.string(),text:a.union([a.string(),a.record(a.string(),a.string())]),icon:a.string().optional()})).optional(),codeTheme:a.union([a.string(),a.object({light:a.string(),dark:a.string()})]).optional()}),d=a.union([a.string(),a.object({rules:a.array(a.object({userAgent:a.string(),allow:a.union([a.string(),a.array(a.string())]).optional(),disallow:a.union([a.string(),a.array(a.string())]).optional()})).optional(),sitemaps:a.array(a.string().url()).optional()})]),f=a.object({defaultLocale:a.string(),locales:a.union([a.record(a.string(),a.string()),a.array(a.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:a.record(a.string(),a.object({label:a.string().optional(),direction:a.enum([`ltr`,`rtl`]).optional(),htmlLang:a.string().optional(),calendar:a.string().optional()})).optional()}),p=a.object({defaultVersion:a.string(),prefix:a.string().optional(),versions:a.array(a.object({label:a.string(),path:a.string()}))}),m=a.object({headers:a.record(a.string(),a.string()).optional(),enableCSP:a.boolean().optional(),customHeaders:a.record(a.string(),a.string()).optional()}),h=a.object({google:a.string().optional(),bing:a.string().optional(),yandex:a.string().optional(),pinterest:a.string().optional(),facebook:a.string().optional()}),g=a.object({metatags:a.record(a.string(),a.string()).optional(),indexing:a.enum([`all`,`public`]).optional(),thumbnails:a.object({background:a.string().optional()}).optional(),verification:h.optional()}),_=a.object({measurementId:a.string().min(1,`Measurement ID is required for GA4`),debug:a.boolean().optional(),anonymizeIp:a.boolean().optional(),sendPageView:a.boolean().optional(),cookieFlags:a.string().optional(),autoTrack:a.object({pageViews:a.boolean().optional(),downloads:a.boolean().optional(),externalLinks:a.boolean().optional(),search:a.boolean().optional()}).optional()}),v=a.object({tagId:a.string().min(1,`Tag ID is required for GTM`),dataLayerName:a.string().optional(),preview:a.string().optional()}),y=a.object({appId:a.string().min(1,`Algolia App ID is required`),apiKey:a.string().min(1,`Algolia API Key is required`),indexName:a.string().min(1,`Algolia Index Name is required`)}),b=a.object({repo:a.string().min(1,`Giscus repository is required`),repoId:a.string().min(1,`Giscus repository ID is required`),category:a.string().optional(),categoryId:a.string().optional(),mapping:a.enum([`pathname`,`url`,`title`,`og:title`,`specific`,`number`]).optional(),strict:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),reactionsEnabled:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),emitMetadata:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),inputPosition:a.enum([`top`,`bottom`]).optional(),theme:a.string().optional(),darkTheme:a.string().optional(),lang:a.string().optional(),loading:a.enum([`lazy`,`eager`]).optional()}),x=a.object({enabled:a.boolean(),owner:a.string().min(1,`GitHub owner is required`),repo:a.string().min(1,`GitHub repository name is required`),categorySlug:a.string().optional(),endpoint:a.string().optional()}),S=a.object({analytics:a.boolean().optional(),speedInsights:a.boolean().optional()}),C=a.object({ga4:_.optional(),gtm:v.optional(),vercel:S.optional()}),w=a.object({algolia:y.optional()}),T=a.object({giscus:b.optional(),custom:x.optional()}),E=a.object({analytics:C.optional(),search:w.optional(),feedback:T.optional()}),D=a.object({siteUrl:a.string().url().optional(),docsDir:a.string().optional(),base:a.string().optional(),theme:u.optional(),i18n:f.optional(),versions:p.optional(),plugins:a.array(l).optional(),robots:d.optional(),security:m.optional(),seo:g.optional(),integrations:E.optional(),vite:a.record(a.string(),a.unknown()).optional()});var O=e({CONFIG_FILES:()=>k,defineConfig:()=>s,resolveConfig:()=>A,resolveConfigAndGenerateTypes:()=>j});const k=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function A(e,n=process.cwd()){let a=n,s={docsDir:r.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},c={};for(let e of k){let t=r.resolve(a,e);if(i.existsSync(t))try{let{loadConfigFromFile:e}=await import(`vite`),n=await e({command:`serve`,mode:`development`},t,a);if(n){c=n.config;break}}catch(t){o(`Failed to load config from ${e}:`,t)}}let l={title:c.title,description:c.description,logo:c.logo,favicon:c.favicon,navbar:c.navbar,sidebar:c.sidebar,sidebarGroups:c.theme?.sidebarGroups,socialLinks:c.socialLinks,githubRepo:c.githubRepo,tabs:c.tabs,codeTheme:c.codeTheme,communityHelp:c.communityHelp,version:c.version,editLink:c.editLink,...c.theme||{}},u=Object.fromEntries(Object.entries(l).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``,items:e.items}));let d={docsDir:r.resolve(e),theme:{...s.theme,...u},i18n:c.i18n?{...c.i18n,locales:Array.isArray(c.i18n.locales)?Object.fromEntries(c.i18n.locales.map(e=>[e,e])):c.i18n.locales}:void 0,versions:c.versions,siteUrl:c.siteUrl,base:c.base,seo:c.seo,plugins:c.plugins||[],robots:c.robots,security:c.security,integrations:c.integrations,vite:c.vite},f=D.safeParse(d);if(!f.success)throw new t(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
7
|
+
`)}`);return f.data}async function j(e,t=process.cwd()){let r=await A(e,t);return n(r,e,t),r}export{s as a,l as i,O as n,A as r,k as t};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
const e=require(`./config-
|
|
6
|
+
const e=require(`./config-B5uVv5q4.cjs`);exports.CONFIG_FILES=e.t,exports.defineConfig=e.a,exports.resolveConfig=e.n,exports.resolveConfigAndGenerateTypes=e.r;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";var t=e({getCSPHeader:()=>n});function n(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}export{n,t};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{_ as t,a as n,d as r,u as i}from"./utils-B3xYMrpK.mjs";import{t as a}from"./pages-external-BYa4JSda.mjs";import{r as o}from"./config-D3_zDkHh.mjs";import{t as s}from"./node/cli-entry.mjs";import c from"node:path";import l from"node:fs";import{bullet as u,colors as d,confirm as f,dividerLog as p,double as m,error as h,info as g,round as _,single as v,success as y,tasks as b,warn as x}from"@bdocs/dui";import{fdir as S}from"fdir";import C from"picomatch";import{distance as w}from"fastest-levenshtein";const T={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function E(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function D(e,t,n){return e.doctorConfig.severity[t]||n}async function O(e,t){l.existsSync(t)||l.mkdirSync(t,{recursive:!0});let n=c.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=c.join(t,`${n}.${r}.bak`);l.copyFileSync(e,i)}const k=new Map;function A(e){let t=k.get(e);if(t)return t;let n=(async()=>{let t=await r(e,!1);return{raw:t.raw,data:t.data,content:t.content}})();return k.set(e,n),n}const j=new Map;function M(e){if(j.has(e))return j.get(e);let t=!1;try{t=l.existsSync(e)&&l.statSync(e).isFile()}catch{t=!1}return j.set(e,t),t}async function N(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t))try{let e=JSON.parse(l.readFileSync(t,`utf-8`));return{...T,...e,checks:{...T.checks,...e.checks,metadata:{...T.checks.metadata,...e.checks?.metadata},links:{...T.checks.links,...e.checks?.links},i18n:{...T.checks.i18n,...e.checks?.i18n},performance:{...T.checks.performance,...e.checks?.performance,budgets:{...T.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...T.fix,...e.fix},reporting:{...T.reporting,...e.reporting},severity:{...T.severity,...e.severity},exclude:[...T.exclude,...e.exclude||[]]}}catch(e){x(`Failed to parse doctor.json: ${e}`)}return T}async function P(e,t=process.cwd(),r,i){let o=c.resolve(t,`.boltdocs`,`generated`);l.existsSync(o)||l.mkdirSync(o,{recursive:!0});let s=i;s||=await new S().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let u=r?.base||`/docs`,d=[];for(let t=0;t<s.length;t+=100){let r=s.slice(t,t+100),i=await Promise.all(r.map(async t=>{let r=c.isAbsolute(t)?t:c.resolve(e,t),i=c.relative(e,r),{data:a}=await A(r),o;return o=a.permalink?a.permalink.startsWith(`/`)?a.permalink:`/${a.permalink}`:n(i),u===`/`?o:(u.endsWith(`/`)?u:u+`/`)+(o.startsWith(`/`)?o.substring(1):o)}));d.push(...i)}d.includes(u)||d.push(u);let f=a(e,r);for(let e of f)d.includes(e)||d.push(e);let p={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return l.writeFileSync(c.resolve(o,`link-tree.json`),JSON.stringify(p,null,2)),p}function F(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-w(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-w(e,t)/Math.max(e.length,t.length)}const I=new Map;function L(e,t){if(I.has(e))return I.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=F(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return I.set(e,a),a}async function R(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let l of e.files){let u=i(c.relative(e.docsDir,l));try{let{raw:i,data:c}=await A(l);if(i.trim().startsWith(`---`)&&i.split(`---`).length>=3&&Object.keys(c).length===0){let t=D(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t.safeParse(c);if(!d.success){let t=D(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:u,level:t,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let t of f)if(c[t]===void 0){let r=D(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:u,level:r,message:`Missing required frontmatter field: "${t}".`,suggestion:`Add the "${t}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let t=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of t)if(c[r]&&Number.isNaN(Date.parse(String(c[r])))){let t=D(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Invalid date format in field "${r}": "${c[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(c.title){let t=String(c.title);if(t.length<r){let i=D(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:u,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>a){let r=D(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:u,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let i=s.get(t)||[];i.push(u),s.set(t,i)}if(c.description&&String(c.description).length<o){let t=D(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:u,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=D(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:u,level:r,message:`Malformed frontmatter (YAML error): ${t.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[t,r]of s.entries())if(r.length>1){let i=D(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)n.push({file:e,level:i,message:`Duplicate title found: "${t}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return n}async function z(e){let t=[],{internal:n,external:r,ignore:a,timeout:o,concurrency:s}=e.doctorConfig.checks.links;if(!n&&!r&&!e.options.checkExternal)return t;let u=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,p=5e5;for(let o of e.files){let s=i(c.relative(e.docsDir,o)),{content:d}=await A(o),m=[...(d.length>p?d.slice(0,p):d).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(u)];for(let i of m){let u=i[1]||i[2],d=!!i[1];if(!u||a.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(r||e.options.checkExternal)&&f.add({url:u,file:o});continue}if(!n||/^(mailto|tel|#)/i.test(u))continue;let p;try{p=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{p=u.split(`#`)[0].split(`?`)[0]}if(!p)continue;let m=!1,h=``;if(p.startsWith(`/`))if(e.routeIndex.has(p)||e.routeIndexWithSlash.has(p)||e.routeIndexWithoutSlash.has(p))m=!0;else{let t=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))m=!1,h=t;else{let t=e.config.base!==`/`&&p.startsWith(e.config.base||`/`)?p.substring((e.config.base||`/`).length):p,n=t.startsWith(`/`)?t.substring(1):t;h=c.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e))}}else h=c.resolve(c.dirname(o),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e));if(!m){let{bestMatch:n,similarity:r}=L(p,e.linkTree.routes),i=!1,a=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(n=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&n!==p||i,m=D(e,`brokenLink`,`high`);m!==`off`&&t.push({file:s,level:m,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${n}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,t=d?`(${u})`:`href="${u}"`,r=d?`(${n}${e})`:`href="${n}${e}"`,i=l.readFileSync(o,`utf-8`).replace(t,r);l.writeFileSync(o,i),k.delete(o)}:void 0})}}}if(f.size>0){g(d.gray(`Verifying ${f.size} external links...`));let n=new Map;for(let e of f)n.has(e.url)||n.set(e.url,[]),n.get(e.url).push(e.file);let r=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),o),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},a=Array.from(n.keys()),l=[];for(let e=0;e<a.length;e+=s){let t=a.slice(e,e+s),n=await Promise.allSettled(t.map(r));l.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let r of l)if(!r.ok){let a=D(e,`brokenLink`,`warning`);if(a!==`off`){let o=n.get(r.url)||[];for(let n of o)t.push({file:i(c.relative(e.docsDir,n)),level:a,message:`Broken external link: "${r.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${r.error||`Status >= 400`}`})}}}return t}async function B(e){let t=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return t;let{defaultLocale:n,locales:r}=e.config.i18n,a=Object.keys(r),o=a.filter(e=>e!==n);for(let r of e.files){let s=i(c.relative(e.docsDir,r)),u=s.split(`/`),d=u[0];if(d===n){let n=u.slice(1).join(`/`);for(let i of o){let a=c.join(e.docsDir,i,n);if(!M(a)){let o=D(e,`missingTranslation`,`warning`);o!==`off`&&t.push({file:s,level:o,message:`Missing translation for locale "${i}"`,suggestion:`Create a version at "${i}/${n}".`,fix:async()=>{let e=c.dirname(a);l.existsSync(e)||l.mkdirSync(e,{recursive:!0}),l.copyFileSync(r,a)}})}}}else if(a.includes(d)){let i=u.slice(1).join(`/`);if(!M(c.join(e.docsDir,n,i))){let a=D(e,`missingTranslation`,`low`);a!==`off`&&t.push({file:s,level:a,message:`Orphaned translation (source missing in "${n}")`,suggestion:`Remove this file or create the source at "${n}/${i}".`,fix:async()=>{l.unlinkSync(r)}})}}}return t}async function V(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=D(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=L(r.link,e.linkTree.routes),a=i>.6,o=D(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=D(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function H(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=c.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!l.existsSync(r))return t.push({file:`(build)`,level:D(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(l.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:D(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let a=n.budgets,o=D(e,`budgetExceeded`,`warning`),s=E(a?.maxJSBundleSize,1/0),u=E(a?.maxCSSBundleSize,1/0),d=E(a?.maxPageHTMLSize,1/0),f=a?.maxImagesKB??1/0,p=a?.maxBuildTime??1/0,m=a?.maxFontCount??1/0;if(s!==1/0&&i.totalJSBundleSize>s){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(s/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&i.totalCSSBundleSize>u){let e=(i.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of i.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:o,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let h=f*1024;if(f!==1/0&&i.totalImagesSize>h){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`Image assets exceed budget: ${e}kb > ${f}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(p!==1/0&&i.buildTime>p){let e=(i.buildTime/1e3).toFixed(1),n=(p/1e3).toFixed(1);t.push({file:`(build)`,level:o,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return m!==1/0&&i.fontCount>m&&t.push({file:`(build)`,level:o,message:`Font files exceed budget: ${i.fontCount} > ${m}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}var U=e({DEFAULT_DOCTOR_CONFIG:()=>T,checkI18n:()=>B,checkLinks:()=>z,checkMetadata:()=>R,checkPerformance:()=>H,checkSidebar:()=>V,doctorAction:()=>G,doctorInit:()=>W,generateLinkTree:()=>P,loadDoctorConfig:()=>N});async function W(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t)){x(`"doctor.json" already exists at ${e}.`);return}try{l.writeFileSync(t,JSON.stringify(T,null,2)),y(`Created "doctor.json" with default configuration.`)}catch(e){h(`Failed to create "doctor.json": ${e}`)}}async function G(e=process.cwd(),t={}){if(t.init){await W(e);return}s();try{let n=await N(e),{format:r}=n.reporting,i=performance.now(),a=await o(`docs`,e),s=c.resolve(e,`docs`);l.existsSync(s)||(r===`pretty`&&h(`Docs dir not found at ${s}`),process.exit(1)),r===`pretty`&&console.log(m([` ${d.dim(`Docs dir:`)} ${s}`,` ${d.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),r===`pretty`&&g(d.dim(`🔍 Discovering files and routes...`));let x=C(n.exclude||[]),w=await new S().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=c.relative(s,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!x(t)&&!n}).crawl(s).withPromise();for(let e of w)j.set(e,!0);let T=await P(s,e,a,w),E=a.base||`/`,D=E===`/`?``:E.endsWith(`/`)?E.slice(0,-1):E,k={root:e,docsDir:s,config:a,doctorConfig:n,linkTree:T,files:w,options:t,routeIndex:new Set(T.routes),routeIndexWithSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:D};r===`pretty`&&g(d.dim(`🧪 Running diagnostic checks in parallel...`));let A=[R(k),z(k),B(k),V(k)];t.budget&&A.push(H(k));let[M,F,I,L,...U]=await Promise.all(A),W=t.budget?U[0]:[],G=[...M,...F,...I,...L,...W];if(r===`pretty`){let e=[{label:`Metadata checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0},{label:`Link checks ${F.length>0?`— ${F.length} issue${F.length===1?``:`s`}`:`— OK`}`,done:F.length===0},{label:`i18n checks ${I.length>0?`— ${I.length} issue${I.length===1?``:`s`}`:`— OK`}`,done:I.length===0},{label:`Sidebar checks ${L.length>0?`— ${L.length} issue${L.length===1?``:`s`}`:`— OK`}`,done:L.length===0}];t.budget&&e.push({label:`Performance budget ${W.length>0?`— ${W.length} issue${W.length===1?``:`s`}`:`— OK`}`,done:W.length===0}),console.log(`\n${b(e)}`)}let K=0;if(t.fix){for(let e of G)if(e.fix){if(k.doctorConfig.fix.confirmChanges&&!await f(`Fix issue in "${e.file}": ${e.message}?`))continue;if(k.doctorConfig.fix.backupFiles){let t=c.resolve(k.docsDir,e.file);l.existsSync(t)&&await O(t,c.resolve(k.root,k.doctorConfig.fix.backupPath))}await e.fix(),K++}}let q=((performance.now()-i)/1e3).toFixed(2),J=G.filter(e=>e.level===`high`).length,Y=G.filter(e=>e.level===`warning`).length,X=G.filter(e=>e.level===`low`).length,Z={summary:{total:G.length,high:J,warning:Y,low:X,fixed:K,duration:q},issues:G.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=c.resolve(e,n.reporting.outputFile);l.existsSync(c.dirname(t))||l.mkdirSync(c.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify(Z,null,2))}if(r===`json`)console.log(JSON.stringify(Z,null,2));else if(r===`pretty`){let e=G.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(G.length>0){p();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?d.red:n.level===`warning`?d.yellow:d.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${d.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${d.green(`✅ Fixed automatically`)}`)}console.log(`\n${v(e,{title:`📄 ${n}`})}`)}p()}if(G.length===0)console.log(_([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];J>0&&e.push(d.red(`${J} Critical Error${J===1?``:`s`}`)),Y>0&&e.push(d.yellow(`${Y} Warning${Y===1?``:`s`}`)),X>0&&e.push(d.blue(`${X} Improvement${X===1?``:`s`}`));let t=[...u(e).split(`
|
|
7
|
+
`).map(e=>e.trimStart()),``,d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)];console.log(`\n${m(t,{title:`Diagnosis Results`})}\n`),K>0&&y(`Successfully fixed ${K} issues automatically!`),J>0?h(`Please fix the critical errors before building for production.`):y(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&J>0&&process.exit(1),n.reporting.maxWarnings!==-1&&Y>n.reporting.maxWarnings&&(r===`pretty`&&h(`Failed: Too many warnings (${Y} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){h(`Doctor failed: ${e}`),process.exit(1)}}export{P as n,U as t};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./utils-Bz1tG9Dg.cjs`),n=require(`./pages-external-CX2uyW95.cjs`),r=require(`./config-B5uVv5q4.cjs`),i=require(`./node/cli-entry.cjs`);let a=require(`node:path`);a=e.n(a);let o=require(`node:fs`);o=e.n(o);let s=require(`@bdocs/dui`),c=require(`fdir`),l=require(`picomatch`);l=e.n(l);let u=require(`fastest-levenshtein`);const d={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function f(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function p(e,t,n){return e.doctorConfig.severity[t]||n}async function m(e,t){o.default.existsSync(t)||o.default.mkdirSync(t,{recursive:!0});let n=a.default.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=a.default.join(t,`${n}.${r}.bak`);o.default.copyFileSync(e,i)}const h=new Map;function g(e){let n=h.get(e);if(n)return n;let r=(async()=>{let n=await t.d(e,!1);return{raw:n.raw,data:n.data,content:n.content}})();return h.set(e,r),r}const _=new Map;function v(e){if(_.has(e))return _.get(e);let t=!1;try{t=o.default.existsSync(e)&&o.default.statSync(e).isFile()}catch{t=!1}return _.set(e,t),t}async function y(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t))try{let e=JSON.parse(o.default.readFileSync(t,`utf-8`));return{...d,...e,checks:{...d.checks,...e.checks,metadata:{...d.checks.metadata,...e.checks?.metadata},links:{...d.checks.links,...e.checks?.links},i18n:{...d.checks.i18n,...e.checks?.i18n},performance:{...d.checks.performance,...e.checks?.performance,budgets:{...d.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...d.fix,...e.fix},reporting:{...d.reporting,...e.reporting},severity:{...d.severity,...e.severity},exclude:[...d.exclude,...e.exclude||[]]}}catch(e){(0,s.warn)(`Failed to parse doctor.json: ${e}`)}return d}async function b(e,r=process.cwd(),i,s){let l=a.default.resolve(r,`.boltdocs`,`generated`);o.default.existsSync(l)||o.default.mkdirSync(l,{recursive:!0});let u=s;u||=await new c.fdir().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let d=i?.base||`/docs`,f=[];for(let n=0;n<u.length;n+=100){let r=u.slice(n,n+100),i=await Promise.all(r.map(async n=>{let r=a.default.isAbsolute(n)?n:a.default.resolve(e,n),i=a.default.relative(e,r),{data:o}=await g(r),s;return s=o.permalink?o.permalink.startsWith(`/`)?o.permalink:`/${o.permalink}`:t.a(i),d===`/`?s:(d.endsWith(`/`)?d:d+`/`)+(s.startsWith(`/`)?s.substring(1):s)}));f.push(...i)}f.includes(d)||f.push(d);let p=n.t(e,i);for(let e of p)f.includes(e)||f.push(e);let m={routes:Array.from(new Set(f)).sort(),timestamp:Date.now()};return o.default.writeFileSync(a.default.resolve(l,`link-tree.json`),JSON.stringify(m,null,2)),m}function x(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-(0,u.distance)(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-(0,u.distance)(e,t)/Math.max(e.length,t.length)}const S=new Map;function C(e,t){if(S.has(e))return S.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=x(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return S.set(e,a),a}async function w(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:i,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let c of e.files){let l=t.u(a.default.relative(e.docsDir,c));try{let{raw:a,data:u}=await g(c);if(a.trim().startsWith(`---`)&&a.split(`---`).length>=3&&Object.keys(u).length===0){let t=p(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t._.safeParse(u);if(!d.success){let t=p(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:l,level:t,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let t of f)if(u[t]===void 0){let r=p(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:l,level:r,message:`Missing required frontmatter field: "${t}".`,suggestion:`Add the "${t}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let t=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of t)if(u[r]&&Number.isNaN(Date.parse(String(u[r])))){let t=p(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Invalid date format in field "${r}": "${u[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(u.title){let t=String(u.title);if(t.length<r){let i=p(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:l,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>i){let r=p(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${i} characters.`})}let a=s.get(t)||[];a.push(l),s.set(t,a)}if(u.description&&String(u.description).length<o){let t=p(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:l,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=p(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:l,level:r,message:`Malformed frontmatter (YAML error): ${t.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[t,r]of s.entries())if(r.length>1){let i=p(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)n.push({file:e,level:i,message:`Duplicate title found: "${t}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return n}async function T(e){let n=[],{internal:r,external:i,ignore:c,timeout:l,concurrency:u}=e.doctorConfig.checks.links;if(!r&&!i&&!e.options.checkExternal)return n;let d=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,m=5e5;for(let s of e.files){let l=t.u(a.default.relative(e.docsDir,s)),{content:u}=await g(s),_=[...(u.length>m?u.slice(0,m):u).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(d)];for(let t of _){let u=t[1]||t[2],d=!!t[1];if(!u||c.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(i||e.options.checkExternal)&&f.add({url:u,file:s});continue}if(!r||/^(mailto|tel|#)/i.test(u))continue;let m;try{m=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{m=u.split(`#`)[0].split(`?`)[0]}if(!m)continue;let g=!1,_=``;if(m.startsWith(`/`))if(e.routeIndex.has(m)||e.routeIndexWithSlash.has(m)||e.routeIndexWithoutSlash.has(m))g=!0;else{let t=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))g=!1,_=t;else{let t=e.config.base!==`/`&&m.startsWith(e.config.base||`/`)?m.substring((e.config.base||`/`).length):m,n=t.startsWith(`/`)?t.substring(1):t;_=a.default.join(e.docsDir,n),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e))}}else _=a.default.resolve(a.default.dirname(s),m),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e));if(!g){let{bestMatch:t,similarity:r}=C(m,e.linkTree.routes),i=!1,a=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(t=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&t!==m||i,g=p(e,`brokenLink`,`high`);g!==`off`&&n.push({file:l,level:g,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${t}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,n=d?`(${u})`:`href="${u}"`,r=d?`(${t}${e})`:`href="${t}${e}"`,i=o.default.readFileSync(s,`utf-8`).replace(n,r);o.default.writeFileSync(s,i),h.delete(s)}:void 0})}}}if(f.size>0){(0,s.info)(s.colors.gray(`Verifying ${f.size} external links...`));let r=new Map;for(let e of f)r.has(e.url)||r.set(e.url,[]),r.get(e.url).push(e.file);let i=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),l),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},o=Array.from(r.keys()),c=[];for(let e=0;e<o.length;e+=u){let t=o.slice(e,e+u),n=await Promise.allSettled(t.map(i));c.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let i of c)if(!i.ok){let o=p(e,`brokenLink`,`warning`);if(o!==`off`){let s=r.get(i.url)||[];for(let r of s)n.push({file:t.u(a.default.relative(e.docsDir,r)),level:o,message:`Broken external link: "${i.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${i.error||`Status >= 400`}`})}}}return n}async function E(e){let n=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return n;let{defaultLocale:r,locales:i}=e.config.i18n,s=Object.keys(i),c=s.filter(e=>e!==r);for(let i of e.files){let l=t.u(a.default.relative(e.docsDir,i)),u=l.split(`/`),d=u[0];if(d===r){let t=u.slice(1).join(`/`);for(let r of c){let s=a.default.join(e.docsDir,r,t);if(!v(s)){let c=p(e,`missingTranslation`,`warning`);c!==`off`&&n.push({file:l,level:c,message:`Missing translation for locale "${r}"`,suggestion:`Create a version at "${r}/${t}".`,fix:async()=>{let e=a.default.dirname(s);o.default.existsSync(e)||o.default.mkdirSync(e,{recursive:!0}),o.default.copyFileSync(i,s)}})}}}else if(s.includes(d)){let t=u.slice(1).join(`/`);if(!v(a.default.join(e.docsDir,r,t))){let a=p(e,`missingTranslation`,`low`);a!==`off`&&n.push({file:l,level:a,message:`Orphaned translation (source missing in "${r}")`,suggestion:`Remove this file or create the source at "${r}/${t}".`,fix:async()=>{o.default.unlinkSync(i)}})}}}return n}async function D(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=p(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=C(r.link,e.linkTree.routes),a=i>.6,o=p(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=p(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function O(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=a.default.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!o.default.existsSync(r))return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(o.default.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let s=n.budgets,c=p(e,`budgetExceeded`,`warning`),l=f(s?.maxJSBundleSize,1/0),u=f(s?.maxCSSBundleSize,1/0),d=f(s?.maxPageHTMLSize,1/0),m=s?.maxImagesKB??1/0,h=s?.maxBuildTime??1/0,g=s?.maxFontCount??1/0;if(l!==1/0&&i.totalJSBundleSize>l){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(l/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&i.totalCSSBundleSize>u){let e=(i.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of i.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:c,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let _=m*1024;if(m!==1/0&&i.totalImagesSize>_){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`Image assets exceed budget: ${e}kb > ${m}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(h!==1/0&&i.buildTime>h){let e=(i.buildTime/1e3).toFixed(1),n=(h/1e3).toFixed(1);t.push({file:`(build)`,level:c,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return g!==1/0&&i.fontCount>g&&t.push({file:`(build)`,level:c,message:`Font files exceed budget: ${i.fontCount} > ${g}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function k(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t)){(0,s.warn)(`"doctor.json" already exists at ${e}.`);return}try{o.default.writeFileSync(t,JSON.stringify(d,null,2)),(0,s.success)(`Created "doctor.json" with default configuration.`)}catch(e){(0,s.error)(`Failed to create "doctor.json": ${e}`)}}async function A(e=process.cwd(),t={}){if(t.init){await k(e);return}i.t();try{let n=await y(e),{format:i}=n.reporting,u=performance.now(),d=await r.n(`docs`,e),f=a.default.resolve(e,`docs`);o.default.existsSync(f)||(i===`pretty`&&(0,s.error)(`Docs dir not found at ${f}`),process.exit(1)),i===`pretty`&&console.log((0,s.double)([` ${s.colors.dim(`Docs dir:`)} ${f}`,` ${s.colors.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),i===`pretty`&&(0,s.info)(s.colors.dim(`🔍 Discovering files and routes...`));let p=(0,l.default)(n.exclude||[]),h=await new c.fdir().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=a.default.relative(f,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!p(t)&&!n}).crawl(f).withPromise();for(let e of h)_.set(e,!0);let g=await b(f,e,d,h),v=d.base||`/`,x=v===`/`?``:v.endsWith(`/`)?v.slice(0,-1):v,S={root:e,docsDir:f,config:d,doctorConfig:n,linkTree:g,files:h,options:t,routeIndex:new Set(g.routes),routeIndexWithSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:x};i===`pretty`&&(0,s.info)(s.colors.dim(`🧪 Running diagnostic checks in parallel...`));let C=[w(S),T(S),E(S),D(S)];t.budget&&C.push(O(S));let[k,A,j,M,...N]=await Promise.all(C),P=t.budget?N[0]:[],F=[...k,...A,...j,...M,...P];if(i===`pretty`){let e=[{label:`Metadata checks ${k.length>0?`— ${k.length} issue${k.length===1?``:`s`}`:`— OK`}`,done:k.length===0},{label:`Link checks ${A.length>0?`— ${A.length} issue${A.length===1?``:`s`}`:`— OK`}`,done:A.length===0},{label:`i18n checks ${j.length>0?`— ${j.length} issue${j.length===1?``:`s`}`:`— OK`}`,done:j.length===0},{label:`Sidebar checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0}];t.budget&&e.push({label:`Performance budget ${P.length>0?`— ${P.length} issue${P.length===1?``:`s`}`:`— OK`}`,done:P.length===0}),console.log(`\n${(0,s.tasks)(e)}`)}let I=0;if(t.fix){for(let e of F)if(e.fix){if(S.doctorConfig.fix.confirmChanges&&!await(0,s.confirm)(`Fix issue in "${e.file}": ${e.message}?`))continue;if(S.doctorConfig.fix.backupFiles){let t=a.default.resolve(S.docsDir,e.file);o.default.existsSync(t)&&await m(t,a.default.resolve(S.root,S.doctorConfig.fix.backupPath))}await e.fix(),I++}}let L=((performance.now()-u)/1e3).toFixed(2),R=F.filter(e=>e.level===`high`).length,z=F.filter(e=>e.level===`warning`).length,B=F.filter(e=>e.level===`low`).length,V={summary:{total:F.length,high:R,warning:z,low:B,fixed:I,duration:L},issues:F.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=a.default.resolve(e,n.reporting.outputFile);o.default.existsSync(a.default.dirname(t))||o.default.mkdirSync(a.default.dirname(t),{recursive:!0}),o.default.writeFileSync(t,JSON.stringify(V,null,2))}if(i===`json`)console.log(JSON.stringify(V,null,2));else if(i===`pretty`){let e=F.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(F.length>0){(0,s.dividerLog)();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?s.colors.red:n.level===`warning`?s.colors.yellow:s.colors.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${s.colors.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${s.colors.green(`✅ Fixed automatically`)}`)}console.log(`\n${(0,s.single)(e,{title:`📄 ${n}`})}`)}(0,s.dividerLog)()}if(F.length===0)console.log((0,s.round)([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];R>0&&e.push(s.colors.red(`${R} Critical Error${R===1?``:`s`}`)),z>0&&e.push(s.colors.yellow(`${z} Warning${z===1?``:`s`}`)),B>0&&e.push(s.colors.blue(`${B} Improvement${B===1?``:`s`}`));let t=[...(0,s.bullet)(e).split(`
|
|
7
|
+
`).map(e=>e.trimStart()),``,s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)];console.log(`\n${(0,s.double)(t,{title:`Diagnosis Results`})}\n`),I>0&&(0,s.success)(`Successfully fixed ${I} issues automatically!`),R>0?(0,s.error)(`Please fix the critical errors before building for production.`):(0,s.success)(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&R>0&&process.exit(1),n.reporting.maxWarnings!==-1&&z>n.reporting.maxWarnings&&(i===`pretty`&&(0,s.error)(`Failed: Too many warnings (${z} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){(0,s.error)(`Doctor failed: ${e}`),process.exit(1)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return d}});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import*as t from"zod";import n from"node:crypto";function r(e,t){let r={alg:`RS256`,typ:`JWT`},i=Math.floor(Date.now()/1e3),a={iat:i-60,exp:i+600,iss:e},o=e=>Buffer.from(JSON.stringify(e)).toString(`base64url`),s=o(r),c=o(a),l=n.createSign(`RSA-SHA256`);l.update(`${s}.${c}`);let u=t.replace(/\\n/g,`
|
|
7
|
+
`);return`${s}.${c}.${l.sign(u,`base64`)}`}async function i(e,t,n){let i=r(e,t),a=await fetch(`https://api.github.com/app/installations/${n}/access_tokens`,{method:`POST`,headers:{Authorization:`Bearer ${i}`,Accept:`application/vnd.github+json`,"User-Agent":`Boltdocs-Feedback`}});if(!a.ok){let e=await a.text();throw Error(`Failed to get installation access token: ${a.status} ${e}`)}return(await a.json()).token}async function a(e,t,n={}){let r=await fetch(`https://api.github.com/graphql`,{method:`POST`,headers:{Authorization:`bearer ${e}`,"Content-Type":`application/json`,"User-Agent":`Boltdocs-Feedback`},body:JSON.stringify({query:t,variables:n})});if(!r.ok){let e=await r.text();throw Error(`GitHub GraphQL API error: ${r.status} ${e}`)}let i=await r.json();if(i.errors?.length){let e=i.errors.map(e=>e.message).join(`, `);throw Error(`GitHub GraphQL Error: ${e}`)}return i.data}async function o(e,t){let n=t.token;if(!n)if(t.appId&&t.privateKey&&t.installationId)n=await i(t.appId,t.privateKey,t.installationId);else throw Error(`GitHub authentication credentials missing. Provide GITHUB_TOKEN or GITHUB_APP_* variables.`);let{owner:r,repo:o,categorySlug:s=`general`}=t,{rating:c,comment:l,path:u,title:d,blockId:f}=e,p=await a(n,`query GetRepoAndCategory($owner: String!, $name: String!, $categorySlug: String!) {
|
|
8
|
+
repository(owner: $owner, name: $name) {
|
|
9
|
+
id
|
|
10
|
+
discussionCategory(slug: $categorySlug) { id }
|
|
11
|
+
}
|
|
12
|
+
}`,{owner:r,name:o,categorySlug:s});if(!p?.repository)throw Error(`Repository not found: ${r}/${o}`);let m=p.repository.id,h=p.repository.discussionCategory?.id;if(!h)throw Error(`Discussion category slug "${s}" not found in ${r}/${o}`);let g=`[Feedback] ${u}`,_=((await a(n,`query FindDiscussion($searchQuery: String!) {
|
|
13
|
+
search(query: $searchQuery, type: DISCUSSION, first: 10) {
|
|
14
|
+
nodes {
|
|
15
|
+
... on Discussion { id title }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}`,{searchQuery:`repo:${r}/${o} in:title "${g}"`}))?.search?.nodes||[]).find(e=>e.title===g)?.id;if(_||=(await a(n,`mutation CreateDiscussion($repositoryId: ID!, $categoryId: ID!, $title: String!, $body: String!) {
|
|
19
|
+
createDiscussion(input: {repositoryId: $repositoryId, categoryId: $categoryId, title: $title, body: $body}) {
|
|
20
|
+
discussion { id }
|
|
21
|
+
}
|
|
22
|
+
}`,{repositoryId:m,categoryId:h,title:g,body:`This discussion thread holds feedback comments for page: [${d}](${u}).`}))?.createDiscussion?.discussion?.id,!_)throw Error(`Failed to resolve or create discussion thread.`);let v=[f?`### Code Block Feedback`:`### Page Feedback`,`- **Page:** [${d}](${u})`,`- **Rating:** ${{good:`😊 GOOD`,neutral:`😐 NEUTRAL`,bad:`🙁 BAD`}[c]}`,f?`- **Block:** ${f}`:``,l?`\n**Comment:**\n${l}`:`
|
|
23
|
+
_No comments provided._`];return await a(n,`mutation AddComment($discussionId: ID!, $body: String!) {
|
|
24
|
+
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
|
|
25
|
+
comment { id }
|
|
26
|
+
}
|
|
27
|
+
}`,{discussionId:_,body:v.filter(Boolean).join(`
|
|
28
|
+
`)}),{success:!0}}var s=e({handleFeedback:()=>l});const c=t.object({rating:t.enum([`good`,`neutral`,`bad`]),path:t.string(),title:t.string(),comment:t.string().optional()});async function l(e,t=process.env,n={}){let r=c.safeParse(e);if(!r.success)throw Error(`Invalid feedback payload`);let i=r.data,a=n.owner||t.GITHUB_REPO_OWNER||t.BOLTDOCS_GITHUB_REPO_OWNER,s=n.repo||t.GITHUB_REPO_NAME||t.BOLTDOCS_GITHUB_REPO_NAME,l=n.categorySlug||t.GITHUB_DISCUSSION_CATEGORY||t.BOLTDOCS_GITHUB_DISCUSSION_CATEGORY||`general`,u=n.token||t.BOLTDOCS_GITHUB_TOKEN||t.GITHUB_TOKEN,d=n.appId||t.GITHUB_APP_ID,f=n.privateKey||t.GITHUB_PRIVATE_KEY,p=n.installationId||t.GITHUB_INSTALLATION_ID;if(!a||!s)throw Error(`GitHub repository coordinates (owner and repo name) are missing. Please set GITHUB_REPO_OWNER and GITHUB_REPO_NAME.`);return await o(i,{owner:a,repo:s,categorySlug:l,token:u,appId:d,privateKey:f,installationId:p}),{success:!0}}export{s as n,l as t};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var e=require(`./chunk-Ds5LZdWN.cjs`).t({SECURITY_HEADERS:()=>t});const t={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains`};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
6
|
+
var e=require(`./chunk-Ds5LZdWN.cjs`).t({SECURITY_HEADERS:()=>t});const t={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains; preload`};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";var t=e({SECURITY_HEADERS:()=>n});const n={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains; preload`};export{t as n,n as t};
|
|
@@ -13,11 +13,17 @@ import * as RAC from "react-aria-components";
|
|
|
13
13
|
const THEME_CONTEXT_SYMBOL = Symbol.for("__BDOCS_THEME_CONTEXT__");
|
|
14
14
|
const THEME_INSTANCE_SYMBOL = Symbol.for("__BDOCS_THEME_INSTANCE__");
|
|
15
15
|
const THEME_EVENT = "boltdocs-theme-change";
|
|
16
|
-
|
|
16
|
+
function isValidTheme(value) {
|
|
17
|
+
return value === "light" || value === "dark" || value === "system";
|
|
18
|
+
}
|
|
19
|
+
const globalStore = globalThis;
|
|
20
|
+
const ThemeContext = globalStore[THEME_CONTEXT_SYMBOL] ?? createContext(void 0);
|
|
21
|
+
globalStore[THEME_CONTEXT_SYMBOL] = ThemeContext;
|
|
17
22
|
function ThemeProvider({ children }) {
|
|
18
23
|
const [theme, setThemeState] = useState(() => {
|
|
19
24
|
if (typeof window !== "undefined") try {
|
|
20
|
-
|
|
25
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
26
|
+
return raw && isValidTheme(raw) ? raw : "system";
|
|
21
27
|
} catch {}
|
|
22
28
|
return "system";
|
|
23
29
|
});
|
|
@@ -32,7 +38,8 @@ function ThemeProvider({ children }) {
|
|
|
32
38
|
};
|
|
33
39
|
useEffect(() => {
|
|
34
40
|
try {
|
|
35
|
-
const
|
|
41
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
42
|
+
const savedTheme = raw && isValidTheme(raw) ? raw : null;
|
|
36
43
|
if (savedTheme) {
|
|
37
44
|
setThemeState(savedTheme);
|
|
38
45
|
applyTheme(savedTheme);
|
|
@@ -41,7 +48,8 @@ function ThemeProvider({ children }) {
|
|
|
41
48
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
42
49
|
const listener = () => {
|
|
43
50
|
try {
|
|
44
|
-
|
|
51
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
52
|
+
if ((raw && isValidTheme(raw) ? raw : "system") === "system") applyTheme("system");
|
|
45
53
|
} catch {}
|
|
46
54
|
};
|
|
47
55
|
mediaQuery.addEventListener("change", listener);
|
|
@@ -60,7 +68,7 @@ function ThemeProvider({ children }) {
|
|
|
60
68
|
resolvedTheme,
|
|
61
69
|
setTheme
|
|
62
70
|
};
|
|
63
|
-
if (typeof globalThis !== "undefined")
|
|
71
|
+
if (typeof globalThis !== "undefined") globalStore[THEME_INSTANCE_SYMBOL] = value;
|
|
64
72
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
65
73
|
value,
|
|
66
74
|
children
|
|
@@ -75,7 +83,7 @@ function useTheme() {
|
|
|
75
83
|
window.addEventListener(THEME_EVENT, handler);
|
|
76
84
|
return () => window.removeEventListener(THEME_EVENT, handler);
|
|
77
85
|
}, [context]);
|
|
78
|
-
if (!context && typeof globalThis !== "undefined" &&
|
|
86
|
+
if (!context && typeof globalThis !== "undefined" && globalStore[THEME_INSTANCE_SYMBOL]) return globalStore[THEME_INSTANCE_SYMBOL];
|
|
79
87
|
if (context === void 0) throw new Error("useTheme must be used within a ThemeProvider");
|
|
80
88
|
return context;
|
|
81
89
|
}
|
|
@@ -14,11 +14,17 @@ react_aria_components = require_icons_dev.__toESM(react_aria_components);
|
|
|
14
14
|
const THEME_CONTEXT_SYMBOL = Symbol.for("__BDOCS_THEME_CONTEXT__");
|
|
15
15
|
const THEME_INSTANCE_SYMBOL = Symbol.for("__BDOCS_THEME_INSTANCE__");
|
|
16
16
|
const THEME_EVENT = "boltdocs-theme-change";
|
|
17
|
-
|
|
17
|
+
function isValidTheme(value) {
|
|
18
|
+
return value === "light" || value === "dark" || value === "system";
|
|
19
|
+
}
|
|
20
|
+
const globalStore = globalThis;
|
|
21
|
+
const ThemeContext = globalStore[THEME_CONTEXT_SYMBOL] ?? (0, react.createContext)(void 0);
|
|
22
|
+
globalStore[THEME_CONTEXT_SYMBOL] = ThemeContext;
|
|
18
23
|
function ThemeProvider({ children }) {
|
|
19
24
|
const [theme, setThemeState] = (0, react.useState)(() => {
|
|
20
25
|
if (typeof window !== "undefined") try {
|
|
21
|
-
|
|
26
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
27
|
+
return raw && isValidTheme(raw) ? raw : "system";
|
|
22
28
|
} catch {}
|
|
23
29
|
return "system";
|
|
24
30
|
});
|
|
@@ -33,7 +39,8 @@ function ThemeProvider({ children }) {
|
|
|
33
39
|
};
|
|
34
40
|
(0, react.useEffect)(() => {
|
|
35
41
|
try {
|
|
36
|
-
const
|
|
42
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
43
|
+
const savedTheme = raw && isValidTheme(raw) ? raw : null;
|
|
37
44
|
if (savedTheme) {
|
|
38
45
|
setThemeState(savedTheme);
|
|
39
46
|
applyTheme(savedTheme);
|
|
@@ -42,7 +49,8 @@ function ThemeProvider({ children }) {
|
|
|
42
49
|
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
43
50
|
const listener = () => {
|
|
44
51
|
try {
|
|
45
|
-
|
|
52
|
+
const raw = window.localStorage.getItem("boltdocs-theme");
|
|
53
|
+
if ((raw && isValidTheme(raw) ? raw : "system") === "system") applyTheme("system");
|
|
46
54
|
} catch {}
|
|
47
55
|
};
|
|
48
56
|
mediaQuery.addEventListener("change", listener);
|
|
@@ -61,7 +69,7 @@ function ThemeProvider({ children }) {
|
|
|
61
69
|
resolvedTheme,
|
|
62
70
|
setTheme
|
|
63
71
|
};
|
|
64
|
-
if (typeof globalThis !== "undefined")
|
|
72
|
+
if (typeof globalThis !== "undefined") globalStore[THEME_INSTANCE_SYMBOL] = value;
|
|
65
73
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeContext.Provider, {
|
|
66
74
|
value,
|
|
67
75
|
children
|
|
@@ -76,7 +84,7 @@ function useTheme() {
|
|
|
76
84
|
window.addEventListener(THEME_EVENT, handler);
|
|
77
85
|
return () => window.removeEventListener(THEME_EVENT, handler);
|
|
78
86
|
}, [context]);
|
|
79
|
-
if (!context && typeof globalThis !== "undefined" &&
|
|
87
|
+
if (!context && typeof globalThis !== "undefined" && globalStore[THEME_INSTANCE_SYMBOL]) return globalStore[THEME_INSTANCE_SYMBOL];
|
|
80
88
|
if (context === void 0) throw new Error("useTheme must be used within a ThemeProvider");
|
|
81
89
|
return context;
|
|
82
90
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
const require_icons_dev = require('./icons-dev-BryEFkJu.cjs');
|
|
7
|
-
const require_image = require('./image-
|
|
7
|
+
const require_image = require('./image-CR6UlaI5.cjs');
|
|
8
8
|
let react = require("react");
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
10
|
let react_aria_components = require("react-aria-components");
|
|
@@ -487,46 +487,33 @@ const ImageComponents = {
|
|
|
487
487
|
//#endregion
|
|
488
488
|
//#region src/client/components/mdx/card.tsx
|
|
489
489
|
function Card({ className, title, icon, href, children, ...props }) {
|
|
490
|
-
const [position, setPosition] = (0, react.useState)({
|
|
491
|
-
x: 0,
|
|
492
|
-
y: 0
|
|
493
|
-
});
|
|
494
|
-
const [opacity, setOpacity] = (0, react.useState)(0);
|
|
495
490
|
const cardRef = (0, react.useRef)(null);
|
|
496
491
|
const handleMouseMove = (e) => {
|
|
497
492
|
if (!cardRef.current) return;
|
|
498
493
|
const rect = cardRef.current.getBoundingClientRect();
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
});
|
|
494
|
+
const x = e.clientX - rect.left;
|
|
495
|
+
const y = e.clientY - rect.top;
|
|
496
|
+
cardRef.current.style.setProperty("--mouse-x", `${x}px`);
|
|
497
|
+
cardRef.current.style.setProperty("--mouse-y", `${y}px`);
|
|
503
498
|
};
|
|
504
|
-
const handleMouseEnter = () => setOpacity(1);
|
|
505
|
-
const handleMouseLeave = () => setOpacity(0);
|
|
506
499
|
const Wrapper = href ? "a" : "div";
|
|
507
500
|
const spotlightColor = "var(--color-primary-500, #eb5828)";
|
|
508
501
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Wrapper, {
|
|
509
502
|
ref: cardRef,
|
|
510
503
|
href,
|
|
511
504
|
onMouseMove: handleMouseMove,
|
|
512
|
-
|
|
513
|
-
onMouseLeave: handleMouseLeave,
|
|
514
|
-
className: require_icons_dev.cn("group relative flex flex-col gap-3 rounded-2xl border p-6 overflow-hidden transition-all duration-300", "hover:shadow-lg dark:hover:shadow-none hover:-translate-y-0.5", "bg-surface border-subtle text-paragraph", href && "cursor-pointer", className),
|
|
505
|
+
className: require_icons_dev.cn("group relative flex flex-col gap-3 rounded-2xl border p-6 overflow-hidden", "transition-[box-shadow,transform] duration-300", "hover:shadow-lg dark:hover:shadow-none hover:-translate-y-0.5", "bg-surface border-subtle text-paragraph", href && "cursor-pointer", className),
|
|
515
506
|
...props,
|
|
516
507
|
children: [
|
|
517
508
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
518
|
-
className: "pointer-events-none absolute inset-0 transition-opacity duration-300",
|
|
519
|
-
style: {
|
|
520
|
-
opacity,
|
|
521
|
-
background: `radial-gradient(600px circle at ${position.x}px ${position.y}px, color-mix(in srgb, ${spotlightColor} 8%, transparent), transparent 40%)`
|
|
522
|
-
}
|
|
509
|
+
className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100",
|
|
510
|
+
style: { background: `radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), color-mix(in srgb, ${spotlightColor} 8%, transparent), transparent 40%)` }
|
|
523
511
|
}),
|
|
524
512
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
525
|
-
className: "pointer-events-none absolute inset-0 rounded-2xl transition-opacity duration-300",
|
|
513
|
+
className: "pointer-events-none absolute inset-0 rounded-2xl opacity-0 transition-opacity duration-300 group-hover:opacity-100",
|
|
526
514
|
style: {
|
|
527
|
-
opacity,
|
|
528
515
|
padding: "1px",
|
|
529
|
-
background: `radial-gradient(400px circle at
|
|
516
|
+
background: `radial-gradient(400px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), color-mix(in srgb, ${spotlightColor} 50%, transparent), transparent 40%)`,
|
|
530
517
|
WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
531
518
|
WebkitMaskComposite: "xor",
|
|
532
519
|
maskComposite: "exclude"
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
import { D as Check, H as Info, M as Copy, R as File, T as AlertTriangle, W as Lightbulb, _ as Link, a as Csv, c as JavaScript, d as React$1, f as Rust, g as Yaml, i as Css, l as Json, m as TypeScript, n as BracketsOrange, p as Shell, r as BracketsRed, rt as useConfig, u as Markdown, w as AlertCircle, y as cn } from "./icons-dev-kJyGWNeg.js";
|
|
7
|
-
import { a as CodeBlockGroup, i as CodeBlockContent, l as useTheme, n as Tooltip, o as CodeBlockHeader, r as CodeBlock$1, s as Heading$1, t as Image$1 } from "./image-
|
|
7
|
+
import { a as CodeBlockGroup, i as CodeBlockContent, l as useTheme, n as Tooltip, o as CodeBlockHeader, r as CodeBlock$1, s as Heading$1, t as Image$1 } from "./image-C9md50h2.js";
|
|
8
8
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { Button } from "react-aria-components";
|
|
@@ -487,46 +487,33 @@ const ImageComponents = {
|
|
|
487
487
|
//#endregion
|
|
488
488
|
//#region src/client/components/mdx/card.tsx
|
|
489
489
|
function Card({ className, title, icon, href, children, ...props }) {
|
|
490
|
-
const [position, setPosition] = useState({
|
|
491
|
-
x: 0,
|
|
492
|
-
y: 0
|
|
493
|
-
});
|
|
494
|
-
const [opacity, setOpacity] = useState(0);
|
|
495
490
|
const cardRef = useRef(null);
|
|
496
491
|
const handleMouseMove = (e) => {
|
|
497
492
|
if (!cardRef.current) return;
|
|
498
493
|
const rect = cardRef.current.getBoundingClientRect();
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
});
|
|
494
|
+
const x = e.clientX - rect.left;
|
|
495
|
+
const y = e.clientY - rect.top;
|
|
496
|
+
cardRef.current.style.setProperty("--mouse-x", `${x}px`);
|
|
497
|
+
cardRef.current.style.setProperty("--mouse-y", `${y}px`);
|
|
503
498
|
};
|
|
504
|
-
const handleMouseEnter = () => setOpacity(1);
|
|
505
|
-
const handleMouseLeave = () => setOpacity(0);
|
|
506
499
|
const Wrapper = href ? "a" : "div";
|
|
507
500
|
const spotlightColor = "var(--color-primary-500, #eb5828)";
|
|
508
501
|
return /* @__PURE__ */ jsxs(Wrapper, {
|
|
509
502
|
ref: cardRef,
|
|
510
503
|
href,
|
|
511
504
|
onMouseMove: handleMouseMove,
|
|
512
|
-
|
|
513
|
-
onMouseLeave: handleMouseLeave,
|
|
514
|
-
className: cn("group relative flex flex-col gap-3 rounded-2xl border p-6 overflow-hidden transition-all duration-300", "hover:shadow-lg dark:hover:shadow-none hover:-translate-y-0.5", "bg-surface border-subtle text-paragraph", href && "cursor-pointer", className),
|
|
505
|
+
className: cn("group relative flex flex-col gap-3 rounded-2xl border p-6 overflow-hidden", "transition-[box-shadow,transform] duration-300", "hover:shadow-lg dark:hover:shadow-none hover:-translate-y-0.5", "bg-surface border-subtle text-paragraph", href && "cursor-pointer", className),
|
|
515
506
|
...props,
|
|
516
507
|
children: [
|
|
517
508
|
/* @__PURE__ */ jsx("div", {
|
|
518
|
-
className: "pointer-events-none absolute inset-0 transition-opacity duration-300",
|
|
519
|
-
style: {
|
|
520
|
-
opacity,
|
|
521
|
-
background: `radial-gradient(600px circle at ${position.x}px ${position.y}px, color-mix(in srgb, ${spotlightColor} 8%, transparent), transparent 40%)`
|
|
522
|
-
}
|
|
509
|
+
className: "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100",
|
|
510
|
+
style: { background: `radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), color-mix(in srgb, ${spotlightColor} 8%, transparent), transparent 40%)` }
|
|
523
511
|
}),
|
|
524
512
|
/* @__PURE__ */ jsx("div", {
|
|
525
|
-
className: "pointer-events-none absolute inset-0 rounded-2xl transition-opacity duration-300",
|
|
513
|
+
className: "pointer-events-none absolute inset-0 rounded-2xl opacity-0 transition-opacity duration-300 group-hover:opacity-100",
|
|
526
514
|
style: {
|
|
527
|
-
opacity,
|
|
528
515
|
padding: "1px",
|
|
529
|
-
background: `radial-gradient(400px circle at
|
|
516
|
+
background: `radial-gradient(400px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), color-mix(in srgb, ${spotlightColor} 50%, transparent), transparent 40%)`,
|
|
530
517
|
WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
|
|
531
518
|
WebkitMaskComposite: "xor",
|
|
532
519
|
maskComposite: "exclude"
|