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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
|
-
import * as _$
|
|
4
|
-
import { CodeToHastOptions } from "shiki";
|
|
5
|
-
|
|
3
|
+
import * as _$http from "http";
|
|
6
4
|
//#region src/shared/types.d.ts
|
|
7
5
|
/**
|
|
8
6
|
* Metadata representing a single documentation route.
|
|
@@ -177,6 +175,43 @@ interface BoltdocsVersionConfig {
|
|
|
177
175
|
label: string;
|
|
178
176
|
path: string;
|
|
179
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Configuration for content collections (e.g. blog posts, changelog)
|
|
180
|
+
* declared in `boltdocs.config.ts`. Each entry maps a directory name
|
|
181
|
+
* (e.g. `[blog]`) to its display + ordering settings.
|
|
182
|
+
*/
|
|
183
|
+
interface BoltdocsCollectionsConfig {
|
|
184
|
+
/**
|
|
185
|
+
* Map of collection id (matches the bracketed directory name) to
|
|
186
|
+
* its display label. Falls back to the id when a label is missing.
|
|
187
|
+
*/
|
|
188
|
+
labels?: Record<string, string | Record<string, string>>;
|
|
189
|
+
/**
|
|
190
|
+
* Map of collection id to a numeric position used for sidebar ordering.
|
|
191
|
+
* Collections with no explicit position are sorted last.
|
|
192
|
+
*/
|
|
193
|
+
positions?: Record<string, number>;
|
|
194
|
+
/**
|
|
195
|
+
* Items-per-page for paginated collection routes (e.g. blog indexes).
|
|
196
|
+
* Falls back to the framework default (10) when omitted.
|
|
197
|
+
*/
|
|
198
|
+
postsPerPage?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Default collection ID used by collection routing when no collection
|
|
201
|
+
* is explicitly referenced. Defaults to `'blog'`.
|
|
202
|
+
*/
|
|
203
|
+
defaultCollection?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Date format string for rendering post dates in listing pages.
|
|
206
|
+
* Defaults to `'MMMM dd, yyyy'`.
|
|
207
|
+
*/
|
|
208
|
+
dateFormat?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Field used to sort posts within a collection.
|
|
211
|
+
* Defaults to `'date'`.
|
|
212
|
+
*/
|
|
213
|
+
sortBy?: 'date' | 'title' | 'sidebarPosition';
|
|
214
|
+
}
|
|
180
215
|
/**
|
|
181
216
|
* Configuration for documentation versioning.
|
|
182
217
|
*/
|
|
@@ -204,6 +239,129 @@ interface PluginContext {
|
|
|
204
239
|
readonly rootDir: string;
|
|
205
240
|
readonly outDir: string;
|
|
206
241
|
readonly routes: RouteMeta[];
|
|
242
|
+
/** Namespaced cache helpers bound to the core's cache machinery. */
|
|
243
|
+
readonly caches: PluginCachesAPI;
|
|
244
|
+
/** Structured diagnostics channel; reports can be drained via `list()`. */
|
|
245
|
+
readonly diagnostics: PluginDiagnosticsAPI;
|
|
246
|
+
/** Helpers for resolving paths inside the workspace safely. */
|
|
247
|
+
readonly paths: PluginPathsAPI;
|
|
248
|
+
/** Declare virtual modules the core should expose to Vite. */
|
|
249
|
+
readonly virtualModules: PluginVirtualModulesAPI;
|
|
250
|
+
/** Register and query transform middleware at runtime. */
|
|
251
|
+
readonly middleware: PluginMiddlewareAPI;
|
|
252
|
+
/**
|
|
253
|
+
* Hook into dev-server file watching and send custom HMR events
|
|
254
|
+
* to connected clients.
|
|
255
|
+
*/
|
|
256
|
+
readonly hmr: PluginHmrAPI;
|
|
257
|
+
/**
|
|
258
|
+
* Register HTTP middleware and server lifecycle hooks without
|
|
259
|
+
* writing a Vite plugin.
|
|
260
|
+
*/
|
|
261
|
+
readonly server: PluginServerAPI;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Functional cache helpers exposed through `PluginContext.caches`.
|
|
265
|
+
*
|
|
266
|
+
* Plugin authors do not get a reference to the raw `TransformCache` /
|
|
267
|
+
* `FileCache` instances — those stay encapsulated in core. The methods
|
|
268
|
+
* returned here are bound to namespaced keys so two plugins cannot
|
|
269
|
+
* collide.
|
|
270
|
+
*/
|
|
271
|
+
interface PluginCachesAPI {
|
|
272
|
+
/** Sharded, hash-keyed cache. One namespace per plugin recommended. */
|
|
273
|
+
transform(namespace: string): PluginTransformCacheAPI;
|
|
274
|
+
/** Routes cache wrapper around the parsed-doc cache. */
|
|
275
|
+
routes: PluginRoutesCacheAPI;
|
|
276
|
+
/** In-memory LRU cache keyed by namespace + plugin-supplied key. */
|
|
277
|
+
memory<V = unknown>(namespace: string, opts?: {
|
|
278
|
+
max?: number;
|
|
279
|
+
ttl?: number;
|
|
280
|
+
}): PluginMemoryCacheAPI<V>;
|
|
281
|
+
}
|
|
282
|
+
interface PluginTransformCacheAPI {
|
|
283
|
+
/** Async read — first call may warm from disk if the entry was evicted. */
|
|
284
|
+
get(key: string): Promise<string | null>;
|
|
285
|
+
/** Synchronous write that batches a background disk flush. */
|
|
286
|
+
set(key: string, value: string): void;
|
|
287
|
+
/** Force-flush background writes. Call before measuring disk state. */
|
|
288
|
+
flush(): Promise<void>;
|
|
289
|
+
}
|
|
290
|
+
interface PluginRoutesCacheAPI {
|
|
291
|
+
/** Read a parsed `RouteMeta` (and its private `_content` blob) by abs file path. */
|
|
292
|
+
get(filePath: string): RouteMeta | null;
|
|
293
|
+
/** Write a parsed route entry. Caller assumptions match `docCache.set`. */
|
|
294
|
+
set(filePath: string, route: RouteMeta): void;
|
|
295
|
+
/** Invalidate one route. Use when content changes. */
|
|
296
|
+
invalidate(filePath: string): void;
|
|
297
|
+
/** Clear every cached route. Use when the directory layout changes. */
|
|
298
|
+
invalidateAll(): void;
|
|
299
|
+
}
|
|
300
|
+
interface PluginMemoryCacheAPI<V> {
|
|
301
|
+
get(key: string): V | undefined;
|
|
302
|
+
set(key: string, value: V): void;
|
|
303
|
+
has(key: string): boolean;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Plugin diagnostics API.
|
|
307
|
+
*
|
|
308
|
+
* Plugins push structured records instead of spamming the logger; downstream
|
|
309
|
+
* tools (dev-server overlay, CI reporters, IDE plugins) drain the queue via
|
|
310
|
+
* `list()`.
|
|
311
|
+
*/
|
|
312
|
+
interface DiagnosticRecord {
|
|
313
|
+
readonly id: number;
|
|
314
|
+
readonly severity: 'info' | 'warn' | 'error';
|
|
315
|
+
readonly code: string;
|
|
316
|
+
readonly message: string;
|
|
317
|
+
readonly pluginName: string;
|
|
318
|
+
readonly filePath?: string;
|
|
319
|
+
readonly routePath?: string;
|
|
320
|
+
readonly time: Date;
|
|
321
|
+
}
|
|
322
|
+
interface PluginDiagnosticsAPI {
|
|
323
|
+
report(severity: DiagnosticRecord['severity'], code: string, message: string, where?: {
|
|
324
|
+
filePath?: string;
|
|
325
|
+
routePath?: string;
|
|
326
|
+
}): void;
|
|
327
|
+
list(): readonly DiagnosticRecord[];
|
|
328
|
+
clear(): void;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Path-resolution helpers exposed through `PluginContext.paths`.
|
|
332
|
+
*
|
|
333
|
+
* Both `resolveDocs` and `resolveAsset` validate the resulting path against
|
|
334
|
+
* the workspace boundary and reject any segment that resolves outside the
|
|
335
|
+
* docs / project root directories.
|
|
336
|
+
*/
|
|
337
|
+
interface PluginPathsAPI {
|
|
338
|
+
resolveDocs(...parts: string[]): string;
|
|
339
|
+
resolveAsset(...parts: string[]): string;
|
|
340
|
+
/**
|
|
341
|
+
* Build a `file://` URL for an absolute path inside the workspace.
|
|
342
|
+
* Useful for `new URL(import.meta.url)` replacements and image srcsets.
|
|
343
|
+
*/
|
|
344
|
+
safeFileURL(absFilePath: string): string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Plugin virtual-modules registration.
|
|
348
|
+
*
|
|
349
|
+
* Plugins call `add(id, loader)` to expose a `virtual:<plugin>/<id>` module
|
|
350
|
+
* to Vite without having to author a full Vite plugin. The loader returns
|
|
351
|
+
* the module source code as a string; the core wraps it in the right
|
|
352
|
+
* `resolveId`/`load` plumbing at Vite build time.
|
|
353
|
+
*/
|
|
354
|
+
interface RegisteredVirtualModule {
|
|
355
|
+
readonly id: string;
|
|
356
|
+
readonly eager: boolean;
|
|
357
|
+
readonly loader: () => string | Promise<string>;
|
|
358
|
+
}
|
|
359
|
+
interface PluginVirtualModulesAPI {
|
|
360
|
+
add(id: string, loader: () => string | Promise<string>, opts?: {
|
|
361
|
+
eager?: boolean;
|
|
362
|
+
}): void;
|
|
363
|
+
has(id: string): boolean;
|
|
364
|
+
list(): readonly RegisteredVirtualModule[];
|
|
207
365
|
}
|
|
208
366
|
/**
|
|
209
367
|
* Logger interface for plugin logging.
|
|
@@ -230,6 +388,152 @@ interface PluginMeta {
|
|
|
230
388
|
version?: string;
|
|
231
389
|
boltdocsVersion?: string;
|
|
232
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Chain control signal returned by transform hooks. Use with `__signal` in
|
|
393
|
+
* the return value to influence the middleware chain:
|
|
394
|
+
*
|
|
395
|
+
* - `'skip'`: stop processing this hook for the current file (remaining
|
|
396
|
+
* plugins in the chain still run).
|
|
397
|
+
* - `'break'`: stop the entire chain immediately — no further plugin's
|
|
398
|
+
* transform hooks run for this file.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* transformMdx: async (_ctx, { code }) => ({
|
|
403
|
+
* code: code.replace(/foo/g, 'bar'),
|
|
404
|
+
* __signal: 'skip', // skip remaining plugins
|
|
405
|
+
* })
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
type ChainSignal = 'skip' | 'break';
|
|
409
|
+
/**
|
|
410
|
+
* Returned by a transform hook that wants to signal the chain. The `__signal`
|
|
411
|
+
* field is optional — most hooks will just return `{ code: string }` and the
|
|
412
|
+
* chain continues normally. When `__signal` is present, `runChain` reacts:
|
|
413
|
+
*
|
|
414
|
+
* - `'skip'` continues with the next plugin, but passes the **original params**
|
|
415
|
+
* (the output of this hook is discarded).
|
|
416
|
+
* - `'break'` stops the chain immediately.
|
|
417
|
+
*
|
|
418
|
+
* @template T The params shape (e.g. `{ code: string; filePath: string }`).
|
|
419
|
+
*/
|
|
420
|
+
type TransformResult<T> = T & {
|
|
421
|
+
__signal?: ChainSignal;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Enriched params passed to `transformSource` and `transformMdx`. The `code`
|
|
425
|
+
* and `filePath` fields are always present. The optional `frontmatter` and
|
|
426
|
+
* `route` fields are populated when available (they are `undefined` in the
|
|
427
|
+
* early pipeline where frontmatter hasn't been parsed yet).
|
|
428
|
+
*/
|
|
429
|
+
interface TransformSourceParams {
|
|
430
|
+
/** The raw or compiled code (source before MDX / JS after MDX). */
|
|
431
|
+
code: string;
|
|
432
|
+
/** Absolute file path of the source document. */
|
|
433
|
+
filePath: string;
|
|
434
|
+
/** Parsed frontmatter, if available. `undefined` in very early pipeline. */
|
|
435
|
+
frontmatter?: Record<string, unknown>;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Enriched params passed to `transformHtml`. The `html` and `path` fields
|
|
439
|
+
* are always present. The optional `route` carries the generated `RouteMeta`
|
|
440
|
+
* for richer context (locale, version, collection, etc.).
|
|
441
|
+
*/
|
|
442
|
+
interface TransformHtmlParams {
|
|
443
|
+
/** The rendered HTML string for this page. */
|
|
444
|
+
html: string;
|
|
445
|
+
/** The route path (e.g. `/docs/guides/start`). */
|
|
446
|
+
path: string;
|
|
447
|
+
/** The route metadata for the page, if available. */
|
|
448
|
+
route?: RouteMeta;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Plugin transform middleware. Each middleware runs in the transform
|
|
452
|
+
* pipeline alongside lifecycle hooks. The `name` field is optional —
|
|
453
|
+
* when omitted, the owning plugin's name is used as context.
|
|
454
|
+
* Middleware runs in `enforce` order (pre → normal → post) and supports
|
|
455
|
+
* `__signal: 'skip'` / `__signal: 'break'` for chain control.
|
|
456
|
+
*/
|
|
457
|
+
interface PluginTransformMiddleware {
|
|
458
|
+
/** Optional name. Defaults to the owning plugin's name for diagnostics. */
|
|
459
|
+
name?: string;
|
|
460
|
+
enforce?: 'pre' | 'post';
|
|
461
|
+
transformSource?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
462
|
+
code: string;
|
|
463
|
+
}> | Promise<TransformResult<{
|
|
464
|
+
code: string;
|
|
465
|
+
}>>;
|
|
466
|
+
transformMdx?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
467
|
+
code: string;
|
|
468
|
+
}> | Promise<TransformResult<{
|
|
469
|
+
code: string;
|
|
470
|
+
}>>;
|
|
471
|
+
transformHtml?: (ctx: PluginContext, params: TransformHtmlParams) => TransformResult<{
|
|
472
|
+
html: string;
|
|
473
|
+
}> | Promise<TransformResult<{
|
|
474
|
+
html: string;
|
|
475
|
+
}>>;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Plugin middleware registry API exposed through `PluginContext.middleware`.
|
|
479
|
+
* Plugins can register named middleware entries from lifecycle hooks.
|
|
480
|
+
*/
|
|
481
|
+
interface PluginMiddlewareAPI {
|
|
482
|
+
add(middleware: PluginTransformMiddleware): void;
|
|
483
|
+
remove(name: string): void;
|
|
484
|
+
has(name: string): boolean;
|
|
485
|
+
list(): readonly PluginTransformMiddleware[];
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* HMR event types plugins can listen to.
|
|
489
|
+
*/
|
|
490
|
+
type PluginHmrEvent = 'add' | 'change' | 'unlink';
|
|
491
|
+
/**
|
|
492
|
+
* Plugin HMR API — hook into file-watching events and send custom
|
|
493
|
+
* HMR messages to connected clients.
|
|
494
|
+
*/
|
|
495
|
+
interface PluginHmrAPI {
|
|
496
|
+
/**
|
|
497
|
+
* Register a callback for file events scoped to the docs directory.
|
|
498
|
+
* The callback receives the normalized file path and event type.
|
|
499
|
+
*/
|
|
500
|
+
onFileEvent(eventType: PluginHmrEvent, handler: (filePath: string) => void | Promise<void>): void;
|
|
501
|
+
/** Shorthand for `onFileEvent('add', handler)`. */
|
|
502
|
+
onFileAdd(handler: (filePath: string) => void | Promise<void>): void;
|
|
503
|
+
/** Shorthand for `onFileEvent('change', handler)`. */
|
|
504
|
+
onFileChange(handler: (filePath: string) => void | Promise<void>): void;
|
|
505
|
+
/** Shorthand for `onFileEvent('unlink', handler)`. */
|
|
506
|
+
onFileUnlink(handler: (filePath: string) => void | Promise<void>): void;
|
|
507
|
+
/**
|
|
508
|
+
* Send a custom HMR event to all connected clients.
|
|
509
|
+
* The client can listen with `import.meta.hot.on('boltdocs:plugin:<name>', ...)`.
|
|
510
|
+
*/
|
|
511
|
+
send(event: string, data?: unknown): void;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Plugin Server API — register HTTP middleware and lifecycle hooks
|
|
515
|
+
* for the dev server and preview server, without writing a Vite plugin.
|
|
516
|
+
*/
|
|
517
|
+
interface PluginServerAPI {
|
|
518
|
+
/**
|
|
519
|
+
* Register a Connect-style middleware function.
|
|
520
|
+
* Runs on both dev and preview servers.
|
|
521
|
+
*/
|
|
522
|
+
use(middleware: PluginServerMiddleware): void;
|
|
523
|
+
/**
|
|
524
|
+
* Register a middleware scoped to a specific path prefix.
|
|
525
|
+
* Only requests starting with `path` trigger the handler.
|
|
526
|
+
*/
|
|
527
|
+
useAt(path: string, handler: PluginServerMiddleware): void;
|
|
528
|
+
/** Called when the dev/preview server starts (once per process). */
|
|
529
|
+
onStart(callback: () => void | Promise<void>): void;
|
|
530
|
+
/** Called when the server shuts down (cleanup). */
|
|
531
|
+
onEnd(callback: () => void | Promise<void>): void;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Connect-style middleware signature.
|
|
535
|
+
*/
|
|
536
|
+
type PluginServerMiddleware = (req: _$http.IncomingMessage, res: _$http.ServerResponse, next: (err?: unknown) => void) => void | Promise<void>;
|
|
233
537
|
/**
|
|
234
538
|
* Plugin lifecycle hooks with full type safety.
|
|
235
539
|
*/
|
|
@@ -239,30 +543,21 @@ interface PluginLifecycleHooks {
|
|
|
239
543
|
beforeDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
240
544
|
afterDev?: (ctx: PluginContext) => Promise<void> | void;
|
|
241
545
|
buildEnd?: (ctx: PluginContext) => Promise<void> | void;
|
|
242
|
-
transformSource?: (ctx: PluginContext, params: {
|
|
243
|
-
code: string;
|
|
244
|
-
filePath: string;
|
|
245
|
-
}) => Promise<{
|
|
246
|
-
code: string;
|
|
247
|
-
}> | {
|
|
546
|
+
transformSource?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
248
547
|
code: string;
|
|
249
|
-
}
|
|
250
|
-
transformMdx?: (ctx: PluginContext, params: {
|
|
548
|
+
}> | Promise<TransformResult<{
|
|
251
549
|
code: string;
|
|
252
|
-
|
|
253
|
-
|
|
550
|
+
}>>;
|
|
551
|
+
transformMdx?: (ctx: PluginContext, params: TransformSourceParams) => TransformResult<{
|
|
254
552
|
code: string;
|
|
255
|
-
}> | {
|
|
553
|
+
}> | Promise<TransformResult<{
|
|
256
554
|
code: string;
|
|
257
|
-
}
|
|
258
|
-
transformHtml?: (ctx: PluginContext, params: {
|
|
259
|
-
html: string;
|
|
260
|
-
path: string;
|
|
261
|
-
}) => Promise<{
|
|
555
|
+
}>>;
|
|
556
|
+
transformHtml?: (ctx: PluginContext, params: TransformHtmlParams) => TransformResult<{
|
|
262
557
|
html: string;
|
|
263
|
-
}> | {
|
|
558
|
+
}> | Promise<TransformResult<{
|
|
264
559
|
html: string;
|
|
265
|
-
}
|
|
560
|
+
}>>;
|
|
266
561
|
}
|
|
267
562
|
/**
|
|
268
563
|
* MDX processor configuration.
|
|
@@ -286,22 +581,19 @@ interface BoltdocsPlugin {
|
|
|
286
581
|
rehypePlugins?: unknown[];
|
|
287
582
|
vitePlugins?: Plugin[];
|
|
288
583
|
components?: Record<string, string>;
|
|
584
|
+
/** Optional runtime metadata exposed to client via useConfig().plugins[].metadata */
|
|
585
|
+
metadata?: Record<string, unknown>;
|
|
586
|
+
/** Declarative transform middleware entries. */
|
|
587
|
+
middleware?: PluginTransformMiddleware[];
|
|
289
588
|
/** Lifecycle hooks with full type safety */
|
|
290
589
|
hooks?: PluginLifecycleHooks;
|
|
291
590
|
}
|
|
292
591
|
/**
|
|
293
|
-
* Configuration for the collections (blog) feature.
|
|
294
592
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
defaultCollection?: string;
|
|
300
|
-
/** Date format string for rendering post dates (e.g., 'MMMM dd, yyyy'). */
|
|
301
|
-
dateFormat?: string;
|
|
302
|
-
/** Field to sort posts by. Defaults to 'date'. */
|
|
303
|
-
sortBy?: 'date' | 'title' | 'sidebarPosition';
|
|
304
|
-
}
|
|
593
|
+
/**
|
|
594
|
+
*/
|
|
595
|
+
/**
|
|
596
|
+
*/
|
|
305
597
|
interface BoltdocsSecurityConfig {
|
|
306
598
|
headers?: Record<string, string>;
|
|
307
599
|
enableCSP?: boolean;
|
|
@@ -486,49 +778,4 @@ declare function defineConfig(config: BoltdocsConfig): BoltdocsConfig;
|
|
|
486
778
|
*/
|
|
487
779
|
declare function resolveConfig(docsDir: string, root?: string): Promise<BoltdocsConfig>;
|
|
488
780
|
//#endregion
|
|
489
|
-
|
|
490
|
-
interface ParsedMeta {
|
|
491
|
-
title?: string;
|
|
492
|
-
lineNumbers?: boolean;
|
|
493
|
-
wordWrap?: boolean;
|
|
494
|
-
[key: string]: any;
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Parses a meta string into a structured ParsedMeta object.
|
|
498
|
-
*/
|
|
499
|
-
declare function parseMetaString(metaStr: string): ParsedMeta;
|
|
500
|
-
/**
|
|
501
|
-
* Unified Shiki Adapter for Boltdocs.
|
|
502
|
-
* Centralizes theme resolution, transformer configuration, and rendering logic.
|
|
503
|
-
*/
|
|
504
|
-
declare class ShikiAdapter {
|
|
505
|
-
private config;
|
|
506
|
-
constructor(config?: BoltdocsConfig);
|
|
507
|
-
/**
|
|
508
|
-
* Resolves the code theme from Boltdocs configuration.
|
|
509
|
-
*/
|
|
510
|
-
getTheme(): ShikiTheme | {
|
|
511
|
-
light: ShikiTheme;
|
|
512
|
-
dark: ShikiTheme;
|
|
513
|
-
};
|
|
514
|
-
/**
|
|
515
|
-
* Creates a Shiki highlighter instance with the configured themes.
|
|
516
|
-
*/
|
|
517
|
-
getHighlighter(): Promise<_$shiki.HighlighterCore>;
|
|
518
|
-
/**
|
|
519
|
-
* Assembles Shiki options including transformers for a specific code block.
|
|
520
|
-
*/
|
|
521
|
-
getOptions(lang: string, meta: string | ParsedMeta): CodeToHastOptions;
|
|
522
|
-
/**
|
|
523
|
-
* Renders code to HTML using the Boltdocs Shiki pipeline.
|
|
524
|
-
* Safely handles highlighter exceptions by falling back to escaped pre.
|
|
525
|
-
*/
|
|
526
|
-
render(code: string, lang: string, meta: string | ParsedMeta): Promise<string>;
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Returns a cached ShikiAdapter instance.
|
|
530
|
-
* Recreates only if the relevant codeTheme configuration values change deeply.
|
|
531
|
-
*/
|
|
532
|
-
declare function getShikiAdapter(config?: BoltdocsConfig): ShikiAdapter;
|
|
533
|
-
//#endregion
|
|
534
|
-
export { resolveConfig as a, BoltdocsPlugin as c, PluginLifecycleHooks as d, PluginLogger as f, RouteMeta as h, parseMetaString as i, BoltdocsThemeConfig as l, PluginStore as m, ShikiAdapter as n, defineConfig as o, PluginMeta as p, getShikiAdapter as r, BoltdocsConfig as s, ParsedMeta as t, PluginContext as u };
|
|
781
|
+
export { BoltdocsThemeConfig as a, PluginLogger as c, PluginTransformMiddleware as d, RouteMeta as f, BoltdocsPlugin as i, PluginMeta as l, defineConfig as n, PluginContext as o, ShikiTheme as p, BoltdocsConfig as r, PluginLifecycleHooks as s, resolveConfig as t, PluginStore as u };
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var e=require(`./chunk-
|
|
6
|
+
var e=require(`./chunk-D1Md3oWO.cjs`).t({getCSPHeader:()=>t});function t(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(`; `)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,6 @@
|
|
|
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"./chunk-BFSpntXv.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};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { B as useConfig, R as icons_exports, d as Check, i as useLocalizedTo, m as ChevronRight, o as normalizePath, p as ChevronLeft, r as cn, t as Link$1 } from "./link-2PzgTnaP.js";
|
|
7
7
|
import { Children, createContext, use, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { useLocation } from "react-router-dom";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1142,15 +1142,8 @@ function SearchHighlight() {
|
|
|
1142
1142
|
//#endregion
|
|
1143
1143
|
//#region src/client/components/primitives/docs-layout.tsx
|
|
1144
1144
|
/**
|
|
1145
|
-
* Root layout shell.
|
|
1146
|
-
*
|
|
1147
|
-
* Usage:
|
|
1148
|
-
* ```tsx
|
|
1149
|
-
* <DocsLayout>
|
|
1150
|
-
* <Navbar />
|
|
1151
|
-
* <DocsLayout.Body>...</DocsLayout.Body>
|
|
1152
|
-
* </DocsLayout>
|
|
1153
|
-
* ```
|
|
1145
|
+
* Root layout shell. Mount children like:
|
|
1146
|
+
* <DocsLayout><Navbar /><DocsLayout.Body>...</DocsLayout.Body></DocsLayout>
|
|
1154
1147
|
*/
|
|
1155
1148
|
function DocsLayoutRoot({ children, className, style }) {
|
|
1156
1149
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -1159,9 +1152,6 @@ function DocsLayoutRoot({ children, className, style }) {
|
|
|
1159
1152
|
children
|
|
1160
1153
|
});
|
|
1161
1154
|
}
|
|
1162
|
-
/**
|
|
1163
|
-
* Horizontal flex container for sidebar + content + toc.
|
|
1164
|
-
*/
|
|
1165
1155
|
function Body({ children, className, style }) {
|
|
1166
1156
|
return /* @__PURE__ */ jsx("div", {
|
|
1167
1157
|
className: cn("mx-auto flex flex-1 w-full max-w-(--breakpoint-3xl) bg-main overflow-hidden", className),
|
|
@@ -1169,29 +1159,23 @@ function Body({ children, className, style }) {
|
|
|
1169
1159
|
children
|
|
1170
1160
|
});
|
|
1171
1161
|
}
|
|
1172
|
-
/**
|
|
1173
|
-
* Main scrollable content area.
|
|
1174
|
-
*/
|
|
1175
1162
|
function Content({ children, className, style }) {
|
|
1176
1163
|
return /* @__PURE__ */ jsx("main", {
|
|
1177
|
-
className: cn("boltdocs-content flex-1 min-w-0 overflow-y-auto",
|
|
1164
|
+
className: cn("boltdocs-content flex-1 min-w-0 overflow-y-auto", className),
|
|
1178
1165
|
style,
|
|
1179
1166
|
children
|
|
1180
1167
|
});
|
|
1181
1168
|
}
|
|
1182
|
-
/**
|
|
1183
|
-
* MDX Content wrapper with standard page padding and max-width logic.
|
|
1184
|
-
*/
|
|
1185
1169
|
function ContentMdx({ children, className, style }) {
|
|
1186
1170
|
return /* @__PURE__ */ jsxs("div", {
|
|
1187
|
-
className: cn("boltdocs-page
|
|
1171
|
+
className: cn("boltdocs-page w-full pt-4 pb-20 px-4 sm:px-8", className),
|
|
1188
1172
|
style,
|
|
1189
|
-
children: [/* @__PURE__ */ jsx(SearchHighlight, {}),
|
|
1173
|
+
children: [/* @__PURE__ */ jsx(SearchHighlight, {}), /* @__PURE__ */ jsx("div", {
|
|
1174
|
+
className: "mx-auto w-full max-w-3xl sm:max-w-4xl lg:max-w-5xl",
|
|
1175
|
+
children
|
|
1176
|
+
})]
|
|
1190
1177
|
});
|
|
1191
1178
|
}
|
|
1192
|
-
/**
|
|
1193
|
-
* Content header area (breadcrumbs, title, description, etc).
|
|
1194
|
-
*/
|
|
1195
1179
|
function Header({ children, className, style }) {
|
|
1196
1180
|
return /* @__PURE__ */ jsx("header", {
|
|
1197
1181
|
className: cn("mb-10", className),
|
|
@@ -1199,9 +1183,6 @@ function Header({ children, className, style }) {
|
|
|
1199
1183
|
children
|
|
1200
1184
|
});
|
|
1201
1185
|
}
|
|
1202
|
-
/**
|
|
1203
|
-
* Footer area inside the content section (page nav).
|
|
1204
|
-
*/
|
|
1205
1186
|
function Footer({ children, className, style }) {
|
|
1206
1187
|
return /* @__PURE__ */ jsx("div", {
|
|
1207
1188
|
className: cn("mt-20", className),
|