boltdocs 2.7.10 → 2.8.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/README.md +2 -2
- package/dist/banner-3N4Jd_L9.d.ts +100 -0
- package/dist/banner-MynZD_Ox.d.cts +100 -0
- package/dist/cache-BMUyNiiA.mjs +6 -0
- package/dist/cache-CKm45d2w.cjs +6 -0
- package/dist/client/index.cjs +2268 -1
- package/dist/client/index.d.cts +86 -110
- package/dist/client/index.d.ts +87 -111
- package/dist/client/index.js +2214 -1
- package/dist/client/mdx.cjs +12 -1
- package/dist/client/mdx.d.cts +39 -93
- package/dist/client/mdx.d.ts +38 -93
- package/dist/client/mdx.js +7 -1
- package/dist/client/primitives.cjs +60 -1
- package/dist/client/primitives.d.cts +411 -347
- package/dist/client/primitives.d.ts +411 -347
- package/dist/client/primitives.js +20 -1
- package/dist/docs-layout-CwCq42Zt.cjs +1348 -0
- package/dist/docs-layout-Dn6S5g59.js +1167 -0
- package/dist/doctor-BArviV8X.cjs +28 -0
- package/dist/doctor-CgLA7_Uv.mjs +28 -0
- package/dist/{doctor-CrytFkqW.cjs → doctor-DyNUVe96.cjs} +1 -1
- package/dist/{routes-DP1vmWRj.cjs → doctor-aN_leTbh.mjs} +1 -1
- package/dist/{generator-ClVanhvi.mjs → generator-BHCrLU6h.mjs} +2 -2
- package/dist/{generator-CHqxiQhF.cjs → generator-CC2yHzhZ.cjs} +2 -2
- package/dist/icons-dev-DvJ-hh9x.cjs +1209 -0
- package/dist/icons-dev-Oju24Wjp.js +845 -0
- package/dist/image-Ch4-GxdO.cjs +268 -0
- package/dist/image-Do8V9PCW.js +214 -0
- package/dist/mdx-D3A2_l7P.js +520 -0
- package/dist/mdx-PLhhPJRS.cjs +531 -0
- package/dist/node/cli-entry.cjs +3 -1
- package/dist/node/cli-entry.mjs +3 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +258 -152
- package/dist/node/index.d.mts +258 -150
- package/dist/node/index.mjs +1 -1
- package/dist/node/routes/worker.cjs +1 -1
- package/dist/node/routes/worker.mjs +1 -1
- package/dist/node-BmlP0eBP.cjs +159 -0
- package/dist/node-Y8_4ayje.mjs +159 -0
- package/dist/package-2nFy_NsW.cjs +6 -0
- package/dist/{package--0Yf0t1N.mjs → package-DAbtltXX.mjs} +1 -1
- package/dist/parser-B7-6PyQz.cjs +6 -0
- package/dist/{parser-Aq8LoH-0.cjs → parser-BzB-zCkF.cjs} +1 -1
- package/dist/parser-WGZdWs0X.mjs +6 -0
- package/dist/routes-BDDSxAl0.mjs +6 -0
- package/dist/routes-DJNJ-rTt.cjs +6 -0
- package/dist/routes-DiYC4nD2.cjs +6 -0
- package/dist/routes-_Bb2f4eI.mjs +6 -0
- package/dist/search-dialog-BXVoecTx.cjs +483 -0
- package/dist/search-dialog-BYhOov4S.cjs +331 -0
- package/dist/search-dialog-C09riYmx.js +313 -0
- package/dist/search-dialog-CUeAfy-8.cjs +8 -0
- package/dist/search-dialog-D8gLkhUV.js +453 -0
- package/dist/search-dialog-DHc_8FFX.js +8 -0
- package/dist/{sidebar-CcBkrm06.d.cts → sidebar-DNq4_ZAa.d.ts} +118 -52
- package/dist/{sidebar-CyZS9YOm.d.ts → sidebar-Dlkgbxs6.d.cts} +118 -52
- package/dist/utils-BYITg7T5.mjs +7 -0
- package/dist/utils-Cjmx1hhk.cjs +7 -0
- package/dist/worker-pool-CtqklOXq.cjs +6 -0
- package/dist/worker-pool-k0DY6k8T.mjs +6 -0
- package/package.json +5 -6
- package/src/shared/config-utils.ts +4 -0
- package/src/shared/types.ts +52 -6
- package/dist/cache-Ba-DZQNH.cjs +0 -6
- package/dist/cache-BuMZ58L5.mjs +0 -6
- package/dist/cards-BakZPTz9.d.ts +0 -30
- package/dist/cards-CQn9mXZS.d.cts +0 -30
- package/dist/docs-layout-KoWNZc8_.js +0 -6
- package/dist/docs-layout-x2yKt2cL.cjs +0 -6
- package/dist/doctor-Be7Ly1oM.mjs +0 -21
- package/dist/doctor-jMxWZyLJ.cjs +0 -21
- package/dist/icons-dev-B_RZIyxu.js +0 -6
- package/dist/icons-dev-BlV3wWFT.cjs +0 -6
- package/dist/image-BHhTvQzr.cjs +0 -6
- package/dist/image-CqKzYD8f.js +0 -6
- package/dist/mdx-DudBEac0.js +0 -7
- package/dist/mdx-r4cDQxWu.cjs +0 -7
- package/dist/node-DtEDyN1u.cjs +0 -111
- package/dist/node-_1jhMGYx.mjs +0 -111
- package/dist/package-DrwtlXfk.cjs +0 -6
- package/dist/parser-CdNbqN5y.cjs +0 -6
- package/dist/parser-nE792MLO.mjs +0 -6
- package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
- package/dist/routes-2k3tbUmC.cjs +0 -6
- package/dist/routes-CpxZIsMM.mjs +0 -6
- package/dist/search-dialog-B584t9ZF.js +0 -6
- package/dist/search-dialog-BvBopRsZ.cjs +0 -6
- package/dist/search-dialog-ByvGScjt.js +0 -6
- package/dist/search-dialog-Cyko6TJm.cjs +0 -6
- package/dist/search-dialog-D6BNohIJ.js +0 -6
- package/dist/search-dialog-DuYTIefy.cjs +0 -6
- package/dist/utils-CG65J0Sc.mjs +0 -7
- package/dist/utils-CKunkU96.cjs +0 -7
- package/dist/worker-pool-CGn7DrLb.mjs +0 -6
- package/dist/worker-pool-Crbqgw5R.cjs +0 -6
- package/src/client/app/config-context.tsx +0 -51
- package/src/client/app/doc-page.tsx +0 -38
- package/src/client/app/docs-layout.tsx +0 -28
- package/src/client/app/head.tsx +0 -122
- package/src/client/app/helmet-compat.tsx +0 -36
- package/src/client/app/mdx-component.tsx +0 -8
- package/src/client/app/mdx-components-context.tsx +0 -72
- package/src/client/app/routes-context.tsx +0 -34
- package/src/client/app/scroll-handler.tsx +0 -74
- package/src/client/app/theme-context.tsx +0 -103
- package/src/client/app/ui-context.tsx +0 -42
- package/src/client/components/docs-layout-default.tsx +0 -85
- package/src/client/components/icons-dev.tsx +0 -282
- package/src/client/components/mdx/callout.tsx +0 -97
- package/src/client/components/mdx/card.tsx +0 -99
- package/src/client/components/mdx/cards.tsx +0 -27
- package/src/client/components/mdx/code-block.tsx +0 -184
- package/src/client/components/mdx/field.tsx +0 -33
- package/src/client/components/mdx/image.tsx +0 -44
- package/src/client/components/mdx/index.ts +0 -19
- package/src/client/components/mdx/table.tsx +0 -54
- package/src/client/components/mdx/typographics.tsx +0 -120
- package/src/client/components/mdx/use-code-block.ts +0 -34
- package/src/client/components/primitives/breadcrumbs.tsx +0 -54
- package/src/client/components/primitives/button-group.tsx +0 -54
- package/src/client/components/primitives/button.tsx +0 -6
- package/src/client/components/primitives/code-block.tsx +0 -120
- package/src/client/components/primitives/docs-layout.tsx +0 -125
- package/src/client/components/primitives/error-boundary.tsx +0 -107
- package/src/client/components/primitives/heading.tsx +0 -128
- package/src/client/components/primitives/helpers/observer.ts +0 -141
- package/src/client/components/primitives/image.tsx +0 -26
- package/src/client/components/primitives/link.tsx +0 -102
- package/src/client/components/primitives/menu.tsx +0 -137
- package/src/client/components/primitives/navbar.tsx +0 -466
- package/src/client/components/primitives/on-this-page.tsx +0 -430
- package/src/client/components/primitives/page-nav.tsx +0 -51
- package/src/client/components/primitives/popover.tsx +0 -28
- package/src/client/components/primitives/search-dialog.tsx +0 -193
- package/src/client/components/primitives/sidebar.tsx +0 -423
- package/src/client/components/primitives/skeleton.tsx +0 -26
- package/src/client/components/primitives/tabs.tsx +0 -70
- package/src/client/components/primitives/tooltip.tsx +0 -81
- package/src/client/components/primitives/types.ts +0 -11
- package/src/client/components/ui-base/banner.tsx +0 -66
- package/src/client/components/ui-base/breadcrumbs.tsx +0 -44
- package/src/client/components/ui-base/copy-markdown.tsx +0 -107
- package/src/client/components/ui-base/error-boundary.tsx +0 -15
- package/src/client/components/ui-base/github-stars.tsx +0 -29
- package/src/client/components/ui-base/icons.tsx +0 -240
- package/src/client/components/ui-base/index.ts +0 -16
- package/src/client/components/ui-base/last-updated.tsx +0 -27
- package/src/client/components/ui-base/navbar.tsx +0 -266
- package/src/client/components/ui-base/not-found.tsx +0 -26
- package/src/client/components/ui-base/on-this-page.tsx +0 -57
- package/src/client/components/ui-base/page-nav.tsx +0 -50
- package/src/client/components/ui-base/search-dialog.tsx +0 -163
- package/src/client/components/ui-base/search-highlight.tsx +0 -10
- package/src/client/components/ui-base/sidebar.tsx +0 -92
- package/src/client/components/ui-base/tabs.tsx +0 -83
- package/src/client/components/ui-base/theme-toggle.tsx +0 -130
- package/src/client/components/ui-base/version-i18n.tsx +0 -80
- package/src/client/hooks/index.ts +0 -13
- package/src/client/hooks/use-analytics.ts +0 -272
- package/src/client/hooks/use-breadcrumbs.ts +0 -22
- package/src/client/hooks/use-i18n.ts +0 -182
- package/src/client/hooks/use-localized-to.ts +0 -113
- package/src/client/hooks/use-location.ts +0 -5
- package/src/client/hooks/use-navbar.ts +0 -130
- package/src/client/hooks/use-page-nav.ts +0 -46
- package/src/client/hooks/use-routes.ts +0 -108
- package/src/client/hooks/use-search-highlight.ts +0 -185
- package/src/client/hooks/use-search.ts +0 -118
- package/src/client/hooks/use-sidebar.ts +0 -205
- package/src/client/hooks/use-tabs.ts +0 -46
- package/src/client/hooks/use-version.ts +0 -111
- package/src/client/index.ts +0 -31
- package/src/client/mdx.ts +0 -2
- package/src/client/primitives.ts +0 -19
- package/src/client/ssg/boltdocs-shell.tsx +0 -148
- package/src/client/ssg/create-routes.tsx +0 -473
- package/src/client/ssg/index.ts +0 -4
- package/src/client/ssg/mdx-page.tsx +0 -38
- package/src/client/store/boltdocs-context.tsx +0 -137
- package/src/client/theme/neutral.css +0 -141
- package/src/client/theme/reset.css +0 -189
- package/src/client/types.ts +0 -116
- package/src/client/utils/cn.ts +0 -6
- package/src/client/utils/copy-clipboard.ts +0 -22
- package/src/client/utils/get-base-file-path.ts +0 -21
- package/src/client/utils/github.ts +0 -121
- package/src/client/utils/i18n.ts +0 -23
- package/src/client/utils/path.ts +0 -9
- package/src/client/utils/react-to-text.ts +0 -34
- package/src/client/virtual.d.ts +0 -24
- /package/dist/{meta-loader-CWg2gnbY.mjs → meta-loader-DzwDFtdT.mjs} +0 -0
package/dist/node/index.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import * as _$vite from "vite";
|
|
3
2
|
import { InlineConfig, Plugin } from "vite";
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { EXIT, SKIP } from "unist-util-visit";
|
|
6
4
|
//#region src/shared/types.d.ts
|
|
7
5
|
/**
|
|
8
6
|
* Represents a single social link in the configuration.
|
|
@@ -32,15 +30,15 @@ interface BoltdocsThemeConfig {
|
|
|
32
30
|
};
|
|
33
31
|
navbar?: Array<{
|
|
34
32
|
label: string | Record<string, string>;
|
|
35
|
-
href:
|
|
33
|
+
href: BoltdocsRoutePathWithFallback;
|
|
36
34
|
items?: Array<{
|
|
37
35
|
label: string | Record<string, string>;
|
|
38
|
-
href:
|
|
36
|
+
href: BoltdocsRoutePathWithFallback;
|
|
39
37
|
}>;
|
|
40
38
|
}>;
|
|
41
39
|
sidebar?: Record<string, Array<{
|
|
42
40
|
text: string;
|
|
43
|
-
link:
|
|
41
|
+
link: BoltdocsRoutePathWithFallback;
|
|
44
42
|
}>>;
|
|
45
43
|
sidebarGroups?: Record<string, {
|
|
46
44
|
title?: string | Record<string, string>;
|
|
@@ -110,24 +108,44 @@ interface BoltdocsVersionsConfig {
|
|
|
110
108
|
prefix?: string;
|
|
111
109
|
versions: BoltdocsVersionConfig[];
|
|
112
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Shared badge value type used in frontmatter, RouteMeta, and ComponentRoute.
|
|
113
|
+
*/
|
|
114
|
+
type BadgeValue = string | {
|
|
115
|
+
text: string;
|
|
116
|
+
expires?: string;
|
|
117
|
+
};
|
|
113
118
|
/**
|
|
114
119
|
* Defines a Boltdocs plugin.
|
|
120
|
+
*
|
|
121
|
+
* Use the `createPlugin()` helper from the node API for full type safety and
|
|
122
|
+
* access to lifecycle hooks.
|
|
115
123
|
*/
|
|
116
124
|
interface BoltdocsPlugin {
|
|
117
125
|
name: string;
|
|
118
126
|
enforce?: 'pre' | 'post';
|
|
119
127
|
version?: string;
|
|
120
128
|
boltdocsVersion?: string;
|
|
121
|
-
permissions?: string[];
|
|
122
129
|
remarkPlugins?: unknown[];
|
|
123
130
|
rehypePlugins?: unknown[];
|
|
124
131
|
vitePlugins?: Plugin[];
|
|
125
132
|
components?: Record<string, string>;
|
|
126
|
-
hooks
|
|
133
|
+
/** Lifecycle hooks — use the `PluginLifecycleHooks` type from the node API. */
|
|
134
|
+
hooks?: Record<string, (ctx: unknown) => Promise<void> | void>;
|
|
127
135
|
}
|
|
128
136
|
/**
|
|
129
|
-
* Configuration for
|
|
130
|
-
*/
|
|
137
|
+
* Configuration for the collections (blog) feature.
|
|
138
|
+
*/
|
|
139
|
+
interface BoltdocsCollectionsConfig {
|
|
140
|
+
/** Number of posts per page in collection listing pages. Defaults to 10. */
|
|
141
|
+
postsPerPage?: number;
|
|
142
|
+
/** The name of the default collection used by BlogList when none is specified. */
|
|
143
|
+
defaultCollection?: string;
|
|
144
|
+
/** Date format string for rendering post dates (e.g., 'MMMM dd, yyyy'). */
|
|
145
|
+
dateFormat?: string;
|
|
146
|
+
/** Field to sort posts by. Defaults to 'date'. */
|
|
147
|
+
sortBy?: 'date' | 'title' | 'sidebarPosition';
|
|
148
|
+
}
|
|
131
149
|
interface BoltdocsSecurityConfig {
|
|
132
150
|
headers?: Record<string, string>;
|
|
133
151
|
enableCSP?: boolean;
|
|
@@ -167,9 +185,18 @@ interface BoltdocsGTMConfig {
|
|
|
167
185
|
dataLayerName?: string;
|
|
168
186
|
preview?: string;
|
|
169
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Configuration for Algolia DocSearch.
|
|
190
|
+
*/
|
|
191
|
+
interface BoltdocsAlgoliaConfig {
|
|
192
|
+
appId: string;
|
|
193
|
+
apiKey: string;
|
|
194
|
+
indexName: string;
|
|
195
|
+
}
|
|
170
196
|
interface BoltdocsIntegrationsConfig {
|
|
171
197
|
ga4?: BoltdocsGA4Config;
|
|
172
198
|
gtm?: BoltdocsGTMConfig;
|
|
199
|
+
algolia?: BoltdocsAlgoliaConfig;
|
|
173
200
|
}
|
|
174
201
|
/**
|
|
175
202
|
* The root configuration object for Boltdocs.
|
|
@@ -182,6 +209,7 @@ interface BoltdocsConfig {
|
|
|
182
209
|
i18n?: BoltdocsI18nConfig;
|
|
183
210
|
versions?: BoltdocsVersionsConfig;
|
|
184
211
|
plugins?: BoltdocsPlugin[];
|
|
212
|
+
collections?: BoltdocsCollectionsConfig;
|
|
185
213
|
robots?: BoltdocsRobotsConfig;
|
|
186
214
|
security?: BoltdocsSecurityConfig;
|
|
187
215
|
seo?: BoltdocsSeoConfig;
|
|
@@ -197,8 +225,16 @@ interface BoltdocsConfig {
|
|
|
197
225
|
declare global {
|
|
198
226
|
namespace Boltdocs {
|
|
199
227
|
interface Types {}
|
|
228
|
+
/**
|
|
229
|
+
* Marker interface augmented by generated code to provide strict route path typing.
|
|
230
|
+
* When no types have been generated (e.g., before first dev server start),
|
|
231
|
+
* keyof is never, and BoltdocsRoutePath falls back to string.
|
|
232
|
+
*/
|
|
233
|
+
interface RoutePaths {}
|
|
200
234
|
}
|
|
201
235
|
}
|
|
236
|
+
type BoltdocsRoutePath = keyof Boltdocs.RoutePaths;
|
|
237
|
+
type BoltdocsRoutePathWithFallback = BoltdocsRoutePath extends never ? string : BoltdocsRoutePath;
|
|
202
238
|
//#endregion
|
|
203
239
|
//#region src/shared/config-utils.d.ts
|
|
204
240
|
/**
|
|
@@ -206,6 +242,10 @@ declare global {
|
|
|
206
242
|
* This is an identity function that provides IntelliSense in both
|
|
207
243
|
* Node.js (config files) and client-side code (MDX examples).
|
|
208
244
|
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* Intended for use in `boltdocs.config.ts` (Node.js context). This function
|
|
247
|
+
* is **not** available as a client-side import from `boltdocs/client`.
|
|
248
|
+
*
|
|
209
249
|
* @param config - The Boltdocs configuration object
|
|
210
250
|
*/
|
|
211
251
|
declare function defineConfig(config: BoltdocsConfig): BoltdocsConfig;
|
|
@@ -239,7 +279,7 @@ interface BoltdocsPluginOptions {
|
|
|
239
279
|
* @param config - The resolved Boltdocs configuration containing custom plugins and components
|
|
240
280
|
* @returns A string of JavaScript code to be evaluated by the browser
|
|
241
281
|
*/
|
|
242
|
-
declare function generateEntryCode(options: BoltdocsPluginOptions, config?: BoltdocsConfig
|
|
282
|
+
declare function generateEntryCode(options: BoltdocsPluginOptions, config?: BoltdocsConfig): string;
|
|
243
283
|
//#endregion
|
|
244
284
|
//#region src/node/routes/types.d.ts
|
|
245
285
|
/**
|
|
@@ -280,14 +320,23 @@ interface RouteMeta {
|
|
|
280
320
|
/** The version this route belongs to, if versioning is configured */
|
|
281
321
|
version?: string;
|
|
282
322
|
/** Optional badge to display next to the sidebar item (e.g., 'New', 'Experimental') */
|
|
283
|
-
badge?:
|
|
284
|
-
text: string;
|
|
285
|
-
expires?: string;
|
|
286
|
-
};
|
|
323
|
+
badge?: BadgeValue;
|
|
287
324
|
/** Optional icon to display (Lucide icon name or raw SVG) */
|
|
288
325
|
icon?: string;
|
|
289
326
|
/** The tab this route belongs to, if tabs are configured */
|
|
290
327
|
tab?: string;
|
|
328
|
+
/** The collection this route belongs to (from [name] directories like [blog]) */
|
|
329
|
+
collection?: string;
|
|
330
|
+
/** Tags for blog posts or other taxonomy */
|
|
331
|
+
tags?: string[];
|
|
332
|
+
/** Author identifier for blog posts */
|
|
333
|
+
author?: string;
|
|
334
|
+
/** Draft flag — excluded from production builds */
|
|
335
|
+
draft?: boolean;
|
|
336
|
+
/** Short excerpt/summary for list displays */
|
|
337
|
+
excerpt?: string;
|
|
338
|
+
/** Cover image for blog posts */
|
|
339
|
+
coverImage?: string;
|
|
291
340
|
/** The extracted plain-text content of the page for search indexing */
|
|
292
341
|
_content?: string;
|
|
293
342
|
/** The raw markdown content of the page */
|
|
@@ -333,126 +382,77 @@ declare function normalizePath(p: string): string;
|
|
|
333
382
|
declare function sanitizeFilename(name: string): string;
|
|
334
383
|
//#endregion
|
|
335
384
|
//#region src/node/plugins/plugin-types.d.ts
|
|
336
|
-
/**
|
|
337
|
-
* Permissions that a plugin can request to access specific Boltdocs capabilities.
|
|
338
|
-
*/
|
|
339
|
-
type PluginPermission = 'fs:read' | 'fs:write' | 'vite:config' | 'mdx:remark' | 'mdx:rehype' | 'components' | 'hooks:build' | 'hooks:dev' | 'analytics:track' | 'analytics:config';
|
|
340
|
-
/**
|
|
341
|
-
* Shared context injected into every plugin lifecycle hook.
|
|
342
|
-
*/
|
|
343
385
|
interface PluginContext {
|
|
344
|
-
/** The full, resolved Boltdocs configuration (Readonly) */
|
|
345
386
|
readonly config: BoltdocsConfig;
|
|
346
|
-
/** A plugin-specific logger */
|
|
347
387
|
readonly logger: PluginLogger;
|
|
348
|
-
/** A shared store for dependency injection and state sharing between plugins */
|
|
349
388
|
readonly store: PluginStore;
|
|
350
|
-
/** Metadata about the current plugin */
|
|
351
389
|
readonly meta: PluginMeta;
|
|
390
|
+
readonly docsDir: string;
|
|
391
|
+
readonly rootDir: string;
|
|
352
392
|
}
|
|
353
|
-
/**
|
|
354
|
-
* Simple logger interface for plugins.
|
|
355
|
-
*/
|
|
356
393
|
interface PluginLogger {
|
|
357
394
|
info(message: string): void;
|
|
358
395
|
warn(message: string): void;
|
|
359
396
|
error(message: string | Error): void;
|
|
360
397
|
debug(message: string): void;
|
|
361
398
|
}
|
|
362
|
-
/**
|
|
363
|
-
* A shared key-value store that allows plugins to share state and configuration.
|
|
364
|
-
*/
|
|
365
399
|
interface PluginStore {
|
|
366
|
-
/** Get a value from the store. Keys are namespaced by plugin internally. */
|
|
367
400
|
get<T = unknown>(pluginName: string, key: string): T | undefined;
|
|
368
|
-
/** Set a value in the store. */
|
|
369
401
|
set(pluginName: string, key: string, value: unknown): void;
|
|
370
|
-
/** Check if a key exists in the store. */
|
|
371
402
|
has(pluginName: string, key: string): boolean;
|
|
372
403
|
}
|
|
373
|
-
/**
|
|
374
|
-
* Metadata for a plugin, used for identification and compatibility checks.
|
|
375
|
-
*/
|
|
376
404
|
interface PluginMeta {
|
|
377
|
-
/** Unique identifier for the plugin */
|
|
378
405
|
name: string;
|
|
379
|
-
/** Version of the plugin itself (semver) */
|
|
380
406
|
version?: string;
|
|
381
|
-
/** Minimum required version of Boltdocs (semver range) */
|
|
382
407
|
boltdocsVersion?: string;
|
|
383
408
|
}
|
|
384
|
-
/**
|
|
385
|
-
* Lifecycle hooks that a plugin can implement to hook into the build and dev processes.
|
|
386
|
-
*/
|
|
387
409
|
interface PluginLifecycleHooks {
|
|
388
|
-
/** Called before the build process starts */
|
|
389
410
|
beforeBuild?: (ctx: PluginContext) => Promise<void> | void;
|
|
390
|
-
/** Called after the build process finishes successfully */
|
|
391
411
|
afterBuild?: (ctx: PluginContext) => Promise<void> | void;
|
|
392
|
-
/** Called before the dev server starts */
|
|
393
412
|
beforeDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
394
|
-
/** Called after the dev server is ready (configureServer) */
|
|
395
413
|
afterDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
396
|
-
/** Called when the final Boltdocs config is resolved */
|
|
397
|
-
configResolved?: (ctx: PluginContext, config: BoltdocsConfig) => void;
|
|
398
|
-
/** Called when the build is closing */
|
|
399
414
|
buildEnd?: (ctx: PluginContext) => Promise<void> | void;
|
|
415
|
+
transformMdx?: (ctx: PluginContext, params: {
|
|
416
|
+
code: string;
|
|
417
|
+
filePath: string;
|
|
418
|
+
}) => Promise<{
|
|
419
|
+
code: string;
|
|
420
|
+
}> | {
|
|
421
|
+
code: string;
|
|
422
|
+
};
|
|
423
|
+
transformHtml?: (ctx: PluginContext, params: {
|
|
424
|
+
html: string;
|
|
425
|
+
path: string;
|
|
426
|
+
}) => Promise<{
|
|
427
|
+
html: string;
|
|
428
|
+
}> | {
|
|
429
|
+
html: string;
|
|
430
|
+
};
|
|
400
431
|
}
|
|
401
|
-
/**
|
|
402
|
-
* The extended, secure Boltdocs plugin interface.
|
|
403
|
-
*/
|
|
404
432
|
interface SecureBoltdocsPlugin {
|
|
405
|
-
/** A unique name for the plugin (e.g., 'boltdocs-plugin-mermaid') */
|
|
406
433
|
name: string;
|
|
407
|
-
/** Whether to run this plugin before or after default ones */
|
|
408
434
|
enforce?: 'pre' | 'post';
|
|
409
|
-
/** Version of the plugin (optional, but recommended for security) */
|
|
410
435
|
version?: string;
|
|
411
|
-
/** Minimum compatible Boltdocs version (optional, semver range) */
|
|
412
436
|
boltdocsVersion?: string;
|
|
413
|
-
/** List of permissions this plugin requires to operate */
|
|
414
|
-
permissions?: PluginPermission[];
|
|
415
|
-
/** Optional remark plugins to add to the MDX pipeline (requires 'mdx:remark' permission) */
|
|
416
437
|
remarkPlugins?: unknown[];
|
|
417
|
-
/** Optional rehype plugins to add to the MDX pipeline (requires 'mdx:rehype' permission) */
|
|
418
438
|
rehypePlugins?: unknown[];
|
|
419
|
-
/** Optional Vite plugins to inject into the build process (requires 'vite:config' permission) */
|
|
420
439
|
vitePlugins?: Plugin[];
|
|
421
|
-
/** Optional custom React components to register in MDX. Map of Name -> Module Path. (requires 'components' permission) */
|
|
422
440
|
components?: Record<string, string>;
|
|
423
|
-
/** Implementation of lifecycle hooks (requires 'hooks:build' or 'hooks:dev' permissions) */
|
|
424
441
|
hooks?: PluginLifecycleHooks;
|
|
425
442
|
}
|
|
426
443
|
//#endregion
|
|
427
444
|
//#region src/node/plugins/plugin-errors.d.ts
|
|
428
|
-
/**
|
|
429
|
-
* Base class for all plugin-related errors in Boltdocs.
|
|
430
|
-
*/
|
|
431
445
|
declare class PluginError extends Error {
|
|
432
446
|
readonly pluginName: string;
|
|
433
|
-
|
|
447
|
+
name: string;
|
|
448
|
+
constructor(pluginName: string, message: string, options?: ErrorOptions);
|
|
434
449
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Specifically for schema or structure validation failures.
|
|
437
|
-
*/
|
|
438
450
|
declare class PluginValidationError extends PluginError {
|
|
439
451
|
constructor(pluginName: string, message: string);
|
|
440
452
|
}
|
|
441
|
-
/**
|
|
442
|
-
* Specifically for version mismatch or compatibility issues.
|
|
443
|
-
*/
|
|
444
453
|
declare class PluginCompatibilityError extends PluginError {
|
|
445
454
|
constructor(pluginName: string, message: string);
|
|
446
455
|
}
|
|
447
|
-
/**
|
|
448
|
-
* Specifically for attempts to use capabilities without proper permissions.
|
|
449
|
-
*/
|
|
450
|
-
declare class PluginPermissionError extends PluginError {
|
|
451
|
-
constructor(pluginName: string, permission: string);
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Specifically for errors that occur during the execution of a lifecycle hook.
|
|
455
|
-
*/
|
|
456
456
|
declare class PluginHookError extends PluginError {
|
|
457
457
|
readonly hookName: string;
|
|
458
458
|
constructor(pluginName: string, hookName: string, originalError: Error);
|
|
@@ -484,99 +484,205 @@ declare class BoltdocsPluginStore implements PluginStore {
|
|
|
484
484
|
}
|
|
485
485
|
//#endregion
|
|
486
486
|
//#region src/node/plugins/plugin-validator.d.ts
|
|
487
|
-
/**
|
|
488
|
-
* Enhanced Zod schema for secure plugins.
|
|
489
|
-
*/
|
|
490
|
-
declare const SecurePluginSchema: z.ZodObject<{
|
|
491
|
-
name: z.ZodString;
|
|
492
|
-
enforce: z.ZodOptional<z.ZodEnum<{
|
|
493
|
-
pre: "pre";
|
|
494
|
-
post: "post";
|
|
495
|
-
}>>;
|
|
496
|
-
remarkPlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
497
|
-
rehypePlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
498
|
-
vitePlugins: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
499
|
-
components: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
500
|
-
version: z.ZodOptional<z.ZodString>;
|
|
501
|
-
boltdocsVersion: z.ZodOptional<z.ZodString>;
|
|
502
|
-
permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
503
|
-
hooks: z.ZodOptional<z.ZodObject<{
|
|
504
|
-
beforeBuild: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
505
|
-
afterBuild: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
506
|
-
beforeDev: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
507
|
-
afterDev: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
508
|
-
configResolved: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
509
|
-
buildEnd: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
510
|
-
}, z.core.$strip>>;
|
|
511
|
-
}, z.core.$strip>;
|
|
512
|
-
/**
|
|
513
|
-
* Validates a list of plugins for correctness, security, and compatibility.
|
|
514
|
-
*/
|
|
515
487
|
declare function validatePlugins(plugins: any[], boltdocsVersion: string): SecureBoltdocsPlugin[];
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/node/plugins/plugin-lifecycle.d.ts
|
|
490
|
+
declare class PluginLifecycleManager {
|
|
491
|
+
private plugins;
|
|
492
|
+
private config;
|
|
493
|
+
private store;
|
|
494
|
+
private docsDir;
|
|
495
|
+
private rootDir;
|
|
496
|
+
constructor(plugins: SecureBoltdocsPlugin[], config: BoltdocsConfig, docsDir?: string, rootDir?: string);
|
|
497
|
+
runHook(hookName: keyof PluginLifecycleHooks, ...args: unknown[]): Promise<void>;
|
|
498
|
+
runChain<TParams>(hookName: keyof PluginLifecycleHooks, initialParams: TParams): Promise<TParams>;
|
|
499
|
+
private getSortedPlugins;
|
|
500
|
+
private createStep;
|
|
501
|
+
private createContext;
|
|
502
|
+
private createLogger;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region ../../node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts
|
|
506
|
+
// ## Interfaces
|
|
516
507
|
/**
|
|
517
|
-
*
|
|
508
|
+
* Info associated with nodes by the ecosystem.
|
|
509
|
+
*
|
|
510
|
+
* This space is guaranteed to never be specified by unist or specifications
|
|
511
|
+
* implementing unist.
|
|
512
|
+
* But you can use it in utilities and plugins to store data.
|
|
513
|
+
*
|
|
514
|
+
* This type can be augmented to register custom data.
|
|
515
|
+
* For example:
|
|
516
|
+
*
|
|
517
|
+
* ```ts
|
|
518
|
+
* declare module 'unist' {
|
|
519
|
+
* interface Data {
|
|
520
|
+
* // `someNode.data.myId` is typed as `number | undefined`
|
|
521
|
+
* myId?: number | undefined
|
|
522
|
+
* }
|
|
523
|
+
* }
|
|
524
|
+
* ```
|
|
518
525
|
*/
|
|
519
|
-
|
|
520
|
-
//#endregion
|
|
521
|
-
//#region src/node/plugins/plugin-sandbox.d.ts
|
|
526
|
+
interface Data {}
|
|
522
527
|
/**
|
|
523
|
-
*
|
|
524
|
-
* the capabilities they have explicitly requested permissions for.
|
|
528
|
+
* One place in a source file.
|
|
525
529
|
*/
|
|
526
|
-
|
|
530
|
+
interface Point {
|
|
527
531
|
/**
|
|
528
|
-
*
|
|
529
|
-
* Throws a PluginPermissionError if not granted.
|
|
532
|
+
* Line in a source file (1-indexed integer).
|
|
530
533
|
*/
|
|
531
|
-
|
|
534
|
+
line: number;
|
|
532
535
|
/**
|
|
533
|
-
*
|
|
534
|
-
* This is used when aggregating plugins (remark, rehype, vite, components).
|
|
536
|
+
* Column in a source file (1-indexed integer).
|
|
535
537
|
*/
|
|
536
|
-
|
|
537
|
-
remarkPlugins: unknown[] | undefined;
|
|
538
|
-
rehypePlugins: unknown[] | undefined;
|
|
539
|
-
vitePlugins: _$vite.Plugin<any>[] | undefined;
|
|
540
|
-
components: Record<string, string> | undefined;
|
|
541
|
-
};
|
|
538
|
+
column: number;
|
|
542
539
|
/**
|
|
543
|
-
*
|
|
540
|
+
* Character in a source file (0-indexed integer).
|
|
544
541
|
*/
|
|
545
|
-
|
|
542
|
+
offset?: number | undefined;
|
|
546
543
|
}
|
|
547
|
-
//#endregion
|
|
548
|
-
//#region src/node/plugins/plugin-lifecycle.d.ts
|
|
549
544
|
/**
|
|
550
|
-
*
|
|
551
|
-
*
|
|
545
|
+
* Position of a node in a source document.
|
|
546
|
+
*
|
|
547
|
+
* A position is a range between two points.
|
|
552
548
|
*/
|
|
553
|
-
|
|
554
|
-
private plugins;
|
|
555
|
-
private config;
|
|
556
|
-
private store;
|
|
557
|
-
constructor(plugins: SecureBoltdocsPlugin[], config: BoltdocsConfig);
|
|
549
|
+
interface Position {
|
|
558
550
|
/**
|
|
559
|
-
*
|
|
551
|
+
* Place of the first character of the parsed source region.
|
|
560
552
|
*/
|
|
561
|
-
|
|
553
|
+
start: Point;
|
|
562
554
|
/**
|
|
563
|
-
*
|
|
555
|
+
* Place of the first character after the parsed source region.
|
|
564
556
|
*/
|
|
565
|
-
|
|
557
|
+
end: Point;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Abstract unist node.
|
|
561
|
+
*
|
|
562
|
+
* The syntactic unit in unist syntax trees are called nodes.
|
|
563
|
+
*
|
|
564
|
+
* This interface is supposed to be extended.
|
|
565
|
+
* If you can use {@link Literal} or {@link Parent}, you should.
|
|
566
|
+
* But for example in markdown, a `thematicBreak` (`***`), is neither literal
|
|
567
|
+
* nor parent, but still a node.
|
|
568
|
+
*/
|
|
569
|
+
interface Node {
|
|
566
570
|
/**
|
|
567
|
-
*
|
|
571
|
+
* Node type.
|
|
568
572
|
*/
|
|
569
|
-
|
|
573
|
+
type: string;
|
|
570
574
|
/**
|
|
571
|
-
*
|
|
575
|
+
* Info from the ecosystem.
|
|
572
576
|
*/
|
|
573
|
-
|
|
577
|
+
data?: Data | undefined;
|
|
578
|
+
/**
|
|
579
|
+
* Position of a node in a source document.
|
|
580
|
+
*
|
|
581
|
+
* Nodes that are generated (not in the original source document) must not
|
|
582
|
+
* have a position.
|
|
583
|
+
*/
|
|
584
|
+
position?: Position | undefined;
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Abstract unist node that contains other nodes (*children*).
|
|
588
|
+
*
|
|
589
|
+
* This interface is supposed to be extended.
|
|
590
|
+
*
|
|
591
|
+
* For example, in XML, an element is a parent of different things, such as
|
|
592
|
+
* comments, text, and further elements.
|
|
593
|
+
*/
|
|
594
|
+
interface Parent extends Node {
|
|
595
|
+
/**
|
|
596
|
+
* List of children.
|
|
597
|
+
*/
|
|
598
|
+
children: Node[];
|
|
574
599
|
}
|
|
575
600
|
//#endregion
|
|
576
|
-
//#region src/node/
|
|
601
|
+
//#region src/node/mdx/types.d.ts
|
|
602
|
+
interface MdxJsxAttributeValueExpression {
|
|
603
|
+
type: 'mdxJsxAttributeValueExpression';
|
|
604
|
+
value: string;
|
|
605
|
+
data?: {
|
|
606
|
+
estree?: any;
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
interface MdxJsxAttribute {
|
|
610
|
+
type: 'mdxJsxAttribute';
|
|
611
|
+
name: string;
|
|
612
|
+
value?: string | MdxJsxAttributeValueExpression;
|
|
613
|
+
}
|
|
614
|
+
interface MdxJsxElement {
|
|
615
|
+
type: 'mdxJsxFlowElement' | 'mdxJsxTextElement';
|
|
616
|
+
name: string | null;
|
|
617
|
+
attributes?: MdxJsxAttribute[];
|
|
618
|
+
children?: any[];
|
|
619
|
+
}
|
|
620
|
+
interface ElementNode {
|
|
621
|
+
type: 'element';
|
|
622
|
+
tagName: string;
|
|
623
|
+
properties?: Record<string, any>;
|
|
624
|
+
children?: any[];
|
|
625
|
+
}
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/node/mdx/shiki-adapter.d.ts
|
|
628
|
+
interface ParsedMeta {
|
|
629
|
+
title?: string;
|
|
630
|
+
lineNumbers?: boolean;
|
|
631
|
+
wordWrap?: boolean;
|
|
632
|
+
[key: string]: any;
|
|
633
|
+
}
|
|
577
634
|
/**
|
|
578
|
-
*
|
|
635
|
+
* Parses a meta string into a structured ParsedMeta object.
|
|
579
636
|
*/
|
|
637
|
+
declare function parseMetaString(metaStr: string): ParsedMeta;
|
|
638
|
+
//#endregion
|
|
639
|
+
//#region src/node/plugins/plugin-utils.d.ts
|
|
640
|
+
interface NodeWithHProperties extends Node {
|
|
641
|
+
data?: {
|
|
642
|
+
hProperties?: Record<string, unknown>;
|
|
643
|
+
[key: string]: unknown;
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* General, type-safe utility to visit nodes in the AST (MDAST/HAST/MDX).
|
|
648
|
+
*/
|
|
649
|
+
declare function visitNodes<T extends Node>(tree: Node, test: string | string[] | ((node: Node) => boolean), callback: (node: T, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
650
|
+
declare function visitRehypeElements(tree: Node, tagName: string, callback: (node: ElementNode, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
651
|
+
declare function visitMdxElements(tree: Node, name: string | string[], callback: (node: MdxJsxElement, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
652
|
+
declare function setNodeProperty(node: NodeWithHProperties, key: string, value: unknown): void;
|
|
653
|
+
declare function getNodeProperty(node: NodeWithHProperties, key: string): unknown;
|
|
654
|
+
declare function createMdxAttribute(name: string, value: unknown): MdxJsxAttribute;
|
|
655
|
+
declare function createRehypeElement(tagName: string, properties?: Record<string, unknown>, children?: Node[]): ElementNode;
|
|
656
|
+
declare function createMdxElement(name: string, attributes?: Record<string, unknown>, children?: Node[], isFlow?: boolean): MdxJsxElement;
|
|
657
|
+
declare function visitRemarkHeadings(tree: Node, callback: (node: any, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
658
|
+
declare function visitRemarkLinks(tree: Node, callback: (node: any, index: number, parent: Parent) => void | number | boolean | symbol): void;
|
|
659
|
+
declare function addNodeClass(node: ElementNode, className: string): void;
|
|
660
|
+
declare function removeNodeClass(node: ElementNode, className: string): void;
|
|
661
|
+
declare function hasNodeClass(node: ElementNode, className: string): boolean;
|
|
662
|
+
//#endregion
|
|
663
|
+
//#region src/node/mdx/constants.d.ts
|
|
664
|
+
declare const MDX_NODES: {
|
|
665
|
+
readonly ROOT: "root";
|
|
666
|
+
readonly ELEMENT: "element";
|
|
667
|
+
readonly TEXT: "text";
|
|
668
|
+
readonly COMMENT: "comment";
|
|
669
|
+
readonly CODE: "code";
|
|
670
|
+
readonly INLINE_CODE: "inlineCode";
|
|
671
|
+
readonly HEADING: "heading";
|
|
672
|
+
readonly PARAGRAPH: "paragraph";
|
|
673
|
+
readonly LINK: "link";
|
|
674
|
+
readonly IMAGE: "image";
|
|
675
|
+
readonly LIST: "list";
|
|
676
|
+
readonly LIST_ITEM: "listItem";
|
|
677
|
+
readonly JSX_FLOW_ELEMENT: "mdxJsxFlowElement";
|
|
678
|
+
readonly JSX_TEXT_ELEMENT: "mdxJsxTextElement";
|
|
679
|
+
readonly JSX_ATTRIBUTE: "mdxJsxAttribute";
|
|
680
|
+
readonly FLOW_EXPRESSION: "mdxFlowExpression";
|
|
681
|
+
readonly TEXT_EXPRESSION: "mdxTextExpression";
|
|
682
|
+
readonly ESM: "mdxjsEsm";
|
|
683
|
+
};
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/node/plugins/index.d.ts
|
|
580
686
|
declare function createPlugin(plugin: SecureBoltdocsPlugin): SecureBoltdocsPlugin;
|
|
581
687
|
//#endregion
|
|
582
688
|
//#region src/node/index.d.ts
|
|
@@ -587,4 +693,4 @@ declare function boltdocs(options?: BoltdocsPluginOptions): Promise<Plugin[]>;
|
|
|
587
693
|
*/
|
|
588
694
|
declare function createViteConfig(root: string, mode?: 'development' | 'production'): Promise<InlineConfig>;
|
|
589
695
|
//#endregion
|
|
590
|
-
export { type BoltdocsConfig, type BoltdocsPlugin, type BoltdocsPluginOptions, BoltdocsPluginStore, type BoltdocsThemeConfig, PluginCompatibilityError, PluginContext, PluginError, PluginHookError, PluginLifecycleHooks, PluginLifecycleManager, PluginLogger, PluginMeta,
|
|
696
|
+
export { type BoltdocsConfig, type BoltdocsPlugin, type BoltdocsPluginOptions, BoltdocsPluginStore, type BoltdocsThemeConfig, EXIT, MDX_NODES, NodeWithHProperties, PluginCompatibilityError, PluginContext, PluginError, PluginHookError, PluginLifecycleHooks, PluginLifecycleManager, PluginLogger, PluginMeta, PluginStore, PluginValidationError, type RouteMeta, SKIP, SecureBoltdocsPlugin, addNodeClass, createMdxAttribute, createMdxElement, createPlugin, createRehypeElement, createViteConfig, boltdocs as default, defineConfig, generateEntryCode, getNodeProperty, hasNodeClass, normalizePath, parseMetaString, removeNodeClass, resolveConfig, sanitizeFilename, setNodeProperty, validatePlugins, visitMdxElements, visitNodes, visitRehypeElements, visitRemarkHeadings, visitRemarkLinks };
|