@dooc-dev/dooc 0.0.4 → 0.0.6

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.
Files changed (231) hide show
  1. package/dist/cli.js +157 -58
  2. package/dist/code-worker.global.js +152 -0
  3. package/dist/code.global.js +101 -101
  4. package/dist/compiler/asset-references.d.ts +4 -0
  5. package/dist/compiler/asset-references.js +117 -0
  6. package/dist/compiler/bundle-urls.d.ts +1 -1
  7. package/dist/compiler/bundle-urls.js +17 -5
  8. package/dist/compiler/check.js +10 -5
  9. package/dist/compiler/code-languages.js +7 -2
  10. package/dist/compiler/compile.d.ts +5 -0
  11. package/dist/compiler/compile.js +117 -12
  12. package/dist/compiler/config.js +2 -1
  13. package/dist/compiler/dxf.d.ts +1 -0
  14. package/dist/compiler/dxf.js +81 -0
  15. package/dist/compiler/export.d.ts +4 -0
  16. package/dist/compiler/export.js +147 -0
  17. package/dist/compiler/figures.js +43 -10
  18. package/dist/compiler/files.js +82 -41
  19. package/dist/compiler/fonts.js +4 -1
  20. package/dist/compiler/icons.d.ts +1 -1
  21. package/dist/compiler/icons.js +11 -2
  22. package/dist/compiler/ignored-files.d.ts +5 -0
  23. package/dist/compiler/ignored-files.js +98 -0
  24. package/dist/compiler/locales.js +13 -8
  25. package/dist/compiler/ops.d.ts +6 -0
  26. package/dist/compiler/ops.js +99 -8
  27. package/dist/compiler/subformat-schema.d.ts +14 -0
  28. package/dist/compiler/subformat-schema.js +92 -0
  29. package/dist/compiler/subformats.d.ts +22 -0
  30. package/dist/compiler/subformats.js +339 -0
  31. package/dist/compiler/textfile.js +3 -0
  32. package/dist/compiler/theme-variants.js +5 -2
  33. package/dist/core/code-file.js +7 -5
  34. package/dist/core/code-grammars.d.ts +5 -0
  35. package/dist/core/code-grammars.js +34 -0
  36. package/dist/core/content-metadata.d.ts +16 -6
  37. package/dist/core/content-metadata.js +283 -17
  38. package/dist/core/content-types.d.ts +4 -2
  39. package/dist/core/escape-html.d.ts +1 -0
  40. package/dist/core/escape-html.js +1 -0
  41. package/dist/core/figure-frame.js +20 -2
  42. package/dist/core/file-embed.js +7 -3
  43. package/dist/core/files.d.ts +2 -1
  44. package/dist/core/files.js +6 -8
  45. package/dist/core/flow-base-css.generated.js +1 -1
  46. package/dist/core/html.d.ts +4 -1
  47. package/dist/core/html.js +11 -10
  48. package/dist/core/icons.d.ts +3 -0
  49. package/dist/core/icons.js +3 -0
  50. package/dist/core/json-tools.d.ts +1 -0
  51. package/dist/core/json-tools.js +12 -0
  52. package/dist/core/language.js +5 -2
  53. package/dist/core/markdown.js +3 -1
  54. package/dist/core/previewers.d.ts +8 -0
  55. package/dist/core/previewers.js +2 -0
  56. package/dist/core/routing.d.ts +5 -2
  57. package/dist/core/routing.js +17 -5
  58. package/dist/core/schema-fields.d.ts +13 -0
  59. package/dist/core/schema-fields.js +175 -0
  60. package/dist/core/schema-graph-mount.js +26 -3
  61. package/dist/core/schema-refs.d.ts +8 -0
  62. package/dist/core/schema-refs.js +82 -0
  63. package/dist/core/subformat-record.d.ts +3 -0
  64. package/dist/core/subformat-record.js +131 -0
  65. package/dist/core/subformats.d.ts +43 -0
  66. package/dist/core/subformats.js +81 -0
  67. package/dist/core/toc-ui.js +26 -24
  68. package/dist/edit.global.js +326 -118
  69. package/dist/flow.global.js +3 -3
  70. package/dist/graph/abnfDiagram-S7VZAUFO-ASBULSKE.js +1 -0
  71. package/dist/graph/architecture-WOLXFQ4H-V57EDXXY.js +1 -0
  72. package/dist/graph/architectureDiagram-YGSQEFNW-GIMP347N.js +36 -0
  73. package/dist/graph/blockDiagram-APKKGZFW-RDL2T4JW.js +140 -0
  74. package/dist/graph/bpmnIcons-APHXDYXF-TWOSQNUQ.js +1 -0
  75. package/dist/graph/c4Diagram-KJ2TOQU5-75LIUC4F.js +38 -0
  76. package/dist/graph/chunk-26TUJSYJ.js +1 -0
  77. package/dist/graph/chunk-3LU66YMI.js +1 -0
  78. package/dist/graph/chunk-3RNHDNP5.js +1 -0
  79. package/dist/graph/chunk-3Y2PDVDE.js +1 -0
  80. package/dist/graph/chunk-3YJHMOOA.js +3 -0
  81. package/dist/graph/chunk-4KILFWYV.js +339 -0
  82. package/dist/graph/chunk-4QDE4SUK.js +1 -0
  83. package/dist/graph/chunk-5OO6DATX.js +1 -0
  84. package/dist/graph/chunk-5UUEAHTN.js +1 -0
  85. package/dist/graph/chunk-6T55RVVR.js +1 -0
  86. package/dist/graph/chunk-ARAJTKOH.js +2 -0
  87. package/dist/graph/chunk-BBD5CEDC.js +72 -0
  88. package/dist/graph/chunk-BVXT562I.js +1 -0
  89. package/dist/graph/chunk-BZAMCJ6B.js +32 -0
  90. package/dist/graph/chunk-C6J4A356.js +15 -0
  91. package/dist/graph/chunk-EG5UVNOC.js +213 -0
  92. package/dist/graph/chunk-GF4TOPUK.js +1 -0
  93. package/dist/graph/chunk-GYT4IYBZ.js +1 -0
  94. package/dist/graph/chunk-HJG2HUYJ.js +88 -0
  95. package/dist/graph/chunk-HOPPTA6H.js +62 -0
  96. package/dist/graph/chunk-I3DMZIHV.js +1 -0
  97. package/dist/graph/chunk-IC23EEF6.js +1 -0
  98. package/dist/graph/chunk-ISO77HML.js +1 -0
  99. package/dist/graph/chunk-JD7ZBJD2.js +1 -0
  100. package/dist/graph/chunk-JRSH5GNS.js +1 -0
  101. package/dist/graph/chunk-JSHWCPFJ.js +1 -0
  102. package/dist/graph/chunk-K2KLZU7M.js +10 -0
  103. package/dist/graph/chunk-K4I76XBX.js +14 -0
  104. package/dist/graph/chunk-KT4VPQD5.js +135 -0
  105. package/dist/graph/chunk-KU6GTEMS.js +1 -0
  106. package/dist/graph/chunk-LT6LXKCR.js +136 -0
  107. package/dist/graph/chunk-MPR575IN.js +1 -0
  108. package/dist/graph/chunk-N3OHKGRZ.js +1 -0
  109. package/dist/graph/chunk-O656ZI37.js +1 -0
  110. package/dist/graph/chunk-OFZLK5G4.js +1 -0
  111. package/dist/graph/chunk-PDH25ALM.js +2 -0
  112. package/dist/graph/chunk-PW2RGZ3O.js +1 -0
  113. package/dist/graph/chunk-QCJUF4YA.js +1 -0
  114. package/dist/graph/chunk-QEEA3KYY.js +2 -0
  115. package/dist/graph/chunk-QYAXYFNI.js +1 -0
  116. package/dist/graph/chunk-QYTM6GY3.js +1 -0
  117. package/dist/graph/chunk-R63JUMUK.js +1 -0
  118. package/dist/graph/chunk-SCEY3ZPT.js +1 -0
  119. package/dist/graph/chunk-VM2H7G2R.js +1 -0
  120. package/dist/graph/chunk-XQS73SBQ.js +1 -0
  121. package/dist/graph/chunk-YCRLJT2S.js +1 -0
  122. package/dist/graph/chunk-Z4FIZ7CR.js +1 -0
  123. package/dist/graph/chunk-ZMCB7VP2.js +1 -0
  124. package/dist/graph/chunk-ZSZXN4BT.js +2 -0
  125. package/dist/graph/classDiagram-v2-L25IHNXF-JL7LVDZH.js +217 -0
  126. package/dist/graph/cose-bilkent-JH36ORCC-PNM3EYPB.js +1 -0
  127. package/dist/graph/cynefin-EF2NZ3EQ-PSXP3DXL.js +1 -0
  128. package/dist/graph/cynefinDiagram-L36ESFBY-QVY54CXO.js +62 -0
  129. package/dist/graph/dagre-SPEB5RXH-HPGQXBZJ.js +4 -0
  130. package/dist/graph/diagram-3B7GL73J-DWH5WS2P.js +200 -0
  131. package/dist/graph/diagram-DNEMPZML-TEGH2U5I.js +24 -0
  132. package/dist/graph/diagram-L3MUGCDN-X4MREUWR.js +41 -0
  133. package/dist/graph/diagram-LA4NIPWU-NXT746HG.js +24 -0
  134. package/dist/graph/diagram-MHCOC4E2-JGHXSAGS.js +3 -0
  135. package/dist/graph/diagram-XPFHEONP-ZHZPBLT4.js +30 -0
  136. package/dist/graph/ebnfDiagram-UZSYDL2S-SMF6KJ43.js +1 -0
  137. package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +27 -0
  138. package/dist/graph/erDiagram-EYBAPDEH-B3JNJ357.js +99 -0
  139. package/dist/graph/eventmodeling-K75KTNOO-WG6DDYMC.js +1 -0
  140. package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +1 -0
  141. package/dist/graph/ganttDiagram-23REXITY-YXBYWFOJ.js +292 -0
  142. package/dist/graph/gitGraph-VSP46ZUC-VBFWJBBT.js +1 -0
  143. package/dist/graph/gitGraphDiagram-STJD7YCW-4FZDCFGV.js +106 -0
  144. package/dist/graph/info-OHQRW6UA-ALVDUVYV.js +1 -0
  145. package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +2 -0
  146. package/dist/graph/ishikawaDiagram-M35NCXHK-FRZD2PWQ.js +70 -0
  147. package/dist/graph/journeyDiagram-OPLOXDXO-7Z66JCPR.js +139 -0
  148. package/dist/graph/kanban-definition-BZKZHSQY-NN5AIKTE.js +89 -0
  149. package/dist/graph/katex-DXDNVO6V.js +257 -0
  150. package/dist/graph/mindmap-definition-I2QAS2VK-HDPCABN2.js +98 -0
  151. package/dist/graph/packet-JDAUHWVQ-5MQIBWAH.js +1 -0
  152. package/dist/graph/pegDiagram-FD4XPPHP-H2BFNCKT.js +1 -0
  153. package/dist/graph/pie-XZMESJXO-T5VRKHVT.js +1 -0
  154. package/dist/graph/pieDiagram-J4AKIIQI-O3NJSVD3.js +39 -0
  155. package/dist/graph/quadrantDiagram-XTYBLID2-TMTZJI3P.js +7 -0
  156. package/dist/graph/radar-ABXABTNO-C6FXIBYW.js +1 -0
  157. package/dist/graph/railroad-I3PHUGI6-ZSO5JXB3.js +1 -0
  158. package/dist/graph/railroad-abnf-LNEFI6M7-CI4GQRHB.js +1 -0
  159. package/dist/graph/railroad-ebnf-DWYD2UWJ-MUENNCGK.js +1 -0
  160. package/dist/graph/railroad-peg-JR7BVNR7-N3X5GGIX.js +1 -0
  161. package/dist/graph/railroadDiagram-MRQ6NCDL-JHWS23UO.js +1 -0
  162. package/dist/graph/requirementDiagram-Y7LWUY3S-7DVLPO4B.js +84 -0
  163. package/dist/graph/sankeyDiagram-WGJFYUXA-Z5L4R5TR.js +40 -0
  164. package/dist/graph/schema-graph-global.js +639 -0
  165. package/dist/graph/sequenceDiagram-5NDRBG5M-RCTU25NT.js +169 -0
  166. package/dist/graph/sizeCapture-INFHLROL-RROY32P5.js +1 -0
  167. package/dist/graph/stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js +291 -0
  168. package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +1 -0
  169. package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +8 -0
  170. package/dist/graph/timeline-definition-SEUHKTQE-ZQSMIVAS.js +120 -0
  171. package/dist/graph/treeView-D4JQ5SDB-42S7U73N.js +1 -0
  172. package/dist/graph/treemap-SAJKECNS-RUBYQ7XF.js +1 -0
  173. package/dist/graph/usecaseDiagram-AFA6YXN4-57RDRYXF.js +370 -0
  174. package/dist/graph/vennDiagram-NNMJR3RB-5C3LVAV6.js +34 -0
  175. package/dist/graph/wardley-7MLQ67FV-NV5HXTTC.js +1 -0
  176. package/dist/graph/wardleyDiagram-S7YFUSEH-6D5BKXHM.js +78 -0
  177. package/dist/graph/xychartDiagram-GGNKY7IX-6ET3ZM67.js +7 -0
  178. package/dist/mcp.js +54 -12
  179. package/dist/plugins/index.d.ts +1 -0
  180. package/dist/plugins/transport.d.ts +22 -0
  181. package/dist/plugins/transport.js +1 -0
  182. package/dist/plugins.global.js +95 -0
  183. package/dist/subformats.global.js +21 -0
  184. package/dist/ui.global.js +80 -60
  185. package/dist/viewer/build-plugins.d.ts +7 -0
  186. package/dist/viewer/build-plugins.js +70 -0
  187. package/dist/viewer/build.d.ts +11 -0
  188. package/dist/viewer/build.js +52 -11
  189. package/dist/viewer/code-file.js +7 -2
  190. package/dist/viewer/editor-tools.d.ts +7 -7
  191. package/dist/viewer/editor-tools.js +36 -5
  192. package/dist/viewer/figure-preview.d.ts +4 -0
  193. package/dist/viewer/figure-preview.js +54 -0
  194. package/dist/viewer/font-picker.js +5 -1
  195. package/dist/viewer/git-diff.d.ts +3 -0
  196. package/dist/viewer/git-diff.js +47 -0
  197. package/dist/viewer/hmr.js +8 -4
  198. package/dist/viewer/i18n.js +7 -5
  199. package/dist/viewer/language-picker.d.ts +2 -2
  200. package/dist/viewer/language-picker.js +26 -9
  201. package/dist/viewer/lazy-preview.d.ts +2 -0
  202. package/dist/viewer/lazy-preview.js +43 -0
  203. package/dist/viewer/locales/eng.json +95 -10
  204. package/dist/viewer/locales/jpn.json +96 -11
  205. package/dist/viewer/locales/zho.json +96 -11
  206. package/dist/viewer/nav-focus.js +8 -1
  207. package/dist/viewer/nav-update.d.ts +2 -0
  208. package/dist/viewer/nav-update.js +117 -0
  209. package/dist/viewer/plugin-blocks.js +1 -1
  210. package/dist/viewer/plugin-style.d.ts +1 -0
  211. package/dist/viewer/plugin-style.js +82 -0
  212. package/dist/viewer/plugins.js +1 -1
  213. package/dist/viewer/resize.d.ts +0 -2
  214. package/dist/viewer/resize.js +2 -98
  215. package/dist/viewer/resource-library.d.ts +11 -9
  216. package/dist/viewer/resource-library.js +181 -31
  217. package/dist/viewer/search.d.ts +4 -2
  218. package/dist/viewer/search.js +252 -53
  219. package/dist/viewer/serve.d.ts +11 -5
  220. package/dist/viewer/serve.js +913 -295
  221. package/dist/viewer/site-icon.js +13 -6
  222. package/dist/viewer/site-title.js +15 -2
  223. package/dist/viewer/textfile.d.ts +5 -0
  224. package/dist/viewer/textfile.js +34 -2
  225. package/dist/viewer/theme-picker.d.ts +2 -0
  226. package/dist/viewer/theme-picker.js +24 -8
  227. package/dist/viewer/workspace.d.ts +2 -0
  228. package/dist/viewer/workspace.js +46 -1
  229. package/package.json +27 -10
  230. package/dist/compiler/bundle.d.ts +0 -2
  231. package/dist/compiler/bundle.js +0 -100
