@dooc-dev/dooc 0.0.5 → 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 (176) hide show
  1. package/dist/cli.js +128 -67
  2. package/dist/code-worker.global.js +152 -0
  3. package/dist/code.global.js +101 -101
  4. package/dist/compiler/bundle-urls.js +2 -0
  5. package/dist/compiler/check.js +2 -0
  6. package/dist/compiler/compile.js +13 -3
  7. package/dist/compiler/dxf.d.ts +1 -0
  8. package/dist/compiler/dxf.js +81 -0
  9. package/dist/compiler/export.js +22 -15
  10. package/dist/compiler/figures.js +39 -10
  11. package/dist/compiler/files.js +2 -0
  12. package/dist/compiler/ignored-files.d.ts +2 -0
  13. package/dist/compiler/ignored-files.js +30 -0
  14. package/dist/compiler/ops.js +1 -1
  15. package/dist/compiler/subformat-schema.d.ts +14 -0
  16. package/dist/compiler/subformat-schema.js +92 -0
  17. package/dist/compiler/subformats.d.ts +5 -7
  18. package/dist/compiler/subformats.js +115 -75
  19. package/dist/core/code-file.js +7 -5
  20. package/dist/core/code-grammars.d.ts +5 -0
  21. package/dist/core/code-grammars.js +34 -0
  22. package/dist/core/content-metadata.d.ts +2 -1
  23. package/dist/core/content-metadata.js +7 -2
  24. package/dist/core/content-types.d.ts +1 -1
  25. package/dist/core/escape-html.d.ts +1 -0
  26. package/dist/core/escape-html.js +1 -0
  27. package/dist/core/figure-frame.js +1 -1
  28. package/dist/core/file-embed.js +7 -3
  29. package/dist/core/html.d.ts +4 -1
  30. package/dist/core/html.js +8 -7
  31. package/dist/core/language.js +5 -2
  32. package/dist/core/markdown.js +3 -1
  33. package/dist/core/previewers.d.ts +8 -0
  34. package/dist/core/previewers.js +2 -0
  35. package/dist/core/schema-fields.d.ts +13 -0
  36. package/dist/core/schema-fields.js +175 -0
  37. package/dist/core/schema-graph-mount.js +26 -3
  38. package/dist/core/schema-refs.d.ts +8 -0
  39. package/dist/core/schema-refs.js +82 -0
  40. package/dist/core/toc-ui.js +1 -1
  41. package/dist/edit.global.js +266 -285
  42. package/dist/flow.global.js +3 -3
  43. package/dist/graph/abnfDiagram-S7VZAUFO-ASBULSKE.js +1 -0
  44. package/dist/graph/architecture-WOLXFQ4H-V57EDXXY.js +1 -0
  45. package/dist/graph/architectureDiagram-YGSQEFNW-GIMP347N.js +36 -0
  46. package/dist/graph/blockDiagram-APKKGZFW-RDL2T4JW.js +140 -0
  47. package/dist/graph/bpmnIcons-APHXDYXF-TWOSQNUQ.js +1 -0
  48. package/dist/graph/c4Diagram-KJ2TOQU5-75LIUC4F.js +38 -0
  49. package/dist/graph/chunk-26TUJSYJ.js +1 -0
  50. package/dist/graph/chunk-3LU66YMI.js +1 -0
  51. package/dist/graph/chunk-3RNHDNP5.js +1 -0
  52. package/dist/graph/chunk-3Y2PDVDE.js +1 -0
  53. package/dist/graph/chunk-3YJHMOOA.js +3 -0
  54. package/dist/graph/chunk-4KILFWYV.js +339 -0
  55. package/dist/graph/chunk-4QDE4SUK.js +1 -0
  56. package/dist/graph/chunk-5OO6DATX.js +1 -0
  57. package/dist/graph/chunk-5UUEAHTN.js +1 -0
  58. package/dist/graph/chunk-6T55RVVR.js +1 -0
  59. package/dist/graph/chunk-ARAJTKOH.js +2 -0
  60. package/dist/graph/chunk-BBD5CEDC.js +72 -0
  61. package/dist/graph/chunk-BVXT562I.js +1 -0
  62. package/dist/graph/chunk-BZAMCJ6B.js +32 -0
  63. package/dist/graph/chunk-C6J4A356.js +15 -0
  64. package/dist/graph/chunk-EG5UVNOC.js +213 -0
  65. package/dist/graph/chunk-GF4TOPUK.js +1 -0
  66. package/dist/graph/chunk-GYT4IYBZ.js +1 -0
  67. package/dist/graph/chunk-HJG2HUYJ.js +88 -0
  68. package/dist/graph/chunk-HOPPTA6H.js +62 -0
  69. package/dist/graph/chunk-I3DMZIHV.js +1 -0
  70. package/dist/graph/chunk-IC23EEF6.js +1 -0
  71. package/dist/graph/chunk-ISO77HML.js +1 -0
  72. package/dist/graph/chunk-JD7ZBJD2.js +1 -0
  73. package/dist/graph/chunk-JRSH5GNS.js +1 -0
  74. package/dist/graph/chunk-JSHWCPFJ.js +1 -0
  75. package/dist/graph/chunk-K2KLZU7M.js +10 -0
  76. package/dist/graph/chunk-K4I76XBX.js +14 -0
  77. package/dist/graph/chunk-KT4VPQD5.js +135 -0
  78. package/dist/graph/chunk-KU6GTEMS.js +1 -0
  79. package/dist/graph/chunk-LT6LXKCR.js +136 -0
  80. package/dist/graph/chunk-MPR575IN.js +1 -0
  81. package/dist/graph/chunk-N3OHKGRZ.js +1 -0
  82. package/dist/graph/chunk-O656ZI37.js +1 -0
  83. package/dist/graph/chunk-OFZLK5G4.js +1 -0
  84. package/dist/graph/chunk-PDH25ALM.js +2 -0
  85. package/dist/graph/chunk-PW2RGZ3O.js +1 -0
  86. package/dist/graph/chunk-QCJUF4YA.js +1 -0
  87. package/dist/graph/chunk-QEEA3KYY.js +2 -0
  88. package/dist/graph/chunk-QYAXYFNI.js +1 -0
  89. package/dist/graph/chunk-QYTM6GY3.js +1 -0
  90. package/dist/graph/chunk-R63JUMUK.js +1 -0
  91. package/dist/graph/chunk-SCEY3ZPT.js +1 -0
  92. package/dist/graph/chunk-VM2H7G2R.js +1 -0
  93. package/dist/graph/chunk-XQS73SBQ.js +1 -0
  94. package/dist/graph/chunk-YCRLJT2S.js +1 -0
  95. package/dist/graph/chunk-Z4FIZ7CR.js +1 -0
  96. package/dist/graph/chunk-ZMCB7VP2.js +1 -0
  97. package/dist/graph/chunk-ZSZXN4BT.js +2 -0
  98. package/dist/graph/classDiagram-v2-L25IHNXF-JL7LVDZH.js +217 -0
  99. package/dist/graph/cose-bilkent-JH36ORCC-PNM3EYPB.js +1 -0
  100. package/dist/graph/cynefin-EF2NZ3EQ-PSXP3DXL.js +1 -0
  101. package/dist/graph/cynefinDiagram-L36ESFBY-QVY54CXO.js +62 -0
  102. package/dist/graph/dagre-SPEB5RXH-HPGQXBZJ.js +4 -0
  103. package/dist/graph/diagram-3B7GL73J-DWH5WS2P.js +200 -0
  104. package/dist/graph/diagram-DNEMPZML-TEGH2U5I.js +24 -0
  105. package/dist/graph/diagram-L3MUGCDN-X4MREUWR.js +41 -0
  106. package/dist/graph/diagram-LA4NIPWU-NXT746HG.js +24 -0
  107. package/dist/graph/diagram-MHCOC4E2-JGHXSAGS.js +3 -0
  108. package/dist/graph/diagram-XPFHEONP-ZHZPBLT4.js +30 -0
  109. package/dist/graph/ebnfDiagram-UZSYDL2S-SMF6KJ43.js +1 -0
  110. package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +27 -0
  111. package/dist/graph/erDiagram-EYBAPDEH-B3JNJ357.js +99 -0
  112. package/dist/graph/eventmodeling-K75KTNOO-WG6DDYMC.js +1 -0
  113. package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +1 -0
  114. package/dist/graph/ganttDiagram-23REXITY-YXBYWFOJ.js +292 -0
  115. package/dist/graph/gitGraph-VSP46ZUC-VBFWJBBT.js +1 -0
  116. package/dist/graph/gitGraphDiagram-STJD7YCW-4FZDCFGV.js +106 -0
  117. package/dist/graph/info-OHQRW6UA-ALVDUVYV.js +1 -0
  118. package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +2 -0
  119. package/dist/graph/ishikawaDiagram-M35NCXHK-FRZD2PWQ.js +70 -0
  120. package/dist/graph/journeyDiagram-OPLOXDXO-7Z66JCPR.js +139 -0
  121. package/dist/graph/kanban-definition-BZKZHSQY-NN5AIKTE.js +89 -0
  122. package/dist/graph/katex-DXDNVO6V.js +257 -0
  123. package/dist/graph/mindmap-definition-I2QAS2VK-HDPCABN2.js +98 -0
  124. package/dist/graph/packet-JDAUHWVQ-5MQIBWAH.js +1 -0
  125. package/dist/graph/pegDiagram-FD4XPPHP-H2BFNCKT.js +1 -0
  126. package/dist/graph/pie-XZMESJXO-T5VRKHVT.js +1 -0
  127. package/dist/graph/pieDiagram-J4AKIIQI-O3NJSVD3.js +39 -0
  128. package/dist/graph/quadrantDiagram-XTYBLID2-TMTZJI3P.js +7 -0
  129. package/dist/graph/radar-ABXABTNO-C6FXIBYW.js +1 -0
  130. package/dist/graph/railroad-I3PHUGI6-ZSO5JXB3.js +1 -0
  131. package/dist/graph/railroad-abnf-LNEFI6M7-CI4GQRHB.js +1 -0
  132. package/dist/graph/railroad-ebnf-DWYD2UWJ-MUENNCGK.js +1 -0
  133. package/dist/graph/railroad-peg-JR7BVNR7-N3X5GGIX.js +1 -0
  134. package/dist/graph/railroadDiagram-MRQ6NCDL-JHWS23UO.js +1 -0
  135. package/dist/graph/requirementDiagram-Y7LWUY3S-7DVLPO4B.js +84 -0
  136. package/dist/graph/sankeyDiagram-WGJFYUXA-Z5L4R5TR.js +40 -0
  137. package/dist/graph/schema-graph-global.js +639 -0
  138. package/dist/graph/sequenceDiagram-5NDRBG5M-RCTU25NT.js +169 -0
  139. package/dist/graph/sizeCapture-INFHLROL-RROY32P5.js +1 -0
  140. package/dist/graph/stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js +291 -0
  141. package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +1 -0
  142. package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +8 -0
  143. package/dist/graph/timeline-definition-SEUHKTQE-ZQSMIVAS.js +120 -0
  144. package/dist/graph/treeView-D4JQ5SDB-42S7U73N.js +1 -0
  145. package/dist/graph/treemap-SAJKECNS-RUBYQ7XF.js +1 -0
  146. package/dist/graph/usecaseDiagram-AFA6YXN4-57RDRYXF.js +370 -0
  147. package/dist/graph/vennDiagram-NNMJR3RB-5C3LVAV6.js +34 -0
  148. package/dist/graph/wardley-7MLQ67FV-NV5HXTTC.js +1 -0
  149. package/dist/graph/wardleyDiagram-S7YFUSEH-6D5BKXHM.js +78 -0
  150. package/dist/graph/xychartDiagram-GGNKY7IX-6ET3ZM67.js +7 -0
  151. package/dist/mcp.js +5 -4
  152. package/dist/plugins.global.js +71 -104
  153. package/dist/subformats.global.js +6 -112
  154. package/dist/ui.global.js +75 -108
  155. package/dist/viewer/build.d.ts +2 -0
  156. package/dist/viewer/build.js +22 -8
  157. package/dist/viewer/code-file.js +7 -2
  158. package/dist/viewer/figure-preview.d.ts +4 -0
  159. package/dist/viewer/figure-preview.js +54 -0
  160. package/dist/viewer/hmr.js +4 -3
  161. package/dist/viewer/lazy-preview.d.ts +2 -0
  162. package/dist/viewer/lazy-preview.js +43 -0
  163. package/dist/viewer/locales/eng.json +26 -3
  164. package/dist/viewer/locales/jpn.json +26 -3
  165. package/dist/viewer/locales/zho.json +26 -3
  166. package/dist/viewer/plugin-blocks.js +1 -1
  167. package/dist/viewer/plugins.js +1 -1
  168. package/dist/viewer/resource-library.d.ts +1 -1
  169. package/dist/viewer/resource-library.js +5 -4
  170. package/dist/viewer/serve.d.ts +2 -1
  171. package/dist/viewer/serve.js +148 -41
  172. package/dist/viewer/textfile.d.ts +2 -0
  173. package/dist/viewer/textfile.js +20 -5
  174. package/package.json +5 -3
  175. package/dist/viewer/lazy-graph.d.ts +0 -2
  176. package/dist/viewer/lazy-graph.js +0 -30
