boltdocs 2.5.5 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/boltdocs.js +2 -2
- package/dist/client/index.cjs +6 -0
- package/dist/client/index.d.cts +1560 -0
- package/dist/client/index.d.ts +1219 -922
- package/dist/client/index.js +6 -1
- package/dist/client/theme/neutral.css +428 -0
- package/dist/node/cli-entry.cjs +8 -0
- package/dist/node/cli-entry.d.cts +2 -0
- package/dist/node/cli-entry.d.mts +2 -1
- package/dist/node/cli-entry.mjs +7 -5
- package/dist/node/index.cjs +6 -0
- package/dist/node/index.d.cts +519 -0
- package/dist/node/index.d.mts +374 -422
- package/dist/node/index.mjs +6 -1
- package/dist/node-BgvNl2Ay.mjs +89 -0
- package/dist/node-vkbb0MK7.cjs +89 -0
- package/dist/package-CR0HF9x3.mjs +6 -0
- package/dist/package-Dgmsc_l5.cjs +6 -0
- package/dist/search-dialog-3lvKsbVG.js +6 -0
- package/dist/search-dialog-DMK5OpgH.cjs +6 -0
- package/dist/use-search-C9bxCqfF.js +6 -0
- package/dist/use-search-DcfZSunO.cjs +6 -0
- package/package.json +26 -25
- package/src/client/app/config-context.tsx +38 -5
- package/src/client/app/doc-page.tsx +34 -0
- package/src/client/app/mdx-component.tsx +2 -3
- package/src/client/app/mdx-components-context.tsx +27 -2
- package/src/client/app/routes-context.tsx +34 -0
- package/src/client/app/scroll-handler.tsx +7 -4
- package/src/client/app/theme-context.tsx +71 -67
- package/src/client/components/default-layout.tsx +34 -33
- package/src/client/components/docs-layout.tsx +1 -2
- package/src/client/components/icons-dev.tsx +36 -5
- package/src/client/components/mdx/admonition.tsx +11 -27
- package/src/client/components/mdx/badge.tsx +1 -1
- package/src/client/components/mdx/button.tsx +3 -3
- package/src/client/components/mdx/card.tsx +1 -1
- package/src/client/components/mdx/code-block.tsx +90 -80
- package/src/client/components/mdx/component-preview.tsx +1 -5
- package/src/client/components/mdx/component-props.tsx +1 -1
- package/src/client/components/mdx/field.tsx +4 -5
- package/src/client/components/mdx/file-tree.tsx +6 -3
- package/src/client/components/mdx/hooks/use-code-block.ts +2 -2
- package/src/client/components/mdx/image.tsx +1 -1
- package/src/client/components/mdx/link.tsx +2 -2
- package/src/client/components/mdx/list.tsx +1 -1
- package/src/client/components/mdx/table.tsx +1 -1
- package/src/client/components/mdx/tabs.tsx +1 -1
- package/src/client/components/primitives/breadcrumbs.tsx +1 -7
- package/src/client/components/primitives/button-group.tsx +1 -1
- package/src/client/components/primitives/button.tsx +1 -1
- package/src/client/components/primitives/code-block.tsx +113 -0
- package/src/client/components/primitives/link.tsx +23 -41
- package/src/client/components/primitives/menu.tsx +5 -6
- package/src/client/components/primitives/navbar.tsx +6 -18
- package/src/client/components/primitives/navigation-menu.tsx +4 -4
- package/src/client/components/primitives/on-this-page.tsx +6 -10
- package/src/client/components/primitives/page-nav.tsx +4 -9
- package/src/client/components/primitives/popover.tsx +1 -1
- package/src/client/components/primitives/search-dialog.tsx +3 -6
- package/src/client/components/primitives/sidebar.tsx +80 -22
- package/src/client/components/primitives/skeleton.tsx +1 -1
- package/src/client/components/primitives/tabs.tsx +4 -11
- package/src/client/components/primitives/tooltip.tsx +3 -3
- package/src/client/components/ui-base/breadcrumbs.tsx +4 -6
- package/src/client/components/ui-base/copy-markdown.tsx +2 -7
- package/src/client/components/ui-base/github-stars.tsx +2 -2
- package/src/client/components/ui-base/head.tsx +58 -51
- package/src/client/components/ui-base/loading.tsx +2 -2
- package/src/client/components/ui-base/navbar.tsx +12 -14
- package/src/client/components/ui-base/not-found.tsx +1 -1
- package/src/client/components/ui-base/on-this-page.tsx +6 -6
- package/src/client/components/ui-base/page-nav.tsx +4 -8
- package/src/client/components/ui-base/search-dialog.tsx +10 -8
- package/src/client/components/ui-base/sidebar.tsx +76 -23
- package/src/client/components/ui-base/tabs.tsx +9 -8
- package/src/client/components/ui-base/theme-toggle.tsx +2 -2
- package/src/client/hooks/use-i18n.ts +3 -3
- package/src/client/hooks/use-localized-to.ts +1 -1
- package/src/client/hooks/use-navbar.ts +8 -6
- package/src/client/hooks/use-routes.ts +19 -11
- package/src/client/hooks/use-search.ts +1 -1
- package/src/client/hooks/use-sidebar.ts +48 -2
- package/src/client/hooks/use-tabs.ts +6 -2
- package/src/client/hooks/use-version.ts +3 -3
- package/src/client/index.ts +22 -22
- package/src/client/ssg/boltdocs-shell.tsx +127 -0
- package/src/client/ssg/create-routes.tsx +179 -0
- package/src/client/ssg/index.ts +3 -0
- package/src/client/ssg/mdx-page.tsx +37 -0
- package/src/client/store/boltdocs-context.tsx +66 -0
- package/src/client/theme/neutral.css +90 -50
- package/src/client/types.ts +5 -33
- package/src/client/utils/react-to-text.ts +34 -0
- package/CHANGELOG.md +0 -98
- package/dist/cache-3FOEPC2P.mjs +0 -1
- package/dist/chunk-5B5NKOW6.mjs +0 -77
- package/dist/chunk-J2PTDWZM.mjs +0 -1
- package/dist/chunk-TP5KMRD3.mjs +0 -1
- package/dist/chunk-Y4RE5KI7.mjs +0 -1
- package/dist/client/index.d.mts +0 -1263
- package/dist/client/index.mjs +0 -1
- package/dist/client/ssr.d.mts +0 -78
- package/dist/client/ssr.d.ts +0 -78
- package/dist/client/ssr.js +0 -1
- package/dist/client/ssr.mjs +0 -1
- package/dist/node/cli-entry.d.ts +0 -1
- package/dist/node/cli-entry.js +0 -82
- package/dist/node/index.d.ts +0 -567
- package/dist/node/index.js +0 -77
- package/dist/package-QFIAETHR.mjs +0 -1
- package/dist/search-dialog-O6VLVSOA.mjs +0 -1
- package/src/client/app/index.tsx +0 -345
- package/src/client/app/mdx-page.tsx +0 -15
- package/src/client/app/preload.tsx +0 -66
- package/src/client/app/router.tsx +0 -30
- package/src/client/integrations/codesandbox.ts +0 -179
- package/src/client/integrations/index.ts +0 -1
- package/src/client/ssr.tsx +0 -65
- package/src/client/store/use-boltdocs-store.ts +0 -44
- package/src/node/cache.ts +0 -408
- package/src/node/cli/build.ts +0 -53
- package/src/node/cli/dev.ts +0 -22
- package/src/node/cli/doctor.ts +0 -243
- package/src/node/cli/index.ts +0 -9
- package/src/node/cli/ui.ts +0 -54
- package/src/node/cli-entry.ts +0 -24
- package/src/node/config.ts +0 -382
- package/src/node/errors.ts +0 -44
- package/src/node/index.ts +0 -84
- package/src/node/mdx/cache.ts +0 -12
- package/src/node/mdx/highlighter.ts +0 -47
- package/src/node/mdx/index.ts +0 -122
- package/src/node/mdx/rehype-shiki.ts +0 -62
- package/src/node/mdx/remark-code-meta.ts +0 -35
- package/src/node/mdx/remark-shiki.ts +0 -61
- package/src/node/plugin/entry.ts +0 -87
- package/src/node/plugin/html.ts +0 -99
- package/src/node/plugin/index.ts +0 -478
- package/src/node/plugin/types.ts +0 -9
- package/src/node/plugins/index.ts +0 -17
- package/src/node/plugins/plugin-errors.ts +0 -62
- package/src/node/plugins/plugin-lifecycle.ts +0 -117
- package/src/node/plugins/plugin-sandbox.ts +0 -59
- package/src/node/plugins/plugin-store.ts +0 -54
- package/src/node/plugins/plugin-types.ts +0 -107
- package/src/node/plugins/plugin-validator.ts +0 -105
- package/src/node/routes/cache.ts +0 -28
- package/src/node/routes/index.ts +0 -293
- package/src/node/routes/parser.ts +0 -262
- package/src/node/routes/sorter.ts +0 -42
- package/src/node/routes/types.ts +0 -61
- package/src/node/schema/config.ts +0 -195
- package/src/node/schema/frontmatter.ts +0 -17
- package/src/node/search/index.ts +0 -55
- package/src/node/security/constants/index.ts +0 -10
- package/src/node/security/csp.ts +0 -31
- package/src/node/security/headers.ts +0 -27
- package/src/node/ssg/index.ts +0 -205
- package/src/node/ssg/meta.ts +0 -33
- package/src/node/ssg/options.ts +0 -15
- package/src/node/ssg/robots.ts +0 -53
- package/src/node/ssg/sitemap.ts +0 -55
- package/src/node/utils.ts +0 -349
- package/tsconfig.json +0 -26
- package/tsup.config.ts +0 -56
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
|
|
2
|
+
import * as _$vite from "vite";
|
|
3
|
+
import { InlineConfig, Plugin } from "vite";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/shared/types.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Represents a single social link in the configuration.
|
|
9
|
+
*/
|
|
10
|
+
interface BoltdocsSocialLink {
|
|
11
|
+
icon: 'discord' | 'x' | 'github' | 'bluesky' | string;
|
|
12
|
+
link: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configuration for the site footer.
|
|
16
|
+
*/
|
|
17
|
+
interface BoltdocsFooterConfig {
|
|
18
|
+
text?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Theme-specific configuration options.
|
|
22
|
+
*/
|
|
23
|
+
interface BoltdocsThemeConfig {
|
|
24
|
+
title?: string | Record<string, string>;
|
|
25
|
+
description?: string | Record<string, string>;
|
|
26
|
+
logo?: string | {
|
|
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<{
|
|
38
|
+
text: string;
|
|
39
|
+
link: string;
|
|
40
|
+
}>>;
|
|
41
|
+
sidebarGroups?: Record<string, {
|
|
42
|
+
title?: string;
|
|
43
|
+
icon?: string;
|
|
44
|
+
}>;
|
|
45
|
+
socialLinks?: BoltdocsSocialLink[];
|
|
46
|
+
footer?: BoltdocsFooterConfig;
|
|
47
|
+
breadcrumbs?: boolean;
|
|
48
|
+
editLink?: string;
|
|
49
|
+
communityHelp?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
githubRepo?: string;
|
|
52
|
+
favicon?: string;
|
|
53
|
+
poweredBy?: boolean;
|
|
54
|
+
tabs?: Array<{
|
|
55
|
+
id: string;
|
|
56
|
+
text: string | Record<string, string>;
|
|
57
|
+
icon?: string;
|
|
58
|
+
}>;
|
|
59
|
+
codeTheme?: ShikiTheme | {
|
|
60
|
+
light: ShikiTheme;
|
|
61
|
+
dark: ShikiTheme;
|
|
62
|
+
};
|
|
63
|
+
copyMarkdown?: boolean | {
|
|
64
|
+
text?: string;
|
|
65
|
+
icon?: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* List of supported syntax highlighting themes.
|
|
70
|
+
*/
|
|
71
|
+
type ShikiTheme = 'github-dark' | 'github-light' | 'tokyo-night' | 'dracula' | 'nord' | 'one-dark-pro' | 'one-light';
|
|
72
|
+
/**
|
|
73
|
+
* Configuration for the robots.txt file.
|
|
74
|
+
*/
|
|
75
|
+
type BoltdocsRobotsConfig = string | {
|
|
76
|
+
rules?: Array<{
|
|
77
|
+
userAgent: string;
|
|
78
|
+
allow?: string | string[];
|
|
79
|
+
disallow?: string | string[];
|
|
80
|
+
}>;
|
|
81
|
+
sitemaps?: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for a specific locale.
|
|
85
|
+
*/
|
|
86
|
+
interface BoltdocsLocaleConfig {
|
|
87
|
+
label?: string;
|
|
88
|
+
direction?: 'ltr' | 'rtl';
|
|
89
|
+
htmlLang?: string;
|
|
90
|
+
calendar?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Configuration for internationalization (i18n).
|
|
94
|
+
*/
|
|
95
|
+
interface BoltdocsI18nConfig {
|
|
96
|
+
defaultLocale: string;
|
|
97
|
+
locales: Record<string, string>;
|
|
98
|
+
localeConfigs?: Record<string, BoltdocsLocaleConfig>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Configuration for a specific documentation version.
|
|
102
|
+
*/
|
|
103
|
+
interface BoltdocsVersionConfig {
|
|
104
|
+
label: string;
|
|
105
|
+
path: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Configuration for documentation versioning.
|
|
109
|
+
*/
|
|
110
|
+
interface BoltdocsVersionsConfig {
|
|
111
|
+
defaultVersion: string;
|
|
112
|
+
prefix?: string;
|
|
113
|
+
versions: BoltdocsVersionConfig[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Defines a Boltdocs plugin.
|
|
117
|
+
*/
|
|
118
|
+
interface BoltdocsPlugin {
|
|
119
|
+
name: string;
|
|
120
|
+
enforce?: 'pre' | 'post';
|
|
121
|
+
version?: string;
|
|
122
|
+
boltdocsVersion?: string;
|
|
123
|
+
permissions?: string[];
|
|
124
|
+
remarkPlugins?: unknown[];
|
|
125
|
+
rehypePlugins?: unknown[];
|
|
126
|
+
vitePlugins?: Plugin[];
|
|
127
|
+
components?: Record<string, string>;
|
|
128
|
+
hooks?: Record<string, any>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Configuration for security-related settings.
|
|
132
|
+
*/
|
|
133
|
+
interface BoltdocsSecurityConfig {
|
|
134
|
+
headers?: Record<string, string>;
|
|
135
|
+
enableCSP?: boolean;
|
|
136
|
+
customHeaders?: Record<string, string>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Configuration for SEO.
|
|
140
|
+
*/
|
|
141
|
+
interface BoltdocsSeoConfig {
|
|
142
|
+
metatags?: Record<string, string>;
|
|
143
|
+
indexing?: 'all' | 'public';
|
|
144
|
+
thumbnails?: {
|
|
145
|
+
background?: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The root configuration object for Boltdocs.
|
|
150
|
+
*/
|
|
151
|
+
interface BoltdocsConfig {
|
|
152
|
+
siteUrl?: string;
|
|
153
|
+
docsDir?: string;
|
|
154
|
+
base?: string;
|
|
155
|
+
homePage?: string;
|
|
156
|
+
theme?: BoltdocsThemeConfig;
|
|
157
|
+
i18n?: BoltdocsI18nConfig;
|
|
158
|
+
versions?: BoltdocsVersionsConfig;
|
|
159
|
+
plugins?: BoltdocsPlugin[];
|
|
160
|
+
robots?: BoltdocsRobotsConfig;
|
|
161
|
+
security?: BoltdocsSecurityConfig;
|
|
162
|
+
seo?: BoltdocsSeoConfig;
|
|
163
|
+
vite?: any;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/shared/config-utils.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* Type-safe helper for defining Boltdocs configuration.
|
|
169
|
+
* This is an identity function that provides IntelliSense in both
|
|
170
|
+
* Node.js (config files) and client-side code (MDX examples).
|
|
171
|
+
*
|
|
172
|
+
* @param config - The Boltdocs configuration object
|
|
173
|
+
*/
|
|
174
|
+
declare function defineConfig(config: BoltdocsConfig): BoltdocsConfig;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/node/config.d.ts
|
|
177
|
+
/**
|
|
178
|
+
* Loads user's configuration file (e.g., `boltdocs.config.js` or `boltdocs.config.ts`) if it exists,
|
|
179
|
+
* merges it with the default configuration, and returns the final `BoltdocsConfig`.
|
|
180
|
+
*
|
|
181
|
+
* @param docsDir - The directory containing the documentation files
|
|
182
|
+
* @param root - The project root directory (defaults to process.cwd())
|
|
183
|
+
* @returns The merged configuration object
|
|
184
|
+
*/
|
|
185
|
+
declare function resolveConfig(docsDir: string, root?: string): Promise<BoltdocsConfig>;
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/node/plugin/types.d.ts
|
|
188
|
+
/**
|
|
189
|
+
* Configuration options specifically for the Boltdocs Vite plugin.
|
|
190
|
+
*/
|
|
191
|
+
interface BoltdocsPluginOptions {
|
|
192
|
+
/** The root directory containing markdown files (default: 'docs') */
|
|
193
|
+
docsDir?: string;
|
|
194
|
+
/** Path to a custom home page component (relative to project root) to render at '/' */
|
|
195
|
+
homePage?: string;
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/node/plugin/entry.d.ts
|
|
199
|
+
/**
|
|
200
|
+
* Generates the raw source code for the virtual entry file (`\0virtual:boltdocs-entry`).
|
|
201
|
+
* This code initializes the client-side React application.
|
|
202
|
+
*
|
|
203
|
+
* @param options - Plugin options containing potential custom overrides (like `homePage` or `customCss`)
|
|
204
|
+
* @param config - The resolved Boltdocs configuration containing custom plugins and components
|
|
205
|
+
* @returns A string of JavaScript code to be evaluated by the browser
|
|
206
|
+
*/
|
|
207
|
+
declare function generateEntryCode(options: BoltdocsPluginOptions, config?: BoltdocsConfig): string;
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/node/routes/types.d.ts
|
|
210
|
+
/**
|
|
211
|
+
* Metadata representing a single documentation route.
|
|
212
|
+
* This information is used to build the client-side router and the sidebar navigation.
|
|
213
|
+
*/
|
|
214
|
+
interface RouteMeta {
|
|
215
|
+
/** The final URL path for the route (e.g., '/docs/guide/start') */
|
|
216
|
+
path: string;
|
|
217
|
+
/** The absolute filesystem path to the source markdown/mdx file */
|
|
218
|
+
componentPath: string;
|
|
219
|
+
/** The title of the page, usually extracted from frontmatter or the filename */
|
|
220
|
+
title: string;
|
|
221
|
+
/** The relative path from the docs directory, used for edit links */
|
|
222
|
+
filePath: string;
|
|
223
|
+
/** Optional description of the page (for SEO/meta tags) */
|
|
224
|
+
description?: string;
|
|
225
|
+
/** Optional explicit position for ordering in the sidebar */
|
|
226
|
+
sidebarPosition?: number;
|
|
227
|
+
/** The group (directory) this route belongs to */
|
|
228
|
+
group?: string;
|
|
229
|
+
/** The display title for the route's group */
|
|
230
|
+
groupTitle?: string;
|
|
231
|
+
/** Optional explicit position for ordering the group itself */
|
|
232
|
+
groupPosition?: number;
|
|
233
|
+
/** Optional icon for the route's group */
|
|
234
|
+
groupIcon?: string;
|
|
235
|
+
/** The sub-route group this route belongs to (from folders starting with _) */
|
|
236
|
+
subRouteGroup?: string;
|
|
237
|
+
/** Extracted markdown headings for search indexing */
|
|
238
|
+
headings?: {
|
|
239
|
+
level: number;
|
|
240
|
+
text: string;
|
|
241
|
+
id: string;
|
|
242
|
+
}[];
|
|
243
|
+
/** The locale this route belongs to, if i18n is configured */
|
|
244
|
+
locale?: string;
|
|
245
|
+
/** The version this route belongs to, if versioning is configured */
|
|
246
|
+
version?: string;
|
|
247
|
+
/** Optional badge to display next to the sidebar item (e.g., 'New', 'Experimental') */
|
|
248
|
+
badge?: string | {
|
|
249
|
+
text: string;
|
|
250
|
+
expires?: string;
|
|
251
|
+
};
|
|
252
|
+
/** Optional icon to display (Lucide icon name or raw SVG) */
|
|
253
|
+
icon?: string;
|
|
254
|
+
/** The tab this route belongs to, if tabs are configured */
|
|
255
|
+
tab?: string;
|
|
256
|
+
/** The extracted plain-text content of the page for search indexing */
|
|
257
|
+
_content?: string;
|
|
258
|
+
/** The raw markdown content of the page */
|
|
259
|
+
_rawContent?: string;
|
|
260
|
+
/** Extracted SEO and Open Graph metadata from frontmatter */
|
|
261
|
+
seo?: Record<string, any>;
|
|
262
|
+
}
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/node/plugins/plugin-types.d.ts
|
|
265
|
+
/**
|
|
266
|
+
* Permissions that a plugin can request to access specific Boltdocs capabilities.
|
|
267
|
+
*/
|
|
268
|
+
type PluginPermission = 'fs:read' | 'fs:write' | 'vite:config' | 'mdx:remark' | 'mdx:rehype' | 'components' | 'hooks:build' | 'hooks:dev';
|
|
269
|
+
/**
|
|
270
|
+
* Shared context injected into every plugin lifecycle hook.
|
|
271
|
+
*/
|
|
272
|
+
interface PluginContext {
|
|
273
|
+
/** The full, resolved Boltdocs configuration (Readonly) */
|
|
274
|
+
readonly config: BoltdocsConfig;
|
|
275
|
+
/** A plugin-specific logger */
|
|
276
|
+
readonly logger: PluginLogger;
|
|
277
|
+
/** A shared store for dependency injection and state sharing between plugins */
|
|
278
|
+
readonly store: PluginStore;
|
|
279
|
+
/** Metadata about the current plugin */
|
|
280
|
+
readonly meta: PluginMeta;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Simple logger interface for plugins.
|
|
284
|
+
*/
|
|
285
|
+
interface PluginLogger {
|
|
286
|
+
info(message: string): void;
|
|
287
|
+
warn(message: string): void;
|
|
288
|
+
error(message: string | Error): void;
|
|
289
|
+
debug(message: string): void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A shared key-value store that allows plugins to share state and configuration.
|
|
293
|
+
*/
|
|
294
|
+
interface PluginStore {
|
|
295
|
+
/** Get a value from the store. Keys are namespaced by plugin internally. */
|
|
296
|
+
get<T = unknown>(pluginName: string, key: string): T | undefined;
|
|
297
|
+
/** Set a value in the store. */
|
|
298
|
+
set(pluginName: string, key: string, value: unknown): void;
|
|
299
|
+
/** Check if a key exists in the store. */
|
|
300
|
+
has(pluginName: string, key: string): boolean;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Metadata for a plugin, used for identification and compatibility checks.
|
|
304
|
+
*/
|
|
305
|
+
interface PluginMeta {
|
|
306
|
+
/** Unique identifier for the plugin */
|
|
307
|
+
name: string;
|
|
308
|
+
/** Version of the plugin itself (semver) */
|
|
309
|
+
version?: string;
|
|
310
|
+
/** Minimum required version of Boltdocs (semver range) */
|
|
311
|
+
boltdocsVersion?: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Lifecycle hooks that a plugin can implement to hook into the build and dev processes.
|
|
315
|
+
*/
|
|
316
|
+
interface PluginLifecycleHooks {
|
|
317
|
+
/** Called before the build process starts */
|
|
318
|
+
beforeBuild?: (ctx: PluginContext) => Promise<void> | void;
|
|
319
|
+
/** Called after the build process finishes successfully */
|
|
320
|
+
afterBuild?: (ctx: PluginContext) => Promise<void> | void;
|
|
321
|
+
/** Called before the dev server starts */
|
|
322
|
+
beforeDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
323
|
+
/** Called after the dev server is ready (configureServer) */
|
|
324
|
+
afterDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
325
|
+
/** Called when the final Boltdocs config is resolved */
|
|
326
|
+
configResolved?: (ctx: PluginContext, config: BoltdocsConfig) => void;
|
|
327
|
+
/** Called when the build is closing */
|
|
328
|
+
buildEnd?: (ctx: PluginContext) => Promise<void> | void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The extended, secure Boltdocs plugin interface.
|
|
332
|
+
*/
|
|
333
|
+
interface SecureBoltdocsPlugin {
|
|
334
|
+
/** A unique name for the plugin (e.g., 'boltdocs-plugin-mermaid') */
|
|
335
|
+
name: string;
|
|
336
|
+
/** Whether to run this plugin before or after default ones */
|
|
337
|
+
enforce?: 'pre' | 'post';
|
|
338
|
+
/** Version of the plugin (optional, but recommended for security) */
|
|
339
|
+
version?: string;
|
|
340
|
+
/** Minimum compatible Boltdocs version (optional, semver range) */
|
|
341
|
+
boltdocsVersion?: string;
|
|
342
|
+
/** List of permissions this plugin requires to operate */
|
|
343
|
+
permissions?: PluginPermission[];
|
|
344
|
+
/** Optional remark plugins to add to the MDX pipeline (requires 'mdx:remark' permission) */
|
|
345
|
+
remarkPlugins?: unknown[];
|
|
346
|
+
/** Optional rehype plugins to add to the MDX pipeline (requires 'mdx:rehype' permission) */
|
|
347
|
+
rehypePlugins?: unknown[];
|
|
348
|
+
/** Optional Vite plugins to inject into the build process (requires 'vite:config' permission) */
|
|
349
|
+
vitePlugins?: Plugin[];
|
|
350
|
+
/** Optional custom React components to register in MDX. Map of Name -> Module Path. (requires 'components' permission) */
|
|
351
|
+
components?: Record<string, string>;
|
|
352
|
+
/** Implementation of lifecycle hooks (requires 'hooks:build' or 'hooks:dev' permissions) */
|
|
353
|
+
hooks?: PluginLifecycleHooks;
|
|
354
|
+
}
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/node/plugins/plugin-errors.d.ts
|
|
357
|
+
/**
|
|
358
|
+
* Base class for all plugin-related errors in Boltdocs.
|
|
359
|
+
*/
|
|
360
|
+
declare class PluginError extends Error {
|
|
361
|
+
readonly pluginName: string;
|
|
362
|
+
constructor(pluginName: string, message: string);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Specifically for schema or structure validation failures.
|
|
366
|
+
*/
|
|
367
|
+
declare class PluginValidationError extends PluginError {
|
|
368
|
+
constructor(pluginName: string, message: string);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Specifically for version mismatch or compatibility issues.
|
|
372
|
+
*/
|
|
373
|
+
declare class PluginCompatibilityError extends PluginError {
|
|
374
|
+
constructor(pluginName: string, message: string);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Specifically for attempts to use capabilities without proper permissions.
|
|
378
|
+
*/
|
|
379
|
+
declare class PluginPermissionError extends PluginError {
|
|
380
|
+
constructor(pluginName: string, permission: string);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Specifically for errors that occur during the execution of a lifecycle hook.
|
|
384
|
+
*/
|
|
385
|
+
declare class PluginHookError extends PluginError {
|
|
386
|
+
readonly hookName: string;
|
|
387
|
+
constructor(pluginName: string, hookName: string, originalError: Error);
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/node/plugins/plugin-store.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* Implementation of the shared plugin store.
|
|
393
|
+
* Uses a namespaced approach to prevent key collisions between plugins.
|
|
394
|
+
*/
|
|
395
|
+
declare class BoltdocsPluginStore implements PluginStore {
|
|
396
|
+
private data;
|
|
397
|
+
/**
|
|
398
|
+
* Internal helper to create a namespaced key.
|
|
399
|
+
*/
|
|
400
|
+
private getNamespaceKey;
|
|
401
|
+
/**
|
|
402
|
+
* Retrieves a value from the store. Returns a deep clone to prevent mutations (side-effects).
|
|
403
|
+
*/
|
|
404
|
+
get<T = unknown>(pluginName: string, key: string): T | undefined;
|
|
405
|
+
/**
|
|
406
|
+
* Stores a value in the store. Key is automatically namespaced.
|
|
407
|
+
*/
|
|
408
|
+
set(pluginName: string, key: string, value: unknown): void;
|
|
409
|
+
/**
|
|
410
|
+
* Checks for the existence of a key in the store.
|
|
411
|
+
*/
|
|
412
|
+
has(pluginName: string, key: string): boolean;
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/node/plugins/plugin-validator.d.ts
|
|
416
|
+
/**
|
|
417
|
+
* Enhanced Zod schema for secure plugins.
|
|
418
|
+
*/
|
|
419
|
+
declare const SecurePluginSchema: z.ZodObject<{
|
|
420
|
+
name: z.ZodString;
|
|
421
|
+
enforce: z.ZodOptional<z.ZodEnum<{
|
|
422
|
+
pre: "pre";
|
|
423
|
+
post: "post";
|
|
424
|
+
}>>;
|
|
425
|
+
remarkPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
426
|
+
rehypePlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
427
|
+
vitePlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
428
|
+
components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
429
|
+
version: z.ZodOptional<z.ZodString>;
|
|
430
|
+
boltdocsVersion: z.ZodOptional<z.ZodString>;
|
|
431
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
432
|
+
hooks: z.ZodOptional<z.ZodObject<{
|
|
433
|
+
beforeBuild: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
434
|
+
afterBuild: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
435
|
+
beforeDev: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
436
|
+
afterDev: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
437
|
+
configResolved: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
438
|
+
buildEnd: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
439
|
+
}, z.core.$strip>>;
|
|
440
|
+
}, z.core.$strip>;
|
|
441
|
+
/**
|
|
442
|
+
* Validates a list of plugins for correctness, security, and compatibility.
|
|
443
|
+
*/
|
|
444
|
+
declare function validatePlugins(plugins: any[], boltdocsVersion: string): SecureBoltdocsPlugin[];
|
|
445
|
+
/**
|
|
446
|
+
* Helper to check if a specific permission is granted to a plugin.
|
|
447
|
+
*/
|
|
448
|
+
declare function hasPermission(plugin: SecureBoltdocsPlugin, permission: PluginPermission): boolean;
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/node/plugins/plugin-sandbox.d.ts
|
|
451
|
+
/**
|
|
452
|
+
* The Sandbox provides a protective layer that ensures plugins only use
|
|
453
|
+
* the capabilities they have explicitly requested permissions for.
|
|
454
|
+
*/
|
|
455
|
+
declare class PluginSandbox {
|
|
456
|
+
/**
|
|
457
|
+
* Validates if a plugin has the required permission for a capability.
|
|
458
|
+
* Throws a PluginPermissionError if not granted.
|
|
459
|
+
*/
|
|
460
|
+
static checkPermission(plugin: SecureBoltdocsPlugin, permission: PluginPermission): void;
|
|
461
|
+
/**
|
|
462
|
+
* Filters a plugin's capabilities based on its declared permissions.
|
|
463
|
+
* This is used when aggregating plugins (remark, rehype, vite, components).
|
|
464
|
+
*/
|
|
465
|
+
static getSanitizedCapabilities(plugin: SecureBoltdocsPlugin): {
|
|
466
|
+
remarkPlugins: unknown[] | undefined;
|
|
467
|
+
rehypePlugins: unknown[] | undefined;
|
|
468
|
+
vitePlugins: _$vite.Plugin<any>[] | undefined;
|
|
469
|
+
components: Record<string, string> | undefined;
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Wraps a hook execution with permission checks and error isolation.
|
|
473
|
+
*/
|
|
474
|
+
static executeWithIsolation<T>(plugin: SecureBoltdocsPlugin, requiredPermission: PluginPermission, hookName: string, action: () => Promise<T> | T): Promise<T | undefined>;
|
|
475
|
+
}
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/node/plugins/plugin-lifecycle.d.ts
|
|
478
|
+
/**
|
|
479
|
+
* Manages the lifecycle of all loaded plugins, ensuring hooks are executed
|
|
480
|
+
* in the correct order with proper error isolation and context.
|
|
481
|
+
*/
|
|
482
|
+
declare class PluginLifecycleManager {
|
|
483
|
+
private plugins;
|
|
484
|
+
private config;
|
|
485
|
+
private store;
|
|
486
|
+
constructor(plugins: SecureBoltdocsPlugin[], config: BoltdocsConfig);
|
|
487
|
+
/**
|
|
488
|
+
* Runs a specific hook for all plugins that implement it.
|
|
489
|
+
*/
|
|
490
|
+
runHook(hookName: keyof PluginLifecycleHooks, ...args: any[]): Promise<void>;
|
|
491
|
+
/**
|
|
492
|
+
* Sorts plugins based on their 'enforce' property (pre -> normal -> post).
|
|
493
|
+
*/
|
|
494
|
+
private getSortedPlugins;
|
|
495
|
+
/**
|
|
496
|
+
* Creates a specialized context for a plugin.
|
|
497
|
+
*/
|
|
498
|
+
private createContext;
|
|
499
|
+
/**
|
|
500
|
+
* Creates a namespaced logger for a plugin.
|
|
501
|
+
*/
|
|
502
|
+
private createLogger;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/node/plugins/index.d.ts
|
|
506
|
+
/**
|
|
507
|
+
* Utility to create a Boltdocs plugin with full type safety.
|
|
508
|
+
*/
|
|
509
|
+
declare function createPlugin(plugin: SecureBoltdocsPlugin): SecureBoltdocsPlugin;
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/node/index.d.ts
|
|
512
|
+
declare function boltdocs(options?: BoltdocsPluginOptions): Promise<Plugin[]>;
|
|
513
|
+
/**
|
|
514
|
+
* Generates the complete Vite configuration for a Boltdocs project.
|
|
515
|
+
* This is used by the Boltdocs CLI to run Vite without a user-defined vite.config.ts.
|
|
516
|
+
*/
|
|
517
|
+
declare function createViteConfig(root: string, mode?: 'development' | 'production'): Promise<InlineConfig>;
|
|
518
|
+
//#endregion
|
|
519
|
+
export { type BoltdocsConfig, type BoltdocsPlugin, type BoltdocsPluginOptions, BoltdocsPluginStore, type BoltdocsThemeConfig, PluginCompatibilityError, PluginContext, PluginError, PluginHookError, PluginLifecycleHooks, PluginLifecycleManager, PluginLogger, PluginMeta, PluginPermission, PluginPermissionError, PluginSandbox, PluginStore, PluginValidationError, type RouteMeta, SecureBoltdocsPlugin, SecurePluginSchema, createPlugin, createViteConfig, boltdocs as default, defineConfig, generateEntryCode, hasPermission, resolveConfig, validatePlugins };
|