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
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": {
|
|
@@ -51,22 +56,22 @@
|
|
|
51
56
|
"chokidar": "^5.0.0",
|
|
52
57
|
"esbuild": "^0.28.2",
|
|
53
58
|
"gray-matter": "^4.0.3",
|
|
54
|
-
"lucide-react": "
|
|
59
|
+
"lucide-react": "1.34.0",
|
|
55
60
|
"react": "^19.2.8",
|
|
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-RBMQ6TZ7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-56TT2V3X.js";import"./chunk-4E7M3CIK.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-OATSOVSV.js";import"./chunk-4OALGQQB.js";import"./chunk-M6T5RSNJ.js";import"./chunk-3TIVCYR7.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{b as runBuild,a as versionSatisfies};
|
|
2
|
-
//# sourceMappingURL=build-RBMQ6TZ7.js.map
|
package/dist/check-FCYLN6KO.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{e as I,j as b,k as M}from"./chunk-4E7M3CIK.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as C,b as S,j as P}from"./chunk-4OALGQQB.js";import"./chunk-3TIVCYR7.js";import"./chunk-EAYVCA3Z.js";import{d as $}from"./chunk-JK7ZNBUA.js";import{a}from"./chunk-AYDF3IFZ.js";import{mkdtemp as W,readdir as V,rm as N}from"fs/promises";import{tmpdir as Q}from"os";import{join as O,relative as K}from"path";import{posix as y}from"path";import{analyzeMarkdown as w}from"@canofold/markdown/server/analyze";function E(e){return Array.from({length:w(e).missingCodeBlockLanguages},()=>({severity:"warning",message:"Code block is missing a language"}))}a(E,"checkCodeBlockLanguages");function H(e,n=0,o=[]){return w(e,{plugins:o}).directiveIssues.map(r=>({severity:"error",message:`${r.message}${r.line===void 0?"":` (line ${r.line+n}${r.column===void 0?"":`, column ${r.column}`})`}`}))}a(H,"checkRichDirectiveSyntax");function R(e){return typeof e.description=="string"&&e.description.trim()?[]:[{severity:"warning",message:"Frontmatter description is missing"}]}a(R,"checkFrontmatterDescription");function B(e,n){return typeof e.title=="string"&&e.title.trim()?[]:[{severity:"warning",page:n.relativePath,message:"Frontmatter title is missing"}]}a(B,"checkFrontmatterTitle");function L(e){return/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)}a(L,"isExternalTarget");function D(e){let n=e.indexOf("#"),o=n===-1?e:e.slice(0,n),r=n===-1?"":e.slice(n+1);return{path:o.split("?")[0]??"",fragment:r}}a(D,"splitTarget");function A(e){try{return decodeURIComponent(e)}catch{return}}a(A,"decodeFragment");function F(e,n){let o=n.split("/").map(r=>{let i=decodeURIComponent(r);if(i.includes("/")||i.includes("\\"))throw new Error("Encoded path separator");return i}).join("/");return y.normalize(y.join(y.dirname(e),o.replace(/^\.\//,"")))}a(F,"resolveRelativeTarget");function j(e){try{return`public${e.split("/").map(o=>{let r=decodeURIComponent(o);if(r.includes("/")||r.includes("\\")||r==="..")throw new Error("Invalid public path");return r}).join("/")}`}catch{return}}a(j,"publicFileFor");function T(e){return e.replace(/\.(?:md|mdx)$/i,n=>n.toLocaleLowerCase("en-US"))}a(T,"markdownExtensionKey");function z(e,n,o="",r=new Set,i=new Set,g=new Map,u=new Map,f=new Set){let c=[],k=w(e),h=new Map([...n].filter(t=>/\.(?:md|mdx)$/i.test(t)).map(t=>[T(t),t]));for(let t of k.images){let s=D(t).path;if(!s||L(s))continue;if(s.startsWith("/")){n.has(j(s)??"")||c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}let d;try{d=F(o,s)}catch{c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}n.has(d)||c.push({severity:"error",message:`Image target does not exist: ${s}`})}for(let t of k.links){let{path:s,fragment:d}=D(t),p=A(d);if(L(s))continue;if(!s){d&&(!p||!i.has(p))&&c.push({severity:"error",message:`Heading target does not exist: #${d}`});continue}if(s.startsWith("/")){if(n.has(j(s)??""))continue;let m;try{m=S(s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}if(f.has(m))continue;let x=m==="/"?"/":`${m.replace(/\/+$/,"")}/`;r.has(x)?d&&(!p||!g.get(x)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let l;try{l=F(o,s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let v=(/\.mdx?$/i.test(l)?[l]:[l,`${l}.md`,`${l}.mdx`,y.join(l,"index.md"),y.join(l,"index.mdx")]).map(m=>n.has(m)?m:h.get(T(m))).find(m=>!!m);v?d&&(!p||!u.get(v)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`})}return c}a(z,"checkLinksAndImages");function U(e){let n=new Map;for(let o of e.headings){let r=o.text.normalize("NFKC").replace(/\s+/g," ").trim().toLocaleLowerCase(e.locale);r&&n.set(r,[...n.get(r)??[],o])}return[...n.values()].filter(o=>o.length>1).map(o=>{let r=o[0];return{severity:"warning",page:e.relativePath,message:`Repeated heading "${r.text}" uses numbered anchors (${o.map(i=>`#${i.slug}`).join(", ")})`}})}a(U,"checkDuplicateHeadings");function G(e){let n=new Map;for(let r of e.pages){let i=`${r.version}:${C(r.relativePath,r.locale)}`;n.set(i,(n.get(i)??new Set).add(r.locale))}let o=[];for(let[r,i]of n)for(let g of e.locales)if(!i.has(g)){let[u,...f]=r.split(":");o.push({severity:"warning",message:`Missing ${g} translation for ${f.join(":")} in version ${u}`})}return o}a(G,"checkMissingTranslations");async function q(e){let n=new Set;async function o(r){let i=await V(r,{withFileTypes:!0});for(let g of i){let u=O(r,g.name);if(g.isDirectory())await o(u);else{if(g.isSymbolicLink())throw new Error(`Documentation files must not use symbolic links: ${K(e,u)}`);n.add(K(e,u).replace(/\\/g,"/"))}}}return a(o,"walk"),await o(e),n}a(q,"collectFiles");function J(e){if(!e.body)return 0;let n=e.transformedSource.lastIndexOf(e.body);return n<0?0:e.transformedSource.slice(0,n).split(`
|
|
2
|
-
`).length-1}a(J,"bodyLineOffset");async function ue({cwd:e}){let n=await P(e),o=await W(O(Q(),"canofold-check-")),r=await M(e,o,n.extensions).finally(()=>N(o,{recursive:!0,force:!0})),i=await I(e,n,r),g=new Set([...b(n,i),...r.publicOutputPaths]),u=new Map(await Promise.all(n.versions.items.map(async t=>[t.id,await q($(e,t.docsDir,`versions.items[${t.id}].docsDir`))]))),f=new Set(i.pages.map(t=>t.routePath)),c=new Map(i.pages.map(t=>[t.routePath,new Set(t.headings.map(s=>s.slug))])),k=new Map(i.versions.map(t=>[t.id,new Map(i.pages.filter(s=>s.version===t.id).map(s=>[s.relativePath,new Set(s.headings.map(d=>d.slug))]))])),h=[...i.pages.flatMap(t=>[...E(t.body).map(s=>({...s,page:t.relativePath})),...H(t.body,J(t),n.markdown.plugins).map(s=>({...s,page:t.relativePath})),...B(t.frontmatter,t),...R(t.frontmatter).map(s=>({...s,page:t.relativePath})),...z(t.body,u.get(t.version)??new Set,t.relativePath,f,new Set(t.headings.map(s=>s.slug)),c,k.get(t.version),g).map(s=>({...s,page:t.sourceRelativePath})),...U(t)]),...G(i)];for(let t of h){let s=t.page?` ${t.page}`:"";console.log(`${t.severity.toUpperCase()}:${s} ${t.message}`)}return h.some(t=>t.severity==="error")&&(process.exitCode=1),h}a(ue,"runCheck");export{ue as runCheck};
|
|
3
|
-
//# sourceMappingURL=check-FCYLN6KO.js.map
|
package/dist/chunk-3TIVCYR7.js
DELETED
package/dist/chunk-4E7M3CIK.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as X,b as Y,d as Q,f as E}from"./chunk-ENPRUF6E.js";import{a as R,b as W,d as K,e as q,f as B,g as k,h as O}from"./chunk-4OALGQQB.js";import{a as H}from"./chunk-3TIVCYR7.js";import{a as V,b as z,c as j}from"./chunk-EAYVCA3Z.js";import{a as I,b as P,d as U,e as _,f as J,h as v}from"./chunk-JK7ZNBUA.js";import{a as u}from"./chunk-AYDF3IFZ.js";import{analyzeMarkdown as Dt}from"@canofold/markdown/server/analyze";import jt from"gray-matter";import{join as It,posix as Rt}from"path";import{z as m}from"zod";var tt=["ai","box","code","file","file-code","gauge","globe","layers","rocket","search","sparkles","terminal"],Pt=m.object({text:m.string().min(1),link:O,primary:m.boolean().optional(),icon:m.enum(tt).optional()}).strict(),bt=m.object({accent:m.string().optional(),tagline:m.string().optional(),image:O.optional(),imageAlt:m.string().optional(),actions:m.array(Pt).refine(t=>t.filter(e=>e.primary).length<=1,{message:"Home page hero actions can contain at most one primary action"}).optional()}).strict(),Et=m.object({icon:m.enum(tt).optional(),image:O.optional(),title:m.string().min(1),details:m.string().min(1)}).strict(),$t=m.string().trim().refine(t=>m.string().date().safeParse(t).success||m.string().datetime({offset:!0}).safeParse(t).success,"Expected an ISO 8601 date"),Z=m.preprocess(t=>t instanceof Date?t.toISOString():t,$t.transform(t=>new Date(t).toISOString())),et=m.object({title:m.string().optional(),seoTitle:m.string().trim().min(1).optional(),description:m.string().optional(),createdAt:Z.optional(),updatedAt:Z.optional(),order:m.number().finite().optional(),group:m.string().optional(),subgroup:m.string().optional(),collapsed:m.boolean().optional(),sidebar:m.boolean().optional(),layout:m.enum(["document","playground"]).optional(),status:m.enum(["draft","published"]).optional(),search:m.boolean().optional(),ai:m.boolean().optional(),tags:m.array(m.string()).optional(),owner:m.string().optional(),hero:bt.optional(),features:m.array(Et).optional()}).passthrough();function le(t){return Object.fromEntries(["title","description","createdAt","updatedAt","order","group","subgroup","tags","owner"].flatMap(o=>t[o]===void 0?[]:[[o,t[o]]]))}u(le,"publicFrontmatterFor");import{readdir as St,readFile as Ct,stat as vt}from"fs/promises";import{join as kt,relative as nt}from"path";async function ot(t,e,o){if(!Number.isFinite(e)||e<1)throw new Error("Concurrency must be a positive finite number");let r=new Array(t.length),n=0,i,l=Math.min(Math.floor(e),t.length);if(await Promise.all(Array.from({length:l},async()=>{for(;n<t.length&&i===void 0;){let c=n++;try{r[c]=await o(t[c],c)}catch(p){i??=p}}})),i)throw i;return r}u(ot,"mapConcurrent");var Ot=32;async function rt(t){async function e(n){let i=[],l=[n];for(;l.length>0;){let c=l.pop();if(!c)continue;let p=await St(c,{withFileTypes:!0});for(let a of p){let s=kt(c,a.name);if(a.isSymbolicLink())throw new Error(`Documentation content must not use symbolic links: ${nt(t,s)}`);a.isDirectory()?l.push(s):a.isFile()&&V(a.name)&&i.push(s)}}return i}u(e,"walk");let o=await e(t);return(await ot(o,Ot,async n=>{let[i,l]=await Promise.all([vt(n),Ct(n,"utf8")]);return{path:nt(t,n),raw:l,mtimeMs:i.mtimeMs}})).sort((n,i)=>n.path.localeCompare(i.path))}u(rt,"scanMarkdownFiles");function it(t){return t.split("-").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}u(it,"humanize");function $(t){return j(R(t.relativePath,t.locale))}u($,"isLocaleHome");function Nt(t){return{type:"link",title:t.title||t.routePath,routePath:t.routePath}}u(Nt,"sidebarLink");function st(t){return R(t.relativePath,t.locale).split("/")}u(st,"pageSegments");function at(t){return st(t).slice(0,-1)}u(at,"pageDirectorySegments");function Tt(t){return j(st(t).at(-1)??"")}u(Tt,"isDirectoryIndex");function Ft(t){let e=new Map,o=new Map,r=new Map;for(let n of t)if(Tt(n)&&o.set(at(n).join("/"),n),n.group&&typeof n.frontmatter.group=="string"){let i=r.get(n.group);if(i&&i!==n.frontmatter.group)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${i}" and "${n.frontmatter.group}"`);r.set(n.group,n.frontmatter.group)}for(let n of t){if($(n)||n.frontmatter.sidebar===!1)continue;let i=at(n),l=i[0]??"",c=o.get(l),p=l?typeof c?.frontmatter.group=="string"?c.frontmatter.group:c?.title||r.get(l)||it(l):"";if(typeof n.frontmatter.group=="string"&&n.frontmatter.group!==p)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${p}" and "${n.frontmatter.group}"`);let a=e.get(l);if(!a)a={segment:l,title:p,items:[]},e.set(l,a);else if(a.title!==p)throw new Error(`Inconsistent group name for locale "${n.locale}" directory "${n.group}": "${a.title}" and "${p}"`);let s=a.items;for(let f=1;f<i.length;f+=1){let d=i[f];if(!d)continue;let g=i.slice(0,f+1).join("/"),h=o.get(g),w=f===1&&typeof n.frontmatter.subgroup=="string"?n.frontmatter.subgroup:void 0,y=(f===1&&typeof h?.frontmatter.subgroup=="string"?h.frontmatter.subgroup:void 0)??h?.title??w??it(d);if(w&&w!==y)throw new Error(`Inconsistent subgroup name for locale "${n.locale}" directory "${g}"`);let b=s.find(C=>C.type==="group"&&C.segment===d),x=b??{type:"group",segment:d,title:y,collapsed:h?.frontmatter.collapsed===!0,items:[]};b||s.push(x),s=x.items}s.push(Nt(n))}return[...e.values()]}u(Ft,"buildSidebar");function N(t){if(t.type==="link")return t;for(let e of t.items){let o=N(e);if(o)return o}}u(N,"firstSidebarLink");function At(t){return t.flatMap(e=>{let o=e.items[0]?N(e.items[0]):void 0;return e.title&&o?[{title:e.title,routePath:o.routePath}]:[]})}u(At,"buildAutomaticNav");function Gt(t,e){return!t.startsWith("/")||e.base==="/"?t:`${e.base}${t.replace(/^\//,"")}`}u(Gt,"versionedNavLink");function Mt(t,e){return t.map(o=>({title:o.text,routePath:Gt(o.link,e)}))}u(Mt,"buildConfiguredNav");function Lt(t,e){return t.map(o=>{if(!o.routePath.startsWith("/"))return o;let r=o.routePath.split("/").filter(Boolean),n=e.find(l=>l.segment&&r.at(-1)===l.segment&&r.length>0),i=n?.items[0]?N(n.items[0]):void 0;return i?{...o,routePath:i.routePath}:o})}u(Lt,"anchorConfiguredNavToSidebar");function Vt(t){let e=new Map;for(let o of t)for(let[r,n]of[["route",o.routePath],["output",o.outputPath],["markdown output",o.markdownOutputPath]]){let i=`${r}:${P(n)}`,l=e.get(i);if(l)throw new Error(`Duplicate ${r} target ${n} for ${l.sourceRelativePath} and ${o.sourceRelativePath}`);e.set(i,o)}}u(Vt,"assertUniquePageTargets");async function zt(t,e,o,r){let n=U(t,o.docsDir,`versions.items[${o.id}].docsDir`),i=await rt(n),l=[];for(let c of i){let p=c.path.split(/[\\/]/);if(p[0]==="public")continue;let a=p[0]&&e.i18n.locales.includes(p[0])?p[0]:void 0,s=a??e.i18n.defaultLocale,f=a?p.slice(1):p;if(f.length===0)continue;let d=f.join("/"),g=Rt.join(o.docsDir.replace(/\\/g,"/"),c.path.replace(/\\/g,"/")),h=r?await r.transformSource({source:c.raw,sourceRelativePath:g,relativePath:c.path.replace(/\\/g,"/"),kind:z(c.path)?"mdx":"markdown",version:o.id,locale:s}):c.raw,w=jt(h),y=et.parse(w.data),b=y.status??"published";if(b==="draft")continue;let x=Dt(w.content),C=typeof y.order=="number"&&Number.isFinite(y.order)?y.order:Number.MAX_SAFE_INTEGER,xt=c.path.replace(/\\/g,"/"),L={sourcePath:It(n,c.path),transformedSource:h,sourceRelativePath:g,relativePath:xt,version:o.id,versionBase:o.base,docsDir:o.docsDir,locale:s,routePath:K(s,e.i18n.defaultLocale,d,o.base),outputPath:q(s,e.i18n.defaultLocale,d,o.base),markdownOutputPath:B(s,e.i18n.defaultLocale,d,o.base),title:typeof y.title=="string"?y.title:x.headings[0]?.text??"",description:typeof y.description=="string"?y.description:"",order:C,group:f.length>1?f[0]??"":"",status:b,search:y.search!==!1,ai:y.ai!==!1,body:w.content,headings:x.headings,searchText:x.text,codeExamples:x.codeExamples,lastUpdated:y.updatedAt??new Date(c.mtimeMs).toISOString(),frontmatter:y};l.push(r?await r.extendPage(L):L)}return l}u(zt,"scanVersionPages");async function De(t,e,o){let r=[];for(let a of e.versions.items)for(let s of await zt(t,e,a,o))r.push(s);let n=new Map(e.versions.items.map((a,s)=>[a.id,s])),i=new Map(e.i18n.locales.map((a,s)=>[a,s]));r.sort((a,s)=>{let f=(n.get(a.version)??0)-(n.get(s.version)??0);if(f!==0)return f;let d=(i.get(a.locale)??0)-(i.get(s.locale)??0);if(d!==0)return d;let g=$(a),h=$(s);return g!==h?g?-1:1:a.order!==s.order?a.order-s.order:a.routePath.localeCompare(s.routePath)}),Vt(r);for(let a of e.versions.items)for(let s of e.i18n.locales)if(!r.some(f=>f.version===a.id&&f.locale===s&&$(f)))throw new Error(`Missing published home page for version "${a.id}" locale "${s}"`);for(let a of e.versions.items)for(let s of e.i18n.locales){let f=r.filter(d=>d.version===a.id&&d.locale===s&&!$(d));f.forEach((d,g)=>{let h=f[g-1],w=f[g+1];h&&(d.previous={title:h.title||h.routePath,routePath:h.routePath}),w&&(d.next={title:w.title||w.routePath,routePath:w.routePath})})}let l={},c={};for(let a of e.versions.items){let s={},f={};l[a.id]=s,c[a.id]=f;for(let d of e.i18n.locales){let g=Ft(r.filter(h=>h.version===a.id&&h.locale===d));s[d]=g,f[d]=e.navigation[d]?Lt(Mt(e.navigation[d],a),g):At(g)}}let p=new Set(r.map(a=>a.routePath));for(let a of Object.values(c))for(let s of Object.values(a))for(let f of s)if(f.routePath.startsWith("/")&&!p.has(f.routePath))throw new Error(`Navigation target is not a generated page: "${f.routePath}"`);return{pages:r,sidebar:l,nav:c,locales:e.i18n.locales,defaultLocale:e.i18n.defaultLocale,versions:e.versions.items.map(a=>({...a})),currentVersion:e.versions.current}}u(De,"buildContentGraph");import{mkdir as Ut,writeFile as ct}from"fs/promises";import{dirname as _t,join as Jt}from"path";var Ht={"&":"&","<":"<",">":">",'"':""","'":"'"};function T(t){return t.replace(/[&<>"']/g,e=>Ht[e]??e)}u(T,"escapeHtml");function F(t){let e=t==="/"?"/":`${t.replace(/\/+$/,"")}/`;return W(e)}u(F,"normalizeRedirectRoute");function A(t,e){let o=new Set(e.pages.map(i=>F(i.routePath))),r=Object.entries(t.redirects).map(([i,l])=>[F(i),F(l)]),n=new Set(r.map(([i])=>i));for(let[i,l]of r){if(i==="/")throw new Error("Redirect source must not replace the site root");if(o.has(i))throw new Error(`Redirect source collides with a generated page: "${i}"`);if(n.has(l))throw new Error(`Redirect chains are not allowed: "${i}" points to redirect "${l}"`);if(!o.has(l))throw new Error(`Redirect target is not a published generated page: "${l}"`)}if(n.size!==r.length)throw new Error("Redirect sources must be unique after route normalization");return r}u(A,"resolveRedirects");async function Ve(t,e,o){let r=A(e,o);if(r.length===0)return;let n=_(t,e.outputDir);for(let[i,l]of r){let c=v(n,k(i),"redirect route"),p=Y(e,l),a=T(p),s=T(X(e,l)??p),f=JSON.stringify(p).replace(/</g,"\\u003c"),d=`<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><link rel="canonical" href="${s}"><meta http-equiv="refresh" content="0;url=${a}"><script>location.replace(${f})</script></head><body><a href="${a}">Redirecting to ${a}</a></body></html>`;await Ut(_t(c),{recursive:!0}),await ct(c,d)}await ct(Jt(n,"redirects.json"),JSON.stringify(Object.fromEntries(r),null,2))}u(Ve,"writeRedirects");import{posix as ut}from"path";var Wt=new Set([".benchmark.json"]),Kt=["assets/canofold-markdown","assets/canofold-playground","assets/canofold-plugins","assets/fonts","pagefind","ai/content","extensions"];function lt(t){let e=new Map;for(let o of t){let r=P(o),n=Kt.find(l=>r===l||r.startsWith(`${l}/`));if(n)throw new Error(`Generated output uses reserved directory "${n}": "${o}"`);let i=e.get(r);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${o}"`);e.set(r,o)}for(let[o,r]of e){let n=ut.dirname(o);for(;n!==".";){let i=e.get(n);if(i)throw new Error(`Generated outputs overlap: "${i}" and "${r}"`);n=ut.dirname(n)}}}u(lt,"assertGeneratedOutputPlan");function pt(t,e){let o=[".benchmark.json","404.html","assets/canofold.css","robots.txt","ai/pages.json","ai/manifest.json",...e.pages.flatMap(n=>[n.outputPath,n.markdownOutputPath])];if(t.search.enabled&&(o.push("assets/canofold-search.js"),Q(t.search.provider)==="compact"))for(let n of e.versions)for(let i of e.locales)o.push(n.id===e.currentVersion?`search/${i}.json`:`search/${n.id}/${i}.json`);t.siteUrl&&o.push("sitemap.xml"),t.ai.pageSummaries&&o.push("ai/summaries.json"),t.ai.codeExamples&&o.push("ai/code-examples.json"),t.ai.markdownIndex&&o.push("ai/index.md"),t.ai.llmsTxt&&o.push("llms.txt"),t.ai.llmsFullTxt&&o.push("llms-full.txt");let r=A(t,e);if(r.length){o.push("redirects.json");for(let[n]of r)o.push(k(n))}return{paths:o,redirects:r}}u(pt,"plannedOutputPaths");function qe(t,e){let{paths:o}=pt(t,e);return lt(o),new Set(o)}u(qe,"generatedOutputPaths");function Be(t,e){let{paths:o,redirects:r}=pt(t,e);return lt(o),new Set([...o.filter(n=>!Wt.has(n)).map(n=>`/${n.split("/").map(encodeURIComponent).join("/")}`),...r.map(([n])=>n)])}u(Be,"generatedPublicPaths");import{randomUUID as Bt}from"crypto";import{mkdir as mt,readFile as Xt,rm as Yt,writeFile as gt}from"fs/promises";import{dirname as Qt,join as ht,posix as wt,resolve as Zt}from"path";import{pathToFileURL as te}from"url";import{build as ee}from"esbuild";import{createHash as ft}from"crypto";function G(t,e){if(t===null||typeof t=="boolean"||typeof t=="string")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError("Fingerprint values must contain only finite numbers");return t}if(typeof t!="object")throw new TypeError("Fingerprint values must be JSON-serializable");if(e.has(t))throw new TypeError("Fingerprint values must not be circular");let o=Object.getPrototypeOf(t);if(!Array.isArray(t)&&o!==Object.prototype&&o!==null)throw new TypeError("Fingerprint values must be JSON-serializable plain objects");e.add(t);try{if(Array.isArray(t)){if(Object.keys(t).length!==t.length)throw new TypeError("Fingerprint values must not contain sparse arrays");return t.map(n=>G(n,e))}let r=Object.entries(t).sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>[n,G(i,e)]);return Object.fromEntries(r)}finally{e.delete(t)}}u(G,"canonicalValue");function qt(t){return JSON.stringify(G(t,new WeakSet))}u(qt,"stableJson");function S(t){return ft("sha256").update(qt(t)).digest("hex")}u(S,"fingerprint");function M(t){return ft("sha256").update(t).digest("hex")}u(M,"fingerprintBytes");var oe=new Set(["apiVersion","name","outputs","transformSource","extendPage","generate"]),ne=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"];function D(t){return t instanceof Error?t.message:String(t)}u(D,"errorMessage");function dt(t){return{sourceRelativePath:t.sourceRelativePath,relativePath:t.relativePath,version:t.version,locale:t.locale,routePath:t.routePath,title:t.title,description:t.description,status:t.status,search:t.search,ai:t.ai,body:t.body,searchText:t.searchText,frontmatter:structuredClone(t.frontmatter)}}u(dt,"extensionPage");function yt(t,e){if(!e||e.includes("\\")||e.startsWith("/")||e!==wt.normalize(e))throw new Error(`Extension "${t}" output must be a normalized relative POSIX path: "${e}"`);if(e.split("/").some(o=>o==="."||o===".."||!o))throw new Error(`Extension "${t}" output must not contain empty, . or .. segments: "${e}"`);return e}u(yt,"normalizeDeclaredOutput");function re(t,e){if(!t||typeof t!="object")throw new Error(`Extension ${e.resolve} must export an extension object or factory`);let o=t,r=Object.keys(o).find(n=>!oe.has(n));if(r)throw new Error(`Extension ${e.resolve} has unknown key "${r}"`);if(o.apiVersion!==1)throw new Error(`Extension ${e.resolve} uses unsupported apiVersion ${String(o.apiVersion)}; expected ${1}`);if(typeof o.name!="string"||!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(o.name))throw new Error(`Extension ${e.resolve} name must be a lowercase portable slug`);for(let n of["transformSource","extendPage","generate"])if(o[n]!==void 0&&typeof o[n]!="function")throw new Error(`Extension "${o.name}" hook ${n} must be a function`);if(o.outputs!==void 0&&!Array.isArray(o.outputs))throw new Error(`Extension "${o.name}" outputs must be an array`);if(o.generate&&!o.outputs?.length)throw new Error(`Extension "${o.name}" with generate() must declare outputs`);if(!o.generate&&o.outputs?.length)throw new Error(`Extension "${o.name}" declares outputs without generate()`);return o}u(re,"assertDefinition");function ie(t,e){if(e===void 0)return{};if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Extension "${t}" extendPage() must return an object or undefined`);let o=new Set(["title","description","searchText","search","ai"]),r=Object.keys(e).find(i=>!o.has(i));if(r)throw new Error(`Extension "${t}" extendPage() returned unknown key "${r}"`);let n=e;for(let i of["title","description","searchText"])if(n[i]!==void 0&&typeof n[i]!="string")throw new Error(`Extension "${t}" extendPage() field ${i} must be a string`);for(let i of["search","ai"])if(n[i]!==void 0&&typeof n[i]!="boolean")throw new Error(`Extension "${t}" extendPage() field ${i} must be a boolean`);return e}u(ie,"assertPagePatch");async function ae(t){let e=[];for(let o of ne){let r=ht(t,o);await I(r)&&e.push({path:o,fingerprint:M(await Xt(r))})}return S(e)}u(ae,"lockfileFingerprint");async function se(t,e,o){let r=Zt(t,o.resolve);if(await J(t,r,`extension ${o.resolve}`),!await I(r))throw new Error(`Extension module not found: ${o.resolve}`);let i=(await ee({entryPoints:[r],bundle:!0,format:"esm",platform:"node",target:"node22",write:!1,sourcemap:"inline",plugins:[{name:"canofold-extension-api",setup(c){c.onResolve({filter:/^canofold$/},()=>({path:"canofold-extension-api",namespace:"canofold-extension-api"})),c.onLoad({filter:/.*/,namespace:"canofold-extension-api"},()=>({loader:"js",contents:`
|
|
2
|
-
export const CANOFOLD_EXTENSION_API_VERSION = ${JSON.stringify(1)}
|
|
3
|
-
export const canofoldVersion = ${JSON.stringify(H)}
|
|
4
|
-
export const defineExtension = (factory) => factory
|
|
5
|
-
`}))}}]})).outputFiles[0];if(!i)throw new Error(`Failed to bundle extension ${o.resolve}`);await mt(e,{recursive:!0});let l=ht(e,`extension-${Bt()}.mjs`);await gt(l,i.contents);try{let p=(await import(`${te(l).href}?t=${Date.now()}`)).default,a=typeof p=="function"?await p(structuredClone(o.options??{})):p,s=re(a,o),f=(s.outputs??[]).map(d=>yt(s.name,d));if(new Set(f.map(P)).size!==f.length)throw new Error(`Extension "${s.name}" declares duplicate portable output paths`);return{definition:s,declaredOutputs:new Set(f),fingerprint:S({descriptor:o,bundle:M(i.contents)})}}finally{await Yt(l,{force:!0})}}u(se,"loadOneExtension");async function lo(t,e,o){let r=[];for(let c of o)try{r.push(await se(t,e,c))}catch(p){throw new Error(`Failed to load extension ${c.resolve}: ${D(p)}`,{cause:p})}let n=new Set;for(let c of r){if(n.has(c.definition.name))throw new Error(`Duplicate extension name "${c.definition.name}"`);n.add(c.definition.name)}let i=r.length?await ae(t):S({lockfiles:[]}),l=r.flatMap(({definition:c,declaredOutputs:p})=>[...p].map(a=>`/extensions/${c.name}/${a.split("/").map(encodeURIComponent).join("/")}`));return{fingerprint:S({apiVersion:1,dependencyFingerprint:i,extensions:r.map(c=>({name:c.definition.name,fingerprint:c.fingerprint}))}),publicOutputPaths:l,async transformSource(c){let p=c.source;for(let{definition:a}of r)if(a.transformSource)try{let s=await a.transformSource({...c,source:p});if(typeof s!="string")throw new Error("transformSource() must return a string");p=s}catch(s){throw new Error(`Extension "${a.name}" transformSource failed for ${c.sourceRelativePath}: ${D(s)}`,{cause:s})}return p},async extendPage(c){let p=c;for(let{definition:a}of r)if(a.extendPage)try{let s=ie(a.name,await a.extendPage(dt(p)));p={...p,...s}}catch(s){throw new Error(`Extension "${a.name}" extendPage failed for ${p.sourceRelativePath}: ${D(s)}`,{cause:s})}return p},async generate(c,p){for(let{definition:a,declaredOutputs:s}of r){if(!a.generate)continue;let f=new Set;try{await a.generate({pages:p.map(dt),emitFile:u(async(g,h)=>{let w=yt(a.name,g);if(!s.has(w))throw new Error(`generate() emitted undeclared output "${w}"`);if(f.has(w))throw new Error(`generate() emitted "${w}" more than once`);f.add(w);let y=v(c,wt.join("extensions",a.name,w),`extension ${a.name} output`);await mt(Qt(y),{recursive:!0}),await gt(y,h)},"emitFile")});let d=[...s].filter(g=>!f.has(g));if(d.length)throw new Error(`generate() did not emit declared outputs: ${d.join(", ")}`)}catch(d){throw new Error(`Extension "${a.name}" generate failed: ${D(d)}`,{cause:d})}}}}}u(lo,"loadExtensionHost");export{S as a,M as b,le as c,ot as d,De as e,T as f,Ve as g,Kt as h,qe as i,Be as j,lo as k};
|
|
6
|
-
//# sourceMappingURL=chunk-4E7M3CIK.js.map
|
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
|