@@ -1,13 +1,13 @@
1
- // The content/ contract. Doc bodies sit flat in content/<id>.md, and only dooc.yaml
2
- // holds the hierarchy and order (docs themselves have no root / child distinction; any doc can
3
- // have children). id = the file name stem is the resolution key for URLs / file links and is
4
- // unique site-wide. YAML reading/writing lives in compiler/manifest.ts; this file only does
5
- // browser-safe tree validation and manipulation.
6
- import { docFile, localFile, parseFileLayout } from "./files.js";
1
+ // dooc.yaml owns document hierarchy and display settings. Nested manifests identify documents
2
+ // by complete source paths; legacy manifests retain their authored IDs during migration.
3
+ import { stringify } from "yaml";
4
+ import { docFile, fileDocumentId, localFile, parseFileLayout } from "./files.js";
7
5
  import { contentLanguageCode, DEFAULT_LANG, isLangTag } from "./language.js";
6
+ import { parseSubformats } from "./subformats.js";
8
7
  export const MANIFEST_FILE = "dooc.yaml";
9
8
  export const DOC_ID_RE = /^[a-z0-9][a-z0-9-]*$/;
10
9
  export const isDocId = (s) => DOC_ID_RE.test(s);
10
+ export const subformatPageId = (ext) => `subformat-${fileDocumentId(ext)}`;
11
11
  /** Doc file name directly under content/ (`<id>.md`) → id. undefined if the shape differs. */
