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.
Files changed (138) hide show
  1. package/dist/{adapters-DEXNIv3x.mjs → adapters-ByYY44Zy.mjs} +1 -1
  2. package/dist/{adapters-uGz-UKQa.cjs → adapters-DvmtpdSF.cjs} +1 -1
  3. package/dist/{banner-DjujkctF.d.ts → banner-BMop1KLF.d.ts} +2 -2
  4. package/dist/{banner-DdSgCs4G.d.cts → banner-CVD0GugR.d.cts} +2 -2
  5. package/dist/{cache-CfRTUzWC.cjs → cache-CO4Dy2uQ.cjs} +1 -1
  6. package/dist/{cache-B0C2i0yP.mjs → cache-Dk53iOo6.mjs} +1 -1
  7. package/dist/chunk-BFSpntXv.mjs +6 -0
  8. package/dist/{chunk-Ds5LZdWN.cjs → chunk-D1Md3oWO.cjs} +1 -1
  9. package/dist/client/index.cjs +219 -172
  10. package/dist/client/index.d.cts +75 -9
  11. package/dist/client/index.d.ts +75 -9
  12. package/dist/client/index.js +119 -73
  13. package/dist/client/mdx.cjs +1 -1
  14. package/dist/client/mdx.d.cts +1 -1
  15. package/dist/client/mdx.d.ts +1 -1
  16. package/dist/client/mdx.js +1 -1
  17. package/dist/client/primitives.cjs +7 -7
  18. package/dist/client/primitives.d.cts +5 -22
  19. package/dist/client/primitives.d.ts +5 -22
  20. package/dist/client/primitives.js +4 -4
  21. package/dist/client/theme/reset.css +31 -4
  22. package/dist/{shiki-adapter-fS94vy-z.d.mts → config-BpzaPsJj.d.cts} +325 -78
  23. package/dist/config-CCXp3aXO.mjs +7 -0
  24. package/dist/{config-BxsogK5A.cjs → config-CMd4XoFq.cjs} +1 -1
  25. package/dist/config-DlGoEM9D.cjs +7 -0
  26. package/dist/{shiki-adapter-l2kEP5rn.d.cts → config-xtS0ZkMm.d.mts} +325 -78
  27. package/dist/{csp-BX06rvdg.cjs → csp-CRp_3U7a.cjs} +1 -1
  28. package/dist/csp-oTC2ygvF.mjs +6 -0
  29. package/dist/{docs-layout-DyLDBwS6.js → docs-layout-BdtZ9z6s.js} +9 -28
  30. package/dist/{docs-layout-D1buSdua.cjs → docs-layout-CFWI15Id.cjs} +69 -88
  31. package/dist/{doctor-DPDcRKM1.cjs → doctor-BBtmNJE0.cjs} +1 -1
  32. package/dist/doctor-Bv16QSrI.cjs +7 -0
  33. package/dist/doctor-DOAbSaiL.mjs +7 -0
  34. package/dist/{generator-BN75lJOv.cjs → generator-COepVWGi.cjs} +1 -1
  35. package/dist/{handler-Btd4t_67.mjs → handler-DzQae4eA.mjs} +1 -1
  36. package/dist/{handler-1LRMYeI4.cjs → handler-XX7cLTqe.cjs} +1 -1
  37. package/dist/headers-Ddwek8K7.mjs +6 -0
  38. package/dist/{headers-YpD10rDb.cjs → headers-dg4SDrjY.cjs} +1 -1
  39. package/dist/{image-5WsgWYTh.js → image-Bz87fCla.js} +1 -1
  40. package/dist/{image-Hb105Gu6.cjs → image-C4TlpMHn.cjs} +18 -18
  41. package/dist/link-2PzgTnaP.js +673 -0
  42. package/dist/{icons-dev-YtDoLUsb.cjs → link-D1Gjkb-2.cjs} +0 -350
  43. package/dist/{mdx-Bv-pS6-O.js → mdx-BuO6a1f7.js} +195 -40
  44. package/dist/{mdx-CDUcJmye.cjs → mdx-CD-tSjRG.cjs} +234 -73
  45. package/dist/{meta-loader-CTB62-Mo.cjs → meta-loader-Dq1zcFnh.cjs} +1 -1
  46. package/dist/node/cache.cjs +1 -1
  47. package/dist/node/cache.d.cts +2 -1
  48. package/dist/node/cache.d.mts +2 -1
  49. package/dist/node/cache.mjs +1 -1
  50. package/dist/node/cli-entry.cjs +6 -6
  51. package/dist/node/cli-entry.mjs +9 -9
  52. package/dist/node/index.cjs +1 -1
  53. package/dist/node/index.d.cts +20 -174
  54. package/dist/node/index.d.mts +18 -175
  55. package/dist/node/index.mjs +1 -1
  56. package/dist/node/mdx/shiki-adapter.cjs +1 -1
  57. package/dist/node/mdx/shiki-adapter.d.cts +49 -1
  58. package/dist/node/mdx/shiki-adapter.d.mts +49 -1
  59. package/dist/node/mdx/shiki-adapter.mjs +1 -1
  60. package/dist/node-B5hu_6qj.cjs +104 -0
  61. package/dist/node-BXtqM1uH.mjs +6 -0
  62. package/dist/node-C8725aw7.mjs +104 -0
  63. package/dist/node-aD1eisrR.cjs +6 -0
  64. package/dist/{package-_-Oa8-qN.cjs → package-CH2ChQqw.cjs} +1 -1
  65. package/dist/{package-CoHWTf0N.mjs → package-DSSB8B5L.mjs} +1 -1
  66. package/dist/{pages-external-CX2uyW95.cjs → pages-external-XkYIs-d5.cjs} +1 -1
  67. package/dist/parser-DCiEWkSk.cjs +8 -0
  68. package/dist/parser-qk9FIHJ7.mjs +8 -0
  69. package/dist/plugin-CX1OZ6jB.cjs +73 -0
  70. package/dist/plugin-CgfiWaFZ.mjs +73 -0
  71. package/dist/routes-BW6zsk7Z.mjs +6 -0
  72. package/dist/routes-BgoIB5wb.cjs +6 -0
  73. package/dist/{routes-D_S9kjkS.cjs → routes-CORVxc02.cjs} +1 -1
  74. package/dist/{search-dialog-BpNULmrl.cjs → search-dialog-B1NERUNx.cjs} +101 -55
  75. package/dist/{search-dialog-BbtxA1uT.cjs → search-dialog-BRFno7HD.cjs} +8 -8
  76. package/dist/{search-dialog-DC7oXU-5.js → search-dialog-BmxHiKwt.js} +2 -2
  77. package/dist/{search-dialog-gp9lrJXm.js → search-dialog-D6TvjcuV.js} +1 -1
  78. package/dist/{search-dialog-PJrFRU5G.js → search-dialog-DFnlx8LO.js} +44 -4
  79. package/dist/{search-dialog-BIuxGQsg.cjs → search-dialog-DHqwjJuG.cjs} +1 -1
  80. package/dist/server/index.cjs +1 -1
  81. package/dist/server/index.d.mts +1 -1
  82. package/dist/server/index.mjs +1 -1
  83. package/dist/shiki-adapter-CoQ6jyJ4.cjs +6 -0
  84. package/dist/shiki-adapter-D-aKw7PP.mjs +6 -0
  85. package/dist/{sidebar-DknLUI1R.d.ts → sidebar-COTaMHR-.d.ts} +349 -41
  86. package/dist/{sidebar-DH2iPKXM.d.cts → sidebar-CrEdJuHX.d.cts} +349 -41
  87. package/dist/{types-generator-CYcHkDzZ.cjs → types-generator-BXhv7Ill.cjs} +1 -1
  88. package/dist/types-generator-bDPvUztF.mjs +26 -0
  89. package/dist/utils-Crm9oPcV.mjs +7 -0
  90. package/dist/utils-D6Xtj0FZ.cjs +7 -0
  91. package/package.json +13 -10
  92. package/src/shared/types.ts +361 -19
  93. package/dist/chunk-hT5z_Zn9-DsJawvsz.mjs +0 -6
  94. package/dist/chunk-hT5z_Zn9-SKz6VFXu.cjs +0 -6
  95. package/dist/config-DAgpZyh6.mjs +0 -7
  96. package/dist/config-DrRQYDCI.cjs +0 -7
  97. package/dist/csp-z2D0FuRW.mjs +0 -6
  98. package/dist/doctor-BadGEhXv.cjs +0 -7
  99. package/dist/doctor-vDsUDgqp.mjs +0 -7
  100. package/dist/escape-string-regexp-AG8q1e25-9Un9V90q.mjs +0 -6
  101. package/dist/escape-string-regexp-AG8q1e25-bJ9Ixe7c.cjs +0 -6
  102. package/dist/esm-shims-DSep1HcR.mjs +0 -6
  103. package/dist/headers-CL0pMcwm.mjs +0 -6
  104. package/dist/icons-dev-CHZOwhQA.js +0 -921
  105. package/dist/lib-BR0SoanK-CLswltLI.cjs +0 -6
  106. package/dist/lib-BR0SoanK-DcYeDrE6.mjs +0 -6
  107. package/dist/lib-DPoCz1YB-CLYXwKST.cjs +0 -6
  108. package/dist/lib-DPoCz1YB-CyGOqgSO.mjs +0 -6
  109. package/dist/micromark-util-character-5KqJafVT-C6gnc770.cjs +0 -6
  110. package/dist/micromark-util-character-5KqJafVT-DkPKsbgn.mjs +0 -6
  111. package/dist/node-BDBv8CT6.mjs +0 -104
  112. package/dist/node-DFV_FV0y.mjs +0 -6
  113. package/dist/node-DqsP7kXz.cjs +0 -6
  114. package/dist/node-yFmAavND.cjs +0 -104
  115. package/dist/parser-BZJgAa9E.mjs +0 -8
  116. package/dist/parser-DlanzESE.cjs +0 -8
  117. package/dist/plugin-BVuwx5D9.cjs +0 -73
  118. package/dist/plugin-BoxD91Yh.mjs +0 -73
  119. package/dist/rehype-slug--ZOxZ-_K-BNeYC4aT.cjs +0 -6
  120. package/dist/rehype-slug--ZOxZ-_K-CjIQEJCs.mjs +0 -6
  121. package/dist/remark-frontmatter-wFYRLcCt-CutW0gA3.mjs +0 -8
  122. package/dist/remark-frontmatter-wFYRLcCt-ENB5qG3y.cjs +0 -8
  123. package/dist/remark-gfm-B8TMkQbX-CjUJo8Rd.cjs +0 -21
  124. package/dist/remark-gfm-B8TMkQbX-Ctu0VV1_.mjs +0 -21
  125. package/dist/rolldown-runtime-fkIsjY3S.mjs +0 -6
  126. package/dist/rollup-DMqoG11U-CKcJ37u_.mjs +0 -59
  127. package/dist/rollup-DMqoG11U-DKdxvZIj.cjs +0 -59
  128. package/dist/routes-BN2XbGcT.mjs +0 -6
  129. package/dist/routes-Cnq8xTCv.cjs +0 -6
  130. package/dist/shiki-adapter-CGTmrR6S.cjs +0 -6
  131. package/dist/shiki-adapter-CK3llqw2.mjs +0 -6
  132. package/dist/types-generator-DVOnRVKU.mjs +0 -26
  133. package/dist/utils-B3xYMrpK.mjs +0 -7
  134. package/dist/utils-Bz1tG9Dg.cjs +0 -7
  135. /package/dist/{errors-C0Hx15Ag.mjs → errors-0zGHRLue.mjs} +0 -0
  136. /package/dist/{errors-Dx6JHoKE.cjs → errors-vKw8CkiX.cjs} +0 -0
  137. /package/dist/{index-DJYJzs-Z.d.mts → index-1KsTDq4o.d.mts} +0 -0
  138. /package/dist/{meta-loader-Bq-MjTXB.mjs → meta-loader-C4Hu9RN9.mjs} +0 -0
