boltdocs 2.6.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +41 -37
- package/dist/client/index.d.ts +41 -37
- package/dist/client/index.js +1 -1
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +30 -3
- package/dist/node/index.d.mts +30 -3
- package/dist/node/index.mjs +1 -1
- package/dist/node-Bogvkxao.mjs +101 -0
- package/dist/node-CXaog6St.cjs +101 -0
- package/dist/{package-CR0HF9x3.mjs → package-Bqbn1AYK.mjs} +1 -1
- package/dist/{package-Dgmsc_l5.cjs → package-CFP44vfn.cjs} +1 -1
- package/dist/{search-dialog-DMK5OpgH.cjs → search-dialog-CV3eJzMm.cjs} +1 -1
- package/dist/{search-dialog-3lvKsbVG.js → search-dialog-DNTomKgu.js} +1 -1
- package/dist/use-search-CS3gH19M.js +6 -0
- package/dist/use-search-DBpJZQuw.cjs +6 -0
- package/package.json +3 -2
- package/src/client/components/ui-base/head.tsx +10 -3
- package/src/client/hooks/use-i18n.ts +4 -3
- package/src/client/hooks/use-localized-to.ts +1 -4
- package/src/client/hooks/use-routes.ts +4 -4
- package/src/client/hooks/use-sidebar.ts +3 -0
- package/src/client/hooks/use-version.ts +19 -6
- package/src/client/index.ts +2 -3
- package/src/client/ssg/boltdocs-shell.tsx +46 -14
- package/src/client/ssg/create-routes.tsx +56 -12
- package/src/client/store/boltdocs-context.tsx +24 -5
- package/src/shared/config-utils.ts +12 -0
- package/src/shared/types.ts +187 -0
- package/dist/node-BgvNl2Ay.mjs +0 -89
- package/dist/node-vkbb0MK7.cjs +0 -89
- package/dist/use-search-C9bxCqfF.js +0 -6
- package/dist/use-search-DcfZSunO.cjs +0 -6
- package/src/client/components/default-layout.tsx +0 -89
|
@@ -18,17 +18,36 @@ const BoltdocsContext =
|
|
|
18
18
|
BoltdocsState | undefined
|
|
19
19
|
>(undefined))
|
|
20
20
|
|
|
21
|
-
export function BoltdocsProvider({
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export function BoltdocsProvider({
|
|
22
|
+
children,
|
|
23
|
+
initialLocale = '',
|
|
24
|
+
initialVersion = '',
|
|
25
|
+
}: {
|
|
26
|
+
children: React.ReactNode
|
|
27
|
+
initialLocale?: string
|
|
28
|
+
initialVersion?: string
|
|
29
|
+
}) {
|
|
30
|
+
const getInitialState = () => {
|
|
31
|
+
if (typeof window === 'undefined')
|
|
32
|
+
return { locale: initialLocale, version: initialVersion }
|
|
33
|
+
const parts = window.location.pathname.split('/').filter(Boolean)
|
|
34
|
+
let locale = initialLocale
|
|
35
|
+
let version = initialVersion
|
|
36
|
+
// ...
|
|
37
|
+
return { locale, version }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const initialState = getInitialState()
|
|
41
|
+
const [locale, setLocale] = useState(initialState.locale)
|
|
42
|
+
const [version, setVersion] = useState(initialState.version)
|
|
24
43
|
const [hasHydrated, setHasHydrated] = useState(false)
|
|
25
44
|
|
|
26
45
|
const value = useMemo(
|
|
27
46
|
() => ({
|
|
28
47
|
currentLocale: locale,
|
|
29
48
|
currentVersion: version,
|
|
30
|
-
setLocale,
|
|
31
|
-
setVersion,
|
|
49
|
+
setLocale: (l: string) => setLocale(l || ''),
|
|
50
|
+
setVersion: (v: string) => setVersion(v || ''),
|
|
32
51
|
hasHydrated,
|
|
33
52
|
setHasHydrated,
|
|
34
53
|
}),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BoltdocsConfig } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type-safe helper for defining Boltdocs configuration.
|
|
5
|
+
* This is an identity function that provides IntelliSense in both
|
|
6
|
+
* Node.js (config files) and client-side code (MDX examples).
|
|
7
|
+
*
|
|
8
|
+
* @param config - The Boltdocs configuration object
|
|
9
|
+
*/
|
|
10
|
+
export function defineConfig(config: BoltdocsConfig): BoltdocsConfig {
|
|
11
|
+
return config
|
|
12
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { Plugin as VitePlugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single social link in the configuration.
|
|
5
|
+
*/
|
|
6
|
+
export interface BoltdocsSocialLink {
|
|
7
|
+
icon: 'discord' | 'x' | 'github' | 'bluesky' | string
|
|
8
|
+
link: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the site footer.
|
|
13
|
+
*/
|
|
14
|
+
export interface BoltdocsFooterConfig {
|
|
15
|
+
text?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Theme-specific configuration options.
|
|
20
|
+
*/
|
|
21
|
+
export interface BoltdocsThemeConfig {
|
|
22
|
+
title?: string | Record<string, string>
|
|
23
|
+
description?: string | Record<string, string>
|
|
24
|
+
logo?:
|
|
25
|
+
| string
|
|
26
|
+
| {
|
|
27
|
+
dark: string
|
|
28
|
+
light: string
|
|
29
|
+
alt?: string
|
|
30
|
+
width?: number
|
|
31
|
+
height?: number
|
|
32
|
+
}
|
|
33
|
+
navbar?: Array<{
|
|
34
|
+
label: string | Record<string, string>
|
|
35
|
+
href: string
|
|
36
|
+
}>
|
|
37
|
+
sidebar?: Record<string, Array<{ text: string; link: string }>>
|
|
38
|
+
sidebarGroups?: Record<string, { title?: string | Record<string, string>; icon?: string }>
|
|
39
|
+
socialLinks?: BoltdocsSocialLink[]
|
|
40
|
+
footer?: BoltdocsFooterConfig
|
|
41
|
+
breadcrumbs?: boolean
|
|
42
|
+
editLink?: string
|
|
43
|
+
communityHelp?: string
|
|
44
|
+
version?: string
|
|
45
|
+
githubRepo?: string
|
|
46
|
+
favicon?: string
|
|
47
|
+
poweredBy?: boolean
|
|
48
|
+
tabs?: Array<{
|
|
49
|
+
id: string
|
|
50
|
+
text: string | Record<string, string>
|
|
51
|
+
icon?: string
|
|
52
|
+
}>
|
|
53
|
+
codeTheme?: ShikiTheme | { light: ShikiTheme; dark: ShikiTheme }
|
|
54
|
+
copyMarkdown?: boolean | { text?: string; icon?: string }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List of supported syntax highlighting themes.
|
|
59
|
+
*/
|
|
60
|
+
export type ShikiTheme =
|
|
61
|
+
| 'github-dark'
|
|
62
|
+
| 'github-light'
|
|
63
|
+
| 'tokyo-night'
|
|
64
|
+
| 'dracula'
|
|
65
|
+
| 'nord'
|
|
66
|
+
| 'one-dark-pro'
|
|
67
|
+
| 'one-light'
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Configuration for the robots.txt file.
|
|
71
|
+
*/
|
|
72
|
+
export type BoltdocsRobotsConfig =
|
|
73
|
+
| string
|
|
74
|
+
| {
|
|
75
|
+
rules?: Array<{
|
|
76
|
+
userAgent: string
|
|
77
|
+
allow?: string | string[]
|
|
78
|
+
disallow?: string | string[]
|
|
79
|
+
}>
|
|
80
|
+
sitemaps?: string[]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for a specific locale.
|
|
85
|
+
*/
|
|
86
|
+
export interface BoltdocsLocaleConfig {
|
|
87
|
+
label?: string
|
|
88
|
+
direction?: 'ltr' | 'rtl'
|
|
89
|
+
htmlLang?: string
|
|
90
|
+
calendar?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Configuration for internationalization (i18n).
|
|
95
|
+
*/
|
|
96
|
+
export interface BoltdocsI18nConfig {
|
|
97
|
+
defaultLocale: string
|
|
98
|
+
locales: string[] | Record<string, string>
|
|
99
|
+
localeConfigs?: Record<string, BoltdocsLocaleConfig>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Configuration for a specific documentation version.
|
|
104
|
+
*/
|
|
105
|
+
export interface BoltdocsVersionConfig {
|
|
106
|
+
label: string
|
|
107
|
+
path: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Configuration for documentation versioning.
|
|
112
|
+
*/
|
|
113
|
+
export interface BoltdocsVersionsConfig {
|
|
114
|
+
defaultVersion: string
|
|
115
|
+
prefix?: string
|
|
116
|
+
versions: BoltdocsVersionConfig[]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Defines a Boltdocs plugin.
|
|
121
|
+
*/
|
|
122
|
+
export interface BoltdocsPlugin {
|
|
123
|
+
name: string
|
|
124
|
+
enforce?: 'pre' | 'post'
|
|
125
|
+
version?: string
|
|
126
|
+
boltdocsVersion?: string
|
|
127
|
+
permissions?: string[] // simplified for shared types
|
|
128
|
+
remarkPlugins?: unknown[]
|
|
129
|
+
rehypePlugins?: unknown[]
|
|
130
|
+
vitePlugins?: VitePlugin[]
|
|
131
|
+
components?: Record<string, string>
|
|
132
|
+
hooks?: Record<string, any>
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Configuration for security-related settings.
|
|
137
|
+
*/
|
|
138
|
+
export interface BoltdocsSecurityConfig {
|
|
139
|
+
headers?: Record<string, string>
|
|
140
|
+
enableCSP?: boolean
|
|
141
|
+
customHeaders?: Record<string, string>
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Configuration for SEO.
|
|
146
|
+
*/
|
|
147
|
+
export interface BoltdocsSeoConfig {
|
|
148
|
+
metatags?: Record<string, string>
|
|
149
|
+
indexing?: 'all' | 'public'
|
|
150
|
+
thumbnails?: {
|
|
151
|
+
background?: string
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The root configuration object for Boltdocs.
|
|
157
|
+
*/
|
|
158
|
+
export interface BoltdocsConfig {
|
|
159
|
+
siteUrl?: string
|
|
160
|
+
docsDir?: string
|
|
161
|
+
base?: string
|
|
162
|
+
homePage?: string
|
|
163
|
+
theme?: BoltdocsThemeConfig
|
|
164
|
+
i18n?: BoltdocsI18nConfig
|
|
165
|
+
versions?: BoltdocsVersionsConfig
|
|
166
|
+
plugins?: BoltdocsPlugin[]
|
|
167
|
+
robots?: BoltdocsRobotsConfig
|
|
168
|
+
security?: BoltdocsSecurityConfig
|
|
169
|
+
seo?: BoltdocsSeoConfig
|
|
170
|
+
vite?: any // Avoid pulling in entire Vite types here
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Global namespace for Boltdocs types that can be augmented by generated code.
|
|
175
|
+
* This allows for strictly typed locales and versions based on the project configuration.
|
|
176
|
+
*/
|
|
177
|
+
declare global {
|
|
178
|
+
namespace Boltdocs {
|
|
179
|
+
interface Types {}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type BoltdocsTypes = Boltdocs.Types
|
|
184
|
+
|
|
185
|
+
export type BoltdocsLocale = Boltdocs.Types extends { Locale: infer L } ? L : string
|
|
186
|
+
export type BoltdocsVersion = Boltdocs.Types extends { Version: infer V } ? V : string
|
|
187
|
+
|
package/dist/node-BgvNl2Ay.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import e from"@vitejs/plugin-react";import t from"@tailwindcss/vite";import n from"node:path";import{fileURLToPath as r}from"node:url";import{loadConfigFromFile as i,loadEnv as a,normalizePath as o}from"vite";import s from"fast-glob";import c from"fs";import l from"gray-matter";import u from"isomorphic-dompurify";import{z as d}from"zod";import f from"path";import p from"crypto";import m from"zlib";import{promisify as h}from"util";import ee from"github-slugger";import{ViteImageOptimizer as te}from"vite-plugin-image-optimizer";import g from"node:fs";import _ from"semver";import v from"@mdx-js/rollup";import ne from"remark-gfm";import re from"remark-frontmatter";import ie from"rehype-slug";import{visit as y}from"unist-util-visit";import{createJavaScriptRegexEngine as b}from"shiki/engine/javascript";import{createHighlighterCore as x}from"shiki/core";import S from"@shikijs/themes/github-light";import C from"@shikijs/themes/github-dark";import ae from"@shikijs/themes/tokyo-night";import w from"@shikijs/themes/dracula";import T from"@shikijs/themes/nord";import E from"@shikijs/themes/one-dark-pro";import oe from"@shikijs/themes/one-light";import D from"@shikijs/langs/html";import se from"@shikijs/langs/js";import ce from"@shikijs/langs/ts";import le from"@shikijs/langs/tsx";import ue from"@shikijs/langs/css";import de from"@shikijs/langs/json";import fe from"@shikijs/langs/bash";import pe from"@shikijs/langs/markdown";import me from"@shikijs/langs/mdx";import he from"@shikijs/langs/yaml";import ge from"@shikijs/langs/rust";import _e from"@shikijs/langs/toml";const O=n.dirname(r(import.meta.url)),ve=/^[a-zA-Z0-9\-_\/\.\(\)]+$/,ye=d.object({title:d.string().max(200).optional(),description:d.string().max(500).optional(),sidebarPosition:d.number().optional(),sidebarLabel:d.string().max(100).optional(),category:d.string().max(50).optional(),order:d.number().optional(),badge:d.string().max(50).optional(),icon:d.string().max(50).optional()});var k=class e extends Error{constructor(t){super(t),this.name=`SecurityViolationError`,Object.setPrototypeOf(this,e.prototype)}},be=class e extends k{constructor(t){super(t),this.name=`PathTraversalError`,Object.setPrototypeOf(this,e.prototype)}},xe=class e extends k{constructor(t){super(t),this.name=`EncodingSecurityError`,Object.setPrototypeOf(this,e.prototype)}},A=class e extends k{constructor(t){super(t),this.name=`ValidationError`,Object.setPrototypeOf(this,e.prototype)}};function j(e){return e.replace(/\\/g,`/`)}function M(e){return e.replace(/^\d+\./,``)}function Se(e){let t=e.match(/^(\d+)\./);return t?parseInt(t[1],10):void 0}function Ce(e){return/\.mdx?$/.test(e)}function N(e){try{return c.statSync(e).mtimeMs}catch{return 0}}function we(e){let t=c.readFileSync(e,`utf-8`);try{let{data:n,content:r,matter:i}=l(t);if(i&&i.length>10240)throw L(`FRONTMATTER_TOO_LARGE`,`Frontmatter block exceeds size limit`,{size:i.length,file:e}),new A(`Security breach: Frontmatter size exceeds limit of 10240 bytes`);let a=ye.safeParse(n);a.success||console.warn(`[VALIDATION][${e}] Invalid frontmatter fields detected.`);let o={...a.success?a.data:{}};return o.title&&=F(o.title).trim(),o.description&&=F(o.description).trim(),{data:o,content:r}}catch(e){if(e instanceof A)throw e;return{data:{},content:t}}}function Te(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function Ee(e){return Te(e)}function De(e){let t=e.split(`/`).map(e=>M(Oe(e))).join(`/`).replace(/\/$/,``);return t=t.replace(/\.mdx?$/,``),(t===`index`||t.endsWith(`/index`))&&(t=t.replace(/index$/,``)),t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function P(e){return u.sanitize(e,{ALLOWED_TAGS:`b.i.em.strong.a.p.br.code.pre.span.div.h1.h2.h3.h4.h5.h6.ul.ol.li.table.thead.tbody.tr.th.td.blockquote.hr`.split(`.`),ALLOWED_ATTR:[`href`,`title`,`target`,`class`,`id`,`src`,`alt`,`width`,`height`],FORCE_BODY:!0})}u.addHook(`afterSanitizeAttributes`,e=>{if(e.hasAttribute(`href`)){let t=e.getAttribute(`href`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`href`)}if(e.hasAttribute(`src`)){let t=e.getAttribute(`src`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`src`)}});function F(e){return u.sanitize(e,{ALLOWED_TAGS:[],KEEP_CONTENT:!0})}function I(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oe(e){return e.replace(/[^a-zA-Z0-9\-_\/\.]/g,``).split(`/`).filter(e=>e!==`..`&&e!==`.`).map(e=>e.replace(/\.\.+/g,`.`)).join(`/`)}function L(e,t,n={}){let r=new Date().toISOString(),i={...n};for(let e in i)typeof i[e]==`string`&&i[e].includes(`:`)&&(i[e]=i[e].split(/[\\/]/).pop()||i[e]);console.error(`[SECURITY][${r}] TYPE: ${e} | MESSAGE: ${t} | DETAILS: ${JSON.stringify(i)}`)}const R=h(c.writeFile),ke=h(c.readFile),z=h(c.mkdir),Ae=h(c.rename);h(c.unlink);const je=process.env.BOLTDOCS_CACHE_DIR||`.boltdocs`,Me=parseInt(process.env.BOLTDOCS_CACHE_LRU_LIMIT||`2000`,10),Ne=process.env.BOLTDOCS_CACHE_COMPRESS!==`0`;var Pe=class{cache=new Map;constructor(e){this.limit=e}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.limit){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}this.cache.set(e,t)}get size(){return this.cache.size}clear(){this.cache.clear()}};const B=new class{queue=Promise.resolve();pendingCount=0;add(e){this.pendingCount++,this.queue=this.queue.then(e).finally(()=>{this.pendingCount--})}async flush(){await this.queue}get pending(){return this.pendingCount}};var Fe=class{entries=new Map;cachePath=null;compress;constructor(e={}){if(this.compress=e.compress===void 0?Ne:e.compress,e.name){let t=e.root||process.cwd(),n=this.compress?`json.gz`:`json`;this.cachePath=f.resolve(t,je,`${e.name}.${n}`)}}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&!(!this.cachePath||!c.existsSync(this.cachePath)))try{let e=c.readFileSync(this.cachePath);this.cachePath.endsWith(`.gz`)&&(e=m.gunzipSync(e));let t=JSON.parse(e.toString(`utf-8`));this.entries=new Map(Object.entries(t))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`||!this.cachePath)return;let e=Object.fromEntries(this.entries),t=JSON.stringify(e),n=this.cachePath,r=this.compress;B.add(async()=>{try{await z(f.dirname(n),{recursive:!0});let e=Buffer.from(t);r&&(e=m.gzipSync(e));let i=`${n}.${p.randomBytes(4).toString(`hex`)}.tmp`;await R(i,e),await Ae(i,n)}catch{}})}get(e){let t=this.entries.get(e);return!t||N(e)!==t.mtime?null:t.data}set(e,t){this.entries.set(e,{data:t,mtime:N(e)})}isValid(e){let t=this.entries.get(e);return t?N(e)===t.mtime:!1}invalidate(e){this.entries.delete(e)}invalidateAll(){this.entries.clear()}pruneStale(e){for(let t of this.entries.keys())e.has(t)||this.entries.delete(t)}get size(){return this.entries.size}async flush(){await B.flush()}},Ie=class{index=new Map;memoryCache=new Pe(Me);baseDir;shardsDir;indexPath;constructor(e,t=process.cwd()){this.baseDir=f.resolve(t,je,`transform-${e}`),this.shardsDir=f.resolve(this.baseDir,`shards`),this.indexPath=f.resolve(this.baseDir,`index.json`)}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&c.existsSync(this.indexPath))try{let e=c.readFileSync(this.indexPath,`utf-8`);this.index=new Map(Object.entries(JSON.parse(e)))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`)return;let e=JSON.stringify(Object.fromEntries(this.index)),t=this.indexPath;B.add(async()=>{await z(f.dirname(t),{recursive:!0}),await R(t,e)})}async getMany(e){let t=new Map,n=[];for(let r of e){let e=this.memoryCache.get(r);e?t.set(r,e):this.index.has(r)&&n.push(r)}if(n.length>0){let e=await Promise.all(n.map(async e=>{let t=this.index.get(e),n=f.resolve(this.shardsDir,`${t}.gz`);try{let t=await ke(n),r=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,r),{key:e,val:r}}catch{return null}}));for(let n of e)n&&t.set(n.key,n.val)}return t}get(e){let t=this.memoryCache.get(e);if(t)return t;let n=this.index.get(e);if(!n)return null;let r=f.resolve(this.shardsDir,`${n}.gz`);if(!c.existsSync(r))return null;try{let t=c.readFileSync(r),n=m.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,n),n}catch{return null}}set(e,t){let n=p.createHash(`md5`).update(t).digest(`hex`);this.index.set(e,n),this.memoryCache.set(e,t);let r=f.resolve(this.shardsDir,`${n}.gz`);B.add(async()=>{if(c.existsSync(r))return;await z(this.shardsDir,{recursive:!0});let e=m.gzipSync(Buffer.from(t)),n=`${r}.${p.randomBytes(4).toString(`hex`)}.tmp`;await R(n,e),await Ae(n,r)})}get size(){return this.index.size}async flush(){await B.flush()}};const V=new Fe({name:`routes`});function Le(){V.invalidateAll()}function Re(e){V.invalidate(e)}function ze(e,t,n,r){let i;try{i=decodeURIComponent(e)}catch{let t=f.basename(e);throw L(`ENCODING_ERROR`,`Invalid character encoding`,{file:t}),new xe(`Security breach: Invalid characters or encoding in path: ${t}`)}if(i.length>260){let e=f.basename(i);throw L(`PATH_TOO_LONG`,`Path length exceeds limit`,{length:i.length,file:e}),new be(`Security breach: Path length exceeds limit of 260 characters: ${e}`)}let a=f.resolve(i),o=f.resolve(t),s=j(f.relative(o,a));if(s.startsWith(`../`)||s===`..`||a.includes(`\0`)||!ve.test(s)){let t=f.basename(e);throw L(`PATH_TRAVERSAL_ATTEMPT`,`Path traversal or invalid characters detected`,{path:s}),new be(`Security breach: File is outside of docs directory, contains null bytes, or invalid characters: ${t}`)}let{data:c,content:l}=we(e),u=s.split(`/`),d,p;if(r?.versions&&u.length>0){let e=u[0],t=r.versions.prefix||``,n=r.versions.versions.find(n=>e===t+n.path||e===n.path);n&&(p=n.path,u=u.slice(1))}if(r?.i18n&&u.length>0){let e=u[0];r.i18n.locales[e]&&(d=e,u=u.slice(1))}let m;if(u.length>0){let e=u[0].match(/^\((.+)\)$/);e&&(m=e[1].toLowerCase(),u=u.slice(1))}let h;u=u.map(e=>{let t=M(e);return t.startsWith(`_`)&&t!==`_`?(h=t.substring(1),e.substring(0,e.length-t.length)+t.substring(1)):e});let te=u.join(`/`),g;g=c.permalink?c.permalink.startsWith(`/`)?c.permalink:`/${c.permalink}`:De(te||`index.md`);let _=n;p&&(_+=`/`+p),d&&(_+=`/`+d),m&&(_+=`/`+m),_+=g===`/`?``:g,(!_||_===``)&&(_=`/`);let v=u[u.length-1],ne=M(v),re=M(f.basename(e,f.extname(e))),ie=c.sidebarPosition??Se(v),y=u.length>=2?u[0]:void 0,b=y?M(y):void 0,x=u.length===2&&/^index\.mdx?$/.test(ne),S=new ee,C=[];for(let e of l.matchAll(/^(#{2,4})\s+(.+)$/gm)){let t=e[1].length,n=P(e[2].replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).trim()).trim(),r=S.slug(n);C.push({level:t,text:n,id:r})}let ae=c.title?P(String(c.title)):re,w=c.description?P(String(c.description)):``;!w&&l&&(w=F(l.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim().slice(0,160));let T=c.badge?P(String(c.badge)):void 0,E=c.icon?String(c.icon):void 0,oe=Be(l),D={},se=[`og:`,`twitter:`,`article:`,`music:`,`video:`,`profile:`,`book:`],ce=[`noindex`,`robots`,`canonical`,`keywords`,`author`];c.seo&&typeof c.seo==`object`&&Object.assign(D,c.seo);for(let e of Object.keys(c))(ce.includes(e)||se.some(t=>e.startsWith(t)))&&(D[e]=c[e]);return c.hidden===!0&&D.noindex===void 0&&(D.noindex=!0),{route:{path:_,componentPath:e,filePath:s,title:ae,description:w,sidebarPosition:ie,headings:C,locale:d,version:p,badge:T,icon:E,tab:m,subRouteGroup:h,_content:oe,_rawContent:l,seo:Object.keys(D).length>0?D:void 0},relativeDir:b,isGroupIndex:x,inferredTab:m,groupMeta:x?{title:c.groupTitle||c.title||(b?I(b):``),position:c.groupPosition??c.sidebarPosition??(y?Se(y):void 0),icon:E}:void 0,inferredGroupPosition:y?Se(y):void 0}}function Be(e){return F(e.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/\{[^\}]+\}/g,``).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim()}function Ve(e){return e.sort((e,t)=>!e.group&&!t.group?He(e,t):e.group?t.group?e.group===t.group?He(e,t):Ue(e,t):1:-1)}function He(e,t){return e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0?e.sidebarPosition-t.sidebarPosition:e.sidebarPosition===void 0?t.sidebarPosition===void 0?e.title.localeCompare(t.title):1:-1}function Ue(e,t){return e.groupPosition!==void 0&&t.groupPosition!==void 0?e.groupPosition-t.groupPosition:e.groupPosition===void 0?t.groupPosition===void 0?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):1:-1}let H=null;const U=new Map;async function W(e,t,n=`/docs`,r=!0){V.load(),U.clear(),(process.env.BOLTDOCS_FORCE_REPARSE===`true`||t?.i18n)&&V.invalidateAll();let i;!r&&H?i=H:(i=await s([`**/*.md`,`**/*.mdx`],{cwd:e,absolute:!0,suppressErrors:!0,followSymbolicLinks:!1}),H=i),V.pruneStale(new Set(i));let a=[],o=0;for(let r=0;r<i.length;r+=50){let s=i.slice(r,r+50),c=await Promise.all(s.map(async r=>{let i=V.get(r);if(i)return o++,i;let a=ze(r,e,n,t);return V.set(r,a),a}));a.push(...c),r+50<i.length&&await new Promise(e=>setImmediate(e))}V.save();let c=new Map,l=[];for(let e of a)if(e.isGroupIndex&&e.relativeDir&&l.push(e),e.relativeDir){let t=c.get(e.relativeDir);t?t.position===void 0&&e.inferredGroupPosition!==void 0&&(t.position=e.inferredGroupPosition):(t={title:I(e.relativeDir),position:e.inferredGroupPosition},c.set(e.relativeDir,t))}for(let e of l){let t=c.get(e.relativeDir);e.groupMeta&&(t.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(t.position=e.groupMeta.position),e.groupMeta.icon&&(t.icon=e.groupMeta.icon))}if(t?.theme?.sidebarGroups)for(let[e,n]of Object.entries(t.theme.sidebarGroups)){let t=c.get(e);t?(n.title&&(t.title=n.title),n.icon&&(t.icon=n.icon)):c.set(e,{title:n.title||I(e),icon:n.icon})}let u=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e],n=t.relativeDir,r=n?c.get(n):void 0;u[e]={...t.route,group:n,groupTitle:r?.title||(n?I(n):void 0),groupPosition:r?.position,groupIcon:r?.icon}}let d=u;if(t?.i18n){let e=We(u,t,n);d=[...u,...e]}return Ve(d)}function We(e,t,n){let r=t.i18n.defaultLocale,i=Object.keys(t.i18n.locales),a=[],o=new Map,s=[];for(let t of e){let e=t.locale||r;o.has(e)||o.set(e,new Set),o.get(e).add(t.path),e===r&&s.push(t)}for(let e of i){let i=o.get(e)||new Set;for(let o of s){let s=Ge(o.path,r,e,n,t);s!==o.path&&(i.has(s)||a.push({...o,path:s,locale:e}))}}return a}function Ge(e,t,n,r,i){let a=`${e}:${n}`,o=U.get(a);if(o)return o;let s=r;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let i=t+n.path;if(e.startsWith(`${r}/${i}`)){s+=`/`+i;break}if(e.startsWith(`${r}/${n.path}`)){s+=`/`+n.path;break}}}let c=e.substring(s.length),l=`/${t}`;if(c.startsWith(l+`/`))c=`/`+n+`/`+c.substring(l.length+1);else if(c===l)c=`/`+n;else if(c===`/`||c===``)c=`/`+n;else{let e=c.startsWith(`/`)?``:`/`;c=`/`+n+e+c}let u=s+c;return U.size>2e3&&U.clear(),U.set(a,u),u}function Ke(e){return e.map(e=>({path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],_content:e._content||``,locale:e.locale,version:e.version,tab:e.tab,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo}))}const qe=d.object({icon:d.string().max(50),link:d.string().url()}),Je=d.object({text:d.string().max(2e3).optional()}),Ye=d.enum([`fs:read`,`fs:write`,`vite:config`,`mdx:remark`,`mdx:rehype`,`components`,`hooks:build`,`hooks:dev`]),Xe=d.object({name:d.string(),enforce:d.enum([`pre`,`post`]).optional(),version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(Ye).optional(),remarkPlugins:d.array(d.any()).optional(),rehypePlugins:d.array(d.any()).optional(),vitePlugins:d.array(d.any()).optional(),components:d.record(d.string(),d.string()).optional(),hooks:d.record(d.string(),d.any()).optional()}),Ze=d.object({title:d.union([d.string(),d.record(d.string(),d.string())]).optional(),description:d.union([d.string(),d.record(d.string(),d.string())]).optional(),logo:d.union([d.string(),d.object({dark:d.string(),light:d.string(),alt:d.string().optional(),width:d.number().optional(),height:d.number().optional()})]).optional(),navbar:d.array(d.object({label:d.union([d.string(),d.record(d.string(),d.string())]),href:d.string()})).optional(),sidebar:d.record(d.string(),d.array(d.object({text:d.string(),link:d.string()}))).optional(),sidebarGroups:d.record(d.string(),d.object({title:d.string().optional(),icon:d.string().optional()})).optional(),socialLinks:d.array(qe).optional(),footer:Je.optional(),breadcrumbs:d.boolean().optional(),editLink:d.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:d.string().url().optional(),version:d.string().max(50).optional(),githubRepo:d.string().max(100).optional(),favicon:d.string().optional(),poweredBy:d.boolean().optional(),tabs:d.array(d.object({id:d.string(),text:d.union([d.string(),d.record(d.string(),d.string())]),icon:d.string().optional()})).optional(),codeTheme:d.union([d.string(),d.object({light:d.string(),dark:d.string()})]).optional(),copyMarkdown:d.union([d.boolean(),d.object({text:d.string().optional(),icon:d.string().optional()})]).optional()}),Qe=d.union([d.string(),d.object({rules:d.array(d.object({userAgent:d.string(),allow:d.union([d.string(),d.array(d.string())]).optional(),disallow:d.union([d.string(),d.array(d.string())]).optional()})).optional(),sitemaps:d.array(d.string().url()).optional()})]),$e=d.object({defaultLocale:d.string(),locales:d.record(d.string(),d.string()),localeConfigs:d.record(d.string(),d.object({label:d.string().optional(),direction:d.enum([`ltr`,`rtl`]).optional(),htmlLang:d.string().optional(),calendar:d.string().optional()})).optional()}),et=d.object({defaultVersion:d.string(),prefix:d.string().optional(),versions:d.array(d.object({label:d.string(),path:d.string()}))}),tt=d.object({headers:d.record(d.string(),d.string()).optional(),enableCSP:d.boolean().optional(),customHeaders:d.record(d.string(),d.string()).optional()}),nt=d.object({metatags:d.record(d.string(),d.string()).optional(),indexing:d.enum([`all`,`public`]).optional(),thumbnails:d.object({background:d.string().optional()}).optional()}),rt=d.object({siteUrl:d.string().url().optional(),docsDir:d.string().optional(),homePage:d.string().optional(),theme:Ze.optional(),i18n:$e.optional(),versions:et.optional(),plugins:d.array(Xe).optional(),robots:Qe.optional(),security:tt.optional(),seo:nt.optional(),vite:d.record(d.string(),d.unknown()).optional()});function it(e){return e}const G=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function K(e,t=process.cwd()){let r=t,a={docsDir:n.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`},poweredBy:!0,breadcrumbs:!0}},o={};for(let e of G){let t=n.resolve(r,e);if(g.existsSync(t))try{let e=await i({command:`serve`,mode:`development`},t,r);if(e){o=e.config;break}}catch(t){console.warn(`[boltdocs] Failed to load config from ${e}:`,t)}}let s={title:o.title,description:o.description,logo:o.logo,favicon:o.favicon,navbar:o.navbar,sidebar:o.sidebar,sidebarGroups:o.theme?.sidebarGroups,socialLinks:o.socialLinks,footer:o.footer,githubRepo:o.githubRepo,tabs:o.tabs,codeTheme:o.codeTheme,copyMarkdown:o.copyMarkdown,breadcrumbs:o.breadcrumbs,poweredBy:o.poweredBy,communityHelp:o.communityHelp,version:o.version,editLink:o.editLink,...o.theme||{}},c=Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));c.navbar&&=c.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``}));let l={docsDir:n.resolve(e),homePage:o.homePage,theme:{...a.theme,...c},i18n:o.i18n,versions:o.versions,siteUrl:o.siteUrl,plugins:o.plugins||[],robots:o.robots,security:o.security,vite:o.vite},u=rt.safeParse(l);if(!u.success)throw new A(`Invalid Boltdocs configuration:\n${u.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
7
|
-
`)}`);return u.data}function at(e,t){let n=(t.siteUrl||``).replace(/\/$/,``);if(!n)return``;let r=t.seo?.indexing!==`all`&&t.seo?.indexing!==`public`;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
8
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
9
|
-
${e.filter(e=>e.seo?.noindex||typeof e.seo?.robots==`string`&&e.seo.robots.includes(`noindex`)?!1:(r&&e.seo?.index,!0)).map(e=>` <url>
|
|
10
|
-
<loc>${Ee(`${n}${e.path.startsWith(`/`)?e.path:`/${e.path}`}`)}</loc>
|
|
11
|
-
<changefreq>weekly</changefreq>
|
|
12
|
-
<priority>0.7</priority>
|
|
13
|
-
</url>`).join(`
|
|
14
|
-
`)}
|
|
15
|
-
</urlset>`}function ot(e){let t=e.siteUrl||``,n=t?`${t.replace(/\/$/,``)}/sitemap.xml`:``;if(e.seo?.indexing!==`all`&&e.seo?.indexing!==`public`&&e.seo?.indexing)return[`User-agent: *`,`Disallow: /`].filter(Boolean).join(`
|
|
16
|
-
`);if(typeof e.robots==`string`)return e.robots;if(e.robots&&typeof e.robots==`object`){let t=e.robots.rules||[],r=e.robots.sitemaps||[],i=t.map(e=>{let t=`User-agent: ${e.userAgent}\n`;return e.allow&&(Array.isArray(e.allow)?t+=e.allow.map(e=>`Allow: ${e}`).join(`
|
|
17
|
-
`)+`
|
|
18
|
-
`:t+=`Allow: ${e.allow}\n`),e.disallow&&(Array.isArray(e.disallow)?t+=e.disallow.map(e=>`Disallow: ${e}`).join(`
|
|
19
|
-
`)+`
|
|
20
|
-
`:t+=`Disallow: ${e.disallow}\n`),t.trim()}).join(`
|
|
21
|
-
|
|
22
|
-
`),a=[...n?[n]:[],...r].map(e=>`Sitemap: ${e}`).join(`
|
|
23
|
-
`);return`${i}${a?`\n\n${a}`:``}`}return[`User-agent: *`,`Allow: /`,``,n?`Sitemap: ${n}`:``].filter(Boolean).join(`
|
|
24
|
-
`)}function q(e,t){let n=e.homePage?`import HomePage from '${j(e.homePage)}';`:``,r=f.resolve(process.cwd(),`index.css`),i=c.existsSync(r)?`import './index.css';`:``,a=e.homePage?`homePage: HomePage,`:``,o=t?.plugins?.flatMap(e=>Object.entries(e.components||{}))||[],s=o.map(([e,t])=>`import * as _comp_${e} from '${j(t)}';
|
|
25
|
-
const ${e} = _comp_${e}.default || _comp_${e}['${e}'] || _comp_${e};`).join(`
|
|
26
|
-
`),l=o.map(([e])=>e).join(`, `),u=f.basename(e.docsDir||`docs`),d=f.resolve(process.cwd(),e.docsDir||`docs`),p=[`tsx`,`ts`,`jsx`,`js`].map(e=>f.resolve(d,`pages-external/index.${e}`)).find(e=>c.existsSync(e)),m=p?`import * as _external_module from '${j(p)}';`:``;return a=p?`homePage: _external_module.homePage || HomePage,`:e.homePage?`homePage: HomePage,`:``,`
|
|
27
|
-
import { ViteReactSSG } from '@bdocs/ssg';
|
|
28
|
-
import { createRoutes } from 'boltdocs/client';
|
|
29
|
-
import _routes from 'virtual:boltdocs-routes.ts';
|
|
30
|
-
import _config from 'virtual:boltdocs-config.ts';
|
|
31
|
-
import _user_mdx_components from 'virtual:boltdocs-mdx-components.tsx';
|
|
32
|
-
import _Layout from 'virtual:boltdocs-layout.tsx';
|
|
33
|
-
${i}
|
|
34
|
-
${n}
|
|
35
|
-
${s}
|
|
36
|
-
${m}
|
|
37
|
-
|
|
38
|
-
const mdxModules = import.meta.glob('/${u}/**/*.{md,mdx}', { eager: true });
|
|
39
|
-
|
|
40
|
-
export const createRoot = ViteReactSSG(
|
|
41
|
-
{
|
|
42
|
-
routes: createRoutes({
|
|
43
|
-
routesData: _routes,
|
|
44
|
-
config: _config,
|
|
45
|
-
mdxModules,
|
|
46
|
-
Layout: _Layout,
|
|
47
|
-
${a}
|
|
48
|
-
${p?`externalPages: _external_module.pages, externalLayout: _external_module.layout,`:``}
|
|
49
|
-
components: { ${l}${l?`, `:``} ...(_user_mdx_components || {}) },
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
({ isClient }) => {
|
|
53
|
-
// Boltdocs initialization hook
|
|
54
|
-
if (isClient) {
|
|
55
|
-
// Client-side initialization
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
`}function st(e){return`<!doctype html>
|
|
60
|
-
<html lang="en">
|
|
61
|
-
<head>
|
|
62
|
-
<meta charset="UTF-8" />
|
|
63
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
64
|
-
<title>${e.theme?.title||`Boltdocs`}</title>
|
|
65
|
-
</head>
|
|
66
|
-
<body>
|
|
67
|
-
<div id="root"></div>
|
|
68
|
-
</body>
|
|
69
|
-
</html>`}function ct(e,t){(!e||!e.includes(`<body`)||!e.includes(`<head`))&&(e=st(t));let n=t.theme,r=n?.title||`Boltdocs`,i=n?.description||``,a=n?.favicon;!a&&n?.logo&&(a=typeof n.logo==`string`?n.logo:n.logo.light||n.logo.dark);let o=[a?`<link rel="icon" href="${a}">`:``,`<meta name="description" content="${i}">`,`<meta property="og:title" content="${r}">`,`<meta property="og:description" content="${i}">`,`<meta property="og:type" content="website">`,`<meta name="twitter:card" content="summary_large_image">`,`<meta name="twitter:title" content="${r}">`,`<meta name="twitter:description" content="${i}">`,`<meta name="generator" content="Boltdocs">`].filter(Boolean).join(`
|
|
70
|
-
`);return e=e.includes(`<title>`)?e.replace(/<title>.*?<\/title>/,`<title>${r}</title>`):e.replace(`</head>`,` <title>${r}</title>\n </head>`),e=e.replace(`</head>`,` ${o}\n
|
|
71
|
-
<script>
|
|
72
|
-
(function() {
|
|
73
|
-
try {
|
|
74
|
-
var stored = localStorage.getItem("boltdocs-theme");
|
|
75
|
-
var isDark =
|
|
76
|
-
stored === "dark" ||
|
|
77
|
-
(stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
78
|
-
document.documentElement.classList.toggle("dark", isDark);
|
|
79
|
-
document.documentElement.dataset.theme = isDark ? "dark" : "light";
|
|
80
|
-
} catch (e) {}
|
|
81
|
-
})();
|
|
82
|
-
<\/script>
|
|
83
|
-
</head>`),!e.includes(`src/main`)&&!e.includes(`virtual:boltdocs-entry`)&&(e=e.replace(`</body>`,` <script type="module">import "virtual:boltdocs-entry";<\/script>
|
|
84
|
-
</body>`)),e}function lt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version});return t}const ut={"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`};function dt(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(`; `)}var J=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},Y=class e extends J{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},ft=class e extends J{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},X=class e extends J{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},pt=class e extends J{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},mt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const ht=Xe.extend({version:d.string().optional(),boltdocsVersion:d.string().optional(),permissions:d.array(d.string()).optional(),hooks:d.object({beforeBuild:d.function().optional(),afterBuild:d.function().optional(),beforeDev:d.function().optional(),afterDev:d.function().optional(),configResolved:d.function().optional(),buildEnd:d.function().optional()}).optional()});function gt(e,t){let n=[],r=new Set;for(let i of e){let e=ht.safeParse(i);if(!e.success)throw new Y(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new Y(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!_.satisfies(t,a.boltdocsVersion))throw new ft(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||f.isAbsolute(t))&&t.includes(`..`))throw new Y(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new X(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof X){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},_t=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new mt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new pt(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function vt(e){return e}function yt(e={},t){let r=n.resolve(process.cwd(),e.docsDir||`docs`),i=j(r),o=t,s,c=!1,l,u=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(t,i){c=i.command===`build`;let s=t.envDir||process.cwd(),d=a(i.mode,s,``);Object.assign(process.env,d),o||=await K(r);let f=(await import(`./package-CR0HF9x3.mjs`)).version,p=gt(o.plugins||[],f);return o.plugins=p,l=new _t(p,o),u=p.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),c&&await l.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=at(Ke(await W(r,o)),o);t&&g.writeFileSync(n.join(e,`sitemap.xml`),t);let i=ot(o);g.writeFileSync(n.join(e,`robots.txt`),i)}},build:{ssrManifest:c},async config(){let t=O;for(;t!==n.parse(t).root&&!g.existsSync(n.join(t,`package.json`));)t=n.dirname(t);if(g.existsSync(n.join(t,`package.json`))&&JSON.parse(g.readFileSync(n.join(t,`package.json`),`utf-8`)).name!==`boltdocs`){let e=n.dirname(t);for(;e!==n.parse(e).root;){if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=n.dirname(e)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-router-dom`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{alias:[{find:`boltdocs/entry`,replacement:j(n.resolve(e.root||process.cwd(),`boltdocs-entry.cjs`))}]}}}}},configResolved(e){s=e,l?.runHook(`configResolved`,o)},async configureServer(e){await l?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(ut).forEach(([e,n])=>{t.setHeader(e,n)}),o.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,dt(o)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let i=t.url?.split(`?`)[0]||`/`,a=t.headers.accept||``,s=i===`/`||i.startsWith(`/docs`)||o.i18n&&Object.keys(o.i18n.locales).some(e=>i.startsWith(`/${e}/docs`)||i===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(i);if(a.includes(`text/html`)&&!c&&s){let r=st(o);r=ct(r,o),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=G.map(e=>n.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>n.resolve(r,`layout.${e}`)),s=[`tsx`,`ts`,`jsx`,`js`],c=s.map(e=>n.resolve(r,`mdx-components.${e}`)),u=s.map(e=>n.resolve(r,`pages-external/index.${e}`)),d=s.map(e=>n.resolve(r,`icons.${e}`));e.watcher.add([...t,...c,...a,...u,...d]);let f=async(t,n)=>{try{let a=j(t);if(G.some(e=>a.endsWith(e))){e.restart();return}if(s.some(e=>a.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.some(e=>a.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.endsWith(`layout.tsx`)||a.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(a.includes(`/pages-external/`)||a.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!a.startsWith(i)||!Ce(a))return;if(n===`add`||n===`unlink`){Le(),o=await K(r);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${n} event:`,e)}};e.watcher.on(`add`,e=>f(e,`add`)),e.watcher.on(`unlink`,e=>f(e,`unlink`)),e.watcher.on(`change`,e=>f(e,`change`)),await l?.runHook(`afterDev`)},resolveId(e){let t=s?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?j(n.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?j(n.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return q(e,o);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=O,t=e;for(;e!==n.parse(e).root;){if(g.existsSync(n.join(e,`package.json`))&&JSON.parse(g.readFileSync(n.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=n.dirname(e)}let r=n.join(t,`src/client/index.ts`),i=n.join(t,`dist/client/index.js`);return`export * from '${j(g.existsSync(r)?r:i)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let i=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(i===`routes`){let e=Ke(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`config`){let e={theme:o?.theme,i18n:o?.i18n,versions:o?.versions,siteUrl:o?.siteUrl,plugins:o?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(i===`entry`)return q(e,o);if(i===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let i of e){let e=n.resolve(r,`mdx-components.${i}`);if(g.existsSync(e)){t=e;break}}if(t){let e=j(t);return`import * as components from '${e}';
|
|
85
|
-
const mdxComponents = components.default || components;
|
|
86
|
-
export default mdxComponents;
|
|
87
|
-
export * from '${e}';`}return`export default {};`}if(i===`layout`){let e=[`tsx`,`jsx`],t=null;for(let i of e){let e=n.resolve(r,`layout.${i}`);if(g.existsSync(e)){t=e;break}}return t?`import UserLayout from '${j(t)}';
|
|
88
|
-
export default UserLayout;`:`import { DefaultLayout } from '${j(n.resolve(O,`../../client/components/default-layout.tsx`))}';
|
|
89
|
-
export default DefaultLayout;`}if(i===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let i of e){let e=n.resolve(r,`icons.${i}`);if(g.existsSync(e)){t=e;break}}return t?`import * as icons from '${j(t)}';\nexport default icons;`:`export default {};`}if(i===`search`){let e=lt(await W(r,o));return`export default ${JSON.stringify(e,null,2)};`}if(i===`client`){let e=O,t=``;for(;e&&e!==n.parse(e).root;){let r=n.join(e,`src/client/index.ts`),i=n.join(e,`dist/client/index.mjs`),a=n.join(e,`client/index.ts`);if(g.existsSync(r)){t=j(r);break}if(g.existsSync(i)){t=j(i);break}if(g.existsSync(a)){t=j(a);break}e=n.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${O}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ct(e,o)}},async closeBundle(){!c||s?.build?.ssr||(await l?.runHook(`afterBuild`),await l?.runHook(`buildEnd`))}},te({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...u]}const $=new Ie(`mdx`),bt=[S.default||S,C.default||C,ae.default||ae,w.default||w,T.default||T,E.default||E,oe.default||oe],xt=[D,se,ce,le,ue,de,fe,pe,me,he,ge,_e];let St=null,Ct=null;const wt=()=>(St??=b(),St),Tt=async e=>Ct||(Ct=x({themes:bt,langs:xt,engine:wt()}),Ct),Et=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},Dt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},Ot=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),kt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var At=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await Tt(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[Et(),Dt(),Ot(),kt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function jt(e){let t=new At(e);return async e=>{let n=await t.getHighlighter();y(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Mt(e){let t=new At(e);return async e=>{let n=await t.getHighlighter();y(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Nt(){return e=>{y(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let Pt=!1;function Ft(e,t=v){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[ne,re,Nt,[jt,e],...n],rehypePlugins:[ie,[Mt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){Pt||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${p.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function It(e){let t=await K(e?.docsDir||`docs`);return[...yt({...e,homePage:e?.homePage||t.homePage},t),Ft(t)]}async function Lt(r,i=`development`){let a=await K(`docs`,r),s=i===`production`,c=s?{...ut}:{};return a.security?.enableCSP&&(c[`Content-Security-Policy`]=dt(a)),{root:r,mode:i,oxc:{jsx:{development:!s,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[e(),t(),await It({...a,root:r})],resolve:{alias:{"boltdocs/entry":o(n.resolve(r,`boltdocs-entry.mjs`)),"boltdocs/client":o(n.resolve(r,`boltdocs-client.mjs`))},dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`]},server:{headers:{...c,...a.vite?.server?.headers},...a.vite?.server},preview:{headers:{...c,...a.vite?.preview?.headers},...a.vite?.preview},...a.vite}}export{it as _,Q as a,gt as c,J as d,pt as f,K as g,q as h,_t as i,mt as l,Y as m,Lt as n,ht as o,X as p,vt as r,Z as s,It as t,ft as u,j as v,we as y};
|
package/dist/node-vkbb0MK7.cjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
-
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@vitejs/plugin-react`);l=c(l);let u=require(`@tailwindcss/vite`);u=c(u);let d=require(`vite`),f=require(`fast-glob`);f=c(f);let p=require(`fs`);p=c(p);let m=require(`gray-matter`);m=c(m);let h=require(`isomorphic-dompurify`);h=c(h);let g=require(`zod`),_=require(`path`);_=c(_);let v=require(`crypto`);v=c(v);let y=require(`zlib`);y=c(y);let b=require(`util`),ee=require(`github-slugger`);ee=c(ee);let te=require(`vite-plugin-image-optimizer`),x=require(`node:path`);x=c(x);let S=require(`node:fs`);S=c(S);let C=require(`semver`);C=c(C);let w=require(`@mdx-js/rollup`);w=c(w);let T=require(`remark-gfm`);T=c(T);let E=require(`remark-frontmatter`);E=c(E);let D=require(`rehype-slug`);D=c(D);let O=require(`unist-util-visit`),ne=require(`shiki/engine/javascript`),re=require(`shiki/core`),k=require(`@shikijs/themes/github-light`);k=c(k);let A=require(`@shikijs/themes/github-dark`);A=c(A);let j=require(`@shikijs/themes/tokyo-night`);j=c(j);let M=require(`@shikijs/themes/dracula`);M=c(M);let N=require(`@shikijs/themes/nord`);N=c(N);let P=require(`@shikijs/themes/one-dark-pro`);P=c(P);let F=require(`@shikijs/themes/one-light`);F=c(F);let ie=require(`@shikijs/langs/html`);ie=c(ie);let ae=require(`@shikijs/langs/js`);ae=c(ae);let oe=require(`@shikijs/langs/ts`);oe=c(oe);let se=require(`@shikijs/langs/tsx`);se=c(se);let ce=require(`@shikijs/langs/css`);ce=c(ce);let le=require(`@shikijs/langs/json`);le=c(le);let ue=require(`@shikijs/langs/bash`);ue=c(ue);let de=require(`@shikijs/langs/markdown`);de=c(de);let fe=require(`@shikijs/langs/mdx`);fe=c(fe);let pe=require(`@shikijs/langs/yaml`);pe=c(pe);let me=require(`@shikijs/langs/rust`);me=c(me);let he=require(`@shikijs/langs/toml`);he=c(he);const ge=/^[a-zA-Z0-9\-_\/\.\(\)]+$/,_e=g.z.object({title:g.z.string().max(200).optional(),description:g.z.string().max(500).optional(),sidebarPosition:g.z.number().optional(),sidebarLabel:g.z.string().max(100).optional(),category:g.z.string().max(50).optional(),order:g.z.number().optional(),badge:g.z.string().max(50).optional(),icon:g.z.string().max(50).optional()});var I=class e extends Error{constructor(t){super(t),this.name=`SecurityViolationError`,Object.setPrototypeOf(this,e.prototype)}},ve=class e extends I{constructor(t){super(t),this.name=`PathTraversalError`,Object.setPrototypeOf(this,e.prototype)}},ye=class e extends I{constructor(t){super(t),this.name=`EncodingSecurityError`,Object.setPrototypeOf(this,e.prototype)}},L=class e extends I{constructor(t){super(t),this.name=`ValidationError`,Object.setPrototypeOf(this,e.prototype)}};function R(e){return e.replace(/\\/g,`/`)}function z(e){return e.replace(/^\d+\./,``)}function be(e){let t=e.match(/^(\d+)\./);return t?parseInt(t[1],10):void 0}function xe(e){return/\.mdx?$/.test(e)}function Se(e){try{return p.default.statSync(e).mtimeMs}catch{return 0}}function Ce(e){let t=p.default.readFileSync(e,`utf-8`);try{let{data:n,content:r,matter:i}=(0,m.default)(t);if(i&&i.length>10240)throw U(`FRONTMATTER_TOO_LARGE`,`Frontmatter block exceeds size limit`,{size:i.length,file:e}),new L(`Security breach: Frontmatter size exceeds limit of 10240 bytes`);let a=_e.safeParse(n);a.success||console.warn(`[VALIDATION][${e}] Invalid frontmatter fields detected.`);let o={...a.success?a.data:{}};return o.title&&=V(o.title).trim(),o.description&&=V(o.description).trim(),{data:o,content:r}}catch(e){if(e instanceof L)throw e;return{data:{},content:t}}}function we(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`)}function Te(e){return we(e)}function Ee(e){let t=e.split(`/`).map(e=>z(De(e))).join(`/`).replace(/\/$/,``);return t=t.replace(/\.mdx?$/,``),(t===`index`||t.endsWith(`/index`))&&(t=t.replace(/index$/,``)),t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function B(e){return h.default.sanitize(e,{ALLOWED_TAGS:`b.i.em.strong.a.p.br.code.pre.span.div.h1.h2.h3.h4.h5.h6.ul.ol.li.table.thead.tbody.tr.th.td.blockquote.hr`.split(`.`),ALLOWED_ATTR:[`href`,`title`,`target`,`class`,`id`,`src`,`alt`,`width`,`height`],FORCE_BODY:!0})}h.default.addHook(`afterSanitizeAttributes`,e=>{if(e.hasAttribute(`href`)){let t=e.getAttribute(`href`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`href`)}if(e.hasAttribute(`src`)){let t=e.getAttribute(`src`)?.toLowerCase()||``;(t.startsWith(`javascript:`)||t.startsWith(`data:`)||t.startsWith(`vbscript:`))&&e.removeAttribute(`src`)}});function V(e){return h.default.sanitize(e,{ALLOWED_TAGS:[],KEEP_CONTENT:!0})}function H(e){return e.charAt(0).toUpperCase()+e.slice(1)}function De(e){return e.replace(/[^a-zA-Z0-9\-_\/\.]/g,``).split(`/`).filter(e=>e!==`..`&&e!==`.`).map(e=>e.replace(/\.\.+/g,`.`)).join(`/`)}function U(e,t,n={}){let r=new Date().toISOString(),i={...n};for(let e in i)typeof i[e]==`string`&&i[e].includes(`:`)&&(i[e]=i[e].split(/[\\/]/).pop()||i[e]);console.error(`[SECURITY][${r}] TYPE: ${e} | MESSAGE: ${t} | DETAILS: ${JSON.stringify(i)}`)}const W=(0,b.promisify)(p.default.writeFile),Oe=(0,b.promisify)(p.default.readFile),ke=(0,b.promisify)(p.default.mkdir),Ae=(0,b.promisify)(p.default.rename);(0,b.promisify)(p.default.unlink);const je=process.env.BOLTDOCS_CACHE_DIR||`.boltdocs`,Me=parseInt(process.env.BOLTDOCS_CACHE_LRU_LIMIT||`2000`,10),Ne=process.env.BOLTDOCS_CACHE_COMPRESS!==`0`;var Pe=class{cache=new Map;constructor(e){this.limit=e}get(e){let t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.limit){let e=this.cache.keys().next().value;e!==void 0&&this.cache.delete(e)}this.cache.set(e,t)}get size(){return this.cache.size}clear(){this.cache.clear()}};const G=new class{queue=Promise.resolve();pendingCount=0;add(e){this.pendingCount++,this.queue=this.queue.then(e).finally(()=>{this.pendingCount--})}async flush(){await this.queue}get pending(){return this.pendingCount}};var Fe=class{entries=new Map;cachePath=null;compress;constructor(e={}){if(this.compress=e.compress===void 0?Ne:e.compress,e.name){let t=e.root||process.cwd(),n=this.compress?`json.gz`:`json`;this.cachePath=_.default.resolve(t,je,`${e.name}.${n}`)}}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&!(!this.cachePath||!p.default.existsSync(this.cachePath)))try{let e=p.default.readFileSync(this.cachePath);this.cachePath.endsWith(`.gz`)&&(e=y.default.gunzipSync(e));let t=JSON.parse(e.toString(`utf-8`));this.entries=new Map(Object.entries(t))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`||!this.cachePath)return;let e=Object.fromEntries(this.entries),t=JSON.stringify(e),n=this.cachePath,r=this.compress;G.add(async()=>{try{await ke(_.default.dirname(n),{recursive:!0});let e=Buffer.from(t);r&&(e=y.default.gzipSync(e));let i=`${n}.${v.default.randomBytes(4).toString(`hex`)}.tmp`;await W(i,e),await Ae(i,n)}catch{}})}get(e){let t=this.entries.get(e);return!t||Se(e)!==t.mtime?null:t.data}set(e,t){this.entries.set(e,{data:t,mtime:Se(e)})}isValid(e){let t=this.entries.get(e);return t?Se(e)===t.mtime:!1}invalidate(e){this.entries.delete(e)}invalidateAll(){this.entries.clear()}pruneStale(e){for(let t of this.entries.keys())e.has(t)||this.entries.delete(t)}get size(){return this.entries.size}async flush(){await G.flush()}},Ie=class{index=new Map;memoryCache=new Pe(Me);baseDir;shardsDir;indexPath;constructor(e,t=process.cwd()){this.baseDir=_.default.resolve(t,je,`transform-${e}`),this.shardsDir=_.default.resolve(this.baseDir,`shards`),this.indexPath=_.default.resolve(this.baseDir,`index.json`)}load(){if(process.env.BOLTDOCS_NO_CACHE!==`1`&&p.default.existsSync(this.indexPath))try{let e=p.default.readFileSync(this.indexPath,`utf-8`);this.index=new Map(Object.entries(JSON.parse(e)))}catch{}}save(){if(process.env.BOLTDOCS_NO_CACHE===`1`)return;let e=JSON.stringify(Object.fromEntries(this.index)),t=this.indexPath;G.add(async()=>{await ke(_.default.dirname(t),{recursive:!0}),await W(t,e)})}async getMany(e){let t=new Map,n=[];for(let r of e){let e=this.memoryCache.get(r);e?t.set(r,e):this.index.has(r)&&n.push(r)}if(n.length>0){let e=await Promise.all(n.map(async e=>{let t=this.index.get(e),n=_.default.resolve(this.shardsDir,`${t}.gz`);try{let t=await Oe(n),r=y.default.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,r),{key:e,val:r}}catch{return null}}));for(let n of e)n&&t.set(n.key,n.val)}return t}get(e){let t=this.memoryCache.get(e);if(t)return t;let n=this.index.get(e);if(!n)return null;let r=_.default.resolve(this.shardsDir,`${n}.gz`);if(!p.default.existsSync(r))return null;try{let t=p.default.readFileSync(r),n=y.default.gunzipSync(t).toString(`utf-8`);return this.memoryCache.set(e,n),n}catch{return null}}set(e,t){let n=v.default.createHash(`md5`).update(t).digest(`hex`);this.index.set(e,n),this.memoryCache.set(e,t);let r=_.default.resolve(this.shardsDir,`${n}.gz`);G.add(async()=>{if(p.default.existsSync(r))return;await ke(this.shardsDir,{recursive:!0});let e=y.default.gzipSync(Buffer.from(t)),n=`${r}.${v.default.randomBytes(4).toString(`hex`)}.tmp`;await W(n,e),await Ae(n,r)})}get size(){return this.index.size}async flush(){await G.flush()}};const K=new Fe({name:`routes`});function Le(){K.invalidateAll()}function Re(e){K.invalidate(e)}function ze(e,t,n,r){let i;try{i=decodeURIComponent(e)}catch{let t=_.default.basename(e);throw U(`ENCODING_ERROR`,`Invalid character encoding`,{file:t}),new ye(`Security breach: Invalid characters or encoding in path: ${t}`)}if(i.length>260){let e=_.default.basename(i);throw U(`PATH_TOO_LONG`,`Path length exceeds limit`,{length:i.length,file:e}),new ve(`Security breach: Path length exceeds limit of 260 characters: ${e}`)}let a=_.default.resolve(i),o=_.default.resolve(t),s=R(_.default.relative(o,a));if(s.startsWith(`../`)||s===`..`||a.includes(`\0`)||!ge.test(s)){let t=_.default.basename(e);throw U(`PATH_TRAVERSAL_ATTEMPT`,`Path traversal or invalid characters detected`,{path:s}),new ve(`Security breach: File is outside of docs directory, contains null bytes, or invalid characters: ${t}`)}let{data:c,content:l}=Ce(e),u=s.split(`/`),d,f;if(r?.versions&&u.length>0){let e=u[0],t=r.versions.prefix||``,n=r.versions.versions.find(n=>e===t+n.path||e===n.path);n&&(f=n.path,u=u.slice(1))}if(r?.i18n&&u.length>0){let e=u[0];r.i18n.locales[e]&&(d=e,u=u.slice(1))}let p;if(u.length>0){let e=u[0].match(/^\((.+)\)$/);e&&(p=e[1].toLowerCase(),u=u.slice(1))}let m;u=u.map(e=>{let t=z(e);return t.startsWith(`_`)&&t!==`_`?(m=t.substring(1),e.substring(0,e.length-t.length)+t.substring(1)):e});let h=u.join(`/`),g;g=c.permalink?c.permalink.startsWith(`/`)?c.permalink:`/${c.permalink}`:Ee(h||`index.md`);let v=n;f&&(v+=`/`+f),d&&(v+=`/`+d),p&&(v+=`/`+p),v+=g===`/`?``:g,(!v||v===``)&&(v=`/`);let y=u[u.length-1],b=z(y),te=z(_.default.basename(e,_.default.extname(e))),x=c.sidebarPosition??be(y),S=u.length>=2?u[0]:void 0,C=S?z(S):void 0,w=u.length===2&&/^index\.mdx?$/.test(b),T=new ee.default,E=[];for(let e of l.matchAll(/^(#{2,4})\s+(.+)$/gm)){let t=e[1].length,n=B(e[2].replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).trim()).trim(),r=T.slug(n);E.push({level:t,text:n,id:r})}let D=c.title?B(String(c.title)):te,O=c.description?B(String(c.description)):``;!O&&l&&(O=V(l.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim().slice(0,160));let ne=c.badge?B(String(c.badge)):void 0,re=c.icon?String(c.icon):void 0,k=Be(l),A={},j=[`og:`,`twitter:`,`article:`,`music:`,`video:`,`profile:`,`book:`],M=[`noindex`,`robots`,`canonical`,`keywords`,`author`];c.seo&&typeof c.seo==`object`&&Object.assign(A,c.seo);for(let e of Object.keys(c))(M.includes(e)||j.some(t=>e.startsWith(t)))&&(A[e]=c[e]);return c.hidden===!0&&A.noindex===void 0&&(A.noindex=!0),{route:{path:v,componentPath:e,filePath:s,title:D,description:O,sidebarPosition:x,headings:E,locale:d,version:f,badge:ne,icon:re,tab:p,subRouteGroup:m,_content:k,_rawContent:l,seo:Object.keys(A).length>0?A:void 0},relativeDir:C,isGroupIndex:w,inferredTab:p,groupMeta:w?{title:c.groupTitle||c.title||(C?H(C):``),position:c.groupPosition??c.sidebarPosition??(S?be(S):void 0),icon:re}:void 0,inferredGroupPosition:S?be(S):void 0}}function Be(e){return V(e.replace(/^#+.*$/gm,``).replace(/\[([^\]]+)\]\([^\)]+\)/g,`$1`).replace(/\{[^\}]+\}/g,``).replace(/[_*`]/g,``).replace(/\s+/g,` `)).trim()}function Ve(e){return e.sort((e,t)=>!e.group&&!t.group?He(e,t):e.group?t.group?e.group===t.group?He(e,t):Ue(e,t):1:-1)}function He(e,t){return e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0?e.sidebarPosition-t.sidebarPosition:e.sidebarPosition===void 0?t.sidebarPosition===void 0?e.title.localeCompare(t.title):1:-1}function Ue(e,t){return e.groupPosition!==void 0&&t.groupPosition!==void 0?e.groupPosition-t.groupPosition:e.groupPosition===void 0?t.groupPosition===void 0?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):1:-1}let We=null;const q=new Map;async function Ge(e,t,n=`/docs`,r=!0){K.load(),q.clear(),(process.env.BOLTDOCS_FORCE_REPARSE===`true`||t?.i18n)&&K.invalidateAll();let i;!r&&We?i=We:(i=await(0,f.default)([`**/*.md`,`**/*.mdx`],{cwd:e,absolute:!0,suppressErrors:!0,followSymbolicLinks:!1}),We=i),K.pruneStale(new Set(i));let a=[],o=0;for(let r=0;r<i.length;r+=50){let s=i.slice(r,r+50),c=await Promise.all(s.map(async r=>{let i=K.get(r);if(i)return o++,i;let a=ze(r,e,n,t);return K.set(r,a),a}));a.push(...c),r+50<i.length&&await new Promise(e=>setImmediate(e))}K.save();let s=new Map,c=[];for(let e of a)if(e.isGroupIndex&&e.relativeDir&&c.push(e),e.relativeDir){let t=s.get(e.relativeDir);t?t.position===void 0&&e.inferredGroupPosition!==void 0&&(t.position=e.inferredGroupPosition):(t={title:H(e.relativeDir),position:e.inferredGroupPosition},s.set(e.relativeDir,t))}for(let e of c){let t=s.get(e.relativeDir);e.groupMeta&&(t.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(t.position=e.groupMeta.position),e.groupMeta.icon&&(t.icon=e.groupMeta.icon))}if(t?.theme?.sidebarGroups)for(let[e,n]of Object.entries(t.theme.sidebarGroups)){let t=s.get(e);t?(n.title&&(t.title=n.title),n.icon&&(t.icon=n.icon)):s.set(e,{title:n.title||H(e),icon:n.icon})}let l=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e],n=t.relativeDir,r=n?s.get(n):void 0;l[e]={...t.route,group:n,groupTitle:r?.title||(n?H(n):void 0),groupPosition:r?.position,groupIcon:r?.icon}}let u=l;if(t?.i18n){let e=Ke(l,t,n);u=[...l,...e]}return Ve(u)}function Ke(e,t,n){let r=t.i18n.defaultLocale,i=Object.keys(t.i18n.locales),a=[],o=new Map,s=[];for(let t of e){let e=t.locale||r;o.has(e)||o.set(e,new Set),o.get(e).add(t.path),e===r&&s.push(t)}for(let e of i){let i=o.get(e)||new Set;for(let o of s){let s=qe(o.path,r,e,n,t);s!==o.path&&(i.has(s)||a.push({...o,path:s,locale:e}))}}return a}function qe(e,t,n,r,i){let a=`${e}:${n}`,o=q.get(a);if(o)return o;let s=r;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let i=t+n.path;if(e.startsWith(`${r}/${i}`)){s+=`/`+i;break}if(e.startsWith(`${r}/${n.path}`)){s+=`/`+n.path;break}}}let c=e.substring(s.length),l=`/${t}`;if(c.startsWith(l+`/`))c=`/`+n+`/`+c.substring(l.length+1);else if(c===l)c=`/`+n;else if(c===`/`||c===``)c=`/`+n;else{let e=c.startsWith(`/`)?``:`/`;c=`/`+n+e+c}let u=s+c;return q.size>2e3&&q.clear(),q.set(a,u),u}function Je(e){return e.map(e=>({path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],_content:e._content||``,locale:e.locale,version:e.version,tab:e.tab,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo}))}const Ye=g.z.object({icon:g.z.string().max(50),link:g.z.string().url()}),Xe=g.z.object({text:g.z.string().max(2e3).optional()}),Ze=g.z.enum([`fs:read`,`fs:write`,`vite:config`,`mdx:remark`,`mdx:rehype`,`components`,`hooks:build`,`hooks:dev`]),Qe=g.z.object({name:g.z.string(),enforce:g.z.enum([`pre`,`post`]).optional(),version:g.z.string().optional(),boltdocsVersion:g.z.string().optional(),permissions:g.z.array(Ze).optional(),remarkPlugins:g.z.array(g.z.any()).optional(),rehypePlugins:g.z.array(g.z.any()).optional(),vitePlugins:g.z.array(g.z.any()).optional(),components:g.z.record(g.z.string(),g.z.string()).optional(),hooks:g.z.record(g.z.string(),g.z.any()).optional()}),$e=g.z.object({title:g.z.union([g.z.string(),g.z.record(g.z.string(),g.z.string())]).optional(),description:g.z.union([g.z.string(),g.z.record(g.z.string(),g.z.string())]).optional(),logo:g.z.union([g.z.string(),g.z.object({dark:g.z.string(),light:g.z.string(),alt:g.z.string().optional(),width:g.z.number().optional(),height:g.z.number().optional()})]).optional(),navbar:g.z.array(g.z.object({label:g.z.union([g.z.string(),g.z.record(g.z.string(),g.z.string())]),href:g.z.string()})).optional(),sidebar:g.z.record(g.z.string(),g.z.array(g.z.object({text:g.z.string(),link:g.z.string()}))).optional(),sidebarGroups:g.z.record(g.z.string(),g.z.object({title:g.z.string().optional(),icon:g.z.string().optional()})).optional(),socialLinks:g.z.array(Ye).optional(),footer:Xe.optional(),breadcrumbs:g.z.boolean().optional(),editLink:g.z.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:g.z.string().url().optional(),version:g.z.string().max(50).optional(),githubRepo:g.z.string().max(100).optional(),favicon:g.z.string().optional(),poweredBy:g.z.boolean().optional(),tabs:g.z.array(g.z.object({id:g.z.string(),text:g.z.union([g.z.string(),g.z.record(g.z.string(),g.z.string())]),icon:g.z.string().optional()})).optional(),codeTheme:g.z.union([g.z.string(),g.z.object({light:g.z.string(),dark:g.z.string()})]).optional(),copyMarkdown:g.z.union([g.z.boolean(),g.z.object({text:g.z.string().optional(),icon:g.z.string().optional()})]).optional()}),et=g.z.union([g.z.string(),g.z.object({rules:g.z.array(g.z.object({userAgent:g.z.string(),allow:g.z.union([g.z.string(),g.z.array(g.z.string())]).optional(),disallow:g.z.union([g.z.string(),g.z.array(g.z.string())]).optional()})).optional(),sitemaps:g.z.array(g.z.string().url()).optional()})]),tt=g.z.object({defaultLocale:g.z.string(),locales:g.z.record(g.z.string(),g.z.string()),localeConfigs:g.z.record(g.z.string(),g.z.object({label:g.z.string().optional(),direction:g.z.enum([`ltr`,`rtl`]).optional(),htmlLang:g.z.string().optional(),calendar:g.z.string().optional()})).optional()}),nt=g.z.object({defaultVersion:g.z.string(),prefix:g.z.string().optional(),versions:g.z.array(g.z.object({label:g.z.string(),path:g.z.string()}))}),rt=g.z.object({headers:g.z.record(g.z.string(),g.z.string()).optional(),enableCSP:g.z.boolean().optional(),customHeaders:g.z.record(g.z.string(),g.z.string()).optional()}),it=g.z.object({metatags:g.z.record(g.z.string(),g.z.string()).optional(),indexing:g.z.enum([`all`,`public`]).optional(),thumbnails:g.z.object({background:g.z.string().optional()}).optional()}),at=g.z.object({siteUrl:g.z.string().url().optional(),docsDir:g.z.string().optional(),homePage:g.z.string().optional(),theme:$e.optional(),i18n:tt.optional(),versions:nt.optional(),plugins:g.z.array(Qe).optional(),robots:et.optional(),security:rt.optional(),seo:it.optional(),vite:g.z.record(g.z.string(),g.z.unknown()).optional()});function ot(e){return e}const st=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function J(e,t=process.cwd()){let n=t,r={docsDir:x.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`},poweredBy:!0,breadcrumbs:!0}},i={};for(let e of st){let t=x.default.resolve(n,e);if(S.default.existsSync(t))try{let e=await(0,d.loadConfigFromFile)({command:`serve`,mode:`development`},t,n);if(e){i=e.config;break}}catch(t){console.warn(`[boltdocs] Failed to load config from ${e}:`,t)}}let a={title:i.title,description:i.description,logo:i.logo,favicon:i.favicon,navbar:i.navbar,sidebar:i.sidebar,sidebarGroups:i.theme?.sidebarGroups,socialLinks:i.socialLinks,footer:i.footer,githubRepo:i.githubRepo,tabs:i.tabs,codeTheme:i.codeTheme,copyMarkdown:i.copyMarkdown,breadcrumbs:i.breadcrumbs,poweredBy:i.poweredBy,communityHelp:i.communityHelp,version:i.version,editLink:i.editLink,...i.theme||{}},o=Object.fromEntries(Object.entries(a).filter(([e,t])=>t!==void 0));o.navbar&&=o.navbar.map(e=>({label:e.label||e.text||``,href:e.href||e.link||e.to||``}));let s={docsDir:x.default.resolve(e),homePage:i.homePage,theme:{...r.theme,...o},i18n:i.i18n,versions:i.versions,siteUrl:i.siteUrl,plugins:i.plugins||[],robots:i.robots,security:i.security,vite:i.vite},c=at.safeParse(s);if(!c.success)throw new L(`Invalid Boltdocs configuration:\n${c.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
|
|
7
|
-
`)}`);return c.data}function ct(e,t){let n=(t.siteUrl||``).replace(/\/$/,``);if(!n)return``;let r=t.seo?.indexing!==`all`&&t.seo?.indexing!==`public`;return`<?xml version="1.0" encoding="UTF-8"?>
|
|
8
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
9
|
-
${e.filter(e=>e.seo?.noindex||typeof e.seo?.robots==`string`&&e.seo.robots.includes(`noindex`)?!1:(r&&e.seo?.index,!0)).map(e=>` <url>
|
|
10
|
-
<loc>${Te(`${n}${e.path.startsWith(`/`)?e.path:`/${e.path}`}`)}</loc>
|
|
11
|
-
<changefreq>weekly</changefreq>
|
|
12
|
-
<priority>0.7</priority>
|
|
13
|
-
</url>`).join(`
|
|
14
|
-
`)}
|
|
15
|
-
</urlset>`}function lt(e){let t=e.siteUrl||``,n=t?`${t.replace(/\/$/,``)}/sitemap.xml`:``;if(e.seo?.indexing!==`all`&&e.seo?.indexing!==`public`&&e.seo?.indexing)return[`User-agent: *`,`Disallow: /`].filter(Boolean).join(`
|
|
16
|
-
`);if(typeof e.robots==`string`)return e.robots;if(e.robots&&typeof e.robots==`object`){let t=e.robots.rules||[],r=e.robots.sitemaps||[],i=t.map(e=>{let t=`User-agent: ${e.userAgent}\n`;return e.allow&&(Array.isArray(e.allow)?t+=e.allow.map(e=>`Allow: ${e}`).join(`
|
|
17
|
-
`)+`
|
|
18
|
-
`:t+=`Allow: ${e.allow}\n`),e.disallow&&(Array.isArray(e.disallow)?t+=e.disallow.map(e=>`Disallow: ${e}`).join(`
|
|
19
|
-
`)+`
|
|
20
|
-
`:t+=`Disallow: ${e.disallow}\n`),t.trim()}).join(`
|
|
21
|
-
|
|
22
|
-
`),a=[...n?[n]:[],...r].map(e=>`Sitemap: ${e}`).join(`
|
|
23
|
-
`);return`${i}${a?`\n\n${a}`:``}`}return[`User-agent: *`,`Allow: /`,``,n?`Sitemap: ${n}`:``].filter(Boolean).join(`
|
|
24
|
-
`)}function ut(e,t){let n=e.homePage?`import HomePage from '${R(e.homePage)}';`:``,r=_.default.resolve(process.cwd(),`index.css`),i=p.default.existsSync(r)?`import './index.css';`:``,a=e.homePage?`homePage: HomePage,`:``,o=t?.plugins?.flatMap(e=>Object.entries(e.components||{}))||[],s=o.map(([e,t])=>`import * as _comp_${e} from '${R(t)}';
|
|
25
|
-
const ${e} = _comp_${e}.default || _comp_${e}['${e}'] || _comp_${e};`).join(`
|
|
26
|
-
`),c=o.map(([e])=>e).join(`, `),l=_.default.basename(e.docsDir||`docs`),u=_.default.resolve(process.cwd(),e.docsDir||`docs`),d=[`tsx`,`ts`,`jsx`,`js`].map(e=>_.default.resolve(u,`pages-external/index.${e}`)).find(e=>p.default.existsSync(e)),f=d?`import * as _external_module from '${R(d)}';`:``;return a=d?`homePage: _external_module.homePage || HomePage,`:e.homePage?`homePage: HomePage,`:``,`
|
|
27
|
-
import { ViteReactSSG } from '@bdocs/ssg';
|
|
28
|
-
import { createRoutes } from 'boltdocs/client';
|
|
29
|
-
import _routes from 'virtual:boltdocs-routes.ts';
|
|
30
|
-
import _config from 'virtual:boltdocs-config.ts';
|
|
31
|
-
import _user_mdx_components from 'virtual:boltdocs-mdx-components.tsx';
|
|
32
|
-
import _Layout from 'virtual:boltdocs-layout.tsx';
|
|
33
|
-
${i}
|
|
34
|
-
${n}
|
|
35
|
-
${s}
|
|
36
|
-
${f}
|
|
37
|
-
|
|
38
|
-
const mdxModules = import.meta.glob('/${l}/**/*.{md,mdx}', { eager: true });
|
|
39
|
-
|
|
40
|
-
export const createRoot = ViteReactSSG(
|
|
41
|
-
{
|
|
42
|
-
routes: createRoutes({
|
|
43
|
-
routesData: _routes,
|
|
44
|
-
config: _config,
|
|
45
|
-
mdxModules,
|
|
46
|
-
Layout: _Layout,
|
|
47
|
-
${a}
|
|
48
|
-
${d?`externalPages: _external_module.pages, externalLayout: _external_module.layout,`:``}
|
|
49
|
-
components: { ${c}${c?`, `:``} ...(_user_mdx_components || {}) },
|
|
50
|
-
}),
|
|
51
|
-
},
|
|
52
|
-
({ isClient }) => {
|
|
53
|
-
// Boltdocs initialization hook
|
|
54
|
-
if (isClient) {
|
|
55
|
-
// Client-side initialization
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
`}function dt(e){return`<!doctype html>
|
|
60
|
-
<html lang="en">
|
|
61
|
-
<head>
|
|
62
|
-
<meta charset="UTF-8" />
|
|
63
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
64
|
-
<title>${e.theme?.title||`Boltdocs`}</title>
|
|
65
|
-
</head>
|
|
66
|
-
<body>
|
|
67
|
-
<div id="root"></div>
|
|
68
|
-
</body>
|
|
69
|
-
</html>`}function ft(e,t){(!e||!e.includes(`<body`)||!e.includes(`<head`))&&(e=dt(t));let n=t.theme,r=n?.title||`Boltdocs`,i=n?.description||``,a=n?.favicon;!a&&n?.logo&&(a=typeof n.logo==`string`?n.logo:n.logo.light||n.logo.dark);let o=[a?`<link rel="icon" href="${a}">`:``,`<meta name="description" content="${i}">`,`<meta property="og:title" content="${r}">`,`<meta property="og:description" content="${i}">`,`<meta property="og:type" content="website">`,`<meta name="twitter:card" content="summary_large_image">`,`<meta name="twitter:title" content="${r}">`,`<meta name="twitter:description" content="${i}">`,`<meta name="generator" content="Boltdocs">`].filter(Boolean).join(`
|
|
70
|
-
`);return e=e.includes(`<title>`)?e.replace(/<title>.*?<\/title>/,`<title>${r}</title>`):e.replace(`</head>`,` <title>${r}</title>\n </head>`),e=e.replace(`</head>`,` ${o}\n
|
|
71
|
-
<script>
|
|
72
|
-
(function() {
|
|
73
|
-
try {
|
|
74
|
-
var stored = localStorage.getItem("boltdocs-theme");
|
|
75
|
-
var isDark =
|
|
76
|
-
stored === "dark" ||
|
|
77
|
-
(stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
78
|
-
document.documentElement.classList.toggle("dark", isDark);
|
|
79
|
-
document.documentElement.dataset.theme = isDark ? "dark" : "light";
|
|
80
|
-
} catch (e) {}
|
|
81
|
-
})();
|
|
82
|
-
<\/script>
|
|
83
|
-
</head>`),!e.includes(`src/main`)&&!e.includes(`virtual:boltdocs-entry`)&&(e=e.replace(`</body>`,` <script type="module">import "virtual:boltdocs-entry";<\/script>
|
|
84
|
-
</body>`)),e}function pt(e){let t=[];for(let n of e)if(t.push({id:n.path,title:n.title,content:n._content||``,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version});return t}const mt={"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`};function ht(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(`; `)}var Y=class e extends Error{pluginName;constructor(t,n){super(`[plugin:${t}] ${n}`),this.name=`PluginError`,this.pluginName=t,Object.setPrototypeOf(this,e.prototype)}},X=class e extends Y{constructor(t,n){super(t,`Validation failed: ${n}`),this.name=`PluginValidationError`,Object.setPrototypeOf(this,e.prototype)}},gt=class e extends Y{constructor(t,n){super(t,`Compatibility error: ${n}`),this.name=`PluginCompatibilityError`,Object.setPrototypeOf(this,e.prototype)}},_t=class e extends Y{constructor(t,n){super(t,`Missing required permission: '${n}'`),this.name=`PluginPermissionError`,Object.setPrototypeOf(this,e.prototype)}},vt=class e extends Y{hookName;constructor(t,n,r){super(t,`Error in hook '${n}': ${r.message}`),this.name=`PluginHookError`,this.hookName=n,this.stack=r.stack,Object.setPrototypeOf(this,e.prototype)}},yt=class{data=new Map;getNamespaceKey(e,t){return`${e}:${t}`}get(e,t){let n=this.getNamespaceKey(e,t),r=this.data.get(n);if(r!==void 0)return typeof r==`object`&&r?JSON.parse(JSON.stringify(r)):r}set(e,t,n){let r=this.getNamespaceKey(e,t),i=typeof n==`object`&&n?JSON.parse(JSON.stringify(n)):n;this.data.set(r,i)}has(e,t){let n=this.getNamespaceKey(e,t);return this.data.has(n)}};const bt=Qe.extend({version:g.z.string().optional(),boltdocsVersion:g.z.string().optional(),permissions:g.z.array(g.z.string()).optional(),hooks:g.z.object({beforeBuild:g.z.function().optional(),afterBuild:g.z.function().optional(),beforeDev:g.z.function().optional(),afterDev:g.z.function().optional(),configResolved:g.z.function().optional(),buildEnd:g.z.function().optional()}).optional()});function xt(e,t){let n=[],r=new Set;for(let i of e){let e=bt.safeParse(i);if(!e.success)throw new X(i.name||`unknown`,e.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `));let a=e.data;if(r.has(a.name))throw new X(a.name,`Duplicate plugin name detected`);if(r.add(a.name),a.boltdocsVersion&&!C.default.satisfies(t,a.boltdocsVersion))throw new gt(a.name,`Plugin expects Boltdocs version ${a.boltdocsVersion}, but current is ${t}`);if(a.components){for(let[e,t]of Object.entries(a.components))if((t.includes(`..`)||_.default.isAbsolute(t))&&t.includes(`..`))throw new X(a.name,`Component '${e}' has an invalid path: traversal sequences are not allowed.`)}n.push(a)}return n}function Z(e,t){return e.permissions?e.permissions.includes(t):!1}var Q=class{static checkPermission(e,t){if(!Z(e,t))throw new _t(e.name,t)}static getSanitizedCapabilities(e){return{remarkPlugins:Z(e,`mdx:remark`)?e.remarkPlugins:[],rehypePlugins:Z(e,`mdx:rehype`)?e.rehypePlugins:[],vitePlugins:Z(e,`vite:config`)?e.vitePlugins:[],components:Z(e,`components`)?e.components:{}}}static async executeWithIsolation(e,t,n,r){try{return this.checkPermission(e,t),await r()}catch(t){if(t instanceof _t){console.warn(`[boltdocs] Skipping hook '${n}' for plugin '${e.name}': ${t.message}`);return}throw t}}},St=class{plugins;config;store;constructor(e,t){this.plugins=e,this.config=t,this.store=new yt}async runHook(e,...t){let n=this.getSortedPlugins();for(let r of n){if(!r.hooks?.[e])continue;let n=this.createContext(r),i=e.toLowerCase().includes(`build`),a=e.toLowerCase().includes(`dev`),o=i?`hooks:build`:a?`hooks:dev`:void 0;try{o?await Q.executeWithIsolation(r,o,e,()=>r.hooks[e](n,...t)):await r.hooks[e](n,...t)}catch(t){let i=new vt(r.name,e,t instanceof Error?t:Error(String(t)));n.logger.error(i)}}}getSortedPlugins(){let e=this.plugins.filter(e=>e.enforce===`pre`),t=this.plugins.filter(e=>!e.enforce),n=this.plugins.filter(e=>e.enforce===`post`);return[...e,...t,...n]}createContext(e){return{config:Object.freeze({...this.config}),meta:{name:e.name,version:e.version,boltdocsVersion:e.boltdocsVersion},store:{get:(e,t)=>this.store.get(e,t),set:(e,t,n)=>this.store.set(e,t,n),has:(e,t)=>this.store.has(e,t)},logger:this.createLogger(e.name)}}createLogger(e){let t=`[plugin:${e}]`;return{info:e=>console.log(`${t} INFO: ${e}`),warn:e=>console.warn(`${t} WARN: ${e}`),error:e=>{let n=e instanceof Error?e.message:e;console.error(`${t} ERROR: ${n}`)},debug:e=>console.debug(`${t} DEBUG: ${e}`)}}};function Ct(e){return e}function wt(e={},t){let n=x.default.resolve(process.cwd(),e.docsDir||`docs`),r=R(n),i=t,a,o=!1,s,c=[];return[{name:`vite-plugin-boltdocs`,enforce:`pre`,async config(t,r){o=r.command===`build`;let a=t.envDir||process.cwd(),l=(0,d.loadEnv)(r.mode,a,``);Object.assign(process.env,l),i||=await J(n);let u=(await Promise.resolve().then(()=>require(`./package-Dgmsc_l5.cjs`))).version,f=xt(i.plugins||[],u);return i.plugins=f,s=new St(f,i),c=f.flatMap(e=>Q.getSanitizedCapabilities(e).vitePlugins||[]),o&&await s.runHook(`beforeBuild`),{ssgOptions:{entry:`boltdocs/entry`,htmlEntry:`index.html`,dirStyle:`nested`,includeAllRoutes:!0,mock:!0,script:`async`,beastiesOptions:{preload:`media`},onFinished:async e=>{let t=ct(Je(await Ge(n,i)),i);t&&S.default.writeFileSync(x.default.join(e,`sitemap.xml`),t);let r=lt(i);S.default.writeFileSync(x.default.join(e,`robots.txt`),r)}},build:{ssrManifest:o},async config(){let t=__dirname;for(;t!==x.default.parse(t).root&&!S.default.existsSync(x.default.join(t,`package.json`));)t=x.default.dirname(t);if(S.default.existsSync(x.default.join(t,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(t,`package.json`),`utf-8`)).name!==`boltdocs`){let e=x.default.dirname(t);for(;e!==x.default.parse(e).root;){if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=x.default.dirname(e)}}return{optimizeDeps:{include:[`react`,`react-dom`,`react-router-dom`],exclude:[`boltdocs`,`boltdocs/client`]},resolve:{alias:[{find:`boltdocs/entry`,replacement:R(x.default.resolve(e.root||process.cwd(),`boltdocs-entry.cjs`))}]}}}}},configResolved(e){a=e,s?.runHook(`configResolved`,i)},async configureServer(e){await s?.runHook(`beforeDev`),e.middlewares.use((e,t,n)=>{process.env.NODE_ENV===`production`&&Object.entries(mt).forEach(([e,n])=>{t.setHeader(e,n)}),i.security?.enableCSP&&t.setHeader(`Content-Security-Policy`,ht(i)),n()}),e.middlewares.use((e,t,n)=>{if(e.url===`/robots.txt`){n();return}n()}),e.middlewares.use(async(t,n,r)=>{let a=t.url?.split(`?`)[0]||`/`,o=t.headers.accept||``,s=a===`/`||a.startsWith(`/docs`)||i.i18n&&Object.keys(i.i18n.locales).some(e=>a.startsWith(`/${e}/docs`)||a===`/${e}`)||!0,c=/\.(js|css|png|jpe?g|gif|svg|ico|webp|woff2?|ttf|otf|mp4|webm|ogg|mp3|wav|flac|aac|pdf|zip|gz|map|json)$/i.test(a);if(o.includes(`text/html`)&&!c&&s){let r=dt(i);r=ft(r,i),r=await e.transformIndexHtml(t.url||`/`,r),n.statusCode=200,n.setHeader(`Content-Type`,`text/html`),n.end(r);return}r()});let t=st.map(e=>x.default.resolve(process.cwd(),e)),a=[`tsx`,`jsx`].map(e=>x.default.resolve(n,`layout.${e}`)),o=[`tsx`,`ts`,`jsx`,`js`],c=o.map(e=>x.default.resolve(n,`mdx-components.${e}`)),l=o.map(e=>x.default.resolve(n,`pages-external/index.${e}`)),u=o.map(e=>x.default.resolve(n,`icons.${e}`));e.watcher.add([...t,...c,...a,...l,...u]);let d=async(t,a)=>{try{let s=R(t);if(st.some(e=>s.endsWith(e))){e.restart();return}if(o.some(e=>s.endsWith(`mdx-components.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-mdx-components.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(o.some(e=>s.endsWith(`icons.${e}`))){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-icons.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.endsWith(`layout.tsx`)||s.endsWith(`layout.jsx`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-layout.tsx`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(s.includes(`/pages-external/`)||s.includes(`\\pages-external\\`)){let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-entry`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`});return}if(!s.startsWith(r)||!xe(s))return;if(a===`add`||a===`unlink`){Le(),i=await J(n);let t=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);t&&e.moduleGraph.invalidateModule(t),e.ws.send({type:`custom`,event:`boltdocs:config-update`,data:{theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl}})}else Re(t);let c=e.moduleGraph.getModuleById(`\0virtual:boltdocs-routes.ts`);c&&e.moduleGraph.invalidateModule(c);let l=e.moduleGraph.getModuleById(`\0virtual:boltdocs-config.ts`);l&&e.moduleGraph.invalidateModule(l),e.ws.send({type:`full-reload`})}catch(e){console.error(`[boltdocs] HMR error during ${a} event:`,e)}};e.watcher.on(`add`,e=>d(e,`add`)),e.watcher.on(`unlink`,e=>d(e,`unlink`)),e.watcher.on(`change`,e=>d(e,`change`)),await s?.runHook(`afterDev`)},resolveId(e){let t=a?.root||process.cwd();return e.includes(`boltdocs-entry.mjs`)||e===`virtual:boltdocs-entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`?R(x.default.resolve(t,`boltdocs-entry.mjs`)):e.includes(`boltdocs-client.mjs`)||e===`virtual:boltdocs-client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.ts`?R(x.default.resolve(t,`boltdocs-client.mjs`)):e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(t){if(t.includes(`boltdocs-entry.mjs`)||t===`\0virtual:boltdocs-entry`)return ut(e,i);if(t.includes(`boltdocs-client.mjs`)||t===`\0virtual:boltdocs-client.ts`||t===`virtual:boltdocs-client`){let e=__dirname,t=e;for(;e!==x.default.parse(e).root;){if(S.default.existsSync(x.default.join(e,`package.json`))&&JSON.parse(S.default.readFileSync(x.default.join(e,`package.json`),`utf-8`)).name===`boltdocs`){t=e;break}e=x.default.dirname(e)}let n=x.default.join(t,`src/client/index.ts`),r=x.default.join(t,`dist/client/index.js`);return`export * from '${R(S.default.existsSync(n)?n:r)}';`}if(!t.startsWith(`\0virtual:boltdocs-`))return;let r=t.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(r===`routes`){let e=Je(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`config`){let e={theme:i?.theme,i18n:i?.i18n,versions:i?.versions,siteUrl:i?.siteUrl,plugins:i?.plugins?.map(e=>({name:e.name}))};return`export default ${JSON.stringify(e,null,2)};`}if(r===`entry`)return ut(e,i);if(r===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`mdx-components.${r}`);if(S.default.existsSync(e)){t=e;break}}if(t){let e=R(t);return`import * as components from '${e}';
|
|
85
|
-
const mdxComponents = components.default || components;
|
|
86
|
-
export default mdxComponents;
|
|
87
|
-
export * from '${e}';`}return`export default {};`}if(r===`layout`){let e=[`tsx`,`jsx`],t=null;for(let r of e){let e=x.default.resolve(n,`layout.${r}`);if(S.default.existsSync(e)){t=e;break}}return t?`import UserLayout from '${R(t)}';
|
|
88
|
-
export default UserLayout;`:`import { DefaultLayout } from '${R(x.default.resolve(__dirname,`../../client/components/default-layout.tsx`))}';
|
|
89
|
-
export default DefaultLayout;`}if(r===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let r of e){let e=x.default.resolve(n,`icons.${r}`);if(S.default.existsSync(e)){t=e;break}}return t?`import * as icons from '${R(t)}';\nexport default icons;`:`export default {};`}if(r===`search`){let e=pt(await Ge(n,i));return`export default ${JSON.stringify(e,null,2)};`}if(r===`client`){let e=__dirname,t=``;for(;e&&e!==x.default.parse(e).root;){let n=x.default.join(e,`src/client/index.ts`),r=x.default.join(e,`dist/client/index.mjs`),i=x.default.join(e,`client/index.ts`);if(S.default.existsSync(n)){t=R(n);break}if(S.default.existsSync(r)){t=R(r);break}if(S.default.existsSync(i)){t=R(i);break}e=x.default.dirname(e)}if(!t)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${__dirname}`);return`export * from '${t}';`}},transformIndexHtml:{order:`pre`,handler(e){return ft(e,i)}},async closeBundle(){!o||a?.build?.ssr||(await s?.runHook(`afterBuild`),await s?.runHook(`buildEnd`))}},(0,te.ViteImageOptimizer)({includePublic:!0,png:{quality:80},jpeg:{quality:80},jpg:{quality:80},webp:{quality:80},avif:{quality:80},svg:{multipass:!0,plugins:[{name:`preset-default`}]}}),{name:`vite-plugin-boltdocs-extra-plugins`,async configResolved(){}},...c]}const $=new Ie(`mdx`),Tt=[k.default.default||k.default,A.default.default||A.default,j.default.default||j.default,M.default.default||M.default,N.default.default||N.default,P.default.default||P.default,F.default.default||F.default],Et=[ie.default,ae.default,oe.default,se.default,ce.default,le.default,ue.default,de.default,fe.default,pe.default,me.default,he.default];let Dt=null,Ot=null;const kt=()=>(Dt??=(0,ne.createJavaScriptRegexEngine)(),Dt),At=async e=>Ot||(Ot=(0,re.createHighlighterCore)({themes:Tt,langs:Et,engine:kt()}),Ot),jt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:line-numbers`,pre(e){let n=this.options.meta?.__raw||``,r=/lineNumbers|showLineNumbers/.test(n);(t||r)&&this.addClassToHast(e,`shiki-line-numbers`)}}},Mt=(e={})=>{let{activateByDefault:t=!1}=e;return{name:`boltdocs:word-wrap`,pre(e){let n=this.options.meta?.__raw||``,r=/wordWrap|word-wrap/.test(n);(t||r)&&this.addClassToHast(e,`shiki-word-wrap`)}}},Nt=()=>({name:`AddTitleProperty`,pre(e){let t=this.options.meta?.__raw;if(!t)return;let n=t.match(/title=(["'])(.*?)\1/)?.[2];e.properties[`data-title`]=n}}),Pt=()=>({name:`AddLanguageProperty`,pre(e){e.properties[`data-lang`]=this.options.lang||`plaintext`}});var Ft=class{config;constructor(e){this.config=e}getTheme(){return this.config?.theme?.codeTheme||{light:`github-light`,dark:`github-dark`}}async getHighlighter(){return await At(this.getTheme())}getOptions(e,t){let n=this.getTheme(),r={lang:e,meta:{__raw:t},transformers:[jt(),Mt(),Nt(),Pt()]};return typeof n==`object`?r.themes={light:n.light,dark:n.dark}:r.theme=n,r}async render(e,t,n){let r=await this.getHighlighter(),i=this.getOptions(t,n);return r.codeToHtml(e,i)}};function It(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,[`mdxJsxFlowElement`,`mdxJsxTextElement`],e=>{if(e.name!==`ComponentPreview`)return;let r=e.attributes?.find(e=>e.name===`code`),i=``;if(r){if(typeof r.value==`string`)i=r.value;else if(r.value?.type===`mdxJsxAttributeValueExpression`){let e=r.value.value??``;i=e.match(/^[`'"]([\s\S]+)[`'"]$/)?.[1]??e}}if(!i)return;let a=e.attributes?.find(e=>e.name===`lineNumbers`||e.name===`showLineNumbers`),o=e.attributes?.find(e=>e.name===`wordWrap`||e.name===`word-wrap`),s=e.attributes?.find(e=>e.name===`title`),c=``;a&&(c+=` lineNumbers`),o&&(c+=` wordWrap`),s&&typeof s.value==`string`&&(c+=` title="${s.value}"`);let l=t.getOptions(`tsx`,c),u=n.codeToHtml(i,l);e.attributes=(e.attributes??[]).filter(e=>e.name!==`highlightedHtml`),e.attributes.push({type:`mdxJsxAttribute`,name:`highlightedHtml`,value:u})})}}function Lt(e){let t=new Ft(e);return async e=>{let n=await t.getHighlighter();(0,O.visit)(e,`element`,e=>{if(e.tagName===`pre`&&e.children?.[0]?.tagName===`code`){let r=e.children[0],i=(r.properties?.className||[]).find(e=>e.startsWith(`language-`)),a=i?i.slice(9):`text`,o=r.children[0]?.value||``,s=r.properties?.metastring||r.data?.meta||``,c=t.getOptions(a,s),l=n.codeToHtml(o,c);e.properties[`data-highlighted`]=`true`,e.properties[`data-highlighted-html`]=l,e.properties[`data-lang`]=a,e.children=[]}})}}function Rt(){return e=>{(0,O.visit)(e,`code`,e=>{e.meta&&(e.data=e.data||{},e.data.hProperties=e.data.hProperties||{},e.data.hProperties.metastring=e.meta)})}}let zt=!1;function Bt(e,t=w.default){let n=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).remarkPlugins||[])||[],r=e?.plugins?.flatMap(e=>Q.getSanitizedCapabilities(e).rehypePlugins||[])||[],i=t({remarkPlugins:[T.default,E.default,Rt,[It,e],...n],rehypePlugins:[D.default,[Lt,e],...r],jsxRuntime:`automatic`});return{...i,name:`vite-plugin-boltdocs-mdx`,async buildStart(){zt||=($.load(),!0),i.buildStart&&await i.buildStart.call(this)},async transform(e,t,n){if(!t.endsWith(`.md`)&&!t.endsWith(`.mdx`))return i.transform?.call(this,e,t,n);let r=`${t}:${v.default.createHash(`md5`).update(e).digest(`hex`)}:v2`,a=$.get(r);if(a)return{code:a,map:null};let o=await i.transform.call(this,e,t,n);return o&&typeof o==`object`&&o.code&&$.set(r,o.code),o},async buildEnd(){$.save(),await $.flush(),i.buildEnd&&await i.buildEnd.call(this)}}}async function Vt(e){let t=await J(e?.docsDir||`docs`);return[...wt({...e,homePage:e?.homePage||t.homePage},t),Bt(t)]}async function Ht(e,t=`development`){let n=await J(`docs`,e),r=t===`production`,i=r?{...mt}:{};return n.security?.enableCSP&&(i[`Content-Security-Policy`]=ht(n)),{root:e,mode:t,oxc:{jsx:{development:!r,runtime:`automatic`,importSource:`react`}},optimizeDeps:{include:[`react`,`react-dom`,`react-dom/client`,`react-helmet-async`,`react-router-dom`],rolldownOptions:{}},build:{rolldownOptions:{}},plugins:[(0,l.default)(),(0,u.default)(),await Vt({...n,root:e})],resolve:{alias:{"boltdocs/entry":(0,d.normalizePath)(x.default.resolve(e,`boltdocs-entry.mjs`)),"boltdocs/client":(0,d.normalizePath)(x.default.resolve(e,`boltdocs-client.mjs`))},dedupe:[`react`,`react-dom`,`react-router-dom`,`react-helmet-async`,`@bdocs/ssg`]},ssr:{noExternal:[`boltdocs`,/@bdocs\/(?!ssg).*/,`react-helmet-async`]},server:{headers:{...i,...n.vite?.server?.headers},...n.vite?.server},preview:{headers:{...i,...n.vite?.preview?.headers},...n.vite?.preview},...n.vite}}Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return ut}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return _t}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return gt}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return Ce}});
|