canofold 0.2.1 → 0.3.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/dist/brand/favicon.webp +0 -0
- package/dist/brand/logo-dark.webp +0 -0
- package/dist/brand/logo-light.webp +0 -0
- package/dist/build-UYV2L7WT.js +2 -0
- package/dist/check-SPGDVG46.js +3 -0
- package/dist/chunk-2XMX5JW6.js +2 -0
- package/dist/chunk-ACUMTEQL.js +2 -0
- package/dist/{chunk-7SYMF26J.js → chunk-EQOADO2H.js} +2 -2
- package/dist/chunk-HS5LEPRC.js +45 -0
- package/dist/chunk-KJ7FG6AY.js +6 -0
- package/dist/chunk-OKX7SQKX.js +671 -0
- package/dist/{clean-7ENN3I7K.js → clean-V2SP7IRD.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/demo-engine.d.ts +78 -0
- package/dist/demo-engine.js +1 -0
- package/dist/{deploy-4YUYRVRO.js → deploy-47AUDPYE.js} +2 -2
- package/dist/dev-3C4T3COS.js +2 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +1 -1
- package/dist/{init-5E5UEXP2.js → init-3PS74OVB.js} +3 -3
- package/dist/{load-W4JHZIBF.js → load-BG2H2Q65.js} +2 -2
- package/dist/{preview-ODXGCQZ7.js → preview-OAMF5HXH.js} +2 -2
- package/dist/styles.input.css +229 -3
- package/package.json +9 -4
- package/dist/build-7SEVEAYT.js +0 -2
- package/dist/check-NY3EVN5Q.js +0 -3
- package/dist/chunk-4OALGQQB.js +0 -2
- package/dist/chunk-B2QFU4ZW.js +0 -664
- package/dist/chunk-FCABZITC.js +0 -6
- package/dist/chunk-JZIKHPBO.js +0 -45
- package/dist/chunk-KUDMXVOM.js +0 -2
- package/dist/dev-AMVXGDVE.js +0 -2
|
@@ -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-EQOADO2H.js";import{l as m}from"./chunk-ACUMTEQL.js";import{a as n}from"./chunk-M6T5RSNJ.js";import"./chunk-2XMX5JW6.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-V2SP7IRD.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-3PS74OVB.js");return r({cwd:o,...h(n)})}if(t==="build"){let{runBuild:r}=await import("./build-UYV2L7WT.js");return r({cwd:o,...d(n)})}if(t==="clean"){a(n,1);let{runClean:r}=await import("./clean-V2SP7IRD.js");return r({cwd:o})}if(t==="dev"){let{runDev:r}=await import("./dev-3C4T3COS.js");return r({cwd:o,port:u(n)})}if(t==="preview"){let{runPreview:r}=await import("./preview-OAMF5HXH.js"),i=u(n);return r({cwd:o,port:i})}if(t==="check"){a(n,1);let{runCheck:r}=await import("./check-SPGDVG46.js");return r({cwd:o})}if(t==="deploy"){a(n,1);let{runDeploy:r}=await import("./deploy-47AUDPYE.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
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
|
|
3
|
+
type CanofoldDemoCacheValue = string | number | boolean | null | CanofoldDemoCacheValue[] | {
|
|
4
|
+
[key: string]: CanofoldDemoCacheValue;
|
|
5
|
+
};
|
|
6
|
+
type CanofoldDemoSandbox = 'inline' | 'iframe';
|
|
7
|
+
interface CanofoldDemoReference {
|
|
8
|
+
id: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
specifier: string;
|
|
12
|
+
sandbox: CanofoldDemoSandbox;
|
|
13
|
+
pageSourcePath: string;
|
|
14
|
+
pageSourceRelativePath: string;
|
|
15
|
+
routePath: string;
|
|
16
|
+
locale: string;
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
sourceOffset?: number;
|
|
20
|
+
sourceEndOffset?: number;
|
|
21
|
+
}
|
|
22
|
+
interface CanofoldPreparedDemo extends CanofoldDemoReference {
|
|
23
|
+
modulePath: string;
|
|
24
|
+
moduleUrl?: string;
|
|
25
|
+
/** Project-local files imported by this demo, used for cache invalidation. */
|
|
26
|
+
dependencyPaths?: string[];
|
|
27
|
+
source: string;
|
|
28
|
+
language: 'tsx' | 'ts' | 'jsx' | 'js';
|
|
29
|
+
}
|
|
30
|
+
interface CanofoldDemoManifest {
|
|
31
|
+
clientUrl: string;
|
|
32
|
+
styleUrls?: string[];
|
|
33
|
+
demos: Record<string, CanofoldPreparedDemo>;
|
|
34
|
+
/** Paths relative to the site output root, used by output safety and caching. */
|
|
35
|
+
outputPaths?: string[];
|
|
36
|
+
/** Project-local engine/setup files that affect every demo page. */
|
|
37
|
+
dependencyPaths?: string[];
|
|
38
|
+
}
|
|
39
|
+
interface CanofoldDemoPrepareContext {
|
|
40
|
+
cwd: string;
|
|
41
|
+
outputRoot: string;
|
|
42
|
+
basePath: string;
|
|
43
|
+
mode: 'analyze' | 'build' | 'dev';
|
|
44
|
+
setup?: string;
|
|
45
|
+
demos: readonly CanofoldDemoReference[];
|
|
46
|
+
}
|
|
47
|
+
interface CanofoldDemoDevRuntime {
|
|
48
|
+
middleware?: (request: IncomingMessage, response: ServerResponse, next: () => void) => void;
|
|
49
|
+
handlesFile?: (path: string) => boolean;
|
|
50
|
+
/** Notify the engine after Canofold refreshes the demo manifest. */
|
|
51
|
+
update?(): void | Promise<void>;
|
|
52
|
+
close(): void | Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
interface CanofoldDemoDevContext {
|
|
55
|
+
cwd: string;
|
|
56
|
+
basePath: string;
|
|
57
|
+
setup?: string;
|
|
58
|
+
server: Server;
|
|
59
|
+
getDemos(): readonly CanofoldPreparedDemo[];
|
|
60
|
+
/** Excludes Canofold output, cache, and atomic replacement files from framework watchers. */
|
|
61
|
+
shouldIgnorePath(path: string): boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Trusted build/dev adapter for interactive component examples.
|
|
65
|
+
*
|
|
66
|
+
* Canofold owns Markdown, routes and the demo declaration model. Engines own
|
|
67
|
+
* project module resolution, browser transforms, CSS, HMR and production
|
|
68
|
+
* client chunks.
|
|
69
|
+
*/
|
|
70
|
+
interface CanofoldDemoEngine {
|
|
71
|
+
id: string;
|
|
72
|
+
version?: string;
|
|
73
|
+
cacheKey?: CanofoldDemoCacheValue;
|
|
74
|
+
prepare(context: CanofoldDemoPrepareContext): Promise<CanofoldDemoManifest>;
|
|
75
|
+
startDev?(context: CanofoldDemoDevContext): Promise<CanofoldDemoDevRuntime>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type { CanofoldDemoCacheValue, CanofoldDemoDevContext, CanofoldDemoDevRuntime, CanofoldDemoEngine, CanofoldDemoManifest, CanofoldDemoPrepareContext, CanofoldDemoReference, CanofoldDemoSandbox, CanofoldPreparedDemo };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=demo-engine.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as g}from"./chunk-ACUMTEQL.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-47AUDPYE.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as B}from"./chunk-HS5LEPRC.js";import{b}from"./chunk-OKX7SQKX.js";import{a as P}from"./chunk-EQOADO2H.js";import"./chunk-KJ7FG6AY.js";import{b as w}from"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-ACUMTEQL.js";import{a as S,b as v}from"./chunk-M6T5RSNJ.js";import"./chunk-2XMX5JW6.js";import"./chunk-EAYVCA3Z.js";import{c as y,e as D}from"./chunk-JK7ZNBUA.js";import{a as r}from"./chunk-AYDF3IFZ.js";import O from"chokidar";import{createMarkdownRenderer as T}from"@canofold/markdown/server";import{relative as I,resolve as E,sep as K}from"path";function k(n,f,u){let t=E(n,u),i=I(n,t).split(K);return i.includes("node_modules")||i.includes(".git")||i.includes(".canofold")||i.some(o=>/^\..+\.(?:tmp|backup)-/.test(o))?!0:y(D(n,f),t)||y(P(n),t)}r(k,"shouldIgnoreGeneratedPath");function U({build:n,reload:f,onBuildError:u=r(o=>v(o instanceof Error?o.message:String(o)),"onBuildError"),onBuildOk:t,debounceMs:i=80}){let o,d,l=!1,c=!1,p=r(()=>{if(o=void 0,!c){if(d){l=!0;return}d=(async()=>{try{let a=await n();c||(t?.(),f(a))}catch(a){u(a)}finally{d=void 0,l&&!c&&(l=!1,o=setTimeout(p,0))}})()}},"run");return{schedule(){if(!c){if(d){l=!0;return}o&&clearTimeout(o),o=setTimeout(p,i)}},async close(){c=!0,l=!1,o&&clearTimeout(o),o=void 0,await d}}}r(U,"createBuildScheduler");async function M({cwd:n,port:f}){let u=T(),t=await b({cwd:n,renderer:u,demoMode:"dev"}),i,o,d,l=r(()=>{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=r(async()=>{let e=t.config.demos.engine;if(!(!t.demoManifest||!e?.startDev||!d))return e.startDev({cwd:n,basePath:t.config.basePath,setup:t.config.demos.setup,server:d,getDemos:r(()=>Object.values(t.demoManifest?.demos??{}),"getDemos"),shouldIgnorePath:r(s=>k(n,t.config.outputDir,s),"shouldIgnorePath")})},"createDemoRuntime"),p=r(async()=>{let e=l();if(e===o){await i?.update?.();return}let s=await c(),m=i;i=s,o=e,await m?.close()},"refreshDemoRuntime"),a=await B({root:r(()=>D(n,t.config.outputDir),"root"),port:f,liveReload:!0,basePath:r(()=>t.config.basePath,"basePath"),configureServer:r(async e=>(d=e,i=await c(),o=l(),{middleware(s,m,g){if(!i?.middleware){g();return}i.middleware(s,m,()=>g())},close:r(()=>i?.close(),"close")}),"configureServer")}),h=O.watch(".",{cwd:n,ignoreInitial:!0,ignored:r(e=>k(n,t.config.outputDir,e),"ignored")}),R=U({build:r(async()=>{t=await b({cwd:n,renderer:u,demoMode:"dev"}),await p();let e=t.changedPages.flatMap(s=>{let m=t.graph.pages.find(g=>g.sourceRelativePath===s);return m?[w(t.config,m.routePath)]:[]});return{protocol:1,type:"update",mode:t.partialReload&&e.length===1?"page":"full",routes:e}},"build"),reload:r(e=>a.reload(e),"reload"),onBuildError:r(e=>{let s=e instanceof Error?e.message:String(e);v("Build error:",s),a.sendBuildError(s)},"onBuildError"),onBuildOk:r(()=>a.sendBuildOk(),"onBuildOk")});return h.on("all",(e,s)=>{i?.handlesFile?.(E(n,s))||R.schedule()}),h.on("error",e=>{let s=e instanceof Error?e.message:String(e);v("File watcher error:",s),a.sendBuildError(s)}),{port:a.port,close:r(async()=>{await h.close(),await R.close(),await a.close()},"close")}}r(M,"startDevServer");async function L({cwd:n,port:f=3333}){let u=await M({cwd:n,port:f});return S(`Dev server running at http://127.0.0.1:${u.port}/`),u}r(L,"runDev");export{L as runDev};
|
|
2
|
+
//# sourceMappingURL=dev-3C4T3COS.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { MarkdownHtmlPolicy, MarkdownCodeOptions, MarkdownFeatureOptions, MarkdownLabels, MarkdownPlugin } from '@canofold/markdown';
|
|
2
2
|
import { MarkdownThemeInput } from '@canofold/markdown/theme';
|
|
3
3
|
import { MarkdownHeading, MarkdownCodeExample } from '@canofold/markdown/server/analyze';
|
|
4
|
+
import { CanofoldDemoReference, CanofoldDemoEngine } from './demo-engine.js';
|
|
5
|
+
export { CanofoldDemoCacheValue, CanofoldDemoDevContext, CanofoldDemoDevRuntime, CanofoldDemoManifest, CanofoldDemoPrepareContext, CanofoldDemoSandbox, CanofoldPreparedDemo } from './demo-engine.js';
|
|
6
|
+
import 'node:http';
|
|
4
7
|
|
|
5
8
|
/** Package version injected by tsup so chunk nesting cannot affect lookup. */
|
|
6
9
|
declare const canofoldVersion: string;
|
|
@@ -101,6 +104,7 @@ interface DocPage {
|
|
|
101
104
|
headings: MarkdownHeading[];
|
|
102
105
|
searchText: string;
|
|
103
106
|
codeExamples: MarkdownCodeExample[];
|
|
107
|
+
demos: CanofoldDemoReference[];
|
|
104
108
|
lastUpdated: string;
|
|
105
109
|
previous?: PageLink;
|
|
106
110
|
next?: PageLink;
|
|
@@ -251,6 +255,11 @@ interface CanofoldConfigInput {
|
|
|
251
255
|
docsDir?: string;
|
|
252
256
|
outputDir?: string;
|
|
253
257
|
styles?: string[];
|
|
258
|
+
demos?: {
|
|
259
|
+
engine?: CanofoldDemoEngine;
|
|
260
|
+
/** Optional project module that wraps every interactive demo with shared providers. */
|
|
261
|
+
setup?: string;
|
|
262
|
+
};
|
|
254
263
|
layout?: {
|
|
255
264
|
header?: boolean;
|
|
256
265
|
};
|
|
@@ -324,6 +333,10 @@ interface CanofoldConfig {
|
|
|
324
333
|
docsDir: string;
|
|
325
334
|
outputDir: string;
|
|
326
335
|
styles: string[];
|
|
336
|
+
demos: {
|
|
337
|
+
engine?: CanofoldDemoEngine;
|
|
338
|
+
setup?: string;
|
|
339
|
+
};
|
|
327
340
|
layout: {
|
|
328
341
|
header: boolean;
|
|
329
342
|
};
|
|
@@ -436,4 +449,4 @@ type CanofoldExtensionFactory = (options: Readonly<CanofoldExtensionOptions>) =>
|
|
|
436
449
|
declare function defineExtension(extension: CanofoldExtension): CanofoldExtension;
|
|
437
450
|
declare function defineExtension(factory: CanofoldExtensionFactory): CanofoldExtensionFactory;
|
|
438
451
|
|
|
439
|
-
export { CANOFOLD_EXTENSION_API_VERSION, type CanofoldConfigInput, type CanofoldExtension, type CanofoldExtensionDescriptor, type CanofoldExtensionFactory, type CanofoldExtensionGenerateContext, type CanofoldExtensionPage, type CanofoldExtensionPagePatch, type CanofoldExtensionSourceContext, type CanofoldJsonValue, type SearchProvider, type SearchProviderContext, canofoldVersion, defineConfig, defineExtension, defineSearchProvider };
|
|
452
|
+
export { CANOFOLD_EXTENSION_API_VERSION, type CanofoldConfigInput, CanofoldDemoEngine, CanofoldDemoReference, type CanofoldExtension, type CanofoldExtensionDescriptor, type CanofoldExtensionFactory, type CanofoldExtensionGenerateContext, type CanofoldExtensionPage, type CanofoldExtensionPagePatch, type CanofoldExtensionSourceContext, type CanofoldJsonValue, type SearchProvider, type SearchProviderContext, canofoldVersion, defineConfig, defineExtension, defineSearchProvider };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as t,f,g as
|
|
1
|
+
import{c as t,f,g as a}from"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as n}from"./chunk-2XMX5JW6.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-2XMX5JW6.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-BG2H2Q65.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-3PS74OVB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=load-
|
|
1
|
+
import{k as a,l as b}from"./chunk-ACUMTEQL.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{a as findConfigPath,b as loadConfig};
|
|
2
|
+
//# sourceMappingURL=load-BG2H2Q65.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=preview-
|
|
1
|
+
import{a as p}from"./chunk-HS5LEPRC.js";import{l as n}from"./chunk-ACUMTEQL.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-OAMF5HXH.js.map
|
package/dist/styles.input.css
CHANGED
|
@@ -349,7 +349,7 @@ a {
|
|
|
349
349
|
display: none;
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
.cf-progress {
|
|
352
|
+
.cf-route-progress {
|
|
353
353
|
position: absolute;
|
|
354
354
|
inset: auto 0 0;
|
|
355
355
|
height: 2px;
|
|
@@ -357,7 +357,7 @@ a {
|
|
|
357
357
|
background: transparent;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
.cf-progress > span {
|
|
360
|
+
.cf-route-progress > span {
|
|
361
361
|
display: block;
|
|
362
362
|
width: 100%;
|
|
363
363
|
height: 100%;
|
|
@@ -497,7 +497,7 @@ a {
|
|
|
497
497
|
overflow: hidden;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
.cf-playground-page .cf-progress {
|
|
500
|
+
.cf-playground-page .cf-route-progress {
|
|
501
501
|
display: none;
|
|
502
502
|
}
|
|
503
503
|
|
|
@@ -855,6 +855,232 @@ a {
|
|
|
855
855
|
padding-top: 0;
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
+
.cf-home > .cf-content {
|
|
859
|
+
max-width: 72.5rem;
|
|
860
|
+
margin-inline: auto;
|
|
861
|
+
background: transparent;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/* Component demos */
|
|
865
|
+
.cf-content .cf-demo {
|
|
866
|
+
--cf-demo-border: color-mix(in oklab, var(--cf-ink) 10%, var(--cf-border));
|
|
867
|
+
overflow: hidden;
|
|
868
|
+
margin: 1.5rem 0;
|
|
869
|
+
border: 1px solid var(--cf-demo-border);
|
|
870
|
+
border-radius: var(--cf-radius-lg);
|
|
871
|
+
background: var(--cf-surface);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
.cf-content .cf-demo[data-cf-demo-sandbox='iframe'] .cf-demo-preview {
|
|
875
|
+
padding: 0;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.cf-content .cf-demo-preview {
|
|
879
|
+
display: grid;
|
|
880
|
+
min-height: 8rem;
|
|
881
|
+
place-items: center;
|
|
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;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.cf-demo-frame {
|
|
897
|
+
display: block;
|
|
898
|
+
width: 100%;
|
|
899
|
+
min-height: 12rem;
|
|
900
|
+
border: 0;
|
|
901
|
+
background: transparent;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
.cf-demo-error,
|
|
905
|
+
.cf-demo-preview[data-cf-demo-error] {
|
|
906
|
+
color: var(--cf-danger, #dc2626);
|
|
907
|
+
font-size: 0.9375rem;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
.cf-content .cf-demo-details {
|
|
911
|
+
position: relative;
|
|
912
|
+
display: grid;
|
|
913
|
+
gap: 0;
|
|
914
|
+
margin: 0;
|
|
915
|
+
padding: 1.65rem 1.5rem 1.15rem;
|
|
916
|
+
border-top: 1px solid var(--cf-demo-border);
|
|
917
|
+
background: var(--cf-surface);
|
|
918
|
+
text-align: left;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
.cf-demo-title {
|
|
922
|
+
position: absolute;
|
|
923
|
+
top: 0;
|
|
924
|
+
left: 1.25rem;
|
|
925
|
+
padding: 0 0.5rem;
|
|
926
|
+
color: var(--cf-ink);
|
|
927
|
+
background: var(--cf-surface);
|
|
928
|
+
font-size: 1rem;
|
|
929
|
+
font-weight: 650;
|
|
930
|
+
line-height: 1.5;
|
|
931
|
+
transform: translateY(-50%);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.cf-demo-description {
|
|
935
|
+
margin: 0;
|
|
936
|
+
color: var(--cf-ink-body);
|
|
937
|
+
font-size: 0.9375rem;
|
|
938
|
+
line-height: 1.7;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
.cf-content .cf-demo-toolbar {
|
|
942
|
+
display: flex;
|
|
943
|
+
align-items: center;
|
|
944
|
+
justify-content: center;
|
|
945
|
+
gap: 0.125rem;
|
|
946
|
+
min-height: 3rem;
|
|
947
|
+
margin: 0;
|
|
948
|
+
padding: 0.5rem 0.875rem;
|
|
949
|
+
border-top: 1px dashed var(--cf-demo-border);
|
|
950
|
+
background: var(--cf-surface);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
.cf-content .cf-demo-action {
|
|
954
|
+
position: relative;
|
|
955
|
+
display: inline-grid;
|
|
956
|
+
width: 2rem;
|
|
957
|
+
height: 2rem;
|
|
958
|
+
place-items: center;
|
|
959
|
+
padding: 0;
|
|
960
|
+
border: 0;
|
|
961
|
+
border-radius: var(--cf-radius-sm);
|
|
962
|
+
color: color-mix(in oklab, var(--cf-ink-secondary) 72%, transparent);
|
|
963
|
+
background: transparent;
|
|
964
|
+
cursor: pointer;
|
|
965
|
+
text-decoration: none;
|
|
966
|
+
transition:
|
|
967
|
+
color 160ms ease,
|
|
968
|
+
background-color 160ms ease;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
.cf-content .cf-demo-action:hover,
|
|
972
|
+
.cf-content .cf-demo-action:focus-visible,
|
|
973
|
+
.cf-content .cf-demo-source-toggle[aria-expanded='true'] {
|
|
974
|
+
color: var(--cf-ink-secondary);
|
|
975
|
+
background: transparent;
|
|
976
|
+
text-decoration: none;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
.cf-content .cf-demo-action:focus-visible {
|
|
980
|
+
outline: 2px solid var(--cf-accent-500);
|
|
981
|
+
outline-offset: 2px;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
.cf-demo-action::before,
|
|
985
|
+
.cf-demo-tooltip {
|
|
986
|
+
position: absolute;
|
|
987
|
+
left: 50%;
|
|
988
|
+
z-index: 4;
|
|
989
|
+
pointer-events: none;
|
|
990
|
+
opacity: 0;
|
|
991
|
+
transition:
|
|
992
|
+
opacity 120ms ease,
|
|
993
|
+
transform 120ms ease;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
.cf-demo-action::before {
|
|
997
|
+
bottom: calc(100% + 0.32rem);
|
|
998
|
+
width: 0.55rem;
|
|
999
|
+
height: 0.55rem;
|
|
1000
|
+
background: #202124;
|
|
1001
|
+
content: '';
|
|
1002
|
+
transform: translate(-50%, 0.2rem) rotate(45deg);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
.cf-demo-tooltip {
|
|
1006
|
+
bottom: calc(100% + 0.58rem);
|
|
1007
|
+
max-width: 14rem;
|
|
1008
|
+
padding: 0.4rem 0.6rem;
|
|
1009
|
+
border-radius: 0.45rem;
|
|
1010
|
+
color: #fff;
|
|
1011
|
+
background: #202124;
|
|
1012
|
+
box-shadow: 0 0.4rem 1rem rgb(0 0 0 / 20%);
|
|
1013
|
+
font-size: 0.8125rem;
|
|
1014
|
+
font-weight: 550;
|
|
1015
|
+
line-height: 1.25;
|
|
1016
|
+
white-space: nowrap;
|
|
1017
|
+
transform: translate(-50%, 0.2rem);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.cf-demo-action:hover::before,
|
|
1021
|
+
.cf-demo-action:hover .cf-demo-tooltip,
|
|
1022
|
+
.cf-demo-action:focus-visible::before,
|
|
1023
|
+
.cf-demo-action:focus-visible .cf-demo-tooltip {
|
|
1024
|
+
opacity: 1;
|
|
1025
|
+
transform: translate(-50%, 0) rotate(45deg);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
.cf-demo-action:hover .cf-demo-tooltip,
|
|
1029
|
+
.cf-demo-action:focus-visible .cf-demo-tooltip {
|
|
1030
|
+
transform: translate(-50%, 0);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
.cf-demo-action-icon {
|
|
1034
|
+
--cf-demo-action-icon: none;
|
|
1035
|
+
|
|
1036
|
+
display: inline-block;
|
|
1037
|
+
width: 1rem;
|
|
1038
|
+
height: 1rem;
|
|
1039
|
+
background: currentColor;
|
|
1040
|
+
-webkit-mask: var(--cf-demo-action-icon) center / contain no-repeat;
|
|
1041
|
+
mask: var(--cf-demo-action-icon) center / contain no-repeat;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.cf-demo-open-icon {
|
|
1045
|
+
--cf-demo-action-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6'/%3E%3Cpath d='M10 14 21 3'/%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3C/svg%3E");
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
.cf-demo-source-icon {
|
|
1049
|
+
--cf-demo-action-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m16 18 6-6-6-6'/%3E%3Cpath d='m8 6-6 6 6 6'/%3E%3C/svg%3E");
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
.cf-demo-source-toggle[aria-expanded='true'] .cf-demo-source-icon {
|
|
1053
|
+
--cf-demo-action-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m18 16 4-4-4-4'/%3E%3Cpath d='m6 8-4 4 4 4'/%3E%3Cpath d='m14.5 4-5 16'/%3E%3C/svg%3E");
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
.cf-demo-source[hidden] {
|
|
1057
|
+
display: none;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
.cf-content .cf-demo-source > .cf-code {
|
|
1061
|
+
margin: 0;
|
|
1062
|
+
border-width: 1px 0 0;
|
|
1063
|
+
border-radius: 0;
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
html[data-cf-demo-standalone],
|
|
1067
|
+
html[data-cf-demo-standalone] body {
|
|
1068
|
+
min-height: 100%;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
html[data-cf-demo-standalone] body {
|
|
1072
|
+
display: grid;
|
|
1073
|
+
box-sizing: border-box;
|
|
1074
|
+
margin: 0;
|
|
1075
|
+
padding: clamp(1.5rem, 5vw, 4rem);
|
|
1076
|
+
place-items: center;
|
|
1077
|
+
background: var(--cf-canvas);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
.cf-demo-standalone {
|
|
1081
|
+
width: min(100%, 72rem);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
858
1084
|
.cf-hero {
|
|
859
1085
|
position: relative;
|
|
860
1086
|
isolation: isolate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canofold",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -32,12 +32,17 @@
|
|
|
32
32
|
".": {
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"import": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./demo-engine": {
|
|
37
|
+
"types": "./dist/demo-engine.d.ts",
|
|
38
|
+
"import": "./dist/demo-engine.js"
|
|
35
39
|
}
|
|
36
40
|
},
|
|
37
41
|
"files": [
|
|
38
42
|
"dist/**/*.js",
|
|
39
43
|
"dist/**/*.d.ts",
|
|
40
44
|
"dist/**/*.css",
|
|
45
|
+
"dist/**/*.webp",
|
|
41
46
|
"README.zh-CN.md"
|
|
42
47
|
],
|
|
43
48
|
"engines": {
|
|
@@ -56,17 +61,17 @@
|
|
|
56
61
|
"react-dom": "^19.2.8",
|
|
57
62
|
"semver": "^7.8.5",
|
|
58
63
|
"zod": "^4.4.3",
|
|
59
|
-
"@canofold/markdown": "0.
|
|
64
|
+
"@canofold/markdown": "0.3.0"
|
|
60
65
|
},
|
|
61
66
|
"devDependencies": {
|
|
62
67
|
"@types/react": "^19.2.18",
|
|
63
|
-
"@types/react-dom": "^19.2.
|
|
68
|
+
"@types/react-dom": "^19.2.7",
|
|
64
69
|
"@types/semver": "^7.8.0",
|
|
65
70
|
"tsup": "^8.3.5",
|
|
66
71
|
"typescript": "^6.0.3"
|
|
67
72
|
},
|
|
68
73
|
"scripts": {
|
|
69
|
-
"build": "tsup && node -e \"require('node:fs').copyFileSync('src/render/styles.input.css','dist/styles.input.css')\"",
|
|
74
|
+
"build": "tsup && node -e \"const fs=require('node:fs');fs.copyFileSync('src/render/styles.input.css','dist/styles.input.css');fs.cpSync('src/assets/brand','dist/brand',{recursive:true})\"",
|
|
70
75
|
"typecheck": "tsc --noEmit",
|
|
71
76
|
"test": "pnpm --dir ../.. build && vitest run --root ../.."
|
|
72
77
|
}
|
package/dist/build-7SEVEAYT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-B2QFU4ZW.js";import"./chunk-FCABZITC.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-7SYMF26J.js";import"./chunk-4OALGQQB.js";import"./chunk-M6T5RSNJ.js";import"./chunk-KUDMXVOM.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{b as runBuild,a as versionSatisfies};
|
|
2
|
-
//# sourceMappingURL=build-7SEVEAYT.js.map
|
package/dist/check-NY3EVN5Q.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{e as I,j as b,k as M}from"./chunk-FCABZITC.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-KUDMXVOM.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-NY3EVN5Q.js.map
|
package/dist/chunk-4OALGQQB.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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
|