12
12
  export const docIdOfFile = (name) => {
13
13
  const id = name.endsWith(".md") ? name.slice(0, -3) : "";
@@ -19,6 +19,11 @@ export const docIdOfFile = (name) => {
19
19
  * Validates id shape and duplicates.
20
20
  */
21
21
  export const parseManifest = (value) => {
22
+ if (value &&
23
+ typeof value === "object" &&
24
+ !Array.isArray(value) &&
25
+ ["system", "left_sidebar", "center_contents", "json_subformats"].some((key) => key in value))
26
+ return parseNestedManifest(value);
22
27
  const errors = [];
23
28
  let title;
24
29
  let icon;
@@ -26,6 +31,8 @@ export const parseManifest = (value) => {
26
31
  let files;
27
32
  let languages;
28
33
  let themes;
34
+ let subformats;
35
+ let defaultSubformatFolder;
29
36
  if (value != null && typeof value === "object" && !Array.isArray(value)) {
30
37
  const manifest = value;
31
38
  for (const key of Object.keys(manifest))
@@ -35,7 +42,9 @@ export const parseManifest = (value) => {
35
42
  key !== "docs" &&
36
43
  key !== "files" &&
37
44
  key !== "languages" &&
38
- key !== "themes")
45
+ key !== "themes" &&
46
+ key !== "subformats" &&
47
+ key !== "default_subformat_folder")
39
48
  errors.push(`${MANIFEST_FILE}: unknown field "${key}"`);
40
49
  if (manifest.title !== undefined) {
41
50
  if (typeof manifest.title !== "string" || !manifest.title.trim())
@@ -65,6 +74,22 @@ export const parseManifest = (value) => {
65
74
  errors.push(`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`);
66
75
  }
67
76
  }
77
+ if (manifest.subformats !== undefined) {
78
+ try {
79
+ subformats = parseSubformats(manifest.subformats);
80
+ }
81
+ catch (error) {
82
+ errors.push(`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`);
83
+ }
84
+ }
85
+ if (manifest.default_subformat_folder !== undefined) {
86
+ const folder = manifest.default_subformat_folder;
87
+ if (!localFile(folder) ||
88
+ ["node_modules", "dist", "locales", MANIFEST_FILE, "docs.config.mjs"].includes(folder.split("/")[0] ?? ""))
89
+ errors.push(`${MANIFEST_FILE}: default_subformat_folder must be a local project folder`);
90
+ else
91
+ defaultSubformatFolder = folder;
92
+ }
68
93
  if (manifest.languages !== undefined) {
69
94
  try {
70
95
  if (!Array.isArray(manifest.languages) ||
@@ -108,6 +133,29 @@ export const parseManifest = (value) => {
108
133
  const at = `${path}[${i}]`;
109
134
  let id;
110
135
  let children;
136
+ if (item && typeof item === "object" && !Array.isArray(item) && "subformat" in item) {
137
+ const config = subformats?.find((format) => format.ext === item.subformat);
138
+ if (!config ||
139
+ Object.keys(item).some((key) => !["subformat", "title", "children"].includes(key)) ||
140
+ (item.title !== undefined &&
141
+ (typeof item.title !== "string" || !item.title.trim()))) {
142
+ errors.push(`${MANIFEST_FILE}: ${at} requires a registered subformat and a non-empty title`);
143
+ continue;
144
+ }
145
+ const id = subformatPageId(config.ext);
146
+ if (seen.has(id)) {
147
+ errors.push(`${MANIFEST_FILE}: duplicate id "${id}"`);
148
+ continue;
149
+ }
150
+ seen.add(id);
151
+ nodes.push({
152
+ id,
153
+ subformat: config.ext,
154
+ title: item.title?.trim() ?? config.ext,
155
+ children: walk(item.children, `${at}.children`),
156
+ });
157
+ continue;
158
+ }
111
159
  if (typeof item === "string") {
112
160
  id = item;
113
161
  }
@@ -139,7 +187,9 @@ export const parseManifest = (value) => {
139
187
  for (const id of [...Object.keys(files.documents), ...Object.keys(files.icons ?? {})])
140
188
  if (!seen.has(id))
141
189
  errors.push(`${MANIFEST_FILE}: files references unknown document "${id}"`);
142
- const paths = [...seen].map((id) => docFile(id, files));
190
+ const paths = flattenTree(tree)
191
+ .filter((node) => !node.subformat)
192
+ .map(({ id }) => docFile(id, files));
143
193
  if (new Set(paths).size !== paths.length)
144
194
  errors.push(`${MANIFEST_FILE}: documents must use distinct files`);
145
195
  }
@@ -151,11 +201,219 @@ export const parseManifest = (value) => {
151
201
  ...(files === undefined ? {} : { files }),
152
202
  ...(languages === undefined ? {} : { languages }),
153
203
  ...(themes === undefined ? {} : { themes }),
204
+ ...(subformats === undefined ? {} : { subformats }),
205
+ ...(defaultSubformatFolder === undefined ? {} : { defaultSubformatFolder }),
154
206
  errors,
155
207
  };
156
208
  };
157
- /** Tree → dooc.yaml text (serialized in the hand-written shape, keeping git diffs clean). */
158
- export const serializeManifest = (tree, { title, icon, defaultLang, files, languages, themes, } = {}) => {
209
+ const parseNestedManifest = (input) => {
210
+ try {
211
+ const object = (value, keys, at) => {
212
+ if (!value || typeof value !== "object" || Array.isArray(value))
213
+ throw new Error(`${at} must be an object`);
214
+ for (const key of Object.keys(value))
215
+ if (!keys.includes(key))
216
+ throw new Error(`${at}: unknown field "${key}"`);
217
+ return value;
218
+ };
219
+ const root = object(input, [
220
+ "system",
221
+ "left_sidebar",
222
+ "center_contents",
223
+ "json_subformats",
224
+ "default_subformat_folder",
225
+ ], MANIFEST_FILE);
226
+ const system = object(root.system ?? {}, ["languages", "default_lang", "themes", "licence", "files"], "system");
227
+ const licence = system.licence;
228
+ if (licence !== undefined && (!localFile(licence) || !licence.trim()))
229
+ throw new Error("system.licence must be a local file path");
230
+ const sidebar = object(root.left_sidebar ?? {}, ["title", "icon"], "left_sidebar");
231
+ const layout = object(system.files ?? {}, ["default_layout", "order"], "system.files");
232
+ const titles = {};
233
+ if (sidebar.title !== undefined) {
234
+ if (!sidebar.title || typeof sidebar.title !== "object" || Array.isArray(sidebar.title))
235
+ throw new Error("left_sidebar.title must map languages to titles");
236
+ for (const [tag, title] of Object.entries(sidebar.title)) {
237
+ if (!isLangTag(tag) || typeof title !== "string" || !title.trim())
238
+ throw new Error("Invalid localized site title");
239
+ const code = contentLanguageCode(tag);
240
+ if (Object.hasOwn(titles, code))
241
+ throw new Error(`Duplicate title language: ${code}`);
242
+ titles[code] = title.trim();
243
+ }
244
+ }
245
+ const themeIcons = {};
246
+ if (sidebar.icon !== undefined) {
247
+ const icons = object(sidebar.icon, ["light", "dark"], "left_sidebar.icon");
248
+ for (const [theme, file] of Object.entries(icons)) {
249
+ if (!localFile(file) || !file.endsWith(".svg"))
250
+ throw new Error("Site icons must be local SVG files");
251
+ themeIcons[theme] = file;
252
+ }
253
+ }
254
+ const documents = {};
255
+ const icons = {};
256
+ const walk = (value) => {
257
+ if (!Array.isArray(value))
258
+ throw new Error("center_contents and children must be lists");
259
+ return value.map((entry) => {
260
+ const node = object(entry, ["file", "icon", "children", "subformat", "title"], "center_contents");
261
+ if (node.icon !== undefined &&
262
+ (!localFile(node.icon) || !node.icon.endsWith(".svg")))
263
+ throw new Error("Document icons must be local SVG files");
264
+ if (node.subformat !== undefined) {
265
+ const config = parseSubformats(root.json_subformats ?? []).find((format) => format.ext === node.subformat);
266
+ if (!config ||
267
+ node.file !== undefined ||
268
+ (node.title !== undefined &&
269
+ (typeof node.title !== "string" || !node.title.trim())))
270
+ throw new Error("Subformat pages require a registered subformat and a non-empty title");
271
+ const id = subformatPageId(config.ext);
272
+ if (typeof node.icon === "string")
273
+ icons[id] = node.icon;
274
+ return {
275
+ id,
276
+ subformat: config.ext,
277
+ title: typeof node.title === "string" ? node.title.trim() : config.ext,
278
+ children: node.children === undefined ? [] : walk(node.children),
279
+ };
280
+ }
281
+ if (!localFile(node.file) || !node.file.endsWith(".md"))
282
+ throw new Error("Each document requires a local .md file");
283
+ const id = fileDocumentId(node.file);
284
+ if (Object.hasOwn(documents, id))
285
+ throw new Error(`Duplicate document: ${node.file}`);
286
+ documents[id] = node.file;
287
+ if (typeof node.icon === "string")
288
+ icons[id] = node.icon;
289
+ return {
290
+ id,
291
+ file: node.file,
292
+ children: node.children === undefined ? [] : walk(node.children),
293
+ };
294
+ });
295
+ };
296
+ const tree = walk(root.center_contents);
297
+ const language = system.default_lang ?? DEFAULT_LANG;
298
+ if (typeof language !== "string" || !isLangTag(language))
299
+ throw new Error("system.default_lang must be a language tag");
300
+ const source = contentLanguageCode(language);
301
+ if (sidebar.title !== undefined && !titles[source])
302
+ throw new Error("left_sidebar.title must include system.default_lang");
303
+ const legacyTree = (nodes) => nodes.map((node) => node.subformat
304
+ ? {
305
+ subformat: node.subformat,
306
+ title: node.title,
307
+ children: legacyTree(node.children),
308
+ }
309
+ : node.children.length
310
+ ? { [node.id]: legacyTree(node.children) }
311
+ : node.id);
312
+ const parsed = parseManifest({
313
+ docs: legacyTree(tree),
314
+ defaultLang: language,
315
+ ...(system.languages === undefined ? {} : { languages: system.languages }),
316
+ ...(system.themes === undefined ? {} : { themes: system.themes }),
317
+ ...(titles[source] ? { title: titles[source] } : {}),
318
+ ...(themeIcons.light || themeIcons.dark
319
+ ? { icon: themeIcons.light ?? themeIcons.dark }
320
+ : {}),
321
+ files: {
322
+ defaultLayout: layout.default_layout,
323
+ documents,
324
+ ...(Object.keys(icons).length ? { icons } : {}),
325
+ },
326
+ ...(root.json_subformats === undefined ? {} : { subformats: root.json_subformats }),
327
+ ...(root.default_subformat_folder === undefined
328
+ ? {}
329
+ : { default_subformat_folder: root.default_subformat_folder }),
330
+ });
331
+ return {
332
+ ...parsed,
333
+ format: "nested",
334
+ tree,
335
+ ...(licence === undefined ? {} : { licence }),
336
+ ...(sidebar.title === undefined ? {} : { titles }),
337
+ ...(sidebar.icon === undefined ? {} : { themeIcons }),
338
+ };
339
+ }
340
+ catch (error) {
341
+ return {
342
+ format: "nested",
343
+ tree: [],
344
+ errors: [`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`],
345
+ };
346
+ }
347
+ };
348
+ /** Serialize the authored format; legacy manifests remain readable during migration. */
349
+ export const serializeManifest = (tree, { format, titles, themeIcons, title, icon, defaultLang, licence, files, languages, themes, subformats, defaultSubformatFolder, } = {}) => {
350
+ if (format === "nested") {
351
+ const contents = (nodes) => nodes.map((node) => ({
352
+ ...(node.subformat
353
+ ? { subformat: node.subformat, title: node.title }
354
+ : { file: docFile(node.id, files) }),
355
+ ...(files?.icons?.[node.id] ? { icon: files.icons[node.id] } : {}),
356
+ ...(node.children.length ? { children: contents(node.children) } : {}),
357
+ }));
358
+ return stringify({
359
+ system: {
360
+ ...(languages ? { languages } : {}),
361
+ default_lang: defaultLang ?? DEFAULT_LANG,
362
+ ...(licence === undefined ? {} : { licence }),
363
+ ...(themes ? { themes } : {}),
364
+ ...(files
365
+ ? {
366
+ files: {
367
+ default_layout: files.defaultLayout,
368
+ },
369
+ }
370
+ : {}),
371
+ },
372
+ ...(titles || title || themeIcons || icon
373
+ ? {
374
+ left_sidebar: {
375
+ ...(titles || title
376
+ ? {
377
+ title: titles ?? {
378
+ [contentLanguageCode(defaultLang ?? DEFAULT_LANG)]: title,
379
+ },
380
+ }
381
+ : {}),
382
+ ...(themeIcons || icon
383
+ ? { icon: themeIcons ?? { light: icon, dark: icon } }
384
+ : {}),
385
+ },
386
+ }
387
+ : {}),
388
+ center_contents: contents(tree),
389
+ ...(subformats ? { json_subformats: subformats } : {}),
390
+ ...(defaultSubformatFolder
391
+ ? { default_subformat_folder: defaultSubformatFolder }
392
+ : {}),
393
+ }, { lineWidth: 0 });
394
+ }
395
+ if (flattenTree(tree).some((node) => node.subformat)) {
396
+ const contents = (nodes) => nodes.map((node) => node.subformat
397
+ ? {
398
+ subformat: node.subformat,
399
+ title: node.title,
400
+ ...(node.children.length ? { children: contents(node.children) } : {}),
401
+ }
402
+ : node.children.length
403
+ ? { [node.id]: contents(node.children) }
404
+ : node.id);
405
+ return stringify({
406
+ ...(title ? { title } : {}),
407
+ ...(icon ? { icon } : {}),
408
+ ...(defaultLang ? { defaultLang } : {}),
409
+ ...(files ? { files } : {}),
410
+ ...(languages ? { languages } : {}),
411
+ ...(themes ? { themes } : {}),
412
+ ...(subformats ? { subformats } : {}),
413
+ ...(defaultSubformatFolder ? { default_subformat_folder: defaultSubformatFolder } : {}),
414
+ docs: contents(tree),
415
+ });
416
+ }
159
417
  const write = (nodes, indent) => nodes.flatMap((n) => n.children.length > 0
160
418
  ? [`${indent}- ${n.id}:`, ...write(n.children, `${indent} `)]
161
419
  : [`${indent}- ${n.id}`]);
@@ -164,10 +422,12 @@ export const serializeManifest = (tree, { title, icon, defaultLang, files, langu
164
422
  defaultLang !== undefined ||
165
423
  files !== undefined ||
166
424
  languages !== undefined ||
167
- themes !== undefined) {
425
+ themes !== undefined ||
426
+ subformats !== undefined ||
427
+ defaultSubformatFolder !== undefined) {
168
428
  const lines = write(tree, " ");
169
- const metadata = `${title === undefined ? "" : `title: ${JSON.stringify(title)}\n`}${icon === undefined ? "" : `icon: ${JSON.stringify(icon)}\n`}${defaultLang === undefined ? "" : `defaultLang: ${JSON.stringify(defaultLang)}\n`}`;
170
- return `${metadata}${files ? `files: ${JSON.stringify(files)}\n` : ""}${languages ? `languages: ${JSON.stringify(languages)}\n` : ""}${themes ? `themes: ${JSON.stringify(themes)}\n` : ""}docs:${lines.length ? `\n${lines.join("\n")}\n` : " []\n"}`;
429
+ const metadata = `${title === undefined ? "" : `title: ${JSON.stringify(title)}\n`}${icon === undefined ? "" : `icon: ${JSON.stringify(icon)}\n`}${defaultLang === undefined ? "" : `defaultLang: ${JSON.stringify(defaultLang)}\n`}${defaultSubformatFolder === undefined ? "" : `default_subformat_folder: ${JSON.stringify(defaultSubformatFolder)}\n`}`;
430
+ return `${metadata}${files ? `files: ${JSON.stringify(files)}\n` : ""}${languages ? `languages: ${JSON.stringify(languages)}\n` : ""}${themes ? `themes: ${JSON.stringify(themes)}\n` : ""}${subformats ? `subformats: ${JSON.stringify(subformats)}\n` : ""}docs:${lines.length ? `\n${lines.join("\n")}\n` : " []\n"}`;
171
431
  }
172
432
  const lines = write(tree, "");
173
433
  return `# Doc hierarchy and order (each id = content/<id>.md)\n${lines.join("\n")}${lines.length > 0 ? "\n" : ""}`;
@@ -177,14 +437,20 @@ export const flattenTree = (tree) => {
177
437
  const out = [];
178
438
  const walk = (nodes, parent, depth) => {
179
439
  for (const n of nodes) {
180
- out.push(parent == null ? { id: n.id, depth } : { id: n.id, parent, depth });
440
+ out.push({
441
+ id: n.id,
442
+ ...(n.file ? { file: n.file } : {}),
443
+ ...(n.subformat ? { subformat: n.subformat, title: n.title } : {}),
444
+ ...(parent == null ? {} : { parent }),
445
+ depth,
446
+ });
181
447
  walk(n.children, n.id, depth + 1);
182
448
  }
183
449
  };
184
450
  walk(tree, undefined, 0);
185
451
  return out;
186
452
  };
187
- const clone = (tree) => tree.map((n) => ({ id: n.id, children: clone(n.children) }));
453
+ const clone = (tree) => tree.map((n) => ({ ...n, children: clone(n.children) }));
188
454
  const findNode = (tree, id) => {
189
455
  for (const n of tree) {
190
456
  if (n.id === id) {
@@ -214,13 +480,13 @@ const detach = (tree, id) => {
214
480
  /** Child list of parent (omitted = top level). undefined if parent doesn't exist. */
215
481
  const childList = (tree, parent) => parent == null ? tree : findNode(tree, parent)?.children;
216
482
  /** Append a new doc to the end of parent's children. Duplicate id / missing parent → undefined. */
217
- export const insertDoc = (tree, id, parent) => {
483
+ export const insertDoc = (tree, id, parent, page = {}) => {
218
484
  const next = clone(tree);
219
485
  const list = childList(next, parent);
220
486
  if (!list || findNode(next, id)) {
221
487
  return undefined;
222
488
  }
223
- list.push({ id, children: [] });
489
+ list.push({ id, ...page, children: [] });
224
490
  return next;
225
491
  };
226
492
  /**
@@ -1,4 +1,5 @@
1
1
  import type { Block, TocEntry } from "./blocks.js";
2
+ import type { SubformatCollection } from "./subformats.js";
2
3
  import type { Frontmatter } from "./taxonomy.js";
3
4
  export interface TermEntry {
4
5
  /** Root-relative .termth path, or a document position for an inline definition. */
@@ -11,7 +12,7 @@ export interface TermEntry {
11
12
  export interface FigureEntry {
12
13
  name: string;
13
14
  file: string;
14
- kind: "svg" | "html" | "image" | "video";
15
+ kind: "svg" | "html" | "image" | "video" | "pdf";
15
16
  /**
16
17
  * Full figure content (SVG / HTML fragment / <img> data URI for rasters). Consumers render it
17
18
  * inline; MCP can pass it as text.
@@ -24,9 +25,10 @@ export interface FigureEntry {
24
25
  }
25
26
  export type CompiledDoc = Frontmatter & {
26
27
  id: string;
28
+ subformat?: SubformatCollection;
27
29
  /** Parent doc id (SoT: dooc.yaml). Omitted = top level. docs[] is in pre-order. */
28
30
  parent?: string;
29
- /** `content/<id>.md`. */
31
+ /** Project-relative Markdown source path, or subformat:<ext> for a display page. */
30
32
  file: string;
31
33
  /** Resolved language (BCP 47): front-matter `lang`, else the site default (language.ts). */
32
34
  lang: string;
@@ -0,0 +1 @@
1
+ export declare const escapeHtml: (s: string) => string;
@@ -0,0 +1 @@
1
+ export const escapeHtml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -31,7 +31,7 @@ const svgBox = (markup) => {
31
31
  };
32
32
  /** One figure → an isolated iframe (rasters stay as <img>). */
33
33
  export const figureFrameHtml = (fig, cls = "fig-frame", label) => {
34
- if (fig.kind === "video")
34
+ if (fig.kind === "video" || fig.kind === "pdf")
35
35
  return label
36
36
  ? fig.markup.replace(/\baria-label="[^"]*"/, () => `aria-label="${esc(label)}"`)
37
37
  : fig.markup;
@@ -57,17 +57,34 @@ export const figureFrameHtml = (fig, cls = "fig-frame", label) => {
57
57
  export function mountFigureFrames(doc) {
58
58
  const SEL = "iframe[data-doc-figure-frame]";
59
59
  const media = window.matchMedia("(prefers-color-scheme: dark)");
60
+ const watched = new WeakSet();
61
+ const loaded = new WeakSet();
60
62
  const theme = (element) => {
61
63
  const t = element.closest("[data-theme]")?.dataset.theme ??
62
64
  doc.documentElement.dataset.theme;
63
65
  return t === "light" || t === "dark" ? t : media.matches ? "dark" : "light";
64
66
  };
65
67
  const apply = (f) => {
68
+ if (!watched.has(f)) {
69
+ watched.add(f);
70
+ f.removeAttribute("data-theme-ready");
71
+ f.addEventListener("load", () => {
72
+ loaded.add(f);
73
+ apply(f);
74
+ });
75
+ }
76
+ // Rewriting srcdoc during its initial load can leave the frame without layout.
77
+ if (!loaded.has(f))
78
+ return;
66
79
  const src = f.getAttribute("srcdoc") ?? "";
67
80
  const next = src.replace(/^(<!doctype html><html data-doc-theme=")[a-z]+"/, `$1${theme(f)}"`);
68
81
  if (next !== src) {
82
+ loaded.delete(f);
83
+ f.removeAttribute("data-theme-ready");
69
84
  f.setAttribute("srcdoc", next);
70
85
  }
86
+ else
87
+ f.setAttribute("data-theme-ready", "true");
71
88
  };
72
89
  const all = () => {
73
90
  for (const f of doc.querySelectorAll(SEL))
@@ -97,7 +114,8 @@ export function mountFigureFrames(doc) {
97
114
  media.addEventListener("change", all);
98
115
  window.addEventListener("message", (ev) => {
99
116
  const h = ev.data?.docFigureHeight;
100
- if (typeof h !== "number")
117
+ // A frame can report zero before layout; keep its initial viewport until measured.
118
+ if (typeof h !== "number" || !Number.isFinite(h) || h <= 0)
101
119
  return;
102
120
  for (const f of doc.querySelectorAll(`${SEL}[data-doc-figure-frame="html"]`)) {
103
121
  if (f.contentWindow === ev.source)
@@ -6,7 +6,7 @@ export const parseFigureLink = (source) => {
6
6
  if (/^(?:[a-z][a-z\d+.-]*:|\/)/i.test(source))
7
7
  return undefined;
8
8
  const path = decodeURIComponent(source.split(/[?#]/)[0] ?? "");
9
- if (!/\.(svg|html|png|webp|gif|mp4|webm|jpe?g)$/.test(path))
9
+ if (!/\.(svg|html|png|webp|gif|mp4|webm|jpe?g|pdf|dxf)$/i.test(path))
10
10
  return undefined;
11
11
  const ref = parseFileReference(source);
12
12
  const file = ref.file.replace(/^(\.\/)+/, "");
@@ -34,10 +34,14 @@ export const parseFileEmbed = (source, settings) => {
34
34
  };
35
35
  }
36
36
  if (ref.range !== undefined ||
37
- (previewer !== "image" && previewer !== "html" && previewer !== "video"))
37
+ (previewer !== "image" &&
38
+ previewer !== "html" &&
39
+ previewer !== "video" &&
40
+ previewer !== "pdf" &&
41
+ previewer !== "dxf"))
38
42
  return { ...ref, kind: "textfile" };
39
43
  const file = ref.file.replace(/^(\.\/)+/, "");
40
44
  if (!localFile(file))
41
- throw new Error("Image and HTML previews require a local file inside the docs root");
45
+ throw new Error("Visual previews require a local file inside the docs root");
42
46
  return { file, kind: previewer === "html" ? "html" : "figure" };
43
47
  };
@@ -1,7 +1,6 @@
1
1
  export interface FileLayout {
2
2
  defaultLayout: boolean;
3
3
  documents: Record<string, string>;
4
- order: string[];
5
4
  icons?: Record<string, string>;
6
5
  }
7
6
  export declare const MAX_FILE_UPLOAD_BYTES: number;
@@ -10,6 +9,8 @@ export declare const isDocumentFileName: (value: unknown) => value is string;
10
9
  export declare const suggestDocFileName: (title: string) => string;
11
10
  export declare const fileExtension: (file: string) => string;
12
11
  export declare const defaultFilePath: (file: string) => string;
12
+ /** Internal keys are derived from the complete path, never authored in the manifest. */
13
+ export declare const fileDocumentId: (file: string) => string;
13
14
  export declare const docFile: (id: string, layout?: FileLayout) => string;
14
15
  export declare const parseFileLayout: (value: unknown) => FileLayout;
15
16
  export declare const docIconFile: (id: string, layout?: FileLayout) => string;
@@ -19,6 +19,8 @@ export const fileExtension = (file) => {
19
19
  return name.includes(".") ? name.slice(name.lastIndexOf(".") + 1).toLowerCase() : "other";
20
20
  };
21
21
  export const defaultFilePath = (file) => `files/${fileExtension(file)}/${file.split("/").pop()}`;
22
+ /** Internal keys are derived from the complete path, never authored in the manifest. */
23
+ export const fileDocumentId = (file) => `file-${Array.from(new TextEncoder().encode(file), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
22
24
  export const docFile = (id, layout) => layout && Object.hasOwn(layout.documents, id)
23
25
  ? layout.documents[id]
24
26
  : `content/${id}.md`;
@@ -26,11 +28,11 @@ export const parseFileLayout = (value) => {
26
28
  if (!value || typeof value !== "object" || Array.isArray(value))
27
29
  throw new Error("files must be an object");
28
30
  const v = value;
31
+ // Accept the retired order field when opening older manifests, without retaining it.
29
32
  if (Object.keys(v).some((key) => !["defaultLayout", "documents", "order", "icons"].includes(key)) ||
30
33
  (v.defaultLayout !== undefined && typeof v.defaultLayout !== "boolean"))
31
34
  throw new Error("Invalid file layout");
32
35
  const documents = v.documents ?? {};
33
- const order = v.order ?? [];
34
36
  const icons = v.icons;
35
37
  if (icons !== undefined &&
36
38
  (!icons ||
@@ -42,18 +44,14 @@ export const parseFileLayout = (value) => {
42
44
  typeof documents !== "object" ||
43
45
  Array.isArray(documents) ||
44
46
  Object.entries(documents).some(([id, file]) => !/^[a-z0-9][a-z0-9-]*$/.test(id) || !localFile(file) || !file.endsWith(".md")) ||
45
- new Set(Object.values(documents)).size !== Object.keys(documents).length ||
46
- !Array.isArray(order) ||
47
- order.some((file) => !localFile(file)) ||
48
- new Set(order).size !== order.length)
49
- throw new Error("Invalid file paths or order");
47
+ new Set(Object.values(documents)).size !== Object.keys(documents).length)
48
+ throw new Error("Invalid file paths");
50
49
  return {
51
50
  defaultLayout: v.defaultLayout !== false,
52
51
  documents: documents,
53
- order,
54
52
  ...(icons ? { icons: icons } : {}),
55
53
  };
56
54
  };
57
55
  export const docIconFile = (id, layout) => layout?.icons && Object.hasOwn(layout.icons, id)
58
56
  ? layout.icons[id]
59
- : `icons/${id}.svg`;
57
+ : `icons/${layout?.documents[id] && fileDocumentId(layout.documents[id]) === id ? layout.documents[id] : id}.svg`;
@@ -1,4 +1,4 @@
1
- // Generated — do not edit by hand (`pnpm run build:css` = build-flow-css.ts
1
+ // Generated — do not edit by hand (`pnpm run build:css` = scripts/build/flow-css.ts
2
2
  // copies it from @xyflow/react/dist/base.css). A structure-only stylesheet; colors come from
3
3
  // `--doc-*` injected by the consumer (React Flow's default theme = style.css is not included).
4
4
  export const XYFLOW_BASE_CSS = "/* this will be exported as base.css and can be used for a basic styling */\n/* these are the necessary styles for React/Svelte Flow, they get used by base.css and style.css */\n.react-flow {\n direction: ltr;\n\n --xy-edge-stroke-default: #b1b1b7;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #555;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(255, 255, 255, 0.5);\n\n --xy-minimap-background-color-default: #fff;\n --xy-minimap-mask-background-color-default: rgba(240, 240, 240, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #e2e2e2;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: transparent;\n --xy-background-pattern-dots-color-default: #91919a;\n --xy-background-pattern-lines-color-default: #eee;\n --xy-background-pattern-cross-color-default: #e2e2e2;\n background-color: var(--xy-background-color, var(--xy-background-color-default));\n --xy-node-border-default: 1px solid #bbb;\n --xy-node-border-selected-default: 1px solid #555;\n\n --xy-handle-background-color-default: #333;\n\n --xy-selection-background-color-default: rgba(150, 150, 180, 0.1);\n --xy-selection-border-default: 1px dotted rgba(155, 155, 155, 0.8);\n --xy-resize-background-color-default: #3367d9;\n}\n.react-flow.dark {\n --xy-edge-stroke-default: #3e3e3e;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #727272;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(150, 150, 150, 0.25);\n\n --xy-minimap-background-color-default: #141414;\n --xy-minimap-mask-background-color-default: rgba(60, 60, 60, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #2b2b2b;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: #141414;\n --xy-background-pattern-dots-color-default: #555;\n --xy-background-pattern-lines-color-default: #333;\n --xy-background-pattern-cross-color-default: #333;\n --xy-node-color-default: #f8f8f8;\n}\n.react-flow__background {\n background-color: var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));\n pointer-events: none;\n z-index: -1;\n}\n.react-flow__container {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n}\n.react-flow__pane {\n z-index: 1;\n touch-action: none;\n}\n.react-flow__pane.draggable {\n cursor: grab;\n }\n.react-flow__pane.dragging {\n cursor: grabbing;\n }\n.react-flow__pane.selection {\n cursor: pointer;\n }\n.react-flow__viewport {\n transform-origin: 0 0;\n z-index: 2;\n pointer-events: none;\n}\n.react-flow__renderer {\n z-index: 4;\n}\n.react-flow__selection {\n z-index: 6;\n}\n.react-flow__nodesselection-rect:focus,\n.react-flow__nodesselection-rect:focus-visible {\n outline: none;\n}\n.react-flow__edge-path {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n stroke-width: var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));\n fill: none;\n}\n.react-flow__connection-path {\n stroke: var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));\n stroke-width: var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));\n fill: none;\n}\n.react-flow .react-flow__edges {\n position: absolute;\n}\n.react-flow .react-flow__edges svg {\n overflow: visible;\n position: absolute;\n pointer-events: none;\n }\n.react-flow__edge {\n pointer-events: visibleStroke;\n}\n.react-flow__edge.selectable {\n cursor: pointer;\n }\n.react-flow__edge.animated path {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\n.react-flow__edge.animated path.react-flow__edge-interaction {\n stroke-dasharray: none;\n animation: none;\n }\n.react-flow__edge.inactive {\n pointer-events: none;\n }\n.react-flow__edge.selected,\n .react-flow__edge:focus,\n .react-flow__edge:focus-visible {\n outline: none;\n }\n.react-flow__edge.selected .react-flow__edge-path,\n .react-flow__edge.selectable:focus .react-flow__edge-path,\n .react-flow__edge.selectable:focus-visible .react-flow__edge-path {\n stroke: var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default));\n }\n.react-flow__edge-textwrapper {\n pointer-events: all;\n }\n.react-flow__edge .react-flow__edge-text {\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n/* Arrowhead marker styles - use CSS custom properties as default */\n.react-flow__arrowhead polyline {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__arrowhead polyline.arrowclosed {\n fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__connection {\n pointer-events: none;\n}\n.react-flow__connection .animated {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\nsvg.react-flow__connectionline {\n z-index: 1001;\n overflow: visible;\n position: absolute;\n}\n.react-flow__nodes {\n pointer-events: none;\n transform-origin: 0 0;\n}\n.react-flow__node {\n position: absolute;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n pointer-events: all;\n transform-origin: 0 0;\n box-sizing: border-box;\n cursor: default;\n}\n.react-flow__node.selectable {\n cursor: pointer;\n }\n.react-flow__node.draggable {\n cursor: grab;\n pointer-events: all;\n }\n.react-flow__node.draggable.dragging {\n cursor: grabbing;\n }\n.react-flow__nodesselection {\n z-index: 3;\n transform-origin: left top;\n pointer-events: none;\n}\n.react-flow__nodesselection-rect {\n position: absolute;\n pointer-events: all;\n cursor: grab;\n }\n.react-flow__handle {\n position: absolute;\n pointer-events: none;\n min-width: 5px;\n min-height: 5px;\n background-color: var(--xy-handle-background-color, var(--xy-handle-background-color-default));\n}\n.react-flow__handle.connectingfrom {\n pointer-events: all;\n }\n.react-flow__handle.connectionindicator {\n pointer-events: all;\n cursor: crosshair;\n }\n.react-flow__handle-bottom {\n top: auto;\n left: 50%;\n bottom: 0;\n transform: translate(-50%, 50%);\n }\n.react-flow__handle-top {\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-left {\n top: 50%;\n left: 0;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-right {\n top: 50%;\n right: 0;\n transform: translate(50%, -50%);\n }\n.react-flow__edgeupdater {\n cursor: move;\n pointer-events: all;\n}\n.react-flow__pane.selection .react-flow__panel {\n pointer-events: none;\n}\n.react-flow__panel {\n position: absolute;\n z-index: 5;\n margin: 15px;\n}\n.react-flow__panel.top {\n top: 0;\n }\n.react-flow__panel.bottom {\n bottom: 0;\n }\n.react-flow__panel.top.center, .react-flow__panel.bottom.center {\n left: 50%;\n transform: translateX(-15px) translateX(-50%);\n }\n.react-flow__panel.left {\n left: 0;\n }\n.react-flow__panel.right {\n right: 0;\n }\n.react-flow__panel.left.center, .react-flow__panel.right.center {\n top: 50%;\n transform: translateY(-15px) translateY(-50%);\n }\n.react-flow__attribution {\n font-size: 10px;\n background: var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));\n padding: 2px 3px;\n margin: 0;\n}\n.react-flow__attribution a {\n text-decoration: none;\n color: #999;\n }\n@keyframes dashdraw {\n from {\n stroke-dashoffset: 10;\n }\n}\n.react-flow__edgelabel-renderer {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n left: 0;\n top: 0;\n}\n.react-flow__viewport-portal {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.react-flow__minimap {\n background: var(\n --xy-minimap-background-color-props,\n var(--xy-minimap-background-color, var(--xy-minimap-background-color-default))\n );\n}\n.react-flow__minimap-svg {\n display: block;\n }\n.react-flow__minimap-mask {\n fill: var(\n --xy-minimap-mask-background-color-props,\n var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default))\n );\n stroke: var(\n --xy-minimap-mask-stroke-color-props,\n var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-mask-stroke-width-props,\n var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default))\n );\n }\n.react-flow__minimap-node {\n fill: var(\n --xy-minimap-node-background-color-props,\n var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default))\n );\n stroke: var(\n --xy-minimap-node-stroke-color-props,\n var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-node-stroke-width-props,\n var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default))\n );\n }\n.react-flow__background-pattern.dots {\n fill: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default))\n );\n }\n.react-flow__background-pattern.lines {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default))\n );\n }\n.react-flow__background-pattern.cross {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default))\n );\n }\n.react-flow__controls {\n display: flex;\n flex-direction: column;\n}\n.react-flow__controls.horizontal {\n flex-direction: row;\n }\n.react-flow__controls-button {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 26px;\n width: 26px;\n padding: 4px;\n }\n.react-flow__controls-button svg {\n width: 100%;\n max-width: 12px;\n max-height: 12px;\n fill: currentColor;\n }\n.react-flow__node-input,\n.react-flow__node-default,\n.react-flow__node-output,\n.react-flow__node-group {\n border: var(--xy-node-border, var(--xy-node-border-default));\n color: var(--xy-node-color, var(--xy-node-color-default));\n}\n.react-flow__node-input.selected,\n .react-flow__node-input:focus,\n .react-flow__node-input:focus-visible,\n .react-flow__node-default.selected,\n .react-flow__node-default:focus,\n .react-flow__node-default:focus-visible,\n .react-flow__node-output.selected,\n .react-flow__node-output:focus,\n .react-flow__node-output:focus-visible,\n .react-flow__node-group.selected,\n .react-flow__node-group:focus,\n .react-flow__node-group:focus-visible {\n outline: none;\n border: var(--xy-node-border-selected, var(--xy-node-border-selected-default));\n }\n.react-flow__nodesselection-rect,\n.react-flow__selection {\n background: var(--xy-selection-background-color, var(--xy-selection-background-color-default));\n border: var(--xy-selection-border, var(--xy-selection-border-default));\n}\n.react-flow__resize-control {\n position: absolute;\n}\n.react-flow__resize-control.left,\n.react-flow__resize-control.right {\n cursor: ew-resize;\n}\n.react-flow__resize-control.top,\n.react-flow__resize-control.bottom {\n cursor: ns-resize;\n}\n.react-flow__resize-control.top.left,\n.react-flow__resize-control.bottom.right {\n cursor: nwse-resize;\n}\n.react-flow__resize-control.bottom.left,\n.react-flow__resize-control.top.right {\n cursor: nesw-resize;\n}\n/* handle styles */\n.react-flow__resize-control.handle {\n width: 5px;\n height: 5px;\n border: 1px solid #fff;\n border-radius: 1px;\n background-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n translate: -50% -50%;\n}\n.react-flow__resize-control.handle.left {\n left: 0;\n top: 50%;\n}\n.react-flow__resize-control.handle.right {\n left: 100%;\n top: 50%;\n}\n.react-flow__resize-control.handle.top {\n left: 50%;\n top: 0;\n}\n.react-flow__resize-control.handle.bottom {\n left: 50%;\n top: 100%;\n}\n.react-flow__resize-control.handle.top.left {\n left: 0;\n}\n.react-flow__resize-control.handle.bottom.left {\n left: 0;\n}\n.react-flow__resize-control.handle.top.right {\n left: 100%;\n}\n.react-flow__resize-control.handle.bottom.right {\n left: 100%;\n}\n/* line styles */\n.react-flow__resize-control.line {\n border-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n border-width: 0;\n border-style: solid;\n}\n.react-flow__resize-control.line.left,\n.react-flow__resize-control.line.right {\n width: 1px;\n transform: translate(-50%, 0);\n top: 0;\n height: 100%;\n}\n.react-flow__resize-control.line.left {\n left: 0;\n border-left-width: 1px;\n}\n.react-flow__resize-control.line.right {\n left: 100%;\n border-right-width: 1px;\n}\n.react-flow__resize-control.line.top,\n.react-flow__resize-control.line.bottom {\n height: 1px;\n transform: translate(0, -50%);\n left: 0;\n width: 100%;\n}\n.react-flow__resize-control.line.top {\n top: 0;\n border-top-width: 1px;\n}\n.react-flow__resize-control.line.bottom {\n border-bottom-width: 1px;\n top: 100%;\n}\n";
@@ -1,12 +1,16 @@
1
1
  import type { Block, TocEntry } from "./blocks.js";
2
2
  import type { FigureEntry, TermEntry } from "./content-types.js";
3
+ import { figureFrameHtml } from "./figure-frame.js";
3
4
  import { type LanguageAdapter } from "./language.js";
4
5
  import { type Frontmatter } from "./taxonomy.js";
6
+ export { escapeHtml } from "./escape-html.js";
5
7
  export interface RenderCtx {
6
8
  /** Source file to published document route. */
7
9
  docLinks?: ReadonlyMap<string, string>;
8
10
  /** Figures including their markup (name → entry). */
9
11
  figures: ReadonlyMap<string, FigureEntry>;
12
+ /** Local viewers may defer large figures; published HTML embeds them directly. */
13
+ figurePreview?: typeof figureFrameHtml;
10
14
  terms: readonly TermEntry[];
11
15
  termLinks?: ReadonlyMap<string, string>;
12
16
  /** The doc's language tag (BCP 47), emitted as `<article lang>`. */
@@ -22,7 +26,6 @@ export interface RenderCtx {
22
26
  language?: LanguageAdapter;
23
27
  }
24
28
  export declare const emptyCtx: RenderCtx;
25
- export declare const escapeHtml: (s: string) => string;
26
29
  /** Shared dictionary entries for definitions and the Resources list. */
27
30
  export declare const termsHtml: (terms: readonly TermEntry[], language?: LanguageAdapter, sortable?: boolean) => string;
28
31
  export declare const blocksHtml: (blocks: Block[], ctx?: RenderCtx) => string;