boltdocs 3.1.0 → 3.2.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/{adapters-DEXNIv3x.mjs → adapters-ByYY44Zy.mjs} +1 -1
- package/dist/{adapters-uGz-UKQa.cjs → adapters-DvmtpdSF.cjs} +1 -1
- package/dist/{banner-DjujkctF.d.ts → banner-BMop1KLF.d.ts} +2 -2
- package/dist/{banner-DdSgCs4G.d.cts → banner-CVD0GugR.d.cts} +2 -2
- package/dist/{cache-CfRTUzWC.cjs → cache-CO4Dy2uQ.cjs} +1 -1
- package/dist/{cache-B0C2i0yP.mjs → cache-Dk53iOo6.mjs} +1 -1
- package/dist/chunk-BFSpntXv.mjs +6 -0
- package/dist/{chunk-Ds5LZdWN.cjs → chunk-D1Md3oWO.cjs} +1 -1
- package/dist/client/index.cjs +219 -172
- package/dist/client/index.d.cts +75 -9
- package/dist/client/index.d.ts +75 -9
- package/dist/client/index.js +119 -73
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.d.cts +1 -1
- package/dist/client/mdx.d.ts +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +7 -7
- package/dist/client/primitives.d.cts +5 -22
- package/dist/client/primitives.d.ts +5 -22
- package/dist/client/primitives.js +4 -4
- package/dist/client/theme/reset.css +31 -4
- package/dist/{shiki-adapter-fS94vy-z.d.mts → config-BpzaPsJj.d.cts} +325 -78
- package/dist/config-CCXp3aXO.mjs +7 -0
- package/dist/{config-BxsogK5A.cjs → config-CMd4XoFq.cjs} +1 -1
- package/dist/config-DlGoEM9D.cjs +7 -0
- package/dist/{shiki-adapter-l2kEP5rn.d.cts → config-xtS0ZkMm.d.mts} +325 -78
- package/dist/{csp-BX06rvdg.cjs → csp-CRp_3U7a.cjs} +1 -1
- package/dist/csp-oTC2ygvF.mjs +6 -0
- package/dist/{docs-layout-DyLDBwS6.js → docs-layout-BdtZ9z6s.js} +9 -28
- package/dist/{docs-layout-D1buSdua.cjs → docs-layout-CFWI15Id.cjs} +69 -88
- package/dist/{doctor-DPDcRKM1.cjs → doctor-BBtmNJE0.cjs} +1 -1
- package/dist/doctor-Bv16QSrI.cjs +7 -0
- package/dist/doctor-DOAbSaiL.mjs +7 -0
- package/dist/{generator-BN75lJOv.cjs → generator-COepVWGi.cjs} +1 -1
- package/dist/{handler-Btd4t_67.mjs → handler-DzQae4eA.mjs} +1 -1
- package/dist/{handler-1LRMYeI4.cjs → handler-XX7cLTqe.cjs} +1 -1
- package/dist/headers-Ddwek8K7.mjs +6 -0
- package/dist/{headers-YpD10rDb.cjs → headers-dg4SDrjY.cjs} +1 -1
- package/dist/{image-5WsgWYTh.js → image-Bz87fCla.js} +1 -1
- package/dist/{image-Hb105Gu6.cjs → image-C4TlpMHn.cjs} +18 -18
- package/dist/link-2PzgTnaP.js +673 -0
- package/dist/{icons-dev-YtDoLUsb.cjs → link-D1Gjkb-2.cjs} +0 -350
- package/dist/{mdx-Bv-pS6-O.js → mdx-BuO6a1f7.js} +195 -40
- package/dist/{mdx-CDUcJmye.cjs → mdx-CD-tSjRG.cjs} +234 -73
- package/dist/{meta-loader-CTB62-Mo.cjs → meta-loader-Dq1zcFnh.cjs} +1 -1
- package/dist/node/cache.cjs +1 -1
- package/dist/node/cache.d.cts +2 -1
- package/dist/node/cache.d.mts +2 -1
- package/dist/node/cache.mjs +1 -1
- package/dist/node/cli-entry.cjs +6 -6
- package/dist/node/cli-entry.mjs +9 -9
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +20 -174
- package/dist/node/index.d.mts +18 -175
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +49 -1
- package/dist/node/mdx/shiki-adapter.d.mts +49 -1
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-B5hu_6qj.cjs +104 -0
- package/dist/node-BXtqM1uH.mjs +6 -0
- package/dist/node-C8725aw7.mjs +104 -0
- package/dist/node-aD1eisrR.cjs +6 -0
- package/dist/{package-_-Oa8-qN.cjs → package-CH2ChQqw.cjs} +1 -1
- package/dist/{package-CoHWTf0N.mjs → package-DSSB8B5L.mjs} +1 -1
- package/dist/{pages-external-CX2uyW95.cjs → pages-external-XkYIs-d5.cjs} +1 -1
- package/dist/parser-DCiEWkSk.cjs +8 -0
- package/dist/parser-qk9FIHJ7.mjs +8 -0
- package/dist/plugin-CX1OZ6jB.cjs +73 -0
- package/dist/plugin-CgfiWaFZ.mjs +73 -0
- package/dist/routes-BW6zsk7Z.mjs +6 -0
- package/dist/routes-BgoIB5wb.cjs +6 -0
- package/dist/{routes-D_S9kjkS.cjs → routes-CORVxc02.cjs} +1 -1
- package/dist/{search-dialog-BpNULmrl.cjs → search-dialog-B1NERUNx.cjs} +101 -55
- package/dist/{search-dialog-BbtxA1uT.cjs → search-dialog-BRFno7HD.cjs} +8 -8
- package/dist/{search-dialog-DC7oXU-5.js → search-dialog-BmxHiKwt.js} +2 -2
- package/dist/{search-dialog-gp9lrJXm.js → search-dialog-D6TvjcuV.js} +1 -1
- package/dist/{search-dialog-PJrFRU5G.js → search-dialog-DFnlx8LO.js} +44 -4
- package/dist/{search-dialog-BIuxGQsg.cjs → search-dialog-DHqwjJuG.cjs} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/shiki-adapter-CoQ6jyJ4.cjs +6 -0
- package/dist/shiki-adapter-D-aKw7PP.mjs +6 -0
- package/dist/{sidebar-DknLUI1R.d.ts → sidebar-COTaMHR-.d.ts} +349 -41
- package/dist/{sidebar-DH2iPKXM.d.cts → sidebar-CrEdJuHX.d.cts} +349 -41
- package/dist/{types-generator-CYcHkDzZ.cjs → types-generator-BXhv7Ill.cjs} +1 -1
- package/dist/types-generator-bDPvUztF.mjs +26 -0
- package/dist/utils-Crm9oPcV.mjs +7 -0
- package/dist/utils-D6Xtj0FZ.cjs +7 -0
- package/package.json +13 -10
- package/src/shared/types.ts +361 -19
- package/dist/chunk-hT5z_Zn9-DsJawvsz.mjs +0 -6
- package/dist/chunk-hT5z_Zn9-SKz6VFXu.cjs +0 -6
- package/dist/config-DAgpZyh6.mjs +0 -7
- package/dist/config-DrRQYDCI.cjs +0 -7
- package/dist/csp-z2D0FuRW.mjs +0 -6
- package/dist/doctor-BadGEhXv.cjs +0 -7
- package/dist/doctor-vDsUDgqp.mjs +0 -7
- package/dist/escape-string-regexp-AG8q1e25-9Un9V90q.mjs +0 -6
- package/dist/escape-string-regexp-AG8q1e25-bJ9Ixe7c.cjs +0 -6
- package/dist/esm-shims-DSep1HcR.mjs +0 -6
- package/dist/headers-CL0pMcwm.mjs +0 -6
- package/dist/icons-dev-CHZOwhQA.js +0 -921
- package/dist/lib-BR0SoanK-CLswltLI.cjs +0 -6
- package/dist/lib-BR0SoanK-DcYeDrE6.mjs +0 -6
- package/dist/lib-DPoCz1YB-CLYXwKST.cjs +0 -6
- package/dist/lib-DPoCz1YB-CyGOqgSO.mjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-C6gnc770.cjs +0 -6
- package/dist/micromark-util-character-5KqJafVT-DkPKsbgn.mjs +0 -6
- package/dist/node-BDBv8CT6.mjs +0 -104
- package/dist/node-DFV_FV0y.mjs +0 -6
- package/dist/node-DqsP7kXz.cjs +0 -6
- package/dist/node-yFmAavND.cjs +0 -104
- package/dist/parser-BZJgAa9E.mjs +0 -8
- package/dist/parser-DlanzESE.cjs +0 -8
- package/dist/plugin-BVuwx5D9.cjs +0 -73
- package/dist/plugin-BoxD91Yh.mjs +0 -73
- package/dist/rehype-slug--ZOxZ-_K-BNeYC4aT.cjs +0 -6
- package/dist/rehype-slug--ZOxZ-_K-CjIQEJCs.mjs +0 -6
- package/dist/remark-frontmatter-wFYRLcCt-CutW0gA3.mjs +0 -8
- package/dist/remark-frontmatter-wFYRLcCt-ENB5qG3y.cjs +0 -8
- package/dist/remark-gfm-B8TMkQbX-CjUJo8Rd.cjs +0 -21
- package/dist/remark-gfm-B8TMkQbX-Ctu0VV1_.mjs +0 -21
- package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
- package/dist/rollup-DMqoG11U-CKcJ37u_.mjs +0 -59
- package/dist/rollup-DMqoG11U-DKdxvZIj.cjs +0 -59
- package/dist/routes-BN2XbGcT.mjs +0 -6
- package/dist/routes-Cnq8xTCv.cjs +0 -6
- package/dist/shiki-adapter-CGTmrR6S.cjs +0 -6
- package/dist/shiki-adapter-CK3llqw2.mjs +0 -6
- package/dist/types-generator-DVOnRVKU.mjs +0 -26
- package/dist/utils-B3xYMrpK.mjs +0 -7
- package/dist/utils-Bz1tG9Dg.cjs +0 -7
- /package/dist/{errors-C0Hx15Ag.mjs → errors-0zGHRLue.mjs} +0 -0
- /package/dist/{errors-Dx6JHoKE.cjs → errors-vKw8CkiX.cjs} +0 -0
- /package/dist/{index-DJYJzs-Z.d.mts → index-1KsTDq4o.d.mts} +0 -0
- /package/dist/{meta-loader-Bq-MjTXB.mjs → meta-loader-C4Hu9RN9.mjs} +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import * as React$2 from "react";
|
|
3
3
|
import { ComponentType, ReactNode } from "react";
|
|
4
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import * as _$http from "http";
|
|
5
6
|
import { Plugin } from "vite";
|
|
6
7
|
|
|
7
8
|
//#region src/shared/types.d.ts
|
|
@@ -109,15 +110,15 @@ interface BoltdocsThemeConfig {
|
|
|
109
110
|
};
|
|
110
111
|
navbar?: Array<{
|
|
111
112
|
label: string | Record<string, string>;
|
|
112
|
-
href: BoltdocsRoutePathWithFallback
|
|
113
|
+
href: BoltdocsRoutePathWithFallback;
|
|
113
114
|
items?: Array<{
|
|
114
115
|
label: string | Record<string, string>;
|
|
115
|
-
href: BoltdocsRoutePathWithFallback
|
|
116
|
+
href: BoltdocsRoutePathWithFallback;
|
|
116
117
|
}>;
|
|
117
118
|
}>;
|
|
118
119
|
sidebar?: Record<string, Array<{
|
|
119
120
|
text: string;
|
|
120
|
-
link: BoltdocsRoutePathWithFallback
|
|
121
|
+
link: BoltdocsRoutePathWithFallback;
|
|
121
122
|
}>>;
|
|
122
123
|
sidebarGroups?: Record<string, {
|
|
123
124
|
title?: string | Record<string, string>;
|
|
@@ -178,6 +179,43 @@ interface BoltdocsVersionConfig {
|
|
|
178
179
|
label: string;
|
|
179
180
|
path: string;
|
|
180
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Configuration for content collections (e.g. blog posts, changelog)
|
|
184
|
+
* declared in `boltdocs.config.ts`. Each entry maps a directory name
|
|
185
|
+
* (e.g. `[blog]`) to its display + ordering settings.
|
|
186
|
+
*/
|
|
187
|
+
interface BoltdocsCollectionsConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Map of collection id (matches the bracketed directory name) to
|
|
190
|
+
* its display label. Falls back to the id when a label is missing.
|
|
191
|
+
*/
|
|
192
|
+
labels?: Record<string, string | Record<string, string>>;
|
|
193
|
+
/**
|
|
194
|
+
* Map of collection id to a numeric position used for sidebar ordering.
|
|
195
|
+
* Collections with no explicit position are sorted last.
|
|
196
|
+
*/
|
|
197
|
+
positions?: Record<string, number>;
|
|
198
|
+
/**
|
|
199
|
+
* Items-per-page for paginated collection routes (e.g. blog indexes).
|
|
200
|
+
* Falls back to the framework default (10) when omitted.
|
|
201
|
+
*/
|
|
202
|
+
postsPerPage?: number;
|
|
203
|
+
/**
|
|
204
|
+
* Default collection ID used by collection routing when no collection
|
|
205
|
+
* is explicitly referenced. Defaults to `'blog'`.
|
|
206
|
+
*/
|
|
207
|
+
defaultCollection?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Date format string for rendering post dates in listing pages.
|
|
210
|
+
* Defaults to `'MMMM dd, yyyy'`.
|
|
211
|
+
*/
|
|
212
|
+
dateFormat?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Field used to sort posts within a collection.
|
|
215
|
+
* Defaults to `'date'`.
|
|
216
|
+
*/
|
|
217
|
+
sortBy?: 'date' | 'title' | 'sidebarPosition';
|
|
218
|
+
}
|
|
181
219
|
/**
|
|
182
220
|
* Configuration for documentation versioning.
|
|
183
221
|
*/
|
|
@@ -197,7 +235,7 @@ type BadgeValue = string | {
|
|
|
197
235
|
* Context provided to plugin lifecycle hooks.
|
|
198
236
|
*/
|
|
199
237
|
interface PluginContext {
|
|
200
|
-
readonly config: BoltdocsConfig
|
|
238
|
+
readonly config: BoltdocsConfig;
|
|
201
239
|
readonly logger: PluginLogger;
|
|
202
240
|
readonly store: PluginStore;
|
|
203
241
|
readonly meta: PluginMeta;
|
|
@@ -205,6 +243,129 @@ interface PluginContext {
|
|
|
205
243
|
readonly rootDir: string;
|
|
206
244
|
readonly outDir: string;
|
|
207
245
|
readonly routes: RouteMeta[];
|
|
246
|
+
/** Namespaced cache helpers bound to the core's cache machinery. */
|
|
247
|
+
readonly caches: PluginCachesAPI;
|
|
248
|
+
/** Structured diagnostics channel; reports can be drained via `list()`. */
|
|
249
|
+
readonly diagnostics: PluginDiagnosticsAPI;
|
|
250
|
+
/** Helpers for resolving paths inside the workspace safely. */
|
|
251
|
+
readonly paths: PluginPathsAPI;
|
|
252
|
+
/** Declare virtual modules the core should expose to Vite. */
|
|
253
|
+
readonly virtualModules: PluginVirtualModulesAPI;
|
|
254
|
+
/** Register and query transform middleware at runtime. */
|
|
255
|
+
readonly middleware: PluginMiddlewareAPI;
|
|
256
|
+
/**
|
|
257
|
+
* Hook into dev-server file watching and send custom HMR events
|
|
258
|
+
* to connected clients.
|
|
259
|
+
*/
|
|
260
|
+
readonly hmr: PluginHmrAPI;
|
|
261
|
+
/**
|
|
262
|
+
* Register HTTP middleware and server lifecycle hooks without
|
|
263
|
+
* writing a Vite plugin.
|
|
264
|
+
*/
|
|
265
|
+
readonly server: PluginServerAPI;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Functional cache helpers exposed through `PluginContext.caches`.
|
|
269
|
+
*
|
|
270
|
+
* Plugin authors do not get a reference to the raw `TransformCache` /
|
|
271
|
+
* `FileCache` instances — those stay encapsulated in core. The methods
|
|
272
|
+
* returned here are bound to namespaced keys so two plugins cannot
|
|
273
|
+
* collide.
|
|
274
|
+
*/
|
|
275
|
+
interface PluginCachesAPI {
|
|
276
|
+
/** Sharded, hash-keyed cache. One namespace per plugin recommended. */
|
|
277
|
+
transform(namespace: string): PluginTransformCacheAPI;
|
|
278
|
+
/** Routes cache wrapper around the parsed-doc cache. */
|
|
279
|
+
routes: PluginRoutesCacheAPI;
|
|
280
|
+
/** In-memory LRU cache keyed by namespace + plugin-supplied key. */
|
|
281
|
+
memory<V = unknown>(namespace: string, opts?: {
|
|
282
|
+
max?: number;
|
|
283
|
+
ttl?: number;
|
|
284
|
+
}): PluginMemoryCacheAPI<V>;
|
|
285
|
+
}
|
|
286
|
+
interface PluginTransformCacheAPI {
|
|
287
|
+
/** Async read — first call may warm from disk if the entry was evicted. */
|
|
288
|
+
get(key: string): Promise<string | null>;
|
|
289
|
+
/** Synchronous write that batches a background disk flush. */
|
|
290
|
+
set(key: string, value: string): void;
|
|
291
|
+
/** Force-flush background writes. Call before measuring disk state. */
|
|
292
|
+
flush(): Promise<void>;
|
|
293
|
+
}
|
|
294
|
+
interface PluginRoutesCacheAPI {
|
|
295
|
+
/** Read a parsed `RouteMeta` (and its private `_content` blob) by abs file path. */
|
|
296
|
+
get(filePath: string): RouteMeta | null;
|
|
297
|
+
/** Write a parsed route entry. Caller assumptions match `docCache.set`. */
|
|
298
|
+
set(filePath: string, route: RouteMeta): void;
|
|
299
|
+
/** Invalidate one route. Use when content changes. */
|
|
300
|
+
invalidate(filePath: string): void;
|
|
301
|
+
/** Clear every cached route. Use when the directory layout changes. */
|
|
302
|
+
invalidateAll(): void;
|
|
303
|
+
}
|
|
304
|
+
interface PluginMemoryCacheAPI<V> {
|
|
305
|
+
get(key: string): V | undefined;
|
|
306
|
+
set(key: string, value: V): void;
|
|
307
|
+
has(key: string): boolean;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Plugin diagnostics API.
|
|
311
|
+
*
|
|
312
|
+
* Plugins push structured records instead of spamming the logger; downstream
|
|
313
|
+
* tools (dev-server overlay, CI reporters, IDE plugins) drain the queue via
|
|
314
|
+
* `list()`.
|
|
315
|
+
*/
|
|
316
|
+
interface DiagnosticRecord {
|
|
317
|
+
readonly id: number;
|
|
318
|
+
readonly severity: 'info' | 'warn' | 'error';
|
|
319
|
+
readonly code: string;
|
|
320
|
+
readonly message: string;
|
|
321
|
+
readonly pluginName: string;
|
|
322
|
+
readonly filePath?: string;
|
|
323
|
+
readonly routePath?: string;
|
|
324
|
+
readonly time: Date;
|
|
325
|
+
}
|
|
326
|
+
interface PluginDiagnosticsAPI {
|
|
327
|
+
report(severity: DiagnosticRecord['severity'], code: string, message: string, where?: {
|
|
328
|
+
filePath?: string;
|
|
329
|
+
routePath?: string;
|
|
330
|
+
}): void;
|
|
331
|
+
list(): readonly DiagnosticRecord[];
|
|
332
|
+
clear(): void;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Path-resolution helpers exposed through `PluginContext.paths`.
|
|
336
|
+
*
|
|
337
|
+
* Both `resolveDocs` and `resolveAsset` validate the resulting path against
|
|
338
|
+
* the workspace boundary and reject any segment that resolves outside the
|
|
339
|
+
* docs / project root directories.
|
|
340
|
+
*/
|
|
341
|
+
interface PluginPathsAPI {
|
|
342
|
+
resolveDocs(...parts: string[]): string;
|
|
343
|
+
resolveAsset(...parts: string[]): string;
|
|
344
|
+
/**
|
|
345
|
+
* Build a `file://` URL for an absolute path inside the workspace.
|
|
346
|
+
* Useful for `new URL(import.meta.url)` replacements and image srcsets.
|
|
347
|
+
*/
|
|
348
|
+
safeFileURL(absFilePath: string): string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Plugin virtual-modules registration.
|
|
352
|
+
*
|
|
353
|
+
* Plugins call `add(id, loader)` to expose a `virtual:<plugin>/<id>` module
|
|
354
|
+
* to Vite without having to author a full Vite plugin. The loader returns
|
|
355
|
+
* the module source code as a string; the core wraps it in the right
|
|
356
|
+
* `resolveId`/`load` plumbing at Vite build time.
|
|
357
|
+
*/
|
|
358
|
+
interface RegisteredVirtualModule {
|
|
359
|
+
readonly id: string;
|
|
360
|
+
readonly eager: boolean;
|
|
361
|
+
readonly loader: () => string | Promise<string>;
|
|
362
|
+
}
|
|
363
|
+
interface PluginVirtualModulesAPI {
|
|
364
|
+
add(id: string, loader: () => string | Promise<string>, opts?: {
|
|
365
|
+
eager?: boolean;
|
|
366
|
+
}): void;
|
|
367
|
+
has(id: string): boolean;
|
|
368
|
+
list(): readonly RegisteredVirtualModule[];
|
|
208
369
|
}
|
|
209
370
|
/**
|
|
210
371
|
* Logger interface for plugin logging.
|
|
@@ -231,6 +392,152 @@ interface PluginMeta {
|
|
|
231
392
|
version?: string;
|
|
232
393
|
boltdocsVersion?: string;
|
|
233
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Chain control signal returned by transform hooks. Use with `__signal` in
|
|
397
|
+
* the return value to influence the middleware chain:
|
|
398
|
+
*
|
|
399
|
+
* - `'skip'`: stop processing this hook for the current file (remaining
|
|
400
|
+
* plugins in the chain still run).
|
|
401
|
+
* - `'break'`: stop the entire chain immediately — no further plugin's
|
|
402
|
+
* transform hooks run for this file.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* transformMdx: async (_ctx, { code }) => ({
|
|
407
|
+
* code: code.replace(/foo/g, 'bar'),
|
|
408
|
+
* __signal: 'skip', // skip remaining plugins
|
|
409
|
+
* })
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
type ChainSignal = 'skip' | 'break';
|
|
413
|
+
/**
|
|
414
|
+
* Returned by a transform hook that wants to signal the chain. The `__signal`
|
|
415
|
+
* field is optional — most hooks will just return `{ code: string }` and the
|
|
416
|
+
* chain continues normally. When `__signal` is present, `runChain` reacts:
|
|
417
|
+
*
|
|
418
|
+
* - `'skip'` continues with the next plugin, but passes the **original params**
|
|
419
|
+
* (the output of this hook is discarded).
|
|
420
|
+
* - `'break'` stops the chain immediately.
|
|
421
|
+
*
|
|
422
|
+
* @template T The params shape (e.g. `{ code: string; filePath: string }`).
|
|
423
|
+
*/
|
|
424
|
+
type TransformResult<T> = T & {
|
|
425
|
+
__signal?: ChainSignal;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* Enriched params passed to `transformSource` and `transformMdx`. The `code`
|
|
429
|
+
* and `filePath` fields are always present. The optional `frontmatter` and
|
|
430
|
+
* `route` fields are populated when available (they are `undefined` in the
|
|
431
|
+
* early pipeline where frontmatter hasn't been parsed yet).
|
|
432
|
+
*/
|
|
433
|
+
interface TransformSourceParams {
|
|
434
|
+
/** The raw or compiled code (source before MDX / JS after MDX). */
|
|
435
|
+
code: string;
|
|
436
|
+
/** Absolute file path of the source document. */
|
|
437
|
+
filePath: string;
|
|
438
|
+
/** Parsed frontmatter, if available. `undefined` in very early pipeline. */
|
|
439
|
+
frontmatter?: Record<string, unknown>;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Enriched params passed to `transformHtml`. The `html` and `path` fields
|
|
443
|
+
* are always present. The optional `route` carries the generated `RouteMeta`
|
|
444
|
+
* for richer context (locale, version, collection, etc.).
|
|
445
|
+
*/
|
|
446
|
+
interface TransformHtmlParams {
|
|
447
|
+
/** The rendered HTML string for this page. */
|
|
448
|
+
html: string;
|
|
449
|
+
/** The route path (e.g. `/docs/guides/start`). */
|
|
450
|
+
path: string;
|
|
451
|
+
/** The route metadata for the page, if available. */
|
|
452
|
+
route?: RouteMeta;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Plugin transform middleware. Each middleware runs in the transform
|
|
456
|
+
* pipeline alongside lifecycle hooks. The `name` field is optional —
|
|
457
|
+
* when omitted, the owning plugin's name is used as context.
|
|
458
|
+
* Middleware runs in `enforce` order (pre → normal → post) and supports
|
|
459
|
+
* `__signal: 'skip'` / `__signal: 'break'` for chain control.
|
|
460
|
+
*/
|
|
461
|
+
interface PluginTransformMiddleware {
|
|
462
|
+
/** Optional name. Defaults to the owning plugin's name for diagnostics. */
|
|
463
|
+
name?: string;
|
|
464
|
+
enforce?: 'pre' | 'post';
|
|
465
|
+
transformSource?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
466
|
+
code: string;
|
|
467
|
+
}> | Promise<TransformResult<{
|
|
468
|
+
code: string;
|
|
469
|
+
}>>;
|
|
470
|
+
transformMdx?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
471
|
+
code: string;
|
|
472
|
+
}> | Promise<TransformResult<{
|
|
473
|
+
code: string;
|
|
474
|
+
}>>;
|
|
475
|
+
transformHtml?: (ctx: PluginContext, params: TransformHtmlParams) => TransformResult<{
|
|
476
|
+
html: string;
|
|
477
|
+
}> | Promise<TransformResult<{
|
|
478
|
+
html: string;
|
|
479
|
+
}>>;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Plugin middleware registry API exposed through `PluginContext.middleware`.
|
|
483
|
+
* Plugins can register named middleware entries from lifecycle hooks.
|
|
484
|
+
*/
|
|
485
|
+
interface PluginMiddlewareAPI {
|
|
486
|
+
add(middleware: PluginTransformMiddleware): void;
|
|
487
|
+
remove(name: string): void;
|
|
488
|
+
has(name: string): boolean;
|
|
489
|
+
list(): readonly PluginTransformMiddleware[];
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* HMR event types plugins can listen to.
|
|
493
|
+
*/
|
|
494
|
+
type PluginHmrEvent = 'add' | 'change' | 'unlink';
|
|
495
|
+
/**
|
|
496
|
+
* Plugin HMR API — hook into file-watching events and send custom
|
|
497
|
+
* HMR messages to connected clients.
|
|
498
|
+
*/
|
|
499
|
+
interface PluginHmrAPI {
|
|
500
|
+
/**
|
|
501
|
+
* Register a callback for file events scoped to the docs directory.
|
|
502
|
+
* The callback receives the normalized file path and event type.
|
|
503
|
+
*/
|
|
504
|
+
onFileEvent(eventType: PluginHmrEvent, handler: (filePath: string) => void | Promise<void>): void;
|
|
505
|
+
/** Shorthand for `onFileEvent('add', handler)`. */
|
|
506
|
+
onFileAdd(handler: (filePath: string) => void | Promise<void>): void;
|
|
507
|
+
/** Shorthand for `onFileEvent('change', handler)`. */
|
|
508
|
+
onFileChange(handler: (filePath: string) => void | Promise<void>): void;
|
|
509
|
+
/** Shorthand for `onFileEvent('unlink', handler)`. */
|
|
510
|
+
onFileUnlink(handler: (filePath: string) => void | Promise<void>): void;
|
|
511
|
+
/**
|
|
512
|
+
* Send a custom HMR event to all connected clients.
|
|
513
|
+
* The client can listen with `import.meta.hot.on('boltdocs:plugin:<name>', ...)`.
|
|
514
|
+
*/
|
|
515
|
+
send(event: string, data?: unknown): void;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Plugin Server API — register HTTP middleware and lifecycle hooks
|
|
519
|
+
* for the dev server and preview server, without writing a Vite plugin.
|
|
520
|
+
*/
|
|
521
|
+
interface PluginServerAPI {
|
|
522
|
+
/**
|
|
523
|
+
* Register a Connect-style middleware function.
|
|
524
|
+
* Runs on both dev and preview servers.
|
|
525
|
+
*/
|
|
526
|
+
use(middleware: PluginServerMiddleware): void;
|
|
527
|
+
/**
|
|
528
|
+
* Register a middleware scoped to a specific path prefix.
|
|
529
|
+
* Only requests starting with `path` trigger the handler.
|
|
530
|
+
*/
|
|
531
|
+
useAt(path: string, handler: PluginServerMiddleware): void;
|
|
532
|
+
/** Called when the dev/preview server starts (once per process). */
|
|
533
|
+
onStart(callback: () => void | Promise<void>): void;
|
|
534
|
+
/** Called when the server shuts down (cleanup). */
|
|
535
|
+
onEnd(callback: () => void | Promise<void>): void;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Connect-style middleware signature.
|
|
539
|
+
*/
|
|
540
|
+
type PluginServerMiddleware = (req: _$http.IncomingMessage, res: _$http.ServerResponse, next: (err?: unknown) => void) => void | Promise<void>;
|
|
234
541
|
/**
|
|
235
542
|
* Plugin lifecycle hooks with full type safety.
|
|
236
543
|
*/
|
|
@@ -240,30 +547,21 @@ interface PluginLifecycleHooks {
|
|
|
240
547
|
beforeDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
241
548
|
afterDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
242
549
|
buildEnd?: (ctx: PluginContext) => Promise<void> | void;
|
|
243
|
-
transformSource?: (ctx: PluginContext, params: {
|
|
550
|
+
transformSource?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
244
551
|
code: string;
|
|
245
|
-
|
|
246
|
-
}) => Promise<{
|
|
552
|
+
}> | Promise<TransformResult<{
|
|
247
553
|
code: string;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
};
|
|
251
|
-
transformMdx?: (ctx: PluginContext, params: {
|
|
252
|
-
code: string;
|
|
253
|
-
filePath: string;
|
|
254
|
-
}) => Promise<{
|
|
554
|
+
}>>;
|
|
555
|
+
transformMdx?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
255
556
|
code: string;
|
|
256
|
-
}> | {
|
|
557
|
+
}> | Promise<TransformResult<{
|
|
257
558
|
code: string;
|
|
258
|
-
}
|
|
259
|
-
transformHtml?: (ctx: PluginContext, params: {
|
|
260
|
-
html: string;
|
|
261
|
-
path: string;
|
|
262
|
-
}) => Promise<{
|
|
559
|
+
}>>;
|
|
560
|
+
transformHtml?: (ctx: PluginContext, params: TransformHtmlParams) => TransformResult<{
|
|
263
561
|
html: string;
|
|
264
|
-
}> | {
|
|
562
|
+
}> | Promise<TransformResult<{
|
|
265
563
|
html: string;
|
|
266
|
-
}
|
|
564
|
+
}>>;
|
|
267
565
|
}
|
|
268
566
|
/**
|
|
269
567
|
* MDX processor configuration.
|
|
@@ -287,22 +585,19 @@ interface BoltdocsPlugin {
|
|
|
287
585
|
rehypePlugins?: unknown[];
|
|
288
586
|
vitePlugins?: Plugin[];
|
|
289
587
|
components?: Record<string, string>;
|
|
588
|
+
/** Optional runtime metadata exposed to client via useConfig().plugins[].metadata */
|
|
589
|
+
metadata?: Record<string, unknown>;
|
|
590
|
+
/** Declarative transform middleware entries. */
|
|
591
|
+
middleware?: PluginTransformMiddleware[];
|
|
290
592
|
/** Lifecycle hooks with full type safety */
|
|
291
593
|
hooks?: PluginLifecycleHooks;
|
|
292
594
|
}
|
|
293
595
|
/**
|
|
294
|
-
* Configuration for the collections (blog) feature.
|
|
295
596
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
defaultCollection?: string;
|
|
301
|
-
/** Date format string for rendering post dates (e.g., 'MMMM dd, yyyy'). */
|
|
302
|
-
dateFormat?: string;
|
|
303
|
-
/** Field to sort posts by. Defaults to 'date'. */
|
|
304
|
-
sortBy?: 'date' | 'title' | 'sidebarPosition';
|
|
305
|
-
}
|
|
597
|
+
/**
|
|
598
|
+
*/
|
|
599
|
+
/**
|
|
600
|
+
*/
|
|
306
601
|
interface BoltdocsSecurityConfig {
|
|
307
602
|
headers?: Record<string, string>;
|
|
308
603
|
enableCSP?: boolean;
|
|
@@ -425,7 +720,7 @@ interface BoltdocsDraftsConfig {
|
|
|
425
720
|
/**
|
|
426
721
|
* The root configuration object for Boltdocs.
|
|
427
722
|
*/
|
|
428
|
-
interface BoltdocsConfig
|
|
723
|
+
interface BoltdocsConfig {
|
|
429
724
|
siteUrl?: string;
|
|
430
725
|
docsDir?: string;
|
|
431
726
|
base?: string;
|
|
@@ -461,7 +756,7 @@ declare global {
|
|
|
461
756
|
}
|
|
462
757
|
type BoltdocsTypes = Boltdocs.Types;
|
|
463
758
|
type BoltdocsRoutePath = keyof Boltdocs.RoutePaths;
|
|
464
|
-
type BoltdocsRoutePathWithFallback
|
|
759
|
+
type BoltdocsRoutePathWithFallback = BoltdocsRoutePath extends never ? string : BoltdocsRoutePath;
|
|
465
760
|
type BoltdocsLocale = Boltdocs.Types extends {
|
|
466
761
|
Locale: infer L;
|
|
467
762
|
} ? L : string;
|
|
@@ -476,8 +771,7 @@ type TransformMdxComponents<T> = { [K in keyof T as K extends `Frontmatter_${str
|
|
|
476
771
|
};
|
|
477
772
|
type BoltdocsMdxComponents = Boltdocs.Types extends {
|
|
478
773
|
MdxComponents: infer M;
|
|
479
|
-
} ? TransformMdxComponents<UnpackMdxComponents<M>> : {
|
|
480
|
-
[key: string]: ComponentType<any>;
|
|
774
|
+
} ? TransformMdxComponents<UnpackMdxComponents<M>> : Omit<Record<string, ComponentType<any>>, 'Frontmatter'> & {
|
|
481
775
|
Frontmatter: Record<string, ComponentType<any>>;
|
|
482
776
|
};
|
|
483
777
|
//#endregion
|
|
@@ -556,12 +850,26 @@ interface ComponentRoute {
|
|
|
556
850
|
excerpt?: string;
|
|
557
851
|
/** Cover image for blog posts */
|
|
558
852
|
coverImage?: string;
|
|
853
|
+
/** Optional explicit order (alternative to sidebarPosition) */
|
|
854
|
+
order?: number;
|
|
855
|
+
/** Optional explicit label for the sidebar */
|
|
856
|
+
sidebarLabel?: string;
|
|
857
|
+
/** Optional category for the page */
|
|
858
|
+
category?: string;
|
|
859
|
+
/** Whether the page is hidden from the sidebar */
|
|
860
|
+
sidebarHidden?: boolean;
|
|
861
|
+
/**
|
|
862
|
+
* Optional nested child routes for sidebar hierarchies that mirror the
|
|
863
|
+
* server-side `RouteMeta.subRoutes` shape. `sidebar.tsx` walks this
|
|
864
|
+
* field to render the group → subRoutes → items tree.
|
|
865
|
+
*/
|
|
866
|
+
routes?: ComponentRoute[];
|
|
559
867
|
/** Raw extensible frontmatter data for custom components and formatters */
|
|
560
|
-
frontmatter?: Record<string,
|
|
868
|
+
frontmatter?: Record<string, unknown>;
|
|
561
869
|
/** Clean URL segments stripped of locale/version prefixes */
|
|
562
870
|
slugParts?: string[];
|
|
563
871
|
/** SEO metadata for page headers */
|
|
564
|
-
seo?: Record<string,
|
|
872
|
+
seo?: Record<string, unknown>;
|
|
565
873
|
/** Flag to indicate if this is a fallback redirect route */
|
|
566
874
|
fallback?: boolean;
|
|
567
875
|
}
|
|
@@ -719,7 +1027,7 @@ declare function SidebarGroup({
|
|
|
719
1027
|
*/
|
|
720
1028
|
interface SidebarLinkProps extends ComponentBase {
|
|
721
1029
|
label: string;
|
|
722
|
-
href: BoltdocsRoutePathWithFallback
|
|
1030
|
+
href: BoltdocsRoutePathWithFallback;
|
|
723
1031
|
active?: boolean;
|
|
724
1032
|
icon?: React.ElementType;
|
|
725
1033
|
badge?: ComponentRoute['badge'];
|
|
@@ -789,4 +1097,4 @@ declare const Sidebar: typeof SidebarRoot & {
|
|
|
789
1097
|
Items: typeof SidebarItems;
|
|
790
1098
|
};
|
|
791
1099
|
//#endregion
|
|
792
|
-
export { BoltdocsRoutePathWithFallback
|
|
1100
|
+
export { BoltdocsRoutePathWithFallback as A, SiteConfig as C, BoltdocsLocale as D, BoltdocsIntegrationsConfig as E, BoltdocsTypes as M, BoltdocsVersion as N, BoltdocsMdxComponents as O, SidebarProps as S, BoltdocsConfig as T, CollectionPostLoaderData as _, SidebarItem as a, NavbarLink as b, SidebarItemsProps as c, SidebarMobile as d, SidebarRoot as f, CollectionListLoaderData as g, BoltdocsTab as h, SidebarHeader as i, BoltdocsSocialLink as j, BoltdocsRoutePath as k, SidebarLink as l, ComponentBase as m, SidebarContent as n, SidebarItemProps as o, SidebarSubGroup as p, SidebarGroup as r, SidebarItems as s, Sidebar as t, SidebarLinkProps as u, ComponentRoute as v, TabsProps as w, OnThisPageProps as x, LayoutProps as y };
|