@@ -186,6 +186,44 @@ export interface BoltdocsVersionConfig {
186
186
  path: string
187
187
  }
188
188
 
189
+ /**
190
+ * Configuration for content collections (e.g. blog posts, changelog)
191
+ * declared in `boltdocs.config.ts`. Each entry maps a directory name
192
+ * (e.g. `[blog]`) to its display + ordering settings.
193
+ */
194
+ export interface BoltdocsCollectionsConfig {
195
+ /**
196
+ * Map of collection id (matches the bracketed directory name) to
197
+ * its display label. Falls back to the id when a label is missing.
198
+ */
199
+ labels?: Record<string, string | Record<string, string>>
200
+ /**
201
+ * Map of collection id to a numeric position used for sidebar ordering.
202
+ * Collections with no explicit position are sorted last.
203
+ */
204
+ positions?: Record<string, number>
205
+ /**
206
+ * Items-per-page for paginated collection routes (e.g. blog indexes).
207
+ * Falls back to the framework default (10) when omitted.
208
+ */
209
+ postsPerPage?: number
210
+ /**
211
+ * Default collection ID used by collection routing when no collection
212
+ * is explicitly referenced. Defaults to `'blog'`.
213
+ */
214
+ defaultCollection?: string
215
+ /**
216
+ * Date format string for rendering post dates in listing pages.
217
+ * Defaults to `'MMMM dd, yyyy'`.
218
+ */
219
+ dateFormat?: string
220
+ /**
221
+ * Field used to sort posts within a collection.
222
+ * Defaults to `'date'`.
223
+ */
224
+ sortBy?: 'date' | 'title' | 'sidebarPosition'
225
+ }
226
+
189
227
  /**
190
228
  * Configuration for documentation versioning.
191
229
  */
@@ -212,6 +250,142 @@ export interface PluginContext {
212
250
  readonly rootDir: string
213
251
  readonly outDir: string
214
252
  readonly routes: RouteMeta[]
253
+ /** Namespaced cache helpers bound to the core's cache machinery. */
254
+ readonly caches: PluginCachesAPI
255
+ /** Structured diagnostics channel; reports can be drained via `list()`. */
256
+ readonly diagnostics: PluginDiagnosticsAPI
257
+ /** Helpers for resolving paths inside the workspace safely. */
258
+ readonly paths: PluginPathsAPI
259
+ /** Declare virtual modules the core should expose to Vite. */
260
+ readonly virtualModules: PluginVirtualModulesAPI
261
+ /** Register and query transform middleware at runtime. */
262
+ readonly middleware: PluginMiddlewareAPI
263
+ /**
264
+ * Hook into dev-server file watching and send custom HMR events
265
+ * to connected clients.
266
+ */
267
+ readonly hmr: PluginHmrAPI
268
+ /**
269
+ * Register HTTP middleware and server lifecycle hooks without
270
+ * writing a Vite plugin.
271
+ */
272
+ readonly server: PluginServerAPI
273
+ }
274
+
275
+ /**
276
+ * Functional cache helpers exposed through `PluginContext.caches`.
277
+ *
278
+ * Plugin authors do not get a reference to the raw `TransformCache` /
279
+ * `FileCache` instances — those stay encapsulated in core. The methods
280
+ * returned here are bound to namespaced keys so two plugins cannot
281
+ * collide.
282
+ */
283
+ export interface PluginCachesAPI {
284
+ /** Sharded, hash-keyed cache. One namespace per plugin recommended. */
285
+ transform(namespace: string): PluginTransformCacheAPI
286
+ /** Routes cache wrapper around the parsed-doc cache. */
287
+ routes: PluginRoutesCacheAPI
288
+ /** In-memory LRU cache keyed by namespace + plugin-supplied key. */
289
+ memory<V = unknown>(
290
+ namespace: string,
291
+ opts?: { max?: number; ttl?: number },
292
+ ): PluginMemoryCacheAPI<V>
293
+ }
294
+
295
+ export interface PluginTransformCacheAPI {
296
+ /** Async read — first call may warm from disk if the entry was evicted. */
297
+ get(key: string): Promise<string | null>
298
+ /** Synchronous write that batches a background disk flush. */
299
+ set(key: string, value: string): void
300
+ /** Force-flush background writes. Call before measuring disk state. */
301
+ flush(): Promise<void>
302
+ }
303
+
304
+ export interface PluginRoutesCacheAPI {
305
+ /** Read a parsed `RouteMeta` (and its private `_content` blob) by abs file path. */
306
+ get(filePath: string): RouteMeta | null
307
+ /** Write a parsed route entry. Caller assumptions match `docCache.set`. */
308
+ set(filePath: string, route: RouteMeta): void
309
+ /** Invalidate one route. Use when content changes. */
310
+ invalidate(filePath: string): void
311
+ /** Clear every cached route. Use when the directory layout changes. */
312
+ invalidateAll(): void
313
+ }
314
+
315
+ export interface PluginMemoryCacheAPI<V> {
316
+ get(key: string): V | undefined
317
+ set(key: string, value: V): void
318
+ has(key: string): boolean
319
+ }
320
+
321
+ /**
322
+ * Plugin diagnostics API.
323
+ *
324
+ * Plugins push structured records instead of spamming the logger; downstream
325
+ * tools (dev-server overlay, CI reporters, IDE plugins) drain the queue via
326
+ * `list()`.
327
+ */
328
+ export interface DiagnosticRecord {
329
+ readonly id: number
330
+ readonly severity: 'info' | 'warn' | 'error'
331
+ readonly code: string
332
+ readonly message: string
333
+ readonly pluginName: string
334
+ readonly filePath?: string
335
+ readonly routePath?: string
336
+ readonly time: Date
337
+ }
338
+
339
+ export interface PluginDiagnosticsAPI {
340
+ report(
341
+ severity: DiagnosticRecord['severity'],
342
+ code: string,
343
+ message: string,
344
+ where?: { filePath?: string; routePath?: string },
345
+ ): void
346
+ list(): readonly DiagnosticRecord[]
347
+ clear(): void
348
+ }
349
+
350
+ /**
351
+ * Path-resolution helpers exposed through `PluginContext.paths`.
352
+ *
353
+ * Both `resolveDocs` and `resolveAsset` validate the resulting path against
354
+ * the workspace boundary and reject any segment that resolves outside the
355
+ * docs / project root directories.
356
+ */
357
+ export interface PluginPathsAPI {
358
+ resolveDocs(...parts: string[]): string
359
+ resolveAsset(...parts: string[]): string
360
+ /**
361
+ * Build a `file://` URL for an absolute path inside the workspace.
362
+ * Useful for `new URL(import.meta.url)` replacements and image srcsets.
363
+ */
364
+ safeFileURL(absFilePath: string): string
365
+ }
366
+
367
+ /**
368
+ * Plugin virtual-modules registration.
369
+ *
370
+ * Plugins call `add(id, loader)` to expose a `virtual:<plugin>/<id>` module
371
+ * to Vite without having to author a full Vite plugin. The loader returns
372
+ * the module source code as a string; the core wraps it in the right
373
+ * `resolveId`/`load` plumbing at Vite build time.
374
+ */
375
+ export interface RegisteredVirtualModule {
376
+ readonly id: string
377
+ readonly eager: boolean
378
+ readonly loader: () => string | Promise<string>
379
+ }
380
+
381
+ export interface PluginVirtualModulesAPI {
382
+ add(
383
+ id: string,
384
+ loader: () => string | Promise<string>,
385
+ opts?: { eager?: boolean },
386
+ ): void
387
+ has(id: string): boolean
388
+ list(): readonly RegisteredVirtualModule[]
215
389
  }
216
390
 
