canofold 0.2.0 → 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-OATSOVSV.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-74GN2NZC.js → clean-V2SP7IRD.js} +2 -2
- package/dist/cli.d.ts +1 -0
- 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 +452 -0
- package/dist/index.js +1 -1
- package/dist/{init-6R5SLESH.js → init-3PS74OVB.js} +3 -3
- package/dist/{load-W4JHZIBF.js → load-BG2H2Q65.js} +2 -2
- package/dist/playground-client.d.ts +17 -0
- package/dist/{preview-ODXGCQZ7.js → preview-OAMF5HXH.js} +2 -2
- package/dist/search-client.d.ts +3 -0
- package/dist/styles.input.css +229 -3
- package/package.json +10 -5
- package/dist/build-RBMQ6TZ7.js +0 -2
- package/dist/check-FCYLN6KO.js +0 -3
- package/dist/chunk-3TIVCYR7.js +0 -2
- package/dist/chunk-4E7M3CIK.js +0 -6
- package/dist/chunk-4OALGQQB.js +0 -2
- package/dist/chunk-56TT2V3X.js +0 -664
- package/dist/chunk-JZIKHPBO.js +0 -45
- package/dist/dev-WJCFAWYD.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.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
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
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { MarkdownHtmlPolicy, MarkdownCodeOptions, MarkdownFeatureOptions, MarkdownLabels, MarkdownPlugin } from '@canofold/markdown';
|
|
2
|
+
import { MarkdownThemeInput } from '@canofold/markdown/theme';
|
|
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';
|
|
7
|
+
|
|
8
|
+
/** Package version injected by tsup so chunk nesting cannot affect lookup. */
|
|
9
|
+
declare const canofoldVersion: string;
|
|
10
|
+
|
|
11
|
+
declare const homeIconNames: readonly ["ai", "box", "code", "file", "file-code", "gauge", "globe", "layers", "rocket", "search", "sparkles", "terminal"];
|
|
12
|
+
type HomeIconName = (typeof homeIconNames)[number];
|
|
13
|
+
interface CanofoldFrontmatter {
|
|
14
|
+
title?: string;
|
|
15
|
+
seoTitle?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
createdAt?: string;
|
|
18
|
+
updatedAt?: string;
|
|
19
|
+
order?: number;
|
|
20
|
+
group?: string;
|
|
21
|
+
subgroup?: string;
|
|
22
|
+
collapsed?: boolean;
|
|
23
|
+
sidebar?: boolean;
|
|
24
|
+
layout?: 'document' | 'playground';
|
|
25
|
+
status?: 'draft' | 'published';
|
|
26
|
+
search?: boolean;
|
|
27
|
+
ai?: boolean;
|
|
28
|
+
tags?: string[];
|
|
29
|
+
owner?: string;
|
|
30
|
+
hero?: {
|
|
31
|
+
accent?: string;
|
|
32
|
+
tagline?: string;
|
|
33
|
+
image?: string;
|
|
34
|
+
imageAlt?: string;
|
|
35
|
+
actions?: Array<{
|
|
36
|
+
text: string;
|
|
37
|
+
link: string;
|
|
38
|
+
primary?: boolean;
|
|
39
|
+
icon?: HomeIconName;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
features?: Array<{
|
|
43
|
+
icon?: HomeIconName;
|
|
44
|
+
image?: string;
|
|
45
|
+
title: string;
|
|
46
|
+
details: string;
|
|
47
|
+
}>;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface PageLink {
|
|
52
|
+
title: string;
|
|
53
|
+
routePath: string;
|
|
54
|
+
}
|
|
55
|
+
interface SidebarLink {
|
|
56
|
+
type: 'link';
|
|
57
|
+
title: string;
|
|
58
|
+
routePath: string;
|
|
59
|
+
}
|
|
60
|
+
interface SidebarTreeGroup {
|
|
61
|
+
type: 'group';
|
|
62
|
+
/** Stable identity among sibling directories; display titles may be translated or duplicated. */
|
|
63
|
+
segment: string;
|
|
64
|
+
title: string;
|
|
65
|
+
collapsed: boolean;
|
|
66
|
+
items: SidebarItem[];
|
|
67
|
+
}
|
|
68
|
+
type SidebarItem = SidebarLink | SidebarTreeGroup;
|
|
69
|
+
interface SidebarGroup {
|
|
70
|
+
/** First directory segment under the locale; used to select a section sidebar. */
|
|
71
|
+
segment: string;
|
|
72
|
+
/** Section title used by automatic top navigation, not rendered inside the sidebar. */
|
|
73
|
+
title: string;
|
|
74
|
+
items: SidebarItem[];
|
|
75
|
+
}
|
|
76
|
+
interface NavItem {
|
|
77
|
+
title: string;
|
|
78
|
+
routePath: string;
|
|
79
|
+
}
|
|
80
|
+
interface DocPage {
|
|
81
|
+
sourcePath: string;
|
|
82
|
+
/** Complete source after extension transforms, including frontmatter and MDX imports. */
|
|
83
|
+
transformedSource: string;
|
|
84
|
+
/** Project-relative source path, including a version-specific docsDir. */
|
|
85
|
+
sourceRelativePath: string;
|
|
86
|
+
/** Path relative to this version's docs root. */
|
|
87
|
+
relativePath: string;
|
|
88
|
+
version: string;
|
|
89
|
+
versionBase: string;
|
|
90
|
+
docsDir: string;
|
|
91
|
+
locale: string;
|
|
92
|
+
routePath: string;
|
|
93
|
+
outputPath: string;
|
|
94
|
+
markdownOutputPath: string;
|
|
95
|
+
title: string;
|
|
96
|
+
description: string;
|
|
97
|
+
order: number;
|
|
98
|
+
/** First sub-directory segment under the locale, '' for root-level pages. */
|
|
99
|
+
group: string;
|
|
100
|
+
status: 'draft' | 'published';
|
|
101
|
+
search: boolean;
|
|
102
|
+
ai: boolean;
|
|
103
|
+
body: string;
|
|
104
|
+
headings: MarkdownHeading[];
|
|
105
|
+
searchText: string;
|
|
106
|
+
codeExamples: MarkdownCodeExample[];
|
|
107
|
+
demos: CanofoldDemoReference[];
|
|
108
|
+
lastUpdated: string;
|
|
109
|
+
previous?: PageLink;
|
|
110
|
+
next?: PageLink;
|
|
111
|
+
frontmatter: CanofoldFrontmatter;
|
|
112
|
+
}
|
|
113
|
+
interface ContentGraph {
|
|
114
|
+
pages: DocPage[];
|
|
115
|
+
/** Grouped sidebar entries per version and locale. */
|
|
116
|
+
sidebar: Record<string, Record<string, SidebarGroup[]>>;
|
|
117
|
+
/** Top navigation entries per version and locale. */
|
|
118
|
+
nav: Record<string, Record<string, NavItem[]>>;
|
|
119
|
+
locales: string[];
|
|
120
|
+
defaultLocale: string;
|
|
121
|
+
versions: Array<{
|
|
122
|
+
id: string;
|
|
123
|
+
label: string;
|
|
124
|
+
base: string;
|
|
125
|
+
docsDir: string;
|
|
126
|
+
}>;
|
|
127
|
+
currentVersion: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface SearchProviderContext {
|
|
131
|
+
cwd: string;
|
|
132
|
+
config: CanofoldConfig;
|
|
133
|
+
graph: ContentGraph;
|
|
134
|
+
outputRoot: string;
|
|
135
|
+
publicPathFor(routePath: string): string;
|
|
136
|
+
resolveOutputPath(outputPath: string, label: string): string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Whole-site index lifecycle. Unlike a Markdown plugin, a provider consumes the
|
|
140
|
+
* completed ContentGraph and output root; unlike an Extension, it owns only the
|
|
141
|
+
* configured search implementation's artifacts.
|
|
142
|
+
*/
|
|
143
|
+
interface SearchProvider {
|
|
144
|
+
readonly id: string;
|
|
145
|
+
/** Browser-side query protocol consumed by Canofold's built-in search modal. */
|
|
146
|
+
readonly client: 'compact' | 'pagefind';
|
|
147
|
+
readonly version?: string;
|
|
148
|
+
/** Resolved JSON options used for build invalidation. Bump `version` when implementation changes. */
|
|
149
|
+
readonly cacheKey?: CanofoldJsonValue;
|
|
150
|
+
write(context: SearchProviderContext): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const THEME_BASE_COLORS: readonly ["paper", "neutral", "slate", "zinc", "stone"];
|
|
154
|
+
declare const CANOFOLD_MARKDOWN_ELEMENT_GROUP_IDS: readonly ["headings", "inline", "lists", "callouts", "code", "tables", "media", "diagrams", "disclosure", "extensions", "api", "metadata"];
|
|
155
|
+
|
|
156
|
+
type ThemeBaseColor = (typeof THEME_BASE_COLORS)[number];
|
|
157
|
+
type CanofoldMarkdownElementGroupId = (typeof CANOFOLD_MARKDOWN_ELEMENT_GROUP_IDS)[number];
|
|
158
|
+
interface CanofoldNavigationItem {
|
|
159
|
+
text: string;
|
|
160
|
+
link: string;
|
|
161
|
+
}
|
|
162
|
+
interface CanofoldVersionItem {
|
|
163
|
+
id: string;
|
|
164
|
+
label: string;
|
|
165
|
+
docsDir: string;
|
|
166
|
+
/** Absolute URL base. The current version normally uses `/`. */
|
|
167
|
+
base: string;
|
|
168
|
+
}
|
|
169
|
+
interface CanofoldAdvertisement {
|
|
170
|
+
image: string;
|
|
171
|
+
href: string;
|
|
172
|
+
alt: string;
|
|
173
|
+
label?: string;
|
|
174
|
+
}
|
|
175
|
+
interface CanofoldSearchConfig {
|
|
176
|
+
enabled: boolean;
|
|
177
|
+
provider: 'compact' | SearchProvider;
|
|
178
|
+
}
|
|
179
|
+
type CanofoldJsonValue = string | number | boolean | null | CanofoldJsonValue[] | {
|
|
180
|
+
[key: string]: CanofoldJsonValue;
|
|
181
|
+
};
|
|
182
|
+
interface CanofoldExtensionDescriptor {
|
|
183
|
+
/** Project-relative TypeScript or JavaScript module. Extensions execute as trusted build code. */
|
|
184
|
+
resolve: string;
|
|
185
|
+
/** JSON-serializable factory options; functions and environment-specific values are rejected. */
|
|
186
|
+
options?: {
|
|
187
|
+
[key: string]: CanofoldJsonValue;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
interface CanofoldLayoutLabels {
|
|
191
|
+
skipToContent: string;
|
|
192
|
+
search: string;
|
|
193
|
+
searchEmpty: string;
|
|
194
|
+
searchUnavailable: string;
|
|
195
|
+
language: string;
|
|
196
|
+
primaryNavigation: string;
|
|
197
|
+
theme: string;
|
|
198
|
+
openSidebar: string;
|
|
199
|
+
onThisPage: string;
|
|
200
|
+
edit: string;
|
|
201
|
+
updated: string;
|
|
202
|
+
previous: string;
|
|
203
|
+
next: string;
|
|
204
|
+
close: string;
|
|
205
|
+
source: string;
|
|
206
|
+
preview: string;
|
|
207
|
+
copySource: string;
|
|
208
|
+
sourceCopied: string;
|
|
209
|
+
quickActions: string;
|
|
210
|
+
github: string;
|
|
211
|
+
docsNavigation: string;
|
|
212
|
+
pageNavigation: string;
|
|
213
|
+
advertisement: string;
|
|
214
|
+
version: string;
|
|
215
|
+
}
|
|
216
|
+
interface CanofoldQuickActionMessages {
|
|
217
|
+
headingsTitle: string;
|
|
218
|
+
headingsDescription: string;
|
|
219
|
+
codeTitle: string;
|
|
220
|
+
codeDescription: string;
|
|
221
|
+
tableTitle: string;
|
|
222
|
+
tableDescription: string;
|
|
223
|
+
diagramTitle: string;
|
|
224
|
+
diagramDescription: string;
|
|
225
|
+
sourceDescription: string;
|
|
226
|
+
themeDescription: string;
|
|
227
|
+
}
|
|
228
|
+
interface CanofoldMarkdownElementGroupMessages {
|
|
229
|
+
label?: string;
|
|
230
|
+
detail?: string;
|
|
231
|
+
hash?: string;
|
|
232
|
+
}
|
|
233
|
+
interface CanofoldNotFoundMessages {
|
|
234
|
+
title: string;
|
|
235
|
+
description: string;
|
|
236
|
+
home: string;
|
|
237
|
+
}
|
|
238
|
+
interface CanofoldLocaleMessages {
|
|
239
|
+
labels?: Partial<CanofoldLayoutLabels>;
|
|
240
|
+
brandTagline?: string;
|
|
241
|
+
quickActions?: Partial<CanofoldQuickActionMessages>;
|
|
242
|
+
markdownElementGroups?: Partial<Record<CanofoldMarkdownElementGroupId, CanofoldMarkdownElementGroupMessages>>;
|
|
243
|
+
markdown?: Partial<MarkdownLabels>;
|
|
244
|
+
notFound?: Partial<CanofoldNotFoundMessages>;
|
|
245
|
+
}
|
|
246
|
+
/** Public authoring contract for canofold.config.ts. Runtime validation uses the matching strict schema. */
|
|
247
|
+
interface CanofoldConfigInput {
|
|
248
|
+
title?: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
siteUrl?: string;
|
|
251
|
+
basePath?: string;
|
|
252
|
+
editUrl?: string;
|
|
253
|
+
github?: string;
|
|
254
|
+
requiredVersion?: string;
|
|
255
|
+
docsDir?: string;
|
|
256
|
+
outputDir?: string;
|
|
257
|
+
styles?: string[];
|
|
258
|
+
demos?: {
|
|
259
|
+
engine?: CanofoldDemoEngine;
|
|
260
|
+
/** Optional project module that wraps every interactive demo with shared providers. */
|
|
261
|
+
setup?: string;
|
|
262
|
+
};
|
|
263
|
+
layout?: {
|
|
264
|
+
header?: boolean;
|
|
265
|
+
};
|
|
266
|
+
markdown?: {
|
|
267
|
+
html?: MarkdownHtmlPolicy;
|
|
268
|
+
code?: Pick<MarkdownCodeOptions, 'themes' | 'fallbackLanguage' | 'unknownLanguage'>;
|
|
269
|
+
features?: MarkdownFeatureOptions;
|
|
270
|
+
labels?: Partial<MarkdownLabels>;
|
|
271
|
+
/**
|
|
272
|
+
* Compiler plugins imported into canofold.config.ts, e.g. from
|
|
273
|
+
* `@canofold/plugins`. They execute as trusted build code; cache identity
|
|
274
|
+
* comes from each plugin's `name`, `version` and `cacheKey`.
|
|
275
|
+
*/
|
|
276
|
+
plugins?: readonly MarkdownPlugin[];
|
|
277
|
+
};
|
|
278
|
+
theme?: {
|
|
279
|
+
logo?: string;
|
|
280
|
+
logoDark?: string;
|
|
281
|
+
favicon?: string;
|
|
282
|
+
accentColor?: string;
|
|
283
|
+
darkMode?: boolean;
|
|
284
|
+
radius?: number | string;
|
|
285
|
+
baseColor?: ThemeBaseColor;
|
|
286
|
+
sidebarWidth?: number | string;
|
|
287
|
+
outlineWidth?: number | string;
|
|
288
|
+
tokens?: MarkdownThemeInput;
|
|
289
|
+
};
|
|
290
|
+
search?: {
|
|
291
|
+
enabled?: boolean;
|
|
292
|
+
/** Use `compact` or a provider such as `pagefind()` from @canofold/plugins. */
|
|
293
|
+
provider?: 'compact' | SearchProvider;
|
|
294
|
+
};
|
|
295
|
+
extensions?: CanofoldExtensionDescriptor[];
|
|
296
|
+
navigation?: Record<string, CanofoldNavigationItem[]>;
|
|
297
|
+
versions?: {
|
|
298
|
+
current: string;
|
|
299
|
+
items: CanofoldVersionItem[];
|
|
300
|
+
};
|
|
301
|
+
redirects?: Record<string, string>;
|
|
302
|
+
advertising?: CanofoldAdvertisement;
|
|
303
|
+
i18n?: {
|
|
304
|
+
defaultLocale?: string;
|
|
305
|
+
locales?: string[];
|
|
306
|
+
localeNames?: Record<string, string>;
|
|
307
|
+
messages?: Record<string, CanofoldLocaleMessages>;
|
|
308
|
+
};
|
|
309
|
+
ai?: {
|
|
310
|
+
llmsTxt?: boolean;
|
|
311
|
+
llmsFullTxt?: boolean;
|
|
312
|
+
markdownIndex?: boolean;
|
|
313
|
+
pageSummaries?: boolean;
|
|
314
|
+
codeExamples?: boolean;
|
|
315
|
+
/** Maximum encoded size of one ai/content JSONL shard. */
|
|
316
|
+
chunkSizeBytes?: number;
|
|
317
|
+
/** Maximum size of the legacy single-file llms-full.txt body. */
|
|
318
|
+
llmsFullMaxBytes?: number;
|
|
319
|
+
/** Write a manifest pointer or fail when llms-full.txt exceeds its budget. */
|
|
320
|
+
llmsFullOverflow?: 'manifest' | 'error';
|
|
321
|
+
/** Current avoids duplicate historical answers; all publishes every configured version. */
|
|
322
|
+
versions?: 'current' | 'all';
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
interface CanofoldConfig {
|
|
326
|
+
title: string;
|
|
327
|
+
description: string;
|
|
328
|
+
siteUrl?: string;
|
|
329
|
+
basePath: string;
|
|
330
|
+
editUrl?: string;
|
|
331
|
+
github?: string;
|
|
332
|
+
requiredVersion?: string;
|
|
333
|
+
docsDir: string;
|
|
334
|
+
outputDir: string;
|
|
335
|
+
styles: string[];
|
|
336
|
+
demos: {
|
|
337
|
+
engine?: CanofoldDemoEngine;
|
|
338
|
+
setup?: string;
|
|
339
|
+
};
|
|
340
|
+
layout: {
|
|
341
|
+
header: boolean;
|
|
342
|
+
};
|
|
343
|
+
markdown: {
|
|
344
|
+
html: MarkdownHtmlPolicy;
|
|
345
|
+
code: MarkdownCodeOptions;
|
|
346
|
+
features: MarkdownFeatureOptions;
|
|
347
|
+
labels: Partial<MarkdownLabels>;
|
|
348
|
+
plugins: readonly MarkdownPlugin[];
|
|
349
|
+
};
|
|
350
|
+
theme: {
|
|
351
|
+
logo?: string;
|
|
352
|
+
logoDark?: string;
|
|
353
|
+
favicon?: string;
|
|
354
|
+
accentColor: string;
|
|
355
|
+
darkMode: boolean;
|
|
356
|
+
radius: number | string;
|
|
357
|
+
baseColor: ThemeBaseColor;
|
|
358
|
+
sidebarWidth: number | string;
|
|
359
|
+
outlineWidth: number | string;
|
|
360
|
+
tokens: MarkdownThemeInput;
|
|
361
|
+
};
|
|
362
|
+
search: CanofoldSearchConfig;
|
|
363
|
+
extensions: CanofoldExtensionDescriptor[];
|
|
364
|
+
navigation: Record<string, CanofoldNavigationItem[]>;
|
|
365
|
+
versions: {
|
|
366
|
+
current: string;
|
|
367
|
+
items: CanofoldVersionItem[];
|
|
368
|
+
};
|
|
369
|
+
redirects: Record<string, string>;
|
|
370
|
+
advertising?: CanofoldAdvertisement;
|
|
371
|
+
i18n: {
|
|
372
|
+
defaultLocale: string;
|
|
373
|
+
locales: string[];
|
|
374
|
+
localeNames?: Record<string, string>;
|
|
375
|
+
messages?: Record<string, CanofoldLocaleMessages>;
|
|
376
|
+
};
|
|
377
|
+
ai: {
|
|
378
|
+
llmsTxt: boolean;
|
|
379
|
+
llmsFullTxt: boolean;
|
|
380
|
+
markdownIndex: boolean;
|
|
381
|
+
pageSummaries: boolean;
|
|
382
|
+
codeExamples: boolean;
|
|
383
|
+
chunkSizeBytes: number;
|
|
384
|
+
llmsFullMaxBytes: number;
|
|
385
|
+
llmsFullOverflow: 'manifest' | 'error';
|
|
386
|
+
versions: 'current' | 'all';
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** Add contextual typing to canofold.config.ts without changing its runtime value. */
|
|
391
|
+
declare function defineConfig(config: CanofoldConfigInput): CanofoldConfigInput;
|
|
392
|
+
|
|
393
|
+
declare function defineSearchProvider<T extends SearchProvider>(provider: T): T;
|
|
394
|
+
|
|
395
|
+
declare const CANOFOLD_EXTENSION_API_VERSION: 1;
|
|
396
|
+
interface CanofoldExtensionSourceContext {
|
|
397
|
+
source: string;
|
|
398
|
+
sourceRelativePath: string;
|
|
399
|
+
relativePath: string;
|
|
400
|
+
kind: 'markdown' | 'mdx';
|
|
401
|
+
version: string;
|
|
402
|
+
locale: string;
|
|
403
|
+
}
|
|
404
|
+
interface CanofoldExtensionPage {
|
|
405
|
+
sourceRelativePath: string;
|
|
406
|
+
relativePath: string;
|
|
407
|
+
version: string;
|
|
408
|
+
locale: string;
|
|
409
|
+
routePath: string;
|
|
410
|
+
title: string;
|
|
411
|
+
description: string;
|
|
412
|
+
status: 'draft' | 'published';
|
|
413
|
+
search: boolean;
|
|
414
|
+
ai: boolean;
|
|
415
|
+
body: string;
|
|
416
|
+
searchText: string;
|
|
417
|
+
frontmatter: CanofoldFrontmatter;
|
|
418
|
+
}
|
|
419
|
+
interface CanofoldExtensionPagePatch {
|
|
420
|
+
title?: string;
|
|
421
|
+
description?: string;
|
|
422
|
+
searchText?: string;
|
|
423
|
+
search?: boolean;
|
|
424
|
+
ai?: boolean;
|
|
425
|
+
}
|
|
426
|
+
interface CanofoldExtensionGenerateContext {
|
|
427
|
+
pages: readonly CanofoldExtensionPage[];
|
|
428
|
+
emitFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Versioned, semantic site-build contract. Compiler ASTs and internal render
|
|
432
|
+
* plugins intentionally stay private so upgrades do not depend on pipeline order.
|
|
433
|
+
* Per-document syntax belongs to MarkdownPlugin; whole-site search indexing
|
|
434
|
+
* belongs to SearchProvider.
|
|
435
|
+
*/
|
|
436
|
+
interface CanofoldExtension {
|
|
437
|
+
apiVersion: typeof CANOFOLD_EXTENSION_API_VERSION;
|
|
438
|
+
name: string;
|
|
439
|
+
/** Every generated path must be declared up front and is scoped under extensions/{name}/. */
|
|
440
|
+
outputs?: string[];
|
|
441
|
+
transformSource?(context: Readonly<CanofoldExtensionSourceContext>): string | Promise<string>;
|
|
442
|
+
extendPage?(page: Readonly<CanofoldExtensionPage>): CanofoldExtensionPagePatch | void | Promise<CanofoldExtensionPagePatch | void>;
|
|
443
|
+
generate?(context: CanofoldExtensionGenerateContext): void | Promise<void>;
|
|
444
|
+
}
|
|
445
|
+
type CanofoldExtensionOptions = {
|
|
446
|
+
[key: string]: CanofoldJsonValue;
|
|
447
|
+
};
|
|
448
|
+
type CanofoldExtensionFactory = (options: Readonly<CanofoldExtensionOptions>) => CanofoldExtension | Promise<CanofoldExtension>;
|
|
449
|
+
declare function defineExtension(extension: CanofoldExtension): CanofoldExtension;
|
|
450
|
+
declare function defineExtension(factory: CanofoldExtensionFactory): CanofoldExtensionFactory;
|
|
451
|
+
|
|
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
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderMarkdownOptions } from '@canofold/markdown';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__canofoldBootstrapMarkdown?: () => Promise<void>;
|
|
6
|
+
__canofoldEnhanceMarkdown?: (root: ParentNode) => Promise<() => void>;
|
|
7
|
+
__canofoldMarkdownDispose?: () => void;
|
|
8
|
+
__canofoldMarkdownReady?: Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface PlaygroundClientOptions {
|
|
12
|
+
basePath: string;
|
|
13
|
+
markdown: Omit<RenderMarkdownOptions, 'labels'>;
|
|
14
|
+
}
|
|
15
|
+
declare function mountPlaygrounds(options: PlaygroundClientOptions): void;
|
|
16
|
+
|
|
17
|
+
export { type PlaygroundClientOptions, mountPlaygrounds };
|
|
@@ -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
|