canofold 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/README.zh-CN.md +33 -0
- package/dist/build-RBMQ6TZ7.js +2 -0
- package/dist/check-FCYLN6KO.js +3 -0
- package/dist/chunk-3TIVCYR7.js +2 -0
- package/dist/chunk-4E7M3CIK.js +6 -0
- package/dist/chunk-4OALGQQB.js +2 -0
- package/dist/chunk-56TT2V3X.js +664 -0
- package/dist/chunk-AYDF3IFZ.js +2 -0
- package/dist/chunk-EAYVCA3Z.js +2 -0
- package/dist/chunk-ENPRUF6E.js +2 -0
- package/dist/chunk-JK7ZNBUA.js +2 -0
- package/dist/chunk-JZIKHPBO.js +45 -0
- package/dist/chunk-M6T5RSNJ.js +2 -0
- package/dist/chunk-OATSOVSV.js +3 -0
- package/dist/chunk-XYJ2OBL3.js +2 -0
- package/dist/clean-74GN2NZC.js +2 -0
- package/dist/cli.js +17 -0
- package/dist/deploy-4YUYRVRO.js +144 -0
- package/dist/dev-WJCFAWYD.js +2 -0
- package/dist/index.js +2 -0
- package/dist/init-6R5SLESH.js +71 -0
- package/dist/load-W4JHZIBF.js +2 -0
- package/dist/playground-client.js +2 -0
- package/dist/preview-ODXGCQZ7.js +2 -0
- package/dist/search-client.js +2 -0
- package/dist/styles.input.css +1739 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Canofold Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Canofold
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
`canofold` is the CLI for the Canofold knowledge and documentation platform. It reads Markdown, MDX, and project-local React components, then builds navigation, search, multilingual routes, versioned pages, and AI-ready knowledge output into deployable static HTML.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Node.js 22 or newer is required. Install Canofold as a project-local development dependency:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -D canofold
|
|
13
|
+
pnpm exec canofold init --locale en
|
|
14
|
+
pnpm exec canofold dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`init` creates `docs/` and a typed `canofold.config.ts`. Add the commands you use regularly to `package.json`; use `pnpm exec canofold ...` for an ad-hoc local invocation.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
- `init` creates or adopts a documentation project.
|
|
22
|
+
- `dev` starts the development server.
|
|
23
|
+
- `check` validates configuration, content, routes, and plugin-owned syntax.
|
|
24
|
+
- `build` writes the production site to `.canofold/dist/`.
|
|
25
|
+
- `preview` serves the production output locally.
|
|
26
|
+
- `clean` removes generated output and persistent build state.
|
|
27
|
+
- `deploy` writes deployment guidance for the current project.
|
|
28
|
+
|
|
29
|
+
Canofold is a build tool, not a sandbox. MDX, local components, configuration, and extensions execute with build-process permissions and must come from reviewed sources.
|
|
30
|
+
|
|
31
|
+
See the [Canofold documentation](https://canofold.dev/en/guide/) for authoring, configuration, deployment, and troubleshooting.
|
|
32
|
+
|
|
33
|
+
License: MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Canofold
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
`canofold` 是 Canofold 知识文档平台的 CLI。它读取 Markdown、MDX 和项目本地 React 组件,生成导航、搜索、多语言路由、版本页面和 AI-ready 知识输出,最终产出可直接部署的静态 HTML。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
要求 Node.js 22 或更高版本。建议把 Canofold 安装为项目本地开发依赖:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add -D canofold
|
|
13
|
+
pnpm exec canofold init
|
|
14
|
+
pnpm exec canofold dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`init` 会创建 `docs/` 和带类型提示的 `canofold.config.ts`。常用命令应写进 `package.json`;临时调用本地版本时使用 `pnpm exec canofold ...`。
|
|
18
|
+
|
|
19
|
+
## 命令
|
|
20
|
+
|
|
21
|
+
- `init` 创建文档项目或接管已有文档。
|
|
22
|
+
- `dev` 启动开发服务器。
|
|
23
|
+
- `check` 检查配置、内容、路由和插件拥有的语法。
|
|
24
|
+
- `build` 把生产站点写入 `.canofold/dist/`。
|
|
25
|
+
- `preview` 在本地预览生产产物。
|
|
26
|
+
- `clean` 删除生成产物和持久化构建状态。
|
|
27
|
+
- `deploy` 根据当前项目生成部署说明。
|
|
28
|
+
|
|
29
|
+
Canofold 是构建工具,不是沙箱。MDX、本地组件、配置和 Extension 都会以构建进程的权限执行,只能使用经过审核的源码。
|
|
30
|
+
|
|
31
|
+
使用方法、配置、部署和故障排查见 [Canofold 文档](https://canofold.dev/guide/)。
|
|
32
|
+
|
|
33
|
+
许可证:MIT
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-56TT2V3X.js";import"./chunk-4E7M3CIK.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-OATSOVSV.js";import"./chunk-4OALGQQB.js";import"./chunk-M6T5RSNJ.js";import"./chunk-3TIVCYR7.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{b as runBuild,a as versionSatisfies};
|
|
2
|
+
//# sourceMappingURL=build-RBMQ6TZ7.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{e as I,j as b,k as M}from"./chunk-4E7M3CIK.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as C,b as S,j as P}from"./chunk-4OALGQQB.js";import"./chunk-3TIVCYR7.js";import"./chunk-EAYVCA3Z.js";import{d as $}from"./chunk-JK7ZNBUA.js";import{a}from"./chunk-AYDF3IFZ.js";import{mkdtemp as W,readdir as V,rm as N}from"fs/promises";import{tmpdir as Q}from"os";import{join as O,relative as K}from"path";import{posix as y}from"path";import{analyzeMarkdown as w}from"@canofold/markdown/server/analyze";function E(e){return Array.from({length:w(e).missingCodeBlockLanguages},()=>({severity:"warning",message:"Code block is missing a language"}))}a(E,"checkCodeBlockLanguages");function H(e,n=0,o=[]){return w(e,{plugins:o}).directiveIssues.map(r=>({severity:"error",message:`${r.message}${r.line===void 0?"":` (line ${r.line+n}${r.column===void 0?"":`, column ${r.column}`})`}`}))}a(H,"checkRichDirectiveSyntax");function R(e){return typeof e.description=="string"&&e.description.trim()?[]:[{severity:"warning",message:"Frontmatter description is missing"}]}a(R,"checkFrontmatterDescription");function B(e,n){return typeof e.title=="string"&&e.title.trim()?[]:[{severity:"warning",page:n.relativePath,message:"Frontmatter title is missing"}]}a(B,"checkFrontmatterTitle");function L(e){return/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)}a(L,"isExternalTarget");function D(e){let n=e.indexOf("#"),o=n===-1?e:e.slice(0,n),r=n===-1?"":e.slice(n+1);return{path:o.split("?")[0]??"",fragment:r}}a(D,"splitTarget");function A(e){try{return decodeURIComponent(e)}catch{return}}a(A,"decodeFragment");function F(e,n){let o=n.split("/").map(r=>{let i=decodeURIComponent(r);if(i.includes("/")||i.includes("\\"))throw new Error("Encoded path separator");return i}).join("/");return y.normalize(y.join(y.dirname(e),o.replace(/^\.\//,"")))}a(F,"resolveRelativeTarget");function j(e){try{return`public${e.split("/").map(o=>{let r=decodeURIComponent(o);if(r.includes("/")||r.includes("\\")||r==="..")throw new Error("Invalid public path");return r}).join("/")}`}catch{return}}a(j,"publicFileFor");function T(e){return e.replace(/\.(?:md|mdx)$/i,n=>n.toLocaleLowerCase("en-US"))}a(T,"markdownExtensionKey");function z(e,n,o="",r=new Set,i=new Set,g=new Map,u=new Map,f=new Set){let c=[],k=w(e),h=new Map([...n].filter(t=>/\.(?:md|mdx)$/i.test(t)).map(t=>[T(t),t]));for(let t of k.images){let s=D(t).path;if(!s||L(s))continue;if(s.startsWith("/")){n.has(j(s)??"")||c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}let d;try{d=F(o,s)}catch{c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}n.has(d)||c.push({severity:"error",message:`Image target does not exist: ${s}`})}for(let t of k.links){let{path:s,fragment:d}=D(t),p=A(d);if(L(s))continue;if(!s){d&&(!p||!i.has(p))&&c.push({severity:"error",message:`Heading target does not exist: #${d}`});continue}if(s.startsWith("/")){if(n.has(j(s)??""))continue;let m;try{m=S(s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}if(f.has(m))continue;let x=m==="/"?"/":`${m.replace(/\/+$/,"")}/`;r.has(x)?d&&(!p||!g.get(x)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let l;try{l=F(o,s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let v=(/\.mdx?$/i.test(l)?[l]:[l,`${l}.md`,`${l}.mdx`,y.join(l,"index.md"),y.join(l,"index.mdx")]).map(m=>n.has(m)?m:h.get(T(m))).find(m=>!!m);v?d&&(!p||!u.get(v)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`})}return c}a(z,"checkLinksAndImages");function U(e){let n=new Map;for(let o of e.headings){let r=o.text.normalize("NFKC").replace(/\s+/g," ").trim().toLocaleLowerCase(e.locale);r&&n.set(r,[...n.get(r)??[],o])}return[...n.values()].filter(o=>o.length>1).map(o=>{let r=o[0];return{severity:"warning",page:e.relativePath,message:`Repeated heading "${r.text}" uses numbered anchors (${o.map(i=>`#${i.slug}`).join(", ")})`}})}a(U,"checkDuplicateHeadings");function G(e){let n=new Map;for(let r of e.pages){let i=`${r.version}:${C(r.relativePath,r.locale)}`;n.set(i,(n.get(i)??new Set).add(r.locale))}let o=[];for(let[r,i]of n)for(let g of e.locales)if(!i.has(g)){let[u,...f]=r.split(":");o.push({severity:"warning",message:`Missing ${g} translation for ${f.join(":")} in version ${u}`})}return o}a(G,"checkMissingTranslations");async function q(e){let n=new Set;async function o(r){let i=await V(r,{withFileTypes:!0});for(let g of i){let u=O(r,g.name);if(g.isDirectory())await o(u);else{if(g.isSymbolicLink())throw new Error(`Documentation files must not use symbolic links: ${K(e,u)}`);n.add(K(e,u).replace(/\\/g,"/"))}}}return a(o,"walk"),await o(e),n}a(q,"collectFiles");function J(e){if(!e.body)return 0;let n=e.transformedSource.lastIndexOf(e.body);return n<0?0:e.transformedSource.slice(0,n).split(`
|
|
2
|
+
`).length-1}a(J,"bodyLineOffset");async function ue({cwd:e}){let n=await P(e),o=await W(O(Q(),"canofold-check-")),r=await M(e,o,n.extensions).finally(()=>N(o,{recursive:!0,force:!0})),i=await I(e,n,r),g=new Set([...b(n,i),...r.publicOutputPaths]),u=new Map(await Promise.all(n.versions.items.map(async t=>[t.id,await q($(e,t.docsDir,`versions.items[${t.id}].docsDir`))]))),f=new Set(i.pages.map(t=>t.routePath)),c=new Map(i.pages.map(t=>[t.routePath,new Set(t.headings.map(s=>s.slug))])),k=new Map(i.versions.map(t=>[t.id,new Map(i.pages.filter(s=>s.version===t.id).map(s=>[s.relativePath,new Set(s.headings.map(d=>d.slug))]))])),h=[...i.pages.flatMap(t=>[...E(t.body).map(s=>({...s,page:t.relativePath})),...H(t.body,J(t),n.markdown.plugins).map(s=>({...s,page:t.relativePath})),...B(t.frontmatter,t),...R(t.frontmatter).map(s=>({...s,page:t.relativePath})),...z(t.body,u.get(t.version)??new Set,t.relativePath,f,new Set(t.headings.map(s=>s.slug)),c,k.get(t.version),g).map(s=>({...s,page:t.sourceRelativePath})),...U(t)]),...G(i)];for(let t of h){let s=t.page?` ${t.page}`:"";console.log(`${t.severity.toUpperCase()}:${s} ${t.message}`)}return h.some(t=>t.severity==="error")&&(process.exitCode=1),h}a(ue,"runCheck");export{ue as runCheck};
|
|
3
|
+
//# sourceMappingURL=check-FCYLN6KO.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as X,b as Y,d as Q,f as E}from"./chunk-ENPRUF6E.js";import{a as R,b as W,d as K,e as q,f as B,g as k,h as O}from"./chunk-4OALGQQB.js";import{a as H}from"./chunk-3TIVCYR7.js";import{a as V,b as z,c as j}from"./chunk-EAYVCA3Z.js";import{a as I,b as P,d as U,e as _,f as J,h as v}from"./chunk-JK7ZNBUA.js";import{a as u}from"./chunk-AYDF3IFZ.js";import{analyzeMarkdown as Dt}from"@canofold/markdown/server/analyze";import jt from"gray-matter";import{join as It,posix as Rt}from"path";import{z as m}from"zod";var tt=["ai","box","code","file","file-code","gauge","globe","layers","rocket","search","sparkles","terminal"],Pt=m.object({text:m.string().min(1),link:O,primary:m.boolean().optional(),icon:m.enum(tt).optional()}).strict(),bt=m.object({accent:m.string().optional(),tagline:m.string().optional(),image:O.optional(),imageAlt:m.string().optional(),actions:m.array(Pt).refine(t=>t.filter(e=>e.primary).length<=1,{message:"Home page hero actions can contain at most one primary action"}).optional()}).strict(),Et=m.object({icon:m.enum(tt).optional(),image:O.optional(),title:m.string().min(1),details:m.string().min(1)}).strict(),$t=m.string().trim().refine(t=>m.string().date().safeParse(t).success||m.string().datetime({offset:!0}).safeParse(t).success,"Expected an ISO 8601 date"),Z=m.preprocess(t=>t instanceof Date?t.toISOString():t,$t.transform(t=>new Date(t).toISOString())),et=m.object({title:m.string().optional(),seoTitle:m.string().trim().min(1).optional(),description:m.string().optional(),createdAt:Z.optional(),updatedAt:Z.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:bt.optional(),features:m.array(Et).optional()}).passthrough();function le(t){return Object.fromEntries(["title","description","createdAt","updatedAt","order","group","subgroup","tags","owner"].flatMap(o=>t[o]===void 0?[]:[[o,t[o]]]))}u(le,"publicFrontmatterFor");import{readdir as St,readFile as Ct,stat as vt}from"fs/promises";import{join as kt,relative as nt}from"path";async function ot(t,e,o){if(!Number.isFinite(e)||e<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(e),t.length);if(await Promise.all(Array.from({length:l},async()=>{for(;n<t.length&&i===void 0;){let c=n++;try{r[c]=await o(t[c],c)}catch(p){i??=p}}})),i)throw i;return r}u(ot,"mapConcurrent");var Ot=32;async function rt(t){async function e(n){let i=[],l=[n];for(;l.length>0;){let c=l.pop();if(!c)continue;let p=await St(c,{withFileTypes:!0});for(let a of p){let s=kt(c,a.name);if(a.isSymbolicLink())throw new Error(`Documentation content must not use symbolic links: ${nt(t,s)}`);a.isDirectory()?l.push(s):a.isFile()&&V(a.name)&&i.push(s)}}return i}u(e,"walk");let o=await e(t);return(await ot(o,Ot,async n=>{let[i,l]=await Promise.all([vt(n),Ct(n,"utf8")]);return{path:nt(t,n),raw:l,mtimeMs:i.mtimeMs}})).sort((n,i)=>n.path.localeCompare(i.path))}u(rt,"scanMarkdownFiles");function it(t){return t.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}u(it,"humanize");function $(t){return j(R(t.relativePath,t.locale))}u($,"isLocaleHome");function Nt(t){return{type:"link",title:t.title||t.routePath,routePath:t.routePath}}u(Nt,"sidebarLink");function st(t){return R(t.relativePath,t.locale).split("/")}u(st,"pageSegments");function at(t){return st(t).slice(0,-1)}u(at,"pageDirectorySegments");function Tt(t){return j(st(t).at(-1)??"")}u(Tt,"isDirectoryIndex");function Ft(t){let e=new Map,o=new Map,r=new Map;for(let n of t)if(Tt(n)&&o.set(at(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($(n)||n.frontmatter.sidebar===!1)continue;let i=at(n),l=i[0]??"",c=o.get(l),p=l?typeof c?.frontmatter.group=="string"?c.frontmatter.group:c?.title||r.get(l)||it(l):"";if(typeof n.frontmatter.group=="string"&&n.frontmatter.group!==p)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${p}" and "${n.frontmatter.group}"`);let a=e.get(l);if(!a)a={segment:l,title:p,items:[]},e.set(l,a);else if(a.title!==p)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${a.title}" and "${p}"`);let s=a.items;for(let f=1;f<i.length;f+=1){let d=i[f];if(!d)continue;let g=i.slice(0,f+1).join("/"),h=o.get(g),w=f===1&&typeof n.frontmatter.subgroup=="string"?n.frontmatter.subgroup:void 0,y=(f===1&&typeof h?.frontmatter.subgroup=="string"?h.frontmatter.subgroup:void 0)??h?.title??w??it(d);if(w&&w!==y)throw new Error(`Inconsistent subgroup name for locale "${n.locale}" directory "${g}"`);let b=s.find(C=>C.type==="group"&&C.segment===d),x=b??{type:"group",segment:d,title:y,collapsed:h?.frontmatter.collapsed===!0,items:[]};b||s.push(x),s=x.items}s.push(Nt(n))}return[...e.values()]}u(Ft,"buildSidebar");function N(t){if(t.type==="link")return t;for(let e of t.items){let o=N(e);if(o)return o}}u(N,"firstSidebarLink");function At(t){return t.flatMap(e=>{let o=e.items[0]?N(e.items[0]):void 0;return e.title&&o?[{title:e.title,routePath:o.routePath}]:[]})}u(At,"buildAutomaticNav");function Gt(t,e){return!t.startsWith("/")||e.base==="/"?t:`${e.base}${t.replace(/^\//,"")}`}u(Gt,"versionedNavLink");function Mt(t,e){return t.map(o=>({title:o.text,routePath:Gt(o.link,e)}))}u(Mt,"buildConfiguredNav");function Lt(t,e){return t.map(o=>{if(!o.routePath.startsWith("/"))return o;let r=o.routePath.split("/").filter(Boolean),n=e.find(l=>l.segment&&r.at(-1)===l.segment&&r.length>0),i=n?.items[0]?N(n.items[0]):void 0;return i?{...o,routePath:i.routePath}:o})}u(Lt,"anchorConfiguredNavToSidebar");function Vt(t){let e=new Map;for(let o of t)for(let[r,n]of[["route",o.routePath],["output",o.outputPath],["markdown output",o.markdownOutputPath]]){let i=`${r}:${P(n)}`,l=e.get(i);if(l)throw new Error(`Duplicate ${r} target ${n} for ${l.sourceRelativePath} and ${o.sourceRelativePath}`);e.set(i,o)}}u(Vt,"assertUniquePageTargets");async function zt(t,e,o,r){let n=U(t,o.docsDir,`versions.items[${o.id}].docsDir`),i=await rt(n),l=[];for(let c of i){let p=c.path.split(/[\\/]/);if(p[0]==="public")continue;let a=p[0]&&e.i18n.locales.includes(p[0])?p[0]:void 0,s=a??e.i18n.defaultLocale,f=a?p.slice(1):p;if(f.length===0)continue;let d=f.join("/"),g=Rt.join(o.docsDir.replace(/\\/g,"/"),c.path.replace(/\\/g,"/")),h=r?await r.transformSource({source:c.raw,sourceRelativePath:g,relativePath:c.path.replace(/\\/g,"/"),kind:z(c.path)?"mdx":"markdown",version:o.id,locale:s}):c.raw,w=jt(h),y=et.parse(w.data),b=y.status??"published";if(b==="draft")continue;let x=Dt(w.content),C=typeof y.order=="number"&&Number.isFinite(y.order)?y.order:Number.MAX_SAFE_INTEGER,xt=c.path.replace(/\\/g,"/"),L={sourcePath:It(n,c.path),transformedSource:h,sourceRelativePath:g,relativePath:xt,version:o.id,versionBase:o.base,docsDir:o.docsDir,locale:s,routePath:K(s,e.i18n.defaultLocale,d,o.base),outputPath:q(s,e.i18n.defaultLocale,d,o.base),markdownOutputPath:B(s,e.i18n.defaultLocale,d,o.base),title:typeof y.title=="string"?y.title:x.headings[0]?.text??"",description:typeof y.description=="string"?y.description:"",order:C,group:f.length>1?f[0]??"":"",status:b,search:y.search!==!1,ai:y.ai!==!1,body:w.content,headings:x.headings,searchText:x.text,codeExamples:x.codeExamples,lastUpdated:y.updatedAt??new Date(c.mtimeMs).toISOString(),frontmatter:y};l.push(r?await r.extendPage(L):L)}return l}u(zt,"scanVersionPages");async function De(t,e,o){let r=[];for(let a of e.versions.items)for(let s of await zt(t,e,a,o))r.push(s);let n=new Map(e.versions.items.map((a,s)=>[a.id,s])),i=new Map(e.i18n.locales.map((a,s)=>[a,s]));r.sort((a,s)=>{let f=(n.get(a.version)??0)-(n.get(s.version)??0);if(f!==0)return f;let d=(i.get(a.locale)??0)-(i.get(s.locale)??0);if(d!==0)return d;let g=$(a),h=$(s);return g!==h?g?-1:1:a.order!==s.order?a.order-s.order:a.routePath.localeCompare(s.routePath)}),Vt(r);for(let a of e.versions.items)for(let s of e.i18n.locales)if(!r.some(f=>f.version===a.id&&f.locale===s&&$(f)))throw new Error(`Missing published home page for version "${a.id}" locale "${s}"`);for(let a of e.versions.items)for(let s of e.i18n.locales){let f=r.filter(d=>d.version===a.id&&d.locale===s&&!$(d));f.forEach((d,g)=>{let h=f[g-1],w=f[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={},c={};for(let a of e.versions.items){let s={},f={};l[a.id]=s,c[a.id]=f;for(let d of e.i18n.locales){let g=Ft(r.filter(h=>h.version===a.id&&h.locale===d));s[d]=g,f[d]=e.navigation[d]?Lt(Mt(e.navigation[d],a),g):At(g)}}let p=new Set(r.map(a=>a.routePath));for(let a of Object.values(c))for(let s of Object.values(a))for(let f of s)if(f.routePath.startsWith("/")&&!p.has(f.routePath))throw new Error(`Navigation target is not a generated page: "${f.routePath}"`);return{pages:r,sidebar:l,nav:c,locales:e.i18n.locales,defaultLocale:e.i18n.defaultLocale,versions:e.versions.items.map(a=>({...a})),currentVersion:e.versions.current}}u(De,"buildContentGraph");import{mkdir as Ut,writeFile as ct}from"fs/promises";import{dirname as _t,join as Jt}from"path";var Ht={"&":"&","<":"<",">":">",'"':""","'":"'"};function T(t){return t.replace(/[&<>"']/g,e=>Ht[e]??e)}u(T,"escapeHtml");function F(t){let e=t==="/"?"/":`${t.replace(/\/+$/,"")}/`;return W(e)}u(F,"normalizeRedirectRoute");function A(t,e){let o=new Set(e.pages.map(i=>F(i.routePath))),r=Object.entries(t.redirects).map(([i,l])=>[F(i),F(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(o.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(!o.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}u(A,"resolveRedirects");async function Ve(t,e,o){let r=A(e,o);if(r.length===0)return;let n=_(t,e.outputDir);for(let[i,l]of r){let c=v(n,k(i),"redirect route"),p=Y(e,l),a=T(p),s=T(X(e,l)??p),f=JSON.stringify(p).replace(/</g,"\\u003c"),d=`<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><link rel="canonical" href="${s}"><meta http-equiv="refresh" content="0;url=${a}"><script>location.replace(${f})</script></head><body><a href="${a}">Redirecting to ${a}</a></body></html>`;await Ut(_t(c),{recursive:!0}),await ct(c,d)}await ct(Jt(n,"redirects.json"),JSON.stringify(Object.fromEntries(r),null,2))}u(Ve,"writeRedirects");import{posix as ut}from"path";var Wt=new Set([".benchmark.json"]),Kt=["assets/canofold-markdown","assets/canofold-playground","assets/canofold-plugins","assets/fonts","pagefind","ai/content","extensions"];function lt(t){let e=new Map;for(let o of t){let r=P(o),n=Kt.find(l=>r===l||r.startsWith(`${l}/`));if(n)throw new Error(`Generated output uses reserved directory "${n}": "${o}"`);let i=e.get(r);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${o}"`);e.set(r,o)}for(let[o,r]of e){let n=ut.dirname(o);for(;n!==".";){let i=e.get(n);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${r}"`);n=ut.dirname(n)}}}u(lt,"assertGeneratedOutputPlan");function pt(t,e){let o=[".benchmark.json","404.html","assets/canofold.css","robots.txt","ai/pages.json","ai/manifest.json",...e.pages.flatMap(n=>[n.outputPath,n.markdownOutputPath])];if(t.search.enabled&&(o.push("assets/canofold-search.js"),Q(t.search.provider)==="compact"))for(let n of e.versions)for(let i of e.locales)o.push(n.id===e.currentVersion?`search/${i}.json`:`search/${n.id}/${i}.json`);t.siteUrl&&o.push("sitemap.xml"),t.ai.pageSummaries&&o.push("ai/summaries.json"),t.ai.codeExamples&&o.push("ai/code-examples.json"),t.ai.markdownIndex&&o.push("ai/index.md"),t.ai.llmsTxt&&o.push("llms.txt"),t.ai.llmsFullTxt&&o.push("llms-full.txt");let r=A(t,e);if(r.length){o.push("redirects.json");for(let[n]of r)o.push(k(n))}return{paths:o,redirects:r}}u(pt,"plannedOutputPaths");function qe(t,e){let{paths:o}=pt(t,e);return lt(o),new Set(o)}u(qe,"generatedOutputPaths");function Be(t,e){let{paths:o,redirects:r}=pt(t,e);return lt(o),new Set([...o.filter(n=>!Wt.has(n)).map(n=>`/${n.split("/").map(encodeURIComponent).join("/")}`),...r.map(([n])=>n)])}u(Be,"generatedPublicPaths");import{randomUUID as Bt}from"crypto";import{mkdir as mt,readFile as Xt,rm as Yt,writeFile as gt}from"fs/promises";import{dirname as Qt,join as ht,posix as wt,resolve as Zt}from"path";import{pathToFileURL as te}from"url";import{build as ee}from"esbuild";import{createHash as ft}from"crypto";function G(t,e){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(e.has(t))throw new TypeError("Fingerprint values must not be circular");let o=Object.getPrototypeOf(t);if(!Array.isArray(t)&&o!==Object.prototype&&o!==null)throw new TypeError("Fingerprint values must be JSON-serializable plain objects");e.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=>G(n,e))}let r=Object.entries(t).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>[n,G(i,e)]);return Object.fromEntries(r)}finally{e.delete(t)}}u(G,"canonicalValue");function qt(t){return JSON.stringify(G(t,new WeakSet))}u(qt,"stableJson");function S(t){return ft("sha256").update(qt(t)).digest("hex")}u(S,"fingerprint");function M(t){return ft("sha256").update(t).digest("hex")}u(M,"fingerprintBytes");var oe=new Set(["apiVersion","name","outputs","transformSource","extendPage","generate"]),ne=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"];function D(t){return t instanceof Error?t.message:String(t)}u(D,"errorMessage");function dt(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)}}u(dt,"extensionPage");function yt(t,e){if(!e||e.includes("\\")||e.startsWith("/")||e!==wt.normalize(e))throw new Error(`Extension "${t}" output must be a normalized relative POSIX path: "${e}"`);if(e.split("/").some(o=>o==="."||o===".."||!o))throw new Error(`Extension "${t}" output must not contain empty, . or .. segments: "${e}"`);return e}u(yt,"normalizeDeclaredOutput");function re(t,e){if(!t||typeof t!="object")throw new Error(`Extension ${e.resolve} must export an extension object or factory`);let o=t,r=Object.keys(o).find(n=>!oe.has(n));if(r)throw new Error(`Extension ${e.resolve} has unknown key "${r}"`);if(o.apiVersion!==1)throw new Error(`Extension ${e.resolve} uses unsupported apiVersion ${String(o.apiVersion)}; expected ${1}`);if(typeof o.name!="string"||!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(o.name))throw new Error(`Extension ${e.resolve} name must be a lowercase portable slug`);for(let n of["transformSource","extendPage","generate"])if(o[n]!==void 0&&typeof o[n]!="function")throw new Error(`Extension "${o.name}" hook ${n} must be a function`);if(o.outputs!==void 0&&!Array.isArray(o.outputs))throw new Error(`Extension "${o.name}" outputs must be an array`);if(o.generate&&!o.outputs?.length)throw new Error(`Extension "${o.name}" with generate() must declare outputs`);if(!o.generate&&o.outputs?.length)throw new Error(`Extension "${o.name}" declares outputs without generate()`);return o}u(re,"assertDefinition");function ie(t,e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Extension "${t}" extendPage() must return an object or undefined`);let o=new Set(["title","description","searchText","search","ai"]),r=Object.keys(e).find(i=>!o.has(i));if(r)throw new Error(`Extension "${t}" extendPage() returned unknown key "${r}"`);let n=e;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 e}u(ie,"assertPagePatch");async function ae(t){let e=[];for(let o of ne){let r=ht(t,o);await I(r)&&e.push({path:o,fingerprint:M(await Xt(r))})}return S(e)}u(ae,"lockfileFingerprint");async function se(t,e,o){let r=Zt(t,o.resolve);if(await J(t,r,`extension ${o.resolve}`),!await I(r))throw new Error(`Extension module not found: ${o.resolve}`);let i=(await ee({entryPoints:[r],bundle:!0,format:"esm",platform:"node",target:"node22",write:!1,sourcemap:"inline",plugins:[{name:"canofold-extension-api",setup(c){c.onResolve({filter:/^canofold$/},()=>({path:"canofold-extension-api",namespace:"canofold-extension-api"})),c.onLoad({filter:/.*/,namespace:"canofold-extension-api"},()=>({loader:"js",contents:`
|
|
2
|
+
export const CANOFOLD_EXTENSION_API_VERSION = ${JSON.stringify(1)}
|
|
3
|
+
export const canofoldVersion = ${JSON.stringify(H)}
|
|
4
|
+
export const defineExtension = (factory) => factory
|
|
5
|
+
`}))}}]})).outputFiles[0];if(!i)throw new Error(`Failed to bundle extension ${o.resolve}`);await mt(e,{recursive:!0});let l=ht(e,`extension-${Bt()}.mjs`);await gt(l,i.contents);try{let p=(await import(`${te(l).href}?t=${Date.now()}`)).default,a=typeof p=="function"?await p(structuredClone(o.options??{})):p,s=re(a,o),f=(s.outputs??[]).map(d=>yt(s.name,d));if(new Set(f.map(P)).size!==f.length)throw new Error(`Extension "${s.name}" declares duplicate portable output paths`);return{definition:s,declaredOutputs:new Set(f),fingerprint:S({descriptor:o,bundle:M(i.contents)})}}finally{await Yt(l,{force:!0})}}u(se,"loadOneExtension");async function lo(t,e,o){let r=[];for(let c of o)try{r.push(await se(t,e,c))}catch(p){throw new Error(`Failed to load extension ${c.resolve}: ${D(p)}`,{cause:p})}let n=new Set;for(let c of r){if(n.has(c.definition.name))throw new Error(`Duplicate extension name "${c.definition.name}"`);n.add(c.definition.name)}let i=r.length?await ae(t):S({lockfiles:[]}),l=r.flatMap(({definition:c,declaredOutputs:p})=>[...p].map(a=>`/extensions/${c.name}/${a.split("/").map(encodeURIComponent).join("/")}`));return{fingerprint:S({apiVersion:1,dependencyFingerprint:i,extensions:r.map(c=>({name:c.definition.name,fingerprint:c.fingerprint}))}),publicOutputPaths:l,async transformSource(c){let p=c.source;for(let{definition:a}of r)if(a.transformSource)try{let s=await a.transformSource({...c,source:p});if(typeof s!="string")throw new Error("transformSource() must return a string");p=s}catch(s){throw new Error(`Extension "${a.name}" transformSource failed for ${c.sourceRelativePath}: ${D(s)}`,{cause:s})}return p},async extendPage(c){let p=c;for(let{definition:a}of r)if(a.extendPage)try{let s=ie(a.name,await a.extendPage(dt(p)));p={...p,...s}}catch(s){throw new Error(`Extension "${a.name}" extendPage failed for ${p.sourceRelativePath}: ${D(s)}`,{cause:s})}return p},async generate(c,p){for(let{definition:a,declaredOutputs:s}of r){if(!a.generate)continue;let f=new Set;try{await a.generate({pages:p.map(dt),emitFile:u(async(g,h)=>{let w=yt(a.name,g);if(!s.has(w))throw new Error(`generate() emitted undeclared output "${w}"`);if(f.has(w))throw new Error(`generate() emitted "${w}" more than once`);f.add(w);let y=v(c,wt.join("extensions",a.name,w),`extension ${a.name} output`);await mt(Qt(y),{recursive:!0}),await gt(y,h)},"emitFile")});let d=[...s].filter(g=>!f.has(g));if(d.length)throw new Error(`generate() did not emit declared outputs: ${d.join(", ")}`)}catch(d){throw new Error(`Extension "${a.name}" generate failed: ${D(d)}`,{cause:d})}}}}}u(lo,"loadExtensionHost");export{S as a,M as b,le as c,ot as d,De as e,T as f,Ve as g,Kt as h,qe as i,Be as j,lo as k};
|
|
6
|
+
//# sourceMappingURL=chunk-4E7M3CIK.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as C}from"./chunk-EAYVCA3Z.js";import{a as v,b as w}from"./chunk-JK7ZNBUA.js";import{a as s}from"./chunk-AYDF3IFZ.js";import{randomUUID as eo}from"crypto";import{mkdir as io,mkdtemp as ro,rm as ao,writeFile as so}from"fs/promises";import{join as f}from"path";import{fileURLToPath as R,pathToFileURL as lo}from"url";import{build as co}from"esbuild";import{posix as g}from"path";function j(t){return t.replace(/\\/g,"/")}s(j,"normalizeRoutePath");function yo(t,n){let e=j(t),r=e.split("/");return r[0]===n?r.slice(1).join("/"):e}s(yo,"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 u(t){return p(t),t.split("/").map(n=>n?encodeURIComponent(decodeURIComponent(n).normalize("NFC")):"").join("/")}s(u,"canonicalRoutePath");function T(t){let n=u(t);return n==="/"?"/":`/${n.replace(/^\/+|\/+$/g,"")}/`}s(T,"normalizedBase");function E(t){let n=j(t);if(n.startsWith("/")||/[?#\u0000-\u001f]/.test(n))throw new Error(`Invalid page path: "${t}"`);if(n.split("/").some(a=>a==="."||a===".."||a===""))throw new Error(`Invalid page path: "${t}"`);let r=C(n),i=/^index$/i.test(r)?"":r.replace(/\/index$/i,"");return i?i.split("/"):[]}s(E,"pageSegments");function U(t){return E(t).map(n=>encodeURIComponent(n)).join("/")}s(U,"pageRoute");function M(t){return E(t).join("/")}s(M,"pageOutputPath");function x(t,n,e="/"){let r=T(e);return t===n?r:`${r}${t}/`}s(x,"localeRootPath");function P(t,n,e="/"){return[T(e).replace(/^\/|\/$/g,""),t===n?"":t].filter(Boolean).join("/")}s(P,"localeOutputPrefix");function ko(t,n,e,r="/"){let i=U(e);return i?`${x(t,n,r)}${i}/`:x(t,n,r)}s(ko,"routePathFor");function So(t,n,e,r="/"){let i=M(e),a=P(t,n,r);return i?g.join(a,i,"index.html"):g.join(a,"index.html")}s(So,"htmlOutputPathFor");function Co(t,n,e,r="/"){let i=M(e),a=P(t,n,r);return i?g.join(a,i,"index.md"):g.join(a,"index.md")}s(Co,"markdownOutputPathFor");function vo(t){let n=p(t).replace(/^\/+|\/+$/g,"");return n?g.join(...n.split("/").map(e=>decodeURIComponent(e)),"index.html"):"index.html"}s(vo,"routeOutputPathFor");var z={title:"Canofold",description:"Technical documentation",basePath:"/",docsDir:"docs",outputDir:".canofold/dist",styles:[],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",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:262144,llmsFullMaxBytes:10485760,llmsFullOverflow:"manifest",versions:"current"}};import{z as o}from"zod";var O=["paper","neutral","slate","zinc","stone"];import{z as G}from"zod";var m=G.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("/")?u(t):t);var D=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(),N=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(),A=o.object({readingWidth:o.string().min(1).optional(),contentWidth:o.string().min(1).optional(),gutter:o.string().min(1).optional()}).strict().optional(),W=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(),B=o.object({durationFast:o.string().min(1).optional(),durationNormal:o.string().min(1).optional(),easing:o.string().min(1).optional()}).strict().optional(),_=o.object({colors:o.object({light:D,dark:D}).strict().optional(),typography:N,layout:A,geometry:W,motion:B}).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(),L=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(),H=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(),K=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(),J=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(),Q=o.object({labels:q.optional(),brandTagline:o.string().optional(),quickActions:H.optional(),markdownElementGroups:J.optional(),markdown:L.optional(),notFound:K.optional()}).strict(),h=o.string().min(1).refine(t=>{try{return p(t),!0}catch{return!1}},"Route must be a safe absolute path").transform(u),y=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"),X=y.refine(t=>new URL(t).pathname==="/",{message:"siteUrl must be an HTTP(S) origin without a path"}),I=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"),Y=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(),k=o.lazy(()=>o.union([o.string(),o.number().finite(),o.boolean(),o.null(),o.array(k),o.record(o.string(),k)])),oo=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,to=o.custom(t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&typeof t.name=="string"&&oo.test(t.name),"markdown.plugins entries must be plugin objects with a lowercase kebab-case name"),no=o.object({resolve:o.string().min(1).regex(/^\.[\\/]/,"Extension resolve must be a project-relative path beginning with ./"),options:o.record(o.string(),k).optional()}).strict(),F=o.object({title:o.string().min(1).optional(),description:o.string().optional(),siteUrl:X.optional(),basePath:h.refine(t=>t.endsWith("/"),"basePath must end with /").optional(),editUrl:y.optional(),github:y.optional(),requiredVersion:o.string().optional(),docsDir:o.string().optional(),outputDir:o.string().optional(),styles:o.array(o.string().min(1)).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:L.optional(),plugins:o.array(to).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(O).optional(),sidebarWidth:o.union([o.number(),o.string()]).optional(),outlineWidth:o.union([o.number(),o.string()]).optional(),tokens:_.optional()}).strict().optional(),search:Y.optional(),extensions:o.array(no).optional(),navigation:o.record(o.string(),o.array(o.object({text:o.string().min(1),link:m}).strict())).optional(),versions:o.object({current:I,items:o.array(o.object({id:I,label:o.string().min(1),docsDir:o.string().min(1),base:h}).strict()).min(1)}).strict().optional(),redirects:o.record(h,h).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(),Q).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 po=["canofold.config.ts","canofold.config.mts","canofold.config.cts","canofold.config.js","canofold.config.mjs","canofold.config.cjs"];function $(){return structuredClone(z)}s($,"cloneDefaultConfig");function mo(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;return{...n,...t,docsDir:i,styles:t.styles?[...t.styles]:n.styles,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,l])=>[a,l.map(d=>({...d}))])),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}}}s(mo,"mergeConfig");function go(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(l=>l.toLowerCase())).size!==e.length)throw new Error("i18n.locales must not contain duplicate locales");for(let l of e)try{Intl.getCanonicalLocales(l)}catch{throw new Error(`Invalid locale identifier in i18n.locales: "${l}"`)}let a=new Set(e);for(let l of[...Object.keys(r),...Object.keys(i)])if(!a.has(l))throw new Error(`i18n resource key "${l}" must be included in i18n.locales`);for(let l of Object.keys(t.navigation))if(!a.has(l))throw new Error(`navigation key "${l}" must be included in i18n.locales`)}s(go,"assertI18nConfig");function uo(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(w)).size!==n.length)throw new Error("versions.items must not contain portable-duplicate version ids");if(new Set(e.map(w)).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(uo,"assertVersionConfig");function ho(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(ho,"assertEffectiveInput");async function fo(t){let n=[];for(let e of po){let r=f(t,e);await v(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(fo,"findConfigPath");async function Vo(t){let n=await fo(t);if(!n)return $();let e=f(t,".canofold/tmp");await io(e,{recursive:!0});let r=await ro(f(e,"config-")),i=f(r,`${eo()}.mjs`),a;try{let b;try{b=R(import.meta.resolve("canofold"))}catch{b=R(new URL("../index.ts",import.meta.url))}let S=(await co({entryPoints:[n],absWorkingDir:t,alias:{canofold:b},bundle:!0,format:"esm",platform:"node",target:"node22",external:["@canofold/plugins"],write:!1,sourcemap:"inline"})).outputFiles[0];if(!S)throw new Error("Failed to bundle canofold.config.ts");await so(i,S.contents),a=await import(`${lo(i).href}?t=${Date.now()}`)}finally{await ao(r,{recursive:!0,force:!0})}let l=F.parse(a.default??{});ho(l);let d=mo(l);return go(d),uo(d),d}s(Vo,"loadConfig");export{yo as a,u as b,x as c,ko as d,So as e,Co as f,vo as g,m as h,fo as i,Vo as j};
|
|
2
|
+
//# sourceMappingURL=chunk-4OALGQQB.js.map
|