217
391
  /**
@@ -242,6 +416,170 @@ export interface PluginMeta {
242
416
  boltdocsVersion?: string
243
417
  }
244
418
 
419
+ /**
420
+ * Chain control signal returned by transform hooks. Use with `__signal` in
421
+ * the return value to influence the middleware chain:
422
+ *
423
+ * - `'skip'`: stop processing this hook for the current file (remaining
424
+ * plugins in the chain still run).
425
+ * - `'break'`: stop the entire chain immediately — no further plugin's
426
+ * transform hooks run for this file.
427
+ *
428
+ * @example
429
+ * ```ts
430
+ * transformMdx: async (_ctx, { code }) => ({
431
+ * code: code.replace(/foo/g, 'bar'),
432
+ * __signal: 'skip', // skip remaining plugins
433
+ * })
434
+ * ```
435
+ */
436
+ export type ChainSignal = 'skip' | 'break'
437
+
438
+ /**
439
+ * Returned by a transform hook that wants to signal the chain. The `__signal`
440
+ * field is optional — most hooks will just return `{ code: string }` and the
441
+ * chain continues normally. When `__signal` is present, `runChain` reacts:
442
+ *
443
+ * - `'skip'` continues with the next plugin, but passes the **original params**
444
+ * (the output of this hook is discarded).
445
+ * - `'break'` stops the chain immediately.
446
+ *
447
+ * @template T The params shape (e.g. `{ code: string; filePath: string }`).
448
+ */
449
+ export type TransformResult<T> = T & { __signal?: ChainSignal }
450
+
451
+ /**
452
+ * Enriched params passed to `transformSource` and `transformMdx`. The `code`
453
+ * and `filePath` fields are always present. The optional `frontmatter` and
454
+ * `route` fields are populated when available (they are `undefined` in the
455
+ * early pipeline where frontmatter hasn't been parsed yet).
456
+ */
457
+ export interface TransformSourceParams {
458
+ /** The raw or compiled code (source before MDX / JS after MDX). */
459
+ code: string
460
+ /** Absolute file path of the source document. */
461
+ filePath: string
462
+ /** Parsed frontmatter, if available. `undefined` in very early pipeline. */
463
+ frontmatter?: Record<string, unknown>
464
+ }
465
+
466
+ /**
467
+ * Enriched params passed to `transformHtml`. The `html` and `path` fields
468
+ * are always present. The optional `route` carries the generated `RouteMeta`
469
+ * for richer context (locale, version, collection, etc.).
470
+ */
471
+ export interface TransformHtmlParams {
472
+ /** The rendered HTML string for this page. */
473
+ html: string
474
+ /** The route path (e.g. `/docs/guides/start`). */
475
+ path: string
476
+ /** The route metadata for the page, if available. */
477
+ route?: RouteMeta
478
+ }
479
+
480
+ /**
481
+ * Plugin transform middleware. Each middleware runs in the transform
482
+ * pipeline alongside lifecycle hooks. The `name` field is optional —
483
+ * when omitted, the owning plugin's name is used as context.
484
+ * Middleware runs in `enforce` order (pre → normal → post) and supports
485
+ * `__signal: 'skip'` / `__signal: 'break'` for chain control.
486
+ */
487
+ export interface PluginTransformMiddleware {
488
+ /** Optional name. Defaults to the owning plugin's name for diagnostics. */
489
+ name?: string
490
+ enforce?: 'pre' | 'post'
491
+ transformSource?: (
492
+ ctx: PluginContext,
493
+ params: TransformSourceParams,
494
+ ) =>
495
+ | TransformResult<{ code: string }>
496
+ | Promise<TransformResult<{ code: string }>>
497
+ transformMdx?: (
498
+ ctx: PluginContext,
499
+ params: TransformSourceParams,
500
+ ) =>
501
+ | TransformResult<{ code: string }>
502
+ | Promise<TransformResult<{ code: string }>>
503
+ transformHtml?: (
504
+ ctx: PluginContext,
505
+ params: TransformHtmlParams,
506
+ ) =>
507
+ | TransformResult<{ html: string }>
508
+ | Promise<TransformResult<{ html: string }>>
509
+ }
510
+
511
+ /**
512
+ * Plugin middleware registry API exposed through `PluginContext.middleware`.
513
+ * Plugins can register named middleware entries from lifecycle hooks.
514
+ */
515
+ export interface PluginMiddlewareAPI {
516
+ add(middleware: PluginTransformMiddleware): void
517
+ remove(name: string): void
518
+ has(name: string): boolean
519
+ list(): readonly PluginTransformMiddleware[]
520
+ }
521
+
522
+ /**
523
+ * HMR event types plugins can listen to.
524
+ */
525
+ export type PluginHmrEvent = 'add' | 'change' | 'unlink'
526
+
527
+ /**
528
+ * Plugin HMR API — hook into file-watching events and send custom
529
+ * HMR messages to connected clients.
530
+ */
531
+ export interface PluginHmrAPI {
532
+ /**
533
+ * Register a callback for file events scoped to the docs directory.
534
+ * The callback receives the normalized file path and event type.
535
+ */
536
+ onFileEvent(
537
+ eventType: PluginHmrEvent,
538
+ handler: (filePath: string) => void | Promise<void>,
539
+ ): void
540
+ /** Shorthand for `onFileEvent('add', handler)`. */
541
+ onFileAdd(handler: (filePath: string) => void | Promise<void>): void
542
+ /** Shorthand for `onFileEvent('change', handler)`. */
543
+ onFileChange(handler: (filePath: string) => void | Promise<void>): void
544
+ /** Shorthand for `onFileEvent('unlink', handler)`. */
545
+ onFileUnlink(handler: (filePath: string) => void | Promise<void>): void
546
+ /**
547
+ * Send a custom HMR event to all connected clients.
548
+ * The client can listen with `import.meta.hot.on('boltdocs:plugin:<name>', ...)`.
549
+ */
550
+ send(event: string, data?: unknown): void
551
+ }
552
+
553
+ /**
554
+ * Plugin Server API — register HTTP middleware and lifecycle hooks
555
+ * for the dev server and preview server, without writing a Vite plugin.
556
+ */
557
+ export interface PluginServerAPI {
558
+ /**
559
+ * Register a Connect-style middleware function.
560
+ * Runs on both dev and preview servers.
561
+ */
562
+ use(middleware: PluginServerMiddleware): void
563
+ /**
564
+ * Register a middleware scoped to a specific path prefix.
565
+ * Only requests starting with `path` trigger the handler.
566
+ */
567
+ useAt(path: string, handler: PluginServerMiddleware): void
568
+ /** Called when the dev/preview server starts (once per process). */
569
+ onStart(callback: () => void | Promise<void>): void
570
+ /** Called when the server shuts down (cleanup). */
571
+ onEnd(callback: () => void | Promise<void>): void
572
+ }
573
+
574
+ /**
575
+ * Connect-style middleware signature.
576
+ */
577
+ export type PluginServerMiddleware = (
578
+ req: import('http').IncomingMessage,
579
+ res: import('http').ServerResponse,
580
+ next: (err?: unknown) => void,
581
+ ) => void | Promise<void>
582
+
245
583
  /**
246
584
  * Plugin lifecycle hooks with full type safety.
247
585
  */
@@ -253,16 +591,22 @@ export interface PluginLifecycleHooks {
253
591
  buildEnd?: (ctx: PluginContext) => Promise<void> | void
254
592
  transformSource?: (
255
593
  ctx: PluginContext,
256
- params: { code: string; filePath: string },
257
- ) => Promise<{ code: string }> | { code: string }
594
+ params: TransformSourceParams,
595
+ ) =>
596
+ | TransformResult<{ code: string }>
597
+ | Promise<TransformResult<{ code: string }>>
258
598
  transformMdx?: (
259
599
  ctx: PluginContext,
260
- params: { code: string; filePath: string },
261
- ) => Promise<{ code: string }> | { code: string }
600
+ params: TransformSourceParams,
601
+ ) =>
602
+ | TransformResult<{ code: string }>
603
+ | Promise<TransformResult<{ code: string }>>
262
604
  transformHtml?: (
263
605
  ctx: PluginContext,
264
- params: { html: string; path: string },
265
- ) => Promise<{ html: string }> | { html: string }
606
+ params: TransformHtmlParams,
607
+ ) =>
608
+ | TransformResult<{ html: string }>
609
+ | Promise<TransformResult<{ html: string }>>
266
610
  }
267
611
 
268
612
  /**
@@ -288,23 +632,22 @@ export interface BoltdocsPlugin {
288
632
  rehypePlugins?: unknown[]
289
633
  vitePlugins?: VitePlugin[]
290
634
  components?: Record<string, string>
635
+ /** Optional runtime metadata exposed to client via useConfig().plugins[].metadata */
636
+ metadata?: Record<string, unknown>
637
+ /** Declarative transform middleware entries. */
638
+ middleware?: PluginTransformMiddleware[]
291
639
  /** Lifecycle hooks with full type safety */
292
640
  hooks?: PluginLifecycleHooks
293
641
  }
294
642
 
295
643
  /**
296
- * Configuration for the collections (blog) feature.
297
644
  */
298
- export interface BoltdocsCollectionsConfig {
299
- /** Number of posts per page in collection listing pages. Defaults to 10. */
300
- postsPerPage?: number
301
- /** The name of the default collection used by BlogList when none is specified. */
302
- defaultCollection?: string
303
- /** Date format string for rendering post dates (e.g., 'MMMM dd, yyyy'). */
304
- dateFormat?: string
305
- /** Field to sort posts by. Defaults to 'date'. */
306
- sortBy?: 'date' | 'title' | 'sidebarPosition'
307
- }
645
+
646
+ /**
647
+ */
648
+
649
+ /**
650
+ */
308
651
 
