boltdocs 3.3.1 → 3.3.3
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-BmB4TKCc.mjs → adapters-BKzKe2mO.mjs} +1 -1
- package/dist/{adapters-Cp1Maurn.cjs → adapters-DwDTQoCG.cjs} +1 -1
- package/dist/{audit-COgjnQ5n.cjs → audit-CHkGiV3c.cjs} +1 -1
- package/dist/{audit-CLXjMzwQ.mjs → audit-CMc_ydRr.mjs} +1 -1
- package/dist/{build-D6FfNA8m.cjs → build-Dh61OnDW.cjs} +1 -1
- package/dist/{build-D_7SvwTh.mjs → build-WmZDi-TG.mjs} +1 -1
- package/dist/client/index.cjs +37 -3
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +36 -3
- package/dist/client/primitives.d.cts +2 -2
- package/dist/client/primitives.d.ts +2 -2
- package/dist/client/router.d.cts +1 -1
- package/dist/client/router.d.ts +1 -1
- package/dist/client/theme/reset.css +31 -13
- package/dist/config-CrsQJHQz.cjs +7 -0
- package/dist/config-DC0nMMk7.mjs +7 -0
- package/dist/{config-jJh8WYJI.cjs → config-PLvresCv.cjs} +1 -1
- package/dist/{dev-CwOyh-wP.mjs → dev-BObyQM9q.mjs} +1 -1
- package/dist/{dev-B9l7fVoQ.cjs → dev-wKVrEH6o.cjs} +1 -1
- package/dist/{doctor-C7whl4ED.cjs → doctor-DMECtdK6.cjs} +1 -1
- package/dist/{doctor-B1_YL0Wt.cjs → doctor-FuFY1jBz.cjs} +1 -1
- package/dist/{doctor-DmQnml2k.mjs → doctor-i8Qmd8DJ.mjs} +1 -1
- package/dist/{index-C56bL-A-.d.cts → index-CSiMUBhC.d.cts} +7 -1
- package/dist/{index-Cu9H6CRa.d.ts → index-Cg3TmXIZ.d.ts} +7 -1
- package/dist/{index-CPUUKzxD.d.cts → index-CgWkOCCn.d.cts} +82 -6
- package/dist/{index-Ci4kfOHF.d.ts → index-CuNSD3E2.d.ts} +82 -6
- package/dist/{native-Kre2T5eS.cjs → native-nLA4Jr0T.cjs} +1 -1
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/highlight.cjs +6 -0
- package/dist/node/highlight.d.cts +5 -0
- package/dist/node/highlight.d.mts +5 -0
- package/dist/node/highlight.mjs +6 -0
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +37 -3
- package/dist/node/index.d.mts +38 -4
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +48 -32
- package/dist/node/mdx/shiki-adapter.d.mts +48 -32
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-B4GvEOqF.cjs +23 -0
- package/dist/node-DwgtnlGU.mjs +23 -0
- package/dist/{package-5EsGUTVl.mjs → package-DWYDpDWO.mjs} +1 -1
- package/dist/package-xYC9zF1o.cjs +6 -0
- package/dist/{parser-CGMY2lJ7.mjs → parser-CD8Oo8qh.mjs} +1 -1
- package/dist/{parser-BqTOsEUa.cjs → parser-vPaKvzLp.cjs} +1 -1
- package/dist/plugin-CxlOHnaa.cjs +69 -0
- package/dist/plugin-VpWRKnmN.mjs +69 -0
- package/dist/{plugin-context-wqHNSZum.mjs → plugin-context-BKK-nfOd.mjs} +1 -1
- package/dist/{plugin-context-C-l90hFt.cjs → plugin-context-BxF88sW4.cjs} +1 -1
- package/dist/{plugin-lifecycle-BAKNKOxd.cjs → plugin-lifecycle-mhRaVBY8.cjs} +1 -1
- package/dist/registry-BbB6NqSv.d.cts +44 -0
- package/dist/registry-CHh8A5as.mjs +6 -0
- package/dist/registry-DLJIooEu.cjs +6 -0
- package/dist/registry-sJqDv0kE.d.mts +44 -0
- package/dist/{resolve-B7vWOd8R.cjs → resolve-BelytNYR.cjs} +1 -1
- package/dist/{resolve-C2kKnk_5.mjs → resolve-C5rT6B21.mjs} +1 -1
- package/dist/{routes-U9L8psZ9.cjs → routes-C0kb4ue6.cjs} +1 -1
- package/dist/{routes-C2nPecwu.cjs → routes-C3_w9fLX.cjs} +1 -1
- package/dist/{routes-BL4y79tb.mjs → routes-C4wrLWwu.mjs} +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/{config-BoRlz0Ca.d.mts → types-Db6zToZH.d.mts} +83 -32
- package/dist/{config-CTsX_tGM.d.cts → types-o7iZ2BAR.d.cts} +84 -33
- package/dist/virtual-modules-XBiJoTsp.mjs +39 -0
- package/dist/virtual-modules-hndVivLR.cjs +39 -0
- package/package.json +10 -5
- package/src/shared/types.ts +92 -1
- package/dist/config-Ceib-AOH.cjs +0 -7
- package/dist/config-DGLQsy7y.mjs +0 -7
- package/dist/node-BFNCsPs3.mjs +0 -23
- package/dist/node-TpmWEqXM.cjs +0 -23
- package/dist/package-Ca2WSiy2.cjs +0 -6
- package/dist/plugin-CUmUZOLD.mjs +0 -69
- package/dist/plugin-Ds3RLYpy.cjs +0 -69
- package/dist/virtual-modules-Ca5tHk1X.cjs +0 -30
- package/dist/virtual-modules-Dlgt1fP0.mjs +0 -30
- /package/dist/{config-files-BYHDOrKn.mjs → config-files-DfwZ3Wot.mjs} +0 -0
- /package/dist/{config-files-D9cdBMl2.cjs → config-files-ph2ZtHWl.cjs} +0 -0
- /package/dist/{csp-C4LmN1ko.cjs → csp-BiGAG8aF.cjs} +0 -0
- /package/dist/{csp-D6JEOqKh.mjs → csp-D0BOH8ae.mjs} +0 -0
- /package/dist/{generator-BlW45ST7.cjs → generator-BCrZL53x.cjs} +0 -0
- /package/dist/{generator-BwknNejd.mjs → generator-CFukoGa0.mjs} +0 -0
- /package/dist/{handler-CDEoKARD.cjs → handler-Ch-Q9NAB.cjs} +0 -0
- /package/dist/{handler-D7UyZlPm.mjs → handler-Lex5DbvG.mjs} +0 -0
- /package/dist/{index-lFoyzCXy.d.mts → index-HAwIo4nZ.d.mts} +0 -0
- /package/dist/{native-BNCY7PRF.cjs → native-BOet8hpE.cjs} +0 -0
- /package/dist/{native-Di9Fnfrv.mjs → native-BYKMke79.mjs} +0 -0
- /package/dist/{resolve-YdTrt_FG.mjs → resolve-C8AFoOQL.mjs} +0 -0
- /package/dist/{resolve-It1Iug83.cjs → resolve-C9jGArE_.cjs} +0 -0
- /package/dist/{types-generator-DG1GX1EZ.mjs → types-generator-BtZ6-ZKx.mjs} +0 -0
- /package/dist/{types-generator-DDSA93P3.cjs → types-generator-C83Iy6X5.cjs} +0 -0
- /package/dist/{update-check-QnrVR3q1.mjs → update-check-BXD1atVv.mjs} +0 -0
- /package/dist/{update-check-BKqmYfwT.cjs → update-check-DFQZyoSU.cjs} +0 -0
|
@@ -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
|
+
const e=require(`./chunk-D1Md3oWO.cjs`);let t=require(`@bdocs/dui`);var n=e.t({BUILTIN_HIGHLIGHTERS:()=>i,DEFAULT_HIGHLIGHTER:()=>r,getCodeHighlighterAdapter:()=>d,getHighlighterNames:()=>l,isHighlighterRegistered:()=>c,prewarmCodeHighlighting:()=>f,prewarmHighlighter:()=>p,registerHighlighter:()=>o,registerPluginHighlighter:()=>s});const r=`shiki`,i=[r],a=new Map;a.set(r,async e=>(await Promise.resolve().then(()=>require(`./node/mdx/shiki-adapter.cjs`))).getShikiAdapter({theme:{codeHighlighting:{engine:r,theme:e?.theme,options:e?.options}}}));function o(e,t){a.set(e,t)}function s(e,t){a.has(e)||a.set(e,async e=>typeof t==`function`?t(e):t)}function c(e){return a.has(e)}function l(){return[...a.keys()]}function u(e){if(!e||typeof e?.getOptions!=`function`||typeof e?.initialize!=`function`)throw Error("[boltdocs] Invalid highlighter adapter: expected `getOptions(lang, meta)` and `initialize()`")}async function d(e){let n={engine:e?.engine??`shiki`,theme:e?.theme,options:e?.options},i=n.engine;try{if(typeof i==`function`){let e=await i(n);return u(e),e}if(i&&typeof i!=`string`)return u(i),i;let e=typeof i==`string`&&i.length>0?i:r;a.has(e)||(0,t.warn)(`[boltdocs] Unknown highlighting engine "${e}". Falling back to "${r}".`);let o=await(a.get(e)??a.get(`shiki`))(n);return u(o),o}catch(e){(0,t.error)(`[boltdocs] Failed to resolve highlighting engine:`,e);let i=a.get(r);if(i)try{let e=await i(n);return u(e),e}catch{}throw e}}async function f(e){try{let t=await d(e);typeof t.prewarm==`function`&&await t.prewarm(e?.options)}catch{}}function p(e){f(e)}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as CodeHighlightConfig, o as CodeHighlighterAdapter } from "./types-Db6zToZH.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/node/highlight/registry.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Factory signature used to produce a highlighter adapter.
|
|
7
|
+
* Receives the resolved engine-agnostic config (`theme`, `options`).
|
|
8
|
+
*/
|
|
9
|
+
type HighlighterFactory = (api: CodeHighlightConfig) => CodeHighlighterAdapter | Promise<CodeHighlighterAdapter>;
|
|
10
|
+
declare const DEFAULT_HIGHLIGHTER = "shiki";
|
|
11
|
+
declare const BUILTIN_HIGHLIGHTERS: readonly ["shiki"];
|
|
12
|
+
/**
|
|
13
|
+
* Register (or replace) a highlight engine by id. Plugins use this to expose
|
|
14
|
+
* custom engines through the core without touching any rendering code.
|
|
15
|
+
*/
|
|
16
|
+
declare function registerHighlighter(name: string, factory: HighlighterFactory): void;
|
|
17
|
+
/**
|
|
18
|
+
* Register an engine provided by a Boltdocs plugin. The plugin id (`plugin.name`)
|
|
19
|
+
* becomes the selectable `theme.codeHighlighting.engine` value. Accepts either
|
|
20
|
+
* a ready adapter instance or a factory, and never overrides a previously
|
|
21
|
+
* registered engine so the first plugin wins deterministically.
|
|
22
|
+
*/
|
|
23
|
+
declare function registerPluginHighlighter(name: string, provider: CodeHighlighterAdapter | ((api: CodeHighlightConfig) => CodeHighlighterAdapter | Promise<CodeHighlighterAdapter>)): void;
|
|
24
|
+
declare function isHighlighterRegistered(name: string): boolean;
|
|
25
|
+
declare function getHighlighterNames(): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the active {@link CodeHighlighterAdapter} for a config.
|
|
28
|
+
*
|
|
29
|
+
* Resolution order:
|
|
30
|
+
* 1. `engine` is a factory → call it with the resolved config
|
|
31
|
+
* 2. `engine` is an adapter instance → validate and return it
|
|
32
|
+
* 3. `engine` is a string → look up the registry (defaults to `'shiki'`);
|
|
33
|
+
* unknown ids warn and fall back to the built-in engine
|
|
34
|
+
*/
|
|
35
|
+
declare function getCodeHighlighterAdapter(config?: CodeHighlightConfig): Promise<CodeHighlighterAdapter>;
|
|
36
|
+
/**
|
|
37
|
+
* Best-effort warmup of the selected engine. Never throws and is intended to
|
|
38
|
+
* run off the critical path (e.g. right after the dev server listens).
|
|
39
|
+
*/
|
|
40
|
+
declare function prewarmCodeHighlighting(config?: CodeHighlightConfig): Promise<void>;
|
|
41
|
+
/** Fire-and-forget wrapper for {@link prewarmCodeHighlighting}. */
|
|
42
|
+
declare function prewarmHighlighter(config?: CodeHighlightConfig): void;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getHighlighterNames as a, prewarmHighlighter as c, getCodeHighlighterAdapter as i, registerHighlighter as l, DEFAULT_HIGHLIGHTER as n, isHighlighterRegistered as o, HighlighterFactory as r, prewarmCodeHighlighting as s, BUILTIN_HIGHLIGHTERS as t, registerPluginHighlighter as u };
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
const e=require(`./csp-
|
|
6
|
+
const e=require(`./csp-BiGAG8aF.cjs`);function t(t,n){let r=n?{...e.n}:{};return t.security?.enableCSP&&(r[`Content-Security-Policy`]=e.t(t)),Object.assign(r,t.security?.headers),Object.assign(r,t.security?.customHeaders),r}exports.resolveSecurityHeaders=t;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import{n as e,t}from"./csp-
|
|
6
|
+
import{n as e,t}from"./csp-D0BOH8ae.mjs";function n(n,r){let i=r?{...e}:{};return n.security?.enableCSP&&(i[`Content-Security-Policy`]=t(n)),Object.assign(i,n.security?.headers),Object.assign(i,n.security?.customHeaders),i}export{n as resolveSecurityHeaders};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
const e=require(`./chunk-D1Md3oWO.cjs`),t=require(`./utils-ej6_SjIZ.cjs`),n=require(`./node/cache.cjs`),r=require(`./cache-CJE9nWLE.cjs`);let i=require(`node:path`);i=e.r(i);let a=require(`node:fs`);a=e.r(a);let o=require(`node:crypto`);o=e.r(o);let s=require(`@bdocs/dui`),c=require(`node:fs/promises`);c=e.r(c);let l=require(`fdir`);function u(e){return i.default.resolve(e)}function d(e,t){return o.default.createHash(`sha1`).update(`${u(e)}:${t}`).digest(`hex`).slice(0,16)}function f(e,a,o){let s=d(e,o),c=t.o();return{fingerprint:o,docCache:new n.FileCache({name:`routes-${s}`,root:a}),parserCache:new r.t(a,s),cachedFileList:null,localizedPathCache:new Map,cachedNativeDocs:null,frontmatterHashes:new Map,directoryMeta:null,cachedDirectoryMetaFiles:null,directoryMetaEntries:new Map,discoverySnapshot:null,discoverySnapshotLoaded:!1,discoverySnapshotPath:i.default.resolve(a,c.dir,`route-discovery-${s}.json`)}}function p(e,t=i.default.dirname(i.default.resolve(e))){let n=u(e),r=i.default.resolve(t),a=f(n,r,`legacy`);return{docsDir:n,cacheRoot:r,docCache:a.docCache,parserCache:a.parserCache,cachedFileList:a.cachedFileList,localizedPathCache:a.localizedPathCache,cachedNativeDocs:a.cachedNativeDocs,frontmatterHashes:a.frontmatterHashes,directoryMeta:a.directoryMeta,cachedDirectoryMetaFiles:a.cachedDirectoryMetaFiles,variants:new Map([[`legacy`,a]]),activeVariant:a,activeGenerations:new Map,generationEpoch:0,disposed:!1}}const m=new Map;function h(e,t,n=!1){if(e.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let r=e.variants.get(t);if(!r&&(r=f(e.docsDir,e.cacheRoot,t),e.variants.set(t,r),e.variants.size>8)){for(let[n,r]of e.variants)if(!(n===t||r===e.activeVariant)&&!e.activeGenerations.has(n)){e.variants.delete(n);break}}return n&&(e.activeVariant=r,e.docCache=r.docCache,e.parserCache=r.parserCache,e.cachedFileList=r.cachedFileList,e.localizedPathCache=r.localizedPathCache,e.cachedNativeDocs=r.cachedNativeDocs,e.frontmatterHashes=r.frontmatterHashes,e.directoryMeta=r.directoryMeta,e.cachedDirectoryMetaFiles=r.cachedDirectoryMetaFiles),r}function g(e,t){e.activeVariant===t&&(e.cachedFileList=t.cachedFileList,e.cachedNativeDocs=t.cachedNativeDocs,e.frontmatterHashes=t.frontmatterHashes,e.directoryMeta=t.directoryMeta,e.cachedDirectoryMetaFiles=t.cachedDirectoryMetaFiles)}function _(e,t){return o.default.createHash(`sha1`).update(JSON.stringify({basePath:t||e?.base||`/docs`,i18n:e?.i18n,versions:e?.versions,drafts:e?.drafts,featureFlags:e?.featureFlags,sidebarGroups:e?.theme?.sidebarGroups})).digest(`hex`)}function v(e,t){let n=u(e),r=m.get(n),i=t??r;(!i||r===i)&&m.delete(n),i&&(i.disposed=!0,i.generationEpoch++,i.activeGenerations.clear(),i.variants.clear(),i.activeVariant=null,i.cachedFileList=null,i.localizedPathCache.clear(),i.cachedNativeDocs=null,i.frontmatterHashes.clear(),i.directoryMeta=null,i.cachedDirectoryMetaFiles=null)}function y(e){let t=u(e),n=m.get(t);return n||(n=p(t),m.set(t,n)),n}const b=p(i.default.resolve(process.cwd(),`docs`)),x=b.docCache;function S(e){try{a.default.rmSync(e.discoverySnapshotPath,{force:!0})}catch{}}function C(e){let t=typeof e==`string`?y(e):e??b;for(let e of t.variants.values())e.cachedFileList=null,e.localizedPathCache.clear(),e.cachedNativeDocs=null,e.frontmatterHashes.clear(),e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,S(e),e.docCache.invalidateAll(),e.parserCache.clear();t.cachedFileList=null,t.localizedPathCache.clear(),t.cachedNativeDocs=null,t.frontmatterHashes.clear(),t.directoryMeta=null,t.cachedDirectoryMetaFiles=null,t.generationEpoch++}function w(e,t){let n=typeof t==`string`?y(t):t??b,r=i.default.resolve(e);for(let e of n.variants.values()){for(let t of e.directoryMetaEntries.keys())i.default.resolve(t)===r&&e.directoryMetaEntries.delete(t);e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,S(e)}n.directoryMeta=null,n.cachedDirectoryMetaFiles=null,n.generationEpoch++}function T(e,t){let n=typeof t==`string`?y(t):t??b;for(let t of n.variants.values())t.docCache.invalidate(e),t.parserCache.invalidate(e),t.cachedNativeDocs?.[e.replace(/\\/g,`/`)]&&delete t.cachedNativeDocs[e.replace(/\\/g,`/`)],t.frontmatterHashes.delete(e);n.cachedNativeDocs=n.activeVariant?.cachedNativeDocs??null,n.frontmatterHashes.delete(e),n.generationEpoch++}function E(e){return e.sort((e,t)=>{let n=e.group?e.groupPosition??999:e.sidebarPosition??999,r=t.group?t.groupPosition??999:t.sidebarPosition??999;return n===r?!e.group&&t.group?-1:e.group&&!t.group?1:e.group&&t.group&&e.group!==t.group?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):D(e,t):n-r})}function D(e,t){if(e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0){let n=e.sidebarPosition-t.sidebarPosition;if(n!==0)return n}else if(e.sidebarPosition!==void 0)return-1;else if(t.sidebarPosition!==void 0)return 1;let n=e.title.localeCompare(t.title);return n===0?e.path.localeCompare(t.path):n}const O=Symbol(`route-generation-invalidated`);async function k(e,t,n){let r=[...t].sort((e,t)=>{if(i.default.dirname(e)===i.default.dirname(t)){let n=i.default.basename(e),r=i.default.basename(t);if(n===`_meta.json`&&r===`meta.json`)return-1;if(n===`meta.json`&&r===`_meta.json`)return 1}return e.localeCompare(t)}),a=new Set(r),o=n.directoryMetaEntries;for(let e of o.keys())a.has(e)||o.delete(e);await Promise.all(r.map(async e=>{let t;try{t=await c.default.stat(e)}catch(t){o.delete(e),(0,s.warn)(`Failed to stat meta.json: ${t instanceof Error?t.message:String(t)}`);return}let n=o.get(e);if(!(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size))try{let n=await c.default.readFile(e,`utf8`);o.set(e,{mtimeMs:t.mtimeMs,size:t.size,content:JSON.parse(n)})}catch(t){o.delete(e),(0,s.warn)(`Failed to read meta.json: ${t instanceof Error?t.message:String(t)}`)}}));let l={};for(let t of r){let n=o.get(t);if(!n)continue;let r=i.default.relative(e,i.default.dirname(t)).replace(/\\/g,`/`);l[r||`.`]=n.content}return l}async function A(e,n){if(!n.discoverySnapshotPath||t.o().noCache)return null;if(n.discoverySnapshotLoaded)return n.discoverySnapshot;n.discoverySnapshotLoaded=!0;try{let t=await c.default.readFile(n.discoverySnapshotPath,`utf8`),r=JSON.parse(t),a=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),o=r.files,s=r.directoryMetaFiles,l=r.directories&&typeof r.directories==`object`?Object.entries(r.directories):[],u=i.default.resolve(e),d=await c.default.realpath(u),f=e=>{let t=i.default.resolve(e);return t===u||t.startsWith(`${u}${i.default.sep}`)},p=e=>/\.(?:md|mdx)$/i.test(e),m=e=>{let t=i.default.basename(e);return t===`meta.json`||t===`_meta.json`};if(r.version!==1||!a(o)||!a(s)||!r.directories||typeof r.directories!=`object`||Array.isArray(r.directories)||o.some(e=>!f(e)||!p(e))||s.some(e=>!f(e)||!m(e))||l.some(([e,t])=>!f(e)||typeof t!=`number`||!Number.isFinite(t)))return null;let h=e=>{let t=i.default.resolve(e);return t===d||t.startsWith(`${d}${i.default.sep}`)},g=await Promise.all([...o,...s].map(async e=>{try{return(await c.default.lstat(e)).isFile()?h(await c.default.realpath(e)):!1}catch{return!1}})),_=await Promise.all(l.map(async([e,t])=>{try{let n=await c.default.stat(e);return n.isDirectory()&&n.mtimeMs===t&&h(await c.default.realpath(e))}catch{return!1}}));if(g.every(Boolean)&&_.every(Boolean)){let e={version:1,files:o,directoryMetaFiles:s,directories:Object.fromEntries(l)};return n.discoverySnapshot=e,e}}catch{}return null}async function j(e,n){if(t.o().noCache){e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1;return}e.discoverySnapshot=n,e.discoverySnapshotLoaded=!0;try{await c.default.mkdir(i.default.dirname(e.discoverySnapshotPath),{recursive:!0}),await c.default.writeFile(e.discoverySnapshotPath,JSON.stringify(n))}catch{}}async function M(e,t,n){if(!n){let n=await A(e,t);if(n)return n}let r=await new l.fdir({excludeSymlinks:!0}).withFullPaths().filter(t=>{let n=i.default.basename(t),r=n===`meta.json`||n===`_meta.json`;return!(t.endsWith(`.md`)||t.endsWith(`.mdx`))&&!r?!1:!i.default.relative(e,t).replace(/\\/g,`/`).split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`&&e!==`_meta.json`)}).crawl(e).withPromise(),a=r.filter(e=>{let t=i.default.basename(e);return t===`meta.json`||t===`_meta.json`}).sort((e,t)=>e.localeCompare(t)),o=r.filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)),s=[/index\./i,/intro/i,/getting-started/i,/readme/i],u=o.map(e=>{let t=s.findIndex(t=>t.test(i.default.basename(e)));return{file:e,score:t===-1?2**53-1:t}});u.sort((e,t)=>e.score-t.score||e.file.localeCompare(t.file));let d=u.map(({file:e})=>e),f=[...d,...a],p=new Set([i.default.resolve(e)]);for(let t of f){let n=i.default.dirname(t);for(;n.startsWith(i.default.resolve(e))&&(p.add(n),n!==i.default.resolve(e));)n=i.default.dirname(n)}let m=await Promise.all([...p].sort().map(async e=>{try{return[e,(await c.default.stat(e)).mtimeMs]}catch{return null}})),h={version:1,files:d,directoryMetaFiles:a,directories:Object.fromEntries(m.filter(e=>e!==null))};return await j(t,h),h}async function N(e,t,n){let r=Array(e.length),i=0;async function a(){for(;i<e.length;){let t=i++;r[t]=await n(e[t])}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>a())),r}function P(e,t){w(e,t)}function F(e,t){let n=typeof t==`string`?y(t):t;if(n){let t=e.replace(/\\/g,`/`);(i.default.basename(t)===`meta.json`||i.default.basename(t)===`_meta.json`)&&w(e,n),n.cachedNativeDocs?.[t]&&delete n.cachedNativeDocs[t],T(e,n);return}T(e)}function I(e){if(e){C(e);return}C()}async function L(e,n,r,a=!1,o,s){let c=o??y(e);if(c.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let l=_(n,r);if(s&&s.fingerprint!==l)throw Error(`[boltdocs] Route cache variant does not match the requested route configuration fingerprint.`);if(s&&c.variants.get(l)!==s)throw Error(`[boltdocs] Route cache variant does not belong to the requested route cache context.`);let u=c.activeGenerations.get(l);if(u)return u;let d=s??h(c,l),f=c.generationEpoch,p=(async()=>{let o=r||n?.base||`/docs`;await d.docCache.load();let s,l,u=await M(e,d,a||t.o().noCache);s=u.files.filter(t=>n?.experimental?.fileRouting?!i.default.relative(e,t).replace(/\\\\/g,`/`).split(`/`).includes(`pages-external`):!0),l=u.directoryMetaFiles,d.cachedFileList=s,d.cachedDirectoryMetaFiles=l,d.directoryMeta=await k(e,l,d),g(c,d),d.docCache.pruneStale(new Set(s));let p=process.env.NODE_ENV===`test`||process.env.VITEST===`true`,m,h=!0;for(let e of s)if(!d.docCache.get(e)){h=!1;break}if(h)m=s.map(e=>{let t=d.docCache.get(e);if(!t)throw Error(`[boltdocs] Route cache entry disappeared for ${e}`);return t});else{if(!p&&!d.cachedNativeDocs)try{let{runParser:t}=await import(`@bdocs/parser`);d.cachedNativeDocs=await t(e,!0)}catch{}if(!p&&d.cachedNativeDocs!==null&&d.cachedNativeDocs){let{parseDocFileWithNative:t}=await Promise.resolve().then(()=>require(`./native-Kre2T5eS.cjs`)),r=s.filter(e=>!d.cachedNativeDocs?.[e.replace(/\\/g,`/`)]);if(r.length>0)try{let{runParserFiles:t}=await import(`@bdocs/parser`),n=await t(e,r,!0);d.cachedNativeDocs={...d.cachedNativeDocs,...n}}catch{}let i=s.some(e=>!d.cachedNativeDocs?.[e.replace(/\\/g,`/`)])?(await Promise.resolve().then(()=>require(`./parser-BqTOsEUa.cjs`))).parseDocFile:void 0;m=await N(s,32,async r=>{let a=d.docCache.get(r);if(a)return a;let s=r.replace(/\\/g,`/`),c=d.cachedNativeDocs[s];if(c){let i=await t(r,c,e,o,n,d.parserCache);return d.docCache.set(r,i),i}else{if(!i)throw Error(`[boltdocs] Native parser did not return a document for ${r}`);let t=await i(r,e,o,n,d.parserCache);return d.docCache.set(r,t),t}})}else{let{parseDocFile:t}=await Promise.resolve().then(()=>require(`./parser-BqTOsEUa.cjs`));m=await N(s,32,async r=>{let i=d.docCache.get(r);if(i)return i;let a=await t(r,e,o,n,d.parserCache);return d.docCache.set(r,a),a})}}if(c.generationEpoch!==f)throw O;d.docCache.save();let _=[],v=new Map,y=process.env.NODE_ENV||`development`,b=n?.drafts?.visible||process.env.BOLTDOCS_DRAFTS===`true`||(n?.drafts?.environments?.includes(y)??!1);for(let e of m)if(!(e.route.draft&&!b)){if(e.route.featureFlags&&n?.featureFlags){if(!e.route.featureFlags.every(e=>{let t=n.featureFlags?.[e];return t===!0||t===y}))continue}else if(e.route.featureFlags&&!n?.featureFlags)continue;if(e.inferredCollection){let t=e.inferredCollection;v.has(t)||v.set(t,[]),v.get(t).push(e)}else _.push(e)}let x=new Map,S=[],C=n?.i18n?.defaultLocale||``;for(let e of _)if(e.isGroupIndex&&e.relativeDir&&S.push(e),e.relativeDir){let n=`${e.route.locale||C}:${e.relativeDir}`,r=x.get(n);r?r.position===void 0&&e.inferredGroupPosition!==void 0&&(r.position=e.inferredGroupPosition):(r={title:t.t(e.relativeDir),position:e.inferredGroupPosition},x.set(n,r))}for(let e of S){let t=`${e.route.locale||C}:${e.relativeDir}`,n=x.get(t);e.groupMeta&&(n.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(n.position=e.groupMeta.position),e.groupMeta.icon&&(n.icon=e.groupMeta.icon))}if(n?.theme?.sidebarGroups){let e=n.i18n?Object.keys(n.i18n.locales):[C];for(let[r,i]of Object.entries(n.theme.sidebarGroups))for(let n of e){let e=`${n}:${r}`,a=x.get(e),o;typeof i.title==`string`?o=i.title:i.title&&(o=i.title[n]||i.title[C]),a?(o&&(a.title=o),i.icon&&(a.icon=i.icon)):x.set(e,{title:o||t.t(r),icon:i.icon})}}let w=Array(_.length);for(let e=0;e<_.length;e++){let n=_[e],r=n.relativeDir,i=n.route.locale||C,a=r?`${i}:${r}`:void 0,o=a?x.get(a):void 0,s;o&&(s=typeof o.title==`string`?o.title:o.title[i]||o.title[C]),w[e]={...n.route,group:r,groupTitle:s||(r?t.t(r):void 0),groupPosition:o?.position,groupIcon:o?.icon}}let T=[];for(let[,e]of v)for(let t of e)T.push({...t.route,collection:t.inferredCollection});T.sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});let D=w;if(n?.i18n){let e=R(w,n,o,d.localizedPathCache);D=[...w,...e]}let A=[...E(D),...T];if(c.generationEpoch!==f)throw O;return A})();c.activeGenerations.set(l,p);try{return await p}catch(t){if(t!==O)throw t;if(c.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);d.docCache.invalidateAll(),d.parserCache.clear(),c.activeGenerations.get(l)===p&&c.activeGenerations.delete(l);let i=0;for(;i<10;)try{return await L(e,n,r,a,c)}catch(e){if(e!==O)throw e;if(c.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);i++}throw Error(`[boltdocs] Route generation was repeatedly invalidated by concurrent file changes.`)}finally{c.activeGenerations.get(l)===p&&c.activeGenerations.delete(l)}}function R(e,t,n,r){let i=t.i18n.defaultLocale,a=Object.keys(t.i18n.locales),o=[],s=new Map,c=[];for(let t of e){let e=t.locale||i;s.has(e)||s.set(e,new Set),s.get(e).add(t.path),e===i&&c.push(t)}for(let e of a){if(e===i)continue;let a=s.get(e)||new Set;for(let s of c){let c=z(s.path,i,e,n,t,r);c!==s.path&&(a.has(c)||o.push({...s,path:c,locale:e}))}}return o}function z(e,t,n,r,i,a){let o=`${e}:${n}`,s=a.get(o);if(s)return s;let c=r.startsWith(`/`)?r:`/`+r,l=c;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let r=`${c}/${t+n.path}`;if(e.startsWith(r)){l=r;break}let i=`${c}/${n.path}`;if(e.startsWith(i)){l=i;break}}}let u=e.substring(l.length),d=`/${t}`;if(u.startsWith(d+`/`))u=`/`+n+`/`+u.substring(d.length+1);else if(u===d)u=`/`+n;else if(u===`/`||u===``)u=`/`+n;else{let e=u.startsWith(`/`)?``:`/`;u=`/`+n+e+u}let f=l+u;return a.size>2e3&&a.clear(),a.set(o,f),f}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return w}});
|
|
6
|
+
const e=require(`./chunk-D1Md3oWO.cjs`),t=require(`./utils-ej6_SjIZ.cjs`),n=require(`./node/cache.cjs`),r=require(`./cache-CJE9nWLE.cjs`);let i=require(`node:path`);i=e.r(i);let a=require(`node:fs`);a=e.r(a);let o=require(`node:crypto`);o=e.r(o);let s=require(`@bdocs/dui`),c=require(`node:fs/promises`);c=e.r(c);let l=require(`fdir`);function u(e){return i.default.resolve(e)}function d(e,t){return o.default.createHash(`sha1`).update(`${u(e)}:${t}`).digest(`hex`).slice(0,16)}function f(e,a,o){let s=d(e,o),c=t.o();return{fingerprint:o,docCache:new n.FileCache({name:`routes-${s}`,root:a}),parserCache:new r.t(a,s),cachedFileList:null,localizedPathCache:new Map,cachedNativeDocs:null,frontmatterHashes:new Map,directoryMeta:null,cachedDirectoryMetaFiles:null,directoryMetaEntries:new Map,discoverySnapshot:null,discoverySnapshotLoaded:!1,discoverySnapshotPath:i.default.resolve(a,c.dir,`route-discovery-${s}.json`)}}function p(e,t=i.default.dirname(i.default.resolve(e))){let n=u(e),r=i.default.resolve(t),a=f(n,r,`legacy`);return{docsDir:n,cacheRoot:r,docCache:a.docCache,parserCache:a.parserCache,cachedFileList:a.cachedFileList,localizedPathCache:a.localizedPathCache,cachedNativeDocs:a.cachedNativeDocs,frontmatterHashes:a.frontmatterHashes,directoryMeta:a.directoryMeta,cachedDirectoryMetaFiles:a.cachedDirectoryMetaFiles,variants:new Map([[`legacy`,a]]),activeVariant:a,activeGenerations:new Map,generationEpoch:0,disposed:!1}}const m=new Map;function h(e,t,n=!1){if(e.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let r=e.variants.get(t);if(!r&&(r=f(e.docsDir,e.cacheRoot,t),e.variants.set(t,r),e.variants.size>8)){for(let[n,r]of e.variants)if(!(n===t||r===e.activeVariant)&&!e.activeGenerations.has(n)){e.variants.delete(n);break}}return n&&(e.activeVariant=r,e.docCache=r.docCache,e.parserCache=r.parserCache,e.cachedFileList=r.cachedFileList,e.localizedPathCache=r.localizedPathCache,e.cachedNativeDocs=r.cachedNativeDocs,e.frontmatterHashes=r.frontmatterHashes,e.directoryMeta=r.directoryMeta,e.cachedDirectoryMetaFiles=r.cachedDirectoryMetaFiles),r}function g(e,t){e.activeVariant===t&&(e.cachedFileList=t.cachedFileList,e.cachedNativeDocs=t.cachedNativeDocs,e.frontmatterHashes=t.frontmatterHashes,e.directoryMeta=t.directoryMeta,e.cachedDirectoryMetaFiles=t.cachedDirectoryMetaFiles)}function _(e,t){return o.default.createHash(`sha1`).update(JSON.stringify({basePath:t||e?.base||`/docs`,i18n:e?.i18n,versions:e?.versions,drafts:e?.drafts,featureFlags:e?.featureFlags,sidebarGroups:e?.theme?.sidebarGroups})).digest(`hex`)}function v(e,t){let n=u(e),r=m.get(n),i=t??r;(!i||r===i)&&m.delete(n),i&&(i.disposed=!0,i.generationEpoch++,i.activeGenerations.clear(),i.variants.clear(),i.activeVariant=null,i.cachedFileList=null,i.localizedPathCache.clear(),i.cachedNativeDocs=null,i.frontmatterHashes.clear(),i.directoryMeta=null,i.cachedDirectoryMetaFiles=null)}function y(e){let t=u(e),n=m.get(t);return n||(n=p(t),m.set(t,n)),n}const b=p(i.default.resolve(process.cwd(),`docs`)),x=b.docCache;function S(e){try{a.default.rmSync(e.discoverySnapshotPath,{force:!0})}catch{}}function C(e){let t=typeof e==`string`?y(e):e??b;for(let e of t.variants.values())e.cachedFileList=null,e.localizedPathCache.clear(),e.cachedNativeDocs=null,e.frontmatterHashes.clear(),e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,S(e),e.docCache.invalidateAll(),e.parserCache.clear();t.cachedFileList=null,t.localizedPathCache.clear(),t.cachedNativeDocs=null,t.frontmatterHashes.clear(),t.directoryMeta=null,t.cachedDirectoryMetaFiles=null,t.generationEpoch++}function w(e,t){let n=typeof t==`string`?y(t):t??b,r=i.default.resolve(e);for(let e of n.variants.values()){for(let t of e.directoryMetaEntries.keys())i.default.resolve(t)===r&&e.directoryMetaEntries.delete(t);e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,S(e)}n.directoryMeta=null,n.cachedDirectoryMetaFiles=null,n.generationEpoch++}function T(e,t){let n=typeof t==`string`?y(t):t??b;for(let t of n.variants.values())t.docCache.invalidate(e),t.parserCache.invalidate(e),t.cachedNativeDocs?.[e.replace(/\\/g,`/`)]&&delete t.cachedNativeDocs[e.replace(/\\/g,`/`)],t.frontmatterHashes.delete(e);n.cachedNativeDocs=n.activeVariant?.cachedNativeDocs??null,n.frontmatterHashes.delete(e),n.generationEpoch++}function E(e){return e.sort((e,t)=>{let n=e.group?e.groupPosition??999:e.sidebarPosition??999,r=t.group?t.groupPosition??999:t.sidebarPosition??999;return n===r?!e.group&&t.group?-1:e.group&&!t.group?1:e.group&&t.group&&e.group!==t.group?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):D(e,t):n-r})}function D(e,t){if(e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0){let n=e.sidebarPosition-t.sidebarPosition;if(n!==0)return n}else if(e.sidebarPosition!==void 0)return-1;else if(t.sidebarPosition!==void 0)return 1;let n=e.title.localeCompare(t.title);return n===0?e.path.localeCompare(t.path):n}const O=Symbol(`route-generation-invalidated`);async function k(e,t,n){let r=[...t].sort((e,t)=>{if(i.default.dirname(e)===i.default.dirname(t)){let n=i.default.basename(e),r=i.default.basename(t);if(n===`_meta.json`&&r===`meta.json`)return-1;if(n===`meta.json`&&r===`_meta.json`)return 1}return e.localeCompare(t)}),a=new Set(r),o=n.directoryMetaEntries;for(let e of o.keys())a.has(e)||o.delete(e);await Promise.all(r.map(async e=>{let t;try{t=await c.default.stat(e)}catch(t){o.delete(e),(0,s.warn)(`Failed to stat meta.json: ${t instanceof Error?t.message:String(t)}`);return}let n=o.get(e);if(!(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size))try{let n=await c.default.readFile(e,`utf8`);o.set(e,{mtimeMs:t.mtimeMs,size:t.size,content:JSON.parse(n)})}catch(t){o.delete(e),(0,s.warn)(`Failed to read meta.json: ${t instanceof Error?t.message:String(t)}`)}}));let l={};for(let t of r){let n=o.get(t);if(!n)continue;let r=i.default.relative(e,i.default.dirname(t)).replace(/\\/g,`/`);l[r||`.`]=n.content}return l}async function A(e,n){if(!n.discoverySnapshotPath||t.o().noCache)return null;if(n.discoverySnapshotLoaded)return n.discoverySnapshot;n.discoverySnapshotLoaded=!0;try{let t=await c.default.readFile(n.discoverySnapshotPath,`utf8`),r=JSON.parse(t),a=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),o=r.files,s=r.directoryMetaFiles,l=r.directories&&typeof r.directories==`object`?Object.entries(r.directories):[],u=i.default.resolve(e),d=await c.default.realpath(u),f=e=>{let t=i.default.resolve(e);return t===u||t.startsWith(`${u}${i.default.sep}`)},p=e=>/\.(?:md|mdx)$/i.test(e),m=e=>{let t=i.default.basename(e);return t===`meta.json`||t===`_meta.json`};if(r.version!==1||!a(o)||!a(s)||!r.directories||typeof r.directories!=`object`||Array.isArray(r.directories)||o.some(e=>!f(e)||!p(e))||s.some(e=>!f(e)||!m(e))||l.some(([e,t])=>!f(e)||typeof t!=`number`||!Number.isFinite(t)))return null;let h=e=>{let t=i.default.resolve(e);return t===d||t.startsWith(`${d}${i.default.sep}`)},g=await Promise.all([...o,...s].map(async e=>{try{return(await c.default.lstat(e)).isFile()?h(await c.default.realpath(e)):!1}catch{return!1}})),_=await Promise.all(l.map(async([e,t])=>{try{let n=await c.default.stat(e);return n.isDirectory()&&n.mtimeMs===t&&h(await c.default.realpath(e))}catch{return!1}}));if(g.every(Boolean)&&_.every(Boolean)){let e={version:1,files:o,directoryMetaFiles:s,directories:Object.fromEntries(l)};return n.discoverySnapshot=e,e}}catch{}return null}async function j(e,n){if(t.o().noCache){e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1;return}e.discoverySnapshot=n,e.discoverySnapshotLoaded=!0;try{await c.default.mkdir(i.default.dirname(e.discoverySnapshotPath),{recursive:!0}),await c.default.writeFile(e.discoverySnapshotPath,JSON.stringify(n))}catch{}}async function M(e,t,n){if(!n){let n=await A(e,t);if(n)return n}let r=await new l.fdir({excludeSymlinks:!0}).withFullPaths().filter(t=>{let n=i.default.basename(t),r=n===`meta.json`||n===`_meta.json`;return!(t.endsWith(`.md`)||t.endsWith(`.mdx`))&&!r?!1:!i.default.relative(e,t).replace(/\\/g,`/`).split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`&&e!==`_meta.json`)}).crawl(e).withPromise(),a=r.filter(e=>{let t=i.default.basename(e);return t===`meta.json`||t===`_meta.json`}).sort((e,t)=>e.localeCompare(t)),o=r.filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)),s=[/index\./i,/intro/i,/getting-started/i,/readme/i],u=o.map(e=>{let t=s.findIndex(t=>t.test(i.default.basename(e)));return{file:e,score:t===-1?2**53-1:t}});u.sort((e,t)=>e.score-t.score||e.file.localeCompare(t.file));let d=u.map(({file:e})=>e),f=[...d,...a],p=new Set([i.default.resolve(e)]);for(let t of f){let n=i.default.dirname(t);for(;n.startsWith(i.default.resolve(e))&&(p.add(n),n!==i.default.resolve(e));)n=i.default.dirname(n)}let m=await Promise.all([...p].sort().map(async e=>{try{return[e,(await c.default.stat(e)).mtimeMs]}catch{return null}})),h={version:1,files:d,directoryMetaFiles:a,directories:Object.fromEntries(m.filter(e=>e!==null))};return await j(t,h),h}async function N(e,t,n){let r=Array(e.length),i=0;async function a(){for(;i<e.length;){let t=i++;r[t]=await n(e[t])}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>a())),r}function P(e,t){w(e,t)}function F(e,t){let n=typeof t==`string`?y(t):t;if(n){let t=e.replace(/\\/g,`/`);(i.default.basename(t)===`meta.json`||i.default.basename(t)===`_meta.json`)&&w(e,n),n.cachedNativeDocs?.[t]&&delete n.cachedNativeDocs[t],T(e,n);return}T(e)}function I(e){if(e){C(e);return}C()}async function L(e,n,r,a=!1,o,s){let c=o??y(e);if(c.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let l=_(n,r);if(s&&s.fingerprint!==l)throw Error(`[boltdocs] Route cache variant does not match the requested route configuration fingerprint.`);if(s&&c.variants.get(l)!==s)throw Error(`[boltdocs] Route cache variant does not belong to the requested route cache context.`);let u=c.activeGenerations.get(l);if(u)return u;let d=s??h(c,l),f=c.generationEpoch,p=(async()=>{let o=r||n?.base||`/docs`;await d.docCache.load();let s,l,u=await M(e,d,a||t.o().noCache);s=u.files.filter(t=>n?.experimental?.fileRouting?!i.default.relative(e,t).replace(/\\\\/g,`/`).split(`/`).includes(`pages-external`):!0),l=u.directoryMetaFiles,d.cachedFileList=s,d.cachedDirectoryMetaFiles=l,d.directoryMeta=await k(e,l,d),g(c,d),d.docCache.pruneStale(new Set(s));let p=process.env.NODE_ENV===`test`||process.env.VITEST===`true`,m,h=!0;for(let e of s)if(!d.docCache.get(e)){h=!1;break}if(h)m=s.map(e=>{let t=d.docCache.get(e);if(!t)throw Error(`[boltdocs] Route cache entry disappeared for ${e}`);return t});else{if(!p&&!d.cachedNativeDocs)try{let{runParser:t}=await import(`@bdocs/parser`);d.cachedNativeDocs=await t(e,!0)}catch{}if(!p&&d.cachedNativeDocs!==null&&d.cachedNativeDocs){let{parseDocFileWithNative:t}=await Promise.resolve().then(()=>require(`./native-nLA4Jr0T.cjs`)),r=s.filter(e=>!d.cachedNativeDocs?.[e.replace(/\\/g,`/`)]);if(r.length>0)try{let{runParserFiles:t}=await import(`@bdocs/parser`),n=await t(e,r,!0);d.cachedNativeDocs={...d.cachedNativeDocs,...n}}catch{}let i=s.some(e=>!d.cachedNativeDocs?.[e.replace(/\\/g,`/`)])?(await Promise.resolve().then(()=>require(`./parser-vPaKvzLp.cjs`))).parseDocFile:void 0;m=await N(s,32,async r=>{let a=d.docCache.get(r);if(a)return a;let s=r.replace(/\\/g,`/`),c=d.cachedNativeDocs[s];if(c){let i=await t(r,c,e,o,n,d.parserCache);return d.docCache.set(r,i),i}else{if(!i)throw Error(`[boltdocs] Native parser did not return a document for ${r}`);let t=await i(r,e,o,n,d.parserCache);return d.docCache.set(r,t),t}})}else{let{parseDocFile:t}=await Promise.resolve().then(()=>require(`./parser-vPaKvzLp.cjs`));m=await N(s,32,async r=>{let i=d.docCache.get(r);if(i)return i;let a=await t(r,e,o,n,d.parserCache);return d.docCache.set(r,a),a})}}if(c.generationEpoch!==f)throw O;d.docCache.save();let _=[],v=new Map,y=process.env.NODE_ENV||`development`,b=n?.drafts?.visible||process.env.BOLTDOCS_DRAFTS===`true`||(n?.drafts?.environments?.includes(y)??!1);for(let e of m)if(!(e.route.draft&&!b)){if(e.route.featureFlags&&n?.featureFlags){if(!e.route.featureFlags.every(e=>{let t=n.featureFlags?.[e];return t===!0||t===y}))continue}else if(e.route.featureFlags&&!n?.featureFlags)continue;if(e.inferredCollection){let t=e.inferredCollection;v.has(t)||v.set(t,[]),v.get(t).push(e)}else _.push(e)}let x=new Map,S=[],C=n?.i18n?.defaultLocale||``;for(let e of _)if(e.isGroupIndex&&e.relativeDir&&S.push(e),e.relativeDir){let n=`${e.route.locale||C}:${e.relativeDir}`,r=x.get(n);r?r.position===void 0&&e.inferredGroupPosition!==void 0&&(r.position=e.inferredGroupPosition):(r={title:t.t(e.relativeDir),position:e.inferredGroupPosition},x.set(n,r))}for(let e of S){let t=`${e.route.locale||C}:${e.relativeDir}`,n=x.get(t);e.groupMeta&&(n.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(n.position=e.groupMeta.position),e.groupMeta.icon&&(n.icon=e.groupMeta.icon))}if(n?.theme?.sidebarGroups){let e=n.i18n?Object.keys(n.i18n.locales):[C];for(let[r,i]of Object.entries(n.theme.sidebarGroups))for(let n of e){let e=`${n}:${r}`,a=x.get(e),o;typeof i.title==`string`?o=i.title:i.title&&(o=i.title[n]||i.title[C]),a?(o&&(a.title=o),i.icon&&(a.icon=i.icon)):x.set(e,{title:o||t.t(r),icon:i.icon})}}let w=Array(_.length);for(let e=0;e<_.length;e++){let n=_[e],r=n.relativeDir,i=n.route.locale||C,a=r?`${i}:${r}`:void 0,o=a?x.get(a):void 0,s;o&&(s=typeof o.title==`string`?o.title:o.title[i]||o.title[C]),w[e]={...n.route,group:r,groupTitle:s||(r?t.t(r):void 0),groupPosition:o?.position,groupIcon:o?.icon}}let T=[];for(let[,e]of v)for(let t of e)T.push({...t.route,collection:t.inferredCollection});T.sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});let D=w;if(n?.i18n){let e=R(w,n,o,d.localizedPathCache);D=[...w,...e]}let A=[...E(D),...T];if(c.generationEpoch!==f)throw O;return A})();c.activeGenerations.set(l,p);try{return await p}catch(t){if(t!==O)throw t;if(c.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);d.docCache.invalidateAll(),d.parserCache.clear(),c.activeGenerations.get(l)===p&&c.activeGenerations.delete(l);let i=0;for(;i<10;)try{return await L(e,n,r,a,c)}catch(e){if(e!==O)throw e;if(c.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);i++}throw Error(`[boltdocs] Route generation was repeatedly invalidated by concurrent file changes.`)}finally{c.activeGenerations.get(l)===p&&c.activeGenerations.delete(l)}}function R(e,t,n,r){let i=t.i18n.defaultLocale,a=Object.keys(t.i18n.locales),o=[],s=new Map,c=[];for(let t of e){let e=t.locale||i;s.has(e)||s.set(e,new Set),s.get(e).add(t.path),e===i&&c.push(t)}for(let e of a){if(e===i)continue;let a=s.get(e)||new Set;for(let s of c){let c=z(s.path,i,e,n,t,r);c!==s.path&&(a.has(c)||o.push({...s,path:c,locale:e}))}}return o}function z(e,t,n,r,i,a){let o=`${e}:${n}`,s=a.get(o);if(s)return s;let c=r.startsWith(`/`)?r:`/`+r,l=c;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let r=`${c}/${t+n.path}`;if(e.startsWith(r)){l=r;break}let i=`${c}/${n.path}`;if(e.startsWith(i)){l=i;break}}}let u=e.substring(l.length),d=`/${t}`;if(u.startsWith(d+`/`))u=`/`+n+`/`+u.substring(d.length+1);else if(u===d)u=`/`+n;else if(u===`/`||u===``)u=`/`+n;else{let e=u.startsWith(`/`)?``:`/`;u=`/`+n+e+u}let f=l+u;return a.size>2e3&&a.clear(),a.set(o,f),f}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return w}});
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
const e=require(`./pages-external-DPiPFxxP.cjs`),t=require(`./routes-
|
|
6
|
+
const e=require(`./pages-external-DPiPFxxP.cjs`),t=require(`./routes-C0kb4ue6.cjs`);exports.generateRoutes=t.t,exports.getExternalRoutePaths=e.n,exports.invalidateDirectoryMetaFile=t.n,exports.invalidateFile=t.r,exports.invalidateRouteCache=t.i;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import{t as e}from"./chunk-BFSpntXv.mjs";import{o as t,t as n}from"./utils-8lzafE49.mjs";import{n as r}from"./pages-external-BBw8ObVK.mjs";import{FileCache as i}from"./node/cache.mjs";import{t as a}from"./cache-OY4HzIXl.mjs";import o from"node:path";import s from"node:fs";import c from"node:crypto";import{warn as l}from"@bdocs/dui";import u from"node:fs/promises";import{fdir as d}from"fdir";function f(e){return o.resolve(e)}function p(e,t){return c.createHash(`sha1`).update(`${f(e)}:${t}`).digest(`hex`).slice(0,16)}function m(e,n,r){let s=p(e,r),c=t();return{fingerprint:r,docCache:new i({name:`routes-${s}`,root:n}),parserCache:new a(n,s),cachedFileList:null,localizedPathCache:new Map,cachedNativeDocs:null,frontmatterHashes:new Map,directoryMeta:null,cachedDirectoryMetaFiles:null,directoryMetaEntries:new Map,discoverySnapshot:null,discoverySnapshotLoaded:!1,discoverySnapshotPath:o.resolve(n,c.dir,`route-discovery-${s}.json`)}}function h(e,t=o.dirname(o.resolve(e))){let n=f(e),r=o.resolve(t),i=m(n,r,`legacy`);return{docsDir:n,cacheRoot:r,docCache:i.docCache,parserCache:i.parserCache,cachedFileList:i.cachedFileList,localizedPathCache:i.localizedPathCache,cachedNativeDocs:i.cachedNativeDocs,frontmatterHashes:i.frontmatterHashes,directoryMeta:i.directoryMeta,cachedDirectoryMetaFiles:i.cachedDirectoryMetaFiles,variants:new Map([[`legacy`,i]]),activeVariant:i,activeGenerations:new Map,generationEpoch:0,disposed:!1}}const g=new Map;function _(e,t,n=!1){if(e.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let r=e.variants.get(t);if(!r&&(r=m(e.docsDir,e.cacheRoot,t),e.variants.set(t,r),e.variants.size>8)){for(let[n,r]of e.variants)if(!(n===t||r===e.activeVariant)&&!e.activeGenerations.has(n)){e.variants.delete(n);break}}return n&&(e.activeVariant=r,e.docCache=r.docCache,e.parserCache=r.parserCache,e.cachedFileList=r.cachedFileList,e.localizedPathCache=r.localizedPathCache,e.cachedNativeDocs=r.cachedNativeDocs,e.frontmatterHashes=r.frontmatterHashes,e.directoryMeta=r.directoryMeta,e.cachedDirectoryMetaFiles=r.cachedDirectoryMetaFiles),r}function v(e,t){e.activeVariant===t&&(e.cachedFileList=t.cachedFileList,e.cachedNativeDocs=t.cachedNativeDocs,e.frontmatterHashes=t.frontmatterHashes,e.directoryMeta=t.directoryMeta,e.cachedDirectoryMetaFiles=t.cachedDirectoryMetaFiles)}function y(e,t){return c.createHash(`sha1`).update(JSON.stringify({basePath:t||e?.base||`/docs`,i18n:e?.i18n,versions:e?.versions,drafts:e?.drafts,featureFlags:e?.featureFlags,sidebarGroups:e?.theme?.sidebarGroups})).digest(`hex`)}function b(e,t){let n=f(e),r=g.get(n),i=t??r;(!i||r===i)&&g.delete(n),i&&(i.disposed=!0,i.generationEpoch++,i.activeGenerations.clear(),i.variants.clear(),i.activeVariant=null,i.cachedFileList=null,i.localizedPathCache.clear(),i.cachedNativeDocs=null,i.frontmatterHashes.clear(),i.directoryMeta=null,i.cachedDirectoryMetaFiles=null)}function x(e){let t=f(e),n=g.get(t);return n||(n=h(t),g.set(t,n)),n}const S=h(o.resolve(process.cwd(),`docs`)),C=S.docCache;function w(e){try{s.rmSync(e.discoverySnapshotPath,{force:!0})}catch{}}function T(e){let t=typeof e==`string`?x(e):e??S;for(let e of t.variants.values())e.cachedFileList=null,e.localizedPathCache.clear(),e.cachedNativeDocs=null,e.frontmatterHashes.clear(),e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,w(e),e.docCache.invalidateAll(),e.parserCache.clear();t.cachedFileList=null,t.localizedPathCache.clear(),t.cachedNativeDocs=null,t.frontmatterHashes.clear(),t.directoryMeta=null,t.cachedDirectoryMetaFiles=null,t.generationEpoch++}function E(e,t){let n=typeof t==`string`?x(t):t??S,r=o.resolve(e);for(let e of n.variants.values()){for(let t of e.directoryMetaEntries.keys())o.resolve(t)===r&&e.directoryMetaEntries.delete(t);e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,w(e)}n.directoryMeta=null,n.cachedDirectoryMetaFiles=null,n.generationEpoch++}function D(e,t){let n=typeof t==`string`?x(t):t??S;for(let t of n.variants.values())t.docCache.invalidate(e),t.parserCache.invalidate(e),t.cachedNativeDocs?.[e.replace(/\\/g,`/`)]&&delete t.cachedNativeDocs[e.replace(/\\/g,`/`)],t.frontmatterHashes.delete(e);n.cachedNativeDocs=n.activeVariant?.cachedNativeDocs??null,n.frontmatterHashes.delete(e),n.generationEpoch++}function O(e){return e.sort((e,t)=>{let n=e.group?e.groupPosition??999:e.sidebarPosition??999,r=t.group?t.groupPosition??999:t.sidebarPosition??999;return n===r?!e.group&&t.group?-1:e.group&&!t.group?1:e.group&&t.group&&e.group!==t.group?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):k(e,t):n-r})}function k(e,t){if(e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0){let n=e.sidebarPosition-t.sidebarPosition;if(n!==0)return n}else if(e.sidebarPosition!==void 0)return-1;else if(t.sidebarPosition!==void 0)return 1;let n=e.title.localeCompare(t.title);return n===0?e.path.localeCompare(t.path):n}var A=e({generateRoutes:()=>B,getExternalRoutePaths:()=>r,invalidateDirectoryMetaFile:()=>L,invalidateFile:()=>R,invalidateRouteCache:()=>z});const j=Symbol(`route-generation-invalidated`);async function M(e,t,n){let r=[...t].sort((e,t)=>{if(o.dirname(e)===o.dirname(t)){let n=o.basename(e),r=o.basename(t);if(n===`_meta.json`&&r===`meta.json`)return-1;if(n===`meta.json`&&r===`_meta.json`)return 1}return e.localeCompare(t)}),i=new Set(r),a=n.directoryMetaEntries;for(let e of a.keys())i.has(e)||a.delete(e);await Promise.all(r.map(async e=>{let t;try{t=await u.stat(e)}catch(t){a.delete(e),l(`Failed to stat meta.json: ${t instanceof Error?t.message:String(t)}`);return}let n=a.get(e);if(!(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size))try{let n=await u.readFile(e,`utf8`);a.set(e,{mtimeMs:t.mtimeMs,size:t.size,content:JSON.parse(n)})}catch(t){a.delete(e),l(`Failed to read meta.json: ${t instanceof Error?t.message:String(t)}`)}}));let s={};for(let t of r){let n=a.get(t);if(!n)continue;let r=o.relative(e,o.dirname(t)).replace(/\\/g,`/`);s[r||`.`]=n.content}return s}async function N(e,n){if(!n.discoverySnapshotPath||t().noCache)return null;if(n.discoverySnapshotLoaded)return n.discoverySnapshot;n.discoverySnapshotLoaded=!0;try{let t=await u.readFile(n.discoverySnapshotPath,`utf8`),r=JSON.parse(t),i=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),a=r.files,s=r.directoryMetaFiles,c=r.directories&&typeof r.directories==`object`?Object.entries(r.directories):[],l=o.resolve(e),d=await u.realpath(l),f=e=>{let t=o.resolve(e);return t===l||t.startsWith(`${l}${o.sep}`)},p=e=>/\.(?:md|mdx)$/i.test(e),m=e=>{let t=o.basename(e);return t===`meta.json`||t===`_meta.json`};if(r.version!==1||!i(a)||!i(s)||!r.directories||typeof r.directories!=`object`||Array.isArray(r.directories)||a.some(e=>!f(e)||!p(e))||s.some(e=>!f(e)||!m(e))||c.some(([e,t])=>!f(e)||typeof t!=`number`||!Number.isFinite(t)))return null;let h=e=>{let t=o.resolve(e);return t===d||t.startsWith(`${d}${o.sep}`)},g=await Promise.all([...a,...s].map(async e=>{try{return(await u.lstat(e)).isFile()?h(await u.realpath(e)):!1}catch{return!1}})),_=await Promise.all(c.map(async([e,t])=>{try{let n=await u.stat(e);return n.isDirectory()&&n.mtimeMs===t&&h(await u.realpath(e))}catch{return!1}}));if(g.every(Boolean)&&_.every(Boolean)){let e={version:1,files:a,directoryMetaFiles:s,directories:Object.fromEntries(c)};return n.discoverySnapshot=e,e}}catch{}return null}async function P(e,n){if(t().noCache){e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1;return}e.discoverySnapshot=n,e.discoverySnapshotLoaded=!0;try{await u.mkdir(o.dirname(e.discoverySnapshotPath),{recursive:!0}),await u.writeFile(e.discoverySnapshotPath,JSON.stringify(n))}catch{}}async function F(e,t,n){if(!n){let n=await N(e,t);if(n)return n}let r=await new d({excludeSymlinks:!0}).withFullPaths().filter(t=>{let n=o.basename(t),r=n===`meta.json`||n===`_meta.json`;return!(t.endsWith(`.md`)||t.endsWith(`.mdx`))&&!r?!1:!o.relative(e,t).replace(/\\/g,`/`).split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`&&e!==`_meta.json`)}).crawl(e).withPromise(),i=r.filter(e=>{let t=o.basename(e);return t===`meta.json`||t===`_meta.json`}).sort((e,t)=>e.localeCompare(t)),a=r.filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)),s=[/index\./i,/intro/i,/getting-started/i,/readme/i],c=a.map(e=>{let t=s.findIndex(t=>t.test(o.basename(e)));return{file:e,score:t===-1?2**53-1:t}});c.sort((e,t)=>e.score-t.score||e.file.localeCompare(t.file));let l=c.map(({file:e})=>e),f=[...l,...i],p=new Set([o.resolve(e)]);for(let t of f){let n=o.dirname(t);for(;n.startsWith(o.resolve(e))&&(p.add(n),n!==o.resolve(e));)n=o.dirname(n)}let m=await Promise.all([...p].sort().map(async e=>{try{return[e,(await u.stat(e)).mtimeMs]}catch{return null}})),h={version:1,files:l,directoryMetaFiles:i,directories:Object.fromEntries(m.filter(e=>e!==null))};return await P(t,h),h}async function I(e,t,n){let r=Array(e.length),i=0;async function a(){for(;i<e.length;){let t=i++;r[t]=await n(e[t])}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>a())),r}function L(e,t){E(e,t)}function R(e,t){let n=typeof t==`string`?x(t):t;if(n){let t=e.replace(/\\/g,`/`);(o.basename(t)===`meta.json`||o.basename(t)===`_meta.json`)&&E(e,n),n.cachedNativeDocs?.[t]&&delete n.cachedNativeDocs[t],D(e,n);return}D(e)}function z(e){if(e){T(e);return}T()}async function B(e,r,i,a=!1,s,c){let l=s??x(e);if(l.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let u=y(r,i);if(c&&c.fingerprint!==u)throw Error(`[boltdocs] Route cache variant does not match the requested route configuration fingerprint.`);if(c&&l.variants.get(u)!==c)throw Error(`[boltdocs] Route cache variant does not belong to the requested route cache context.`);let d=l.activeGenerations.get(u);if(d)return d;let f=c??_(l,u),p=l.generationEpoch,m=(async()=>{let s=i||r?.base||`/docs`;await f.docCache.load();let c,u,d=await F(e,f,a||t().noCache);c=d.files.filter(t=>r?.experimental?.fileRouting?!o.relative(e,t).replace(/\\\\/g,`/`).split(`/`).includes(`pages-external`):!0),u=d.directoryMetaFiles,f.cachedFileList=c,f.cachedDirectoryMetaFiles=u,f.directoryMeta=await M(e,u,f),v(l,f),f.docCache.pruneStale(new Set(c));let m=process.env.NODE_ENV===`test`||process.env.VITEST===`true`,h,g=!0;for(let e of c)if(!f.docCache.get(e)){g=!1;break}if(g)h=c.map(e=>{let t=f.docCache.get(e);if(!t)throw Error(`[boltdocs] Route cache entry disappeared for ${e}`);return t});else{if(!m&&!f.cachedNativeDocs)try{let{runParser:t}=await import(`@bdocs/parser`);f.cachedNativeDocs=await t(e,!0)}catch{}if(!m&&f.cachedNativeDocs!==null&&f.cachedNativeDocs){let{parseDocFileWithNative:t}=await import(`./native-Di9Fnfrv.mjs`).then(e=>e.t),n=c.filter(e=>!f.cachedNativeDocs?.[e.replace(/\\/g,`/`)]);if(n.length>0)try{let{runParserFiles:t}=await import(`@bdocs/parser`),r=await t(e,n,!0);f.cachedNativeDocs={...f.cachedNativeDocs,...r}}catch{}let i=c.some(e=>!f.cachedNativeDocs?.[e.replace(/\\/g,`/`)])?(await import(`./parser-CGMY2lJ7.mjs`)).parseDocFile:void 0;h=await I(c,32,async n=>{let a=f.docCache.get(n);if(a)return a;let o=n.replace(/\\/g,`/`),c=f.cachedNativeDocs[o];if(c){let i=await t(n,c,e,s,r,f.parserCache);return f.docCache.set(n,i),i}else{if(!i)throw Error(`[boltdocs] Native parser did not return a document for ${n}`);let t=await i(n,e,s,r,f.parserCache);return f.docCache.set(n,t),t}})}else{let{parseDocFile:t}=await import(`./parser-CGMY2lJ7.mjs`);h=await I(c,32,async n=>{let i=f.docCache.get(n);if(i)return i;let a=await t(n,e,s,r,f.parserCache);return f.docCache.set(n,a),a})}}if(l.generationEpoch!==p)throw j;f.docCache.save();let _=[],y=new Map,b=process.env.NODE_ENV||`development`,x=r?.drafts?.visible||process.env.BOLTDOCS_DRAFTS===`true`||(r?.drafts?.environments?.includes(b)??!1);for(let e of h)if(!(e.route.draft&&!x)){if(e.route.featureFlags&&r?.featureFlags){if(!e.route.featureFlags.every(e=>{let t=r.featureFlags?.[e];return t===!0||t===b}))continue}else if(e.route.featureFlags&&!r?.featureFlags)continue;if(e.inferredCollection){let t=e.inferredCollection;y.has(t)||y.set(t,[]),y.get(t).push(e)}else _.push(e)}let S=new Map,C=[],w=r?.i18n?.defaultLocale||``;for(let e of _)if(e.isGroupIndex&&e.relativeDir&&C.push(e),e.relativeDir){let t=`${e.route.locale||w}:${e.relativeDir}`,r=S.get(t);r?r.position===void 0&&e.inferredGroupPosition!==void 0&&(r.position=e.inferredGroupPosition):(r={title:n(e.relativeDir),position:e.inferredGroupPosition},S.set(t,r))}for(let e of C){let t=`${e.route.locale||w}:${e.relativeDir}`,n=S.get(t);e.groupMeta&&(n.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(n.position=e.groupMeta.position),e.groupMeta.icon&&(n.icon=e.groupMeta.icon))}if(r?.theme?.sidebarGroups){let e=r.i18n?Object.keys(r.i18n.locales):[w];for(let[t,i]of Object.entries(r.theme.sidebarGroups))for(let r of e){let e=`${r}:${t}`,a=S.get(e),o;typeof i.title==`string`?o=i.title:i.title&&(o=i.title[r]||i.title[w]),a?(o&&(a.title=o),i.icon&&(a.icon=i.icon)):S.set(e,{title:o||n(t),icon:i.icon})}}let T=Array(_.length);for(let e=0;e<_.length;e++){let t=_[e],r=t.relativeDir,i=t.route.locale||w,a=r?`${i}:${r}`:void 0,o=a?S.get(a):void 0,s;o&&(s=typeof o.title==`string`?o.title:o.title[i]||o.title[w]),T[e]={...t.route,group:r,groupTitle:s||(r?n(r):void 0),groupPosition:o?.position,groupIcon:o?.icon}}let E=[];for(let[,e]of y)for(let t of e)E.push({...t.route,collection:t.inferredCollection});E.sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});let D=T;if(r?.i18n){let e=V(T,r,s,f.localizedPathCache);D=[...T,...e]}let k=[...O(D),...E];if(l.generationEpoch!==p)throw j;return k})();l.activeGenerations.set(u,m);try{return await m}catch(t){if(t!==j)throw t;if(l.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);f.docCache.invalidateAll(),f.parserCache.clear(),l.activeGenerations.get(u)===m&&l.activeGenerations.delete(u);let n=0;for(;n<10;)try{return await B(e,r,i,a,l)}catch(e){if(e!==j)throw e;if(l.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);n++}throw Error(`[boltdocs] Route generation was repeatedly invalidated by concurrent file changes.`)}finally{l.activeGenerations.get(u)===m&&l.activeGenerations.delete(u)}}function V(e,t,n,r){let i=t.i18n.defaultLocale,a=Object.keys(t.i18n.locales),o=[],s=new Map,c=[];for(let t of e){let e=t.locale||i;s.has(e)||s.set(e,new Set),s.get(e).add(t.path),e===i&&c.push(t)}for(let e of a){if(e===i)continue;let a=s.get(e)||new Set;for(let s of c){let c=H(s.path,i,e,n,t,r);c!==s.path&&(a.has(c)||o.push({...s,path:c,locale:e}))}}return o}function H(e,t,n,r,i,a){let o=`${e}:${n}`,s=a.get(o);if(s)return s;let c=r.startsWith(`/`)?r:`/`+r,l=c;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let r=`${c}/${t+n.path}`;if(e.startsWith(r)){l=r;break}let i=`${c}/${n.path}`;if(e.startsWith(i)){l=i;break}}}let u=e.substring(l.length),d=`/${t}`;if(u.startsWith(d+`/`))u=`/`+n+`/`+u.substring(d.length+1);else if(u===d)u=`/`+n;else if(u===`/`||u===``)u=`/`+n;else{let e=u.startsWith(`/`)?``:`/`;u=`/`+n+e+u}let f=l+u;return a.size>2e3&&a.clear(),a.set(o,f),f}export{b as a,_ as c,A as i,y as l,R as n,C as o,z as r,x as s,B as t,E as u};
|
|
6
|
+
import{t as e}from"./chunk-BFSpntXv.mjs";import{o as t,t as n}from"./utils-8lzafE49.mjs";import{n as r}from"./pages-external-BBw8ObVK.mjs";import{FileCache as i}from"./node/cache.mjs";import{t as a}from"./cache-OY4HzIXl.mjs";import o from"node:path";import s from"node:fs";import c from"node:crypto";import{warn as l}from"@bdocs/dui";import u from"node:fs/promises";import{fdir as d}from"fdir";function f(e){return o.resolve(e)}function p(e,t){return c.createHash(`sha1`).update(`${f(e)}:${t}`).digest(`hex`).slice(0,16)}function m(e,n,r){let s=p(e,r),c=t();return{fingerprint:r,docCache:new i({name:`routes-${s}`,root:n}),parserCache:new a(n,s),cachedFileList:null,localizedPathCache:new Map,cachedNativeDocs:null,frontmatterHashes:new Map,directoryMeta:null,cachedDirectoryMetaFiles:null,directoryMetaEntries:new Map,discoverySnapshot:null,discoverySnapshotLoaded:!1,discoverySnapshotPath:o.resolve(n,c.dir,`route-discovery-${s}.json`)}}function h(e,t=o.dirname(o.resolve(e))){let n=f(e),r=o.resolve(t),i=m(n,r,`legacy`);return{docsDir:n,cacheRoot:r,docCache:i.docCache,parserCache:i.parserCache,cachedFileList:i.cachedFileList,localizedPathCache:i.localizedPathCache,cachedNativeDocs:i.cachedNativeDocs,frontmatterHashes:i.frontmatterHashes,directoryMeta:i.directoryMeta,cachedDirectoryMetaFiles:i.cachedDirectoryMetaFiles,variants:new Map([[`legacy`,i]]),activeVariant:i,activeGenerations:new Map,generationEpoch:0,disposed:!1}}const g=new Map;function _(e,t,n=!1){if(e.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let r=e.variants.get(t);if(!r&&(r=m(e.docsDir,e.cacheRoot,t),e.variants.set(t,r),e.variants.size>8)){for(let[n,r]of e.variants)if(!(n===t||r===e.activeVariant)&&!e.activeGenerations.has(n)){e.variants.delete(n);break}}return n&&(e.activeVariant=r,e.docCache=r.docCache,e.parserCache=r.parserCache,e.cachedFileList=r.cachedFileList,e.localizedPathCache=r.localizedPathCache,e.cachedNativeDocs=r.cachedNativeDocs,e.frontmatterHashes=r.frontmatterHashes,e.directoryMeta=r.directoryMeta,e.cachedDirectoryMetaFiles=r.cachedDirectoryMetaFiles),r}function v(e,t){e.activeVariant===t&&(e.cachedFileList=t.cachedFileList,e.cachedNativeDocs=t.cachedNativeDocs,e.frontmatterHashes=t.frontmatterHashes,e.directoryMeta=t.directoryMeta,e.cachedDirectoryMetaFiles=t.cachedDirectoryMetaFiles)}function y(e,t){return c.createHash(`sha1`).update(JSON.stringify({basePath:t||e?.base||`/docs`,i18n:e?.i18n,versions:e?.versions,drafts:e?.drafts,featureFlags:e?.featureFlags,sidebarGroups:e?.theme?.sidebarGroups})).digest(`hex`)}function b(e,t){let n=f(e),r=g.get(n),i=t??r;(!i||r===i)&&g.delete(n),i&&(i.disposed=!0,i.generationEpoch++,i.activeGenerations.clear(),i.variants.clear(),i.activeVariant=null,i.cachedFileList=null,i.localizedPathCache.clear(),i.cachedNativeDocs=null,i.frontmatterHashes.clear(),i.directoryMeta=null,i.cachedDirectoryMetaFiles=null)}function x(e){let t=f(e),n=g.get(t);return n||(n=h(t),g.set(t,n)),n}const S=h(o.resolve(process.cwd(),`docs`)),C=S.docCache;function w(e){try{s.rmSync(e.discoverySnapshotPath,{force:!0})}catch{}}function T(e){let t=typeof e==`string`?x(e):e??S;for(let e of t.variants.values())e.cachedFileList=null,e.localizedPathCache.clear(),e.cachedNativeDocs=null,e.frontmatterHashes.clear(),e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,w(e),e.docCache.invalidateAll(),e.parserCache.clear();t.cachedFileList=null,t.localizedPathCache.clear(),t.cachedNativeDocs=null,t.frontmatterHashes.clear(),t.directoryMeta=null,t.cachedDirectoryMetaFiles=null,t.generationEpoch++}function E(e,t){let n=typeof t==`string`?x(t):t??S,r=o.resolve(e);for(let e of n.variants.values()){for(let t of e.directoryMetaEntries.keys())o.resolve(t)===r&&e.directoryMetaEntries.delete(t);e.directoryMeta=null,e.cachedDirectoryMetaFiles=null,e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1,w(e)}n.directoryMeta=null,n.cachedDirectoryMetaFiles=null,n.generationEpoch++}function D(e,t){let n=typeof t==`string`?x(t):t??S;for(let t of n.variants.values())t.docCache.invalidate(e),t.parserCache.invalidate(e),t.cachedNativeDocs?.[e.replace(/\\/g,`/`)]&&delete t.cachedNativeDocs[e.replace(/\\/g,`/`)],t.frontmatterHashes.delete(e);n.cachedNativeDocs=n.activeVariant?.cachedNativeDocs??null,n.frontmatterHashes.delete(e),n.generationEpoch++}function O(e){return e.sort((e,t)=>{let n=e.group?e.groupPosition??999:e.sidebarPosition??999,r=t.group?t.groupPosition??999:t.sidebarPosition??999;return n===r?!e.group&&t.group?-1:e.group&&!t.group?1:e.group&&t.group&&e.group!==t.group?(e.groupTitle||e.group).localeCompare(t.groupTitle||t.group):k(e,t):n-r})}function k(e,t){if(e.sidebarPosition!==void 0&&t.sidebarPosition!==void 0){let n=e.sidebarPosition-t.sidebarPosition;if(n!==0)return n}else if(e.sidebarPosition!==void 0)return-1;else if(t.sidebarPosition!==void 0)return 1;let n=e.title.localeCompare(t.title);return n===0?e.path.localeCompare(t.path):n}var A=e({generateRoutes:()=>B,getExternalRoutePaths:()=>r,invalidateDirectoryMetaFile:()=>L,invalidateFile:()=>R,invalidateRouteCache:()=>z});const j=Symbol(`route-generation-invalidated`);async function M(e,t,n){let r=[...t].sort((e,t)=>{if(o.dirname(e)===o.dirname(t)){let n=o.basename(e),r=o.basename(t);if(n===`_meta.json`&&r===`meta.json`)return-1;if(n===`meta.json`&&r===`_meta.json`)return 1}return e.localeCompare(t)}),i=new Set(r),a=n.directoryMetaEntries;for(let e of a.keys())i.has(e)||a.delete(e);await Promise.all(r.map(async e=>{let t;try{t=await u.stat(e)}catch(t){a.delete(e),l(`Failed to stat meta.json: ${t instanceof Error?t.message:String(t)}`);return}let n=a.get(e);if(!(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size))try{let n=await u.readFile(e,`utf8`);a.set(e,{mtimeMs:t.mtimeMs,size:t.size,content:JSON.parse(n)})}catch(t){a.delete(e),l(`Failed to read meta.json: ${t instanceof Error?t.message:String(t)}`)}}));let s={};for(let t of r){let n=a.get(t);if(!n)continue;let r=o.relative(e,o.dirname(t)).replace(/\\/g,`/`);s[r||`.`]=n.content}return s}async function N(e,n){if(!n.discoverySnapshotPath||t().noCache)return null;if(n.discoverySnapshotLoaded)return n.discoverySnapshot;n.discoverySnapshotLoaded=!0;try{let t=await u.readFile(n.discoverySnapshotPath,`utf8`),r=JSON.parse(t),i=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),a=r.files,s=r.directoryMetaFiles,c=r.directories&&typeof r.directories==`object`?Object.entries(r.directories):[],l=o.resolve(e),d=await u.realpath(l),f=e=>{let t=o.resolve(e);return t===l||t.startsWith(`${l}${o.sep}`)},p=e=>/\.(?:md|mdx)$/i.test(e),m=e=>{let t=o.basename(e);return t===`meta.json`||t===`_meta.json`};if(r.version!==1||!i(a)||!i(s)||!r.directories||typeof r.directories!=`object`||Array.isArray(r.directories)||a.some(e=>!f(e)||!p(e))||s.some(e=>!f(e)||!m(e))||c.some(([e,t])=>!f(e)||typeof t!=`number`||!Number.isFinite(t)))return null;let h=e=>{let t=o.resolve(e);return t===d||t.startsWith(`${d}${o.sep}`)},g=await Promise.all([...a,...s].map(async e=>{try{return(await u.lstat(e)).isFile()?h(await u.realpath(e)):!1}catch{return!1}})),_=await Promise.all(c.map(async([e,t])=>{try{let n=await u.stat(e);return n.isDirectory()&&n.mtimeMs===t&&h(await u.realpath(e))}catch{return!1}}));if(g.every(Boolean)&&_.every(Boolean)){let e={version:1,files:a,directoryMetaFiles:s,directories:Object.fromEntries(c)};return n.discoverySnapshot=e,e}}catch{}return null}async function P(e,n){if(t().noCache){e.discoverySnapshot=null,e.discoverySnapshotLoaded=!1;return}e.discoverySnapshot=n,e.discoverySnapshotLoaded=!0;try{await u.mkdir(o.dirname(e.discoverySnapshotPath),{recursive:!0}),await u.writeFile(e.discoverySnapshotPath,JSON.stringify(n))}catch{}}async function F(e,t,n){if(!n){let n=await N(e,t);if(n)return n}let r=await new d({excludeSymlinks:!0}).withFullPaths().filter(t=>{let n=o.basename(t),r=n===`meta.json`||n===`_meta.json`;return!(t.endsWith(`.md`)||t.endsWith(`.mdx`))&&!r?!1:!o.relative(e,t).replace(/\\/g,`/`).split(`/`).some(e=>e.startsWith(`_`)&&e!==`_index.md`&&e!==`_index.mdx`&&e!==`_meta.json`)}).crawl(e).withPromise(),i=r.filter(e=>{let t=o.basename(e);return t===`meta.json`||t===`_meta.json`}).sort((e,t)=>e.localeCompare(t)),a=r.filter(e=>e.endsWith(`.md`)||e.endsWith(`.mdx`)),s=[/index\./i,/intro/i,/getting-started/i,/readme/i],c=a.map(e=>{let t=s.findIndex(t=>t.test(o.basename(e)));return{file:e,score:t===-1?2**53-1:t}});c.sort((e,t)=>e.score-t.score||e.file.localeCompare(t.file));let l=c.map(({file:e})=>e),f=[...l,...i],p=new Set([o.resolve(e)]);for(let t of f){let n=o.dirname(t);for(;n.startsWith(o.resolve(e))&&(p.add(n),n!==o.resolve(e));)n=o.dirname(n)}let m=await Promise.all([...p].sort().map(async e=>{try{return[e,(await u.stat(e)).mtimeMs]}catch{return null}})),h={version:1,files:l,directoryMetaFiles:i,directories:Object.fromEntries(m.filter(e=>e!==null))};return await P(t,h),h}async function I(e,t,n){let r=Array(e.length),i=0;async function a(){for(;i<e.length;){let t=i++;r[t]=await n(e[t])}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>a())),r}function L(e,t){E(e,t)}function R(e,t){let n=typeof t==`string`?x(t):t;if(n){let t=e.replace(/\\/g,`/`);(o.basename(t)===`meta.json`||o.basename(t)===`_meta.json`)&&E(e,n),n.cachedNativeDocs?.[t]&&delete n.cachedNativeDocs[t],D(e,n);return}D(e)}function z(e){if(e){T(e);return}T()}async function B(e,r,i,a=!1,s,c){let l=s??x(e);if(l.disposed)throw Error(`[boltdocs] Route cache context has been disposed.`);let u=y(r,i);if(c&&c.fingerprint!==u)throw Error(`[boltdocs] Route cache variant does not match the requested route configuration fingerprint.`);if(c&&l.variants.get(u)!==c)throw Error(`[boltdocs] Route cache variant does not belong to the requested route cache context.`);let d=l.activeGenerations.get(u);if(d)return d;let f=c??_(l,u),p=l.generationEpoch,m=(async()=>{let s=i||r?.base||`/docs`;await f.docCache.load();let c,u,d=await F(e,f,a||t().noCache);c=d.files.filter(t=>r?.experimental?.fileRouting?!o.relative(e,t).replace(/\\\\/g,`/`).split(`/`).includes(`pages-external`):!0),u=d.directoryMetaFiles,f.cachedFileList=c,f.cachedDirectoryMetaFiles=u,f.directoryMeta=await M(e,u,f),v(l,f),f.docCache.pruneStale(new Set(c));let m=process.env.NODE_ENV===`test`||process.env.VITEST===`true`,h,g=!0;for(let e of c)if(!f.docCache.get(e)){g=!1;break}if(g)h=c.map(e=>{let t=f.docCache.get(e);if(!t)throw Error(`[boltdocs] Route cache entry disappeared for ${e}`);return t});else{if(!m&&!f.cachedNativeDocs)try{let{runParser:t}=await import(`@bdocs/parser`);f.cachedNativeDocs=await t(e,!0)}catch{}if(!m&&f.cachedNativeDocs!==null&&f.cachedNativeDocs){let{parseDocFileWithNative:t}=await import(`./native-BYKMke79.mjs`).then(e=>e.t),n=c.filter(e=>!f.cachedNativeDocs?.[e.replace(/\\/g,`/`)]);if(n.length>0)try{let{runParserFiles:t}=await import(`@bdocs/parser`),r=await t(e,n,!0);f.cachedNativeDocs={...f.cachedNativeDocs,...r}}catch{}let i=c.some(e=>!f.cachedNativeDocs?.[e.replace(/\\/g,`/`)])?(await import(`./parser-CD8Oo8qh.mjs`)).parseDocFile:void 0;h=await I(c,32,async n=>{let a=f.docCache.get(n);if(a)return a;let o=n.replace(/\\/g,`/`),c=f.cachedNativeDocs[o];if(c){let i=await t(n,c,e,s,r,f.parserCache);return f.docCache.set(n,i),i}else{if(!i)throw Error(`[boltdocs] Native parser did not return a document for ${n}`);let t=await i(n,e,s,r,f.parserCache);return f.docCache.set(n,t),t}})}else{let{parseDocFile:t}=await import(`./parser-CD8Oo8qh.mjs`);h=await I(c,32,async n=>{let i=f.docCache.get(n);if(i)return i;let a=await t(n,e,s,r,f.parserCache);return f.docCache.set(n,a),a})}}if(l.generationEpoch!==p)throw j;f.docCache.save();let _=[],y=new Map,b=process.env.NODE_ENV||`development`,x=r?.drafts?.visible||process.env.BOLTDOCS_DRAFTS===`true`||(r?.drafts?.environments?.includes(b)??!1);for(let e of h)if(!(e.route.draft&&!x)){if(e.route.featureFlags&&r?.featureFlags){if(!e.route.featureFlags.every(e=>{let t=r.featureFlags?.[e];return t===!0||t===b}))continue}else if(e.route.featureFlags&&!r?.featureFlags)continue;if(e.inferredCollection){let t=e.inferredCollection;y.has(t)||y.set(t,[]),y.get(t).push(e)}else _.push(e)}let S=new Map,C=[],w=r?.i18n?.defaultLocale||``;for(let e of _)if(e.isGroupIndex&&e.relativeDir&&C.push(e),e.relativeDir){let t=`${e.route.locale||w}:${e.relativeDir}`,r=S.get(t);r?r.position===void 0&&e.inferredGroupPosition!==void 0&&(r.position=e.inferredGroupPosition):(r={title:n(e.relativeDir),position:e.inferredGroupPosition},S.set(t,r))}for(let e of C){let t=`${e.route.locale||w}:${e.relativeDir}`,n=S.get(t);e.groupMeta&&(n.title=e.groupMeta.title,e.groupMeta.position!==void 0&&(n.position=e.groupMeta.position),e.groupMeta.icon&&(n.icon=e.groupMeta.icon))}if(r?.theme?.sidebarGroups){let e=r.i18n?Object.keys(r.i18n.locales):[w];for(let[t,i]of Object.entries(r.theme.sidebarGroups))for(let r of e){let e=`${r}:${t}`,a=S.get(e),o;typeof i.title==`string`?o=i.title:i.title&&(o=i.title[r]||i.title[w]),a?(o&&(a.title=o),i.icon&&(a.icon=i.icon)):S.set(e,{title:o||n(t),icon:i.icon})}}let T=Array(_.length);for(let e=0;e<_.length;e++){let t=_[e],r=t.relativeDir,i=t.route.locale||w,a=r?`${i}:${r}`:void 0,o=a?S.get(a):void 0,s;o&&(s=typeof o.title==`string`?o.title:o.title[i]||o.title[w]),T[e]={...t.route,group:r,groupTitle:s||(r?n(r):void 0),groupPosition:o?.position,groupIcon:o?.icon}}let E=[];for(let[,e]of y)for(let t of e)E.push({...t.route,collection:t.inferredCollection});E.sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});let D=T;if(r?.i18n){let e=V(T,r,s,f.localizedPathCache);D=[...T,...e]}let k=[...O(D),...E];if(l.generationEpoch!==p)throw j;return k})();l.activeGenerations.set(u,m);try{return await m}catch(t){if(t!==j)throw t;if(l.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);f.docCache.invalidateAll(),f.parserCache.clear(),l.activeGenerations.get(u)===m&&l.activeGenerations.delete(u);let n=0;for(;n<10;)try{return await B(e,r,i,a,l)}catch(e){if(e!==j)throw e;if(l.disposed)throw Error(`[boltdocs] Route cache context was disposed during generation.`);n++}throw Error(`[boltdocs] Route generation was repeatedly invalidated by concurrent file changes.`)}finally{l.activeGenerations.get(u)===m&&l.activeGenerations.delete(u)}}function V(e,t,n,r){let i=t.i18n.defaultLocale,a=Object.keys(t.i18n.locales),o=[],s=new Map,c=[];for(let t of e){let e=t.locale||i;s.has(e)||s.set(e,new Set),s.get(e).add(t.path),e===i&&c.push(t)}for(let e of a){if(e===i)continue;let a=s.get(e)||new Set;for(let s of c){let c=H(s.path,i,e,n,t,r);c!==s.path&&(a.has(c)||o.push({...s,path:c,locale:e}))}}return o}function H(e,t,n,r,i,a){let o=`${e}:${n}`,s=a.get(o);if(s)return s;let c=r.startsWith(`/`)?r:`/`+r,l=c;if(i?.versions){let t=i.versions.prefix||``;for(let n of i.versions.versions){let r=`${c}/${t+n.path}`;if(e.startsWith(r)){l=r;break}let i=`${c}/${n.path}`;if(e.startsWith(i)){l=i;break}}}let u=e.substring(l.length),d=`/${t}`;if(u.startsWith(d+`/`))u=`/`+n+`/`+u.substring(d.length+1);else if(u===d)u=`/`+n;else if(u===`/`||u===``)u=`/`+n;else{let e=u.startsWith(`/`)?``:`/`;u=`/`+n+e+u}let f=l+u;return a.size>2e3&&a.clear(),a.set(o,f),f}export{b as a,_ as c,A as i,y as l,R as n,C as o,z as r,x as s,B as t,E as u};
|
package/dist/server/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../adapters-
|
|
6
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../adapters-DwDTQoCG.cjs`);exports.handleAwsFeedback=e.t,exports.handleNetlifyFeedback=e.r,exports.handleVercelFeedback=e.i,exports.handleWebFeedback=e.n;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { i as handleVercelFeedback, n as handleWebFeedback, r as handleNetlifyFeedback, t as handleAwsFeedback } from "../index-
|
|
2
|
+
import { i as handleVercelFeedback, n as handleWebFeedback, r as handleNetlifyFeedback, t as handleAwsFeedback } from "../index-HAwIo4nZ.mjs";
|
|
3
3
|
export { handleAwsFeedback, handleNetlifyFeedback, handleVercelFeedback, handleWebFeedback };
|
package/dist/server/index.mjs
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import{i as e,n as t,r as n,t as r}from"../adapters-
|
|
6
|
+
import{i as e,n as t,r as n,t as r}from"../adapters-BKzKe2mO.mjs";export{r as handleAwsFeedback,n as handleNetlifyFeedback,e as handleVercelFeedback,t as handleWebFeedback};
|
|
@@ -131,15 +131,86 @@ interface BoltdocsThemeConfig {
|
|
|
131
131
|
text: string | Record<string, string>;
|
|
132
132
|
icon?: string;
|
|
133
133
|
}>;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Legacy alias for `codeHighlighting.theme`. Kept for backwards
|
|
136
|
+
* compatibility — prefer `codeHighlighting`.
|
|
137
|
+
* @deprecated Use `codeHighlighting` instead.
|
|
138
|
+
*/
|
|
139
|
+
codeTheme?: CodeTheme;
|
|
140
|
+
/**
|
|
141
|
+
* Configures the markdown code highlighting engine. The engine is
|
|
142
|
+
* engine-agnostic: `engine` accepts a registry id (`'shiki'` by default),
|
|
143
|
+
* an adapter instance, or an adapter factory — so any highlighter can be
|
|
144
|
+
* plugged in without changes to the core.
|
|
145
|
+
*
|
|
146
|
+
* Shorthand: a plain string is a registry id, i.e. `'shiki'` is
|
|
147
|
+
* equivalent to `{ engine: 'shiki' }` (resolved by
|
|
148
|
+
* `normalizeCodeHighlightConfig()` at every read site).
|
|
149
|
+
*/
|
|
150
|
+
codeHighlighting?: CodeHighlightConfig | string;
|
|
138
151
|
}
|
|
139
152
|
/**
|
|
140
|
-
*
|
|
153
|
+
* An engine-agnostic theme: either a single theme name or a light/dark pair.
|
|
141
154
|
*/
|
|
142
|
-
type
|
|
155
|
+
type CodeTheme = string | {
|
|
156
|
+
light: string;
|
|
157
|
+
dark: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Runtime produced by a {@link CodeHighlighterAdapter} after initialization.
|
|
161
|
+
*/
|
|
162
|
+
interface CodeHighlighterRuntime {
|
|
163
|
+
codeToHast(code: string, options: Record<string, unknown>): unknown;
|
|
164
|
+
codeToHtml(code: string, options: Record<string, unknown>): Promise<string>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The SPI every highlighting engine must implement. Build the highlighter
|
|
168
|
+
* lazily via {@link CodeHighlighterAdapter.initialize} (never on module load)
|
|
169
|
+
* so unused engines cost nothing and the core stays engine-agnostic.
|
|
170
|
+
*/
|
|
171
|
+
interface CodeHighlighterAdapter {
|
|
172
|
+
/** Registry id, emitted as `data-code-engine` on rendered `<pre>` blocks. */
|
|
173
|
+
name: string;
|
|
174
|
+
version?: string;
|
|
175
|
+
/** Assemble engine options for a code block (theme, transformers, meta...). */
|
|
176
|
+
getOptions(lang: string, meta: ParsedMetaLike): Record<string, unknown>;
|
|
177
|
+
/** Create (or reuse) the highlighter runtime for this adapter. */
|
|
178
|
+
initialize(): Promise<CodeHighlighterRuntime>;
|
|
179
|
+
/** Ensure a language grammar/capability is loaded before rendering. */
|
|
180
|
+
ensureLanguage?(lang: string): Promise<boolean>;
|
|
181
|
+
/** Warm the highlighter off the critical path (background, never awaited). */
|
|
182
|
+
prewarm?(options?: Record<string, unknown>): void | Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Minimal structural view of `ParsedMeta` so `shared/types.ts` (bundled to
|
|
186
|
+
* the client) does not depend on `@bdocs/unist-utils`. The framework's
|
|
187
|
+
* canonical implementation lives in `@bdocs/unist-utils`.
|
|
188
|
+
*/
|
|
189
|
+
interface ParsedMetaLike {
|
|
190
|
+
title?: string;
|
|
191
|
+
lineNumbers?: boolean;
|
|
192
|
+
wordWrap?: boolean;
|
|
193
|
+
__raw?: string;
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* How to select a highlighting engine:
|
|
198
|
+
* - `string` → registry id (e.g. `'shiki'`, or a plugin-provided engine name)
|
|
199
|
+
* - `CodeHighlighterAdapter` → used directly
|
|
200
|
+
* - `() => CodeHighlighterAdapter | Promise<...>` → factory resolved on demand
|
|
201
|
+
*/
|
|
202
|
+
type CodeHighlighterEngine = string | CodeHighlighterAdapter | ((api: CodeHighlightConfig) => CodeHighlighterAdapter | Promise<CodeHighlighterAdapter>);
|
|
203
|
+
/**
|
|
204
|
+
* Engine-agnostic configuration for markdown code highlighting.
|
|
205
|
+
*/
|
|
206
|
+
interface CodeHighlightConfig {
|
|
207
|
+
/** Engine selector. Defaults to the built-in `'shiki'` engine. */
|
|
208
|
+
engine?: CodeHighlighterEngine;
|
|
209
|
+
/** Single theme name or a light/dark pair. */
|
|
210
|
+
theme?: CodeTheme;
|
|
211
|
+
/** Engine-specific options (e.g. `{ regexEngine: 'oniguruma' | 'javascript' }` for Shiki). */
|
|
212
|
+
options?: Record<string, unknown>;
|
|
213
|
+
}
|
|
143
214
|
/**
|
|
144
215
|
* Configuration for the robots.txt file.
|
|
145
216
|
*/
|
|
@@ -842,6 +913,11 @@ interface BoltdocsIntegrationsConfig {
|
|
|
842
913
|
interface BoltdocsSsgConfig {
|
|
843
914
|
/** Critical CSS strategy; `none` disables critical CSS processing. */
|
|
844
915
|
criticalCss?: 'zig-critters' | 'beasties' | 'none';
|
|
916
|
+
/**
|
|
917
|
+
* Per-page budget (bytes) for inlined critical CSS. Pages exceeding it get
|
|
918
|
+
* no inline critical CSS (with a build warning). Default: 24576 (24KB).
|
|
919
|
+
*/
|
|
920
|
+
criticalCssMaxSize?: number;
|
|
845
921
|
}
|
|
846
922
|
/**
|
|
847
923
|
* Configuration for drafts visibility control.
|
|
@@ -896,29 +972,4 @@ type BoltdocsRoutePath = keyof Boltdocs.RoutePaths;
|
|
|
896
972
|
type ExternalRouteReference = `/${string}` | `#${string}` | `?${string}` | `site:/${string}` | `site:${string}` | `http://${string}` | `https://${string}` | `//${string}`;
|
|
897
973
|
type BoltdocsRoutePathWithFallback = BoltdocsRoutePath | ExternalRouteReference | string;
|
|
898
974
|
//#endregion
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Type-safe helper for defining Boltdocs configuration.
|
|
902
|
-
* This is an identity function that provides IntelliSense in both
|
|
903
|
-
* Node.js (config files) and client-side code (MDX examples).
|
|
904
|
-
*
|
|
905
|
-
* @remarks
|
|
906
|
-
* Intended for use in `boltdocs.config.ts` (Node.js context). This function
|
|
907
|
-
* is **not** available as a client-side import from `boltdocs/client`.
|
|
908
|
-
*
|
|
909
|
-
* @param config - The Boltdocs configuration object
|
|
910
|
-
*/
|
|
911
|
-
declare function defineConfig(config: BoltdocsConfig): BoltdocsConfig;
|
|
912
|
-
//#endregion
|
|
913
|
-
//#region src/node/config.d.ts
|
|
914
|
-
/**
|
|
915
|
-
* Loads user's configuration file (e.g., `boltdocs.config.js` or `boltdocs.config.ts`) if it exists,
|
|
916
|
-
* merges it with the default configuration, and returns the final `BoltdocsConfig`.
|
|
917
|
-
*
|
|
918
|
-
* @param docsDir - The directory containing the documentation files
|
|
919
|
-
* @param root - The project root directory (defaults to process.cwd())
|
|
920
|
-
* @returns The merged configuration object
|
|
921
|
-
*/
|
|
922
|
-
declare function resolveConfig(docsDir: string, root?: string, command?: string, mode?: string): Promise<BoltdocsConfig>;
|
|
923
|
-
//#endregion
|
|
924
|
-
export { StructuredData as C, ShikiTheme as S, PluginServerMiddleware as _, BoltdocsThemeConfig as a, RegisteredVirtualModule as b, ExternalFileRoute as c, JsonLdValue as d, PluginContext as f, PluginMeta as g, PluginLogger as h, BoltdocsExperimentalConfig as i, IPluginLifecycleManager as l, PluginLifecycleHooks as m, defineConfig as n, BoltdocsViewTransitionsConfig as o, PluginHmrEvent as p, BoltdocsConfig as r, DiagnosticRecord as s, resolveConfig as t, JsonLdObject as u, PluginStore as v, RouteMeta as x, PluginTransformMiddleware as y };
|
|
975
|
+
export { PluginTransformMiddleware as C, StructuredData as E, PluginStore as S, RouteMeta as T, PluginHmrEvent as _, CodeHighlightConfig as a, PluginMeta as b, CodeHighlighterRuntime as c, ExternalFileRoute as d, IPluginLifecycleManager as f, PluginContext as g, ParsedMetaLike as h, BoltdocsViewTransitionsConfig as i, CodeTheme as l, JsonLdValue as m, BoltdocsExperimentalConfig as n, CodeHighlighterAdapter as o, JsonLdObject as p, BoltdocsThemeConfig as r, CodeHighlighterEngine as s, BoltdocsConfig as t, DiagnosticRecord as u, PluginLifecycleHooks as v, RegisteredVirtualModule as w, PluginServerMiddleware as x, PluginLogger as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
3
2
|
import * as _$http from "http";
|
|
3
|
+
import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
4
4
|
//#region src/shared/types.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Metadata representing a single documentation route.
|
|
@@ -131,15 +131,86 @@ interface BoltdocsThemeConfig {
|
|
|
131
131
|
text: string | Record<string, string>;
|
|
132
132
|
icon?: string;
|
|
133
133
|
}>;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Legacy alias for `codeHighlighting.theme`. Kept for backwards
|
|
136
|
+
* compatibility — prefer `codeHighlighting`.
|
|
137
|
+
* @deprecated Use `codeHighlighting` instead.
|
|
138
|
+
*/
|
|
139
|
+
codeTheme?: CodeTheme;
|
|
140
|
+
/**
|
|
141
|
+
* Configures the markdown code highlighting engine. The engine is
|
|
142
|
+
* engine-agnostic: `engine` accepts a registry id (`'shiki'` by default),
|
|
143
|
+
* an adapter instance, or an adapter factory — so any highlighter can be
|
|
144
|
+
* plugged in without changes to the core.
|
|
145
|
+
*
|
|
146
|
+
* Shorthand: a plain string is a registry id, i.e. `'shiki'` is
|
|
147
|
+
* equivalent to `{ engine: 'shiki' }` (resolved by
|
|
148
|
+
* `normalizeCodeHighlightConfig()` at every read site).
|
|
149
|
+
*/
|
|
150
|
+
codeHighlighting?: CodeHighlightConfig | string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* An engine-agnostic theme: either a single theme name or a light/dark pair.
|
|
154
|
+
*/
|
|
155
|
+
type CodeTheme = string | {
|
|
156
|
+
light: string;
|
|
157
|
+
dark: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Runtime produced by a {@link CodeHighlighterAdapter} after initialization.
|
|
161
|
+
*/
|
|
162
|
+
interface CodeHighlighterRuntime {
|
|
163
|
+
codeToHast(code: string, options: Record<string, unknown>): unknown;
|
|
164
|
+
codeToHtml(code: string, options: Record<string, unknown>): Promise<string>;
|
|
138
165
|
}
|
|
139
166
|
/**
|
|
140
|
-
*
|
|
167
|
+
* The SPI every highlighting engine must implement. Build the highlighter
|
|
168
|
+
* lazily via {@link CodeHighlighterAdapter.initialize} (never on module load)
|
|
169
|
+
* so unused engines cost nothing and the core stays engine-agnostic.
|
|
141
170
|
*/
|
|
142
|
-
|
|
171
|
+
interface CodeHighlighterAdapter {
|
|
172
|
+
/** Registry id, emitted as `data-code-engine` on rendered `<pre>` blocks. */
|
|
173
|
+
name: string;
|
|
174
|
+
version?: string;
|
|
175
|
+
/** Assemble engine options for a code block (theme, transformers, meta...). */
|
|
176
|
+
getOptions(lang: string, meta: ParsedMetaLike): Record<string, unknown>;
|
|
177
|
+
/** Create (or reuse) the highlighter runtime for this adapter. */
|
|
178
|
+
initialize(): Promise<CodeHighlighterRuntime>;
|
|
179
|
+
/** Ensure a language grammar/capability is loaded before rendering. */
|
|
180
|
+
ensureLanguage?(lang: string): Promise<boolean>;
|
|
181
|
+
/** Warm the highlighter off the critical path (background, never awaited). */
|
|
182
|
+
prewarm?(options?: Record<string, unknown>): void | Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Minimal structural view of `ParsedMeta` so `shared/types.ts` (bundled to
|
|
186
|
+
* the client) does not depend on `@bdocs/unist-utils`. The framework's
|
|
187
|
+
* canonical implementation lives in `@bdocs/unist-utils`.
|
|
188
|
+
*/
|
|
189
|
+
interface ParsedMetaLike {
|
|
190
|
+
title?: string;
|
|
191
|
+
lineNumbers?: boolean;
|
|
192
|
+
wordWrap?: boolean;
|
|
193
|
+
__raw?: string;
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* How to select a highlighting engine:
|
|
198
|
+
* - `string` → registry id (e.g. `'shiki'`, or a plugin-provided engine name)
|
|
199
|
+
* - `CodeHighlighterAdapter` → used directly
|
|
200
|
+
* - `() => CodeHighlighterAdapter | Promise<...>` → factory resolved on demand
|
|
201
|
+
*/
|
|
202
|
+
type CodeHighlighterEngine = string | CodeHighlighterAdapter | ((api: CodeHighlightConfig) => CodeHighlighterAdapter | Promise<CodeHighlighterAdapter>);
|
|
203
|
+
/**
|
|
204
|
+
* Engine-agnostic configuration for markdown code highlighting.
|
|
205
|
+
*/
|
|
206
|
+
interface CodeHighlightConfig {
|
|
207
|
+
/** Engine selector. Defaults to the built-in `'shiki'` engine. */
|
|
208
|
+
engine?: CodeHighlighterEngine;
|
|
209
|
+
/** Single theme name or a light/dark pair. */
|
|
210
|
+
theme?: CodeTheme;
|
|
211
|
+
/** Engine-specific options (e.g. `{ regexEngine: 'oniguruma' | 'javascript' }` for Shiki). */
|
|
212
|
+
options?: Record<string, unknown>;
|
|
213
|
+
}
|
|
143
214
|
/**
|
|
144
215
|
* Configuration for the robots.txt file.
|
|
145
216
|
*/
|
|
@@ -842,6 +913,11 @@ interface BoltdocsIntegrationsConfig {
|
|
|
842
913
|
interface BoltdocsSsgConfig {
|
|
843
914
|
/** Critical CSS strategy; `none` disables critical CSS processing. */
|
|
844
915
|
criticalCss?: 'zig-critters' | 'beasties' | 'none';
|
|
916
|
+
/**
|
|
917
|
+
* Per-page budget (bytes) for inlined critical CSS. Pages exceeding it get
|
|
918
|
+
* no inline critical CSS (with a build warning). Default: 24576 (24KB).
|
|
919
|
+
*/
|
|
920
|
+
criticalCssMaxSize?: number;
|
|
845
921
|
}
|
|
846
922
|
/**
|
|
847
923
|
* Configuration for drafts visibility control.
|
|
@@ -896,29 +972,4 @@ type BoltdocsRoutePath = keyof Boltdocs.RoutePaths;
|
|
|
896
972
|
type ExternalRouteReference = `/${string}` | `#${string}` | `?${string}` | `site:/${string}` | `site:${string}` | `http://${string}` | `https://${string}` | `//${string}`;
|
|
897
973
|
type BoltdocsRoutePathWithFallback = BoltdocsRoutePath | ExternalRouteReference | string;
|
|
898
974
|
//#endregion
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Type-safe helper for defining Boltdocs configuration.
|
|
902
|
-
* This is an identity function that provides IntelliSense in both
|
|
903
|
-
* Node.js (config files) and client-side code (MDX examples).
|
|
904
|
-
*
|
|
905
|
-
* @remarks
|
|
906
|
-
* Intended for use in `boltdocs.config.ts` (Node.js context). This function
|
|
907
|
-
* is **not** available as a client-side import from `boltdocs/client`.
|
|
908
|
-
*
|
|
909
|
-
* @param config - The Boltdocs configuration object
|
|
910
|
-
*/
|
|
911
|
-
declare function defineConfig(config: BoltdocsConfig): BoltdocsConfig;
|
|
912
|
-
//#endregion
|
|
913
|
-
//#region src/node/config.d.ts
|
|
914
|
-
/**
|
|
915
|
-
* Loads user's configuration file (e.g., `boltdocs.config.js` or `boltdocs.config.ts`) if it exists,
|
|
916
|
-
* merges it with the default configuration, and returns the final `BoltdocsConfig`.
|
|
917
|
-
*
|
|
918
|
-
* @param docsDir - The directory containing the documentation files
|
|
919
|
-
* @param root - The project root directory (defaults to process.cwd())
|
|
920
|
-
* @returns The merged configuration object
|
|
921
|
-
*/
|
|
922
|
-
declare function resolveConfig(docsDir: string, root?: string, command?: string, mode?: string): Promise<BoltdocsConfig>;
|
|
923
|
-
//#endregion
|
|
924
|
-
export { StructuredData as C, ShikiTheme as S, PluginServerMiddleware as _, BoltdocsThemeConfig as a, RegisteredVirtualModule as b, ExternalFileRoute as c, JsonLdValue as d, PluginContext as f, PluginMeta as g, PluginLogger as h, BoltdocsExperimentalConfig as i, IPluginLifecycleManager as l, PluginLifecycleHooks as m, defineConfig as n, BoltdocsViewTransitionsConfig as o, PluginHmrEvent as p, BoltdocsConfig as r, DiagnosticRecord as s, resolveConfig as t, JsonLdObject as u, PluginStore as v, RouteMeta as x, PluginTransformMiddleware as y };
|
|
975
|
+
export { PluginTransformMiddleware as C, StructuredData as E, PluginStore as S, RouteMeta as T, PluginHmrEvent as _, CodeHighlightConfig as a, PluginMeta as b, CodeHighlighterRuntime as c, ExternalFileRoute as d, IPluginLifecycleManager as f, PluginContext as g, ParsedMetaLike as h, BoltdocsViewTransitionsConfig as i, CodeTheme as l, JsonLdValue as m, BoltdocsExperimentalConfig as n, CodeHighlighterAdapter as o, JsonLdObject as p, BoltdocsThemeConfig as r, CodeHighlighterEngine as s, BoltdocsConfig as t, DiagnosticRecord as u, PluginLifecycleHooks as v, RegisteredVirtualModule as w, PluginServerMiddleware as x, PluginLogger as y };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boltdocs - https://boltdocs.vercel.app
|
|
3
|
+
* Copyright (c) 2026 Jesus Alcala
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
import{_ as e,g as t,h as n}from"./plugin-context-BKK-nfOd.mjs";import{u as r}from"./utils-8lzafE49.mjs";import{c as i,l as a,s as o,t as s}from"./routes-C4wrLWwu.mjs";import c from"node:path";import l from"node:fs";function u(e){return typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(u):e&&typeof e==`object`?Object.values(e).flatMap(u):[]}const d=new Set([`title`,`description`,`permalink`,`sidebarPosition`,`sidebarLabel`,`sidebarHidden`,`hidden`,`category`,`order`,`badge`,`icon`,`date`,`lastUpdated`,`groupTitle`,`groupPosition`,`seo`]);function f(e){let t=[];for(let n of e){let e=``;n.frontmatter&&(e=u(Object.entries(n.frontmatter).filter(([e])=>!d.has(e)).map(([e,t])=>t)).join(` `));let r=(e?`${n._content||``} ${e}`:n._content||``).slice(0,500);if(t.push({id:n.path,title:n.title,content:r,url:n.path,display:n.groupTitle?`${n.groupTitle} > ${n.title}`:n.title,locale:n.locale,version:n.version}),n.headings)for(let e of n.headings)t.push({id:`${n.path}#${e.id}`,title:e.text,content:`${e.text} in ${n.title}`,url:`${n.path}#${e.id}`,display:`${n.title} > ${e.text}`,locale:n.locale,version:n.version})}return t}function p(e){return{path:e.path,filePath:e.filePath,title:e.title,description:e.description||``,sidebarPosition:e.sidebarPosition,badge:e.badge,icon:e.icon,headings:e.headings||[],frontmatter:e.frontmatter,locale:e.locale,version:e.version,tab:e.tab,collection:e.collection,tags:e.tags,author:e.author,draft:e.draft,excerpt:e.excerpt,coverImage:e.coverImage,group:e.group,groupTitle:e.groupTitle,groupPosition:e.groupPosition,groupIcon:e.groupIcon,subRouteGroup:e.subRouteGroup,seo:e.seo,date:e.date,lastUpdated:e.lastUpdated,category:e.category,order:e.order,sidebarLabel:e.sidebarLabel,sidebarHidden:e.sidebarHidden,slugParts:e.slugParts}}function m(e){return{routeCacheContext:e,routeGenerationFingerprint:void 0,directoryMetaCache:null,routesDataMap:new Map,collectionsDataMap:new Map,searchDataMap:new Map}}const h=m();function g(e){return e??h}function _(e){let t=g(e);t.directoryMetaCache=null,t.routeGenerationFingerprint=void 0,t.routeCacheVariant=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()}function v(e,t){return(!t.routeCacheContext||t.routeCacheContext.disposed)&&(t.routeCacheContext=o(e),t.routeCacheVariant=void 0,t.routeGenerationFingerprint=void 0,t.routesDataMap.clear(),t.collectionsDataMap.clear(),t.searchDataMap.clear()),t.routeCacheContext}async function y(e,t,n,r){let o=g(n),c=v(e,o),l=a(t),u=(r?.fingerprint===l&&c.variants.get(l)===r?r:void 0)??i(c,l);o.routeCacheVariant=u,o.routeGenerationFingerprint=l;let d=await s(e,t,void 0,!1,c,u);o.routesDataMap.clear();for(let e of d)o.routesDataMap.set(e.path,e);b(o)}function b(e){let t=g(e),n=Array.from(t.routesDataMap.values()),r=f(n);t.searchDataMap.clear();for(let e of r)t.searchDataMap.set(e.id,e);t.collectionsDataMap.clear();for(let e of n)if(e.collection){let n={path:e.path,title:e.title,date:e.date,excerpt:e.excerpt,tags:e.tags,author:e.author,coverImage:e.coverImage,filePath:e.filePath,locale:e.locale,version:e.version,frontmatter:e.frontmatter,draft:e.frontmatter?.draft,collection:e.collection};t.collectionsDataMap.set(e.filePath,n)}}async function x(e,t,n){let r=g(n);v(e,r);let i=a(t);(r.routesDataMap.size===0||r.routeGenerationFingerprint!==i)&&(r.routesDataMap.clear(),r.collectionsDataMap.clear(),r.searchDataMap.clear(),await y(e,t,r))}function S(e){let t=g(e),n={},r=Array.from(t.collectionsDataMap.values()).sort((e,t)=>{let n=e=>{if(!e)return-1/0;let t=new Date(e).getTime();return Number.isFinite(t)?t:-1/0},r=n(e.date),i=n(t.date)-r;return i===0?e.path.localeCompare(t.path):i});for(let e of r){let t=e.collection;t&&(n[t]||(n[t]=[]),n[t].push(e))}return n}function C(e,t=e=>e){let n=Array.from(e.values(),t).sort((e,t)=>{let n=e=>{if(typeof e!=`object`||!e)return String(e);let t=e;return`${String(t.path||``)}\u0000${String(t.id||``)}\u0000${String(t.filePath||``)}`};return n(e).localeCompare(n(t))});return`export default ${JSON.stringify(n)};`}function w(e){return Array.from(g(e).searchDataMap.values()).sort((e,t)=>e.id.localeCompare(t.id))}function T(e){return`export default ${JSON.stringify(e)};`}async function E(e,t,n,r,i){let o=g(n);r&&(o.routeCacheContext=r),i&&(o.routeCacheVariant=i);let s=a(t);o.routeGenerationFingerprint!==s&&(o.routesDataMap.clear(),o.collectionsDataMap.clear(),o.searchDataMap.clear());let c=new Map(o.routesDataMap),l=new Map(o.collectionsDataMap),u=new Map(o.searchDataMap);await y(e,t,o);let d={routes:{updated:[],deleted:[]},collections:{updated:[],deleted:[]},search:{updated:[],deleted:[]}};for(let[e,t]of o.routesDataMap){let n=c.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.routes.updated.push(p(t))}for(let e of c.keys())o.routesDataMap.has(e)||d.routes.deleted.push(e);for(let[e,t]of o.collectionsDataMap){let n=l.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.collections.updated.push(t)}for(let e of l.keys())o.collectionsDataMap.has(e)||d.collections.deleted.push(e);for(let[e,t]of o.searchDataMap){let n=u.get(e);(!n||JSON.stringify(n)!==JSON.stringify(t))&&d.search.updated.push(t)}for(let e of u.keys())o.searchDataMap.has(e)||d.search.deleted.push(e);return d}function D(i,a,o,s,u,d){let f=u?.virtualModuleRegistry??n,m=g(d);return{name:`vite-plugin-boltdocs-virtual-modules`,resolveId(e){if(o()?.root||process.cwd(),e.includes(`boltdocs-entry`)||e===`virtual:boltdocs-entry`||e===`boltdocs/entry`||e===`boltdocs-entry`||e===`\0virtual:boltdocs-entry`||e===`\0virtual:boltdocs-entry.tsx`)return`\0virtual:boltdocs-entry.tsx`;if(e.includes(`boltdocs-client`)||e===`virtual:boltdocs-client`||e===`boltdocs/client`||e===`boltdocs-client`||e===`\0virtual:boltdocs-client.mjs`)return`\0virtual:boltdocs-client.mjs`;if(e.startsWith(`\0`)){let t=e.slice(1);if(!t.startsWith(`virtual:boltdocs-`)&&f?.has(t))return e}else if(!e.startsWith(`virtual:boltdocs-`)&&f?.has(e))return`\0`+e;return e.startsWith(`virtual:boltdocs-`)?`\0`+e:e.startsWith(`\0virtual:boltdocs-`)?e:null},async load(n,u){let d=a(),h=n.startsWith(`\0`)?n.slice(1):n;if(!h.includes(`boltdocs-entry.tsx`)&&!h.includes(`boltdocs-client.mjs`)&&!h.startsWith(`virtual:boltdocs-`)&&f?.has(h)){let e=f?.get(h);if(!e)return null;try{let t=await e.loader();if(typeof t!=`string`)throw Error(`[boltdocs] Plugin virtual module '${h}' loader must return a string source code, got ${typeof t}.`);return t}catch(e){throw Error(`[boltdocs] Plugin virtual module '${h}' failed to load: ${e instanceof Error?e.message:String(e)}`)}}if(n.includes(`boltdocs-entry.tsx`)||n===`\0virtual:boltdocs-entry`){let e=this.environment?.config?.consumer,n=o(),r=e===void 0?!!n?.build?.ssr:e!==`client`;return t({...i,ssr:r,useCompiledPages:n?.command===`build`},d)}if(n.includes(`boltdocs-client.mjs`)||n===`\0virtual:boltdocs-client.ts`||n===`virtual:boltdocs-client`){let t=e,n=t;for(;t!==c.parse(t).root;){if(l.existsSync(c.join(t,`package.json`))&&JSON.parse(l.readFileSync(c.join(t,`package.json`),`utf-8`)).name===`boltdocs`){n=t;break}t=c.dirname(t)}let i=c.join(n,`src/client/index.ts`),a=c.join(n,`dist/client/index.js`);return`export * from '${r(l.existsSync(i)?i:a)}';`}if(!n.startsWith(`\0virtual:boltdocs-`))return;let g=n.replace(`\0virtual:boltdocs-`,``).replace(/\.tsx?$/,``);if(g===`routes`)return await x(s,d,m),C(m.routesDataMap,p);if(g===`collections`)return await x(s,d,m),T(S(m));if(g===`config`){await x(s,d,m);let e=m.routeCacheVariant?.directoryMeta||{};m.directoryMetaCache=e;let t=[...new Set(Array.from(m.routesDataMap.values()).map(e=>e.collection).filter(e=>!!e))].sort((e,t)=>e.localeCompare(t)),n=d?.collections,r=n?{...n,labels:{...n.labels||{},...Object.fromEntries(t.map(e=>[e,n.labels?.[e]??e]))}}:t.length>0?t:void 0,i={base:d?.base,theme:d?.theme,i18n:d?.i18n,versions:d?.versions,siteUrl:d?.siteUrl,integrations:d?.integrations,collections:r,seo:d?.seo,experimental:d?.experimental,plugins:d?.plugins?.map(e=>({name:e.name})),directoryMeta:e};return`export default ${JSON.stringify(i,null,2)};`}if(g===`entry`){let e=this,n=o(),r=e.environment?.config?.consumer,a=r===void 0?!!(u?.ssr??n?.build?.ssr):r!==`client`;return t({...i,ssr:a,useCompiledPages:n?.command===`build`},d)}if(g===`mdx-components`){let e=[`tsx`,`ts`,`jsx`,`js`],t=null;for(let n of e){let e=c.resolve(s,`mdx-components.${n}`);if(l.existsSync(e)){t=e;break}}let n={};if(d?.plugins)for(let e of d.plugins)e.components&&Object.assign(n,e.components);let i=Object.entries(n),a=i.map(([e,t],n)=>`import * as _pluginCompMod_${n} from '${t}';`).join(`
|
|
7
|
+
`),o=i.map(([e],t)=>`${JSON.stringify(e)}: _pluginCompMod_${t}[${JSON.stringify(e)}] || _pluginCompMod_${t}["default"] || _pluginCompMod_${t}`).join(`,
|
|
8
|
+
`);if(t){let e=r(t);return`${a}
|
|
9
|
+
import * as components from '${e}';
|
|
10
|
+
const userMdxComponents = components.default || components;
|
|
11
|
+
const mdxComponents = {
|
|
12
|
+
${o}${o?`,`:``}
|
|
13
|
+
...userMdxComponents,
|
|
14
|
+
};
|
|
15
|
+
export default mdxComponents;
|
|
16
|
+
export * from '${e}';`}return`${a}
|
|
17
|
+
const mdxComponents = {
|
|
18
|
+
${o}
|
|
19
|
+
};
|
|
20
|
+
export default mdxComponents;`}if(g===`layout`){let e=[`tsx`,`jsx`],t=null;for(let n of e){let e=c.resolve(s,`layout.${n}`);if(l.existsSync(e)){t=e;break}}if(t)return`import UserLayout from '${r(t)}';
|
|
21
|
+
export default UserLayout;`;throw Error(`[Boltdocs] Layout file not found. A 'layout.tsx' or 'layout.jsx' file is mandatory in your docs directory. Please create one to define your site structure.`)}if(g===`icons`){let e=[`tsx`,`jsx`,`ts`,`js`],t=null;for(let n of e){let e=c.resolve(s,`icons.${n}`);if(l.existsSync(e)){t=e;break}}return t?`import * as icons from '${r(t)}';\nexport default icons;`:`export default {};`}if(g===`search`)return await x(s,d,m),`export default async function fetchSearchData(options = {}) {
|
|
22
|
+
const base = import.meta.env.BASE_URL || '/';
|
|
23
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
24
|
+
const basePath = base.endsWith('/') ? base : base + '/';
|
|
25
|
+
const url = new URL('search.json', new URL(basePath, origin));
|
|
26
|
+
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
27
|
+
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
28
|
+
if (!res.ok) throw new Error('Failed to fetch search index');
|
|
29
|
+
return res.json();
|
|
30
|
+
}`;if(g===`page-source`){await x(s,d,m);let e={};for(let t of m.routesDataMap.values())t.path&&t._rawContent&&(e[t.path]=t._rawContent);return`export default async function fetchPageSource(options = {}) {
|
|
31
|
+
const base = import.meta.env.BASE_URL || '/';
|
|
32
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';
|
|
33
|
+
const basePath = base.endsWith('/') ? base : base + '/';
|
|
34
|
+
const url = new URL('page-source.json', new URL(basePath, origin));
|
|
35
|
+
if (options.bustCache) url.searchParams.set('t', String(Date.now()));
|
|
36
|
+
const res = await fetch(url, { cache: options.bustCache ? 'no-store' : 'default' });
|
|
37
|
+
if (!res.ok) throw new Error('Failed to fetch page source');
|
|
38
|
+
return res.json();
|
|
39
|
+
}`}if(g===`client`){let t=e,n=``;for(;t&&t!==c.parse(t).root;){let e=c.join(t,`src/client/index.ts`),i=c.join(t,`dist/client/index.mjs`),a=c.join(t,`client/index.ts`);if(l.existsSync(e)){n=r(e);break}if(l.existsSync(i)){n=r(i);break}if(l.existsSync(a)){n=r(a);break}t=c.dirname(t)}if(!n)throw Error(`[boltdocs] Could not resolve boltdocs/client entry point starting from ${e}`);return`export * from '${n}';`}}}}export{E as computeFrontmatterDelta,m as createVirtualModuleState,D as createVirtualModulesPlugin,w as getSearchDataExport,_ as invalidateDirectoryMetaCache};
|