@stacksjs/bunpress 0.2.32 → 0.2.33
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/bin/cli.js +1 -1
- package/dist/{chunk-15vwh1bm.js → chunk-19em34hd.js} +1 -1
- package/dist/chunk-9kzche7g.js +2 -0
- package/dist/{chunk-f5ycxw18.js → chunk-dgdd6yma.js} +2 -2
- package/dist/{chunk-ttas3mc2.js → chunk-ds2b3vtw.js} +200 -125
- package/dist/{chunk-ebrg03kn.js → chunk-hnkqm0qx.js} +6 -6
- package/dist/{chunk-verdt5gx.js → chunk-nr19j5pk.js} +1 -1
- package/dist/{chunk-gn1n2yxt.js → chunk-twt99rzk.js} +1 -1
- package/dist/{chunk-5dtz0br7.js → chunk-zxfhq634.js} +2 -2
- package/dist/src/highlighter.d.ts +43 -1
- package/dist/src/hoist-styles.d.ts +3 -0
- package/dist/src/index.js +1 -1
- package/dist/src/long-page.d.ts +51 -0
- package/dist/src/minify-css.d.ts +1 -0
- package/dist/templates/layout-doc.stx +1 -1
- package/dist/templates/sidebar-section.stx +0 -192
- package/dist/templates/sidebar.stx +194 -0
- package/package.json +1 -1
- package/dist/chunk-fy78hg56.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{w as f4,x as c4,z as p4}from"./chunk-zxfhq634.js";import{B as g4,C as O,E as $4,J as w4,K as b4,L as v4,_ as d4,aa as u4,da as r,ea as l4}from"./chunk-dgdd6yma.js";import{ga as F,ha as i}from"./chunk-twt99rzk.js";var{Glob:g6}=globalThis.Bun;import{copyFile as f6,mkdir as c6,readdir as p6}from"fs/promises";import{existsSync as d6}from"fs";import{join as v,resolve as u6}from"path";import S from"process";import{CLI as l6}from"@stacksjs/clapp";var p="0.2.33";import{randomUUID as e4}from"crypto";import{mkdir as R4,mkdtemp as K6,readFile as Q6,realpath as Z6,rename as o,rm as d,rmdir as $6,writeFile as X6}from"fs/promises";import{basename as Y6,dirname as W4,join as q4,resolve as N6}from"path";var u=new Map;async function H6(K,Z){let Q=u.get(K)??Promise.resolve(),$,Y=new Promise((H)=>{$=H}),X=Q.then(()=>Y);u.set(K,X),await Q;try{return await Z()}finally{if($(),u.get(K)===X)u.delete(K)}}function _6(K){return K!==null&&typeof K==="object"&&"code"in K&&K.code==="ENOENT"}async function G4(K,Z,Q){let $=N6(K);await R4(W4($),{recursive:!0});let Y=q4(await Z6(W4($)),Y6($));return H6(Y,async()=>{let X=`${Y}.lock`;try{await R4(X,{mode:448})}catch(V){if(V!==null&&typeof V==="object"&&"code"in V&&V.code==="EEXIST")throw Error(`Documentation output is locked: ${X}. Verify the recorded owner has stopped before removing a stale lock.`);throw V}let H=JSON.stringify({pid:process.pid,token:e4()}),N=q4(X,"owner.json"),_,R,q=!1,G=!1;try{await X6(N,H,{flag:"wx",mode:384}),_=await K6(`${Y}.tmp-`);let V=await Z(_),U=`${_}.previous`;try{await o(Y,U),R=U}catch(W){if(!_6(W))throw W}if(await o(_,Y),q=!0,await Q?.(),G=!0,R)await d(R,{recursive:!0});return V}catch(V){if(!G&&(q||R))try{if(q)await d(Y,{recursive:!0});if(R)await o(R,Y)}catch(U){throw AggregateError([V,U],`Documentation publication failed; previous output is retained at ${R??Y}`)}throw V}finally{try{if(_)await d(_,{recursive:!0,force:!0})}finally{if(await Q6(N,"utf8").catch(()=>{return})===H)await d(N),await $6(X);else throw Error(`Documentation output lock ownership changed: ${X}`)}}})}var{Glob:R6}=globalThis.Bun;import{dirname as W6,relative as q6,resolve as l,sep as V4}from"path";import{mkdir as G6}from"fs/promises";function A4(K){return V4==="/"?K:K.split(V4).join("/")}function V6(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function j4(K,Z,Q){let $=l(K),Y=Q?A4(q6($,l(Q))):void 0,X=[],H=new R6("**/*");for await(let R of H.scan({cwd:$,onlyFiles:!0})){let q=A4(R);if(q===Y)continue;X.push(q)}X.sort((R,q)=>R.localeCompare(q));let N=[],_=new Bun.CryptoHasher("sha256");for(let R of X){let q=new Uint8Array(await Bun.file(l($,R)).arrayBuffer()),G=V6(q);N.push({path:R,bytes:q.byteLength,sha256:G}),_.update(`${R}\x00${q.byteLength}\x00${G}
|
|
3
3
|
`)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:N,tree_sha256:_.digest("hex")}}async function M4(K,Z,Q){let $=await j4(K,Q,Z);return await G6(W6(l(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
|
|
4
4
|
`),$}function J4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function U4(K,Z,Q){let $=await Bun.file(Z).json();if($.schema_version!==1||$.generator!=="bunpress"||!Array.isArray($.outputs))throw Error(`Unsupported or malformed BunPress build manifest: ${Z}`);let Y=await j4(K,Q,Z);if(JSON.stringify(Y)===JSON.stringify($))return Y;let X=J4($),H=J4(Y),N=Y.outputs.filter((G)=>!X.has(G.path)).map((G)=>G.path),_=$.outputs.filter((G)=>!H.has(G.path)).map((G)=>G.path),R=Y.outputs.filter((G)=>{let V=X.get(G.path);return V&&(V.bytes!==G.bytes||V.sha256!==G.sha256)}).map((G)=>{let V=X.get(G.path);return`${G.path} [bytes ${V.bytes} -> ${G.bytes}; sha256 ${V.sha256} -> ${G.sha256}]`}),q=[$.generator_version!==Y.generator_version?`generator ${$.generator_version} -> ${Y.generator_version}`:"",N.length?`added: ${N.join(", ")}`:"",_.length?`removed: ${_.join(", ")}`:"",R.length?`changed: ${R.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${q.join("; ")||"tree hash changed"}`)}import{existsSync as A6}from"fs";import{rm as J6}from"fs/promises";import{join as j6}from"path";var I={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m"};function z(K,Z){return`${I[Z]}${K}${I.reset}`}function T(K){console.log(`${I.green}\u2713${I.reset} ${K}`)}function A(K){console.error(`${I.red}\u2717${I.reset} ${K}`)}function h(K){console.warn(`${I.yellow}\u26A0${I.reset} ${K}`)}function B(K){console.log(`${I.blue}\u2139${I.reset} ${K}`)}function w(K){if(K===0)return"0 B";let Z=1024,Q=["B","KB","MB","GB"],$=Math.floor(Math.log(K)/Math.log(Z));return`${Number.parseFloat((K/Z**$).toFixed(2))} ${Q[$]}`}function t(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var B4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class C{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(B4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${I.cyan}${K}${I.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),A(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!B4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function a(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${I.cyan}?${I.reset} ${K} ${I.dim}(${Q})${I.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:X}=await $.read(),H=Y.decode(X).trim().toLowerCase();if(!H)return Z;return H==="y"||H==="yes"}function g(K){if(K.length===0)return;let Z=Object.keys(K[0]),Q={};for(let Y of Z)Q[Y]=Math.max(Y.length,...K.map((X)=>String(X[Y]).length));let $=Z.map((Y)=>Y.padEnd(Q[Y])).join(" ");console.log(z($,"bold")),console.log("\u2500".repeat($.length));for(let Y of K){let X=Z.map((H)=>String(Y[H]).padEnd(Q[H])).join(" ");console.log(X)}}async function n(K){try{return Bun.file(K).size}catch{return 0}}async function M6(K){try{let{Glob:Z}=awaitPromise.resolve(globalThis.Bun),Q=new Z("**/*"),$=0;for await(let Y of Q.scan(K)){let X=`${K}/${Y}`,H=await n(X);$+=H}return $}catch{return 0}}async function T4(K={}){let Z=await O,Q=K.outdir||Z.outDir||"./dist",$=j6(Q,".bunpress"),Y=K.force||!1,X=K.verbose||!1;try{if(!A6($))return B(`Directory "${$}" does not exist, nothing to clean`),!0;let N=await M6($);if(X)B(`Found "${$}" (${w(N)})`);if(!Y){if(!await a(`Delete "${$}" directory? (${w(N)})`,!1))return B("Clean cancelled"),!1}let _=process.env.VITEST==="true"||!1,R=null;if(!_&&!X)R=new C("Cleaning build artifacts..."),R.start();if(await J6($,{recursive:!0,force:!0}),R)R.succeed(`Cleaned ${w(N)} from "${$}"`);else if(X||_)T(`Cleaned ${w(N)} from "${$}"`);return!0}catch(H){return A(`Failed to clean directory: ${H}`),!1}}import{existsSync as e}from"fs";import{join as K4}from"path";async function z4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let X=K4(process.cwd(),Y);if(e(X)){Q=X;break}}if(!Q)return A("No configuration file found"),B('Run "bunpress config init" to create one'),!1;T(`Configuration file: ${Q}`),console.log();let $=await Bun.file(Q).text();return console.log(z("Configuration:","bold")),console.log($),!0}catch(Z){return A(`Failed to show configuration: ${Z}`),!1}}async function O4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let _ of Q){let R=K4(process.cwd(),_);if(e(R)){$=R;break}}if(!$)return A("No configuration file found"),!1;if(Z)B(`Validating ${$}...`);let X=(await import($)).default;if(!X)return A("Configuration file does not export a default object"),!1;let H=[],N=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")H.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")H.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))H.push("nav should be an array");else for(let[_,R]of X.nav.entries())if(!R.text||!R.link)H.push(`nav[${_}] is missing required fields (text, link)`)}if(!i(X))N.push("no `url` set: sitemap, RSS, canonical links and Open Graph tags are all skipped without an absolute base URL");if(H.length>0){A("Configuration validation failed:");for(let _ of H)console.log(` \u2022 ${_}`);return!1}for(let _ of N)h(_);return T("Configuration is valid \u2713"),!0}catch(Q){return A(`Failed to validate configuration: ${Q}`),!1}}async function L4(K={}){let Z=K4(process.cwd(),"bunpress.config.ts");if(e(Z))return A("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
|
|
5
5
|
|
|
@@ -290,8 +290,8 @@ ${Z}`}async function y6(K){let Z=[];async function Q($){let Y=await b.promises.r
|
|
|
290
290
|
`)){let X=Y.match(/^#{1,6}\s+(.*)$/);if(!X)continue;let H=X[1].trim(),N=H.match(/\{#([\w-]+)\}\s*$/),_=N?N[1]:b4(w4(H));if(!_)continue;v4(_,Q)}}catch{}return y4.set(K,Q),Q}function k6(K){let Z=[],Q=/!\[([^\]]*)\]\(([^)]+)\)/g,$;while(($=Q.exec(K))!==null){let Y=$[1],X=$[2];if(!Y||Y.trim()==="")Z.push(X)}return Z}function P6(K){if(console.log(""),B("\uD83D\uDCCA SEO Report"),console.log(""),console.log(`Total pages checked: ${z(K.totalPages.toString(),"blue")}`),console.log(`Passed: ${z(K.passed.toString(),"green")}`),console.log(`Errors: ${z(K.errors.length.toString(),K.errors.length>0?"red":"green")}`),console.log(`Warnings: ${z(K.warnings.length.toString(),K.warnings.length>0?"yellow":"green")}`),console.log(""),K.errors.length>0){A(`\u2717 ${K.errors.length} errors found:`),console.log("");let Z=K.errors.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(Z),console.log("")}if(K.warnings.length>0){h(`\u26A0 ${K.warnings.length} warnings found:`),console.log("");let Z=K.warnings.map((Q)=>({Category:Q.category,File:Q.file,Message:Q.message}));g(Z),console.log("")}if(K.errors.length===0&&K.warnings.length===0)T("\u2713 All SEO checks passed!");else if(K.errors.length===0)T("\u2713 No errors found (only warnings)")}import{join as h6}from"path";async function m6(K){let Z=await Bun.file(K).text(),Q=Z.split(`
|
|
291
291
|
`),$=0,Y=!1,X=[];for(let R of Q){if(R.trim().startsWith("```")){Y=!Y;continue}if(!Y)X.push(R)}$=X.join(" ").split(/\s+/).filter((R)=>R.length>0).length;let N=Q.filter((R)=>R.match(/^#{1,6}\s+/)).length,_=(Z.match(/```/g)||[]).length/2;return{path:K,size:await n(K),lines:Q.length,words:$,headings:N,codeBlocks:Math.floor(_)}}async function h4(K={}){let Z=await O,Q=K.dir||Z.docsDir||"./docs",$=K.verbose||!1;try{console.log(z(`
|
|
292
292
|
Analyzing documentation...
|
|
293
|
-
`,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),X=new Y("**/*.md"),H=[];for await(let j of X.scan(Q)){let J=h6(Q,j),f=await m6(J);H.push(f)}if(H.length===0)return A("No markdown files found"),!1;let N=H.reduce((j,J)=>j+J.size,0),_=H.reduce((j,J)=>j+J.lines,0),R=H.reduce((j,J)=>j+J.words,0),q=H.reduce((j,J)=>j+J.headings,0),G=H.reduce((j,J)=>j+J.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${H.length}`),console.log(`Total size: ${w(N)}`),console.log(`Total lines: ${_.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${q}`),console.log(`Code blocks: ${G}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let j=H.map((J)=>({File:J.path.replace(`${Q}/`,""),Size:w(J.size),Lines:J.lines,Words:J.words,Headings:J.headings,"Code Blocks":J.codeBlocks}));g(j),console.log()}let V=N/H.length,U=_/H.length,W=R/H.length;console.log(z("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${w(V)}`),console.log(`Lines: ${Math.round(U)}`),console.log(`Words: ${Math.round(W)}`),console.log();let E=[...H].sort((j,J)=>J.size-j.size).slice(0,5);if(E.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let j of E){let J=j.path.replace(`${Q}/`,"");console.log(` ${J.padEnd(40)} ${w(j.size)}`)}console.log()}let x=Math.ceil(R/200);return B(`Estimated reading time: ${x} minutes`),!0}catch(Y){return A(`Failed to generate statistics: ${Y}`),!1}}var L=new l6("bunpress"),M={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function a6(K,Z,Q=!1){let $=`${Z}/public`;try{await p6($);let Y=new g6("**/*");for await(let X of Y.scan($)){let H=v($,X),N=v(K,X);await c6(v(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await f6(H,N)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}async function n6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await u4(K,Q);if(await Bun.write(v(Z,d4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function i6(K,Z,Q,$){try{if(Q.sitemap?.enabled!==!1&&i(Q))await p4(K,Z,Q);if(Q.robots?.enabled!==!1)await c4(Z,Q);if(Q.rss?.enabled)await f4(K,Z,Q,Q.rss)}catch(Y){if($)console.error("Error generating SEO files:",Y)}}async function s6(K={}){let Z=await O;if(!K.config)return Z;let Q=u6(S.cwd(),K.config);if(!d6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return g4({...Z,...Y})}async function m4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await s6(K),Q=K.outdir||Z.outDir||M.outdir,$=v(Q,".bunpress"),Y=K.dir||Z.docsDir||M.docsdir,X=K.verbose??M.verbose,H=performance.now(),N=new C("Building documentation...");if(!X)N.start();try{let _=await G4($,async(q)=>{let G=await r(Y);if(G.length===0)throw Error("No markdown files found in docs directory");if(X)console.log(`Found ${G.length} markdown files:`),G.forEach((y)=>console.log(`- ${y}`));let{markdownToHtml:V,wrapInLayout:U}=await import("./chunk-
|
|
294
|
-
Generated ${_} HTML files in ${$}`);return!0}catch(_){if(!X)N.fail("Build failed");return console.error("Error during build:",_),!1}}async function r6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-
|
|
293
|
+
`,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),X=new Y("**/*.md"),H=[];for await(let j of X.scan(Q)){let J=h6(Q,j),f=await m6(J);H.push(f)}if(H.length===0)return A("No markdown files found"),!1;let N=H.reduce((j,J)=>j+J.size,0),_=H.reduce((j,J)=>j+J.lines,0),R=H.reduce((j,J)=>j+J.words,0),q=H.reduce((j,J)=>j+J.headings,0),G=H.reduce((j,J)=>j+J.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${H.length}`),console.log(`Total size: ${w(N)}`),console.log(`Total lines: ${_.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${q}`),console.log(`Code blocks: ${G}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let j=H.map((J)=>({File:J.path.replace(`${Q}/`,""),Size:w(J.size),Lines:J.lines,Words:J.words,Headings:J.headings,"Code Blocks":J.codeBlocks}));g(j),console.log()}let V=N/H.length,U=_/H.length,W=R/H.length;console.log(z("Averages per File","bold")),console.log("\u2500".repeat(50)),console.log(`Size: ${w(V)}`),console.log(`Lines: ${Math.round(U)}`),console.log(`Words: ${Math.round(W)}`),console.log();let E=[...H].sort((j,J)=>J.size-j.size).slice(0,5);if(E.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let j of E){let J=j.path.replace(`${Q}/`,"");console.log(` ${J.padEnd(40)} ${w(j.size)}`)}console.log()}let x=Math.ceil(R/200);return B(`Estimated reading time: ${x} minutes`),!0}catch(Y){return A(`Failed to generate statistics: ${Y}`),!1}}var L=new l6("bunpress"),M={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function a6(K,Z,Q=!1){let $=`${Z}/public`;try{await p6($);let Y=new g6("**/*");for await(let X of Y.scan($)){let H=v($,X),N=v(K,X);await c6(v(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await f6(H,N)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}async function n6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await u4(K,Q);if(await Bun.write(v(Z,d4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function i6(K,Z,Q,$){try{if(Q.sitemap?.enabled!==!1&&i(Q))await p4(K,Z,Q);if(Q.robots?.enabled!==!1)await c4(Z,Q);if(Q.rss?.enabled)await f4(K,Z,Q,Q.rss)}catch(Y){if($)console.error("Error generating SEO files:",Y)}}async function s6(K={}){let Z=await O;if(!K.config)return Z;let Q=u6(S.cwd(),K.config);if(!d6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return g4({...Z,...Y})}async function m4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await s6(K),Q=K.outdir||Z.outDir||M.outdir,$=v(Q,".bunpress"),Y=K.dir||Z.docsDir||M.docsdir,X=K.verbose??M.verbose,H=performance.now(),N=new C("Building documentation...");if(!X)N.start();try{let _=await G4($,async(q)=>{let G=await r(Y);if(G.length===0)throw Error("No markdown files found in docs directory");if(X)console.log(`Found ${G.length} markdown files:`),G.forEach((y)=>console.log(`- ${y}`));let{markdownToHtml:V,wrapInLayout:U}=await import("./chunk-9kzche7g.js"),{loadI18nTranslations:W,resolveI18nConfig:E}=await import("./chunk-19em34hd.js"),{mkdir:x,writeFile:j}=await import("fs/promises"),J=await W(E(Z),Z);if(X)console.log("Transforming markdown to HTML...");let f=l4(G,Y,J),Y4=f.pages;for(let y of Y4){let a4=await Bun.file(y.sourceFile).text(),{html:n4,frontmatter:N4}=await V(a4,Y,{page:y,catalog:f}),m=y.relativePath,i4=`/${m}`,s4=N4.layout||"doc",r4=await U(n4,Z,i4,s4,N4,{i18n:J,locale:y.locale,sourceFile:y.sourceFile,docsDir:Y}),o4=m==="index"||m.endsWith("/index"),H4=y.locale&&y.locale!==J.defaultLocale&&J.enabled?v(q,y.locale):q,c=o4?v(H4,`${m}.html`):v(H4,m,"index.html"),_4=c.substring(0,c.lastIndexOf("/"));if(_4)await x(_4,{recursive:!0});if(await j(c,r4),X)console.log(`Generated: ${c}`)}if(X)console.log(`Processed ${G.length} markdown files into ${Y4.length} pages.`);if(await a6(q,Y,X),await o6(q),await r6(q,Z),K.searchIndex!==!1)await n6(Y,q,Z,X||!1);if(await i6(Y,q,Z,X||!1),K.checkManifest)await U4(q,K.checkManifest,p);return G.length},async()=>{if(K.manifest)await M4($,K.manifest,p)}),R=performance.now()-H;if(!X)N.succeed(`Built ${_} pages to HTML in ${t(R)}`);else T(`Build completed in ${t(R)}`),console.log(`
|
|
294
|
+
Generated ${_} HTML files in ${$}`);return!0}catch(_){if(!X)N.fail("Build failed");return console.error("Error during build:",_),!1}}async function r6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-9kzche7g.js"),X=`
|
|
295
295
|
<style>
|
|
296
296
|
.NotFound {
|
|
297
297
|
padding: 64px 24px 96px;
|
|
@@ -375,7 +375,7 @@ Generated ${_} HTML files in ${$}`);return!0}catch(_){if(!X)N.fail("Build failed
|
|
|
375
375
|
</div>
|
|
376
376
|
`,H=await $(X,Z,"/404","doc");await Bun.write(v(K,"404.html"),H)}async function o6(K){let Z=v(K,"index.html");try{if(!await Bun.file(Z).exists())console.error("Warning: No index.html found at root")}catch(Q){console.error("Error checking root index.html:",Q)}}L.command("build","Build the documentation site").option("--outdir <outdir>","Output directory").option("--dir <dir>","Documentation directory").option("--config <config>","Path to config file").option("--minify","Minify output files",{default:!1}).option("--sourcemap","Generate source maps",{default:!1}).option("--manifest <path>","Write a deterministic rendered-tree manifest").option("--check-manifest <path>","Fail unless the rendered tree matches a checked manifest").option("--search-index","Write the client search index (on by default; --no-search-index skips it)",{default:!0}).option("--watch","Watch for changes and rebuild",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await m4(K))S.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await O,Y=K.dir||$.docsDir||"./docs";console.log(`
|
|
377
377
|
Watching for changes...`),Q(Y,{recursive:!0},async(X,H)=>{if(H&&H.endsWith(".md"))console.log(`
|
|
378
|
-
Detected change in ${H}, rebuilding...`),await m4(K)}),await new Promise(()=>{})}});L.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:M.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:M.watch}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{let Z=await O,Q=K.port||M.port,$=K.dir||Z.docsDir||M.docsdir,Y=K.watch??M.watch,X=K.verbose??M.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:Y,verbose:X});let{serveCLI:H}=await import("./chunk-
|
|
378
|
+
Detected change in ${H}, rebuilding...`),await m4(K)}),await new Promise(()=>{})}});L.command("dev","Build and serve documentation using BunPress server").option("--port <port>","Port to listen on",{default:M.port}).option("--dir <dir>","Documentation directory").option("--watch","Watch for changes",{default:M.watch}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{let Z=await O,Q=K.port||M.port,$=K.dir||Z.docsDir||M.docsdir,Y=K.watch??M.watch,X=K.verbose??M.verbose;if(X)console.log("Starting BunPress dev server with options:",{port:Q,root:$,watch:Y,verbose:X});let{serveCLI:H}=await import("./chunk-9kzche7g.js");await H({port:Q,root:$,watch:Y,config:Z})});async function t6(K={}){let Z=await O,Q=K.dir||Z.docsDir||M.docsdir,$=K.output||"./docs.md",Y=K.full??!1,X=K.verbose??M.verbose;if(X)console.log(`Generating LLM markdown from ${Q}`),console.log(`Output file: ${$}`),console.log(`Full content: ${Y}`);let H=await r(Q);if(H.length===0)return console.log("No markdown files found in docs directory"),!1;if(X)console.log(`Found ${H.length} markdown files`);H.sort();let N=`# Documentation
|
|
379
379
|
|
|
380
380
|
`;N+=`Generated: ${new Date().toISOString()}
|
|
381
381
|
|
|
@@ -394,5 +394,5 @@ Detected change in ${H}, rebuilding...`),await m4(K)}),await new Promise(()=>{})
|
|
|
394
394
|
`}N+=`---
|
|
395
395
|
|
|
396
396
|
`}return await Bun.write($,N),console.log(`
|
|
397
|
-
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}L.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await t6(K))S.exit(1)});L.command("init","Initialize a new BunPress project").option("--name <name>","Project name").option("--template <template>","Template to use").option("--force","Overwrite existing files",{default:!1}).action(async(K)=>{if(!await E4(K))S.exit(1)});L.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:M.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{await D4(K)});L.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:M.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await T4(K))S.exit(1)});L.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await x4(K))S.exit(1)});L.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await z4(K))S.exit(1)});L.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await O4(K))S.exit(1)});L.command("config:init","Initialize configuration file").action(async(K)=>{if(!await L4(K))S.exit(1)});L.command("new <path>","Create a new markdown file").option("--title <title>","Page title").option("--template <template>","Template to use (default, guide, api, blog)",{default:"default"}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K,Z)=>{if(!await F4(K,Z))S.exit(1)});L.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await h4(K))S.exit(1)});L.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await k4(K)});L.command("deploy","Deploy documentation to AWS using CloudFormation (S3 + CloudFront + Route53)").option("--region <region>","AWS region for S3 bucket",{default:"us-east-1"}).option("--bucket <bucket>","S3 bucket name (auto-generated if not provided)").option("--domain <domain>","Custom domain (e.g., docs.example.com)").option("--subdomain <subdomain>","Subdomain (used with --base-domain)").option("--base-domain <baseDomain>","Base domain (e.g., example.com) - must have Route53 hosted zone").option("--stack-name <stackName>","CloudFormation stack name").option("--hosted-zone-id <hostedZoneId>","Route53 hosted zone ID (auto-detected from domain)").option("--certificate-arn <certificateArn>","ACM certificate ARN (auto-created if not provided)").option("--dry-run","Show configuration without deploying",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-
|
|
398
|
-
export{T as
|
|
397
|
+
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}L.command("llm","Generate LLM-friendly markdown file from documentation").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--output <output>","Output file path",{default:"./docs.md"}).option("--full","Include full content (not just titles and headings)",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await t6(K))S.exit(1)});L.command("init","Initialize a new BunPress project").option("--name <name>","Project name").option("--template <template>","Template to use").option("--force","Overwrite existing files",{default:!1}).action(async(K)=>{if(!await E4(K))S.exit(1)});L.command("preview","Preview the built documentation site").option("--port <port>","Port to listen on",{default:M.port}).option("--outdir <outdir>","Output directory (looks for .bunpress folder inside)").option("--open","Open in browser",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{await D4(K)});L.command("clean","Clean build artifacts").option("--outdir <outdir>","Output directory to clean",{default:M.outdir}).option("--force","Skip confirmation prompt",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await T4(K))S.exit(1)});L.command("doctor","Run diagnostic checks on the project").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await x4(K))S.exit(1)});L.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await z4(K))S.exit(1)});L.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await O4(K))S.exit(1)});L.command("config:init","Initialize configuration file").action(async(K)=>{if(!await L4(K))S.exit(1)});L.command("new <path>","Create a new markdown file").option("--title <title>","Page title").option("--template <template>","Template to use (default, guide, api, blog)",{default:"default"}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K,Z)=>{if(!await F4(K,Z))S.exit(1)});L.command("stats","Show documentation statistics").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await h4(K))S.exit(1)});L.command("seo:check","Check SEO for all documentation pages").option("--dir <dir>","Documentation directory (defaults to config docsDir)").option("--fix","Automatically fix issues (add missing titles/descriptions)",{default:!1}).action(async(K)=>{await k4(K)});L.command("deploy","Deploy documentation to AWS using CloudFormation (S3 + CloudFront + Route53)").option("--region <region>","AWS region for S3 bucket",{default:"us-east-1"}).option("--bucket <bucket>","S3 bucket name (auto-generated if not provided)").option("--domain <domain>","Custom domain (e.g., docs.example.com)").option("--subdomain <subdomain>","Subdomain (used with --base-domain)").option("--base-domain <baseDomain>","Base domain (e.g., example.com) - must have Route53 hosted zone").option("--stack-name <stackName>","CloudFormation stack name").option("--hosted-zone-id <hostedZoneId>","Route53 hosted zone ID (auto-detected from domain)").option("--certificate-arn <certificateArn>","ACM certificate ARN (auto-created if not provided)").option("--dry-run","Show configuration without deploying",{default:!1}).option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{let{deployCommand:Z}=await import("./chunk-nr19j5pk.js");if(!await Z(K))S.exit(1)});L.help();L.version(p);var X4=Bun.argv[1]||"",e6=X4.endsWith("/bunpress")||X4.endsWith("/cli.ts")||X4.endsWith("/cli.js");if(e6)L.parse();
|
|
398
|
+
export{T as p,A as q,B as r,C as s,s6 as t,m4 as u};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{p as $,q as I,r as f,s as h,u as x}from"./chunk-hnkqm0qx.js";import"./chunk-zxfhq634.js";import{C as _}from"./chunk-dgdd6yma.js";import"./chunk-twt99rzk.js";import{join as D}from"path";var E="@stacksjs/ts-cloud";async function Y(){try{return await import(E)}catch(j){throw Error(`Deploying requires @stacksjs/ts-cloud, which is an optional dependency.
|
|
3
3
|
Install it with: bun add -d @stacksjs/ts-cloud
|
|
4
4
|
Original error: ${j instanceof Error?j.message:String(j)}`)}}function W(j,A){let k=A||j?.provider;if(!k||k==="route53")return null;if(k==="porkbun"){let m=j?.apiKey||process.env.PORKBUN_API_KEY,w=j?.secretKey||process.env.PORKBUN_SECRET_KEY;if(!m||!w)throw Error("Porkbun API credentials not found. Set PORKBUN_API_KEY and PORKBUN_SECRET_KEY environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"porkbun",apiKey:m,secretKey:w}}if(k==="godaddy"){let m=j?.apiKey||process.env.GODADDY_API_KEY,w=j?.secretKey||process.env.GODADDY_API_SECRET,J=j?.environment||process.env.GODADDY_ENVIRONMENT;if(!m||!w)throw Error("GoDaddy API credentials not found. Set GODADDY_API_KEY and GODADDY_API_SECRET environment variables, or configure them in bunpress.config.ts under cloud.dnsProvider");return{provider:"godaddy",apiKey:m,apiSecret:w,environment:J}}throw Error(`Unknown DNS provider: ${k}. Supported: porkbun, godaddy, route53`)}async function F(j={}){let A=await _,k=A.cloud||{},m=j.verbose??A.verbose??!1;if(k.driver&&k.driver!=="aws")return I(`Unsupported cloud driver: ${k.driver}. Only 'aws' is implemented.`),!1;let w=j.region||k.region||"us-east-1",J=j.domain||k.domain,M=j.subdomain||k.subdomain,N=j.baseDomain||k.baseDomain,O=j.bucket||k.bucket,P=j.stackName||k.stackName,U=j.hostedZoneId||k.hostedZoneId,Q=j.certificateArn||k.certificateArn,V=k.cacheControl||"max-age=31536000, public",B;if(J)B=J;else if(M&&N)B=`${M}.${N}`;let K=B?.replace(/\./g,"-")||"bunpress-site",G=null;try{G=W(k.dnsProvider,j.dnsProvider)}catch(H){return I(H.message),!1}let L=G!==null;if(j.dryRun){if(f("Dry run mode - no changes will be made"),console.log(`
|
|
5
5
|
Configuration:`),console.log(` Region: ${w}`),console.log(` Site Name: ${K}`),console.log(` Bucket: ${O||"auto-generated"}`),console.log(` Domain: ${B||"not specified"}`),console.log(` Stack Name: ${P||`${K}-static-site`}`),console.log(` DNS Provider: ${G?.provider||"route53 (AWS)"}`),!L)console.log(` Hosted Zone ID: ${U||"auto-detected"}`);return console.log(` Certificate ARN: ${Q||"auto-created"}`),!0}if(!process.env.AWS_ACCESS_KEY_ID||!process.env.AWS_SECRET_ACCESS_KEY)return I("AWS credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables."),!1;let z=new h("Building documentation...");try{if(!m)z.start();if(!await x({verbose:m})){if(!m)z.fail("Build failed");return!1}if(!m)z.succeed("Documentation built successfully");let C=A.outDir||"./dist",X=D(C,".bunpress");if(!m)z.text="Deploying infrastructure with CloudFormation...",z.start();else if(console.log(`
|
|
@@ -35,4 +35,4 @@ var Y=import.meta.require;function Q(q){return(q.sitemap?.baseUrl||q.url||"").re
|
|
|
35
35
|
}
|
|
36
36
|
})();
|
|
37
37
|
`.trim()}
|
|
38
|
-
export{Y as
|
|
38
|
+
export{Y as ga,Q as ha,j as ia,A as ja,E as ka,F as la,Z as ma,I as na,_ as oa,D as pa,S as qa,w as ra};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ha as B}from"./chunk-twt99rzk.js";var{YAML:R}=globalThis.Bun;import*as X from"fs";import*as T from"path";async function F(H,J,j){let K=B(J),N=j?.title||J.title||J.markdown?.title||"Documentation Feed",O=j?.description||J.description||J.markdown?.meta?.description||"Documentation updates",Q=j?.author||"Documentation Team",Z=j?.email||"",_=j?.language||"en-us",$=j?.maxItems||20,V=j?.fullContent||!1,W=await w(H,K,V);W.sort((Y,z)=>z.pubDate.getTime()-Y.pubDate.getTime());let G=W.slice(0,$);return P({title:N,description:O,link:K,language:_,author:Q,email:Z,items:G})}async function c(H,J,j,K){if(!K?.enabled)return;if(!B(j)){if(j.verbose)console.warn("\u26A0\uFE0F RSS feed generation skipped: baseUrl not configured");return}let N=await F(H,j,K),O=K.filename||"feed.xml",Q=T.join(J,O);if(await X.promises.writeFile(Q,N,"utf-8"),j.verbose){let Z=(N.match(/<item>/g)||[]).length;console.log(`\u2705 RSS feed generated: ${Q} (${Z} items)`)}}async function w(H,J,j){let K=[],N=await k(H);for(let O of N){let Q=await X.promises.readFile(O,"utf-8"),{frontmatter:Z,markdown:_}=x(Q);if(!Z.date||!Z.title)continue;let V=T.relative(H,O).replace(/\.md$/,"").replace(/index$/,"").replace(/\\/g,"/");if(!V.startsWith("/"))V=`/${V}`;if(V.endsWith("/")&&V!=="/")V=V.slice(0,-1);let W=`${J.replace(/\/$/,"")}${V}`,G=Z.description||U(_),Y=new Date(Z.date),z=Z.author;K.push({title:Z.title,link:W,description:G,pubDate:Y,author:z,content:j?_:void 0})}return K}async function k(H){let J=[];async function j(K){let N=await X.promises.readdir(K,{withFileTypes:!0});for(let O of N){let Q=T.join(K,O.name);if(O.isDirectory()){if(!O.name.startsWith(".")&&O.name!=="node_modules")await j(Q)}else if(O.isFile()&&O.name.endsWith(".md"))J.push(Q)}}return await j(H),J}function x(H){let J=/^---\n([\s\S]*?)\n---\n?/,j=H.match(J);if(!j)return{frontmatter:{},markdown:H};let K=j[1],N=H.slice(j[0].length);try{return{frontmatter:R.parse(K),markdown:N}}catch{return{frontmatter:{},markdown:H}}}function U(H,J=200){let j=H.replace(/^#{1,6}\s+(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]+`/g,"").replace(/!\[.*?\]\(.*?\)/g,"").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_~]/g,"").trim(),K=j.split(`
|
|
3
3
|
|
|
4
4
|
`)[0]||j;if(K.length>J)return`${K.slice(0,J)}...`;return K}function P(H){let J=new Date,j=H.items.length>0?H.items[0].pubDate:J,K=H.items.map((N)=>{let O=N.content?`
|
|
5
5
|
<content:encoded><![CDATA[${N.content}]]></content:encoded>`:"",Q=N.author?`
|
|
@@ -29,4 +29,4 @@ ${Q.map((V)=>{return` <sitemap>
|
|
|
29
29
|
</sitemap>`}).join(`
|
|
30
30
|
`)}
|
|
31
31
|
</sitemapindex>`,$=A.join(J,K);await I.promises.writeFile($,_,"utf-8")}function d(H){return(typeof H==="string"?new Date(H):H).toISOString().split("T")[0]}function m(H,J){let j=[];for(let K=0;K<H.length;K+=J)j.push(H.slice(K,K+J));return j}
|
|
32
|
-
export{F as
|
|
32
|
+
export{F as v,c as w,a as x,n as y,i as z};
|
|
@@ -27,8 +27,12 @@ export declare function highlightCodeSync(code: string, language: string): strin
|
|
|
27
27
|
/**
|
|
28
28
|
* Gets the CSS styles for syntax highlighting
|
|
29
29
|
* Note: ts-syntax-highlighter includes its own theme CSS
|
|
30
|
+
*
|
|
31
|
+
* @param inlineTheme the theme the highlighter resolved inline
|
|
32
|
+
* (`markdown.syntaxHighlightTheme`). Anything but the light theme gets the
|
|
33
|
+
* light palette spelled out for light mode as well.
|
|
30
34
|
*/
|
|
31
|
-
export declare function getSyntaxHighlightingStyles(): string;
|
|
35
|
+
export declare function getSyntaxHighlightingStyles(inlineTheme?: string): string;
|
|
32
36
|
/**
|
|
33
37
|
* Pre-warms the highlighter by creating the instance early
|
|
34
38
|
* Call this during application initialization for better performance
|
|
@@ -38,3 +42,41 @@ export declare function prewarmHighlighter(): Promise<void>;
|
|
|
38
42
|
* Gets the highlighter instance for advanced usage
|
|
39
43
|
*/
|
|
40
44
|
export declare function getHighlighterInstance(): Promise<TSHighlighter>;
|
|
45
|
+
/**
|
|
46
|
+
* The light palette for every token, for a site that resolved a dark one.
|
|
47
|
+
*
|
|
48
|
+
* `markdown.syntaxHighlightTheme` decides which colours the highlighter
|
|
49
|
+
* writes inline. The sheet below is built around the light theme: it leaves
|
|
50
|
+
* the inline colours alone in light mode and replaces them in dark mode. A
|
|
51
|
+
* site that asked for `github-dark` therefore got the dark palette inline in
|
|
52
|
+
* both modes, and in light mode nothing corrected it: string literals at
|
|
53
|
+
* #a5d6ff on the light code block are 1.42:1, which is a page of code with
|
|
54
|
+
* its strings missing.
|
|
55
|
+
*
|
|
56
|
+
* So when the inline theme is not the light one, light mode is corrected the
|
|
57
|
+
* same way dark mode always has been: every token gets the light palette's
|
|
58
|
+
* colour for its scope, with !important because an inline style cannot be
|
|
59
|
+
* outranked. The rules run in the same order as the dark block, general to
|
|
60
|
+
* specific, and carry no \`html.dark\`, so the dark block outranks them in
|
|
61
|
+
* the dark and the two palettes cannot both apply.
|
|
62
|
+
*
|
|
63
|
+
* Colours are GitHub Light's, with the three the block already darkens for
|
|
64
|
+
* its ground (comment, function, keyword). test/theme-contrast.test.ts holds
|
|
65
|
+
* each of them to 4.5:1 on every surface code is drawn on.
|
|
66
|
+
* @defaultValue
|
|
67
|
+
* ```ts
|
|
68
|
+
* {
|
|
69
|
+
* default: '#24292f',
|
|
70
|
+
* variable: '#953800',
|
|
71
|
+
* type: '#953800',
|
|
72
|
+
* function: '#7a3fd0',
|
|
73
|
+
* tag: '#116329',
|
|
74
|
+
* constant: '#0550ae',
|
|
75
|
+
* keyword: '#c5141f',
|
|
76
|
+
* string: '#0a3069',
|
|
77
|
+
* comment: '#5c636b',
|
|
78
|
+
* invalid: '#82071e'
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare const LIGHT_TOKEN_PALETTE: Record<string, string>;
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as p,b as u,c as m,d as o,e as s,f as h,g as a,h as d,i as t,j as
|
|
2
|
+
import{a as p,b as u,c as m,d as o,e as s,f as h,g as a,h as d,i as t,j as c,k as Oj,l as kj,m as Cj,n as Mj,o as Tj}from"../chunk-ds2b3vtw.js";import{v as S,w as V,x as W,y as X,z as Y}from"../chunk-zxfhq634.js";import{$ as _,A as x,B as v,C as g,D as f,I as Ej,J as Gj,K as Jj,L as Kj,M as Nj,N as Pj,O as Qj,P as Sj,Q as Vj,R as Wj,S as Xj,T as Yj,U as Zj,V as _j,W as $j,X as Aj,Y as Fj,Z as Ij,_ as Z,aa as $,ba as Lj}from"../chunk-dgdd6yma.js";import{ia as i,ja as l,ka as n,la as r,ma as e,na as jj,oa as qj,pa as zj,qa as Bj,ra as Dj}from"../chunk-twt99rzk.js";function D(E){return E.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function N(E,K=!1){let z=E.trim();if(!z||/[\u0000-\u0020\u007f-\u009f\\]/.test(z))return null;let G=/^([a-z][a-z\d+.-]*):/i.exec(z)?.[1]?.toLowerCase();if(/^[^/]*:/.test(z)&&(!G||!["http","https",...K?[]:["mailto"]].includes(G)))return null;return z}function F(E,K={}){let z=[],G=E.replace(/[\u0000-\u0002]/g,""),Q=(j)=>j.replace(/\u0001(\d+)\u0002/g,(q,B)=>z[Number(B)]??""),J=(j)=>D(Q(j));return Bun.markdown.render(G,{text:(j)=>`\x01${z.push(j)-1}\x02`,heading:(j,q)=>`<h${q.level} id="wiki-${D(q.id??"")}">${j}</h${q.level}>`,paragraph:(j)=>`<p>${j}</p>`,blockquote:(j)=>`<blockquote>${j}</blockquote>`,strong:(j)=>`<strong>${j}</strong>`,emphasis:(j)=>`<em>${j}</em>`,strikethrough:(j)=>`<del>${j}</del>`,hr:()=>"<hr>",codespan:(j)=>`<code>${J(j)}</code>`,code:(j,q)=>{return`<pre><code${q?.language&&/^[\w+#.-]{1,30}$/.test(q.language)?` class="language-${D(q.language)}"`:""}>${J(j)}</code></pre>`},list:(j,q)=>q.ordered?`<ol start="${q.start??1}">${j}</ol>`:`<ul>${j}</ul>`,listItem:(j,q)=>`<li>${typeof q.checked==="boolean"?`<input type="checkbox" disabled${q.checked?" checked":""}>`:""}${j}</li>`,table:(j)=>`<table>${j}</table>`,thead:(j)=>`<thead>${j}</thead>`,tbody:(j)=>`<tbody>${j}</tbody>`,tr:(j)=>`<tr>${j}</tr>`,th:(j)=>`<th>${j}</th>`,td:(j)=>`<td>${j}</td>`,link:(j,q)=>{let B=N(q.href);if(!B)return j;let P=N(K.resolveLink?.(B)??B);return P?`<a href="${D(P)}" rel="nofollow noopener noreferrer">${j}</a>`:j},image:(j,q)=>{let B=N(q.src,!0);return B?`<img src="${D(B)}" alt="${J(j)}" loading="lazy">`:J(j)},html:(j)=>j},{tables:!0,strikethrough:!0,tasklists:!0,autolinks:!0,headings:{ids:!0}}).replace(/\u0001(\d+)\u0002/g,(j,q)=>D(z[Number(q)]??""))}export{kj as wrapInLayout,Oj as stripConfiguredBasePath,Mj as startServer,r as splitLocaleFromPath,u as setLanguageAliases,Tj as serveCLI,l as resolveI18nConfig,p as resetHighlighter,Kj as reserveUniqueSlug,F as renderUntrustedMarkdown,$j as processInlineTocSyntax,t as prewarmHighlighter,m as normalizeLanguage,Cj as markdownToHtml,Gj as markdownHeadingText,e as localizeUrl,zj as localeLabel,jj as localeContentCandidates,n as loadI18nTranslations,o as isLanguageSupported,h as highlightCodeSync,s as highlightCode,d as getSyntaxHighlightingStyles,c as getHighlighterInstance,i as getConfiguredBasePath,f as getConfig,Nj as generateUniqueSlug,Fj as generateTocStyles,Ij as generateTocScripts,_j as generateTocPositions,Vj as generateTocHtml,Zj as generateTocData,Jj as generateSlug,Y as generateSitemap,Xj as generateSidebarTocHtml,V as generateRssFeed,W as generateRobotsTxt,Dj as generateLocaleDetectionScript,Wj as generateInlineTocHtml,Bj as generateHreflangTags,Yj as generateFloatingTocHtml,Sj as filterHeadings,Pj as extractHeadings,Aj as enhanceHeadingsWithAnchors,Ej as defaultTocConfig,x as defaultConfig,Lj as decodeHtmlEntities,qj as configForLocale,g as config,Qj as buildTocHierarchy,X as buildSitemap,_ as buildSearchRuntimeConfig,$ as buildSearchIndex,S as buildRssFeed,v as applyConfigPlugins,Z as SEARCH_INDEX_PATH,a as LIGHT_TOKEN_PALETTE};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare function isLongPage(articleHtml: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Long pages render only what is near the reader.
|
|
4
|
+
*
|
|
5
|
+
* A generated reference can be one very long page. One real case: every
|
|
6
|
+
* command of a CLI, 350 option tables and 20,000 elements in a single
|
|
7
|
+
* document. A browser lays all of that out before it paints anything, which
|
|
8
|
+
* measured 117ms on a fast laptop and four times that on the phone a
|
|
9
|
+
* performance audit simulates: a single task long enough to count as the
|
|
10
|
+
* page being unresponsive, for content nobody has scrolled to.
|
|
11
|
+
*
|
|
12
|
+
* `content-visibility: auto` lets the browser skip the layout and paint of a
|
|
13
|
+
* block until it is close to the viewport. On that page it brings the first
|
|
14
|
+
* layout down to under 10ms. The page stays whole to everything else:
|
|
15
|
+
* find-in-page, the outline, anchors and assistive technology all still reach
|
|
16
|
+
* the skipped blocks, and `auto` in `contain-intrinsic-size` makes the browser
|
|
17
|
+
* remember each block's real height once it has drawn it.
|
|
18
|
+
*
|
|
19
|
+
* Four choices keep it from changing what a reader sees:
|
|
20
|
+
*
|
|
21
|
+
* - Only pages over {@link LONG_PAGE_BYTES} of article markup opt in. An
|
|
22
|
+
* ordinary page lays out in a few milliseconds and gains nothing.
|
|
23
|
+
* - The first {@link EAGER_BLOCKS} blocks of the article are never skipped.
|
|
24
|
+
* A block that is on screen when the page loads is first laid out at its
|
|
25
|
+
* placeholder height and then at its real one, which moves everything
|
|
26
|
+
* under it: applied to every block, the page that prompted this scored a
|
|
27
|
+
* 0.18 layout shift for a table the reader was already looking at. Past
|
|
28
|
+
* the first screenful a block is drawn before it scrolls into view.
|
|
29
|
+
* - Headings are never skipped. They are what an anchor, the outline and the
|
|
30
|
+
* scroll position all measure against, so they stay exact.
|
|
31
|
+
* - It is limited to browsers with scroll anchoring. A skipped block is a
|
|
32
|
+
* placeholder until drawn, and anchoring is what holds the reader's place
|
|
33
|
+
* when a block above them takes its real height; without it, scrolling up
|
|
34
|
+
* would jump.
|
|
35
|
+
*/
|
|
36
|
+
/** Article markup beyond this many characters makes a page "long". */
|
|
37
|
+
export declare const LONG_PAGE_BYTES: unknown;
|
|
38
|
+
/**
|
|
39
|
+
* How many of the article's leading blocks always render. Forty one-line
|
|
40
|
+
* blocks are taller than any screen a documentation page is read on.
|
|
41
|
+
*/
|
|
42
|
+
export declare const EAGER_BLOCKS: 40;
|
|
43
|
+
/** Set on the `<article>` of a long page; the rule below is scoped to it. */
|
|
44
|
+
export declare const LONG_PAGE_CLASS: 'bp-doc--long';
|
|
45
|
+
/**
|
|
46
|
+
* In every doc page's stylesheet, not only a long page's: the client router
|
|
47
|
+
* swaps the article without swapping the theme, so a reader who navigates
|
|
48
|
+
* from a short page to a long one needs the rule to be there already. It
|
|
49
|
+
* matches nothing until an article carries the class.
|
|
50
|
+
*/
|
|
51
|
+
export declare const longPageCss: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function minifyCss(css: string): string;
|
|
@@ -6,195 +6,3 @@
|
|
|
6
6
|
</ul>
|
|
7
7
|
</div>
|
|
8
8
|
</div>
|
|
9
|
-
|
|
10
|
-
<style>
|
|
11
|
-
.sidebar-section {
|
|
12
|
-
margin-bottom: 4px;
|
|
13
|
-
padding-bottom: 4px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.sidebar-section + .sidebar-section {
|
|
17
|
-
border-top: 1px solid var(--bp-c-divider);
|
|
18
|
-
padding-top: 10px;
|
|
19
|
-
margin-top: 10px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.sidebar-section-toggle {
|
|
23
|
-
width: 100%;
|
|
24
|
-
display: flex;
|
|
25
|
-
align-items: center;
|
|
26
|
-
justify-content: space-between;
|
|
27
|
-
gap: 8px;
|
|
28
|
-
padding: 6px 20px 6px 22px;
|
|
29
|
-
font-size: 13px;
|
|
30
|
-
font-weight: 700;
|
|
31
|
-
letter-spacing: 0.01em;
|
|
32
|
-
color: var(--bp-c-text-1);
|
|
33
|
-
background: transparent;
|
|
34
|
-
border: none;
|
|
35
|
-
cursor: pointer;
|
|
36
|
-
transition: color 0.25s;
|
|
37
|
-
font-family: inherit;
|
|
38
|
-
text-align: left;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.sidebar-section-toggle > span {
|
|
42
|
-
min-width: 0;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
text-overflow: ellipsis;
|
|
45
|
-
white-space: nowrap;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.sidebar-section-toggle:hover {
|
|
49
|
-
color: var(--bp-c-brand-1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.sidebar-section-toggle .chevron {
|
|
53
|
-
width: 14px;
|
|
54
|
-
height: 14px;
|
|
55
|
-
color: var(--bp-c-text-3);
|
|
56
|
-
transition: transform 0.2s ease-in-out;
|
|
57
|
-
flex-shrink: 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.sidebar-items {
|
|
61
|
-
list-style: none;
|
|
62
|
-
margin: 2px 0 0 0;
|
|
63
|
-
padding: 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* Animates to the section's own height. A max-height of 1000px cut off any
|
|
67
|
-
* section longer than that, which nested groups make easy to reach. */
|
|
68
|
-
.sidebar-items-wrapper {
|
|
69
|
-
display: grid;
|
|
70
|
-
grid-template-rows: 1fr;
|
|
71
|
-
transition: grid-template-rows 0.3s ease-in-out, opacity 0.2s ease-in-out;
|
|
72
|
-
opacity: 1;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.sidebar-items-wrapper > .sidebar-items { overflow: hidden; min-height: 0; }
|
|
76
|
-
|
|
77
|
-
.sidebar-section.collapsed > .sidebar-items-wrapper {
|
|
78
|
-
grid-template-rows: 0fr;
|
|
79
|
-
opacity: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.sidebar-section.collapsed > .sidebar-section-toggle .chevron {
|
|
83
|
-
transform: rotate(-90deg);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.BPSidebarItem-link {
|
|
87
|
-
display: block;
|
|
88
|
-
/* Indented one step past the section title so the hierarchy reads at a
|
|
89
|
-
* glance, and one more step per nested group; the 2px rail is transparent
|
|
90
|
-
* until active, so the label never shifts sideways when you navigate to it. */
|
|
91
|
-
padding: 6px 20px 6px calc(32px + var(--bp-sidebar-depth, 0) * 14px);
|
|
92
|
-
color: var(--bp-c-text-2);
|
|
93
|
-
text-decoration: none;
|
|
94
|
-
font-size: 14px;
|
|
95
|
-
line-height: 1.5;
|
|
96
|
-
transition: color 0.25s, background-color 0.25s;
|
|
97
|
-
border-left: 2px solid transparent;
|
|
98
|
-
overflow-wrap: anywhere;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.BPSidebarItem-link:hover {
|
|
102
|
-
color: var(--bp-c-brand-1);
|
|
103
|
-
background-color: var(--bp-c-default-soft, var(--bp-c-gray-soft));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.BPSidebarItem-link.is-active {
|
|
107
|
-
color: var(--bp-c-brand-1);
|
|
108
|
-
font-weight: 600;
|
|
109
|
-
border-left-color: var(--bp-c-brand-1);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* A nested group: its title at the level of its siblings, its items one step
|
|
113
|
-
* further in, folding the way a section does. */
|
|
114
|
-
.BPSidebarGroup-head {
|
|
115
|
-
display: flex;
|
|
116
|
-
align-items: center;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.BPSidebarGroup-link,
|
|
120
|
-
.BPSidebarGroup-text {
|
|
121
|
-
flex: 1;
|
|
122
|
-
min-width: 0;
|
|
123
|
-
padding: 6px 4px 6px calc(32px + var(--bp-sidebar-depth, 0) * 14px);
|
|
124
|
-
color: var(--bp-c-text-1);
|
|
125
|
-
font-size: 14px;
|
|
126
|
-
font-weight: 600;
|
|
127
|
-
line-height: 1.5;
|
|
128
|
-
text-decoration: none;
|
|
129
|
-
border-left: 2px solid transparent;
|
|
130
|
-
overflow-wrap: anywhere;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.BPSidebarGroup-link:hover { color: var(--bp-c-brand-1); }
|
|
134
|
-
.BPSidebarGroup-link.is-active { color: var(--bp-c-brand-1); border-left-color: var(--bp-c-brand-1); }
|
|
135
|
-
|
|
136
|
-
.BPSidebarGroup-toggle {
|
|
137
|
-
display: flex;
|
|
138
|
-
align-items: center;
|
|
139
|
-
justify-content: center;
|
|
140
|
-
flex-shrink: 0;
|
|
141
|
-
width: 32px;
|
|
142
|
-
height: 32px;
|
|
143
|
-
margin-right: 12px;
|
|
144
|
-
padding: 0;
|
|
145
|
-
color: var(--bp-c-text-3);
|
|
146
|
-
background: transparent;
|
|
147
|
-
border: none;
|
|
148
|
-
border-radius: 6px;
|
|
149
|
-
cursor: pointer;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.BPSidebarGroup-toggle:hover { color: var(--bp-c-brand-1); background-color: var(--bp-c-default-soft, var(--bp-c-gray-soft)); }
|
|
153
|
-
|
|
154
|
-
.BPSidebarGroup-toggle .chevron {
|
|
155
|
-
width: 14px;
|
|
156
|
-
height: 14px;
|
|
157
|
-
transition: transform 0.2s ease-in-out;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/* Rows that animate to their content's own height, however long the group:
|
|
161
|
-
* a fixed max-height clipped a long group and lagged on a short one. */
|
|
162
|
-
.BPSidebarGroup-items {
|
|
163
|
-
display: grid;
|
|
164
|
-
grid-template-rows: 1fr;
|
|
165
|
-
transition: grid-template-rows 0.25s ease-in-out, opacity 0.2s ease-in-out;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.BPSidebarGroup-items > .sidebar-items { overflow: hidden; min-height: 0; margin: 0; }
|
|
169
|
-
.BPSidebarGroup.collapsed > .BPSidebarGroup-items { grid-template-rows: 0fr; opacity: 0; }
|
|
170
|
-
.BPSidebarGroup.collapsed > .BPSidebarGroup-head .chevron { transform: rotate(-90deg); }
|
|
171
|
-
|
|
172
|
-
@media (prefers-reduced-motion: reduce) {
|
|
173
|
-
.BPSidebarGroup-items, .BPSidebarGroup-toggle .chevron { transition: none; }
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/* Larger rows on touch layouts, where the drawer is the primary navigation. */
|
|
177
|
-
@media (max-width: 959px) {
|
|
178
|
-
.BPSidebarItem-link {
|
|
179
|
-
padding-top: 9px;
|
|
180
|
-
padding-bottom: 9px;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
.sidebar-section-toggle {
|
|
184
|
-
padding-top: 10px;
|
|
185
|
-
padding-bottom: 10px;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
</style>
|
|
189
|
-
|
|
190
|
-
<script>
|
|
191
|
-
function toggleSection(section) {
|
|
192
|
-
section.classList.toggle('collapsed');
|
|
193
|
-
}
|
|
194
|
-
function toggleSidebarGroup(button) {
|
|
195
|
-
var group = button.closest('.BPSidebarGroup');
|
|
196
|
-
if (!group) return;
|
|
197
|
-
var collapsed = group.classList.toggle('collapsed');
|
|
198
|
-
button.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
|
|
199
|
-
}
|
|
200
|
-
</script>
|