309
652
  export interface BoltdocsSecurityConfig {
310
653
  headers?: Record<string, string>
@@ -506,7 +849,6 @@ export type BoltdocsMdxComponents = Boltdocs.Types extends {
506
849
  MdxComponents: infer M
507
850
  }
508
851
  ? TransformMdxComponents<UnpackMdxComponents<M>>
509
- : {
510
- [key: string]: ComponentType<any>
852
+ : Omit<Record<string, ComponentType<any>>, 'Frontmatter'> & {
511
853
  Frontmatter: Record<string, ComponentType<any>>
512
854
  }
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),d=e(import.meta.url);export{u as i,c as n,d as r,s as t};
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- require(`./chunk-Ds5LZdWN.cjs`);let e=require(`node:module`);var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},u=(e,r,i)=>(i=e==null?{}:t(a(e)),l(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),d=(0,e.createRequire)(require(`url`).pathToFileURL(__filename).href);Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
@@ -1,7 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{r as t}from"./errors-C0Hx15Ag.mjs";import{t as n}from"./types-generator-DVOnRVKU.mjs";import r from"node:path";import i from"node:fs";import{z as a}from"zod";import{warn as o}from"@bdocs/dui";function s(e){return e}const c=a.object({icon:a.string().max(50),link:a.string().url()});a.object({text:a.string().max(2e3).optional()});const l=a.object({processor:a.enum([`unified`,`satteri`]).optional()}),u=a.object({name:a.string(),enforce:a.enum([`pre`,`post`]).optional(),version:a.string().optional(),boltdocsVersion:a.string().optional(),remarkPlugins:a.array(a.unknown()).optional(),rehypePlugins:a.array(a.unknown()).optional(),vitePlugins:a.array(a.unknown()).optional(),components:a.record(a.string(),a.string()).optional(),hooks:a.record(a.string(),a.unknown()).optional()}),d=a.object({title:a.union([a.string(),a.record(a.string(),a.string())]).optional(),description:a.union([a.string(),a.record(a.string(),a.string())]).optional(),logo:a.union([a.string(),a.object({dark:a.string(),light:a.string(),alt:a.string().optional(),width:a.number().optional(),height:a.number().optional()})]).optional(),navbar:a.array(a.object({label:a.union([a.string(),a.record(a.string(),a.string())]),href:a.string(),items:a.array(a.object({label:a.union([a.string(),a.record(a.string(),a.string())]),href:a.string()})).optional()})).optional(),sidebar:a.record(a.string(),a.array(a.object({text:a.string(),link:a.string()}))).optional(),sidebarGroups:a.record(a.string(),a.object({title:a.union([a.string(),a.record(a.string(),a.string())]).optional(),icon:a.string().optional()})).optional(),socialLinks:a.array(c).optional(),editLink:a.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:a.string().url().optional(),version:a.string().max(50).optional(),githubRepo:a.string().max(100).optional(),favicon:a.string().optional(),tabs:a.array(a.object({id:a.string(),text:a.union([a.string(),a.record(a.string(),a.string())]),icon:a.string().optional()})).optional(),codeTheme:a.union([a.string(),a.object({light:a.string(),dark:a.string()})]).optional()}),f=a.union([a.string(),a.object({rules:a.array(a.object({userAgent:a.string(),allow:a.union([a.string(),a.array(a.string())]).optional(),disallow:a.union([a.string(),a.array(a.string())]).optional()})).optional(),sitemaps:a.array(a.string().url()).optional()})]),p=a.object({defaultLocale:a.string(),locales:a.union([a.record(a.string(),a.string()),a.array(a.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:a.record(a.string(),a.object({label:a.string().optional(),direction:a.enum([`ltr`,`rtl`]).optional(),htmlLang:a.string().optional(),calendar:a.string().optional()})).optional()}),m=a.object({defaultVersion:a.string(),prefix:a.string().optional(),versions:a.array(a.object({label:a.string(),path:a.string()}))}),h=a.object({headers:a.record(a.string(),a.string()).optional(),enableCSP:a.boolean().optional(),customHeaders:a.record(a.string(),a.string()).optional()}),g=a.object({google:a.string().optional(),bing:a.string().optional(),yandex:a.string().optional(),pinterest:a.string().optional(),facebook:a.string().optional()}),_=a.object({metatags:a.record(a.string(),a.string()).optional(),indexing:a.enum([`all`,`public`]).optional(),thumbnails:a.object({background:a.string().optional()}).optional(),verification:g.optional()}),v=a.object({measurementId:a.string().min(1,`Measurement ID is required for GA4`),debug:a.boolean().optional(),anonymizeIp:a.boolean().optional(),sendPageView:a.boolean().optional(),cookieFlags:a.string().optional(),autoTrack:a.object({pageViews:a.boolean().optional(),downloads:a.boolean().optional(),externalLinks:a.boolean().optional(),search:a.boolean().optional()}).optional()}),y=a.object({tagId:a.string().min(1,`Tag ID is required for GTM`),dataLayerName:a.string().optional(),preview:a.string().optional()}),b=a.object({appId:a.string().min(1,`Algolia App ID is required`),apiKey:a.string().min(1,`Algolia API Key is required`),indexName:a.string().min(1,`Algolia Index Name is required`)}),x=a.object({repo:a.string().min(1,`Giscus repository is required`),repoId:a.string().min(1,`Giscus repository ID is required`),category:a.string().optional(),categoryId:a.string().optional(),mapping:a.enum([`pathname`,`url`,`title`,`og:title`,`specific`,`number`]).optional(),strict:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),reactionsEnabled:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),emitMetadata:a.union([a.enum([`0`,`1`]),a.boolean()]).optional(),inputPosition:a.enum([`top`,`bottom`]).optional(),theme:a.string().optional(),darkTheme:a.string().optional(),lang:a.string().optional(),loading:a.enum([`lazy`,`eager`]).optional()}),S=a.object({enabled:a.boolean(),owner:a.string().min(1,`GitHub owner is required`),repo:a.string().min(1,`GitHub repository name is required`),categorySlug:a.string().optional(),endpoint:a.string().optional()}),C=a.object({analytics:a.boolean().optional(),speedInsights:a.boolean().optional()}),w=a.object({apiKey:a.string().min(1,`API key is required for PostHog`),host:a.string().url().optional(),capturePageview:a.boolean().optional(),capturePageleave:a.boolean().optional(),sessionRecording:a.boolean().optional(),autocapture:a.boolean().optional()}),T=a.object({ga4:v.optional(),gtm:y.optional(),vercel:C.optional(),posthog:w.optional()}),E=a.object({algolia:b.optional()}),D=a.object({giscus:x.optional(),custom:S.optional()}),O=a.object({analytics:T.optional(),search:E.optional(),feedback:D.optional()}),k=a.object({visible:a.boolean().optional(),environments:a.array(a.string()).optional()}),A=a.object({siteUrl:a.string().url().optional(),docsDir:a.string().optional(),base:a.string().optional(),theme:d.optional(),i18n:p.optional(),versions:m.optional(),mdx:l.optional(),plugins:a.array(u).optional(),robots:f.optional(),security:h.optional(),seo:_.optional(),integrations:O.optional(),drafts:k.optional(),featureFlags:a.record(a.string(),a.union([a.boolean(),a.string()])).optional(),vite:a.record(a.string(),a.unknown()).optional()});var j=e({CONFIG_FILES:()=>M,defineConfig:()=>s,resolveConfig:()=>N,resolveConfigAndGenerateTypes:()=>P});const M=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function N(e,n=process.cwd()){let a=n,s={docsDir:r.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},c={};for(let e of M){let t=r.resolve(a,e);if(i.existsSync(t))try{let{loadConfigFromFile:e}=await import(`vite`),n=await e({command:`serve`,mode:`development`},t,a);if(n){c=n.config;break}}catch(t){t instanceof Error&&o(`Failed to load config from ${e}: ${t}`)}}let l={title:c.title,description:c.description,logo:c.logo,favicon:c.favicon,navbar:c.navbar,sidebar:c.sidebar,sidebarGroups:c.theme?.sidebarGroups,socialLinks:c.socialLinks,githubRepo:c.githubRepo,tabs:c.tabs,codeTheme:c.codeTheme,communityHelp:c.communityHelp,version:c.version,editLink:c.editLink,...c.theme||{}},u=Object.fromEntries(Object.entries(l).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||``,href:e.href||``,items:e.items}));let d={docsDir:r.resolve(e),theme:{...s.theme,...u},i18n:c.i18n?{...c.i18n,locales:Array.isArray(c.i18n.locales)?Object.fromEntries(c.i18n.locales.map(e=>[e,e])):c.i18n.locales}:void 0,versions:c.versions,siteUrl:c.siteUrl,base:c.base,seo:c.seo,plugins:c.plugins||[],robots:c.robots,security:c.security,integrations:c.integrations,vite:c.vite},f=A.safeParse(d);if(!f.success)throw new t(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
7
- `)}`);return f.data}async function P(e,t=process.cwd()){let r=await N(e,t);return n(r,e,t),r}export{s as a,u as i,j as n,N as r,M as t};
@@ -1,7 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./errors-Dx6JHoKE.cjs`),n=require(`./types-generator-CYcHkDzZ.cjs`);let r=require(`node:path`);r=e.n(r);let i=require(`node:fs`);i=e.n(i);let a=require(`zod`),o=require(`@bdocs/dui`);function s(e){return e}const c=a.z.object({icon:a.z.string().max(50),link:a.z.string().url()});a.z.object({text:a.z.string().max(2e3).optional()});const l=a.z.object({processor:a.z.enum([`unified`,`satteri`]).optional()}),u=a.z.object({name:a.z.string(),enforce:a.z.enum([`pre`,`post`]).optional(),version:a.z.string().optional(),boltdocsVersion:a.z.string().optional(),remarkPlugins:a.z.array(a.z.unknown()).optional(),rehypePlugins:a.z.array(a.z.unknown()).optional(),vitePlugins:a.z.array(a.z.unknown()).optional(),components:a.z.record(a.z.string(),a.z.string()).optional(),hooks:a.z.record(a.z.string(),a.z.unknown()).optional()}),d=a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),description:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),logo:a.z.union([a.z.string(),a.z.object({dark:a.z.string(),light:a.z.string(),alt:a.z.string().optional(),width:a.z.number().optional(),height:a.z.number().optional()})]).optional(),navbar:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string(),items:a.z.array(a.z.object({label:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),href:a.z.string()})).optional()})).optional(),sidebar:a.z.record(a.z.string(),a.z.array(a.z.object({text:a.z.string(),link:a.z.string()}))).optional(),sidebarGroups:a.z.record(a.z.string(),a.z.object({title:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]).optional(),icon:a.z.string().optional()})).optional(),socialLinks:a.z.array(c).optional(),editLink:a.z.string().refine(e=>!e||e.includes(`:path`),{message:`editLink must contain ':path' placeholder if specified`}).optional(),communityHelp:a.z.string().url().optional(),version:a.z.string().max(50).optional(),githubRepo:a.z.string().max(100).optional(),favicon:a.z.string().optional(),tabs:a.z.array(a.z.object({id:a.z.string(),text:a.z.union([a.z.string(),a.z.record(a.z.string(),a.z.string())]),icon:a.z.string().optional()})).optional(),codeTheme:a.z.union([a.z.string(),a.z.object({light:a.z.string(),dark:a.z.string()})]).optional()}),f=a.z.union([a.z.string(),a.z.object({rules:a.z.array(a.z.object({userAgent:a.z.string(),allow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional(),disallow:a.z.union([a.z.string(),a.z.array(a.z.string())]).optional()})).optional(),sitemaps:a.z.array(a.z.string().url()).optional()})]),p=a.z.object({defaultLocale:a.z.string(),locales:a.z.union([a.z.record(a.z.string(),a.z.string()),a.z.array(a.z.string())]).transform(e=>Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e),localeConfigs:a.z.record(a.z.string(),a.z.object({label:a.z.string().optional(),direction:a.z.enum([`ltr`,`rtl`]).optional(),htmlLang:a.z.string().optional(),calendar:a.z.string().optional()})).optional()}),m=a.z.object({defaultVersion:a.z.string(),prefix:a.z.string().optional(),versions:a.z.array(a.z.object({label:a.z.string(),path:a.z.string()}))}),h=a.z.object({headers:a.z.record(a.z.string(),a.z.string()).optional(),enableCSP:a.z.boolean().optional(),customHeaders:a.z.record(a.z.string(),a.z.string()).optional()}),g=a.z.object({google:a.z.string().optional(),bing:a.z.string().optional(),yandex:a.z.string().optional(),pinterest:a.z.string().optional(),facebook:a.z.string().optional()}),_=a.z.object({metatags:a.z.record(a.z.string(),a.z.string()).optional(),indexing:a.z.enum([`all`,`public`]).optional(),thumbnails:a.z.object({background:a.z.string().optional()}).optional(),verification:g.optional()}),v=a.z.object({measurementId:a.z.string().min(1,`Measurement ID is required for GA4`),debug:a.z.boolean().optional(),anonymizeIp:a.z.boolean().optional(),sendPageView:a.z.boolean().optional(),cookieFlags:a.z.string().optional(),autoTrack:a.z.object({pageViews:a.z.boolean().optional(),downloads:a.z.boolean().optional(),externalLinks:a.z.boolean().optional(),search:a.z.boolean().optional()}).optional()}),y=a.z.object({tagId:a.z.string().min(1,`Tag ID is required for GTM`),dataLayerName:a.z.string().optional(),preview:a.z.string().optional()}),b=a.z.object({appId:a.z.string().min(1,`Algolia App ID is required`),apiKey:a.z.string().min(1,`Algolia API Key is required`),indexName:a.z.string().min(1,`Algolia Index Name is required`)}),x=a.z.object({repo:a.z.string().min(1,`Giscus repository is required`),repoId:a.z.string().min(1,`Giscus repository ID is required`),category:a.z.string().optional(),categoryId:a.z.string().optional(),mapping:a.z.enum([`pathname`,`url`,`title`,`og:title`,`specific`,`number`]).optional(),strict:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),reactionsEnabled:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),emitMetadata:a.z.union([a.z.enum([`0`,`1`]),a.z.boolean()]).optional(),inputPosition:a.z.enum([`top`,`bottom`]).optional(),theme:a.z.string().optional(),darkTheme:a.z.string().optional(),lang:a.z.string().optional(),loading:a.z.enum([`lazy`,`eager`]).optional()}),S=a.z.object({enabled:a.z.boolean(),owner:a.z.string().min(1,`GitHub owner is required`),repo:a.z.string().min(1,`GitHub repository name is required`),categorySlug:a.z.string().optional(),endpoint:a.z.string().optional()}),C=a.z.object({analytics:a.z.boolean().optional(),speedInsights:a.z.boolean().optional()}),w=a.z.object({apiKey:a.z.string().min(1,`API key is required for PostHog`),host:a.z.string().url().optional(),capturePageview:a.z.boolean().optional(),capturePageleave:a.z.boolean().optional(),sessionRecording:a.z.boolean().optional(),autocapture:a.z.boolean().optional()}),T=a.z.object({ga4:v.optional(),gtm:y.optional(),vercel:C.optional(),posthog:w.optional()}),E=a.z.object({algolia:b.optional()}),D=a.z.object({giscus:x.optional(),custom:S.optional()}),O=a.z.object({analytics:T.optional(),search:E.optional(),feedback:D.optional()}),k=a.z.object({visible:a.z.boolean().optional(),environments:a.z.array(a.z.string()).optional()}),A=a.z.object({siteUrl:a.z.string().url().optional(),docsDir:a.z.string().optional(),base:a.z.string().optional(),theme:d.optional(),i18n:p.optional(),versions:m.optional(),mdx:l.optional(),plugins:a.z.array(u).optional(),robots:f.optional(),security:h.optional(),seo:_.optional(),integrations:O.optional(),drafts:k.optional(),featureFlags:a.z.record(a.z.string(),a.z.union([a.z.boolean(),a.z.string()])).optional(),vite:a.z.record(a.z.string(),a.z.unknown()).optional()}),j=[`boltdocs.config.js`,`boltdocs.config.mjs`,`boltdocs.config.ts`];async function M(e,n=process.cwd()){let a=n,s={docsDir:r.default.resolve(e),theme:{title:`Boltdocs`,description:`A Vite documentation framework`,navbar:[{label:`Home`,href:`/`},{label:`Documentation`,href:`/docs`}],codeTheme:{light:`github-light`,dark:`github-dark`}}},c={};for(let e of j){let t=r.default.resolve(a,e);if(i.default.existsSync(t))try{let{loadConfigFromFile:e}=await import(`vite`),n=await e({command:`serve`,mode:`development`},t,a);if(n){c=n.config;break}}catch(t){t instanceof Error&&(0,o.warn)(`Failed to load config from ${e}: ${t}`)}}let l={title:c.title,description:c.description,logo:c.logo,favicon:c.favicon,navbar:c.navbar,sidebar:c.sidebar,sidebarGroups:c.theme?.sidebarGroups,socialLinks:c.socialLinks,githubRepo:c.githubRepo,tabs:c.tabs,codeTheme:c.codeTheme,communityHelp:c.communityHelp,version:c.version,editLink:c.editLink,...c.theme||{}},u=Object.fromEntries(Object.entries(l).filter(([e,t])=>t!==void 0));u.navbar&&=u.navbar.map(e=>({label:e.label||``,href:e.href||``,items:e.items}));let d={docsDir:r.default.resolve(e),theme:{...s.theme,...u},i18n:c.i18n?{...c.i18n,locales:Array.isArray(c.i18n.locales)?Object.fromEntries(c.i18n.locales.map(e=>[e,e])):c.i18n.locales}:void 0,versions:c.versions,siteUrl:c.siteUrl,base:c.base,seo:c.seo,plugins:c.plugins||[],robots:c.robots,security:c.security,integrations:c.integrations,vite:c.vite},f=A.safeParse(d);if(!f.success)throw new t.r(`Invalid Boltdocs configuration:\n${f.error.issues.map(e=>` - ${e.path.join(`.`)}: ${e.message}`).join(`
7
- `)}`);return f.data}async function N(e,t=process.cwd()){let r=await M(e,t);return n.t(r,e,t),r}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return j}});
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";var t=e({getCSPHeader:()=>n});function n(e){let t=process.env.NODE_ENV===`development`,n={"default-src":[`'self'`],"script-src":[`'self'`,`'unsafe-inline'`],"style-src":[`'self'`,`'unsafe-inline'`],"img-src":[`'self'`,`data:`,`https:`],"font-src":[`'self'`],"connect-src":[`'self'`]};return t&&(n[`script-src`]=[`'self'`,`'unsafe-eval'`,`'unsafe-inline'`],n[`style-src`]=[`'self'`,`'unsafe-inline'`]),Object.entries(n).map(([e,t])=>`${e} ${t.join(` `)}`).join(`; `)}export{n,t};
@@ -1,7 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- const e=require(`./chunk-Ds5LZdWN.cjs`),t=require(`./utils-Bz1tG9Dg.cjs`),n=require(`./pages-external-CX2uyW95.cjs`),r=require(`./config-DrRQYDCI.cjs`),i=require(`./node/cli-entry.cjs`);let a=require(`node:path`);a=e.n(a);let o=require(`node:fs`);o=e.n(o);let s=require(`@bdocs/dui`),c=require(`fdir`),l=require(`picomatch`);l=e.n(l);let u=require(`fastest-levenshtein`);const d={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function f(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function p(e,t,n){return e.doctorConfig.severity[t]||n}async function m(e,t){o.default.existsSync(t)||o.default.mkdirSync(t,{recursive:!0});let n=a.default.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=a.default.join(t,`${n}.${r}.bak`);o.default.copyFileSync(e,i)}const h=new Map;function g(e){let n=h.get(e);if(n)return n;let r=(async()=>{let n=await t.d(e,!1);return{raw:n.raw,data:n.data,content:n.content}})();return h.set(e,r),r}const _=new Map;function v(e){if(_.has(e))return _.get(e);let t=!1;try{t=o.default.existsSync(e)&&o.default.statSync(e).isFile()}catch{t=!1}return _.set(e,t),t}async function y(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t))try{let e=JSON.parse(o.default.readFileSync(t,`utf-8`));return{...d,...e,checks:{...d.checks,...e.checks,metadata:{...d.checks.metadata,...e.checks?.metadata},links:{...d.checks.links,...e.checks?.links},i18n:{...d.checks.i18n,...e.checks?.i18n},performance:{...d.checks.performance,...e.checks?.performance,budgets:{...d.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...d.fix,...e.fix},reporting:{...d.reporting,...e.reporting},severity:{...d.severity,...e.severity},exclude:[...d.exclude,...e.exclude||[]]}}catch(e){(0,s.warn)(`Failed to parse doctor.json: ${e}`)}return d}async function b(e,r=process.cwd(),i,s){let l=a.default.resolve(r,`.boltdocs`,`generated`);o.default.existsSync(l)||o.default.mkdirSync(l,{recursive:!0});let u=s;u||=await new c.fdir().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let d=i?.base||`/docs`,f=[];for(let n=0;n<u.length;n+=100){let r=u.slice(n,n+100),i=await Promise.all(r.map(async n=>{let r=a.default.isAbsolute(n)?n:a.default.resolve(e,n),i=a.default.relative(e,r),{data:o}=await g(r),s;return s=o.permalink?o.permalink.startsWith(`/`)?o.permalink:`/${o.permalink}`:t.a(i),d===`/`?s:(d.endsWith(`/`)?d:d+`/`)+(s.startsWith(`/`)?s.substring(1):s)}));f.push(...i)}f.includes(d)||f.push(d);let p=n.t(e,i);for(let e of p)f.includes(e)||f.push(e);let m={routes:Array.from(new Set(f)).sort(),timestamp:Date.now()};return o.default.writeFileSync(a.default.resolve(l,`link-tree.json`),JSON.stringify(m,null,2)),m}function x(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-(0,u.distance)(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-(0,u.distance)(e,t)/Math.max(e.length,t.length)}const S=new Map;function C(e,t){if(S.has(e))return S.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=x(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return S.set(e,a),a}async function w(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:i,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let c of e.files){let l=t.u(a.default.relative(e.docsDir,c));try{let{raw:a,data:u}=await g(c);if(a.trim().startsWith(`---`)&&a.split(`---`).length>=3&&Object.keys(u).length===0){let t=p(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t._.safeParse(u);if(!d.success){let t=p(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:l,level:t,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let t of f)if(u[t]===void 0){let r=p(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:l,level:r,message:`Missing required frontmatter field: "${t}".`,suggestion:`Add the "${t}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let t=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of t)if(u[r]&&Number.isNaN(Date.parse(String(u[r])))){let t=p(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:l,level:t,message:`Invalid date format in field "${r}": "${u[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(u.title){let t=String(u.title);if(t.length<r){let i=p(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:l,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>i){let r=p(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:l,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${i} characters.`})}let a=s.get(t)||[];a.push(l),s.set(t,a)}if(u.description&&String(u.description).length<o){let t=p(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:l,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=p(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:l,level:r,message:`Malformed frontmatter (YAML error): ${t.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[t,r]of s.entries())if(r.length>1){let i=p(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)n.push({file:e,level:i,message:`Duplicate title found: "${t}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return n}async function T(e){let n=[],{internal:r,external:i,ignore:c,timeout:l,concurrency:u}=e.doctorConfig.checks.links;if(!r&&!i&&!e.options.checkExternal)return n;let d=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,m=5e5;for(let s of e.files){let l=t.u(a.default.relative(e.docsDir,s)),{content:u}=await g(s),_=[...(u.length>m?u.slice(0,m):u).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(d)];for(let t of _){let u=t[1]||t[2],d=!!t[1];if(!u||c.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(i||e.options.checkExternal)&&f.add({url:u,file:s});continue}if(!r||/^(mailto|tel|#)/i.test(u))continue;let m;try{m=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{m=u.split(`#`)[0].split(`?`)[0]}if(!m)continue;let g=!1,_=``;if(m.startsWith(`/`))if(e.routeIndex.has(m)||e.routeIndexWithSlash.has(m)||e.routeIndexWithoutSlash.has(m))g=!0;else{let t=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))g=!1,_=t;else{let t=e.config.base!==`/`&&m.startsWith(e.config.base||`/`)?m.substring((e.config.base||`/`).length):m,n=t.startsWith(`/`)?t.substring(1):t;_=a.default.join(e.docsDir,n),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e))}}else _=a.default.resolve(a.default.dirname(s),m),g=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>v(_+e));if(!g){let{bestMatch:t,similarity:r}=C(m,e.linkTree.routes),i=!1,a=e.basePrefix+(m.startsWith(`/`)?m:`/`+m);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(t=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&t!==m||i,g=p(e,`brokenLink`,`high`);g!==`off`&&n.push({file:l,level:g,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${t}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,n=d?`(${u})`:`href="${u}"`,r=d?`(${t}${e})`:`href="${t}${e}"`,i=o.default.readFileSync(s,`utf-8`).replace(n,r);o.default.writeFileSync(s,i),h.delete(s)}:void 0})}}}if(f.size>0){(0,s.info)(s.colors.gray(`Verifying ${f.size} external links...`));let r=new Map;for(let e of f)r.has(e.url)||r.set(e.url,[]),r.get(e.url).push(e.file);let i=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),l),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},o=Array.from(r.keys()),c=[];for(let e=0;e<o.length;e+=u){let t=o.slice(e,e+u),n=await Promise.allSettled(t.map(i));c.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let i of c)if(!i.ok){let o=p(e,`brokenLink`,`warning`);if(o!==`off`){let s=r.get(i.url)||[];for(let r of s)n.push({file:t.u(a.default.relative(e.docsDir,r)),level:o,message:`Broken external link: "${i.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${i.error||`Status >= 400`}`})}}}return n}async function E(e){let n=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return n;let{defaultLocale:r,locales:i}=e.config.i18n,s=Object.keys(i),c=s.filter(e=>e!==r);for(let i of e.files){let l=t.u(a.default.relative(e.docsDir,i)),u=l.split(`/`),d=u[0];if(d===r){let t=u.slice(1).join(`/`);for(let r of c){let s=a.default.join(e.docsDir,r,t);if(!v(s)){let c=p(e,`missingTranslation`,`warning`);c!==`off`&&n.push({file:l,level:c,message:`Missing translation for locale "${r}"`,suggestion:`Create a version at "${r}/${t}".`,fix:async()=>{let e=a.default.dirname(s);o.default.existsSync(e)||o.default.mkdirSync(e,{recursive:!0}),o.default.copyFileSync(i,s)}})}}}else if(s.includes(d)){let t=u.slice(1).join(`/`);if(!v(a.default.join(e.docsDir,r,t))){let a=p(e,`missingTranslation`,`low`);a!==`off`&&n.push({file:l,level:a,message:`Orphaned translation (source missing in "${r}")`,suggestion:`Remove this file or create the source at "${r}/${t}".`,fix:async()=>{o.default.unlinkSync(i)}})}}}return n}async function D(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=p(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=C(r.link,e.linkTree.routes),a=i>.6,o=p(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=p(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function O(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=a.default.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!o.default.existsSync(r))return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(o.default.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:p(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let s=n.budgets,c=p(e,`budgetExceeded`,`warning`),l=f(s?.maxJSBundleSize,1/0),u=f(s?.maxCSSBundleSize,1/0),d=f(s?.maxPageHTMLSize,1/0),m=s?.maxImagesKB??1/0,h=s?.maxBuildTime??1/0,g=s?.maxFontCount??1/0;if(l!==1/0&&i.totalJSBundleSize>l){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(l/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&i.totalCSSBundleSize>u){let e=(i.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of i.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:c,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let _=m*1024;if(m!==1/0&&i.totalImagesSize>_){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:c,message:`Image assets exceed budget: ${e}kb > ${m}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(h!==1/0&&i.buildTime>h){let e=(i.buildTime/1e3).toFixed(1),n=(h/1e3).toFixed(1);t.push({file:`(build)`,level:c,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return g!==1/0&&i.fontCount>g&&t.push({file:`(build)`,level:c,message:`Font files exceed budget: ${i.fontCount} > ${g}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}async function k(e){let t=a.default.resolve(e,`doctor.json`);if(o.default.existsSync(t)){(0,s.warn)(`"doctor.json" already exists at ${e}.`);return}try{o.default.writeFileSync(t,JSON.stringify(d,null,2)),(0,s.success)(`Created "doctor.json" with default configuration.`)}catch(e){(0,s.error)(`Failed to create "doctor.json": ${e}`)}}async function A(e=process.cwd(),t={}){if(t.init){await k(e);return}i.t();try{let n=await y(e),{format:i}=n.reporting,u=performance.now(),d=await r.n(`docs`,e),f=a.default.resolve(e,`docs`);o.default.existsSync(f)||(i===`pretty`&&(0,s.error)(`Docs dir not found at ${f}`),process.exit(1)),i===`pretty`&&console.log((0,s.double)([` ${s.colors.dim(`Docs dir:`)} ${f}`,` ${s.colors.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),i===`pretty`&&(0,s.info)(s.colors.dim(`🔍 Discovering files and routes...`));let p=(0,l.default)(n.exclude||[]),h=await new c.fdir().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=a.default.relative(f,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!p(t)&&!n}).crawl(f).withPromise();for(let e of h)_.set(e,!0);let g=await b(f,e,d,h),v=d.base||`/`,x=v===`/`?``:v.endsWith(`/`)?v.slice(0,-1):v,S={root:e,docsDir:f,config:d,doctorConfig:n,linkTree:g,files:h,options:t,routeIndex:new Set(g.routes),routeIndexWithSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(g.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:x};i===`pretty`&&(0,s.info)(s.colors.dim(`🧪 Running diagnostic checks in parallel...`));let C=[w(S),T(S),E(S),D(S)];t.budget&&C.push(O(S));let[k,A,j,M,...N]=await Promise.all(C),P=t.budget?N[0]:[],F=[...k,...A,...j,...M,...P];if(i===`pretty`){let e=[{label:`Metadata checks ${k.length>0?`— ${k.length} issue${k.length===1?``:`s`}`:`— OK`}`,done:k.length===0},{label:`Link checks ${A.length>0?`— ${A.length} issue${A.length===1?``:`s`}`:`— OK`}`,done:A.length===0},{label:`i18n checks ${j.length>0?`— ${j.length} issue${j.length===1?``:`s`}`:`— OK`}`,done:j.length===0},{label:`Sidebar checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0}];t.budget&&e.push({label:`Performance budget ${P.length>0?`— ${P.length} issue${P.length===1?``:`s`}`:`— OK`}`,done:P.length===0}),console.log(`\n${(0,s.tasks)(e)}`)}let I=0;if(t.fix){for(let e of F)if(e.fix){if(S.doctorConfig.fix.confirmChanges&&!await(0,s.confirm)(`Fix issue in "${e.file}": ${e.message}?`))continue;if(S.doctorConfig.fix.backupFiles){let t=a.default.resolve(S.docsDir,e.file);o.default.existsSync(t)&&await m(t,a.default.resolve(S.root,S.doctorConfig.fix.backupPath))}await e.fix(),I++}}let L=((performance.now()-u)/1e3).toFixed(2),R=F.filter(e=>e.level===`high`).length,z=F.filter(e=>e.level===`warning`).length,B=F.filter(e=>e.level===`low`).length,V={summary:{total:F.length,high:R,warning:z,low:B,fixed:I,duration:L},issues:F.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=a.default.resolve(e,n.reporting.outputFile);o.default.existsSync(a.default.dirname(t))||o.default.mkdirSync(a.default.dirname(t),{recursive:!0}),o.default.writeFileSync(t,JSON.stringify(V,null,2))}if(i===`json`)console.log(JSON.stringify(V,null,2));else if(i===`pretty`){let e=F.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(F.length>0){(0,s.dividerLog)();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?s.colors.red:n.level===`warning`?s.colors.yellow:s.colors.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${s.colors.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${s.colors.green(`✅ Fixed automatically`)}`)}console.log(`\n${(0,s.single)(e,{title:`📄 ${n}`})}`)}(0,s.dividerLog)()}if(F.length===0)console.log((0,s.round)([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];R>0&&e.push(s.colors.red(`${R} Critical Error${R===1?``:`s`}`)),z>0&&e.push(s.colors.yellow(`${z} Warning${z===1?``:`s`}`)),B>0&&e.push(s.colors.blue(`${B} Improvement${B===1?``:`s`}`));let t=[...(0,s.bullet)(e).split(`
7
- `).map(e=>e.trimStart()),``,s.colors.dim(`Scanned ${h.length} file${h.length===1?``:`s`} in ${L}s`)];console.log(`\n${(0,s.double)(t,{title:`Diagnosis Results`})}\n`),I>0&&(0,s.success)(`Successfully fixed ${I} issues automatically!`),R>0?(0,s.error)(`Please fix the critical errors before building for production.`):(0,s.success)(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&R>0&&process.exit(1),n.reporting.maxWarnings!==-1&&z>n.reporting.maxWarnings&&(i===`pretty`&&(0,s.error)(`Failed: Too many warnings (${z} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){(0,s.error)(`Doctor failed: ${e}`),process.exit(1)}}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return d}});
@@ -1,7 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";import{_ as t,a as n,d as r,u as i}from"./utils-B3xYMrpK.mjs";import{t as a}from"./pages-external-BYa4JSda.mjs";import{r as o}from"./config-DAgpZyh6.mjs";import{t as s}from"./node/cli-entry.mjs";import c from"node:path";import l from"node:fs";import{bullet as u,colors as d,confirm as f,dividerLog as p,double as m,error as h,info as g,round as _,single as v,success as y,tasks as b,warn as x}from"@bdocs/dui";import{fdir as S}from"fdir";import C from"picomatch";import{distance as w}from"fastest-levenshtein";const T={$schema:`https://boltdocs.vercel.app/schemas/doctor-config.schema.json`,checks:{metadata:{enabled:!0,titleMin:10,titleMax:60,descriptionMin:50,required:[`title`,`description`],optional:[],validateDates:!1},links:{internal:!0,external:!1,timeout:1e4,concurrency:10,ignore:[]},i18n:{enabled:!0},performance:{enabled:!0,budgets:{maxJSBundleSize:`200kb`,maxCSSBundleSize:`30kb`,maxPageHTMLSize:`80kb`,maxImagesKB:500,maxBuildTime:3e4,maxFontCount:3}}},fix:{confirmChanges:!1,backupFiles:!1,backupPath:`.boltdocs/backups`},reporting:{format:`pretty`,outputFile:`.boltdocs/reports/doctor.json`,failOnError:!1,maxWarnings:-1},severity:{missingTranslation:`warning`,brokenLink:`high`,brokenAnchor:`warning`,largeFile:`warning`,orphanedPage:`low`,duplicateTitle:`low`,shortMetadata:`low`,missingMetadata:`warning`,malformedFrontmatter:`high`,invalidFrontmatter:`high`,budgetExceeded:`warning`},exclude:[]};function E(e,t){if(e==null)return t;if(typeof e==`number`)return e;let n=e.toLowerCase().match(/^(\d+(?:\.\d+)?)\s*(b|kb|mb|gb)?$/);if(!n)return t;let r=Number.parseFloat(n[1]),i=n[2]||`b`;return Math.round(r*({b:1,kb:1024,mb:1024*1024,gb:1024*1024*1024}[i]||1))}function D(e,t,n){return e.doctorConfig.severity[t]||n}async function O(e,t){l.existsSync(t)||l.mkdirSync(t,{recursive:!0});let n=c.basename(e),r=new Date().toISOString().replace(/[:.]/g,`-`),i=c.join(t,`${n}.${r}.bak`);l.copyFileSync(e,i)}const k=new Map;function A(e){let t=k.get(e);if(t)return t;let n=(async()=>{let t=await r(e,!1);return{raw:t.raw,data:t.data,content:t.content}})();return k.set(e,n),n}const j=new Map;function M(e){if(j.has(e))return j.get(e);let t=!1;try{t=l.existsSync(e)&&l.statSync(e).isFile()}catch{t=!1}return j.set(e,t),t}async function N(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t))try{let e=JSON.parse(l.readFileSync(t,`utf-8`));return{...T,...e,checks:{...T.checks,...e.checks,metadata:{...T.checks.metadata,...e.checks?.metadata},links:{...T.checks.links,...e.checks?.links},i18n:{...T.checks.i18n,...e.checks?.i18n},performance:{...T.checks.performance,...e.checks?.performance,budgets:{...T.checks.performance?.budgets,...e.checks?.performance?.budgets}}},fix:{...T.fix,...e.fix},reporting:{...T.reporting,...e.reporting},severity:{...T.severity,...e.severity},exclude:[...T.exclude,...e.exclude||[]]}}catch(e){x(`Failed to parse doctor.json: ${e}`)}return T}async function P(e,t=process.cwd(),r,i){let o=c.resolve(t,`.boltdocs`,`generated`);l.existsSync(o)||l.mkdirSync(o,{recursive:!0});let s=i;s||=await new S().withFullPaths().filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)).crawl(e).withPromise();let u=r?.base||`/docs`,d=[];for(let t=0;t<s.length;t+=100){let r=s.slice(t,t+100),i=await Promise.all(r.map(async t=>{let r=c.isAbsolute(t)?t:c.resolve(e,t),i=c.relative(e,r),{data:a}=await A(r),o;return o=a.permalink?a.permalink.startsWith(`/`)?a.permalink:`/${a.permalink}`:n(i),u===`/`?o:(u.endsWith(`/`)?u:u+`/`)+(o.startsWith(`/`)?o.substring(1):o)}));d.push(...i)}d.includes(u)||d.push(u);let f=a(e,r);for(let e of f)d.includes(e)||d.push(e);let p={routes:Array.from(new Set(d)).sort(),timestamp:Date.now()};return l.writeFileSync(c.resolve(o,`link-tree.json`),JSON.stringify(p,null,2)),p}function F(e,t){if(e===t)return 1;if(!e||!t)return 0;let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=n[n.length-1]||``,a=r[r.length-1]||``;if(i===a){let e=0;for(let t of n)r.includes(t)&&e++;return e>=2?.99:.9}if(i.length>3&&a.length>3&&(a.startsWith(i)||i.startsWith(a))&&Math.min(i.length,a.length)/Math.max(i.length,a.length)>.5)return .88;let o=1-w(i,a)/Math.max(i.length,a.length);return o>.8?o*.95:1-w(e,t)/Math.max(e.length,t.length)}const I=new Map;function L(e,t){if(I.has(e))return I.get(e);let n=e.length,r=``,i=0;for(let a of t){if(a===e)continue;let t=a.length,o=Math.max(n,t);if(o===0)continue;let s=1-Math.abs(n-t)/o;if(s<=.8&&s<=i)continue;let c=F(e,a);c>i&&(i=c,r=a)}let a={bestMatch:r,similarity:i};return I.set(e,a),a}async function R(e){let n=[];if(!e.doctorConfig.checks.metadata.enabled)return n;let{titleMin:r,titleMax:a,descriptionMin:o}=e.doctorConfig.checks.metadata,s=new Map;for(let l of e.files){let u=i(c.relative(e.docsDir,l));try{let{raw:i,data:c}=await A(l);if(i.trim().startsWith(`---`)&&i.split(`---`).length>=3&&Object.keys(c).length===0){let t=D(e,`malformedFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Malformed frontmatter (YAML parsing failed).`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}let d=t.safeParse(c);if(!d.success){let t=D(e,`invalidFrontmatter`,`high`);if(t!==`off`)for(let e of d.error.issues)n.push({file:u,level:t,message:`Invalid frontmatter field "${e.path.join(`.`)}": ${e.message}`,suggestion:`Ensure the field follows the correct type.`})}let f=Array.from(new Set([`title`,...e.doctorConfig.checks.metadata.required]));for(let t of f)if(c[t]===void 0){let r=D(e,`missingMetadata`,`warning`);r!==`off`&&n.push({file:u,level:r,message:`Missing required frontmatter field: "${t}".`,suggestion:`Add the "${t}" field to your frontmatter.`})}if(e.doctorConfig.checks.metadata.validateDates){let t=[`date`,`lastUpdated`,...e.doctorConfig.checks.metadata.optional.filter(e=>e.toLowerCase().includes(`date`))];for(let r of t)if(c[r]&&Number.isNaN(Date.parse(String(c[r])))){let t=D(e,`invalidFrontmatter`,`high`);t!==`off`&&n.push({file:u,level:t,message:`Invalid date format in field "${r}": "${c[r]}".`,suggestion:`Use a valid ISO date format (e.g., YYYY-MM-DD).`})}}if(c.title){let t=String(c.title);if(t.length<r){let i=D(e,`shortMetadata`,`low`);i!==`off`&&n.push({file:u,level:i,message:`Title is too short (${t.length} chars).`,suggestion:`Titles should be at least ${r} characters for better SEO.`})}else if(t.length>a){let r=D(e,`shortMetadata`,`low`);r!==`off`&&n.push({file:u,level:r,message:`Title is too long (${t.length} chars).`,suggestion:`Titles should be under ${a} characters.`})}let i=s.get(t)||[];i.push(u),s.set(t,i)}if(c.description&&String(c.description).length<o){let t=D(e,`shortMetadata`,`low`);t!==`off`&&n.push({file:u,level:t,message:`Description is very short.`,suggestion:`Descriptions should ideally be at least ${o} characters.`})}}catch(t){if(t instanceof Error){let r=D(e,`malformedFrontmatter`,`high`);r!==`off`&&n.push({file:u,level:r,message:`Malformed frontmatter (YAML error): ${t.message}`,suggestion:`Check your YAML syntax for indentation or unquoted special characters.`})}}}for(let[t,r]of s.entries())if(r.length>1){let i=D(e,`duplicateTitle`,`low`);if(i!==`off`)for(let e of r)n.push({file:e,level:i,message:`Duplicate title found: "${t}"`,suggestion:`Ensure each page has a unique title. Also used in: ${r.filter(t=>t!==e).join(`, `)}`})}return n}async function z(e){let t=[],{internal:n,external:r,ignore:a,timeout:o,concurrency:s}=e.doctorConfig.checks.links;if(!n&&!r&&!e.options.checkExternal)return t;let u=/(?:\[.*?\]\((.*?)\))|(?:href=["']([^"']+)["'])/g,f=new Set,p=5e5;for(let o of e.files){let s=i(c.relative(e.docsDir,o)),{content:d}=await A(o),m=[...(d.length>p?d.slice(0,p):d).replace(/```[\s\S]*?```/g,``).replace(/`[^`\n]*`/g,``).matchAll(u)];for(let i of m){let u=i[1]||i[2],d=!!i[1];if(!u||a.some(e=>u.includes(e)))continue;if(/^https?:\/\//i.test(u)){(r||e.options.checkExternal)&&f.add({url:u,file:o});continue}if(!n||/^(mailto|tel|#)/i.test(u))continue;let p;try{p=decodeURIComponent(u.split(`#`)[0].split(`?`)[0])}catch{p=u.split(`#`)[0].split(`?`)[0]}if(!p)continue;let m=!1,h=``;if(p.startsWith(`/`))if(e.routeIndex.has(p)||e.routeIndexWithSlash.has(p)||e.routeIndexWithoutSlash.has(p))m=!0;else{let t=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);if(e.routeIndex.has(t)||e.routeIndexWithSlash.has(t))m=!1,h=t;else{let t=e.config.base!==`/`&&p.startsWith(e.config.base||`/`)?p.substring((e.config.base||`/`).length):p,n=t.startsWith(`/`)?t.substring(1):t;h=c.join(e.docsDir,n),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e))}}else h=c.resolve(c.dirname(o),p),m=[``,`.md`,`.mdx`,`/index.md`,`/index.mdx`].some(e=>M(h+e));if(!m){let{bestMatch:n,similarity:r}=L(p,e.linkTree.routes),i=!1,a=e.basePrefix+(p.startsWith(`/`)?p:`/`+p);(e.routeIndex.has(a)||e.routeIndexWithSlash.has(a))&&(n=a,r=1,i=!0);let c=r>.6||i,f=r>.75&&n!==p||i,m=D(e,`brokenLink`,`high`);m!==`off`&&t.push({file:s,level:m,message:`Broken internal link: "${u}"`,suggestion:c?`Did you mean "${n}"?`:`Ensure the target exists or check for typos.`,fix:f?async()=>{let e=u.includes(`#`)?`#`+u.split(`#`)[1]:``,t=d?`(${u})`:`href="${u}"`,r=d?`(${n}${e})`:`href="${n}${e}"`,i=l.readFileSync(o,`utf-8`).replace(t,r);l.writeFileSync(o,i),k.delete(o)}:void 0})}}}if(f.size>0){g(d.gray(`Verifying ${f.size} external links...`));let n=new Map;for(let e of f)n.has(e.url)||n.set(e.url,[]),n.get(e.url).push(e.file);let r=async e=>{try{let t=new AbortController,n=setTimeout(()=>t.abort(),o),r=await fetch(e,{method:`HEAD`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}});return clearTimeout(n),!r.ok&&r.status!==404?{url:e,ok:(await fetch(e,{method:`GET`,signal:t.signal,headers:{"User-Agent":`boltdocs-doctor/1.0`}})).ok}:{url:e,ok:r.ok}}catch(t){return{url:e,ok:!1,error:t.message}}},a=Array.from(n.keys()),l=[];for(let e=0;e<a.length;e+=s){let t=a.slice(e,e+s),n=await Promise.allSettled(t.map(r));l.push(...n.map(e=>e.status===`fulfilled`?e.value:{url:`unknown`,ok:!1,error:e.reason}))}for(let r of l)if(!r.ok){let a=D(e,`brokenLink`,`warning`);if(a!==`off`){let o=n.get(r.url)||[];for(let n of o)t.push({file:i(c.relative(e.docsDir,n)),level:a,message:`Broken external link: "${r.url}"`,suggestion:`Verify the URL or update it if it's permanently down. Error: ${r.error||`Status >= 400`}`})}}}return t}async function B(e){let t=[];if(!e.doctorConfig.checks.i18n.enabled||!e.config.i18n)return t;let{defaultLocale:n,locales:r}=e.config.i18n,a=Object.keys(r),o=a.filter(e=>e!==n);for(let r of e.files){let s=i(c.relative(e.docsDir,r)),u=s.split(`/`),d=u[0];if(d===n){let n=u.slice(1).join(`/`);for(let i of o){let a=c.join(e.docsDir,i,n);if(!M(a)){let o=D(e,`missingTranslation`,`warning`);o!==`off`&&t.push({file:s,level:o,message:`Missing translation for locale "${i}"`,suggestion:`Create a version at "${i}/${n}".`,fix:async()=>{let e=c.dirname(a);l.existsSync(e)||l.mkdirSync(e,{recursive:!0}),l.copyFileSync(r,a)}})}}}else if(a.includes(d)){let i=u.slice(1).join(`/`);if(!M(c.join(e.docsDir,n,i))){let a=D(e,`missingTranslation`,`low`);a!==`off`&&t.push({file:s,level:a,message:`Orphaned translation (source missing in "${n}")`,suggestion:`Remove this file or create the source at "${n}/${i}".`,fix:async()=>{l.unlinkSync(r)}})}}}return t}async function V(e){let t=[];if(!e.config.theme.sidebar)return t;let n=new Set,r=e.config.theme.sidebar;for(let[i,a]of Object.entries(r))for(let r of a){if(!r.text){let n=D(e,`invalidFrontmatter`,`warning`);n!==`off`&&t.push({file:`boltdocs.config.ts`,level:n,message:`Sidebar item in group "${i}" is missing a label.`,suggestion:`Add a "text" property to the sidebar item.`})}if(r.link&&(n.add(r.link),!e.routeIndex.has(r.link))){let{bestMatch:n,similarity:i}=L(r.link,e.linkTree.routes),a=i>.6,o=D(e,`brokenLink`,`high`);o!==`off`&&t.push({file:`boltdocs.config.ts`,level:o,message:`Broken sidebar link: "${r.link}"`,suggestion:a?`Did you mean "${n}"?`:`Ensure the route exists and is correctly formatted.`})}}for(let r of e.linkTree.routes)if(!(r===`/`||r===``)&&!n.has(r)){let n=D(e,`orphanedPage`,`low`);n!==`off`&&t.push({file:`Sidebar`,level:n,message:`Orphaned page found: "${r}" is not linked in the sidebar.`,suggestion:`Consider adding it to the sidebar for better discoverability.`})}return t}async function H(e){let t=[],n=e.doctorConfig.checks.performance;if(!n?.enabled)return t;let r=c.resolve(e.root,`.boltdocs`,`reports`,`performance.json`);if(!l.existsSync(r))return t.push({file:`(build)`,level:D(e,`budgetExceeded`,`warning`),message:"Performance metrics not found. Run `boltdocs build` first."}),t;let i;try{i=JSON.parse(l.readFileSync(r,`utf-8`))}catch{return t.push({file:`(build)`,level:D(e,`budgetExceeded`,`warning`),message:`Failed to parse performance metrics file.`}),t}let a=n.budgets,o=D(e,`budgetExceeded`,`warning`),s=E(a?.maxJSBundleSize,1/0),u=E(a?.maxCSSBundleSize,1/0),d=E(a?.maxPageHTMLSize,1/0),f=a?.maxImagesKB??1/0,p=a?.maxBuildTime??1/0,m=a?.maxFontCount??1/0;if(s!==1/0&&i.totalJSBundleSize>s){let e=(i.totalJSBundleSize/1024).toFixed(0),n=(s/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`JS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Code-split large dependencies or lazy-load route components.`})}if(u!==1/0&&i.totalCSSBundleSize>u){let e=(i.totalCSSBundleSize/1024).toFixed(0),n=(u/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`CSS bundle size exceeds budget: ${e}kb > ${n}kb`,suggestion:`Remove unused styles or split CSS by route.`})}if(d!==1/0){for(let e of i.pages)if(e.htmlSize>d){let n=(e.htmlSize/1024).toFixed(0),r=(d/1024).toFixed(0);t.push({file:e.route,level:o,message:`Page HTML size exceeds budget: ${n}kb > ${r}kb`,suggestion:`Reduce the amount of inline content or split into sub-pages.`})}}let h=f*1024;if(f!==1/0&&i.totalImagesSize>h){let e=(i.totalImagesSize/1024).toFixed(0);t.push({file:`(build)`,level:o,message:`Image assets exceed budget: ${e}kb > ${f}kb`,suggestion:`Optimize images with lossy compression or use next-gen formats (webp/avif).`})}if(p!==1/0&&i.buildTime>p){let e=(i.buildTime/1e3).toFixed(1),n=(p/1e3).toFixed(1);t.push({file:`(build)`,level:o,message:`Build time exceeds budget: ${e}s > ${n}s`,suggestion:"Check for large unoptimized assets or increase `concurrency` in SSG options."})}return m!==1/0&&i.fontCount>m&&t.push({file:`(build)`,level:o,message:`Font files exceed budget: ${i.fontCount} > ${m}`,suggestion:`Reduce the number of font families or use variable fonts.`}),t}var U=e({DEFAULT_DOCTOR_CONFIG:()=>T,checkI18n:()=>B,checkLinks:()=>z,checkMetadata:()=>R,checkPerformance:()=>H,checkSidebar:()=>V,doctorAction:()=>G,doctorInit:()=>W,generateLinkTree:()=>P,loadDoctorConfig:()=>N});async function W(e){let t=c.resolve(e,`doctor.json`);if(l.existsSync(t)){x(`"doctor.json" already exists at ${e}.`);return}try{l.writeFileSync(t,JSON.stringify(T,null,2)),y(`Created "doctor.json" with default configuration.`)}catch(e){h(`Failed to create "doctor.json": ${e}`)}}async function G(e=process.cwd(),t={}){if(t.init){await W(e);return}s();try{let n=await N(e),{format:r}=n.reporting,i=performance.now(),a=await o(`docs`,e),s=c.resolve(e,`docs`);l.existsSync(s)||(r===`pretty`&&h(`Docs dir not found at ${s}`),process.exit(1)),r===`pretty`&&console.log(m([` ${d.dim(`Docs dir:`)} ${s}`,` ${d.dim(`Reports:`)} ${e}/.boltdocs/reports/`],{title:`✦ DOCTOR — Documentation Health Check`})),r===`pretty`&&g(d.dim(`🔍 Discovering files and routes...`));let x=C(n.exclude||[]),w=await new S().withFullPaths().filter(e=>{if(!(e.endsWith(`.md`)||e.endsWith(`.mdx`)))return!1;let t=c.relative(s,e).replace(/\\/g,`/`),n=t.split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`);return!x(t)&&!n}).crawl(s).withPromise();for(let e of w)j.set(e,!0);let T=await P(s,e,a,w),E=a.base||`/`,D=E===`/`?``:E.endsWith(`/`)?E.slice(0,-1):E,k={root:e,docsDir:s,config:a,doctorConfig:n,linkTree:T,files:w,options:t,routeIndex:new Set(T.routes),routeIndexWithSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e:e+`/`)),routeIndexWithoutSlash:new Set(T.routes.map(e=>e.endsWith(`/`)?e.slice(0,-1):e)),basePrefix:D};r===`pretty`&&g(d.dim(`🧪 Running diagnostic checks in parallel...`));let A=[R(k),z(k),B(k),V(k)];t.budget&&A.push(H(k));let[M,F,I,L,...U]=await Promise.all(A),W=t.budget?U[0]:[],G=[...M,...F,...I,...L,...W];if(r===`pretty`){let e=[{label:`Metadata checks ${M.length>0?`— ${M.length} issue${M.length===1?``:`s`}`:`— OK`}`,done:M.length===0},{label:`Link checks ${F.length>0?`— ${F.length} issue${F.length===1?``:`s`}`:`— OK`}`,done:F.length===0},{label:`i18n checks ${I.length>0?`— ${I.length} issue${I.length===1?``:`s`}`:`— OK`}`,done:I.length===0},{label:`Sidebar checks ${L.length>0?`— ${L.length} issue${L.length===1?``:`s`}`:`— OK`}`,done:L.length===0}];t.budget&&e.push({label:`Performance budget ${W.length>0?`— ${W.length} issue${W.length===1?``:`s`}`:`— OK`}`,done:W.length===0}),console.log(`\n${b(e)}`)}let K=0;if(t.fix){for(let e of G)if(e.fix){if(k.doctorConfig.fix.confirmChanges&&!await f(`Fix issue in "${e.file}": ${e.message}?`))continue;if(k.doctorConfig.fix.backupFiles){let t=c.resolve(k.docsDir,e.file);l.existsSync(t)&&await O(t,c.resolve(k.root,k.doctorConfig.fix.backupPath))}await e.fix(),K++}}let q=((performance.now()-i)/1e3).toFixed(2),J=G.filter(e=>e.level===`high`).length,Y=G.filter(e=>e.level===`warning`).length,X=G.filter(e=>e.level===`low`).length,Z={summary:{total:G.length,high:J,warning:Y,low:X,fixed:K,duration:q},issues:G.map(e=>({...e,fix:void 0}))};if(n.reporting.outputFile){let t=c.resolve(e,n.reporting.outputFile);l.existsSync(c.dirname(t))||l.mkdirSync(c.dirname(t),{recursive:!0}),l.writeFileSync(t,JSON.stringify(Z,null,2))}if(r===`json`)console.log(JSON.stringify(Z,null,2));else if(r===`pretty`){let e=G.reduce((e,t)=>(e[t.file]||(e[t.file]=[]),e[t.file].push(t),e),{});if(G.length>0){p();for(let[n,r]of Object.entries(e)){let e=[];for(let n of r){let r=n.level===`high`?`❌`:n.level===`warning`?`⚠️`:`ℹ️`,i=n.level===`high`?d.red:n.level===`warning`?d.yellow:d.blue;e.push(`${r} ${i(n.level.toUpperCase())}: ${n.message}`),n.suggestion&&e.push(` ${d.dim(`💡 ${n.suggestion}`)}`),t.fix&&n.fix&&e.push(` ${d.green(`✅ Fixed automatically`)}`)}console.log(`\n${v(e,{title:`📄 ${n}`})}`)}p()}if(G.length===0)console.log(_([` Everything looks perfect!`,` Your documentation is in great shape.`,``,` ${d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)}`],{title:`✨ Documentation Health Check`}));else{let e=[];J>0&&e.push(d.red(`${J} Critical Error${J===1?``:`s`}`)),Y>0&&e.push(d.yellow(`${Y} Warning${Y===1?``:`s`}`)),X>0&&e.push(d.blue(`${X} Improvement${X===1?``:`s`}`));let t=[...u(e).split(`
7
- `).map(e=>e.trimStart()),``,d.dim(`Scanned ${w.length} file${w.length===1?``:`s`} in ${q}s`)];console.log(`\n${m(t,{title:`Diagnosis Results`})}\n`),K>0&&y(`Successfully fixed ${K} issues automatically!`),J>0?h(`Please fix the critical errors before building for production.`):y(`No critical issues found. You are ready to go!`)}}n.reporting.failOnError&&J>0&&process.exit(1),n.reporting.maxWarnings!==-1&&Y>n.reporting.maxWarnings&&(r===`pretty`&&h(`Failed: Too many warnings (${Y} > ${n.reporting.maxWarnings})`),process.exit(1))}catch(e){h(`Doctor failed: ${e}`),process.exit(1)}}export{P as n,U as t};
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- function e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}export{e as t};
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- function e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import e from"node:path";import{fileURLToPath as t}from"node:url";const n=e.dirname(t(import.meta.url));export{n as t};
@@ -1,6 +0,0 @@
1
- /**
2
- * Boltdocs - https://boltdocs.vercel.app
3
- * Copyright (c) 2026 Jesus Alcala
4
- * Licensed under the MIT License.
5
- */
6
- import{t as e}from"./rolldown-runtime-fkIsjY3S.mjs";var t=e({SECURITY_HEADERS:()=>n});const n={"X-Content-Type-Options":`nosniff`,"X-Frame-Options":`DENY`,"X-XSS-Protection":`1; mode=block`,"Referrer-Policy":`strict-origin-when-cross-origin`,"Permissions-Policy":`camera=(), microphone=(), geolocation=()`,"Strict-Transport-Security":`max-age=31536000; includeSubDomains; preload`};export{t as n,n as t};