@stacksjs/bunpress 0.2.17 → 0.2.19
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-kvkhq8vp.js → chunk-3ymfys00.js} +273 -20
- package/dist/{chunk-7nnedf6q.js → chunk-532cbqgt.js} +96 -92
- package/dist/{chunk-r5g5120d.js → chunk-7cdk9y78.js} +6 -6
- package/dist/{chunk-wg17w4a2.js → chunk-9ytw3mfw.js} +1 -1
- package/dist/chunk-f4dw2x6b.js +2 -0
- package/dist/{chunk-s7tcgrb6.js → chunk-rcr6k1et.js} +2 -2
- package/dist/{chunk-4r44z49z.js → chunk-rnzqf7rp.js} +1 -1
- package/dist/{chunk-1d8gksnh.js → chunk-z74qp3xn.js} +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/message-previews.d.ts +60 -0
- package/dist/src/serve.d.ts +7 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunk-he7yz8ak.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{B as k4,y as C4,z as v4}from"./chunk-rcr6k1et.js";import{D as b4,E as O,G as e,L as L4,M as x4,N as E4,aa as P4,ca as h4}from"./chunk-3ymfys00.js";import{da as F,ea as a}from"./chunk-rnzqf7rp.js";var{Glob:m4}=globalThis.Bun;import{copyFile as L6,mkdir as g4,readdir as x6,rename as E6,rm as K4}from"fs/promises";import{existsSync as S6}from"fs";import{join as D,resolve as F6}from"path";import E from"process";import{CLI as y6}from"@stacksjs/clapp";var p="0.2.19";var{Glob:i4}=globalThis.Bun;import{dirname as s4,relative as r4,resolve as c,sep as N4}from"path";import{mkdir as o4}from"fs/promises";function q4(K){return N4==="/"?K:K.split(N4).join("/")}function t4(K){let Z=new Bun.CryptoHasher("sha256");return Z.update(K),Z.digest("hex")}async function _4(K,Z,Q){let $=c(K),Y=Q?q4(r4($,c(Q))):void 0,X=[],q=new i4("**/*");for await(let R of q.scan({cwd:$,onlyFiles:!0})){let _=q4(R);if(_===Y)continue;X.push(_)}X.sort((R,_)=>R.localeCompare(_));let N=[],W=new Bun.CryptoHasher("sha256");for(let R of X){let _=new Uint8Array(await Bun.file(c($,R)).arrayBuffer()),G=t4(_);N.push({path:R,bytes:_.byteLength,sha256:G}),W.update(`${R}\x00${_.byteLength}\x00${G}
|
|
3
3
|
`)}return{schema_version:1,generator:"bunpress",generator_version:Z,outputs:N,tree_sha256:W.digest("hex")}}async function W4(K,Z,Q){let $=await _4(K,Q,Z);return await o4(s4(c(Z)),{recursive:!0}),await Bun.write(Z,`${JSON.stringify($,null,2)}
|
|
4
4
|
`),$}function H4(K){return new Map(K.outputs.map((Z)=>[Z.path,Z]))}async function R4(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 _4(K,Q,Z);if(JSON.stringify(Y)===JSON.stringify($))return Y;let X=H4($),q=H4(Y),N=Y.outputs.filter((G)=>!X.has(G.path)).map((G)=>G.path),W=$.outputs.filter((G)=>!q.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}]`}),_=[$.generator_version!==Y.generator_version?`generator ${$.generator_version} -> ${Y.generator_version}`:"",N.length?`added: ${N.join(", ")}`:"",W.length?`removed: ${W.join(", ")}`:"",R.length?`changed: ${R.join(", ")}`:""].filter(Boolean);throw Error(`BunPress output does not match ${Z}: ${_.join("; ")||"tree hash changed"}`)}import{existsSync as e4}from"fs";import{rm as K6}from"fs/promises";import{join as Q6}from"path";var L={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`${L[Z]}${K}${L.reset}`}function T(K){console.log(`${L.green}\u2713${L.reset} ${K}`)}function j(K){console.error(`${L.red}\u2717${L.reset} ${K}`)}function h(K){console.warn(`${L.yellow}\u26A0${L.reset} ${K}`)}function B(K){console.log(`${L.blue}\u2139${L.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 i(K){if(K<1000)return`${K}ms`;if(K<60000)return`${(K/1000).toFixed(2)}s`;return`${(K/60000).toFixed(2)}m`}var G4=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);class v{frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];index=0;interval=null;text;constructor(K){this.text=K}start(){if(G4){console.log(` ${this.text}`);return}process.stdout.write("\x1B[?25l"),this.interval=setInterval(()=>{let K=this.frames[this.index];process.stdout.write(`\r${L.cyan}${K}${L.reset} ${this.text}`),this.index=(this.index+1)%this.frames.length},80)}succeed(K){this.stop(),T(K||this.text)}fail(K){this.stop(),j(K||this.text)}stop(){if(this.interval)clearInterval(this.interval),this.interval=null;if(!G4)process.stdout.write("\r\x1B[K"),process.stdout.write("\x1B[?25h")}update(K){this.text=K}}async function d(K,Z=!1){let Q=Z?"Y/n":"y/N";process.stdout.write(`${L.cyan}?${L.reset} ${K} ${L.dim}(${Q})${L.reset}: `);let $=Bun.file("/dev/stdin").stream().getReader(),Y=new TextDecoder,{value:X}=await $.read(),q=Y.decode(X).trim().toLowerCase();if(!q)return Z;return q==="y"||q==="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((q)=>String(Y[q]).padEnd(Q[q])).join(" ");console.log(X)}}async function l(K){try{return Bun.file(K).size}catch{return 0}}async function Z6(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}`,q=await l(X);$+=q}return $}catch{return 0}}async function V4(K={}){let Z=await O,Q=K.outdir||Z.outDir||"./dist",$=Q6(Q,".bunpress"),Y=K.force||!1,X=K.verbose||!1;try{if(!e4($))return B(`Directory "${$}" does not exist, nothing to clean`),!0;let N=await Z6($);if(X)B(`Found "${$}" (${w(N)})`);if(!Y){if(!await d(`Delete "${$}" directory? (${w(N)})`,!1))return B("Clean cancelled"),!1}let W=process.env.VITEST==="true"||!1,R=null;if(!W&&!X)R=new v("Cleaning build artifacts..."),R.start();if(await K6($,{recursive:!0,force:!0}),R)R.succeed(`Cleaned ${w(N)} from "${$}"`);else if(X||W)T(`Cleaned ${w(N)} from "${$}"`);return!0}catch(q){return j(`Failed to clean directory: ${q}`),!1}}import{existsSync as s}from"fs";import{join as r}from"path";async function j4(K={}){try{let Z=["bunpress.config.ts","bunpress.config.js"],Q=null;for(let Y of Z){let X=r(process.cwd(),Y);if(s(X)){Q=X;break}}if(!Q)return j("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 j(`Failed to show configuration: ${Z}`),!1}}async function A4(K={}){let Z=K.verbose||!1;try{let Q=["bunpress.config.ts","bunpress.config.js"],$=null;for(let W of Q){let R=r(process.cwd(),W);if(s(R)){$=R;break}}if(!$)return j("No configuration file found"),!1;if(Z)B(`Validating ${$}...`);let X=(await import($)).default;if(!X)return j("Configuration file does not export a default object"),!1;let q=[],N=[];if(X.markdown){if(X.markdown.toc&&typeof X.markdown.toc!=="object"&&typeof X.markdown.toc!=="boolean")q.push("markdown.toc should be an object or boolean");if(X.markdown.features){if(typeof X.markdown.features!=="object")q.push("markdown.features should be an object")}}if(X.nav){if(!Array.isArray(X.nav))q.push("nav should be an array");else for(let[W,R]of X.nav.entries())if(!R.text||!R.link)q.push(`nav[${W}] is missing required fields (text, link)`)}if(!a(X))N.push("no `url` set: sitemap, RSS, canonical links and Open Graph tags are all skipped without an absolute base URL");if(q.length>0){j("Configuration validation failed:");for(let W of q)console.log(` \u2022 ${W}`);return!1}for(let W of N)h(W);return T("Configuration is valid \u2713"),!0}catch(Q){return j(`Failed to validate configuration: ${Q}`),!1}}async function J4(K={}){let Z=r(process.cwd(),"bunpress.config.ts");if(s(Z))return j("Configuration file already exists"),!1;let Q=`import type { BunPressConfig } from '@stacksjs/bunpress'
|
|
5
5
|
|
|
@@ -290,8 +290,8 @@ ${Z}`}async function A6(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 q=X[1].trim(),N=q.match(/\{#([\w-]+)\}\s*$/),W=N?N[1]:x4(L4(q));if(!W)continue;E4(W,Q)}}catch{}return I4.set(K,Q),Q}function T6(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 z6(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){j(`\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 O6}from"path";async function I6(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,W=(Z.match(/```/g)||[]).length/2;return{path:K,size:await l(K),lines:Q.length,words:$,headings:N,codeBlocks:Math.floor(W)}}async function D4(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"),q=[];for await(let J of X.scan(Q)){let A=O6(Q,J),f=await I6(A);q.push(f)}if(q.length===0)return j("No markdown files found"),!1;let N=q.reduce((J,A)=>J+A.size,0),W=q.reduce((J,A)=>J+A.lines,0),R=q.reduce((J,A)=>J+A.words,0),_=q.reduce((J,A)=>J+A.headings,0),G=q.reduce((J,A)=>J+A.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${w(N)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${G}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let J=q.map((A)=>({File:A.path.replace(`${Q}/`,""),Size:w(A.size),Lines:A.lines,Words:A.words,Headings:A.headings,"Code Blocks":A.codeBlocks}));g(J),console.log()}let V=N/q.length,U=W/q.length,H=R/q.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(H)}`),console.log();let S=[...q].sort((J,A)=>A.size-J.size).slice(0,5);if(S.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let J of S){let A=J.path.replace(`${Q}/`,"");console.log(` ${A.padEnd(40)} ${w(J.size)}`)}console.log()}let x=Math.ceil(R/200);return B(`Estimated reading time: ${x} minutes`),!0}catch(Y){return j(`Failed to generate statistics: ${Y}`),!1}}var I=new y6("bunpress"),M={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function f4(K){let Z=new m4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function D6(K,Z,Q=!1){let $=`${Z}/public`;try{await x6($);let Y=new m4("**/*");for await(let X of Y.scan($)){let q=D($,X),N=D(K,X);await g4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await L6(q,N)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function w6(K,Z,Q){let $=Z.replace(/^\.\//,""),Y=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:Y(_),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),N=new Map;for(let _ of X)N.set(_,new Map);let W=new Set;for(let _ of K){let G=Y(_),V=G.split("/");if(V.length>1&&q.has(V[0])&&V[0]!==Q.defaultLocale){let H=V.slice(1).join("/");N.get(V[0]).set(H,_),W.add(H);continue}let U=G.match(/^(.*)\.([A-Za-z-]+)$/);if(U&&q.has(U[2])){N.get(U[2]).set(U[1],_),W.add(U[1]);continue}N.get(Q.defaultLocale).set(G,_),W.add(G)}let R=[];for(let _ of X)for(let G of W){let V=N.get(_).get(G)??N.get(Q.defaultLocale).get(G);if(!V)continue;R.push({sourceFile:V,relativePath:G,locale:_})}return R}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await h4(K,Q);if(await Bun.write(D(Z,P4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function C6(K,Z,Q,$){try{if(Q.sitemap?.enabled!==!1&&a(Q))await k4(K,Z,Q);if(Q.robots?.enabled!==!1)await v4(Z,Q);if(Q.rss?.enabled)await C4(K,Z,Q,Q.rss)}catch(Y){if($)console.error("Error generating SEO files:",Y)}}async function v6(K={}){let Z=await O;if(!K.config)return Z;let Q=F6(E.cwd(),K.config);if(!S6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return b4({...Z,...Y})}async function w4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await v6(K),Q=K.outdir||Z.outDir||M.outdir,$=D(Q,".bunpress"),Y=`${$}.tmp-${E.pid}`,X=K.dir||Z.docsDir||M.docsdir,q=K.verbose??M.verbose,N=K.minify??!1,W=K.sourcemap??!1,R=performance.now(),_=new v("Building documentation...");if(!q)_.start();await K4(Y,{recursive:!0,force:!0}),await g4(Y,{recursive:!0});let G=await f4(X);if(G.length===0){if(!q)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(q)console.log(`Found ${G.length} markdown files:`),G.forEach((V)=>console.log(`- ${V}`));try{let{markdownToHtml:V,wrapInLayout:U}=await import("./chunk-
|
|
294
|
-
Generated ${G.length} HTML files in ${$}`);return!0}catch(V){if(await K4(Y,{recursive:!0,force:!0}),!q)_.fail("Build failed");return console.error("Error during build:",V),!1}}async function k6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-
|
|
293
|
+
`,"bold"));let{Glob:Y}=awaitPromise.resolve(globalThis.Bun),X=new Y("**/*.md"),q=[];for await(let J of X.scan(Q)){let A=O6(Q,J),f=await I6(A);q.push(f)}if(q.length===0)return j("No markdown files found"),!1;let N=q.reduce((J,A)=>J+A.size,0),W=q.reduce((J,A)=>J+A.lines,0),R=q.reduce((J,A)=>J+A.words,0),_=q.reduce((J,A)=>J+A.headings,0),G=q.reduce((J,A)=>J+A.codeBlocks,0);if(console.log(z("Summary","bold")),console.log("\u2500".repeat(50)),console.log(`Files: ${q.length}`),console.log(`Total size: ${w(N)}`),console.log(`Total lines: ${W.toLocaleString()}`),console.log(`Total words: ${R.toLocaleString()}`),console.log(`Headings: ${_}`),console.log(`Code blocks: ${G}`),console.log(),$){console.log(z("Per-file Statistics","bold")),console.log("\u2500".repeat(50));let J=q.map((A)=>({File:A.path.replace(`${Q}/`,""),Size:w(A.size),Lines:A.lines,Words:A.words,Headings:A.headings,"Code Blocks":A.codeBlocks}));g(J),console.log()}let V=N/q.length,U=W/q.length,H=R/q.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(H)}`),console.log();let S=[...q].sort((J,A)=>A.size-J.size).slice(0,5);if(S.length>0){console.log(z("Top 5 Largest Files","bold")),console.log("\u2500".repeat(50));for(let J of S){let A=J.path.replace(`${Q}/`,"");console.log(` ${A.padEnd(40)} ${w(J.size)}`)}console.log()}let x=Math.ceil(R/200);return B(`Estimated reading time: ${x} minutes`),!0}catch(Y){return j(`Failed to generate statistics: ${Y}`),!1}}var I=new y6("bunpress"),M={outdir:O.outDir||"./dist",docsdir:O.docsDir||"./docs",port:3000,open:!0,watch:!0,verbose:O.verbose};async function f4(K){let Z=new m4("**/*.md"),Q=[];for await(let $ of Z.scan(K))Q.push(D(K,$));return Q}async function D6(K,Z,Q=!1){let $=`${Z}/public`;try{await x6($);let Y=new m4("**/*");for await(let X of Y.scan($)){let q=D($,X),N=D(K,X);await g4(D(K,X.split("/").slice(0,-1).join("/")),{recursive:!0}),await L6(q,N)}}catch{if(Q)console.log("No public directory found, skipping static assets copy")}}function w6(K,Z,Q){let $=Z.replace(/^\.\//,""),Y=(_)=>_.replace(/^\.\//,"").replace($,"").replace(/^\//,"").replace(/\.md$/,"");if(!Q.enabled)return K.map((_)=>({sourceFile:_,relativePath:Y(_),locale:Q.defaultLocale}));let X=Q.locales,q=new Set(X),N=new Map;for(let _ of X)N.set(_,new Map);let W=new Set;for(let _ of K){let G=Y(_),V=G.split("/");if(V.length>1&&q.has(V[0])&&V[0]!==Q.defaultLocale){let H=V.slice(1).join("/");N.get(V[0]).set(H,_),W.add(H);continue}let U=G.match(/^(.*)\.([A-Za-z-]+)$/);if(U&&q.has(U[2])){N.get(U[2]).set(U[1],_),W.add(U[1]);continue}N.get(Q.defaultLocale).set(G,_),W.add(G)}let R=[];for(let _ of X)for(let G of W){let V=N.get(_).get(G)??N.get(Q.defaultLocale).get(G);if(!V)continue;R.push({sourceFile:V,relativePath:G,locale:_})}return R}async function b6(K,Z,Q,$){if((Q.search??Q.markdown?.search)?.enabled===!1)return;try{let Y=await h4(K,Q);if(await Bun.write(D(Z,P4.replace(/^\//,"")),JSON.stringify(Y)),$)console.log(`Indexed ${Y.length} sections for search.`)}catch(Y){if($)console.error("Error generating search index:",Y)}}async function C6(K,Z,Q,$){try{if(Q.sitemap?.enabled!==!1&&a(Q))await k4(K,Z,Q);if(Q.robots?.enabled!==!1)await v4(Z,Q);if(Q.rss?.enabled)await C4(K,Z,Q,Q.rss)}catch(Y){if($)console.error("Error generating SEO files:",Y)}}async function v6(K={}){let Z=await O;if(!K.config)return Z;let Q=F6(E.cwd(),K.config);if(!S6(Q))throw Error(`Config file not found: ${Q}`);let $=await import(Q),Y=$.default??$;return b4({...Z,...Y})}async function w4(K={}){if(K.manifest&&K.checkManifest)throw Error("--manifest and --check-manifest are mutually exclusive");let Z=await v6(K),Q=K.outdir||Z.outDir||M.outdir,$=D(Q,".bunpress"),Y=`${$}.tmp-${E.pid}`,X=K.dir||Z.docsDir||M.docsdir,q=K.verbose??M.verbose,N=K.minify??!1,W=K.sourcemap??!1,R=performance.now(),_=new v("Building documentation...");if(!q)_.start();await K4(Y,{recursive:!0,force:!0}),await g4(Y,{recursive:!0});let G=await f4(X);if(G.length===0){if(!q)_.fail("No markdown files found in docs directory");else console.log("No markdown files found in docs directory");return!1}if(q)console.log(`Found ${G.length} markdown files:`),G.forEach((V)=>console.log(`- ${V}`));try{let{markdownToHtml:V,wrapInLayout:U}=await import("./chunk-f4dw2x6b.js"),{loadI18nTranslations:H,resolveI18nConfig:S}=await import("./chunk-9ytw3mfw.js"),{mkdir:x,writeFile:J}=await import("fs/promises"),A=await H(S(Z),Z);if(q)console.log("Transforming markdown to HTML...");let f=w6(G,X,A);for(let C of f){let u4=await Bun.file(C.sourceFile).text(),{html:p4,frontmatter:$4}=await V(u4,X),m=C.relativePath,c4=`/${m}`,d4=$4.layout||"doc",l4=await U(p4,Z,c4,d4,$4,{i18n:A,locale:C.locale,sourceFile:C.sourceFile,docsDir:X}),a4=m==="index"||m.endsWith("/index"),X4=C.locale&&C.locale!==A.defaultLocale&&A.enabled?D(Y,C.locale):Y,u=a4?D(X4,`${m}.html`):D(X4,m,"index.html"),Y4=u.substring(0,u.lastIndexOf("/"));if(Y4)await x(Y4,{recursive:!0});if(await J(u,l4),q)console.log(`Generated: ${u}`)}if(q)console.log(`Processed ${G.length} markdown files into ${f.length} pages.`);if(await D6(Y,X,q),await P6(Y),await k6(Y,Z),K.searchIndex!==!1)await b6(X,Y,Z,q||!1);if(await C6(X,Y,Z,q||!1),K.checkManifest)await R4(Y,K.checkManifest,p);if(await K4($,{recursive:!0,force:!0}),await E6(Y,$),K.manifest)await W4($,K.manifest,p);let Z4=performance.now()-R;if(!q)_.succeed(`Built ${G.length} pages to HTML in ${i(Z4)}`);else T(`Build completed in ${i(Z4)}`),console.log(`
|
|
294
|
+
Generated ${G.length} HTML files in ${$}`);return!0}catch(V){if(await K4(Y,{recursive:!0,force:!0}),!q)_.fail("Build failed");return console.error("Error during build:",V),!1}}async function k6(K,Z){let{getConfiguredBasePath:Q,wrapInLayout:$}=await import("./chunk-f4dw2x6b.js"),X=`
|
|
295
295
|
<style>
|
|
296
296
|
.NotFound {
|
|
297
297
|
padding: 64px 24px 96px;
|
|
@@ -370,7 +370,7 @@ Generated ${G.length} HTML files in ${$}`);return!0}catch(V){if(await K4(Y,{recu
|
|
|
370
370
|
</div>
|
|
371
371
|
`,q=await $(X,Z,"/404","doc");await Bun.write(D(K,"404.html"),q)}async function P6(K){let Z=D(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)}}I.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 w4(K))E.exit(1);if(K.watch){let{watch:Q}=await import("fs"),$=await O,Y=K.dir||$.docsDir||"./docs";console.log(`
|
|
372
372
|
Watching for changes...`),Q(Y,{recursive:!0},async(X,q)=>{if(q&&q.endsWith(".md"))console.log(`
|
|
373
|
-
Detected change in ${q}, rebuilding...`),await w4(K)}),await new Promise(()=>{})}});I.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:q}=await import("./chunk-
|
|
373
|
+
Detected change in ${q}, rebuilding...`),await w4(K)}),await new Promise(()=>{})}});I.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:q}=await import("./chunk-f4dw2x6b.js");await q({port:Q,root:$,watch:Y,config:Z})});async function h6(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 q=await f4(Q);if(q.length===0)return console.log("No markdown files found in docs directory"),!1;if(X)console.log(`Found ${q.length} markdown files`);q.sort();let N=`# Documentation
|
|
374
374
|
|
|
375
375
|
`;N+=`Generated: ${new Date().toISOString()}
|
|
376
376
|
|
|
@@ -389,5 +389,5 @@ Detected change in ${q}, rebuilding...`),await w4(K)}),await new Promise(()=>{})
|
|
|
389
389
|
`}N+=`---
|
|
390
390
|
|
|
391
391
|
`}return await Bun.write($,N),console.log(`
|
|
392
|
-
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}I.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 h6(K))E.exit(1)});I.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 B4(K))E.exit(1)});I.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 O4(K)});I.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 V4(K))E.exit(1)});I.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 U4(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await j4(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await A4(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await J4(K))E.exit(1)});I.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 z4(K,Z))E.exit(1)});I.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 D4(K))E.exit(1)});I.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 F4(K)});I.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-
|
|
393
|
-
export{T as
|
|
392
|
+
LLM markdown generated successfully: ${$}`),console.log(`Total size: ${(N.length/1024).toFixed(2)} KB`),!0}I.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 h6(K))E.exit(1)});I.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 B4(K))E.exit(1)});I.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 O4(K)});I.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 V4(K))E.exit(1)});I.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 U4(K))E.exit(1)});I.command("config:show","Show current configuration").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await j4(K))E.exit(1)});I.command("config:validate","Validate configuration file").option("--verbose","Enable verbose logging",{default:M.verbose}).action(async(K)=>{if(!await A4(K))E.exit(1)});I.command("config:init","Initialize configuration file").action(async(K)=>{if(!await J4(K))E.exit(1)});I.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 z4(K,Z))E.exit(1)});I.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 D4(K))E.exit(1)});I.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 F4(K)});I.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-z74qp3xn.js");if(!await Z(K))E.exit(1)});I.help();I.version(p);var Q4=Bun.argv[1]||"",m6=Q4.endsWith("/bunpress")||Q4.endsWith("/cli.ts")||Q4.endsWith("/cli.js");if(m6)I.parse();
|
|
393
|
+
export{T as q,j as r,B as s,v as t,f4 as u,v6 as v,w4 as w};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{fa as a,ga as b,ha as c,ia as d,ja as e,ka as f,la as g,ma as h,na as i}from"./chunk-rnzqf7rp.js";export{c as splitLocaleFromPath,a as resolveI18nConfig,d as localizeUrl,g as localeLabel,e as localeContentCandidates,b as loadI18nTranslations,i as generateLocaleDetectionScript,h as generateHreflangTags,f as configForLocale};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{j as a,k as b,l as c,m as d,n as e,o as f,p as g}from"./chunk-532cbqgt.js";import"./chunk-3ymfys00.js";import"./chunk-rnzqf7rp.js";export{d as wrapInLayout,c as stripConfiguredBasePath,f as startServer,g as serveCLI,e as markdownToHtml,b as getConfiguredBasePath,a as decodeHtmlEntities};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ea as B}from"./chunk-rnzqf7rp.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 x,c as y,a as z,n as A,i as B};
|
|
@@ -35,4 +35,4 @@ var j=import.meta.require;function X(q){return(q.sitemap?.baseUrl||q.url||"").re
|
|
|
35
35
|
}
|
|
36
36
|
})();
|
|
37
37
|
`.trim()}
|
|
38
|
-
export{j as
|
|
38
|
+
export{j as da,X as ea,O as fa,A as ga,E as ha,x as ia,I as ja,_ as ka,D as la,F as ma,R as na};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{q as $,r as I,s as f,t as h,w as x}from"./chunk-7cdk9y78.js";import"./chunk-rcr6k1et.js";import{E as _}from"./chunk-3ymfys00.js";import"./chunk-rnzqf7rp.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(`
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as W,b as X,c as Y,d as Z,e as _,f as $,g as b,h as v,i as A,j as zj,k as Bj,l as Dj,m as Ej,n as Gj,o as Hj}from"../chunk-
|
|
2
|
+
import{a as W,b as X,c as Y,d as Z,e as _,f as $,g as b,h as v,i as A,j as zj,k as Bj,l as Dj,m as Ej,n as Gj,o as Hj,p as Ij}from"../chunk-532cbqgt.js";import{A as u,B as w,x as j,y as k,z as q}from"../chunk-rcr6k1et.js";import{$ as wj,C as Q,D as S,E as T,F as V,K as p,L as f,M as c,N as d,O as g,P as a,Q as n,R as o,S as r,T as t,U as i,V as s,W as e,X as jj,Y as kj,Z as qj,_ as uj,aa as z,ba as B,ca as D}from"../chunk-3ymfys00.js";import{fa as F,ga as R,ha as U,ia as m,ja as x,ka as C,la as l,ma as h,na as y}from"../chunk-rnzqf7rp.js";export{Ej as wrapInLayout,Dj as stripConfiguredBasePath,Hj as startServer,U as splitLocaleFromPath,X as setLanguageAliases,Ij as serveCLI,F as resolveI18nConfig,W as resetHighlighter,d as reserveUniqueSlug,kj as processInlineTocSyntax,v as prewarmHighlighter,Y as normalizeLanguage,Gj as markdownToHtml,f as markdownHeadingText,m as localizeUrl,l as localeLabel,x as localeContentCandidates,R as loadI18nTranslations,Z as isLanguageSupported,$ as highlightCodeSync,_ as highlightCode,b as getSyntaxHighlightingStyles,A as getHighlighterInstance,Bj as getConfiguredBasePath,V as getConfig,g as generateUniqueSlug,uj as generateTocStyles,wj as generateTocScripts,jj as generateTocPositions,r as generateTocHtml,e as generateTocData,c as generateSlug,w as generateSitemap,i as generateSidebarTocHtml,k as generateRssFeed,q as generateRobotsTxt,y as generateLocaleDetectionScript,t as generateInlineTocHtml,h as generateHreflangTags,s as generateFloatingTocHtml,o as filterHeadings,a as extractHeadings,qj as enhanceHeadingsWithAnchors,p as defaultTocConfig,Q as defaultConfig,zj as decodeHtmlEntities,C as configForLocale,T as config,n as buildTocHierarchy,u as buildSitemap,B as buildSearchRuntimeConfig,D as buildSearchIndex,j as buildRssFeed,S as applyConfigPlugins,z as SEARCH_INDEX_PATH};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare function isMessagePreviewLang(lang: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Split a fence into headers and body. Headers exist only when a `---` line
|
|
4
|
+
* follows lines that all read `key: value`, so a body that merely contains a
|
|
5
|
+
* colon is never mistaken for one.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseMessage(source: string, splitParts: boolean): ParsedMessage;
|
|
8
|
+
export declare function renderEmailPreview(source: string): string;
|
|
9
|
+
/** How many SMS segments a message costs, the way carriers count them. */
|
|
10
|
+
export declare function countSmsSegments(text: string): SmsSegments;
|
|
11
|
+
export declare function renderSmsPreview(source: string): string;
|
|
12
|
+
/** Render a message fence, or `null` when the language is not one of ours. */
|
|
13
|
+
export declare function renderMessagePreview(lang: string, source: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Replace each top-level ```email / ```sms fence with its text, so the copy of
|
|
16
|
+
* a message stays searchable while every other code block is stripped from
|
|
17
|
+
* the search index. A message fence shown inside a longer example fence is
|
|
18
|
+
* left alone: that is syntax being demonstrated, not a message.
|
|
19
|
+
*/
|
|
20
|
+
export declare function unwrapMessageFences(markdown: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Message previews: ```email and ```sms fences rendered as the message itself.
|
|
23
|
+
*
|
|
24
|
+
* Product docs often need to show the exact copy a system sends — a welcome
|
|
25
|
+
* email, a class reminder text — and a plain code block reads as code, not as
|
|
26
|
+
* a message. These fences render an email as a mail-client card (headers,
|
|
27
|
+
* subject, body, buttons) and an SMS thread as phone bubbles with a character
|
|
28
|
+
* and segment count, so a reader sees what the recipient sees.
|
|
29
|
+
*
|
|
30
|
+
* ````md
|
|
31
|
+
* ```email
|
|
32
|
+
* from: Acme <hello@acme.com>
|
|
33
|
+
* to: The new member
|
|
34
|
+
* subject: Welcome to Acme, {firstName}
|
|
35
|
+
* ---
|
|
36
|
+
* Hi {firstName},
|
|
37
|
+
*
|
|
38
|
+
* [Set your password](https://acme.com/reset)
|
|
39
|
+
* ```
|
|
40
|
+
* ````
|
|
41
|
+
*
|
|
42
|
+
* Header lines (`key: value`) come before the first `---`; the body follows.
|
|
43
|
+
* In an `sms` fence every later `---` starts another message in the thread,
|
|
44
|
+
* and a message whose lines all start with `> ` is a reply from the recipient.
|
|
45
|
+
* In an `email` fence a later `---` is a divider (above a footer, say).
|
|
46
|
+
* `{name}` and `{{ name }}` placeholders are highlighted as variables.
|
|
47
|
+
*/
|
|
48
|
+
/** The fence languages rendered as message previews. */
|
|
49
|
+
export declare const MESSAGE_PREVIEW_LANGS: readonly string[];
|
|
50
|
+
/** Styles for both previews, built on the theme's own colour variables. */
|
|
51
|
+
export declare const messagePreviewCSS: string;
|
|
52
|
+
export declare interface ParsedMessage {
|
|
53
|
+
headers: Array<{ key: string, value: string }>
|
|
54
|
+
parts: string[][]
|
|
55
|
+
}
|
|
56
|
+
export declare interface SmsSegments {
|
|
57
|
+
encoding: 'GSM-7' | 'UCS-2'
|
|
58
|
+
length: number
|
|
59
|
+
segments: number
|
|
60
|
+
}
|
package/dist/src/serve.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { config } from './config';
|
|
2
2
|
import type { BunPressConfig, Frontmatter } from './types';
|
|
3
3
|
import type { ResolvedI18n } from './i18n';
|
|
4
|
+
/**
|
|
5
|
+
* Text from HTML back to text: `Raster & heatmap` to `Raster & heatmap`.
|
|
6
|
+
* A page title is read from its rendered `<h1>`, and is escaped again where
|
|
7
|
+
* it is written; left encoded, `&` came out as `&amp;` in the tab.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decodeHtmlEntities(value: string): string;
|
|
4
10
|
export declare function getConfiguredBasePath(config: BunPressConfig): string;
|
|
5
11
|
export declare function stripConfiguredBasePath(config: BunPressConfig, pathname: string): string;
|
|
6
12
|
export declare function wrapInLayout(content: string, siteConfig: BunPressConfig, currentPath: string, layout?: string, frontmatter?: Frontmatter, options?: WrapLayoutOptions): Promise<string>;
|
|
@@ -34,6 +40,7 @@ export declare interface CodeBlockFeatures {
|
|
|
34
40
|
lineNumbers: boolean
|
|
35
41
|
diffs: boolean
|
|
36
42
|
errorWarningMarkers: boolean
|
|
43
|
+
messagePreviews?: boolean
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* Wrap content in BunPress documentation layout
|
package/dist/src/types.d.ts
CHANGED
|
@@ -217,6 +217,7 @@ export declare interface MarkdownFeaturesConfig {
|
|
|
217
217
|
githubAlerts?: boolean | GitHubAlertsConfig
|
|
218
218
|
codeBlocks?: boolean | CodeBlocksConfig
|
|
219
219
|
codeGroups?: boolean
|
|
220
|
+
messagePreviews?: boolean
|
|
220
221
|
codeImports?: boolean
|
|
221
222
|
inlineToc?: boolean
|
|
222
223
|
customAnchors?: boolean
|
package/package.json
CHANGED
package/dist/chunk-he7yz8ak.js
DELETED