canofold 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-72JU66ZI.js +2 -0
- package/dist/{check-SPGDVG46.js → check-EJ4AQZQN.js} +2 -2
- package/dist/{chunk-EQOADO2H.js → chunk-BSFJWPWR.js} +2 -2
- package/dist/chunk-GLAK57S4.js +45 -0
- package/dist/chunk-JACOFQSH.js +2 -0
- package/dist/{chunk-OKX7SQKX.js → chunk-LGMGXZ4I.js} +22 -20
- package/dist/{chunk-KJ7FG6AY.js → chunk-LP3NAJM7.js} +4 -4
- package/dist/chunk-VMPJIE5E.js +2 -0
- package/dist/{clean-V2SP7IRD.js → clean-REXZDZX4.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/demo-engine.d.ts +4 -0
- package/dist/{deploy-47AUDPYE.js → deploy-VQKVGFX5.js} +2 -2
- package/dist/dev-4LCWVCHW.js +2 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/{init-3PS74OVB.js → init-TVOVOMAO.js} +3 -3
- package/dist/{load-BG2H2Q65.js → load-4UYHBETN.js} +2 -2
- package/dist/{preview-OAMF5HXH.js → preview-FB3HCXFC.js} +2 -2
- package/dist/search-client.js +1 -1
- package/dist/styles.input.css +2 -12
- package/package.json +10 -9
- package/dist/build-UYV2L7WT.js +0 -2
- package/dist/chunk-2XMX5JW6.js +0 -2
- package/dist/chunk-ACUMTEQL.js +0 -2
- package/dist/chunk-HS5LEPRC.js +0 -45
- package/dist/dev-3C4T3COS.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{a as Q,b as Z,d as tt,f as $}from"./chunk-ENPRUF6E.js";import{a as F,b as q,d as B,e as K,f as X,g as R,i as Y,j}from"./chunk-ACUMTEQL.js";import{a as H}from"./chunk-2XMX5JW6.js";import{a as U,b as _,c as N}from"./chunk-EAYVCA3Z.js";import{a as T,b,d as J,e as v,f as W,h as O}from"./chunk-JK7ZNBUA.js";import{a as c}from"./chunk-AYDF3IFZ.js";import{createHash as Ct}from"crypto";var et={name:"canofold-demo",version:"1",directiveNames:["demo"]};function x(t){return t.line===void 0?"":` at line ${t.line}${t.column===void 0?"":`, column ${t.column}`}`}c(x,"locationOf");function St(t,o){return Ct("sha256").update(JSON.stringify([t.version,t.sourceRelativePath,o.line??0,o.column??0,o.attributes.src??""])).digest("hex").slice(0,16)}c(St,"demoId");function kt(t,o,e){if(!t)throw new Error(`Demo directives require a \`src\` attribute in ${e.sourceRelativePath}${x(o)}`);if(/^[a-z][a-z\d+.-]*:/i.test(t)||t.startsWith("//"))throw new Error(`Demo \`src\` must reference a project module, got ${JSON.stringify(t)} in ${e.sourceRelativePath}${x(o)}`);if(t.includes("\0")||t.includes("?")||t.includes("#"))throw new Error(`Demo \`src\` must not contain a null byte, query, or fragment in ${e.sourceRelativePath}${x(o)}`);return t}c(kt,"validateSpecifier");function Dt(t,o,e){if(!t||t==="inline")return"inline";if(t==="iframe")return"iframe";throw new Error(`Demo \`sandbox\` must be \`inline\` or \`iframe\` in ${e.sourceRelativePath}${x(o)}`)}c(Dt,"validateSandbox");function ot(t,o){return o.filter(e=>e.name==="demo").map(e=>{if(e.type!=="leafDirective")throw new Error(`Demo directives must use leaf syntax in ${t.sourceRelativePath}${x(e)}`);let r=Object.keys(e.attributes).filter(n=>n!=="src"&&n!=="sandbox"&&n!=="description");if(r.length>0)throw new Error(`Demo directives do not support ${r.map(n=>`\`${n}\``).join(", ")} in ${t.sourceRelativePath}${x(e)}`);return{id:St(t,e),...e.label?{title:e.label}:{},...e.attributes.description?.trim()?{description:e.attributes.description.trim()}:{},specifier:kt(e.attributes.src?.trim()??"",e,t),sandbox:Dt(e.attributes.sandbox?.trim(),e,t),pageSourcePath:t.sourcePath,pageSourceRelativePath:t.sourceRelativePath,routePath:t.routePath,locale:t.locale,...e.line===void 0?{}:{line:e.line},...e.column===void 0?{}:{column:e.column},...e.offset===void 0?{}:{sourceOffset:e.offset},...e.endOffset===void 0?{}:{sourceEndOffset:e.endOffset}}})}c(ot,"demoReferencesForPage");import{analyzeMarkdown as Mt}from"@canofold/markdown/server/analyze";import Gt from"gray-matter";import{join as Lt,posix as Vt}from"path";import{z as m}from"zod";var rt=["ai","box","code","file","file-code","gauge","globe","layers","rocket","search","sparkles","terminal"],vt=m.object({text:m.string().min(1),link:j,primary:m.boolean().optional(),icon:m.enum(rt).optional()}).strict(),Ot=m.object({accent:m.string().optional(),tagline:m.string().optional(),image:j.optional(),imageAlt:m.string().optional(),actions:m.array(vt).refine(t=>t.filter(o=>o.primary).length<=1,{message:"Home page hero actions can contain at most one primary action"}).optional()}).strict(),Rt=m.object({icon:m.enum(rt).optional(),image:j.optional(),title:m.string().min(1),details:m.string().min(1)}).strict(),jt=m.string().trim().refine(t=>m.string().date().safeParse(t).success||m.string().datetime({offset:!0}).safeParse(t).success,"Expected an ISO 8601 date"),nt=m.preprocess(t=>t instanceof Date?t.toISOString():t,jt.transform(t=>new Date(t).toISOString())),it=m.object({title:m.string().optional(),seoTitle:m.string().trim().min(1).optional(),description:m.string().optional(),createdAt:nt.optional(),updatedAt:nt.optional(),order:m.number().finite().optional(),group:m.string().optional(),subgroup:m.string().optional(),collapsed:m.boolean().optional(),sidebar:m.boolean().optional(),layout:m.enum(["document","playground"]).optional(),status:m.enum(["draft","published"]).optional(),search:m.boolean().optional(),ai:m.boolean().optional(),tags:m.array(m.string()).optional(),owner:m.string().optional(),hero:Ot.optional(),features:m.array(Rt).optional()}).passthrough();function xe(t){return Object.fromEntries(["title","description","createdAt","updatedAt","order","group","subgroup","tags","owner"].flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}c(xe,"publicFrontmatterFor");import{readdir as It,readFile as Nt,stat as Tt}from"fs/promises";import{join as Ft,relative as at}from"path";async function st(t,o,e){if(!Number.isFinite(o)||o<1)throw new Error("Concurrency must be a positive finite number");let r=new Array(t.length),n=0,i,l=Math.min(Math.floor(o),t.length);if(await Promise.all(Array.from({length:l},async()=>{for(;n<t.length&&i===void 0;){let u=n++;try{r[u]=await e(t[u],u)}catch(f){i??=f}}})),i)throw i;return r}c(st,"mapConcurrent");var At=32;async function ct(t){async function o(n){let i=[],l=[n];for(;l.length>0;){let u=l.pop();if(!u)continue;let f=await It(u,{withFileTypes:!0});for(let s of f){let a=Ft(u,s.name);if(s.isSymbolicLink())throw new Error(`Documentation content must not use symbolic links: ${at(t,a)}`);s.isDirectory()?l.push(a):s.isFile()&&U(s.name)&&i.push(a)}}return i}c(o,"walk");let e=await o(t);return(await st(e,At,async n=>{let[i,l]=await Promise.all([Tt(n),Nt(n,"utf8")]);return{path:at(t,n),raw:l,mtimeMs:i.mtimeMs}})).sort((n,i)=>n.path.localeCompare(i.path))}c(ct,"scanMarkdownFiles");function ut(t){return t.split("-").filter(Boolean).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}c(ut,"humanize");function C(t){return N(F(t.relativePath,t.locale))}c(C,"isLocaleHome");function zt(t){return{type:"link",title:t.title||t.routePath,routePath:t.routePath}}c(zt,"sidebarLink");function ft(t){return F(t.relativePath,t.locale).split("/")}c(ft,"pageSegments");function lt(t){return ft(t).slice(0,-1)}c(lt,"pageDirectorySegments");function Ut(t){return N(ft(t).at(-1)??"")}c(Ut,"isDirectoryIndex");function _t(t){let o=new Map,e=new Map,r=new Map;for(let n of t)if(Ut(n)&&e.set(lt(n).join("/"),n),n.group&&typeof n.frontmatter.group=="string"){let i=r.get(n.group);if(i&&i!==n.frontmatter.group)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${i}" and "${n.frontmatter.group}"`);r.set(n.group,n.frontmatter.group)}for(let n of t){if(C(n)||n.frontmatter.sidebar===!1)continue;let i=lt(n),l=i[0]??"",u=e.get(l),f=l?typeof u?.frontmatter.group=="string"?u.frontmatter.group:u?.title||r.get(l)||ut(l):"";if(typeof n.frontmatter.group=="string"&&n.frontmatter.group!==f)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${f}" and "${n.frontmatter.group}"`);let s=o.get(l);if(!s)s={segment:l,title:f,items:[]},o.set(l,s);else if(s.title!==f)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${s.title}" and "${f}"`);let a=s.items;for(let p=1;p<i.length;p+=1){let d=i[p];if(!d)continue;let g=i.slice(0,p+1).join("/"),h=e.get(g),w=p===1&&typeof n.frontmatter.subgroup=="string"?n.frontmatter.subgroup:void 0,y=(p===1&&typeof h?.frontmatter.subgroup=="string"?h.frontmatter.subgroup:void 0)??h?.title??w??ut(d);if(w&&w!==y)throw new Error(`Inconsistent subgroup name for locale "${n.locale}" directory "${g}"`);let E=a.find(k=>k.type==="group"&&k.segment===d),P=E??{type:"group",segment:d,title:y,collapsed:h?.frontmatter.collapsed===!0,items:[]};E||a.push(P),a=P.items}a.push(zt(n))}return[...o.values()]}c(_t,"buildSidebar");function A(t){if(t.type==="link")return t;for(let o of t.items){let e=A(o);if(e)return e}}c(A,"firstSidebarLink");function Ht(t){return t.flatMap(o=>{let e=o.items[0]?A(o.items[0]):void 0;return o.title&&e?[{title:o.title,routePath:e.routePath}]:[]})}c(Ht,"buildAutomaticNav");function Jt(t,o){return!t.startsWith("/")||o.base==="/"?t:`${o.base}${t.replace(/^\//,"")}`}c(Jt,"versionedNavLink");function Wt(t,o){return t.map(e=>({title:e.text,routePath:Jt(e.link,o)}))}c(Wt,"buildConfiguredNav");function qt(t,o){return t.map(e=>{if(!e.routePath.startsWith("/"))return e;let r=e.routePath.split("/").filter(Boolean),n=o.find(l=>l.segment&&r.at(-1)===l.segment&&r.length>0),i=n?.items[0]?A(n.items[0]):void 0;return i?{...e,routePath:i.routePath}:e})}c(qt,"anchorConfiguredNavToSidebar");function Bt(t){let o=new Map;for(let e of t)for(let[r,n]of[["route",e.routePath],["output",e.outputPath],["markdown output",e.markdownOutputPath]]){let i=`${r}:${b(n)}`,l=o.get(i);if(l)throw new Error(`Duplicate ${r} target ${n} for ${l.sourceRelativePath} and ${e.sourceRelativePath}`);o.set(i,e)}}c(Bt,"assertUniquePageTargets");async function Kt(t,o,e,r){let n=J(t,e.docsDir,`versions.items[${e.id}].docsDir`),i=await ct(n),l=[];for(let u of i){let f=u.path.split(/[\\/]/);if(f[0]==="public")continue;let s=f[0]&&o.i18n.locales.includes(f[0])?f[0]:void 0,a=s??o.i18n.defaultLocale,p=s?f.slice(1):f;if(p.length===0)continue;let d=p.join("/"),g=Vt.join(e.docsDir.replace(/\\/g,"/"),u.path.replace(/\\/g,"/")),h=r?await r.transformSource({source:u.raw,sourceRelativePath:g,relativePath:u.path.replace(/\\/g,"/"),kind:_(u.path)?"mdx":"markdown",version:e.id,locale:a}):u.raw,w=Gt(h),y=it.parse(w.data),E=y.status??"published";if(E==="draft")continue;let P=Mt(w.content,{plugins:[...o.markdown.plugins,et]}),k=typeof y.order=="number"&&Number.isFinite(y.order)?y.order:Number.MAX_SAFE_INTEGER,$t=u.path.replace(/\\/g,"/"),D={sourcePath:Lt(n,u.path),transformedSource:h,sourceRelativePath:g,relativePath:$t,version:e.id,versionBase:e.base,docsDir:e.docsDir,locale:a,routePath:B(a,o.i18n.defaultLocale,d,e.base),outputPath:K(a,o.i18n.defaultLocale,d,e.base),markdownOutputPath:X(a,o.i18n.defaultLocale,d,e.base),title:typeof y.title=="string"?y.title:P.headings[0]?.text??"",description:typeof y.description=="string"?y.description:"",order:k,group:p.length>1?p[0]??"":"",status:E,search:y.search!==!1,ai:y.ai!==!1,body:w.content,headings:P.headings,searchText:P.text,codeExamples:P.codeExamples,demos:[],lastUpdated:y.updatedAt??new Date(u.mtimeMs).toISOString(),frontmatter:y};D.demos=ot(D,P.directives),l.push(r?await r.extendPage(D):D)}return l}c(Kt,"scanVersionPages");async function ze(t,o,e){let r=[];for(let s of o.versions.items)for(let a of await Kt(t,o,s,e))r.push(a);let n=new Map(o.versions.items.map((s,a)=>[s.id,a])),i=new Map(o.i18n.locales.map((s,a)=>[s,a]));r.sort((s,a)=>{let p=(n.get(s.version)??0)-(n.get(a.version)??0);if(p!==0)return p;let d=(i.get(s.locale)??0)-(i.get(a.locale)??0);if(d!==0)return d;let g=C(s),h=C(a);return g!==h?g?-1:1:s.order!==a.order?s.order-a.order:s.routePath.localeCompare(a.routePath)}),Bt(r);for(let s of o.versions.items)for(let a of o.i18n.locales)if(!r.some(p=>p.version===s.id&&p.locale===a&&C(p)))throw new Error(`Missing published home page for version "${s.id}" locale "${a}"`);for(let s of o.versions.items)for(let a of o.i18n.locales){let p=r.filter(d=>d.version===s.id&&d.locale===a&&!C(d));p.forEach((d,g)=>{let h=p[g-1],w=p[g+1];h&&(d.previous={title:h.title||h.routePath,routePath:h.routePath}),w&&(d.next={title:w.title||w.routePath,routePath:w.routePath})})}let l={},u={};for(let s of o.versions.items){let a={},p={};l[s.id]=a,u[s.id]=p;for(let d of o.i18n.locales){let g=_t(r.filter(h=>h.version===s.id&&h.locale===d));a[d]=g,p[d]=o.navigation[d]?qt(Wt(o.navigation[d],s),g):Ht(g)}}let f=new Set(r.map(s=>s.routePath));for(let s of Object.values(u))for(let a of Object.values(s))for(let p of a)if(p.routePath.startsWith("/")&&!f.has(p.routePath))throw new Error(`Navigation target is not a generated page: "${p.routePath}"`);return{pages:r,sidebar:l,nav:u,locales:o.i18n.locales,defaultLocale:o.i18n.defaultLocale,versions:o.versions.items.map(s=>({...s})),currentVersion:o.versions.current}}c(ze,"buildContentGraph");import{mkdir as Yt,writeFile as pt}from"fs/promises";import{dirname as Qt,join as Zt}from"path";var Xt={"&":"&","<":"<",">":">",'"':""","'":"'"};function M(t){return t.replace(/[&<>"']/g,o=>Xt[o]??o)}c(M,"escapeHtml");function G(t){let o=t==="/"?"/":`${t.replace(/\/+$/,"")}/`;return q(o)}c(G,"normalizeRedirectRoute");function L(t,o){let e=new Set(o.pages.map(i=>G(i.routePath))),r=Object.entries(t.redirects).map(([i,l])=>[G(i),G(l)]),n=new Set(r.map(([i])=>i));for(let[i,l]of r){if(i==="/")throw new Error("Redirect source must not replace the site root");if(e.has(i))throw new Error(`Redirect source collides with a generated page: "${i}"`);if(n.has(l))throw new Error(`Redirect chains are not allowed: "${i}" points to redirect "${l}"`);if(!e.has(l))throw new Error(`Redirect target is not a published generated page: "${l}"`)}if(n.size!==r.length)throw new Error("Redirect sources must be unique after route normalization");return r}c(L,"resolveRedirects");async function Qe(t,o,e){let r=L(o,e);if(r.length===0)return;let n=v(t,o.outputDir);for(let[i,l]of r){let u=O(n,R(i),"redirect route"),f=Z(o,l),s=M(f),a=M(Q(o,l)??f),p=JSON.stringify(f).replace(/</g,"\\u003c"),d=`<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><link rel="canonical" href="${a}"><meta http-equiv="refresh" content="0;url=${s}"><script>location.replace(${p})</script></head><body><a href="${s}">Redirecting to ${s}</a></body></html>`;await Yt(Qt(u),{recursive:!0}),await pt(u,d)}await pt(Zt(n,"redirects.json"),JSON.stringify(Object.fromEntries(r),null,2))}c(Qe,"writeRedirects");import{posix as dt}from"path";var te=new Set([".benchmark.json"]),ee=["assets/canofold-markdown","assets/canofold-demos","assets/canofold-playground","assets/canofold-plugins","assets/fonts","pagefind","ai/content","extensions"];function mt(t){let o=new Map;for(let e of t){let r=b(e),n=ee.find(l=>r===l||r.startsWith(`${l}/`));if(n)throw new Error(`Generated output uses reserved directory "${n}": "${e}"`);let i=o.get(r);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${e}"`);o.set(r,e)}for(let[e,r]of o){let n=dt.dirname(e);for(;n!==".";){let i=o.get(n);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${r}"`);n=dt.dirname(n)}}}c(mt,"assertGeneratedOutputPlan");function gt(t,o){let e=[".benchmark.json","404.html","assets/canofold.css",...Y,"robots.txt","ai/pages.json","ai/manifest.json",...o.pages.flatMap(n=>[n.outputPath,n.markdownOutputPath])];if(t.search.enabled&&(e.push("assets/canofold-search.js"),tt(t.search.provider)==="compact"))for(let n of o.versions)for(let i of o.locales)e.push(n.id===o.currentVersion?`search/${i}.json`:`search/${n.id}/${i}.json`);t.siteUrl&&e.push("sitemap.xml"),t.ai.pageSummaries&&e.push("ai/summaries.json"),t.ai.codeExamples&&e.push("ai/code-examples.json"),t.ai.markdownIndex&&e.push("ai/index.md"),t.ai.llmsTxt&&e.push("llms.txt"),t.ai.llmsFullTxt&&e.push("llms-full.txt");let r=L(t,o);if(r.length){e.push("redirects.json");for(let[n]of r)e.push(R(n))}return{paths:e,redirects:r}}c(gt,"plannedOutputPaths");function ao(t,o){let{paths:e}=gt(t,o);return mt(e),new Set(e)}c(ao,"generatedOutputPaths");function co(t,o){let{paths:e,redirects:r}=gt(t,o);return mt(e),new Set([...e.filter(n=>!te.has(n)).map(n=>`/${n.split("/").map(encodeURIComponent).join("/")}`),...r.map(([n])=>n)])}c(co,"generatedPublicPaths");import{randomUUID as ne}from"crypto";import{mkdir as yt,readFile as re,rm as ie,writeFile as Pt}from"fs/promises";import{dirname as se,join as bt,posix as xt,resolve as ae}from"path";import{pathToFileURL as ce}from"url";import{build as ue}from"esbuild";import{createHash as ht}from"crypto";function V(t,o){if(t===null||typeof t=="boolean"||typeof t=="string")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError("Fingerprint values must contain only finite numbers");return t}if(typeof t!="object")throw new TypeError("Fingerprint values must be JSON-serializable");if(o.has(t))throw new TypeError("Fingerprint values must not be circular");let e=Object.getPrototypeOf(t);if(!Array.isArray(t)&&e!==Object.prototype&&e!==null)throw new TypeError("Fingerprint values must be JSON-serializable plain objects");o.add(t);try{if(Array.isArray(t)){if(Object.keys(t).length!==t.length)throw new TypeError("Fingerprint values must not contain sparse arrays");return t.map(n=>V(n,o))}let r=Object.entries(t).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>[n,V(i,o)]);return Object.fromEntries(r)}finally{o.delete(t)}}c(V,"canonicalValue");function oe(t){return JSON.stringify(V(t,new WeakSet))}c(oe,"stableJson");function S(t){return ht("sha256").update(oe(t)).digest("hex")}c(S,"fingerprint");function z(t){return ht("sha256").update(t).digest("hex")}c(z,"fingerprintBytes");var le=new Set(["apiVersion","name","outputs","transformSource","extendPage","generate"]),fe=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"];function I(t){return t instanceof Error?t.message:String(t)}c(I,"errorMessage");function wt(t){return{sourceRelativePath:t.sourceRelativePath,relativePath:t.relativePath,version:t.version,locale:t.locale,routePath:t.routePath,title:t.title,description:t.description,status:t.status,search:t.search,ai:t.ai,body:t.body,searchText:t.searchText,frontmatter:structuredClone(t.frontmatter)}}c(wt,"extensionPage");function Et(t,o){if(!o||o.includes("\\")||o.startsWith("/")||o!==xt.normalize(o))throw new Error(`Extension "${t}" output must be a normalized relative POSIX path: "${o}"`);if(o.split("/").some(e=>e==="."||e===".."||!e))throw new Error(`Extension "${t}" output must not contain empty, . or .. segments: "${o}"`);return o}c(Et,"normalizeDeclaredOutput");function pe(t,o){if(!t||typeof t!="object")throw new Error(`Extension ${o.resolve} must export an extension object or factory`);let e=t,r=Object.keys(e).find(n=>!le.has(n));if(r)throw new Error(`Extension ${o.resolve} has unknown key "${r}"`);if(e.apiVersion!==1)throw new Error(`Extension ${o.resolve} uses unsupported apiVersion ${String(e.apiVersion)}; expected ${1}`);if(typeof e.name!="string"||!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(e.name))throw new Error(`Extension ${o.resolve} name must be a lowercase portable slug`);for(let n of["transformSource","extendPage","generate"])if(e[n]!==void 0&&typeof e[n]!="function")throw new Error(`Extension "${e.name}" hook ${n} must be a function`);if(e.outputs!==void 0&&!Array.isArray(e.outputs))throw new Error(`Extension "${e.name}" outputs must be an array`);if(e.generate&&!e.outputs?.length)throw new Error(`Extension "${e.name}" with generate() must declare outputs`);if(!e.generate&&e.outputs?.length)throw new Error(`Extension "${e.name}" declares outputs without generate()`);return e}c(pe,"assertDefinition");function de(t,o){if(o===void 0)return{};if(!o||typeof o!="object"||Array.isArray(o))throw new Error(`Extension "${t}" extendPage() must return an object or undefined`);let e=new Set(["title","description","searchText","search","ai"]),r=Object.keys(o).find(i=>!e.has(i));if(r)throw new Error(`Extension "${t}" extendPage() returned unknown key "${r}"`);let n=o;for(let i of["title","description","searchText"])if(n[i]!==void 0&&typeof n[i]!="string")throw new Error(`Extension "${t}" extendPage() field ${i} must be a string`);for(let i of["search","ai"])if(n[i]!==void 0&&typeof n[i]!="boolean")throw new Error(`Extension "${t}" extendPage() field ${i} must be a boolean`);return o}c(de,"assertPagePatch");async function me(t){let o=[];for(let e of fe){let r=bt(t,e);await T(r)&&o.push({path:e,fingerprint:z(await re(r))})}return S(o)}c(me,"lockfileFingerprint");async function ge(t,o,e){let r=ae(t,e.resolve);if(await W(t,r,`extension ${e.resolve}`),!await T(r))throw new Error(`Extension module not found: ${e.resolve}`);let i=(await ue({entryPoints:[r],bundle:!0,format:"esm",platform:"node",target:"node22",write:!1,sourcemap:"inline",plugins:[{name:"canofold-extension-api",setup(u){u.onResolve({filter:/^canofold$/},()=>({path:"canofold-extension-api",namespace:"canofold-extension-api"})),u.onLoad({filter:/.*/,namespace:"canofold-extension-api"},()=>({loader:"js",contents:`
|
|
1
|
+
import{a as Q,b as Z,d as tt,f as $}from"./chunk-ENPRUF6E.js";import{a as F,b as q,d as B,e as K,f as X,g as R,i as Y,j}from"./chunk-VMPJIE5E.js";import{a as _}from"./chunk-JACOFQSH.js";import{a as H,b as U,c as N}from"./chunk-EAYVCA3Z.js";import{a as T,b,d as J,e as v,f as W,h as O}from"./chunk-JK7ZNBUA.js";import{a as c}from"./chunk-AYDF3IFZ.js";import{createHash as St}from"crypto";var et={name:"canofold-demo",version:"1",directiveNames:["demo"]};function x(t){return t.line===void 0?"":` at line ${t.line}${t.column===void 0?"":`, column ${t.column}`}`}c(x,"locationOf");function Ct(t,o){return St("sha256").update(JSON.stringify([t.version,t.sourceRelativePath,o.line??0,o.column??0,o.attributes.src??""])).digest("hex").slice(0,16)}c(Ct,"demoId");function kt(t,o,e){if(!t)throw new Error(`Demo directives require a \`src\` attribute in ${e.sourceRelativePath}${x(o)}`);if(/^[a-z][a-z\d+.-]*:/i.test(t)||t.startsWith("//"))throw new Error(`Demo \`src\` must reference a project module, got ${JSON.stringify(t)} in ${e.sourceRelativePath}${x(o)}`);if(t.includes("\0")||t.includes("?")||t.includes("#"))throw new Error(`Demo \`src\` must not contain a null byte, query, or fragment in ${e.sourceRelativePath}${x(o)}`);return t}c(kt,"validateSpecifier");function Dt(t,o,e){if(!t||t==="inline")return"inline";if(t==="iframe")return"iframe";throw new Error(`Demo \`sandbox\` must be \`inline\` or \`iframe\` in ${e.sourceRelativePath}${x(o)}`)}c(Dt,"validateSandbox");function ot(t,o){return o.filter(e=>e.name==="demo").map(e=>{if(e.type!=="leafDirective")throw new Error(`Demo directives must use leaf syntax in ${t.sourceRelativePath}${x(e)}`);let r=Object.keys(e.attributes).filter(n=>n!=="src"&&n!=="sandbox"&&n!=="description");if(r.length>0)throw new Error(`Demo directives do not support ${r.map(n=>`\`${n}\``).join(", ")} in ${t.sourceRelativePath}${x(e)}`);return{id:Ct(t,e),...e.label?{title:e.label}:{},...e.attributes.description?.trim()?{description:e.attributes.description.trim()}:{},specifier:kt(e.attributes.src?.trim()??"",e,t),sandbox:Dt(e.attributes.sandbox?.trim(),e,t),pageSourcePath:t.sourcePath,pageSourceRelativePath:t.sourceRelativePath,routePath:t.routePath,locale:t.locale,...e.line===void 0?{}:{line:e.line},...e.column===void 0?{}:{column:e.column},...e.offset===void 0?{}:{sourceOffset:e.offset},...e.endOffset===void 0?{}:{sourceEndOffset:e.endOffset}}})}c(ot,"demoReferencesForPage");import{analyzeMarkdown as Mt}from"@canofold/markdown/server/analyze";import Gt from"gray-matter";import{join as Lt,posix as Vt}from"path";import{z as m}from"zod";var rt=["ai","box","code","file","file-code","gauge","globe","layers","rocket","search","sparkles","terminal"],vt=m.object({text:m.string().min(1),link:j,primary:m.boolean().optional(),icon:m.enum(rt).optional()}).strict(),Ot=m.object({accent:m.string().optional(),tagline:m.string().optional(),image:j.optional(),imageAlt:m.string().optional(),actions:m.array(vt).refine(t=>t.filter(o=>o.primary).length<=1,{message:"Home page hero actions can contain at most one primary action"}).optional()}).strict(),Rt=m.object({icon:m.enum(rt).optional(),image:j.optional(),title:m.string().min(1),details:m.string().min(1)}).strict(),jt=m.string().trim().refine(t=>m.string().date().safeParse(t).success||m.string().datetime({offset:!0}).safeParse(t).success,"Expected an ISO 8601 date"),nt=m.preprocess(t=>t instanceof Date?t.toISOString():t,jt.transform(t=>new Date(t).toISOString())),it=m.object({title:m.string().optional(),seoTitle:m.string().trim().min(1).optional(),description:m.string().optional(),createdAt:nt.optional(),updatedAt:nt.optional(),order:m.number().finite().optional(),group:m.string().optional(),subgroup:m.string().optional(),collapsed:m.boolean().optional(),sidebar:m.boolean().optional(),layout:m.enum(["document","playground"]).optional(),status:m.enum(["draft","published"]).optional(),search:m.boolean().optional(),ai:m.boolean().optional(),tags:m.array(m.string()).optional(),owner:m.string().optional(),hero:Ot.optional(),features:m.array(Rt).optional()}).passthrough();function xe(t){return Object.fromEntries(["title","description","createdAt","updatedAt","order","group","subgroup","tags","owner"].flatMap(e=>t[e]===void 0?[]:[[e,t[e]]]))}c(xe,"publicFrontmatterFor");import{readdir as It,readFile as Nt,stat as Tt}from"fs/promises";import{join as Ft,relative as at}from"path";async function st(t,o,e){if(!Number.isFinite(o)||o<1)throw new Error("Concurrency must be a positive finite number");let r=new Array(t.length),n=0,i,l=Math.min(Math.floor(o),t.length);if(await Promise.all(Array.from({length:l},async()=>{for(;n<t.length&&i===void 0;){let u=n++;try{r[u]=await e(t[u],u)}catch(f){i??=f}}})),i)throw i;return r}c(st,"mapConcurrent");var At=32;async function ct(t){async function o(n){let i=[],l=[n];for(;l.length>0;){let u=l.pop();if(!u)continue;let f=await It(u,{withFileTypes:!0});for(let s of f){let a=Ft(u,s.name);if(s.isSymbolicLink())throw new Error(`Documentation content must not use symbolic links: ${at(t,a)}`);s.isDirectory()?l.push(a):s.isFile()&&H(s.name)&&i.push(a)}}return i}c(o,"walk");let e=await o(t);return(await st(e,At,async n=>{let[i,l]=await Promise.all([Tt(n),Nt(n,"utf8")]);return{path:at(t,n),raw:l,mtimeMs:i.mtimeMs}})).sort((n,i)=>n.path.localeCompare(i.path))}c(ct,"scanMarkdownFiles");function ut(t){return t.split("-").filter(Boolean).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(" ")}c(ut,"humanize");function S(t){return N(F(t.relativePath,t.locale))}c(S,"isLocaleHome");function zt(t){return{type:"link",title:t.title||t.routePath,routePath:t.routePath}}c(zt,"sidebarLink");function ft(t){return F(t.relativePath,t.locale).split("/")}c(ft,"pageSegments");function lt(t){return ft(t).slice(0,-1)}c(lt,"pageDirectorySegments");function Ht(t){return N(ft(t).at(-1)??"")}c(Ht,"isDirectoryIndex");function Ut(t){let o=new Map,e=new Map,r=new Map;for(let n of t)if(Ht(n)&&e.set(lt(n).join("/"),n),n.group&&typeof n.frontmatter.group=="string"){let i=r.get(n.group);if(i&&i!==n.frontmatter.group)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${i}" and "${n.frontmatter.group}"`);r.set(n.group,n.frontmatter.group)}for(let n of t){if(S(n)||n.frontmatter.sidebar===!1)continue;let i=lt(n),l=i[0]??"",u=e.get(l),f=l?typeof u?.frontmatter.group=="string"?u.frontmatter.group:u?.title||r.get(l)||ut(l):"";if(typeof n.frontmatter.group=="string"&&n.frontmatter.group!==f)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${f}" and "${n.frontmatter.group}"`);let s=o.get(l);if(!s)s={segment:l,title:f,items:[]},o.set(l,s);else if(s.title!==f)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${s.title}" and "${f}"`);let a=s.items;for(let p=1;p<i.length;p+=1){let d=i[p];if(!d)continue;let h=i.slice(0,p+1).join("/"),g=e.get(h),w=p===1&&typeof n.frontmatter.subgroup=="string"?n.frontmatter.subgroup:void 0,y=(p===1&&typeof g?.frontmatter.subgroup=="string"?g.frontmatter.subgroup:void 0)??g?.title??w??ut(d);if(w&&w!==y)throw new Error(`Inconsistent subgroup name for locale "${n.locale}" directory "${h}"`);let E=a.find(k=>k.type==="group"&&k.segment===d),P=E??{type:"group",segment:d,title:y,collapsed:g?.frontmatter.collapsed===!0,items:[]};E||a.push(P),a=P.items}a.push(zt(n))}return[...o.values()]}c(Ut,"buildSidebar");function A(t){if(t.type==="link")return t;for(let o of t.items){let e=A(o);if(e)return e}}c(A,"firstSidebarLink");function _t(t){return t.flatMap(o=>{let e=o.items[0]?A(o.items[0]):void 0;return o.title&&e?[{title:o.title,routePath:e.routePath}]:[]})}c(_t,"buildAutomaticNav");function Jt(t,o){return!t.startsWith("/")||o.base==="/"?t:`${o.base}${t.replace(/^\//,"")}`}c(Jt,"versionedNavLink");function Wt(t,o){return t.map(e=>({title:e.text,routePath:Jt(e.link,o)}))}c(Wt,"buildConfiguredNav");function qt(t,o){return t.map(e=>{if(!e.routePath.startsWith("/"))return e;let r=e.routePath.split("/").filter(Boolean),n=o.find(l=>l.segment&&r.at(-1)===l.segment&&r.length>0),i=n?.items[0]?A(n.items[0]):void 0;return i?{...e,routePath:i.routePath}:e})}c(qt,"anchorConfiguredNavToSidebar");function Bt(t){let o=new Map;for(let e of t)for(let[r,n]of[["route",e.routePath],["output",e.outputPath],["markdown output",e.markdownOutputPath]]){let i=`${r}:${b(n)}`,l=o.get(i);if(l)throw new Error(`Duplicate ${r} target ${n} for ${l.sourceRelativePath} and ${e.sourceRelativePath}`);o.set(i,e)}}c(Bt,"assertUniquePageTargets");async function Kt(t,o,e,r){let n=J(t,e.docsDir,`versions.items[${e.id}].docsDir`),i=await ct(n),l=[];for(let u of i){let f=u.path.split(/[\\/]/);if(f[0]==="public")continue;let s=f[0]&&o.i18n.locales.includes(f[0])?f[0]:void 0,a=s??o.i18n.defaultLocale,p=s?f.slice(1):f;if(p.length===0)continue;let d=p.join("/"),h=Vt.join(e.docsDir.replace(/\\/g,"/"),u.path.replace(/\\/g,"/")),g=r?await r.transformSource({source:u.raw,sourceRelativePath:h,relativePath:u.path.replace(/\\/g,"/"),kind:U(u.path)?"mdx":"markdown",version:e.id,locale:a}):u.raw,w=Gt(g),y=it.parse(w.data),E=y.status??"published";if(E==="draft")continue;let P=Mt(w.content,{plugins:[...o.markdown.plugins,et]}),k=typeof y.order=="number"&&Number.isFinite(y.order)?y.order:Number.MAX_SAFE_INTEGER,$t=u.path.replace(/\\/g,"/"),D={sourcePath:Lt(n,u.path),transformedSource:g,sourceRelativePath:h,relativePath:$t,version:e.id,versionBase:e.base,docsDir:e.docsDir,locale:a,routePath:B(a,o.i18n.defaultLocale,d,e.base),outputPath:K(a,o.i18n.defaultLocale,d,e.base),markdownOutputPath:X(a,o.i18n.defaultLocale,d,e.base),title:typeof y.title=="string"?y.title:P.headings[0]?.text??"",description:typeof y.description=="string"?y.description:"",order:k,group:p.length>1?p[0]??"":"",status:E,search:y.search!==!1,ai:y.ai!==!1,body:w.content,headings:P.headings,searchText:P.text,codeExamples:P.codeExamples,demos:[],lastUpdated:y.updatedAt??new Date(u.mtimeMs).toISOString(),frontmatter:y};D.demos=ot(D,P.directives),l.push(r?await r.extendPage(D):D)}return l}c(Kt,"scanVersionPages");async function ze(t,o,e){let r=[];for(let s of o.versions.items)for(let a of await Kt(t,o,s,e))r.push(a);let n=new Map(o.versions.items.map((s,a)=>[s.id,a])),i=new Map(o.i18n.locales.map((s,a)=>[s,a]));r.sort((s,a)=>{let p=(n.get(s.version)??0)-(n.get(a.version)??0);if(p!==0)return p;let d=(i.get(s.locale)??0)-(i.get(a.locale)??0);if(d!==0)return d;let h=S(s),g=S(a);return h!==g?h?-1:1:s.order!==a.order?s.order-a.order:s.routePath.localeCompare(a.routePath)}),Bt(r);for(let s of o.versions.items)for(let a of o.i18n.locales)if(!r.some(p=>p.version===s.id&&p.locale===a&&S(p)))throw new Error(`Missing published home page for version "${s.id}" locale "${a}"`);for(let s of o.versions.items)for(let a of o.i18n.locales){let p=r.filter(d=>d.version===s.id&&d.locale===a&&!S(d));p.forEach((d,h)=>{let g=p[h-1],w=p[h+1];g&&(d.previous={title:g.title||g.routePath,routePath:g.routePath}),w&&(d.next={title:w.title||w.routePath,routePath:w.routePath})})}let l={},u={};for(let s of o.versions.items){let a={},p={};l[s.id]=a,u[s.id]=p;for(let d of o.i18n.locales){let h=Ut(r.filter(g=>g.version===s.id&&g.locale===d));a[d]=h,p[d]=o.navigation[d]?qt(Wt(o.navigation[d],s),h):_t(h)}}let f=new Set(r.map(s=>s.routePath));for(let s of Object.values(u))for(let a of Object.values(s))for(let p of a)if(p.routePath.startsWith("/")&&!f.has(p.routePath))throw new Error(`Navigation target is not a generated page: "${p.routePath}"`);return{pages:r,sidebar:l,nav:u,locales:o.i18n.locales,defaultLocale:o.i18n.defaultLocale,versions:o.versions.items.map(s=>({...s})),currentVersion:o.versions.current}}c(ze,"buildContentGraph");import{mkdir as Yt,writeFile as pt}from"fs/promises";import{dirname as Qt,join as Zt}from"path";var Xt={"&":"&","<":"<",">":">",'"':""","'":"'"};function M(t){return t.replace(/[&<>"']/g,o=>Xt[o]??o)}c(M,"escapeHtml");function G(t){let o=t==="/"?"/":`${t.replace(/\/+$/,"")}/`;return q(o)}c(G,"normalizeRedirectRoute");function L(t,o){let e=new Set(o.pages.map(i=>G(i.routePath))),r=Object.entries(t.redirects).map(([i,l])=>[G(i),G(l)]),n=new Set(r.map(([i])=>i));for(let[i,l]of r){if(i==="/")throw new Error("Redirect source must not replace the site root");if(e.has(i))throw new Error(`Redirect source collides with a generated page: "${i}"`);if(n.has(l))throw new Error(`Redirect chains are not allowed: "${i}" points to redirect "${l}"`);if(!e.has(l))throw new Error(`Redirect target is not a published generated page: "${l}"`)}if(n.size!==r.length)throw new Error("Redirect sources must be unique after route normalization");return r}c(L,"resolveRedirects");async function Qe(t,o,e){let r=L(o,e);if(r.length===0)return;let n=v(t,o.outputDir);for(let[i,l]of r){let u=O(n,R(i),"redirect route"),f=Z(o,l),s=M(f),a=M(Q(o,l)??f),p=JSON.stringify(f).replace(/</g,"\\u003c"),d=`<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><link rel="canonical" href="${a}"><meta http-equiv="refresh" content="0;url=${s}"><script>location.replace(${p})</script></head><body><a href="${s}">Redirecting to ${s}</a></body></html>`;await Yt(Qt(u),{recursive:!0}),await pt(u,d)}await pt(Zt(n,"redirects.json"),JSON.stringify(Object.fromEntries(r),null,2))}c(Qe,"writeRedirects");import{posix as dt}from"path";var te=new Set([".benchmark.json"]),ee=["assets/canofold-markdown","assets/canofold-demos","assets/canofold-playground","assets/canofold-plugins","assets/fonts","pagefind","ai/content","extensions"];function mt(t){let o=new Map;for(let e of t){let r=b(e),n=ee.find(l=>r===l||r.startsWith(`${l}/`));if(n)throw new Error(`Generated output uses reserved directory "${n}": "${e}"`);let i=o.get(r);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${e}"`);o.set(r,e)}for(let[e,r]of o){let n=dt.dirname(e);for(;n!==".";){let i=o.get(n);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${r}"`);n=dt.dirname(n)}}}c(mt,"assertGeneratedOutputPlan");function ht(t,o){let e=[".benchmark.json","404.html","assets/canofold.css",...Y,"robots.txt","ai/pages.json","ai/manifest.json",...o.pages.flatMap(n=>[n.outputPath,n.markdownOutputPath])];if(t.search.enabled&&(e.push("assets/canofold-search.js"),tt(t.search.provider)==="compact"))for(let n of o.versions)for(let i of o.locales)e.push(n.id===o.currentVersion?`search/${i}.json`:`search/${n.id}/${i}.json`);t.siteUrl&&e.push("sitemap.xml"),t.ai.pageSummaries&&e.push("ai/summaries.json"),t.ai.codeExamples&&e.push("ai/code-examples.json"),t.ai.markdownIndex&&e.push("ai/index.md"),t.ai.llmsTxt&&e.push("llms.txt"),t.ai.llmsFullTxt&&e.push("llms-full.txt");let r=L(t,o);if(r.length){e.push("redirects.json");for(let[n]of r)e.push(R(n))}return{paths:e,redirects:r}}c(ht,"plannedOutputPaths");function ao(t,o){let{paths:e}=ht(t,o);return mt(e),new Set(e)}c(ao,"generatedOutputPaths");function co(t,o){let{paths:e,redirects:r}=ht(t,o);return mt(e),new Set([...e.filter(n=>!te.has(n)).map(n=>`/${n.split("/").map(encodeURIComponent).join("/")}`),...r.map(([n])=>n)])}c(co,"generatedPublicPaths");import{randomUUID as ne}from"crypto";import{mkdir as yt,readFile as re,rm as ie,writeFile as Pt}from"fs/promises";import{dirname as se,join as bt,posix as xt,resolve as ae}from"path";import{pathToFileURL as ce}from"url";import{build as ue}from"esbuild";import{createHash as gt}from"crypto";function V(t,o){if(t===null||typeof t=="boolean"||typeof t=="string")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError("Fingerprint values must contain only finite numbers");return t}if(typeof t!="object")throw new TypeError("Fingerprint values must be JSON-serializable");if(o.has(t))throw new TypeError("Fingerprint values must not be circular");let e=Object.getPrototypeOf(t);if(!Array.isArray(t)&&e!==Object.prototype&&e!==null)throw new TypeError("Fingerprint values must be JSON-serializable plain objects");o.add(t);try{if(Array.isArray(t)){if(Object.keys(t).length!==t.length)throw new TypeError("Fingerprint values must not contain sparse arrays");return t.map(n=>V(n,o))}let r=Object.entries(t).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>[n,V(i,o)]);return Object.fromEntries(r)}finally{o.delete(t)}}c(V,"canonicalValue");function oe(t){return JSON.stringify(V(t,new WeakSet))}c(oe,"stableJson");function C(t){return gt("sha256").update(oe(t)).digest("hex")}c(C,"fingerprint");function z(t){return gt("sha256").update(t).digest("hex")}c(z,"fingerprintBytes");var le=new Set(["apiVersion","name","outputs","transformSource","extendPage","generate"]),fe=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"];function I(t){return t instanceof Error?t.message:String(t)}c(I,"errorMessage");function wt(t){return{sourceRelativePath:t.sourceRelativePath,relativePath:t.relativePath,version:t.version,locale:t.locale,routePath:t.routePath,title:t.title,description:t.description,status:t.status,search:t.search,ai:t.ai,body:t.body,searchText:t.searchText,frontmatter:structuredClone(t.frontmatter)}}c(wt,"extensionPage");function Et(t,o){if(!o||o.includes("\\")||o.startsWith("/")||o!==xt.normalize(o))throw new Error(`Extension "${t}" output must be a normalized relative POSIX path: "${o}"`);if(o.split("/").some(e=>e==="."||e===".."||!e))throw new Error(`Extension "${t}" output must not contain empty, . or .. segments: "${o}"`);return o}c(Et,"normalizeDeclaredOutput");function pe(t,o){if(!t||typeof t!="object")throw new Error(`Extension ${o.resolve} must export an extension object or factory`);let e=t,r=Object.keys(e).find(n=>!le.has(n));if(r)throw new Error(`Extension ${o.resolve} has unknown key "${r}"`);if(e.apiVersion!==1)throw new Error(`Extension ${o.resolve} uses unsupported apiVersion ${String(e.apiVersion)}; expected ${1}`);if(typeof e.name!="string"||!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(e.name))throw new Error(`Extension ${o.resolve} name must be a lowercase portable slug`);for(let n of["transformSource","extendPage","generate"])if(e[n]!==void 0&&typeof e[n]!="function")throw new Error(`Extension "${e.name}" hook ${n} must be a function`);if(e.outputs!==void 0&&!Array.isArray(e.outputs))throw new Error(`Extension "${e.name}" outputs must be an array`);if(e.generate&&!e.outputs?.length)throw new Error(`Extension "${e.name}" with generate() must declare outputs`);if(!e.generate&&e.outputs?.length)throw new Error(`Extension "${e.name}" declares outputs without generate()`);return e}c(pe,"assertDefinition");function de(t,o){if(o===void 0)return{};if(!o||typeof o!="object"||Array.isArray(o))throw new Error(`Extension "${t}" extendPage() must return an object or undefined`);let e=new Set(["title","description","searchText","search","ai"]),r=Object.keys(o).find(i=>!e.has(i));if(r)throw new Error(`Extension "${t}" extendPage() returned unknown key "${r}"`);let n=o;for(let i of["title","description","searchText"])if(n[i]!==void 0&&typeof n[i]!="string")throw new Error(`Extension "${t}" extendPage() field ${i} must be a string`);for(let i of["search","ai"])if(n[i]!==void 0&&typeof n[i]!="boolean")throw new Error(`Extension "${t}" extendPage() field ${i} must be a boolean`);return o}c(de,"assertPagePatch");async function me(t){let o=[];for(let e of fe){let r=bt(t,e);await T(r)&&o.push({path:e,fingerprint:z(await re(r))})}return C(o)}c(me,"lockfileFingerprint");async function he(t,o,e){let r=ae(t,e.resolve);if(await W(t,r,`extension ${e.resolve}`),!await T(r))throw new Error(`Extension module not found: ${e.resolve}`);let i=(await ue({entryPoints:[r],bundle:!0,format:"esm",platform:"node",target:"node22",write:!1,sourcemap:"inline",plugins:[{name:"canofold-extension-api",setup(u){u.onResolve({filter:/^canofold$/},()=>({path:"canofold-extension-api",namespace:"canofold-extension-api"})),u.onLoad({filter:/.*/,namespace:"canofold-extension-api"},()=>({loader:"js",contents:`
|
|
2
2
|
export const CANOFOLD_EXTENSION_API_VERSION = ${JSON.stringify(1)}
|
|
3
|
-
export const canofoldVersion = ${JSON.stringify(
|
|
3
|
+
export const canofoldVersion = ${JSON.stringify(_)}
|
|
4
4
|
export const defineExtension = (factory) => factory
|
|
5
|
-
`}))}}]})).outputFiles[0];if(!i)throw new Error(`Failed to bundle extension ${e.resolve}`);await yt(o,{recursive:!0});let l=bt(o,`extension-${ne()}.mjs`);await Pt(l,i.contents);try{let f=(await import(`${ce(l).href}?t=${Date.now()}`)).default,s=typeof f=="function"?await f(structuredClone(e.options??{})):f,a=pe(s,e),p=(a.outputs??[]).map(d=>Et(a.name,d));if(new Set(p.map(b)).size!==p.length)throw new Error(`Extension "${a.name}" declares duplicate portable output paths`);return{definition:a,declaredOutputs:new Set(p),fingerprint:
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
`}))}}]})).outputFiles[0];if(!i)throw new Error(`Failed to bundle extension ${e.resolve}`);await yt(o,{recursive:!0});let l=bt(o,`extension-${ne()}.mjs`);await Pt(l,i.contents);try{let f=(await import(`${ce(l).href}?t=${Date.now()}`)).default,s=typeof f=="function"?await f(structuredClone(e.options??{})):f,a=pe(s,e),p=(a.outputs??[]).map(d=>Et(a.name,d));if(new Set(p.map(b)).size!==p.length)throw new Error(`Extension "${a.name}" declares duplicate portable output paths`);return{definition:a,declaredOutputs:new Set(p),fingerprint:C({descriptor:e,bundle:z(i.contents)})}}finally{await ie(l,{force:!0})}}c(he,"loadOneExtension");async function So(t,o,e){let r=[];for(let u of e)try{r.push(await he(t,o,u))}catch(f){throw new Error(`Failed to load extension ${u.resolve}: ${I(f)}`,{cause:f})}let n=new Set;for(let u of r){if(n.has(u.definition.name))throw new Error(`Duplicate extension name "${u.definition.name}"`);n.add(u.definition.name)}let i=r.length?await me(t):C({lockfiles:[]}),l=r.flatMap(({definition:u,declaredOutputs:f})=>[...f].map(s=>`/extensions/${u.name}/${s.split("/").map(encodeURIComponent).join("/")}`));return{fingerprint:C({apiVersion:1,dependencyFingerprint:i,extensions:r.map(u=>({name:u.definition.name,fingerprint:u.fingerprint}))}),publicOutputPaths:l,async transformSource(u){let f=u.source;for(let{definition:s}of r)if(s.transformSource)try{let a=await s.transformSource({...u,source:f});if(typeof a!="string")throw new Error("transformSource() must return a string");f=a}catch(a){throw new Error(`Extension "${s.name}" transformSource failed for ${u.sourceRelativePath}: ${I(a)}`,{cause:a})}return f},async extendPage(u){let f=u;for(let{definition:s}of r)if(s.extendPage)try{let a=de(s.name,await s.extendPage(wt(f)));f={...f,...a}}catch(a){throw new Error(`Extension "${s.name}" extendPage failed for ${f.sourceRelativePath}: ${I(a)}`,{cause:a})}return f},async generate(u,f){for(let{definition:s,declaredOutputs:a}of r){if(!s.generate)continue;let p=new Set;try{await s.generate({pages:f.map(wt),emitFile:c(async(h,g)=>{let w=Et(s.name,h);if(!a.has(w))throw new Error(`generate() emitted undeclared output "${w}"`);if(p.has(w))throw new Error(`generate() emitted "${w}" more than once`);p.add(w);let y=O(u,xt.join("extensions",s.name,w),`extension ${s.name} output`);await yt(se(y),{recursive:!0}),await Pt(y,g)},"emitFile")});let d=[...a].filter(h=>!p.has(h));if(d.length)throw new Error(`generate() did not emit declared outputs: ${d.join(", ")}`)}catch(d){throw new Error(`Extension "${s.name}" generate failed: ${I(d)}`,{cause:d})}}}}}c(So,"loadExtensionHost");async function vo({cwd:t,config:o,graph:e,mode:r,server:n}){let i=e.pages.flatMap(u=>u.demos);if(i.length===0){if(o.demos.setup&&!o.demos.engine)throw new Error("demos.setup requires demos.engine");return}let l=o.demos.engine;if(!l)throw new Error(`Found ${i.length} demo directive${i.length===1?"":"s"}, but no demos.engine is configured`);return l.prepare({cwd:t,outputRoot:v(t,o.outputDir),basePath:o.basePath,mode:r,server:n,setup:o.demos.setup,demos:i})}c(vo,"prepareDemoManifest");export{C as a,z as b,xe as c,et as d,st as e,ze as f,M as g,Qe as h,ee as i,ao as j,co as k,So as l,vo as m};
|
|
6
|
+
//# sourceMappingURL=chunk-LP3NAJM7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as v}from"./chunk-EAYVCA3Z.js";import{a as T,b as y}from"./chunk-JK7ZNBUA.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{randomUUID as ro}from"crypto";import{mkdir as ao,mkdtemp as so,rm as lo,writeFile as co}from"fs/promises";import{join as w}from"path";import{fileURLToPath as A,pathToFileURL as po}from"url";import{build as mo}from"esbuild";import{posix as u}from"path";function j(t){return t.replace(/\\/g,"/")}s(j,"normalizeRoutePath");function So(t,n){let e=j(t),r=e.split("/");return r[0]===n?r.slice(1).join("/"):e}s(So,"localeRelativePathFor");function p(t){if(!t.startsWith("/")||t!=="/"&&t.includes("//")||/[\\?#\u0000-\u001f]/.test(t))throw new Error(`Invalid route path: "${t}"`);for(let n of t.split("/")){let e;try{e=decodeURIComponent(n)}catch{throw new Error(`Invalid route path: "${t}"`)}if(e==="."||e===".."||e.includes("/")||e.includes("\\")||/[\u0000-\u001f]/.test(e))throw new Error(`Invalid route path: "${t}"`)}return t}s(p,"assertRoutePath");function f(t){return p(t),t.split("/").map(n=>n?encodeURIComponent(decodeURIComponent(n).normalize("NFC")):"").join("/")}s(f,"canonicalRoutePath");function E(t){let n=f(t);return n==="/"?"/":`/${n.replace(/^\/+|\/+$/g,"")}/`}s(E,"normalizedBase");function D(t){let n=j(t);if(n.startsWith("/")||/[?#\u0000-\u001f]/.test(n))throw new Error(`Invalid page path: "${t}"`);if(n.split("/").some(l=>l==="."||l===".."||l===""))throw new Error(`Invalid page path: "${t}"`);let r=v(n),i=/^index$/i.test(r)?"":r.replace(/\/index$/i,"");return i?i.split("/"):[]}s(D,"pageSegments");function U(t){return D(t).map(n=>encodeURIComponent(n)).join("/")}s(U,"pageRoute");function P(t){return D(t).join("/")}s(P,"pageOutputPath");function x(t,n,e="/"){let r=E(e);return t===n?r:`${r}${t}/`}s(x,"localeRootPath");function M(t,n,e="/"){return[E(e).replace(/^\/|\/$/g,""),t===n?"":t].filter(Boolean).join("/")}s(M,"localeOutputPrefix");function Co(t,n,e,r="/"){let i=U(e);return i?`${x(t,n,r)}${i}/`:x(t,n,r)}s(Co,"routePathFor");function vo(t,n,e,r="/"){let i=P(e),l=M(t,n,r);return i?u.join(l,i,"index.html"):u.join(l,"index.html")}s(vo,"htmlOutputPathFor");function To(t,n,e,r="/"){let i=P(e),l=M(t,n,r);return i?u.join(l,i,"index.md"):u.join(l,"index.md")}s(To,"markdownOutputPathFor");function xo(t){let n=p(t).replace(/^\/+|\/+$/g,"");return n?u.join(...n.split("/").map(e=>decodeURIComponent(e)),"index.html"):"index.html"}s(xo,"routeOutputPathFor");var h={logo:"/assets/canofold-brand/logo-light.webp",logoDark:"/assets/canofold-brand/logo-dark.webp",favicon:"/assets/canofold-brand/favicon.webp"},Po=Object.values(h).map(t=>t.slice(1));var O={title:"Canofold",description:"Technical documentation",basePath:"/",docsDir:"docs",outputDir:".canofold/dist",styles:[],demos:{},layout:{header:!0},seo:{robots:"allow"},markdown:{html:"sanitize",code:{},features:{},labels:{},plugins:[]},theme:{accentColor:"canofold",darkMode:!1,radius:8,baseColor:"paper",sidebarWidth:"17.5rem",outlineWidth:"18.75rem",logo:h.logo,logoDark:h.logoDark,favicon:h.favicon,tokens:{}},search:{enabled:!0,provider:"compact"},extensions:[],navigation:{},versions:{current:"current",items:[{id:"current",label:"Current",docsDir:"docs",base:"/"}]},redirects:{},i18n:{defaultLocale:"zh",locales:["zh"],localeNames:{},messages:{}},ai:{llmsTxt:!0,llmsFullTxt:!0,markdownIndex:!0,pageSummaries:!0,codeExamples:!0,chunkSizeBytes:256*1024,llmsFullMaxBytes:10*1024*1024,llmsFullOverflow:"manifest",versions:"current"}};import{z as o}from"zod";var z=["paper","neutral","slate","zinc","stone"];import{z as N}from"zod";var m=N.string().min(1).refine(t=>{if(t.startsWith("/")){if(t.startsWith("//"))return!1;try{return p(t),!0}catch{return!1}}try{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},"Resource must be an absolute site path or HTTPS URL").transform(t=>t.startsWith("/")?f(t):t);var I=o.object({canvas:o.string().optional(),foreground:o.string().optional(),text:o.string().optional(),muted:o.string().optional(),mutedSubtle:o.string().optional(),surface:o.string().optional(),surfaceSecondary:o.string().optional(),surfaceSoft:o.string().optional(),surfaceElevated:o.string().optional(),border:o.string().optional(),borderStrong:o.string().optional(),hairline:o.string().optional(),primary:o.string().optional(),primarySoft:o.string().optional(),primaryForeground:o.string().optional(),primaryDeep:o.string().optional(),accent:o.string().optional(),info:o.string().optional(),infoDeep:o.string().optional(),success:o.string().optional(),successDeep:o.string().optional(),warning:o.string().optional(),warningDeep:o.string().optional(),danger:o.string().optional(),dangerDeep:o.string().optional(),codeBackground:o.string().optional(),codeForeground:o.string().optional(),overlay:o.string().optional(),shadow:o.string().optional(),shadowSmall:o.string().optional()}).strict().optional(),_=o.object({displayFont:o.string().min(1).optional(),sansFont:o.string().min(1).optional(),monoFont:o.string().min(1).optional(),bodySize:o.string().min(1).optional(),bodyLineHeight:o.string().min(1).optional(),headingLineHeight:o.string().min(1).optional(),heading1Size:o.string().min(1).optional(),heading2Size:o.string().min(1).optional(),heading3Size:o.string().min(1).optional(),heading4Size:o.string().min(1).optional(),heading5Size:o.string().min(1).optional(),heading6Size:o.string().min(1).optional()}).strict().optional(),G=o.object({readingWidth:o.string().min(1).optional(),contentWidth:o.string().min(1).optional(),gutter:o.string().min(1).optional()}).strict().optional(),B=o.object({radiusSmall:o.string().min(1).optional(),radiusMedium:o.string().min(1).optional(),radiusLarge:o.string().min(1).optional(),radiusFull:o.string().min(1).optional()}).strict().optional(),W=o.object({durationFast:o.string().min(1).optional(),durationNormal:o.string().min(1).optional(),easing:o.string().min(1).optional()}).strict().optional(),H=o.object({colors:o.object({light:I,dark:I}).strict().optional(),typography:_,layout:G,geometry:B,motion:W}).strict(),Z=o.object({themes:o.object({light:o.string().min(1).optional(),dark:o.string().min(1).optional()}).strict().optional(),fallbackLanguage:o.string().min(1).optional(),overflow:o.enum(["wrap","scroll"]).optional(),unknownLanguage:o.enum(["warn","error","plain-text"]).optional()}).strict(),V=o.object({callouts:o.boolean().optional(),tabs:o.boolean().optional(),codeGroups:o.boolean().optional(),steps:o.boolean().optional(),terminals:o.boolean().optional(),documentBlocks:o.boolean().optional(),tables:o.boolean().optional(),codeBlocks:o.boolean().optional()}).strict(),R=o.object({copyCode:o.string().optional(),copyFailed:o.string().optional(),copySnippet:o.string().optional(),copyTerminal:o.string().optional(),terminalTitle:o.string().optional(),tabsTitle:o.string().optional(),tabItem:o.string().optional(),codeGroupTitle:o.string().optional(),codeGroupItem:o.string().optional(),taskCompleted:o.string().optional(),taskIncomplete:o.string().optional(),copySectionLink:o.string().optional(),tableTitle:o.string().optional(),copyTableCsv:o.string().optional(),downloadTableCsv:o.string().optional(),zoomTable:o.string().optional(),closeTablePreview:o.string().optional(),sortTableColumn:o.string().optional(),zoomImage:o.string().optional(),closeImagePreview:o.string().optional(),imageGallery:o.string().optional(),closeImageGallery:o.string().optional(),previousGalleryImage:o.string().optional(),nextGalleryImage:o.string().optional(),galleryThumbnails:o.string().optional(),galleryImage:o.string().optional()}).strict(),q=o.object({skipToContent:o.string().optional(),search:o.string().optional(),searchEmpty:o.string().optional(),searchUnavailable:o.string().optional(),language:o.string().optional(),primaryNavigation:o.string().optional(),theme:o.string().optional(),openSidebar:o.string().optional(),onThisPage:o.string().optional(),edit:o.string().optional(),updated:o.string().optional(),previous:o.string().optional(),next:o.string().optional(),close:o.string().optional(),source:o.string().optional(),preview:o.string().optional(),copySource:o.string().optional(),sourceCopied:o.string().optional(),quickActions:o.string().optional(),github:o.string().optional(),docsNavigation:o.string().optional(),pageNavigation:o.string().optional(),advertisement:o.string().optional(),version:o.string().optional()}).strict(),K=o.object({headingsTitle:o.string().optional(),headingsDescription:o.string().optional(),codeTitle:o.string().optional(),codeDescription:o.string().optional(),tableTitle:o.string().optional(),tableDescription:o.string().optional(),diagramTitle:o.string().optional(),diagramDescription:o.string().optional(),sourceDescription:o.string().optional(),themeDescription:o.string().optional()}).strict(),J=o.object({title:o.string().optional(),description:o.string().optional(),home:o.string().optional()}).strict(),c=o.object({label:o.string().optional(),detail:o.string().optional(),hash:o.string().optional()}).strict(),Q=o.object({headings:c.optional(),inline:c.optional(),lists:c.optional(),callouts:c.optional(),code:c.optional(),tables:c.optional(),media:c.optional(),diagrams:c.optional(),disclosure:c.optional(),extensions:c.optional(),api:c.optional(),metadata:c.optional()}).strict(),X=o.object({labels:q.optional(),brandTagline:o.string().optional(),quickActions:K.optional(),markdownElementGroups:Q.optional(),markdown:R.optional(),notFound:J.optional()}).strict(),b=o.string().min(1).refine(t=>{try{return p(t),!0}catch{return!1}},"Route must be a safe absolute path").transform(f),k=o.string().url().refine(t=>{let n=new URL(t);return(n.protocol==="https:"||n.protocol==="http:")&&!n.username&&!n.password&&!n.search&&!n.hash},"URL must use HTTP(S) without credentials, a query, or a hash"),Y=k.refine(t=>new URL(t).pathname==="/",{message:"siteUrl must be an HTTP(S) origin without a path"}),L=o.string().min(1).regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,"Version id must be a safe portable slug"),oo=o.object({enabled:o.boolean().optional(),provider:o.union([o.literal("compact"),o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.id=="string"&&(t.client==="compact"||t.client==="pagefind")&&typeof t.write=="function","search.provider must be compact or a SearchProvider object")]).optional()}).strict(),to=o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.prepare=="function"&&(t.startDev===void 0||typeof t.startDev=="function"),"demos.engine must be a Canofold demo engine object"),S=o.lazy(()=>o.union([o.string(),o.number().finite(),o.boolean(),o.null(),o.array(S),o.record(o.string(),S)])),no=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,eo=o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.name=="string"&&no.test(t.name),"markdown.plugins entries must be plugin objects with a lowercase kebab-case name"),io=o.object({resolve:o.string().min(1).regex(/^\.[\\/]/,"Extension resolve must be a project-relative path beginning with ./"),options:o.record(o.string(),S).optional()}).strict(),F=o.object({title:o.string().min(1).optional(),description:o.string().optional(),siteUrl:Y.optional(),basePath:b.refine(t=>t.endsWith("/"),"basePath must end with /").optional(),editUrl:k.optional(),github:k.optional(),requiredVersion:o.string().optional(),docsDir:o.string().optional(),outputDir:o.string().optional(),styles:o.array(o.string().min(1)).optional(),demos:o.object({engine:to.optional(),setup:o.string().min(1).optional()}).strict().optional(),layout:o.object({header:o.boolean().optional()}).strict().optional(),seo:o.object({robots:o.enum(["allow","disallow"]).optional()}).strict().optional(),markdown:o.object({html:o.enum(["trusted","sanitize","strip"]).optional(),code:Z.optional(),features:V.optional(),labels:R.optional(),plugins:o.array(eo).optional()}).strict().optional(),theme:o.object({logo:m.optional(),logoDark:m.optional(),favicon:m.optional(),accentColor:o.string().optional(),darkMode:o.boolean().optional(),radius:o.union([o.number(),o.string()]).optional(),baseColor:o.enum(z).optional(),sidebarWidth:o.union([o.number(),o.string()]).optional(),outlineWidth:o.union([o.number(),o.string()]).optional(),tokens:H.optional()}).strict().optional(),search:oo.optional(),extensions:o.array(io).optional(),navigation:o.record(o.string(),o.array(o.object({text:o.string().min(1),link:m}).strict())).optional(),versions:o.object({current:L,items:o.array(o.object({id:L,label:o.string().min(1),docsDir:o.string().min(1),base:b}).strict()).min(1)}).strict().optional(),redirects:o.record(b,b).optional(),advertising:o.object({image:m,href:m,alt:o.string().min(1),label:o.string().min(1).optional()}).strict().optional(),i18n:o.object({defaultLocale:o.string().optional(),locales:o.array(o.string().min(1)).min(1).optional(),localeNames:o.record(o.string(),o.string().min(1)).optional(),messages:o.record(o.string(),X).optional()}).strict().optional(),ai:o.object({llmsTxt:o.boolean().optional(),llmsFullTxt:o.boolean().optional(),markdownIndex:o.boolean().optional(),pageSummaries:o.boolean().optional(),codeExamples:o.boolean().optional(),chunkSizeBytes:o.number().int().min(16*1024).max(4*1024*1024).optional(),llmsFullMaxBytes:o.number().int().min(16*1024).max(1024*1024*1024).optional(),llmsFullOverflow:o.enum(["manifest","error"]).optional(),versions:o.enum(["current","all"]).optional()}).strict().optional()}).strict();var go=["canofold.config.ts","canofold.config.mts","canofold.config.cts","canofold.config.js","canofold.config.mjs","canofold.config.cjs"];function $(){return structuredClone(O)}s($,"cloneDefaultConfig");function uo(t){let n=$(),e=t.docsDir??n.docsDir,r=t.versions?{current:t.versions.current,items:t.versions.items.map(a=>({...a}))}:{current:"current",items:[{id:"current",label:"Current",docsDir:e,base:"/"}]},i=r.items.find(a=>a.id===r.current)?.docsDir??e,l={...n,...t,docsDir:i,styles:t.styles?[...t.styles]:n.styles,demos:{engine:t.demos?.engine??n.demos.engine,setup:t.demos?.setup??n.demos.setup},layout:{header:t.layout?.header??n.layout.header},seo:{robots:t.seo?.robots??n.seo.robots},markdown:{html:t.markdown?.html??n.markdown.html,code:{...n.markdown.code,...t.markdown?.code,themes:{...n.markdown.code.themes,...t.markdown?.code?.themes}},features:{...n.markdown.features,...t.markdown?.features},labels:{...n.markdown.labels,...t.markdown?.labels},plugins:t.markdown?.plugins?[...t.markdown.plugins]:n.markdown.plugins},theme:{...n.theme,...t.theme,tokens:{colors:{light:{...n.theme.tokens.colors?.light,...t.theme?.tokens?.colors?.light},dark:{...n.theme.tokens.colors?.dark,...t.theme?.tokens?.colors?.dark}},typography:{...n.theme.tokens.typography,...t.theme?.tokens?.typography},layout:{...n.theme.tokens.layout,...t.theme?.tokens?.layout},geometry:{...n.theme.tokens.geometry,...t.theme?.tokens?.geometry},motion:{...n.theme.tokens.motion,...t.theme?.tokens?.motion}}},search:{enabled:t.search?.enabled??n.search.enabled,provider:t.search?.provider??n.search.provider},extensions:(t.extensions??n.extensions).map(a=>({...a,...a.options?{options:structuredClone(a.options)}:{}})),navigation:Object.fromEntries(Object.entries(t.navigation??n.navigation).map(([a,d])=>[a,d.map(g=>({...g}))])),versions:r,redirects:{...n.redirects,...t.redirects},...t.advertising?{advertising:{...t.advertising}}:{},i18n:{...n.i18n,...t.i18n,locales:t.i18n?.locales?[...t.i18n.locales]:n.i18n.locales,localeNames:{...n.i18n.localeNames,...t.i18n?.localeNames},messages:{...n.i18n.messages,...t.i18n?.messages}},ai:{...n.ai,...t.ai}};return t.theme?.logo&&!t.theme.logoDark&&delete l.theme.logoDark,l}s(uo,"mergeConfig");function fo(t){let{defaultLocale:n,locales:e,localeNames:r={},messages:i={}}=t.i18n;if(!e.includes(n))throw new Error(`i18n.defaultLocale "${n}" must be included in i18n.locales`);if(new Set(e.map(a=>a.toLowerCase())).size!==e.length)throw new Error("i18n.locales must not contain duplicate locales");for(let a of e)try{Intl.getCanonicalLocales(a)}catch{throw new Error(`Invalid locale identifier in i18n.locales: "${a}"`)}let l=new Set(e);for(let a of[...Object.keys(r),...Object.keys(i)])if(!l.has(a))throw new Error(`i18n resource key "${a}" must be included in i18n.locales`);for(let a of Object.keys(t.navigation))if(!l.has(a))throw new Error(`navigation key "${a}" must be included in i18n.locales`)}s(fo,"assertI18nConfig");function ho(t){let n=t.versions.items.map(i=>i.id),e=t.versions.items.map(i=>i.base);if(!n.includes(t.versions.current))throw new Error(`versions.current "${t.versions.current}" must match a versions.items id`);if(new Set(n.map(y)).size!==n.length)throw new Error("versions.items must not contain portable-duplicate version ids");if(new Set(e.map(y)).size!==e.length)throw new Error("versions.items must not contain duplicate bases");for(let i of t.versions.items){try{p(i.base)}catch{throw new Error(`Version base "${i.base}" must be a safe absolute route ending in /`)}if(!i.base.endsWith("/")||i.base.includes("//"))throw new Error(`Version base "${i.base}" must be an absolute path ending in /`)}if(t.versions.items.find(i=>i.id===t.versions.current)?.base!=="/")throw new Error('The current documentation version must use base "/"')}s(ho,"assertVersionConfig");function bo(t){if(t.docsDir!==void 0&&t.versions!==void 0)throw new Error("docsDir cannot be combined with versions; set docsDir on each versions.items entry");if(t.theme?.logoDark&&!t.theme.logo)throw new Error("theme.logoDark requires theme.logo");if(t.theme?.logoDark&&t.theme.darkMode!==!0)throw new Error("theme.logoDark requires theme.darkMode: true")}s(bo,"assertEffectiveInput");async function wo(t){let n=[];for(let e of go){let r=w(t,e);await T(r)&&n.push(r)}if(n.length>1)throw new Error(`Multiple Canofold configuration files found: ${n.map(e=>e.split(/[\\/]/).at(-1)).join(", ")}`);return n[0]}s(wo,"findConfigPath");async function Qo(t){let n=await wo(t);if(!n)return $();let e=w(t,".canofold/tmp");await ao(e,{recursive:!0});let r=await so(w(e,"config-")),i=w(r,`${ro()}.mjs`),l;try{let g;try{g=A(import.meta.resolve("canofold"))}catch{g=A(new URL("../index.ts",import.meta.url))}let C=(await mo({entryPoints:[n],absWorkingDir:t,alias:{canofold:g},bundle:!0,format:"esm",platform:"node",target:"node22",external:["@canofold/plugins","@canofold/vite"],write:!1,sourcemap:"inline"})).outputFiles[0];if(!C)throw new Error("Failed to bundle canofold.config.ts");await co(i,C.contents),l=await import(`${po(i).href}?t=${Date.now()}`)}finally{await lo(r,{recursive:!0,force:!0})}let a=F.parse(l.default??{});bo(a);let d=uo(a);return fo(d),ho(d),d}s(Qo,"loadConfig");export{So as a,f as b,x as c,Co as d,vo as e,To as f,xo as g,h,Po as i,m as j,wo as k,Qo as l};
|
|
2
|
+
//# sourceMappingURL=chunk-VMPJIE5E.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s,b as f,e as p,f as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=clean-
|
|
1
|
+
import{a as s,b as f,e as p,f as l}from"./chunk-BSFJWPWR.js";import{l as m}from"./chunk-VMPJIE5E.js";import{a as n}from"./chunk-M6T5RSNJ.js";import"./chunk-JACOFQSH.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import{a as u}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 m(t),r=s(t),a=await l(t,i,r);await p(r,async()=>{let c=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(c,{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(c,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}, .canofold/cache, and temporary or interrupted build files`)}u(x,"runClean");export{x as runClean};
|
|
2
|
+
//# sourceMappingURL=clean-REXZDZX4.js.map
|
package/dist/cli.js
CHANGED
|
@@ -13,5 +13,5 @@ Commands:
|
|
|
13
13
|
Preview .canofold/dist on a custom local port
|
|
14
14
|
check Run documentation checks
|
|
15
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-
|
|
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-TVOVOMAO.js");return r({cwd:o,...h(n)})}if(t==="build"){let{runBuild:r}=await import("./build-72JU66ZI.js");return r({cwd:o,...d(n)})}if(t==="clean"){a(n,1);let{runClean:r}=await import("./clean-REXZDZX4.js");return r({cwd:o})}if(t==="dev"){let{runDev:r}=await import("./dev-4LCWVCHW.js");return r({cwd:o,port:u(n)})}if(t==="preview"){let{runPreview:r}=await import("./preview-FB3HCXFC.js"),i=u(n);return r({cwd:o,port:i})}if(t==="check"){a(n,1);let{runCheck:r}=await import("./check-EJ4AQZQN.js");return r({cwd:o})}if(t==="deploy"){a(n,1);let{runDeploy:r}=await import("./deploy-VQKVGFX5.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
17
|
//# sourceMappingURL=cli.js.map
|
package/dist/demo-engine.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ interface CanofoldPreparedDemo extends CanofoldDemoReference {
|
|
|
29
29
|
}
|
|
30
30
|
interface CanofoldDemoManifest {
|
|
31
31
|
clientUrl: string;
|
|
32
|
+
/** Optional Markdown browser entry emitted by the same module graph as demos. */
|
|
33
|
+
markdownClientUrl?: string;
|
|
32
34
|
styleUrls?: string[];
|
|
33
35
|
demos: Record<string, CanofoldPreparedDemo>;
|
|
34
36
|
/** Paths relative to the site output root, used by output safety and caching. */
|
|
@@ -41,6 +43,8 @@ interface CanofoldDemoPrepareContext {
|
|
|
41
43
|
outputRoot: string;
|
|
42
44
|
basePath: string;
|
|
43
45
|
mode: 'analyze' | 'build' | 'dev';
|
|
46
|
+
/** Shared HTTP server used by the single long-lived Vite session in dev mode. */
|
|
47
|
+
server?: Server;
|
|
44
48
|
setup?: string;
|
|
45
49
|
demos: readonly CanofoldDemoReference[];
|
|
46
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{l as g}from"./chunk-
|
|
1
|
+
import{l as g}from"./chunk-VMPJIE5E.js";import{a as d}from"./chunk-M6T5RSNJ.js";import"./chunk-EAYVCA3Z.js";import{a as i,e as f}from"./chunk-JK7ZNBUA.js";import{a as r}from"./chunk-AYDF3IFZ.js";import{mkdir as y,readFile as h,writeFile as $}from"fs/promises";import{join as a}from"path";function k(o){return`"${o.replace(/[\\"$]/g,"\\$&")}"`}r(k,"quoteNginxValue");async function b(o){if(await i(a(o,"pnpm-lock.yaml")))return"pnpm";if(await i(a(o,"yarn.lock")))return"yarn";try{let e=JSON.parse(await h(a(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"}r(b,"detectPackageManager");function w(o,e,s){let t=o.replaceAll("\\","/"),c=k(`/var/www/canofold/${t.replace(/^\/+/,"")}`),l=e.replace(/\/$/,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),p=e==="/"?` location / {
|
|
2
2
|
try_files $uri $uri/ =404;
|
|
3
3
|
}`:` location = ${e.replace(/\/$/,"")} {
|
|
4
4
|
return 308 ${e};
|
|
@@ -141,4 +141,4 @@ server {
|
|
|
141
141
|
${p}
|
|
142
142
|
}
|
|
143
143
|
`}}r(w,"createGuides");async function E({cwd:o}){let e=await g(o),s=f(o,e.outputDir);if(!await i(a(s,"index.html")))throw new Error(`Build output not found at ${e.outputDir}. Run canofold build before canofold deploy.`);let t=a(o,".canofold/deploy"),c=await b(o);await y(t,{recursive:!0});for(let[l,p]of Object.entries(w(e.outputDir,e.basePath,c)))await $(a(t,l),p);d(`Wrote deployment guides to ${t}`)}r(E,"runDeploy");export{E as runDeploy};
|
|
144
|
-
//# sourceMappingURL=deploy-
|
|
144
|
+
//# sourceMappingURL=deploy-VQKVGFX5.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as P}from"./chunk-GLAK57S4.js";import{b as D}from"./chunk-LGMGXZ4I.js";import{a as w}from"./chunk-BSFJWPWR.js";import"./chunk-LP3NAJM7.js";import{b as S}from"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-VMPJIE5E.js";import{a as R,b as g}from"./chunk-M6T5RSNJ.js";import"./chunk-JACOFQSH.js";import"./chunk-EAYVCA3Z.js";import{c as h,e as y}from"./chunk-JK7ZNBUA.js";import{a as o}from"./chunk-AYDF3IFZ.js";import O from"chokidar";import{createMarkdownRenderer as T}from"@canofold/markdown/server";import{relative as I,resolve as k,sep as K}from"path";import{createServer as U}from"http";function B(n,m,u){let s=k(n,u),t=I(n,s).split(K);return t.includes("node_modules")||t.includes(".git")||t.includes(".canofold")||t.some(r=>/^\..+\.(?:tmp|backup)-/.test(r))?!0:h(y(n,m),s)||h(w(n),s)}o(B,"shouldIgnoreGeneratedPath");function x({build:n,reload:m,onBuildError:u=o(r=>g(r instanceof Error?r.message:String(r)),"onBuildError"),onBuildOk:s,debounceMs:t=80}){let r,d,l=!1,c=!1,p=o(()=>{if(r=void 0,!c){if(d){l=!0;return}d=(async()=>{try{let a=await n();c||(s?.(),m(a))}catch(a){u(a)}finally{d=void 0,l&&!c&&(l=!1,r=setTimeout(p,0))}})()}},"run");return{schedule(){if(!c){if(d){l=!0;return}r&&clearTimeout(r),r=setTimeout(p,t)}},async close(){c=!0,l=!1,r&&clearTimeout(r),r=void 0,await d}}}o(x,"createBuildScheduler");async function E({cwd:n,port:m}){let u=T(),s=U(),t=await D({cwd:n,renderer:u,demoMode:"dev",demoServer:s}),r,d,l=o(()=>{let e=t.config.demos.engine;if(!(!t.demoManifest||!e?.startDev))return JSON.stringify({id:e.id,version:e.version??"",cacheKey:e.cacheKey??null,basePath:t.config.basePath,outputDir:t.config.outputDir,setup:t.config.demos.setup??null})},"runtimeKeyForCurrentBuild"),c=o(async()=>{let e=t.config.demos.engine;if(!(!t.demoManifest||!e?.startDev))return e.startDev({cwd:n,basePath:t.config.basePath,setup:t.config.demos.setup,server:s,getDemos:o(()=>Object.values(t.demoManifest?.demos??{}),"getDemos"),shouldIgnorePath:o(i=>B(n,t.config.outputDir,i),"shouldIgnorePath")})},"createDemoRuntime"),p=o(async()=>{let e=l();if(e===d){await r?.update?.();return}let i=await c(),f=r;r=i,d=e,await f?.close()},"refreshDemoRuntime"),a=await P({root:o(()=>y(n,t.config.outputDir),"root"),port:m,server:s,liveReload:!0,basePath:o(()=>t.config.basePath,"basePath"),configureServer:o(async()=>(r=await c(),d=l(),{middleware(e,i,f){if(!r?.middleware){f();return}r.middleware(e,i,()=>f())},close:o(()=>r?.close(),"close")}),"configureServer")}),v=O.watch(".",{cwd:n,ignoreInitial:!0,ignored:o(e=>B(n,t.config.outputDir,e),"ignored")}),b=x({build:o(async()=>{t=await D({cwd:n,renderer:u,demoMode:"dev",demoServer:s}),await p();let e=t.changedPages.flatMap(i=>{let f=t.graph.pages.find(M=>M.sourceRelativePath===i);return f?[S(t.config,f.routePath)]:[]});return{protocol:1,type:"update",mode:t.partialReload&&e.length===1?"page":"full",routes:e}},"build"),reload:o(e=>a.reload(e),"reload"),onBuildError:o(e=>{let i=e instanceof Error?e.message:String(e);g("Build error:",i),a.sendBuildError(i)},"onBuildError"),onBuildOk:o(()=>a.sendBuildOk(),"onBuildOk")});return v.on("all",(e,i)=>{r?.handlesFile?.(k(n,i))||b.schedule()}),v.on("error",e=>{let i=e instanceof Error?e.message:String(e);g("File watcher error:",i),a.sendBuildError(i)}),{port:a.port,close:o(async()=>{await v.close(),await b.close(),await a.close()},"close")}}o(E,"startDevServer");async function V({cwd:n,port:m=3333}){let u=await E({cwd:n,port:m});return R(`Dev server running at http://127.0.0.1:${u.port}/`),u}o(V,"runDev");export{V as runDev};
|
|
2
|
+
//# sourceMappingURL=dev-4LCWVCHW.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -263,9 +263,12 @@ interface CanofoldConfigInput {
|
|
|
263
263
|
layout?: {
|
|
264
264
|
header?: boolean;
|
|
265
265
|
};
|
|
266
|
+
seo?: {
|
|
267
|
+
robots?: 'allow' | 'disallow';
|
|
268
|
+
};
|
|
266
269
|
markdown?: {
|
|
267
270
|
html?: MarkdownHtmlPolicy;
|
|
268
|
-
code?: Pick<MarkdownCodeOptions, 'themes' | 'fallbackLanguage' | 'unknownLanguage'>;
|
|
271
|
+
code?: Pick<MarkdownCodeOptions, 'themes' | 'fallbackLanguage' | 'overflow' | 'unknownLanguage'>;
|
|
269
272
|
features?: MarkdownFeatureOptions;
|
|
270
273
|
labels?: Partial<MarkdownLabels>;
|
|
271
274
|
/**
|
|
@@ -340,6 +343,9 @@ interface CanofoldConfig {
|
|
|
340
343
|
layout: {
|
|
341
344
|
header: boolean;
|
|
342
345
|
};
|
|
346
|
+
seo: {
|
|
347
|
+
robots: 'allow' | 'disallow';
|
|
348
|
+
};
|
|
343
349
|
markdown: {
|
|
344
350
|
html: MarkdownHtmlPolicy;
|
|
345
351
|
code: MarkdownCodeOptions;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as t,f,g as a}from"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as n}from"./chunk-
|
|
1
|
+
import{c as t,f,g as a}from"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as n}from"./chunk-JACOFQSH.js";import"./chunk-JK7ZNBUA.js";import{a as o}from"./chunk-AYDF3IFZ.js";function r(e){return e}o(r,"defineConfig");export{f as CANOFOLD_EXTENSION_API_VERSION,n as canofoldVersion,r as defineConfig,a as defineExtension,t as defineSearchProvider};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as d}from"./chunk-M6T5RSNJ.js";import{a as b}from"./chunk-
|
|
1
|
+
import{a as d}from"./chunk-M6T5RSNJ.js";import{a as b}from"./chunk-JACOFQSH.js";import{a as k,d as S}from"./chunk-EAYVCA3Z.js";import{a as T,d as j,f as N}from"./chunk-JK7ZNBUA.js";import{a as l}from"./chunk-AYDF3IFZ.js";import{mkdir as U,readFile as B,readdir as G,rm as V,rmdir as Y,writeFile as _}from"fs/promises";import{dirname as W,isAbsolute as Q,join as E}from"path";import{createInterface as Z}from"readline/promises";import{join as y}from"path";var R=`/**
|
|
2
2
|
* Minimal declarations for trusted project-local TSX components.
|
|
3
3
|
*
|
|
4
4
|
* Canofold intentionally does not publish or emulate a UI component module.
|
|
@@ -67,5 +67,5 @@ export default defineConfig({
|
|
|
67
67
|
locales: [${n.map(i=>`'${i}'`).join(", ")}]
|
|
68
68
|
}
|
|
69
69
|
})
|
|
70
|
-
`}l(H,"configTemplate");function O(e){let{docsDir:t,defaultLocale:n,locales:i,includeContent:r,includeConfig:s}=e,c={[y(t,"canofold-env.d.ts")]:R};if(s&&(c["canofold.config.ts"]=H(t,n,i)),!r)return c;for(let g of i){let p=g===n?t:y(t,g),a=q(g);c[y(p,"index.md")]=a?.index??A,a&&(c[y(p,"guide.md")]=a.guide)}return c}l(O,"createInitFiles");async function J(e,t=""){let n;try{n=await G(e,{withFileTypes:!0})}catch(r){if(r.code==="ENOENT")return[];throw r}let i=[];for(let r of n){let s=t?E(t,r.name):r.name;if(r.isFile()&&k(r.name)&&i.push(s),r.isDirectory()&&(t||r.name!=="public"))for(let c of await J(E(e,r.name),s))i.push(c)}return i.sort((r,s)=>r.localeCompare(s))}l(J,"listMarkdownFiles");function ee(e,t){for(let n of t)try{Intl.getCanonicalLocales(n)}catch{throw new Error(`Invalid locale: ${n}`)}if(new Set(t.map(n=>n.toLowerCase())).size!==t.length)throw new Error("Locales must not contain duplicates");if(!t.some(n=>n.toLowerCase()===e.toLowerCase()))throw new Error(`Default locale ${e} must be included in locales`)}l(ee,"validateLocaleSelection");async function te(e=Z({input:process.stdin,output:process.stdout})){try{let n=((await e.question("Existing documents found. Enter their locale, or a comma-separated locale list (default: zh): ")).trim()||"zh").split(",").map(i=>i.trim());if(n.some(i=>!i))throw new Error("Locales must be a comma-separated list of locale identifiers");return n}catch(t){throw t.code==="ABORT_ERR"?new Error("Canofold initialization cancelled"):t}finally{e.close()}}l(te,"promptForLocales");function ne(e,t){return e.length===t.length&&e.every((n,i)=>n.toLowerCase()===t[i]?.toLowerCase())}l(ne,"sameLocales");function oe(e,t){if(e.docsDir&&e.docsDir!==t.docsDir)throw new Error(`--docs-dir ${e.docsDir} conflicts with configured docsDir ${t.docsDir}`);if(e.locale&&e.locale.toLowerCase()!==t.i18n.defaultLocale.toLowerCase())throw new Error(`--locale ${e.locale} conflicts with configured defaultLocale ${t.i18n.defaultLocale}`);if(e.locales&&!ne(e.locales,t.i18n.locales))throw new Error(`--locales ${e.locales.join(",")} conflicts with configured locales ${t.i18n.locales.join(",")}`)}l(oe,"assertOptionsMatchConfig");function $(e){return S(e.replace(/\\/g,"/")).normalize("NFC").toLocaleLowerCase("en-US")}l($,"portablePageKey");function ie(e,t,n){if(!e.length)return[];let i=[],r=e.map(a=>a.replace(/\\/g,"/")),s=l(a=>n==="."?a:`${n.replace(/\\/g,"/")}/${a}`,"displayPath"),c=t.normalize("NFC").toLocaleLowerCase("en-US");r.some(a=>{let h=$(a);return h==="index"||h===`${c}/index`})||i.push(`no default-language index.md or index.mdx was found in ${n}`);let p=new Map;for(let a of r)a.startsWith(`${t}/`)||p.set($(a),a);for(let a of r){if(!a.startsWith(`${t}/`))continue;let h=a.slice(t.length+1),u=p.get($(h));u&&i.push(`${s(u)} and ${s(a)} map to the same default-language page; keep only one source`)}return i}l(ie,"existingContentWarnings");async function re(e,t){let n=[],i=e;for(;!await T(i);){n.push(i);let r=W(i);if(r===i)break;i=r}for(let r of n.reverse())try{await U(r),t.push(r)}catch(s){if(s.code!=="EEXIST")throw s}}l(re,"createMissingDirectoryChain");async function xe(e,t={}){let n=e.targetDir?E(e.cwd,e.targetDir):e.cwd,{findConfigPath:i,loadConfig:r}=await import("./load-
|
|
71
|
-
//# sourceMappingURL=init-
|
|
70
|
+
`}l(H,"configTemplate");function O(e){let{docsDir:t,defaultLocale:n,locales:i,includeContent:r,includeConfig:s}=e,c={[y(t,"canofold-env.d.ts")]:R};if(s&&(c["canofold.config.ts"]=H(t,n,i)),!r)return c;for(let g of i){let p=g===n?t:y(t,g),a=q(g);c[y(p,"index.md")]=a?.index??A,a&&(c[y(p,"guide.md")]=a.guide)}return c}l(O,"createInitFiles");async function J(e,t=""){let n;try{n=await G(e,{withFileTypes:!0})}catch(r){if(r.code==="ENOENT")return[];throw r}let i=[];for(let r of n){let s=t?E(t,r.name):r.name;if(r.isFile()&&k(r.name)&&i.push(s),r.isDirectory()&&(t||r.name!=="public"))for(let c of await J(E(e,r.name),s))i.push(c)}return i.sort((r,s)=>r.localeCompare(s))}l(J,"listMarkdownFiles");function ee(e,t){for(let n of t)try{Intl.getCanonicalLocales(n)}catch{throw new Error(`Invalid locale: ${n}`)}if(new Set(t.map(n=>n.toLowerCase())).size!==t.length)throw new Error("Locales must not contain duplicates");if(!t.some(n=>n.toLowerCase()===e.toLowerCase()))throw new Error(`Default locale ${e} must be included in locales`)}l(ee,"validateLocaleSelection");async function te(e=Z({input:process.stdin,output:process.stdout})){try{let n=((await e.question("Existing documents found. Enter their locale, or a comma-separated locale list (default: zh): ")).trim()||"zh").split(",").map(i=>i.trim());if(n.some(i=>!i))throw new Error("Locales must be a comma-separated list of locale identifiers");return n}catch(t){throw t.code==="ABORT_ERR"?new Error("Canofold initialization cancelled"):t}finally{e.close()}}l(te,"promptForLocales");function ne(e,t){return e.length===t.length&&e.every((n,i)=>n.toLowerCase()===t[i]?.toLowerCase())}l(ne,"sameLocales");function oe(e,t){if(e.docsDir&&e.docsDir!==t.docsDir)throw new Error(`--docs-dir ${e.docsDir} conflicts with configured docsDir ${t.docsDir}`);if(e.locale&&e.locale.toLowerCase()!==t.i18n.defaultLocale.toLowerCase())throw new Error(`--locale ${e.locale} conflicts with configured defaultLocale ${t.i18n.defaultLocale}`);if(e.locales&&!ne(e.locales,t.i18n.locales))throw new Error(`--locales ${e.locales.join(",")} conflicts with configured locales ${t.i18n.locales.join(",")}`)}l(oe,"assertOptionsMatchConfig");function $(e){return S(e.replace(/\\/g,"/")).normalize("NFC").toLocaleLowerCase("en-US")}l($,"portablePageKey");function ie(e,t,n){if(!e.length)return[];let i=[],r=e.map(a=>a.replace(/\\/g,"/")),s=l(a=>n==="."?a:`${n.replace(/\\/g,"/")}/${a}`,"displayPath"),c=t.normalize("NFC").toLocaleLowerCase("en-US");r.some(a=>{let h=$(a);return h==="index"||h===`${c}/index`})||i.push(`no default-language index.md or index.mdx was found in ${n}`);let p=new Map;for(let a of r)a.startsWith(`${t}/`)||p.set($(a),a);for(let a of r){if(!a.startsWith(`${t}/`))continue;let h=a.slice(t.length+1),u=p.get($(h));u&&i.push(`${s(u)} and ${s(a)} map to the same default-language page; keep only one source`)}return i}l(ie,"existingContentWarnings");async function re(e,t){let n=[],i=e;for(;!await T(i);){n.push(i);let r=W(i);if(r===i)break;i=r}for(let r of n.reverse())try{await U(r),t.push(r)}catch(s){if(s.code!=="EEXIST")throw s}}l(re,"createMissingDirectoryChain");async function xe(e,t={}){let n=e.targetDir?E(e.cwd,e.targetDir):e.cwd,{findConfigPath:i,loadConfig:r}=await import("./load-4UYHBETN.js"),s=!!await i(n),c=s?await r(n):void 0;c&&oe(e,c);let g=c?.docsDir??e.docsDir??"docs";if(Q(g))throw new Error("docsDir must be a relative path");let p=j(n,g,"docsDir");await N(n,p,"docsDir");let a=await J(p),h=a.length>0,u=e.locales;if(h&&!s&&!e.locale&&!u){let o=e.localePrompt??(process.stdin.isTTY&&process.stdout.isTTY?te:void 0);if(!o){let f=a[0]??"";throw new Error(`Found ${a.length} existing Markdown file(s) in "${g}" (e.g. "${f}"), but cannot determine their language in a non-interactive environment. Specify the locale explicitly: canofold init --locale <locale> (e.g. --locale zh)`)}u=await o()}let x=c?.i18n.defaultLocale??e.locale??u?.[0]??"zh";u=c?.i18n.locales??u??[x],ee(x,u);let M=O({docsDir:g,defaultLocale:x,locales:u,includeContent:!h,includeConfig:!s}),P=[],F=[],D=ie(a,x,g);for(let[o,f]of Object.entries(M)){let w=E(n,o);try{let C=await B(w,"utf8");F.push(o),C!==f&&D.push(`${o} already exists with different content`)}catch(C){let v=C.code;if(v==="EISDIR")throw new Error(`Cannot create ${o} because a directory exists at that path`);if(v!=="ENOENT")throw C;P.push({relativePath:o,content:f,fullPath:w})}}let m={mode:s?"configured":h?"adopt":"create",createFiles:P,keepFiles:F,warnings:D};if(!m.createFiles.length){for(let o of m.warnings)d(`Warning: ${o}`);d(`Canofold is already initialized in ${n}`);return}let L=[],K=t.writeFile??((o,f,w)=>_(o,f,w)),X=[...new Set(m.createFiles.map(o=>W(o.fullPath)))].sort((o,f)=>o.length-f.length),I=[];try{for(let o of X)await re(o,I);for(let o of m.createFiles)await K(o.fullPath,o.content,{flag:"wx"}),L.push(o.fullPath)}catch(o){await Promise.all(L.map(f=>V(f,{force:!0})));for(let f of I.sort((w,C)=>C.length-w.length))try{await Y(f)}catch{}throw o}for(let o of m.createFiles)d(`Created ${o.relativePath}`);for(let o of m.keepFiles)d(`Kept existing ${o}`);for(let o of m.warnings)d(`Warning: ${o}`);if(m.mode==="adopt"){let o=a.length===1?"document":"documents";d(`Adopted ${a.length} existing ${o} in ${n}`),d(`Kept ${a.length} existing ${o} unchanged`),d("Next: canofold check")}else m.mode==="configured"?(d(`Created missing documentation files in ${n}`),d("Next: canofold dev")):(d(`Created Canofold docs in ${n}`),d("Next: canofold dev"));d("Add .canofold/ to .gitignore if this directory is versioned.")}l(xe,"runInit");export{te as promptForLocales,xe as runInit};
|
|
71
|
+
//# sourceMappingURL=init-TVOVOMAO.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{k as a,l as b}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=load-
|
|
1
|
+
import{k as a,l as b}from"./chunk-VMPJIE5E.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{a as findConfigPath,b as loadConfig};
|
|
2
|
+
//# sourceMappingURL=load-4UYHBETN.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=preview-
|
|
1
|
+
import{a as p}from"./chunk-GLAK57S4.js";import{l as n}from"./chunk-VMPJIE5E.js";import{a}from"./chunk-M6T5RSNJ.js";import"./chunk-EAYVCA3Z.js";import{e as i}from"./chunk-JK7ZNBUA.js";import{a as e}from"./chunk-AYDF3IFZ.js";async function g({cwd:r,port:s=4173}){let t=await n(r),o=await p({root:i(r,t.outputDir),port:s,basePath:t.basePath});return a(`Preview running at http://127.0.0.1:${o.port}${t.basePath}`),o}e(g,"runPreview");export{g as runPreview};
|
|
2
|
+
//# sourceMappingURL=preview-FB3HCXFC.js.map
|
package/dist/search-client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as B}from"./chunk-XYJ2OBL3.js";import{a as c}from"./chunk-AYDF3IFZ.js";var ee=2;function O(m,a,i=8){let n=B(m),s=m.toLowerCase(),f=new Map;return n.forEach(l=>{(a.postings[l]||[]).forEach(p=>{f.set(p,(f.get(p)||0)+1)})}),Array.from(f,([l,p])=>{let u=a.docs[l];if(!u)return;let w=[u.title,u.description,...u.tags||[],u.excerpt].join(" ").toLowerCase().includes(s)?ee:0;return{doc:u,score:p+w}}).filter(l=>!!l).filter(l=>l.score>0).sort((l,p)=>p.score-l.score).slice(0,i).map(l=>l.doc)}c(O,"queryCompactIndex");function K(m,a){let i=c(t=>String(t??"").replace(/<[^>]*>/g," ").replace(/&(?:nbsp|#160);/gi," ").replace(/&(?:amp|#38);/gi,"&").replace(/&(?:lt|#60);/gi,"<").replace(/&(?:gt|#62);/gi,">").replace(/\s+/g," ").trim(),"plainText"),n=i(m).toLowerCase().split(/\s+/).filter(Boolean),s=c((...t)=>{let d=t.map(i).join(" ").toLowerCase();return n.length>0&&n.every(x=>d.includes(x))},"matches"),f=c((t,d)=>!d||!t.toLowerCase().startsWith(d.toLowerCase())?t:t.slice(d.length).replace(/^[\s·::.\-—]+/,"").trim()||t,"withoutRepeatedLead"),l=c((t,d)=>(s(t)?4:0)+(s(d)?2:0)+(s(t,d)?1:0),"score"),u=(a.sub_results??[]).map((t,d)=>{let x=i(t.title),E=i(t.plain_excerpt||t.excerpt);return{fragment:t,title:x,excerpt:E,index:d,score:l(x,E)}}).filter(t=>t.score>0).sort((t,d)=>d.score-t.score||t.index-d.index)[0],h=i(a.meta?.title||a.url);if(u){let t=u.title===h?"":u.title,d=f(u.excerpt,u.title),x=[t,d].filter(Boolean).join(" \xB7 ")||u.title||a.url;return{title:h,description:x,excerpt:d,routePath:u.fragment.url||a.url}}let w=i(a.meta?.description),L=i(a.plain_excerpt||a.excerpt),o=s(h)?w||L||a.url:s(w)?w:s(L)?L:void 0;if(o)return{title:h,description:o,excerpt:L,routePath:a.url}}c(K,"createPagefindSearchDocument");function W(m,a){let i=m.trim().toLowerCase();return i?a.map((n,s)=>{let f=n.title.toLowerCase(),l=n.description.toLowerCase(),p=String(n.excerpt??"").toLowerCase(),u=(f===i?200:f.includes(i)?100:0)+(l.includes(i)?24:0)+(p.includes(i)?8:0);return{document:n,index:s,score:u}}).sort((n,s)=>s.score-n.score||n.index-s.index).map(n=>n.document):a}c(W,"rankSearchDocuments");function _(m,a){let i=c(w=>w.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',"""),"escape"),n=String(m),s=a.trim();if(!s)return i(n);let f=n.toLowerCase(),l=s.toLowerCase(),p=0,u="",h=f.indexOf(l);for(;h!==-1;)u+=i(n.slice(p,h)),u+=`<mark>${i(n.slice(h,h+s.length))}</mark>`,p=h+s.length,h=f.indexOf(l,p);return u+i(n.slice(p))}c(_,"highlightSearchText");var $=8,te=32;function R(m){return String(m).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""")}c(R,"escapeHtml");function F(){let m=window;m.__canofoldSearchDispose?.();let a=new AbortController,i=a.signal,n=c((o,t,d,x={})=>o.addEventListener(t,d,{...x,signal:i}),"on"),s,f=!1,l=document.querySelector("[data-canofold-search]");if(l){let D=function(e){return q().then(e).catch(()=>{})},I=function(e){return x==="pagefind"?Y(e):V(e)},j=function(){return Array.from(o.querySelectorAll('a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter(e=>e.tabIndex>=0&&!e.closest("[hidden]")&&e.getAttribute("aria-hidden")!=="true")},M=function(){k=document.activeElement,o.removeAttribute("hidden"),document.documentElement.classList.add("cf-search-open"),T?.removeAttribute("hidden"),S?.setAttribute("hidden",""),requestAnimationFrame(()=>(b||H)?.focus()),x==="pagefind"&&D(e=>e.init?.())},y=function(){o.setAttribute("hidden",""),document.documentElement.classList.remove("cf-search-open"),b&&(b.value=""),S&&(S.innerHTML=""),T?.removeAttribute("hidden"),S?.setAttribute("hidden",""),k instanceof HTMLElement&&k.focus({preventScroll:!0})};var p=D,u=I,h=j,w=M,L=y;c(D,"runPagefind"),c(I,"search"),c(j,"focusable"),c(M,"openModal"),c(y,"closeModal");let o=l,t=o.getAttribute("data-locale")||document.documentElement.lang||"en",d=o.getAttribute("data-version")||"current",x=o.getAttribute("data-search-provider")||"compact",E=o.getAttribute("data-search-index-url")||`/search/${t}.json`,N=o.getAttribute("data-search-bundle-url")||"/pagefind/pagefind.js",U=o.getAttribute("data-empty-label")||"No matching documents",X=o.getAttribute("data-error-label")||"Search index is unavailable",b=o.querySelector("input"),T=o.querySelector("[data-canofold-search-default]"),S=o.querySelector("[data-canofold-search-results]"),z=document.querySelectorAll("[data-canofold-search-open]"),G=o.querySelectorAll("[data-canofold-search-close]"),J=o.querySelectorAll("[data-canofold-search-action]"),H=o.querySelector('[role="dialog"]'),v,P,k;async function Q(){let e=await fetch(E);if(!e.ok)throw new Error("Search index not found");return await e.json()}c(Q,"loadLocalIndex");async function V(e){v||(v=Q().catch(g=>{throw v=void 0,g}));let r=await v;return O(e,r,$)}c(V,"searchCompact");async function q(){return P||(P=import(N).then(e=>e).catch(e=>{throw P=void 0,e})),P}c(q,"loadPagefind");async function Y(e){let g=await(await q()).search(e,{filters:{version:d,locale:t}}),C=await Promise.all(g.results.slice(0,te).map(async A=>{let Z=await A.data();return K(e,Z)}));return W(e,C.filter(A=>!!A)).slice(0,$)}c(Y,"searchPagefind"),z.forEach(e=>n(e,"click",M)),G.forEach(e=>n(e,"click",y)),S&&n(S,"click",e=>{let r=e.target;r instanceof Element&&r.closest("a[href]")&&y()}),J.forEach(e=>n(e,"click",()=>{let r=e.getAttribute("data-canofold-search-action");y(),r==="source"&&document.querySelector("[data-canofold-source-open]")?.click(),r==="theme"&&document.querySelector("[data-canofold-theme-toggle]")?.click()})),n(document,"keydown",e=>{let r=e;if((r.metaKey||r.ctrlKey)&&r.key.toLowerCase()==="k")r.preventDefault(),o.hasAttribute("hidden")?M():y();else if(r.key==="Escape"&&!o.hasAttribute("hidden"))y();else if(r.key==="Tab"&&!o.hasAttribute("hidden")){let g=j();if(!g.length){r.preventDefault(),H?.focus();return}let C=g[0],A=g[g.length-1];r.shiftKey&&document.activeElement===C?(r.preventDefault(),A?.focus()):!r.shiftKey&&document.activeElement===A&&(r.preventDefault(),C?.focus())}}),b&&S&&n(b,"input",()=>{clearTimeout(s),s=setTimeout(async()=>{let e=b.value.trim();if(!e){S.innerHTML="",S.setAttribute("hidden",""),T?.removeAttribute("hidden");return}T?.setAttribute("hidden",""),S.removeAttribute("hidden"),x==="pagefind"&&D(r=>r.preload?.(e,{filters:{version:d,locale:t}}));try{let r=await I(e);if(f||b.value.trim()!==e)return;S.innerHTML=r.length?r.map(g=>'<a class="cf-search-result" href="'+R(g.routePath)+'"><span class="cf-search-result-copy"><strong>'+_(g.title,e)+"</strong><small>"+_(g.description||g.routePath,e)+'</small></span><span class="cf-search-result-arrow" aria-hidden="true">\u2192</span></a>').join(""):`<p class="cf-search-empty">${R(U)}</p>`}catch{if(f||b.value.trim()!==e)return;S.innerHTML=`<p class="cf-search-empty">${R(X)}</p>`}},150)})}m.__canofoldSearchDispose=()=>{f=!0,a.abort(),clearTimeout(s),document.documentElement.classList.remove("cf-search-open")}}c(F,"bootstrapSearch");var ne=window;ne.__canofoldBootstrapSearch=F;F();export{F as bootstrapSearch};
|
|
2
2
|
//# sourceMappingURL=search-client.js.map
|
package/dist/styles.input.css
CHANGED
|
@@ -880,17 +880,7 @@ a {
|
|
|
880
880
|
min-height: 8rem;
|
|
881
881
|
place-items: center;
|
|
882
882
|
padding: clamp(1.5rem, 4vw, 3rem);
|
|
883
|
-
background:
|
|
884
|
-
linear-gradient(45deg, var(--cf-surface-soft) 25%, transparent 25%),
|
|
885
|
-
linear-gradient(-45deg, var(--cf-surface-soft) 25%, transparent 25%),
|
|
886
|
-
linear-gradient(45deg, transparent 75%, var(--cf-surface-soft) 75%),
|
|
887
|
-
linear-gradient(-45deg, transparent 75%, var(--cf-surface-soft) 75%);
|
|
888
|
-
background-position:
|
|
889
|
-
0 0,
|
|
890
|
-
0 8px,
|
|
891
|
-
8px -8px,
|
|
892
|
-
-8px 0;
|
|
893
|
-
background-size: 16px 16px;
|
|
883
|
+
background: transparent;
|
|
894
884
|
}
|
|
895
885
|
|
|
896
886
|
.cf-demo-frame {
|
|
@@ -922,7 +912,7 @@ a {
|
|
|
922
912
|
position: absolute;
|
|
923
913
|
top: 0;
|
|
924
914
|
left: 1.25rem;
|
|
925
|
-
padding: 0 0.
|
|
915
|
+
padding: 0 0 0.3rem;
|
|
926
916
|
color: var(--cf-ink);
|
|
927
917
|
background: var(--cf-surface);
|
|
928
918
|
font-size: 1rem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canofold",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A static-first, minimally invasive knowledge and documentation platform for Markdown, MDX, search, and AI-ready output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Canofold Contributors",
|
|
@@ -56,22 +56,23 @@
|
|
|
56
56
|
"chokidar": "^5.0.0",
|
|
57
57
|
"esbuild": "^0.28.2",
|
|
58
58
|
"gray-matter": "^4.0.3",
|
|
59
|
-
"lucide-react": "1.
|
|
60
|
-
"react": "^19.
|
|
61
|
-
"react-dom": "^19.
|
|
59
|
+
"lucide-react": "1.46.0",
|
|
60
|
+
"react": "^19.3.0",
|
|
61
|
+
"react-dom": "^19.3.0",
|
|
62
62
|
"semver": "^7.8.5",
|
|
63
|
-
"zod": "^4.
|
|
64
|
-
"@canofold/markdown": "0.3.
|
|
63
|
+
"zod": "^4.6.5",
|
|
64
|
+
"@canofold/markdown": "0.3.2"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@types/react": "^19.
|
|
68
|
-
"@types/react-dom": "^19.
|
|
67
|
+
"@types/react": "^19.3.0",
|
|
68
|
+
"@types/react-dom": "^19.3.0",
|
|
69
69
|
"@types/semver": "^7.8.0",
|
|
70
70
|
"tsup": "^8.3.5",
|
|
71
71
|
"typescript": "^6.0.3"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
|
-
"build": "tsup
|
|
74
|
+
"build": "tsup",
|
|
75
|
+
"dev": "tsup --watch",
|
|
75
76
|
"typecheck": "tsc --noEmit",
|
|
76
77
|
"test": "pnpm --dir ../.. build && vitest run --root ../.."
|
|
77
78
|
}
|
package/dist/build-UYV2L7WT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-OKX7SQKX.js";import"./chunk-EQOADO2H.js";import"./chunk-KJ7FG6AY.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-ACUMTEQL.js";import"./chunk-M6T5RSNJ.js";import"./chunk-2XMX5JW6.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{b as runBuild,a as versionSatisfies};
|
|
2
|
-
//# sourceMappingURL=build-UYV2L7WT.js.map
|
package/dist/chunk-2XMX5JW6.js
DELETED
package/dist/chunk-ACUMTEQL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as v}from"./chunk-EAYVCA3Z.js";import{a as T,b as y}from"./chunk-JK7ZNBUA.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{randomUUID as ro}from"crypto";import{mkdir as ao,mkdtemp as so,rm as lo,writeFile as co}from"fs/promises";import{join as w}from"path";import{fileURLToPath as A,pathToFileURL as po}from"url";import{build as mo}from"esbuild";import{posix as u}from"path";function j(t){return t.replace(/\\/g,"/")}s(j,"normalizeRoutePath");function So(t,n){let e=j(t),r=e.split("/");return r[0]===n?r.slice(1).join("/"):e}s(So,"localeRelativePathFor");function p(t){if(!t.startsWith("/")||t!=="/"&&t.includes("//")||/[\\?#\u0000-\u001f]/.test(t))throw new Error(`Invalid route path: "${t}"`);for(let n of t.split("/")){let e;try{e=decodeURIComponent(n)}catch{throw new Error(`Invalid route path: "${t}"`)}if(e==="."||e===".."||e.includes("/")||e.includes("\\")||/[\u0000-\u001f]/.test(e))throw new Error(`Invalid route path: "${t}"`)}return t}s(p,"assertRoutePath");function f(t){return p(t),t.split("/").map(n=>n?encodeURIComponent(decodeURIComponent(n).normalize("NFC")):"").join("/")}s(f,"canonicalRoutePath");function E(t){let n=f(t);return n==="/"?"/":`/${n.replace(/^\/+|\/+$/g,"")}/`}s(E,"normalizedBase");function D(t){let n=j(t);if(n.startsWith("/")||/[?#\u0000-\u001f]/.test(n))throw new Error(`Invalid page path: "${t}"`);if(n.split("/").some(l=>l==="."||l===".."||l===""))throw new Error(`Invalid page path: "${t}"`);let r=v(n),i=/^index$/i.test(r)?"":r.replace(/\/index$/i,"");return i?i.split("/"):[]}s(D,"pageSegments");function U(t){return D(t).map(n=>encodeURIComponent(n)).join("/")}s(U,"pageRoute");function P(t){return D(t).join("/")}s(P,"pageOutputPath");function x(t,n,e="/"){let r=E(e);return t===n?r:`${r}${t}/`}s(x,"localeRootPath");function M(t,n,e="/"){return[E(e).replace(/^\/|\/$/g,""),t===n?"":t].filter(Boolean).join("/")}s(M,"localeOutputPrefix");function Co(t,n,e,r="/"){let i=U(e);return i?`${x(t,n,r)}${i}/`:x(t,n,r)}s(Co,"routePathFor");function vo(t,n,e,r="/"){let i=P(e),l=M(t,n,r);return i?u.join(l,i,"index.html"):u.join(l,"index.html")}s(vo,"htmlOutputPathFor");function To(t,n,e,r="/"){let i=P(e),l=M(t,n,r);return i?u.join(l,i,"index.md"):u.join(l,"index.md")}s(To,"markdownOutputPathFor");function xo(t){let n=p(t).replace(/^\/+|\/+$/g,"");return n?u.join(...n.split("/").map(e=>decodeURIComponent(e)),"index.html"):"index.html"}s(xo,"routeOutputPathFor");var h={logo:"/assets/canofold-brand/logo-light.webp",logoDark:"/assets/canofold-brand/logo-dark.webp",favicon:"/assets/canofold-brand/favicon.webp"},Po=Object.values(h).map(t=>t.slice(1));var O={title:"Canofold",description:"Technical documentation",basePath:"/",docsDir:"docs",outputDir:".canofold/dist",styles:[],demos:{},layout:{header:!0},markdown:{html:"sanitize",code:{},features:{},labels:{},plugins:[]},theme:{accentColor:"canofold",darkMode:!1,radius:8,baseColor:"paper",sidebarWidth:"17.5rem",outlineWidth:"18.75rem",logo:h.logo,logoDark:h.logoDark,favicon:h.favicon,tokens:{}},search:{enabled:!0,provider:"compact"},extensions:[],navigation:{},versions:{current:"current",items:[{id:"current",label:"Current",docsDir:"docs",base:"/"}]},redirects:{},i18n:{defaultLocale:"zh",locales:["zh"],localeNames:{},messages:{}},ai:{llmsTxt:!0,llmsFullTxt:!0,markdownIndex:!0,pageSummaries:!0,codeExamples:!0,chunkSizeBytes:256*1024,llmsFullMaxBytes:10*1024*1024,llmsFullOverflow:"manifest",versions:"current"}};import{z as o}from"zod";var z=["paper","neutral","slate","zinc","stone"];import{z as N}from"zod";var m=N.string().min(1).refine(t=>{if(t.startsWith("/")){if(t.startsWith("//"))return!1;try{return p(t),!0}catch{return!1}}try{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},"Resource must be an absolute site path or HTTPS URL").transform(t=>t.startsWith("/")?f(t):t);var I=o.object({canvas:o.string().optional(),foreground:o.string().optional(),text:o.string().optional(),muted:o.string().optional(),mutedSubtle:o.string().optional(),surface:o.string().optional(),surfaceSecondary:o.string().optional(),surfaceSoft:o.string().optional(),surfaceElevated:o.string().optional(),border:o.string().optional(),borderStrong:o.string().optional(),hairline:o.string().optional(),primary:o.string().optional(),primarySoft:o.string().optional(),primaryForeground:o.string().optional(),primaryDeep:o.string().optional(),accent:o.string().optional(),info:o.string().optional(),infoDeep:o.string().optional(),success:o.string().optional(),successDeep:o.string().optional(),warning:o.string().optional(),warningDeep:o.string().optional(),danger:o.string().optional(),dangerDeep:o.string().optional(),codeBackground:o.string().optional(),codeForeground:o.string().optional(),overlay:o.string().optional(),shadow:o.string().optional(),shadowSmall:o.string().optional()}).strict().optional(),_=o.object({displayFont:o.string().min(1).optional(),sansFont:o.string().min(1).optional(),monoFont:o.string().min(1).optional(),bodySize:o.string().min(1).optional(),bodyLineHeight:o.string().min(1).optional(),headingLineHeight:o.string().min(1).optional(),heading1Size:o.string().min(1).optional(),heading2Size:o.string().min(1).optional(),heading3Size:o.string().min(1).optional(),heading4Size:o.string().min(1).optional(),heading5Size:o.string().min(1).optional(),heading6Size:o.string().min(1).optional()}).strict().optional(),G=o.object({readingWidth:o.string().min(1).optional(),contentWidth:o.string().min(1).optional(),gutter:o.string().min(1).optional()}).strict().optional(),B=o.object({radiusSmall:o.string().min(1).optional(),radiusMedium:o.string().min(1).optional(),radiusLarge:o.string().min(1).optional(),radiusFull:o.string().min(1).optional()}).strict().optional(),W=o.object({durationFast:o.string().min(1).optional(),durationNormal:o.string().min(1).optional(),easing:o.string().min(1).optional()}).strict().optional(),H=o.object({colors:o.object({light:I,dark:I}).strict().optional(),typography:_,layout:G,geometry:B,motion:W}).strict(),Z=o.object({themes:o.object({light:o.string().min(1).optional(),dark:o.string().min(1).optional()}).strict().optional(),fallbackLanguage:o.string().min(1).optional(),unknownLanguage:o.enum(["warn","error","plain-text"]).optional()}).strict(),V=o.object({callouts:o.boolean().optional(),tabs:o.boolean().optional(),codeGroups:o.boolean().optional(),steps:o.boolean().optional(),terminals:o.boolean().optional(),documentBlocks:o.boolean().optional(),tables:o.boolean().optional(),codeBlocks:o.boolean().optional()}).strict(),R=o.object({copyCode:o.string().optional(),copyFailed:o.string().optional(),copySnippet:o.string().optional(),copyTerminal:o.string().optional(),terminalTitle:o.string().optional(),tabsTitle:o.string().optional(),tabItem:o.string().optional(),codeGroupTitle:o.string().optional(),codeGroupItem:o.string().optional(),taskCompleted:o.string().optional(),taskIncomplete:o.string().optional(),copySectionLink:o.string().optional(),tableTitle:o.string().optional(),copyTableCsv:o.string().optional(),downloadTableCsv:o.string().optional(),zoomTable:o.string().optional(),closeTablePreview:o.string().optional(),sortTableColumn:o.string().optional(),zoomImage:o.string().optional(),closeImagePreview:o.string().optional(),imageGallery:o.string().optional(),closeImageGallery:o.string().optional(),previousGalleryImage:o.string().optional(),nextGalleryImage:o.string().optional(),galleryThumbnails:o.string().optional(),galleryImage:o.string().optional()}).strict(),q=o.object({skipToContent:o.string().optional(),search:o.string().optional(),searchEmpty:o.string().optional(),searchUnavailable:o.string().optional(),language:o.string().optional(),primaryNavigation:o.string().optional(),theme:o.string().optional(),openSidebar:o.string().optional(),onThisPage:o.string().optional(),edit:o.string().optional(),updated:o.string().optional(),previous:o.string().optional(),next:o.string().optional(),close:o.string().optional(),source:o.string().optional(),preview:o.string().optional(),copySource:o.string().optional(),sourceCopied:o.string().optional(),quickActions:o.string().optional(),github:o.string().optional(),docsNavigation:o.string().optional(),pageNavigation:o.string().optional(),advertisement:o.string().optional(),version:o.string().optional()}).strict(),K=o.object({headingsTitle:o.string().optional(),headingsDescription:o.string().optional(),codeTitle:o.string().optional(),codeDescription:o.string().optional(),tableTitle:o.string().optional(),tableDescription:o.string().optional(),diagramTitle:o.string().optional(),diagramDescription:o.string().optional(),sourceDescription:o.string().optional(),themeDescription:o.string().optional()}).strict(),J=o.object({title:o.string().optional(),description:o.string().optional(),home:o.string().optional()}).strict(),c=o.object({label:o.string().optional(),detail:o.string().optional(),hash:o.string().optional()}).strict(),Q=o.object({headings:c.optional(),inline:c.optional(),lists:c.optional(),callouts:c.optional(),code:c.optional(),tables:c.optional(),media:c.optional(),diagrams:c.optional(),disclosure:c.optional(),extensions:c.optional(),api:c.optional(),metadata:c.optional()}).strict(),X=o.object({labels:q.optional(),brandTagline:o.string().optional(),quickActions:K.optional(),markdownElementGroups:Q.optional(),markdown:R.optional(),notFound:J.optional()}).strict(),b=o.string().min(1).refine(t=>{try{return p(t),!0}catch{return!1}},"Route must be a safe absolute path").transform(f),k=o.string().url().refine(t=>{let n=new URL(t);return(n.protocol==="https:"||n.protocol==="http:")&&!n.username&&!n.password&&!n.search&&!n.hash},"URL must use HTTP(S) without credentials, a query, or a hash"),Y=k.refine(t=>new URL(t).pathname==="/",{message:"siteUrl must be an HTTP(S) origin without a path"}),L=o.string().min(1).regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,"Version id must be a safe portable slug"),oo=o.object({enabled:o.boolean().optional(),provider:o.union([o.literal("compact"),o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.id=="string"&&(t.client==="compact"||t.client==="pagefind")&&typeof t.write=="function","search.provider must be compact or a SearchProvider object")]).optional()}).strict(),to=o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.prepare=="function"&&(t.startDev===void 0||typeof t.startDev=="function"),"demos.engine must be a Canofold demo engine object"),S=o.lazy(()=>o.union([o.string(),o.number().finite(),o.boolean(),o.null(),o.array(S),o.record(o.string(),S)])),no=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,eo=o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.name=="string"&&no.test(t.name),"markdown.plugins entries must be plugin objects with a lowercase kebab-case name"),io=o.object({resolve:o.string().min(1).regex(/^\.[\\/]/,"Extension resolve must be a project-relative path beginning with ./"),options:o.record(o.string(),S).optional()}).strict(),F=o.object({title:o.string().min(1).optional(),description:o.string().optional(),siteUrl:Y.optional(),basePath:b.refine(t=>t.endsWith("/"),"basePath must end with /").optional(),editUrl:k.optional(),github:k.optional(),requiredVersion:o.string().optional(),docsDir:o.string().optional(),outputDir:o.string().optional(),styles:o.array(o.string().min(1)).optional(),demos:o.object({engine:to.optional(),setup:o.string().min(1).optional()}).strict().optional(),layout:o.object({header:o.boolean().optional()}).strict().optional(),markdown:o.object({html:o.enum(["trusted","sanitize","strip"]).optional(),code:Z.optional(),features:V.optional(),labels:R.optional(),plugins:o.array(eo).optional()}).strict().optional(),theme:o.object({logo:m.optional(),logoDark:m.optional(),favicon:m.optional(),accentColor:o.string().optional(),darkMode:o.boolean().optional(),radius:o.union([o.number(),o.string()]).optional(),baseColor:o.enum(z).optional(),sidebarWidth:o.union([o.number(),o.string()]).optional(),outlineWidth:o.union([o.number(),o.string()]).optional(),tokens:H.optional()}).strict().optional(),search:oo.optional(),extensions:o.array(io).optional(),navigation:o.record(o.string(),o.array(o.object({text:o.string().min(1),link:m}).strict())).optional(),versions:o.object({current:L,items:o.array(o.object({id:L,label:o.string().min(1),docsDir:o.string().min(1),base:b}).strict()).min(1)}).strict().optional(),redirects:o.record(b,b).optional(),advertising:o.object({image:m,href:m,alt:o.string().min(1),label:o.string().min(1).optional()}).strict().optional(),i18n:o.object({defaultLocale:o.string().optional(),locales:o.array(o.string().min(1)).min(1).optional(),localeNames:o.record(o.string(),o.string().min(1)).optional(),messages:o.record(o.string(),X).optional()}).strict().optional(),ai:o.object({llmsTxt:o.boolean().optional(),llmsFullTxt:o.boolean().optional(),markdownIndex:o.boolean().optional(),pageSummaries:o.boolean().optional(),codeExamples:o.boolean().optional(),chunkSizeBytes:o.number().int().min(16*1024).max(4*1024*1024).optional(),llmsFullMaxBytes:o.number().int().min(16*1024).max(1024*1024*1024).optional(),llmsFullOverflow:o.enum(["manifest","error"]).optional(),versions:o.enum(["current","all"]).optional()}).strict().optional()}).strict();var go=["canofold.config.ts","canofold.config.mts","canofold.config.cts","canofold.config.js","canofold.config.mjs","canofold.config.cjs"];function $(){return structuredClone(O)}s($,"cloneDefaultConfig");function uo(t){let n=$(),e=t.docsDir??n.docsDir,r=t.versions?{current:t.versions.current,items:t.versions.items.map(a=>({...a}))}:{current:"current",items:[{id:"current",label:"Current",docsDir:e,base:"/"}]},i=r.items.find(a=>a.id===r.current)?.docsDir??e,l={...n,...t,docsDir:i,styles:t.styles?[...t.styles]:n.styles,demos:{engine:t.demos?.engine??n.demos.engine,setup:t.demos?.setup??n.demos.setup},layout:{header:t.layout?.header??n.layout.header},markdown:{html:t.markdown?.html??n.markdown.html,code:{...n.markdown.code,...t.markdown?.code,themes:{...n.markdown.code.themes,...t.markdown?.code?.themes}},features:{...n.markdown.features,...t.markdown?.features},labels:{...n.markdown.labels,...t.markdown?.labels},plugins:t.markdown?.plugins?[...t.markdown.plugins]:n.markdown.plugins},theme:{...n.theme,...t.theme,tokens:{colors:{light:{...n.theme.tokens.colors?.light,...t.theme?.tokens?.colors?.light},dark:{...n.theme.tokens.colors?.dark,...t.theme?.tokens?.colors?.dark}},typography:{...n.theme.tokens.typography,...t.theme?.tokens?.typography},layout:{...n.theme.tokens.layout,...t.theme?.tokens?.layout},geometry:{...n.theme.tokens.geometry,...t.theme?.tokens?.geometry},motion:{...n.theme.tokens.motion,...t.theme?.tokens?.motion}}},search:{enabled:t.search?.enabled??n.search.enabled,provider:t.search?.provider??n.search.provider},extensions:(t.extensions??n.extensions).map(a=>({...a,...a.options?{options:structuredClone(a.options)}:{}})),navigation:Object.fromEntries(Object.entries(t.navigation??n.navigation).map(([a,d])=>[a,d.map(g=>({...g}))])),versions:r,redirects:{...n.redirects,...t.redirects},...t.advertising?{advertising:{...t.advertising}}:{},i18n:{...n.i18n,...t.i18n,locales:t.i18n?.locales?[...t.i18n.locales]:n.i18n.locales,localeNames:{...n.i18n.localeNames,...t.i18n?.localeNames},messages:{...n.i18n.messages,...t.i18n?.messages}},ai:{...n.ai,...t.ai}};return t.theme?.logo&&!t.theme.logoDark&&delete l.theme.logoDark,l}s(uo,"mergeConfig");function fo(t){let{defaultLocale:n,locales:e,localeNames:r={},messages:i={}}=t.i18n;if(!e.includes(n))throw new Error(`i18n.defaultLocale "${n}" must be included in i18n.locales`);if(new Set(e.map(a=>a.toLowerCase())).size!==e.length)throw new Error("i18n.locales must not contain duplicate locales");for(let a of e)try{Intl.getCanonicalLocales(a)}catch{throw new Error(`Invalid locale identifier in i18n.locales: "${a}"`)}let l=new Set(e);for(let a of[...Object.keys(r),...Object.keys(i)])if(!l.has(a))throw new Error(`i18n resource key "${a}" must be included in i18n.locales`);for(let a of Object.keys(t.navigation))if(!l.has(a))throw new Error(`navigation key "${a}" must be included in i18n.locales`)}s(fo,"assertI18nConfig");function ho(t){let n=t.versions.items.map(i=>i.id),e=t.versions.items.map(i=>i.base);if(!n.includes(t.versions.current))throw new Error(`versions.current "${t.versions.current}" must match a versions.items id`);if(new Set(n.map(y)).size!==n.length)throw new Error("versions.items must not contain portable-duplicate version ids");if(new Set(e.map(y)).size!==e.length)throw new Error("versions.items must not contain duplicate bases");for(let i of t.versions.items){try{p(i.base)}catch{throw new Error(`Version base "${i.base}" must be a safe absolute route ending in /`)}if(!i.base.endsWith("/")||i.base.includes("//"))throw new Error(`Version base "${i.base}" must be an absolute path ending in /`)}if(t.versions.items.find(i=>i.id===t.versions.current)?.base!=="/")throw new Error('The current documentation version must use base "/"')}s(ho,"assertVersionConfig");function bo(t){if(t.docsDir!==void 0&&t.versions!==void 0)throw new Error("docsDir cannot be combined with versions; set docsDir on each versions.items entry");if(t.theme?.logoDark&&!t.theme.logo)throw new Error("theme.logoDark requires theme.logo");if(t.theme?.logoDark&&t.theme.darkMode!==!0)throw new Error("theme.logoDark requires theme.darkMode: true")}s(bo,"assertEffectiveInput");async function wo(t){let n=[];for(let e of go){let r=w(t,e);await T(r)&&n.push(r)}if(n.length>1)throw new Error(`Multiple Canofold configuration files found: ${n.map(e=>e.split(/[\\/]/).at(-1)).join(", ")}`);return n[0]}s(wo,"findConfigPath");async function Qo(t){let n=await wo(t);if(!n)return $();let e=w(t,".canofold/tmp");await ao(e,{recursive:!0});let r=await so(w(e,"config-")),i=w(r,`${ro()}.mjs`),l;try{let g;try{g=A(import.meta.resolve("canofold"))}catch{g=A(new URL("../index.ts",import.meta.url))}let C=(await mo({entryPoints:[n],absWorkingDir:t,alias:{canofold:g},bundle:!0,format:"esm",platform:"node",target:"node22",external:["@canofold/plugins","@canofold/vite"],write:!1,sourcemap:"inline"})).outputFiles[0];if(!C)throw new Error("Failed to bundle canofold.config.ts");await co(i,C.contents),l=await import(`${po(i).href}?t=${Date.now()}`)}finally{await lo(r,{recursive:!0,force:!0})}let a=F.parse(l.default??{});bo(a);let d=uo(a);return fo(d),ho(d),d}s(Qo,"loadConfig");export{So as a,f as b,x as c,Co as d,vo as e,To as f,xo as g,h,Po as i,m as j,wo as k,Qo as l};
|
|
2
|
-
//# sourceMappingURL=chunk-ACUMTEQL.js.map
|