@@ -1,3 +1,4 @@
1
+ import { type PreviewSettings } from "../core/previewers.js";
1
2
  import type { PluginTransport } from "../plugins/transport.js";
2
3
  export interface BuildOptions {
3
4
  format: "html" | "zip";
@@ -10,6 +11,7 @@ export interface BuildOptions {
10
11
  pluginModule?: string;
11
12
  /** Build-time authenticated reads; live HTML receives its transport at runtime. */
12
13
  pluginTransport?: PluginTransport;
14
+ previews?: PreviewSettings;
13
15
  }
14
16
  /** Build one artifact from the manifest and its managed content. */
15
17
  export declare const buildBundle: (root: string, options: BuildOptions) => Promise<{
@@ -7,8 +7,12 @@ import { exportEntries } from "../compiler/export.js";
7
7
  import { loadProjectFonts } from "../compiler/fonts.js";
8
8
  import { textfilePath } from "../compiler/textfile.js";
9
9
  import { zip } from "../compiler/zip.js";
10
+ import { walkBlocks } from "../core/blocks.js";
11
+ import { selectCodeGrammars } from "../core/code-grammars.js";
12
+ import { parsePreviewSettings } from "../core/previewers.js";
10
13
  import { loadBuildPlugins, pluginSnapshot } from "./build-plugins.js";
11
14
  import { loadSiteLanguages } from "./languages.js";
15
+ import { loadViewerPlugins } from "./plugin-config.js";
12
16
  import { sourceFileBase } from "./workspace.js";
13
17
  /** Build one artifact from the manifest and its managed content. */
14
18
  export const buildBundle = async (root, options) => {
@@ -31,8 +35,12 @@ export const buildBundle = async (root, options) => {
31
35
  throw new Error("build format must be html | zip");
32
36
  if (urlPreview !== "embed" && urlPreview !== "network")
33
37
  throw new Error("--url_preview must be embed | network");
38
+ const previews = options.previews ??
39
+ parsePreviewSettings({
40
+ domains: (await loadViewerPlugins(options.pluginModule)).allowedDomains ?? [],
41
+ });
34
42
  const validate = (path) => {
35
- const compiled = compileSite(path);
43
+ const compiled = compileSite(path, { previews });
36
44
  if (compiled.errors.length)
37
45
  throw new Error(`Content validation failed:\n${compiled.errors.join("\n")}`);
38
46
  return compiled;
@@ -67,14 +75,20 @@ export const buildBundle = async (root, options) => {
67
75
  return { data: zip(entries), docs: compiled.docs.length };
68
76
  const config = await loadSiteLanguages(root);
69
77
  const { bundleClient, publishHtml, siteFrom } = await import("./serve.js");
78
+ const site = {
79
+ ...siteFrom(compiled, config.languages, config),
80
+ sourceBase,
81
+ fonts: loadProjectFonts(root),
82
+ };
83
+ const blocks = walkBlocks(site.entries.flatMap((entry) => entry.blocks));
84
+ const code = blocks.flatMap((block) => block.type === "code" && block.lang !== "mermaid" && !block.unavailable ? [block] : []);
85
+ site.codeGrammars = selectCodeGrammars(site.codeGrammars ?? [], code.map((block) => block.lang ?? "text"));
86
+ const diagrams = blocks.some((block) => block.type === "schemaGraph" ||
87
+ (block.type === "code" && block.lang === "mermaid" && !block.unavailable));
70
88
  return {
71
- data: publishHtml({
72
- ...siteFrom(compiled, config.languages),
73
- sourceBase,
74
- fonts: loadProjectFonts(root),
75
- codeLanguages: config.codeLanguages,
76
- codeGrammars: config.codeGrammars,
77
- }, await bundleClient("core/schema-graph-global.tsx"), undefined, await bundleClient("viewer/code-highlight.ts"), options.mode === "live" ? "live" : urlPreview === "embed" ? "static" : "network", options.mode === "live" ? await bundleClient("viewer/published-plugins.ts") : "", compiled.docs.some((doc) => doc.subformat)
89
+ data: publishHtml(site, diagrams ? await bundleClient("core/schema-graph-global.tsx") : "", undefined, code.length ? await bundleClient("viewer/code-highlight.ts") : "", options.mode === "live" ? "live" : urlPreview === "embed" ? "static" : "network", options.mode === "live" && blocks.some((block) => block.type === "external")
90
+ ? await bundleClient("viewer/published-plugins.ts")
91
+ : "", compiled.docs.some((doc) => doc.subformat)
78
92
  ? await bundleClient("viewer/published-subformats.ts")
79
93
  : ""),
80
94
  docs: compiled.docs.length,
@@ -1,5 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { readManifest } from "../compiler/manifest.js";
3
+ import { validateSubformatFile } from "../compiler/subformats.js";
3
4
  import { textfilePath, writeTextfile } from "../compiler/textfile.js";
4
5
  import { codeFileName, codeFilePlan } from "../core/code-file.js";
5
6
  import { isDocId } from "../core/content-metadata.js";
@@ -20,8 +21,12 @@ export const codeFileResponse = (root, input, previews) => {
20
21
  ? defaultFilePath(codeFileName(input.body, input.position, input.documentId))
21
22
  : input.file;
22
23
  let plan = codeFilePlan(input.body, input.position, target, previews);
23
- const create = () => !existsSync(textfilePath(root, plan.file)) &&
24
- writeTextfile(root, plan.file, plan.content, null);
24
+ const create = () => {
25
+ if (existsSync(textfilePath(root, plan.file)))
26
+ return false;
27
+ validateSubformatFile(root, plan.file, plan.content, previews?.domains);
28
+ return writeTextfile(root, plan.file, plan.content, null);
29
+ };
25
30
  if (automatic) {
26
31
  for (let index = 2; !create(); index++) {
27
32
  const dot = target.lastIndexOf(".");
@@ -0,0 +1,4 @@
1
+ import type { FigureEntry } from "../core/content-types.js";
2
+ export declare const deferredFigureHtml: (fig: FigureEntry, cls?: string, label?: string) => string;
3
+ /** Delegated so previews inserted by navigation or HMR use the same loading state. */
4
+ export declare function mountFigurePreviews(): void;
@@ -0,0 +1,54 @@
1
+ import { escapeHtml } from "../core/escape-html.js";
2
+ import { figureFrameHtml } from "../core/figure-frame.js";
3
+ export const deferredFigureHtml = (fig, cls = "fig-frame", label) => {
4
+ if (fig.markup.length <= 100_000)
5
+ return figureFrameHtml(fig, cls, label);
6
+ if (cls.includes("figpop-frame"))
7
+ return escapeHtml(fig.title ?? fig.file);
8
+ const url = `/api/figure-preview?file=${encodeURIComponent(fig.file)}${label === undefined ? "" : `&label=${encodeURIComponent(label)}`}`;
9
+ return `<div class="figure-placeholder" data-figure-preview="${escapeHtml(url)}"><span>${escapeHtml(label || fig.title || fig.file)}</span><button type="button" data-i18n="Load preview">Load preview</button><span role="status"></span></div>`;
10
+ };
11
+ /** Delegated so previews inserted by navigation or HMR use the same loading state. */
12
+ export function mountFigurePreviews() {
13
+ document.addEventListener("click", async (event) => {
14
+ const button = event.target instanceof Element
15
+ ? event.target.closest("[data-figure-preview] > button")
16
+ : null;
17
+ const host = button?.parentElement;
18
+ const url = host?.dataset.figurePreview;
19
+ const status = host?.querySelector('[role="status"]');
20
+ if (!button || !host || !url || !status)
21
+ return;
22
+ const translate = (key) => window.__docsTranslate?.(key) ?? key;
23
+ button.disabled = true;
24
+ host.setAttribute("aria-busy", "true");
25
+ status.textContent = translate("Loading");
26
+ try {
27
+ const response = await fetch(url);
28
+ if (!response.ok)
29
+ throw new Error(translate("Preview unavailable"));
30
+ const html = await response.text();
31
+ if (!host.isConnected)
32
+ return;
33
+ const focused = document.activeElement === button;
34
+ host.innerHTML = html;
35
+ host.classList.remove("figure-placeholder");
36
+ delete host.dataset.figurePreview;
37
+ if (focused) {
38
+ host.tabIndex = -1;
39
+ host.focus({ preventScroll: true });
40
+ }
41
+ }
42
+ catch (error) {
43
+ if (!host.isConnected)
44
+ return;
45
+ status.textContent = error instanceof Error ? error.message : String(error);
46
+ button.textContent = translate("Retry");
47
+ button.dataset.i18n = "Retry";
48
+ }
49
+ finally {
50
+ button.disabled = false;
51
+ host.removeAttribute("aria-busy");
52
+ }
53
+ });
54
+ }
@@ -57,6 +57,7 @@ export const classifyChange = (rel) => {
57
57
  p === "src/viewer/edit-code-highlight.ts" ||
58
58
  p === "src/viewer/edit-git-diff.ts" ||
59
59
  p === "src/viewer/code-tokens.ts" ||
60
+ p === "src/viewer/code-worker.ts" ||
60
61
  p === "src/viewer/i18n.ts" ||
61
62
  p === "src/viewer/language-picker.ts" ||
62
63
  p === "src/viewer/theme-picker.ts" ||
@@ -282,7 +283,7 @@ export const hmrClientScript = (mode) => `
282
283
  const main = document.querySelector("main");
283
284
  const nextMain = next.querySelector("main");
284
285
  if (!main || !nextMain) { reload(); return; }
285
- const y = window.scrollY;
286
+ const y = main.scrollTop;
286
287
  document.title = next.title;
287
288
  const title = document.getElementById("site-title");
288
289
  const nextTitle = next.getElementById("site-title");
@@ -302,7 +303,7 @@ export const hmrClientScript = (mode) => `
302
303
  (${updateNav.toString()})(nav, nextNav.innerHTML);
303
304
  if (window.__docsNavRestore) window.__docsNavRestore();
304
305
  }
305
- window.scrollTo(0, y);
306
+ main.scrollTo(0, y);
306
307
  };
307
308
 
308
309
  // Notification hooks for the edit client (src/viewer/edit-client.ts). edit-client.ts may run
@@ -324,7 +325,7 @@ export const hmrClientScript = (mode) => `
324
325
  });
325
326
  es.addEventListener("change", (ev) => {
326
327
  const { kind, files } = JSON.parse(ev.data);
327
- if (MODE === "preview") { if (kind === "content") void swap(); return; }
328
+ if (MODE === "preview" && kind === "content") { void swap(); return; }
328
329
  if (kind === "content") {
329
330
  const onContent = window.__docsHmr && window.__docsHmr.onContent;
330
331
  // If registered, leave it to the in-place update and don't reload (the editor swaps
@@ -0,0 +1,2 @@
1
+ /** Load enhancement scripts only when their content is near the viewport. */
2
+ export declare const loadPreviewScript: (src: string, selector: string, type?: string) => void;
@@ -0,0 +1,43 @@
1
+ /** Load enhancement scripts only when their content is near the viewport. */
2
+ export const loadPreviewScript = (src, selector, type = "") => {
3
+ const root = document.querySelector("main") ?? document.body;
4
+ let requested = false;
5
+ const load = () => {
6
+ if (requested)
7
+ return;
8
+ requested = true;
9
+ const script = document.createElement("script");
10
+ script.type = type;
11
+ script.src = src;
12
+ script.onload = () => {
13
+ observer.disconnect();
14
+ visibility.disconnect();
15
+ pending.clear();
16
+ };
17
+ script.onerror = () => {
18
+ script.remove();
19
+ requested = false;
20
+ };
21
+ document.head.append(script);
22
+ };
23
+ const pending = new Set();
24
+ const visibility = new IntersectionObserver((entries) => {
25
+ if (entries.some((entry) => entry.isIntersecting && root.contains(entry.target)))
26
+ load();
27
+ }, { rootMargin: "200px" });
28
+ const watch = () => {
29
+ for (const node of pending)
30
+ if (!root.contains(node)) {
31
+ visibility.unobserve(node);
32
+ pending.delete(node);
33
+ }
34
+ for (const node of root.querySelectorAll(selector))
35
+ if (!pending.has(node)) {
36
+ pending.add(node);
37
+ visibility.observe(node);
38
+ }
39
+ };
40
+ const observer = new MutationObserver(watch);
41
+ observer.observe(root, { childList: true, subtree: true });
42
+ watch();
43
+ };
@@ -35,6 +35,7 @@
35
35
  "Save (Ctrl+S)": "Save (Ctrl+S)",
36
36
  "View settings": "View settings",
37
37
  "Auto save": "Auto save",
38
+ "Wrap lines": "Wrap lines",
38
39
  "Front-matter fields": "Front-matter fields",
39
40
  "title": "title",
40
41
  "desc": "desc",
@@ -336,6 +337,10 @@
336
337
  "Added": "Added",
337
338
  "Modified": "Modified",
338
339
  "Add subformat…": "Add subformat…",
340
+ "Delete": "Delete",
341
+ "Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "Delete subformat {ext} and its sidebar page? Records and schema files will be kept.",
342
+ "Subformat changed externally. Reload and try again.": "Subformat changed externally. Reload and try again.",
343
+ "Move or remove this subformat page's child pages before deleting it.": "Move or remove this subformat page's child pages before deleting it.",
339
344
  "Add subformat": "Add subformat",
340
345
  "Extension": "Extension",
341
346
  "Storage format": "Storage format",
@@ -356,6 +361,16 @@
356
361
  "Add field": "Add field",
357
362
  "Required": "Required",
358
363
  "Allow extra fields": "Allow extra fields",
364
+ "Schema settings": "Schema settings",
365
+ "Remove nested fields before changing the type.": "Remove nested fields before changing the type.",
366
+ "Any type": "Any type",
367
+ "One choice per line. Use \"\" for empty text, \"a\\nb\" for multiline text, and JSON for other types.": "One choice per line. Use \"\" for empty text, \"a\\nb\" for multiline text, and JSON for other types.",
368
+ "Enter at least one choice.": "Enter at least one choice.",
369
+ "Enter a non-empty JSON array of schemas.": "Enter a non-empty JSON array of schemas.",
370
+ "Enter a JSON schema object or boolean.": "Enter a JSON schema object or boolean.",
371
+ "Enter an object containing named schemas.": "Enter an object containing named schemas.",
372
+ "The constant must match the field type.": "The constant must match the field type.",
373
+ "Change existing choices or defaults before changing the type.": "Change existing choices or defaults before changing the type.",
359
374
  "Choices (one per line)": "Choices (one per line)",
360
375
  "Item type": "Item type",
361
376
  "Rename linked fields in JSON text.": "Rename linked fields in JSON text.",
@@ -373,9 +388,17 @@
373
388
  "Remove page": "Remove page",
374
389
  "Rename page": "Rename page",
375
390
  "Remove this page from the sidebar? The records will be kept.": "Remove this page from the sidebar? The records will be kept.",
376
- "Constraints": "Constraints",
377
- "Semantic": "Semantic",
391
+ "Parameters": "Parameters",
378
392
  "Items": "Items",
379
393
  "Remove parameter": "Remove parameter",
380
- "Check the parameter value.": "Check the parameter value."
394
+ "Check the parameter value.": "Check the parameter value.",
395
+ "Download PDF": "Download PDF",
396
+ "Choose date": "Choose date",
397
+ "Previous month": "Previous month",
398
+ "Next month": "Next month",
399
+ "Today": "Today",
400
+ "Clear": "Clear",
401
+ "Enter a valid date (YYYY-MM-DD).": "Enter a valid date (YYYY-MM-DD).",
402
+ "Load preview": "Load preview",
403
+ "Preview unavailable": "Preview unavailable"
381
404
  }
@@ -35,6 +35,7 @@
35
35
  "Save (Ctrl+S)": "保存(Ctrl+S)",
36
36
  "View settings": "表示設定",
37
37
  "Auto save": "自動保存",
38
+ "Wrap lines": "折り返す",
38
39
  "Front-matter fields": "文書の属性を表示",
39
40
  "title": "タイトル",
40
41
  "desc": "説明",
@@ -336,6 +337,10 @@
336
337
  "Added": "新規",
337
338
  "Modified": "変更",
338
339
  "Add subformat…": "subformatを追加…",
340
+ "Delete": "削除",
341
+ "Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "subformat {ext} とサイドバーのページを削除しますか? レコードとスキーマファイルは保持されます。",
342
+ "Subformat changed externally. Reload and try again.": "subformatが外部で変更されました。再読み込みしてやり直してください。",
343
+ "Move or remove this subformat page's child pages before deleting it.": "削除する前に、このsubformatページの子ページを移動または削除してください。",
339
344
  "Add subformat": "subformatを追加",
340
345
  "Extension": "拡張子",
341
346
  "Storage format": "保存形式",
@@ -356,6 +361,16 @@
356
361
  "Add field": "フィールドを追加",
357
362
  "Required": "必須",
358
363
  "Allow extra fields": "未定義のフィールドを許可",
364
+ "Schema settings": "スキーマ全体の設定",
365
+ "Remove nested fields before changing the type.": "型を変える前に入れ子のフィールドを削除してください。",
366
+ "Any type": "任意の型",
367
+ "One choice per line. Use \"\" for empty text, \"a\\nb\" for multiline text, and JSON for other types.": "選択肢は1行に1つ。空文字は \"\"、改行入りは \"a\\nb\"、その他の型はJSONで入力します。",
368
+ "Enter at least one choice.": "選択肢を1つ以上入力してください。",
369
+ "Enter a non-empty JSON array of schemas.": "スキーマを1つ以上含むJSON配列を入力してください。",
370
+ "Enter a JSON schema object or boolean.": "JSON Schemaオブジェクトまたは真偽値を入力してください。",
371
+ "Enter an object containing named schemas.": "名前付きスキーマを含むオブジェクトを入力してください。",
372
+ "The constant must match the field type.": "固定値をフィールドの型に合わせてください。",
373
+ "Change existing choices or defaults before changing the type.": "型を変える前に既存の選択肢や既定値を変更してください。",
359
374
  "Choices (one per line)": "選択肢(1行に1つ)",
360
375
  "Item type": "配列要素の型",
361
376
  "Rename linked fields in JSON text.": "参照されるフィールド名はJSON textで変更してください。",
@@ -373,9 +388,17 @@
373
388
  "Remove page": "ページを削除",
374
389
  "Rename page": "ページ名を変更",
375
390
  "Remove this page from the sidebar? The records will be kept.": "サイドバーからこのページを削除しますか? レコードは保持されます。",
376
- "Constraints": "制約",
377
- "Semantic": "意味情報",
391
+ "Parameters": "パラメーター",
378
392
  "Items": "配列要素",
379
393
  "Remove parameter": "パラメーターを削除",
380
- "Check the parameter value.": "パラメーターの値を確認してください。"
394
+ "Check the parameter value.": "パラメーターの値を確認してください。",
395
+ "Download PDF": "PDFをダウンロード",
396
+ "Choose date": "日付を選択",
397
+ "Previous month": "前の月",
398
+ "Next month": "次の月",
399
+ "Today": "今日",
400
+ "Clear": "クリア",
401
+ "Enter a valid date (YYYY-MM-DD).": "有効な日付を入力してください(YYYY-MM-DD)。",
402
+ "Load preview": "プレビューを読み込む",
403
+ "Preview unavailable": "プレビューを読み込めません"
381
404
  }
@@ -35,6 +35,7 @@
35
35
  "Save (Ctrl+S)": "保存(Ctrl+S)",
36
36
  "View settings": "显示设置",
37
37
  "Auto save": "自动保存",
38
+ "Wrap lines": "自动换行",
38
39
  "Front-matter fields": "显示文档属性",
39
40
  "title": "标题",
40
41
  "desc": "描述",
@@ -336,6 +337,10 @@
336
337
  "Added": "新增",
337
338
  "Modified": "修改",
338
339
  "Add subformat…": "添加子格式…",
340
+ "Delete": "删除",
341
+ "Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "删除子格式 {ext} 及其侧边栏页面?记录和模式文件将保留。",
342
+ "Subformat changed externally. Reload and try again.": "子格式已被外部修改。请重新加载后重试。",
343
+ "Move or remove this subformat page's child pages before deleting it.": "删除前,请先移动或删除此子格式页面的子页面。",
339
344
  "Add subformat": "添加子格式",
340
345
  "Extension": "扩展名",
341
346
  "Storage format": "存储格式",
@@ -356,6 +361,16 @@
356
361
  "Add field": "添加字段",
357
362
  "Required": "必填",
358
363
  "Allow extra fields": "允许额外字段",
364
+ "Schema settings": "模式设置",
365
+ "Remove nested fields before changing the type.": "更改类型前,请先删除嵌套字段。",
366
+ "Any type": "任意类型",
367
+ "One choice per line. Use \"\" for empty text, \"a\\nb\" for multiline text, and JSON for other types.": "每行一个选项。空文本用 \"\",多行文本用 \"a\\nb\",其他类型用JSON。",
368
+ "Enter at least one choice.": "请至少输入一个选项。",
369
+ "Enter a non-empty JSON array of schemas.": "请输入至少包含一个模式的JSON数组。",
370
+ "Enter a JSON schema object or boolean.": "请输入JSON模式对象或布尔值。",
371
+ "Enter an object containing named schemas.": "请输入包含命名模式的对象。",
372
+ "The constant must match the field type.": "常量必须符合字段类型。",
373
+ "Change existing choices or defaults before changing the type.": "更改类型前,请先修改现有选项或默认值。",
359
374
  "Choices (one per line)": "选项(每行一个)",
360
375
  "Item type": "数组项类型",
361
376
  "Rename linked fields in JSON text.": "请在JSON text中重命名关联字段。",
@@ -373,9 +388,17 @@
373
388
  "Remove page": "移除页面",
374
389
  "Rename page": "重命名页面",
375
390
  "Remove this page from the sidebar? The records will be kept.": "从侧边栏移除此页面?记录将被保留。",
376
- "Constraints": "约束",
377
- "Semantic": "语义信息",
391
+ "Parameters": "参数",
378
392
  "Items": "数组元素",
379
393
  "Remove parameter": "移除参数",
380
- "Check the parameter value.": "请检查参数值。"
394
+ "Check the parameter value.": "请检查参数值。",
395
+ "Download PDF": "下载 PDF",
396
+ "Choose date": "选择日期",
397
+ "Previous month": "上个月",
398
+ "Next month": "下个月",
399
+ "Today": "今天",
400
+ "Clear": "清除",
401
+ "Enter a valid date (YYYY-MM-DD).": "请输入有效日期(YYYY-MM-DD)。",
402
+ "Load preview": "加载预览",
403
+ "Preview unavailable": "无法加载预览"
381
404
  }
@@ -1,4 +1,4 @@
1
- import { escapeHtml } from "../core/html.js";
1
+ import { escapeHtml } from "../core/escape-html.js";
2
2
  import { parseMdast } from "../core/markdown.js";
3
3
  import { pluginLink, } from "../plugins/blocks.js";
4
4
  const link = (url, html) => pluginLink(url)
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { escapeHtml } from "../core/html.js";
2
+ import { escapeHtml } from "../core/escape-html.js";
3
3
  import { isPluginError, PluginError } from "../plugins/oauth.js";
4
4
  import { createPluginRuntime } from "../plugins/runtime.js";
5
5
  import { isLocalToolRequest } from "./editor-tools.js";
@@ -24,7 +24,7 @@ export interface ResourceIndex {
24
24
  errors: string[];
25
25
  }
26
26
  /** Index authored content, including files not referenced by any document. */
27
- export declare const resourceIndex: (root: string, files: readonly string[]) => ResourceIndex;
27
+ export declare const resourceIndex: (root: string, files: readonly string[], domains?: readonly string[]) => ResourceIndex;
28
28
  export type ResourceView = "files" | "codeblocks" | "urls" | "url-previews";
29
29
  export declare const resourceTabs: (view: ResourceView) => string;
30
30
  export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<ResourceView, "files"> | "subformats", pageTitle?: string) => string;
@@ -16,7 +16,7 @@ const codeFormat = (language) => /^(text|txt|plain|plaintext)$/.test(language)
16
16
  ? "text"
17
17
  : (bundledLanguagesInfo.find((entry) => entry.id === language || entry.aliases?.includes(language))?.id ?? language);
18
18
  /** Index authored content, including files not referenced by any document. */
19
- export const resourceIndex = (root, files) => {
19
+ export const resourceIndex = (root, files, domains = []) => {
20
20
  const result = {
21
21
  codeblocks: [],
22
22
  urls: [],
@@ -32,7 +32,7 @@ export const resourceIndex = (root, files) => {
32
32
  try {
33
33
  if (!paths.has(config.schema))
34
34
  throw new Error("Schema is not available in the workspace");
35
- const loaded = loadSubformat(root, config);
35
+ const loaded = loadSubformat(root, config, domains);
36
36
  formats.set(config.ext, loaded);
37
37
  result.subformats.push({
38
38
  ...config,
@@ -62,9 +62,10 @@ export const resourceIndex = (root, files) => {
62
62
  const source = { file, line: offset + (node.position?.start.line ?? 1) };
63
63
  if (node.type === "code") {
64
64
  const language = node.lang?.toLowerCase() || "text";
65
+ const format = formats.get(language.replace(/^\./, ""));
65
66
  result.codeblocks.push({
66
- language: formats.get(language)?.format ?? language,
67
- format: formats.has(language) ? language : codeFormat(language),
67
+ language: format?.format ?? language,
68
+ format: format?.ext ?? codeFormat(language),
68
69
  caption: node.meta ?? "",
69
70
  content: node.value,
70
71
  source,
@@ -10,6 +10,7 @@ import { type PreviewSettings } from "../core/previewers.js";
10
10
  import { type Frontmatter } from "../core/taxonomy.js";
11
11
  import { type WorkspaceSource } from "../core/workspace.js";
12
12
  import { type FilePreviewResults } from "./file-references.js";
13
+ import { type SiteLanguages } from "./languages.js";
13
14
  import { type ViewerRuntime } from "./plugin-config.js";
14
15
  export type ServeMode = "preview" | "edit";
15
16
  /**
@@ -81,7 +82,7 @@ export interface Site {
81
82
  themes?: readonly ("light" | "dark")[];
82
83
  }
83
84
  /** Compile result → viewer Site (shared by the server's per-request path and one-off publish). */
84
- export declare const siteFrom: ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }: Compiled, languages?: readonly LanguageAdapter[]) => Site;
85
+ export declare const siteFrom: ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }: Compiled, languages?: readonly LanguageAdapter[], code?: Pick<SiteLanguages, "codeLanguages" | "codeGrammars">) => Site;
85
86
  export declare const filePreviewResults: (entry: Entry, site: Site) => FilePreviewResults;
86
87
  /** Renders only the requested doc, not every doc in site.entries. */
87
88
  export declare const renderEntryHtml: (site: Site, entry: Entry) => {