docfuse 0.1.0

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.
@@ -0,0 +1,3 @@
1
+ import{a as h}from"./chunk-GRQDPV4U.js";import{d as a,e as E,f as d,g as u}from"./chunk-JK7ZNBUA.js";import{a as o}from"./chunk-AYDF3IFZ.js";import{randomUUID as b}from"crypto";import{mkdir as B,open as x,readFile as p,rename as S,rm as f,stat as k,writeFile as M}from"fs/promises";import{hostname as O}from"os";import{dirname as v,join as y}from"path";var w=600*1e3,A=Math.floor(w/3);function l(t){return typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.includes("\\")&&t.split("/").every(e=>e!==""&&e!=="."&&e!=="..")}o(l,"isSafeOutputPath");function Q(t){return a(t,".docfuse/cache","build cache")}o(Q,"resolveBuildCacheRoot");function Y(t){return a(t,".docfuse/tmp","temporary build files")}o(Y,"resolveBuildTemporaryRoot");function P(t){return y(t,"build-manifest.json")}o(P,"manifestPath");function D(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fingerprint=="string"&&l(e.outputPath)&&l(e.markdownOutputPath)&&Array.isArray(e.assetOutputPaths)&&e.assetOutputPaths.every(l)}o(D,"isPageState");function R(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fingerprint=="string"&&Number.isSafeInteger(e.size)&&Number(e.size)>=0}o(R,"isOutputState");function j(t){if(!t||typeof t!="object")return!1;let e=t;return e.schemaVersion===3&&e.docfuseVersion===h&&typeof e.buildFingerprint=="string"&&typeof e.sharedFingerprint=="string"&&!!e.pages&&typeof e.pages=="object"&&Object.values(e.pages).every(D)&&!!e.outputs&&typeof e.outputs=="object"&&Object.keys(e.outputs).length>0&&Object.keys(e.outputs).every(l)&&Object.values(e.outputs).every(R)}o(j,"isBuildManifest");async function Z(t){try{let e=JSON.parse(await p(P(t),"utf8"));return j(e)?e:void 0}catch(e){if(e.code==="ENOENT"||e instanceof SyntaxError)return;throw e}}o(Z,"readBuildManifest");async function tt(t,e){await B(t,{recursive:!0});let n=P(t),i=y(t,`.build-manifest.${b()}.tmp`);try{await M(i,`${JSON.stringify(e,null,2)}
2
+ `,{flag:"wx",flush:!0});try{await S(i,n)}catch(r){let s=r.code;if(s!=="EEXIST"&&s!=="EPERM")throw r;await f(n,{force:!0}),await S(i,n)}}finally{await f(i,{force:!0})}}o(tt,"writeBuildManifest");function T(t){try{return process.kill(t,0),!0}catch(e){return e.code!=="ESRCH"}}o(T,"processIsAlive");function F(t,e,n=Date.now()){if(t.hostname===O()&&typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0&&!T(t.pid))return!0;let i=typeof t.updatedAt=="number"?t.updatedAt:typeof t.createdAt=="number"?t.createdAt:void 0,r=i===void 0?e:Math.max(i,e);return r===void 0||!Number.isFinite(r)||r>n+w||n-r>w}o(F,"lockIsStale");function J(t,e){return JSON.stringify({ownerId:t,pid:process.pid,hostname:O(),createdAt:e})}o(J,"lockContents");async function g(t){try{return JSON.parse(await p(t,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}o(g,"readBuildLock");async function m(t){let e=await x(t,"wx"),n=b(),i=Date.now();try{return await e.writeFile(J(n,i)),{handle:e,path:t,ownerId:n,createdAt:i}}catch(r){throw await e.close(),await f(t,{force:!0}),r}}o(m,"createBuildLock");async function N(t){(await g(t.path))?.ownerId===t.ownerId&&await f(t.path,{force:!0})}o(N,"releaseBuildLock");async function I(t){let e,n;try{let[r,s]=await Promise.all([p(t,"utf8"),k(t)]);e=r,n=s.mtimeMs}catch(r){if(r.code==="ENOENT")return!0;throw r}let i;try{i=F(JSON.parse(e),n)}catch{i=Date.now()-n>w}if(!i)return!1;try{let[r,s]=await Promise.all([p(t,"utf8"),k(t)]);return r!==e||s.mtimeMs!==n?!1:(await f(t),!0)}catch(r){if(r.code==="ENOENT")return!0;throw r}}o(I,"removeStaleLock");async function _(t){try{return await m(t)}catch(e){if(e.code!=="EEXIST")throw e;if(!await I(t))throw new Error("Another Docfuse build is already running for this project");try{return await m(t)}catch(n){throw n.code==="EEXIST"?new Error("Another Docfuse build is already running for this project"):n}}}o(_,"acquireBuildLock");async function C(t){let e=v(t);await B(e,{recursive:!0});let n=y(e,"build.lock"),i=await _(`${n}.reclaim`);try{try{return await m(n)}catch(r){if(r.code!=="EEXIST")throw r;if(!await I(n))throw new Error("Another Docfuse build is already running for this project");return await m(n)}}finally{await i.handle.close(),await N(i)}}o(C,"openBuildLock");async function $(t){if((await g(t.path))?.ownerId!==t.ownerId)return!1;let n=new Date;return await t.handle.utimes(n,n),!0}o($,"refreshBuildLock");async function V(t){if((await g(t.path))?.ownerId!==t.ownerId)throw new Error("Docfuse build lock ownership was lost during the build")}o(V,"assertBuildLockOwned");async function et(t,e){let n=await C(t),i,r=setInterval(()=>{$(n).then(s=>{s||(i=new Error("Docfuse build lock ownership was lost during the build"))}).catch(s=>{i=s})},A);r.unref();try{let s=o(()=>V(n),"assertOwned"),c=await e(s);if(i)throw i;return await s(),c}finally{clearInterval(r),await n.handle.close(),await N(n)}}o(et,"withBuildLock");async function ot(t,e,n){let i=E(t,e.outputDir);await d(t,i,"outputDir"),await d(t,n,"build cache"),await u(i,n,"build cache");for(let r of e.versions.items){let s=a(t,r.docsDir,`versions.items[${r.id}].docsDir`);await d(t,s,`versions.items[${r.id}].docsDir`),await u(i,s,`versions.items[${r.id}].docsDir`),await u(n,s,`versions.items[${r.id}].docsDir`,"build cache")}for(let[r,s]of e.styles.entries()){let c=a(t,s,`styles[${r}]`);await d(t,c,`styles[${r}]`),await u(i,c,`styles[${r}]`),await u(n,c,`styles[${r}]`,"build cache")}return i}o(ot,"resolveSafeOutputRoot");export{Q as a,Y as b,Z as c,tt as d,et as e,ot as f};
3
+ //# sourceMappingURL=chunk-S36HQTIA.js.map
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./chunk-AYDF3IFZ.js";function h(a){let r=a.toLowerCase(),i=r.match(/[a-z0-9]+/g)??[],o=[];for(let f of r.matchAll(new RegExp("\\p{Script=Han}+","gu"))){let t=Array.from(f[0]);o.push(...t);for(let n=0;n<t.length-1;n+=1){let s=t[n],c=t[n+1];s&&c&&o.push(s+c)}}return Array.from(new Set([...i,...o]))}e(h,"tokenize");export{h as a};
2
+ //# sourceMappingURL=chunk-XYJ2OBL3.js.map
@@ -0,0 +1,2 @@
1
+ import{a as m,b as f,e as p,f as l}from"./chunk-S36HQTIA.js";import{j as s}from"./chunk-DOOG32NU.js";import{a as n}from"./chunk-5NTRNUFG.js";import"./chunk-GRQDPV4U.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import{a as c}from"./chunk-AYDF3IFZ.js";import{readdir as R,rm as o}from"fs/promises";import{basename as h,dirname as g,join as b}from"path";async function x({cwd:t}){let i=await s(t),r=m(t),a=await l(t,i,r);await p(r,async()=>{let u=g(a),d=h(a).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=new RegExp(`^\\.${d}\\.(?:backup|(?:tmp|backup)-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$`,"i"),v=await R(u,{withFileTypes:!0}).catch(e=>{if(e.code==="ENOENT")return[];throw e});await Promise.all(v.filter(e=>w.test(e.name)).map(e=>o(b(u,e.name),{recursive:!0,force:!0}))),await o(a,{recursive:!0,force:!0}),await o(r,{recursive:!0,force:!0}),await o(f(t),{recursive:!0,force:!0})}),n(`Removed ${i.outputDir}, .docfuse/cache, and temporary or interrupted build files`)}c(x,"runClean");export{x as runClean};
2
+ //# sourceMappingURL=clean-KTIDWI35.js.map
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import{b as f}from"./chunk-5NTRNUFG.js";import{a as l}from"./chunk-AYDF3IFZ.js";function u(n){let o=n.slice(1),t=o.flatMap((c,s)=>c==="--port"?[s]:[]);if(t.length>1)throw new Error("--port may only be specified once");let r=t[0];if(r===void 0){if(o.length)throw new Error(`Unknown option: ${o[0]}`);return}if(r!==0)throw new Error(`Unknown option: ${o[0]}`);let i=o[r+1];if(!i||i.startsWith("-"))throw new Error("Missing value for --port");if(o.length>2)throw new Error(`Unknown option: ${o[2]}`);let e=Number(i);if(!Number.isInteger(e)||e<1||e>65535)throw new Error(`Invalid port: ${i}`);return e}l(u,"portFromArgs");function d(n){let o=n.slice(1);if(!o.length)return{noCache:!1};if(o[0]!=="--no-cache")throw new Error(`Unknown option: ${o[0]}`);if(o.length>1)throw new Error(`Unknown option: ${o[1]}`);return{noCache:!0}}l(d,"buildOptionsFromArgs");function w(n){try{let o=Intl.getCanonicalLocales(n)[0];if(!o)throw new Error("Missing canonical locale");return o}catch{throw new Error(`Invalid locale: ${n}`)}}l(w,"canonicalLocale");function h(n){let o={},t=n.slice(1),r=new Set;for(let i=0;i<t.length;i+=1){let e=t[i];if(!e)continue;if(!e.startsWith("-")){if(o.targetDir)throw new Error(`Unknown option: ${e}`);o.targetDir=e;continue}if(e!=="--locale"&&e!=="--locales"&&e!=="--docs-dir")throw new Error(`Unknown option: ${e}`);if(r.has(e))throw new Error(`${e} may only be specified once`);r.add(e);let c=t[i+1];if(!c||c.startsWith("-"))throw new Error(`Missing value for ${e}`);if(i+=1,e==="--locale"&&(o.locale=c),e==="--locales"){let s=c.split(",").map(p=>p.trim());if(s.some(p=>!p))throw new Error("--locales must be a comma-separated list of locale identifiers");o.locales=s}e==="--docs-dir"&&(o.docsDir=c)}if(o.locale&&(o.locale=w(o.locale)),o.locales){if(o.locales=o.locales.map(w),new Set(o.locales).size!==o.locales.length)throw new Error("--locales must not contain duplicate locales");if(o.locale&&!o.locales.includes(o.locale))throw new Error(`--locale ${o.locale} must be included in --locales`);o.locale??=o.locales[0]}return o}l(h,"initOptionsFromArgs");function g(){console.log(`docfuse
3
+
4
+ Commands:
5
+ init [dir] [--locale <locale>] [--locales <locale,...>] [--docs-dir <path>]
6
+ Create or adopt documentation
7
+ dev [--port <number>]
8
+ Start local docs server on a custom local port
9
+ build [--no-cache]
10
+ Build static site, optionally ignoring the persistent cache
11
+ clean Remove generated output and the persistent build cache
12
+ preview [--port <number>]
13
+ Preview .docfuse/dist on a custom local port
14
+ check Run documentation checks
15
+ deploy Generate deployment guidance
16
+ `)}l(g,"printHelp");function a(n,o){let t=n[o];if(t!==void 0)throw new Error(`Unknown option: ${t}`)}l(a,"assertArgumentCount");async function m(n,o=process.cwd()){let t=n[0]??"help";if(t==="help"||t==="--help"||t==="-h"){a(n,1),g();return}if(t==="init"){let{runInit:r}=await import("./init-NJUIADRO.js");return r({cwd:o,...h(n)})}if(t==="build"){let{runBuild:r}=await import("./build-X3KCJUYB.js");return r({cwd:o,...d(n)})}if(t==="clean"){a(n,1);let{runClean:r}=await import("./clean-KTIDWI35.js");return r({cwd:o})}if(t==="dev"){let{runDev:r}=await import("./dev-BMFVSQSM.js");return r({cwd:o,port:u(n)})}if(t==="preview"){let{runPreview:r}=await import("./preview-FI2XY4WS.js"),i=u(n);return r({cwd:o,port:i})}if(t==="check"){a(n,1);let{runCheck:r}=await import("./check-RJPHTGI6.js");return r({cwd:o})}if(t==="deploy"){a(n,1);let{runDeploy:r}=await import("./deploy-UPDSE6GI.js");return r({cwd:o})}throw new Error(`Unknown command: ${t}`)}l(m,"runCli");m(process.argv.slice(2)).catch(n=>{f(n instanceof Error?n.message:String(n)),process.exitCode=1});
17
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,144 @@
1
+ import{j as g}from"./chunk-DOOG32NU.js";import{a as d}from"./chunk-5NTRNUFG.js";import"./chunk-EAYVCA3Z.js";import{a as i,e as f}from"./chunk-JK7ZNBUA.js";import{a}from"./chunk-AYDF3IFZ.js";import{mkdir as y,readFile as h,writeFile as $}from"fs/promises";import{join as r}from"path";function k(o){return`"${o.replace(/[\\"$]/g,"\\$&")}"`}a(k,"quoteNginxValue");async function b(o){if(await i(r(o,"pnpm-lock.yaml")))return"pnpm";if(await i(r(o,"yarn.lock")))return"yarn";try{let e=JSON.parse(await h(r(o,"package.json"),"utf8"));if(typeof e.packageManager=="string"){if(e.packageManager.startsWith("pnpm@"))return"pnpm";if(e.packageManager.startsWith("yarn@"))return"yarn"}}catch(e){if(e.code!=="ENOENT"&&!(e instanceof SyntaxError))throw e}return"npm"}a(b,"detectPackageManager");function w(o,e,s){let t=o.replaceAll("\\","/"),c=k(`/var/www/docfuse/${t.replace(/^\/+/,"")}`),u=e.replace(/\/$/,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p=e==="/"?` location / {
2
+ try_files $uri $uri/ =404;
3
+ }`:` location = ${e.replace(/\/$/,"")} {
4
+ return 308 ${e};
5
+ }
6
+
7
+ location ${e} {
8
+ rewrite ^${u}/(.*)$ /$1 break;
9
+ try_files $uri $uri/ =404;
10
+ }
11
+
12
+ location / {
13
+ return 404;
14
+ }`,l=JSON.stringify(t),m={npm:"npm exec -- docfuse build",pnpm:"pnpm exec docfuse build",yarn:"yarn exec docfuse build"}[s],n=`Deploy directory:
15
+
16
+ \`\`\`txt
17
+ ${t}
18
+ \`\`\`
19
+
20
+ Serve this directory at URL path \`${e}\`.
21
+
22
+ Docfuse does not provide hosting, permissions, accounts, analytics, or server runtime.
23
+ `;return{"README.md":`# Docfuse Deployment
24
+
25
+ ${n}
26
+
27
+ Supported static hosts:
28
+
29
+ - GitHub Pages
30
+ - Cloudflare Pages
31
+ - Vercel
32
+ - Netlify
33
+ - Nginx
34
+ - Object storage
35
+ `,"github-pages.md":`# GitHub Pages
36
+
37
+ ${n}
38
+
39
+ Use \`${t}\` as the published static artifact.
40
+ `,"github-pages.yml":`name: Deploy Docfuse
41
+
42
+ on:
43
+ push:
44
+ branches: [main]
45
+ workflow_dispatch:
46
+
47
+ permissions:
48
+ contents: read
49
+ pages: write
50
+ id-token: write
51
+
52
+ concurrency:
53
+ group: pages
54
+ cancel-in-progress: false
55
+
56
+ jobs:
57
+ pages:
58
+ runs-on: ubuntu-latest
59
+ environment:
60
+ name: github-pages
61
+ url: \${{ steps.deployment.outputs.page_url }}
62
+ steps:
63
+ - uses: actions/checkout@v4
64
+ - uses: actions/setup-node@v4
65
+ with:
66
+ node-version: 22
67
+ - uses: actions/configure-pages@v5
68
+ - name: Install dependencies
69
+ shell: bash
70
+ run: |
71
+ if [[ -f pnpm-lock.yaml ]]; then
72
+ corepack enable
73
+ pnpm install --frozen-lockfile
74
+ elif [[ -f yarn.lock ]]; then
75
+ corepack enable
76
+ yarn install --immutable
77
+ elif [[ -f package-lock.json ]]; then
78
+ npm ci
79
+ elif [[ -f package.json ]]; then
80
+ npm install
81
+ fi
82
+ - name: Build documentation
83
+ shell: bash
84
+ run: |
85
+ if [[ -f pnpm-lock.yaml ]]; then
86
+ pnpm exec docfuse build
87
+ elif [[ -f yarn.lock ]]; then
88
+ yarn exec docfuse build
89
+ elif [[ -f package.json ]]; then
90
+ npm exec -- docfuse build
91
+ else
92
+ echo "Add docfuse to package.json before deploying" >&2
93
+ exit 1
94
+ fi
95
+ - uses: actions/upload-pages-artifact@v3
96
+ with:
97
+ path: ${l}
98
+ - name: Deploy to GitHub Pages
99
+ id: deployment
100
+ uses: actions/deploy-pages@v4
101
+ `,"cloudflare-pages.md":`# Cloudflare Pages
102
+
103
+ ${n}
104
+
105
+ Set the output directory to \`${t}\`.
106
+ `,"vercel.md":`# Vercel
107
+
108
+ ${n}
109
+
110
+ Use \`${t}\` as the output directory.
111
+ `,"vercel.json":`{
112
+ "outputDirectory": ${l}
113
+ }
114
+ `,"netlify.md":`# Netlify
115
+
116
+ ${n}
117
+
118
+ Use \`${t}\` as the publish directory.
119
+ `,"netlify.toml":`[build]
120
+ publish = ${l}
121
+ command = ${JSON.stringify(m)}
122
+ `,"nginx.md":`# Nginx
123
+
124
+ ${n}
125
+
126
+ Serve \`${t}\` as a static directory.
127
+ `,"nginx.conf":`# NOTE: Update the 'root' path below to match your server's document root.
128
+ # The default /var/www/docfuse/ is a placeholder \u2014 adjust it to where you
129
+ # copied the built output (the contents of the '${t}' directory).
130
+ server {
131
+ listen 80;
132
+ server_name _;
133
+ root ${c};
134
+ index index.html;
135
+ error_page 404 /404.html;
136
+
137
+ location = /404.html {
138
+ internal;
139
+ }
140
+
141
+ ${p}
142
+ }
143
+ `}}a(w,"createGuides");async function E({cwd:o}){let e=await g(o),s=f(o,e.outputDir);if(!await i(r(s,"index.html")))throw new Error(`Build output not found at ${e.outputDir}. Run docfuse build before docfuse deploy.`);let t=r(o,".docfuse/deploy"),c=await b(o);await y(t,{recursive:!0});for(let[u,p]of Object.entries(w(e.outputDir,e.basePath,c)))await $(r(t,u),p);d(`Wrote deployment guides to ${t}`)}a(E,"runDeploy");export{E as runDeploy};
144
+ //# sourceMappingURL=deploy-UPDSE6GI.js.map
@@ -0,0 +1,2 @@
1
+ import{a as b}from"./chunk-FF7ZHS4U.js";import{b as g}from"./chunk-N26MW2YK.js";import"./chunk-M47X2MM3.js";import{b as h}from"./chunk-GNYJERGG.js";import"./chunk-XYJ2OBL3.js";import{a as B}from"./chunk-S36HQTIA.js";import"./chunk-DOOG32NU.js";import{a as v,b as f}from"./chunk-5NTRNUFG.js";import"./chunk-GRQDPV4U.js";import"./chunk-EAYVCA3Z.js";import{c as p,e as m}from"./chunk-JK7ZNBUA.js";import{a as o}from"./chunk-AYDF3IFZ.js";import w from"chokidar";import{createMarkdownRenderer as S}from"@docfuse/markdown/server";import{relative as P,resolve as k,sep as R}from"path";function D({build:i,reload:c,onBuildError:l=o(t=>f(t instanceof Error?t.message:String(t)),"onBuildError"),onBuildOk:n,debounceMs:s=80}){let t,u,e=!1,r=!1,a=o(()=>{if(t=void 0,!r){if(u){e=!0;return}u=(async()=>{try{let d=await i();r||(n?.(),c(d))}catch(d){l(d)}finally{u=void 0,e&&!r&&(e=!1,t=setTimeout(a,0))}})()}},"run");return{schedule(){if(!r){if(u){e=!0;return}t&&clearTimeout(t),t=setTimeout(a,s)}},async close(){r=!0,e=!1,t&&clearTimeout(t),t=void 0,await u}}}o(D,"createBuildScheduler");async function y({cwd:i,port:c}){let l=S(),n=await g({cwd:i,renderer:l}),s=await b({root:o(()=>m(i,n.config.outputDir),"root"),port:c,liveReload:!0,basePath:o(()=>n.config.basePath,"basePath")}),t=w.watch(".",{cwd:i,ignoreInitial:!0,ignored:o(e=>{let r=k(i,e),a=P(i,r).split(R);return a.includes("node_modules")||a.includes(".git")||a.includes(".docfuse")||a.some(d=>/^\..+\.(?:tmp|backup)-/.test(d))?!0:p(m(i,n.config.outputDir),r)||p(B(i),r)},"ignored")}),u=D({build:o(async()=>{n=await g({cwd:i,renderer:l});let e=n.changedPages.flatMap(r=>{let a=n.graph.pages.find(d=>d.sourceRelativePath===r);return a?[h(n.config,a.routePath)]:[]});return{protocol:1,type:"update",mode:n.partialReload&&e.length===1?"page":"full",routes:e}},"build"),reload:o(e=>s.reload(e),"reload"),onBuildError:o(e=>{let r=e instanceof Error?e.message:String(e);f("Build error:",r),s.sendBuildError(r)},"onBuildError"),onBuildOk:o(()=>s.sendBuildOk(),"onBuildOk")});return t.on("all",()=>u.schedule()),t.on("error",e=>{let r=e instanceof Error?e.message:String(e);f("File watcher error:",r),s.sendBuildError(r)}),{port:s.port,close:o(async()=>{await t.close(),await u.close(),await s.close()},"close")}}o(y,"startDevServer");async function z({cwd:i,port:c=3333}){let l=await y({cwd:i,port:c});return v(`Dev server running at http://127.0.0.1:${l.port}/`),l}o(z,"runDev");export{z as runDev};
2
+ //# sourceMappingURL=dev-BMFVSQSM.js.map
@@ -0,0 +1,438 @@
1
+ import { MarkdownHtmlPolicy, MarkdownCodeOptions, MarkdownFeatureOptions, MarkdownLabels, MarkdownPlugin } from '@docfuse/markdown';
2
+ import { MarkdownThemeInput } from '@docfuse/markdown/theme';
3
+ import { MarkdownHeading, MarkdownCodeExample } from '@docfuse/markdown/server/analyze';
4
+
5
+ /** Package version injected by tsup so chunk nesting cannot affect lookup. */
6
+ declare const docfuseVersion: string;
7
+
8
+ declare const homeIconNames: readonly ["ai", "box", "code", "file", "file-code", "gauge", "globe", "layers", "rocket", "search", "sparkles", "terminal"];
9
+ type HomeIconName = (typeof homeIconNames)[number];
10
+ interface DocfuseFrontmatter {
11
+ title?: string;
12
+ description?: string;
13
+ createdAt?: string;
14
+ updatedAt?: string;
15
+ order?: number;
16
+ group?: string;
17
+ subgroup?: string;
18
+ collapsed?: boolean;
19
+ sidebar?: boolean;
20
+ layout?: 'document' | 'playground';
21
+ status?: 'draft' | 'published';
22
+ search?: boolean;
23
+ ai?: boolean;
24
+ tags?: string[];
25
+ owner?: string;
26
+ hero?: {
27
+ accent?: string;
28
+ tagline?: string;
29
+ image?: string;
30
+ imageAlt?: string;
31
+ actions?: Array<{
32
+ text: string;
33
+ link: string;
34
+ primary?: boolean;
35
+ icon?: HomeIconName;
36
+ }>;
37
+ };
38
+ features?: Array<{
39
+ icon?: HomeIconName;
40
+ image?: string;
41
+ title: string;
42
+ details: string;
43
+ }>;
44
+ [key: string]: unknown;
45
+ }
46
+
47
+ interface PageLink {
48
+ title: string;
49
+ routePath: string;
50
+ }
51
+ interface SidebarLink {
52
+ type: 'link';
53
+ title: string;
54
+ routePath: string;
55
+ }
56
+ interface SidebarTreeGroup {
57
+ type: 'group';
58
+ /** Stable identity among sibling directories; display titles may be translated or duplicated. */
59
+ segment: string;
60
+ title: string;
61
+ collapsed: boolean;
62
+ items: SidebarItem[];
63
+ }
64
+ type SidebarItem = SidebarLink | SidebarTreeGroup;
65
+ interface SidebarGroup {
66
+ /** First directory segment under the locale; used to select a section sidebar. */
67
+ segment: string;
68
+ /** Section title used by automatic top navigation, not rendered inside the sidebar. */
69
+ title: string;
70
+ items: SidebarItem[];
71
+ }
72
+ interface NavItem {
73
+ title: string;
74
+ routePath: string;
75
+ }
76
+ interface DocPage {
77
+ sourcePath: string;
78
+ /** Complete source after extension transforms, including frontmatter and MDX imports. */
79
+ transformedSource: string;
80
+ /** Project-relative source path, including a version-specific docsDir. */
81
+ sourceRelativePath: string;
82
+ /** Path relative to this version's docs root. */
83
+ relativePath: string;
84
+ version: string;
85
+ versionBase: string;
86
+ docsDir: string;
87
+ locale: string;
88
+ routePath: string;
89
+ outputPath: string;
90
+ markdownOutputPath: string;
91
+ title: string;
92
+ description: string;
93
+ order: number;
94
+ /** First sub-directory segment under the locale, '' for root-level pages. */
95
+ group: string;
96
+ status: 'draft' | 'published';
97
+ search: boolean;
98
+ ai: boolean;
99
+ body: string;
100
+ headings: MarkdownHeading[];
101
+ searchText: string;
102
+ codeExamples: MarkdownCodeExample[];
103
+ lastUpdated: string;
104
+ previous?: PageLink;
105
+ next?: PageLink;
106
+ frontmatter: DocfuseFrontmatter;
107
+ }
108
+ interface ContentGraph {
109
+ pages: DocPage[];
110
+ /** Grouped sidebar entries per version and locale. */
111
+ sidebar: Record<string, Record<string, SidebarGroup[]>>;
112
+ /** Top navigation entries per version and locale. */
113
+ nav: Record<string, Record<string, NavItem[]>>;
114
+ locales: string[];
115
+ defaultLocale: string;
116
+ versions: Array<{
117
+ id: string;
118
+ label: string;
119
+ base: string;
120
+ docsDir: string;
121
+ }>;
122
+ currentVersion: string;
123
+ }
124
+
125
+ interface SearchProviderContext {
126
+ cwd: string;
127
+ config: DocfuseConfig;
128
+ graph: ContentGraph;
129
+ outputRoot: string;
130
+ publicPathFor(routePath: string): string;
131
+ resolveOutputPath(outputPath: string, label: string): string;
132
+ }
133
+ /**
134
+ * Whole-site index lifecycle. Unlike a Markdown plugin, a provider consumes the
135
+ * completed ContentGraph and output root; unlike an Extension, it owns only the
136
+ * configured search implementation's artifacts.
137
+ */
138
+ interface SearchProvider {
139
+ readonly id: string;
140
+ /** Browser-side query protocol consumed by Docfuse's built-in search modal. */
141
+ readonly client: 'compact' | 'pagefind';
142
+ readonly version?: string;
143
+ /** Resolved JSON options used for build invalidation. Bump `version` when implementation changes. */
144
+ readonly cacheKey?: DocfuseJsonValue;
145
+ write(context: SearchProviderContext): Promise<void>;
146
+ }
147
+
148
+ declare const THEME_BASE_COLORS: readonly ["paper", "neutral", "slate", "zinc", "stone"];
149
+ declare const DOCFUSE_MARKDOWN_ELEMENT_GROUP_IDS: readonly ["headings", "inline", "lists", "callouts", "code", "tables", "media", "diagrams", "disclosure", "extensions", "api", "metadata"];
150
+
151
+ type ThemeBaseColor = (typeof THEME_BASE_COLORS)[number];
152
+ type DocfuseMarkdownElementGroupId = (typeof DOCFUSE_MARKDOWN_ELEMENT_GROUP_IDS)[number];
153
+ interface DocfuseNavigationItem {
154
+ text: string;
155
+ link: string;
156
+ }
157
+ interface DocfuseVersionItem {
158
+ id: string;
159
+ label: string;
160
+ docsDir: string;
161
+ /** Absolute URL base. The current version normally uses `/`. */
162
+ base: string;
163
+ }
164
+ interface DocfuseAdvertisement {
165
+ image: string;
166
+ href: string;
167
+ alt: string;
168
+ label?: string;
169
+ }
170
+ interface DocfuseSearchConfig {
171
+ enabled: boolean;
172
+ provider: 'compact' | SearchProvider;
173
+ }
174
+ type DocfuseJsonValue = string | number | boolean | null | DocfuseJsonValue[] | {
175
+ [key: string]: DocfuseJsonValue;
176
+ };
177
+ interface DocfuseExtensionDescriptor {
178
+ /** Project-relative TypeScript or JavaScript module. Extensions execute as trusted build code. */
179
+ resolve: string;
180
+ /** JSON-serializable factory options; functions and environment-specific values are rejected. */
181
+ options?: {
182
+ [key: string]: DocfuseJsonValue;
183
+ };
184
+ }
185
+ interface DocfuseLayoutLabels {
186
+ skipToContent: string;
187
+ search: string;
188
+ searchEmpty: string;
189
+ searchUnavailable: string;
190
+ language: string;
191
+ primaryNavigation: string;
192
+ theme: string;
193
+ openSidebar: string;
194
+ onThisPage: string;
195
+ edit: string;
196
+ updated: string;
197
+ previous: string;
198
+ next: string;
199
+ close: string;
200
+ source: string;
201
+ preview: string;
202
+ copySource: string;
203
+ sourceCopied: string;
204
+ quickActions: string;
205
+ github: string;
206
+ docsNavigation: string;
207
+ pageNavigation: string;
208
+ advertisement: string;
209
+ version: string;
210
+ }
211
+ interface DocfuseQuickActionMessages {
212
+ headingsTitle: string;
213
+ headingsDescription: string;
214
+ codeTitle: string;
215
+ codeDescription: string;
216
+ tableTitle: string;
217
+ tableDescription: string;
218
+ diagramTitle: string;
219
+ diagramDescription: string;
220
+ sourceDescription: string;
221
+ themeDescription: string;
222
+ }
223
+ interface DocfuseMarkdownElementGroupMessages {
224
+ label?: string;
225
+ detail?: string;
226
+ hash?: string;
227
+ }
228
+ interface DocfuseNotFoundMessages {
229
+ title: string;
230
+ description: string;
231
+ home: string;
232
+ }
233
+ interface DocfuseLocaleMessages {
234
+ labels?: Partial<DocfuseLayoutLabels>;
235
+ brandTagline?: string;
236
+ quickActions?: Partial<DocfuseQuickActionMessages>;
237
+ markdownElementGroups?: Partial<Record<DocfuseMarkdownElementGroupId, DocfuseMarkdownElementGroupMessages>>;
238
+ markdown?: Partial<MarkdownLabels>;
239
+ notFound?: Partial<DocfuseNotFoundMessages>;
240
+ }
241
+ /** Public authoring contract for docfuse.config.ts. Runtime validation uses the matching strict schema. */
242
+ interface DocfuseConfigInput {
243
+ title?: string;
244
+ description?: string;
245
+ siteUrl?: string;
246
+ basePath?: string;
247
+ editUrl?: string;
248
+ github?: string;
249
+ requiredVersion?: string;
250
+ docsDir?: string;
251
+ outputDir?: string;
252
+ styles?: string[];
253
+ layout?: {
254
+ header?: boolean;
255
+ };
256
+ markdown?: {
257
+ html?: MarkdownHtmlPolicy;
258
+ code?: Pick<MarkdownCodeOptions, 'themes' | 'fallbackLanguage' | 'unknownLanguage'>;
259
+ features?: MarkdownFeatureOptions;
260
+ labels?: Partial<MarkdownLabels>;
261
+ /**
262
+ * Compiler plugins imported into docfuse.config.ts, e.g. from
263
+ * `@docfuse/plugins`. They execute as trusted build code; cache identity
264
+ * comes from each plugin's `name`, `version` and `cacheKey`.
265
+ */
266
+ plugins?: readonly MarkdownPlugin[];
267
+ };
268
+ theme?: {
269
+ logo?: string;
270
+ logoDark?: string;
271
+ favicon?: string;
272
+ accentColor?: string;
273
+ darkMode?: boolean;
274
+ radius?: number | string;
275
+ baseColor?: ThemeBaseColor;
276
+ sidebarWidth?: number | string;
277
+ outlineWidth?: number | string;
278
+ tokens?: MarkdownThemeInput;
279
+ };
280
+ search?: {
281
+ enabled?: boolean;
282
+ /** Use `compact` or a provider such as `pagefind()` from @docfuse/plugins. */
283
+ provider?: 'compact' | SearchProvider;
284
+ };
285
+ extensions?: DocfuseExtensionDescriptor[];
286
+ navigation?: Record<string, DocfuseNavigationItem[]>;
287
+ versions?: {
288
+ current: string;
289
+ items: DocfuseVersionItem[];
290
+ };
291
+ redirects?: Record<string, string>;
292
+ advertising?: DocfuseAdvertisement;
293
+ i18n?: {
294
+ defaultLocale?: string;
295
+ locales?: string[];
296
+ localeNames?: Record<string, string>;
297
+ messages?: Record<string, DocfuseLocaleMessages>;
298
+ };
299
+ ai?: {
300
+ llmsTxt?: boolean;
301
+ llmsFullTxt?: boolean;
302
+ markdownIndex?: boolean;
303
+ pageSummaries?: boolean;
304
+ codeExamples?: boolean;
305
+ /** Maximum encoded size of one ai/content JSONL shard. */
306
+ chunkSizeBytes?: number;
307
+ /** Maximum size of the legacy single-file llms-full.txt body. */
308
+ llmsFullMaxBytes?: number;
309
+ /** Write a manifest pointer or fail when llms-full.txt exceeds its budget. */
310
+ llmsFullOverflow?: 'manifest' | 'error';
311
+ /** Current avoids duplicate historical answers; all publishes every configured version. */
312
+ versions?: 'current' | 'all';
313
+ };
314
+ }
315
+ interface DocfuseConfig {
316
+ title: string;
317
+ description: string;
318
+ siteUrl?: string;
319
+ basePath: string;
320
+ editUrl?: string;
321
+ github?: string;
322
+ requiredVersion?: string;
323
+ docsDir: string;
324
+ outputDir: string;
325
+ styles: string[];
326
+ layout: {
327
+ header: boolean;
328
+ };
329
+ markdown: {
330
+ html: MarkdownHtmlPolicy;
331
+ code: MarkdownCodeOptions;
332
+ features: MarkdownFeatureOptions;
333
+ labels: Partial<MarkdownLabels>;
334
+ plugins: readonly MarkdownPlugin[];
335
+ };
336
+ theme: {
337
+ logo?: string;
338
+ logoDark?: string;
339
+ favicon?: string;
340
+ accentColor: string;
341
+ darkMode: boolean;
342
+ radius: number | string;
343
+ baseColor: ThemeBaseColor;
344
+ sidebarWidth: number | string;
345
+ outlineWidth: number | string;
346
+ tokens: MarkdownThemeInput;
347
+ };
348
+ search: DocfuseSearchConfig;
349
+ extensions: DocfuseExtensionDescriptor[];
350
+ navigation: Record<string, DocfuseNavigationItem[]>;
351
+ versions: {
352
+ current: string;
353
+ items: DocfuseVersionItem[];
354
+ };
355
+ redirects: Record<string, string>;
356
+ advertising?: DocfuseAdvertisement;
357
+ i18n: {
358
+ defaultLocale: string;
359
+ locales: string[];
360
+ localeNames?: Record<string, string>;
361
+ messages?: Record<string, DocfuseLocaleMessages>;
362
+ };
363
+ ai: {
364
+ llmsTxt: boolean;
365
+ llmsFullTxt: boolean;
366
+ markdownIndex: boolean;
367
+ pageSummaries: boolean;
368
+ codeExamples: boolean;
369
+ chunkSizeBytes: number;
370
+ llmsFullMaxBytes: number;
371
+ llmsFullOverflow: 'manifest' | 'error';
372
+ versions: 'current' | 'all';
373
+ };
374
+ }
375
+
376
+ /** Add contextual typing to docfuse.config.ts without changing its runtime value. */
377
+ declare function defineConfig(config: DocfuseConfigInput): DocfuseConfigInput;
378
+
379
+ declare function defineSearchProvider<T extends SearchProvider>(provider: T): T;
380
+
381
+ declare const DOCFUSE_EXTENSION_API_VERSION: 1;
382
+ interface DocfuseExtensionSourceContext {
383
+ source: string;
384
+ sourceRelativePath: string;
385
+ relativePath: string;
386
+ kind: 'markdown' | 'mdx';
387
+ version: string;
388
+ locale: string;
389
+ }
390
+ interface DocfuseExtensionPage {
391
+ sourceRelativePath: string;
392
+ relativePath: string;
393
+ version: string;
394
+ locale: string;
395
+ routePath: string;
396
+ title: string;
397
+ description: string;
398
+ status: 'draft' | 'published';
399
+ search: boolean;
400
+ ai: boolean;
401
+ body: string;
402
+ searchText: string;
403
+ frontmatter: DocfuseFrontmatter;
404
+ }
405
+ interface DocfuseExtensionPagePatch {
406
+ title?: string;
407
+ description?: string;
408
+ searchText?: string;
409
+ search?: boolean;
410
+ ai?: boolean;
411
+ }
412
+ interface DocfuseExtensionGenerateContext {
413
+ pages: readonly DocfuseExtensionPage[];
414
+ emitFile(path: string, content: string | Uint8Array): Promise<void>;
415
+ }
416
+ /**
417
+ * Versioned, semantic site-build contract. Compiler ASTs and internal render
418
+ * plugins intentionally stay private so upgrades do not depend on pipeline order.
419
+ * Per-document syntax belongs to MarkdownPlugin; whole-site search indexing
420
+ * belongs to SearchProvider.
421
+ */
422
+ interface DocfuseExtension {
423
+ apiVersion: typeof DOCFUSE_EXTENSION_API_VERSION;
424
+ name: string;
425
+ /** Every generated path must be declared up front and is scoped under extensions/{name}/. */
426
+ outputs?: string[];
427
+ transformSource?(context: Readonly<DocfuseExtensionSourceContext>): string | Promise<string>;
428
+ extendPage?(page: Readonly<DocfuseExtensionPage>): DocfuseExtensionPagePatch | void | Promise<DocfuseExtensionPagePatch | void>;
429
+ generate?(context: DocfuseExtensionGenerateContext): void | Promise<void>;
430
+ }
431
+ type DocfuseExtensionOptions = {
432
+ [key: string]: DocfuseJsonValue;
433
+ };
434
+ type DocfuseExtensionFactory = (options: Readonly<DocfuseExtensionOptions>) => DocfuseExtension | Promise<DocfuseExtension>;
435
+ declare function defineExtension(extension: DocfuseExtension): DocfuseExtension;
436
+ declare function defineExtension(factory: DocfuseExtensionFactory): DocfuseExtensionFactory;
437
+
438
+ export { DOCFUSE_EXTENSION_API_VERSION, type DocfuseConfigInput, type DocfuseExtension, type DocfuseExtensionDescriptor, type DocfuseExtensionFactory, type DocfuseExtensionGenerateContext, type DocfuseExtensionPage, type DocfuseExtensionPagePatch, type DocfuseExtensionSourceContext, type DocfuseJsonValue, type SearchProvider, type SearchProviderContext, defineConfig, defineExtension, defineSearchProvider, docfuseVersion };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{c as n,f,g as r}from"./chunk-GNYJERGG.js";import"./chunk-XYJ2OBL3.js";import{a as t}from"./chunk-GRQDPV4U.js";import"./chunk-JK7ZNBUA.js";import{a as e}from"./chunk-AYDF3IFZ.js";function i(o){return o}e(i,"defineConfig");export{f as DOCFUSE_EXTENSION_API_VERSION,i as defineConfig,r as defineExtension,n as defineSearchProvider,t as docfuseVersion};
2
+ //# sourceMappingURL=index.js.map