@dooc-dev/dooc 0.0.7 → 0.0.8

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 (302) hide show
  1. package/dist/client.global.js +1 -0
  2. package/dist/code-worker.global.js +11 -11
  3. package/dist/code.global.js +75 -75
  4. package/dist/edit.global.js +234 -231
  5. package/dist/{compiler → engine/compiler}/bundle-urls.js +1 -4
  6. package/dist/{compiler → engine/compiler}/check-prose.d.ts +1 -1
  7. package/dist/{compiler → engine/compiler}/check-prose.js +1 -1
  8. package/dist/{compiler → engine/compiler}/check.js +15 -27
  9. package/dist/{compiler → engine/compiler}/code-blocks.js +3 -1
  10. package/dist/{compiler → engine/compiler}/code-languages.js +1 -2
  11. package/dist/{compiler → engine/compiler}/compile.d.ts +5 -4
  12. package/dist/{compiler → engine/compiler}/compile.js +91 -32
  13. package/dist/{compiler → engine/compiler}/config.js +1 -3
  14. package/dist/{compiler → engine/compiler}/dialect.d.ts +1 -3
  15. package/dist/{compiler → engine/compiler}/dialect.js +8 -52
  16. package/dist/{compiler → engine/compiler}/dxf.js +1 -1
  17. package/dist/{compiler → engine/compiler}/export.js +15 -8
  18. package/dist/{compiler → engine/compiler}/figures.js +26 -22
  19. package/dist/{compiler → engine/compiler}/file-cache.d.ts +1 -2
  20. package/dist/{compiler → engine/compiler}/file-cache.js +8 -15
  21. package/dist/{compiler → engine/compiler}/files.js +49 -38
  22. package/dist/{compiler → engine/compiler}/fonts.js +1 -3
  23. package/dist/{compiler → engine/compiler}/from-mdast.js +1 -1
  24. package/dist/engine/compiler/host.d.ts +10 -0
  25. package/dist/engine/compiler/host.js +16 -0
  26. package/dist/{compiler → engine/compiler}/icons.d.ts +3 -0
  27. package/dist/{compiler → engine/compiler}/icons.js +28 -10
  28. package/dist/{compiler → engine/compiler}/ignored-files.d.ts +2 -0
  29. package/dist/{compiler → engine/compiler}/ignored-files.js +12 -3
  30. package/dist/{compiler → engine/compiler}/locales.js +2 -8
  31. package/dist/{compiler → engine/compiler}/manifest.d.ts +3 -2
  32. package/dist/engine/compiler/manifest.js +46 -0
  33. package/dist/{compiler → engine/compiler}/ops.d.ts +4 -1
  34. package/dist/{compiler → engine/compiler}/ops.js +36 -21
  35. package/dist/engine/compiler/schema-file-references.d.ts +2 -0
  36. package/dist/engine/compiler/schema-file-references.js +82 -0
  37. package/dist/engine/compiler/serialize.d.ts +2 -0
  38. package/dist/engine/compiler/serialize.js +5 -0
  39. package/dist/{compiler → engine/compiler}/subformat-schema.js +1 -3
  40. package/dist/{compiler → engine/compiler}/subformats.d.ts +10 -0
  41. package/dist/{compiler → engine/compiler}/subformats.js +122 -18
  42. package/dist/{compiler → engine/compiler}/textfile-remote.js +1 -2
  43. package/dist/{compiler → engine/compiler}/textfile.js +4 -6
  44. package/dist/{compiler → engine/compiler}/theme-variants.js +1 -1
  45. package/dist/{compiler → engine/compiler}/zip.js +1 -1
  46. package/dist/{core → engine/core}/blocks.d.ts +6 -4
  47. package/dist/{core → engine/core}/content-metadata.d.ts +6 -1
  48. package/dist/{core → engine/core}/content-metadata.js +84 -18
  49. package/dist/{core → engine/core}/content-types.d.ts +4 -2
  50. package/dist/{core → engine/core}/html.d.ts +7 -0
  51. package/dist/{core → engine/core}/html.js +44 -3
  52. package/dist/{core → engine/core}/icons.d.ts +3 -0
  53. package/dist/engine/core/icons.js +20 -0
  54. package/dist/{core → engine/core}/routing.d.ts +2 -0
  55. package/dist/{core → engine/core}/routing.js +9 -0
  56. package/dist/{core → engine/core}/schema-refs.d.ts +1 -1
  57. package/dist/{core → engine/core}/schema-refs.js +3 -1
  58. package/dist/engine/core/subformat-references.d.ts +5 -0
  59. package/dist/engine/core/subformat-references.js +33 -0
  60. package/dist/{core → engine/core}/subformats.d.ts +7 -0
  61. package/dist/{core → engine/core}/subformats.js +5 -1
  62. package/dist/{core → engine/core}/taxonomy.d.ts +2 -3
  63. package/dist/{core → engine/core}/taxonomy.js +1 -5
  64. package/dist/flow.global.js +306 -306
  65. package/dist/frontend/application-request.d.ts +14 -0
  66. package/dist/frontend/application-request.js +36 -0
  67. package/dist/frontend/document-application.d.ts +200 -0
  68. package/dist/{viewer/serve.js → frontend/document-application.js} +1611 -1670
  69. package/dist/frontend/figure-preview.d.ts +4 -0
  70. package/dist/{viewer → frontend}/figure-preview.js +4 -4
  71. package/dist/{viewer → frontend}/file-references.d.ts +1 -1
  72. package/dist/{viewer → frontend}/file-references.js +3 -3
  73. package/dist/{viewer → frontend}/font-picker.d.ts +1 -1
  74. package/dist/{viewer → frontend}/font-settings.d.ts +1 -1
  75. package/dist/{viewer → frontend}/language-picker.js +112 -18
  76. package/dist/{viewer → frontend}/locales/eng.json +16 -2
  77. package/dist/{viewer → frontend}/locales/jpn.json +16 -2
  78. package/dist/{viewer → frontend}/locales/zho.json +16 -2
  79. package/dist/{viewer → frontend}/nav-focus.js +2 -0
  80. package/dist/{viewer → frontend}/plugin-blocks.js +2 -2
  81. package/dist/{viewer → frontend}/resize.js +14 -2
  82. package/dist/frontend/resource-download.d.ts +2 -0
  83. package/dist/frontend/resource-download.js +43 -0
  84. package/dist/{viewer → frontend}/resource-library.d.ts +9 -2
  85. package/dist/{viewer → frontend}/resource-library.js +133 -37
  86. package/dist/{core → frontend}/schema-graph-flow.d.ts +1 -1
  87. package/dist/{core → frontend}/schema-graph-flow.js +1 -1
  88. package/dist/{viewer → frontend}/search.d.ts +2 -2
  89. package/dist/{viewer → frontend}/search.js +26 -8
  90. package/dist/graph/schema-graph-global.js +17 -17
  91. package/dist/install.sh +68 -0
  92. package/dist/plugins.global.js +62 -62
  93. package/dist/{viewer → server}/assets.d.ts +2 -0
  94. package/dist/server/assets.js +7 -0
  95. package/dist/{viewer → server}/build-plugins.js +4 -4
  96. package/dist/{viewer → server}/build.d.ts +2 -1
  97. package/dist/{viewer → server}/build.js +31 -15
  98. package/dist/{cli.js → server/cli.js} +199 -66
  99. package/dist/server/editor-tools.d.ts +1 -0
  100. package/dist/server/editor-tools.js +1 -0
  101. package/dist/{viewer → server}/extension-pack.js +2 -2
  102. package/dist/{viewer → server}/extensions.d.ts +1 -1
  103. package/dist/{viewer → server}/extensions.js +3 -3
  104. package/dist/server/git-diff.d.ts +10 -0
  105. package/dist/{viewer → server}/git-diff.js +45 -10
  106. package/dist/server/git-origin.d.ts +4 -0
  107. package/dist/server/git-origin.js +103 -0
  108. package/dist/server/git.d.ts +9 -0
  109. package/dist/{viewer → server}/git.js +50 -6
  110. package/dist/server/history.d.ts +14 -0
  111. package/dist/server/history.js +205 -0
  112. package/dist/{viewer → server}/hmr.d.ts +0 -22
  113. package/dist/server/hmr.js +168 -0
  114. package/dist/server/index.d.ts +17 -0
  115. package/dist/{index.js → server/index.js} +16 -16
  116. package/dist/{viewer → server}/ja-lint.d.ts +1 -1
  117. package/dist/{viewer → server}/languages.d.ts +1 -1
  118. package/dist/{viewer → server}/languages.js +3 -3
  119. package/dist/{mcp.d.ts → server/mcp.d.ts} +2 -2
  120. package/dist/{mcp.js → server/mcp.js} +60 -21
  121. package/dist/{viewer → server}/plugin-config.d.ts +2 -2
  122. package/dist/{viewer → server}/plugin-config.js +2 -2
  123. package/dist/{plugins → server/plugins}/local-storage.d.ts +1 -1
  124. package/dist/{plugins → server/plugins}/local-storage.js +1 -1
  125. package/dist/{plugins → server/plugins}/runtime.d.ts +4 -4
  126. package/dist/{plugins → server/plugins}/runtime.js +4 -4
  127. package/dist/{viewer → server}/plugins.d.ts +3 -3
  128. package/dist/{viewer → server}/plugins.js +14 -13
  129. package/dist/server/resource-library.d.ts +1 -0
  130. package/dist/server/resource-library.js +1 -0
  131. package/dist/server/self.d.ts +5 -0
  132. package/dist/server/self.js +98 -0
  133. package/dist/server/serve.d.ts +61 -0
  134. package/dist/server/serve.js +503 -0
  135. package/dist/server/static-client.d.ts +4 -0
  136. package/dist/server/static-client.js +117 -0
  137. package/dist/server/workspace-server.d.ts +16 -0
  138. package/dist/server/workspace-server.js +266 -0
  139. package/dist/{viewer → server}/workspace.d.ts +6 -1
  140. package/dist/{viewer → server}/workspace.js +46 -0
  141. package/dist/subformats.global.js +92 -6
  142. package/dist/ui.global.js +85 -72
  143. package/dist/workspace/client.d.ts +13 -0
  144. package/dist/workspace/client.js +114 -0
  145. package/dist/{viewer → workspace}/code-file.d.ts +1 -1
  146. package/dist/{viewer → workspace}/code-file.js +7 -7
  147. package/dist/workspace/connection.d.ts +27 -0
  148. package/dist/workspace/connection.js +38 -0
  149. package/dist/{viewer → workspace}/editor-tools.d.ts +7 -1
  150. package/dist/{viewer → workspace}/editor-tools.js +12 -9
  151. package/dist/{viewer → workspace}/git-types.d.ts +7 -0
  152. package/dist/workspace/github.d.ts +4 -0
  153. package/dist/workspace/github.js +99 -0
  154. package/dist/workspace/history.d.ts +46 -0
  155. package/dist/workspace/history.js +86 -0
  156. package/dist/workspace/protocol.d.ts +38 -0
  157. package/dist/workspace/protocol.js +20 -0
  158. package/dist/workspace/resource-download.d.ts +1 -0
  159. package/dist/workspace/resource-download.js +8 -0
  160. package/dist/workspace/server.d.ts +9 -0
  161. package/dist/workspace/server.js +48 -0
  162. package/dist/{viewer → workspace}/site-icon.js +9 -10
  163. package/dist/{viewer → workspace}/site-title.js +6 -7
  164. package/dist/{viewer → workspace}/textfile.d.ts +1 -1
  165. package/dist/{viewer → workspace}/textfile.js +5 -5
  166. package/dist/workspace-worker.global.js +2859 -0
  167. package/package.json +34 -20
  168. package/dist/compiler/manifest.js +0 -37
  169. package/dist/compiler/serialize.d.ts +0 -3
  170. package/dist/compiler/serialize.js +0 -16
  171. package/dist/core/icons.js +0 -5
  172. package/dist/index.d.ts +0 -17
  173. package/dist/viewer/assets.js +0 -3
  174. package/dist/viewer/figure-preview.d.ts +0 -4
  175. package/dist/viewer/git-diff.d.ts +0 -6
  176. package/dist/viewer/git.d.ts +0 -5
  177. package/dist/viewer/hmr.js +0 -341
  178. package/dist/viewer/serve.d.ts +0 -216
  179. /package/dist/{compiler → engine/compiler}/asset-references.d.ts +0 -0
  180. /package/dist/{compiler → engine/compiler}/asset-references.js +0 -0
  181. /package/dist/{compiler → engine/compiler}/bundle-urls.d.ts +0 -0
  182. /package/dist/{compiler → engine/compiler}/check-types.d.ts +0 -0
  183. /package/dist/{compiler → engine/compiler}/check-types.js +0 -0
  184. /package/dist/{compiler → engine/compiler}/check.d.ts +0 -0
  185. /package/dist/{compiler → engine/compiler}/code-blocks.d.ts +0 -0
  186. /package/dist/{compiler → engine/compiler}/code-languages.d.ts +0 -0
  187. /package/dist/{compiler → engine/compiler}/config.d.ts +0 -0
  188. /package/dist/{compiler → engine/compiler}/drawio.d.ts +0 -0
  189. /package/dist/{compiler → engine/compiler}/drawio.js +0 -0
  190. /package/dist/{compiler → engine/compiler}/dxf.d.ts +0 -0
  191. /package/dist/{compiler → engine/compiler}/export.d.ts +0 -0
  192. /package/dist/{compiler → engine/compiler}/figures.d.ts +0 -0
  193. /package/dist/{compiler → engine/compiler}/files.d.ts +0 -0
  194. /package/dist/{compiler → engine/compiler}/fonts.d.ts +0 -0
  195. /package/dist/{compiler → engine/compiler}/format.d.ts +0 -0
  196. /package/dist/{compiler → engine/compiler}/format.js +0 -0
  197. /package/dist/{compiler → engine/compiler}/from-mdast.d.ts +0 -0
  198. /package/dist/{compiler → engine/compiler}/language-codes.d.ts +0 -0
  199. /package/dist/{compiler → engine/compiler}/language-codes.js +0 -0
  200. /package/dist/{compiler → engine/compiler}/locales.d.ts +0 -0
  201. /package/dist/{compiler → engine/compiler}/public-file.d.ts +0 -0
  202. /package/dist/{compiler → engine/compiler}/public-file.js +0 -0
  203. /package/dist/{compiler → engine/compiler}/subformat-schema.d.ts +0 -0
  204. /package/dist/{compiler → engine/compiler}/terms.d.ts +0 -0
  205. /package/dist/{compiler → engine/compiler}/terms.js +0 -0
  206. /package/dist/{compiler → engine/compiler}/textfile-remote.d.ts +0 -0
  207. /package/dist/{compiler → engine/compiler}/textfile.d.ts +0 -0
  208. /package/dist/{compiler → engine/compiler}/theme-variants.d.ts +0 -0
  209. /package/dist/{compiler → engine/compiler}/zip.d.ts +0 -0
  210. /package/dist/{core → engine/core}/blocks.js +0 -0
  211. /package/dist/{core → engine/core}/code-file.d.ts +0 -0
  212. /package/dist/{core → engine/core}/code-file.js +0 -0
  213. /package/dist/{core → engine/core}/code-grammars.d.ts +0 -0
  214. /package/dist/{core → engine/core}/code-grammars.js +0 -0
  215. /package/dist/{core → engine/core}/content-types.js +0 -0
  216. /package/dist/{core → engine/core}/escape-html.d.ts +0 -0
  217. /package/dist/{core → engine/core}/escape-html.js +0 -0
  218. /package/dist/{core → engine/core}/extension-package.d.ts +0 -0
  219. /package/dist/{core → engine/core}/extension-package.js +0 -0
  220. /package/dist/{core → engine/core}/figure-frame.d.ts +0 -0
  221. /package/dist/{core → engine/core}/figure-frame.js +0 -0
  222. /package/dist/{core → engine/core}/file-embed.d.ts +0 -0
  223. /package/dist/{core → engine/core}/file-embed.js +0 -0
  224. /package/dist/{core → engine/core}/files.d.ts +0 -0
  225. /package/dist/{core → engine/core}/files.js +0 -0
  226. /package/dist/{core → engine/core}/graph-common.d.ts +0 -0
  227. /package/dist/{core → engine/core}/graph-common.js +0 -0
  228. /package/dist/{core → engine/core}/graph.d.ts +0 -0
  229. /package/dist/{core → engine/core}/graph.js +0 -0
  230. /package/dist/{core → engine/core}/inline.d.ts +0 -0
  231. /package/dist/{core → engine/core}/inline.js +0 -0
  232. /package/dist/{core → engine/core}/json-tools.d.ts +0 -0
  233. /package/dist/{core → engine/core}/json-tools.js +0 -0
  234. /package/dist/{core → engine/core}/language.d.ts +0 -0
  235. /package/dist/{core → engine/core}/language.js +0 -0
  236. /package/dist/{core → engine/core}/languages/ja.d.ts +0 -0
  237. /package/dist/{core → engine/core}/languages/ja.js +0 -0
  238. /package/dist/{core → engine/core}/markdown.d.ts +0 -0
  239. /package/dist/{core → engine/core}/markdown.js +0 -0
  240. /package/dist/{core → engine/core}/previewers.d.ts +0 -0
  241. /package/dist/{core → engine/core}/previewers.js +0 -0
  242. /package/dist/{core → engine/core}/schema-comments.d.ts +0 -0
  243. /package/dist/{core → engine/core}/schema-comments.js +0 -0
  244. /package/dist/{core → engine/core}/schema-fields.d.ts +0 -0
  245. /package/dist/{core → engine/core}/schema-fields.js +0 -0
  246. /package/dist/{core → engine/core}/schema-graph.d.ts +0 -0
  247. /package/dist/{core → engine/core}/schema-graph.js +0 -0
  248. /package/dist/{core → engine/core}/subformat-record.d.ts +0 -0
  249. /package/dist/{core → engine/core}/subformat-record.js +0 -0
  250. /package/dist/{core → engine/core}/term-reference.d.ts +0 -0
  251. /package/dist/{core → engine/core}/term-reference.js +0 -0
  252. /package/dist/{core → engine/core}/textfile.d.ts +0 -0
  253. /package/dist/{core → engine/core}/textfile.js +0 -0
  254. /package/dist/{core → engine/core}/theme-variants.d.ts +0 -0
  255. /package/dist/{core → engine/core}/theme-variants.js +0 -0
  256. /package/dist/{core → engine/core}/workspace.d.ts +0 -0
  257. /package/dist/{core → engine/core}/workspace.js +0 -0
  258. /package/dist/{viewer → frontend}/bundle-network.d.ts +0 -0
  259. /package/dist/{viewer → frontend}/bundle-network.js +0 -0
  260. /package/dist/{core → frontend}/flow-base-css.generated.d.ts +0 -0
  261. /package/dist/{core → frontend}/flow-base-css.generated.js +0 -0
  262. /package/dist/{core → frontend}/flow-css.d.ts +0 -0
  263. /package/dist/{core → frontend}/flow-css.js +0 -0
  264. /package/dist/{viewer → frontend}/font-picker.js +0 -0
  265. /package/dist/{viewer → frontend}/font-settings.js +0 -0
  266. /package/dist/{viewer → frontend}/i18n.d.ts +0 -0
  267. /package/dist/{viewer → frontend}/i18n.js +0 -0
  268. /package/dist/{viewer → frontend}/language-picker.d.ts +0 -0
  269. /package/dist/{viewer → frontend}/lazy-preview.d.ts +0 -0
  270. /package/dist/{viewer → frontend}/lazy-preview.js +0 -0
  271. /package/dist/{viewer → frontend}/nav-focus.d.ts +0 -0
  272. /package/dist/{viewer → frontend}/nav-update.d.ts +0 -0
  273. /package/dist/{viewer → frontend}/nav-update.js +0 -0
  274. /package/dist/{viewer → frontend}/plugin-blocks.d.ts +0 -0
  275. /package/dist/{viewer → frontend}/plugin-style.d.ts +0 -0
  276. /package/dist/{viewer → frontend}/plugin-style.js +0 -0
  277. /package/dist/{viewer → frontend}/plugin-view.d.ts +0 -0
  278. /package/dist/{viewer → frontend}/plugin-view.js +0 -0
  279. /package/dist/{viewer → frontend}/resize.d.ts +0 -0
  280. /package/dist/{core → frontend}/schema-graph-mount.d.ts +0 -0
  281. /package/dist/{core → frontend}/schema-graph-mount.js +0 -0
  282. /package/dist/{core → frontend}/table-ui.d.ts +0 -0
  283. /package/dist/{core → frontend}/table-ui.js +0 -0
  284. /package/dist/{core → frontend}/terms-ui.d.ts +0 -0
  285. /package/dist/{core → frontend}/terms-ui.js +0 -0
  286. /package/dist/{viewer → frontend}/theme-picker.d.ts +0 -0
  287. /package/dist/{viewer → frontend}/theme-picker.js +0 -0
  288. /package/dist/{core → frontend}/toc-ui.d.ts +0 -0
  289. /package/dist/{core → frontend}/toc-ui.js +0 -0
  290. /package/dist/{core → frontend}/video-ui.d.ts +0 -0
  291. /package/dist/{core → frontend}/video-ui.js +0 -0
  292. /package/dist/{viewer → server}/build-plugins.d.ts +0 -0
  293. /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
  294. /package/dist/{viewer → server}/extension-pack.d.ts +0 -0
  295. /package/dist/{viewer → server}/fonts/LICENSE.txt +0 -0
  296. /package/dist/{viewer → server}/fonts/udev-gothic-regular.woff2 +0 -0
  297. /package/dist/{viewer → server}/fonts.d.ts +0 -0
  298. /package/dist/{viewer → server}/fonts.js +0 -0
  299. /package/dist/{viewer → server}/ja-lint.js +0 -0
  300. /package/dist/{viewer → workspace}/git-types.js +0 -0
  301. /package/dist/{viewer → workspace}/site-icon.d.ts +0 -0
  302. /package/dist/{viewer → workspace}/site-title.d.ts +0 -0
@@ -1,2 +1,4 @@
1
1
  export declare const prebuilt: boolean;
2
+ export declare const standalone = false;
3
+ export declare const readInstaller: () => Buffer;
2
4
  export declare const readViewerAsset: (name: string) => Buffer;
@@ -0,0 +1,7 @@
1
+ import { readFileSync } from "node:fs";
2
+ export const prebuilt = import.meta.url.endsWith(".js");
3
+ export const standalone = false;
4
+ export const readInstaller = () => readFileSync(new URL(prebuilt ? "../install.sh" : "../../../scripts/release/install.sh", import.meta.url));
5
+ export const readViewerAsset = (name) => readFileSync(new URL(name.startsWith("fonts/")
6
+ ? `./${name}`
7
+ : `${prebuilt ? ".." : "../../../dist"}/${name}`, import.meta.url));
@@ -1,9 +1,9 @@
1
- import { createLocalPluginStorage } from "../plugins/local-storage.js";
2
- import { createPluginRuntime } from "../plugins/runtime.js";
1
+ import { PLUGIN_BLOCK_CSS } from "../frontend/plugin-style.js";
2
+ import { pluginViewHtml } from "../frontend/plugin-view.js";
3
3
  import { createExtensionManager } from "./extensions.js";
4
4
  import { loadViewerPlugins } from "./plugin-config.js";
5
- import { PLUGIN_BLOCK_CSS } from "./plugin-style.js";
6
- import { pluginViewHtml } from "./plugin-view.js";
5
+ import { createLocalPluginStorage } from "./plugins/local-storage.js";
6
+ import { createPluginRuntime } from "./plugins/runtime.js";
7
7
  /** Only previously enabled packages execute; personal credentials never enter the artifact. */
8
8
  export const loadBuildPlugins = async (root, module) => {
9
9
  const initial = await loadViewerPlugins(module);
@@ -1,5 +1,5 @@
1
- import { type PreviewSettings } from "../core/previewers.js";
2
1
  import type { PluginTransport } from "../plugins/transport.js";
2
+ import { type PreviewSettings } from "../engine/core/previewers.js";
3
3
  export interface BuildOptions {
4
4
  format: "html" | "zip";
5
5
  urlPreview?: "embed" | "network";
@@ -7,6 +7,7 @@ export interface BuildOptions {
7
7
  auth?: "external";
8
8
  /** Public directory URL corresponding to the manifest directory, embedded in HTML. */
9
9
  sourceUrl?: string;
10
+ easyDownload?: boolean;
10
11
  /** Trusted server module used for static snapshots, never serialized into HTML. */
11
12
  pluginModule?: string;
12
13
  /** Build-time authenticated reads; live HTML receives its transport at runtime. */
@@ -1,15 +1,17 @@
1
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
1
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import { dirname, join } from "node:path";
4
- import { embedBundleUrls } from "../compiler/bundle-urls.js";
5
- import { compileSite } from "../compiler/compile.js";
6
- import { exportEntries } from "../compiler/export.js";
7
- import { loadProjectFonts } from "../compiler/fonts.js";
8
- import { textfilePath } from "../compiler/textfile.js";
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";
4
+ import { embedBundleUrls } from "../engine/compiler/bundle-urls.js";
5
+ import { compileSite } from "../engine/compiler/compile.js";
6
+ import { exportEntries } from "../engine/compiler/export.js";
7
+ import { filesSnapshot } from "../engine/compiler/files.js";
8
+ import { loadProjectFonts } from "../engine/compiler/fonts.js";
9
+ import { manifestFile, projectRoot } from "../engine/compiler/manifest.js";
10
+ import { textfilePath } from "../engine/compiler/textfile.js";
11
+ import { zip } from "../engine/compiler/zip.js";
12
+ import { walkBlocks } from "../engine/core/blocks.js";
13
+ import { selectCodeGrammars } from "../engine/core/code-grammars.js";
14
+ import { parsePreviewSettings } from "../engine/core/previewers.js";
13
15
  import { loadBuildPlugins, pluginSnapshot } from "./build-plugins.js";
14
16
  import { loadSiteLanguages } from "./languages.js";
15
17
  import { loadViewerPlugins } from "./plugin-config.js";
@@ -17,6 +19,10 @@ import { sourceFileBase } from "./workspace.js";
17
19
  /** Build one artifact from the manifest and its managed content. */
18
20
  export const buildBundle = async (root, options) => {
19
21
  const { format } = options;
22
+ if (options.easyDownload !== undefined && typeof options.easyDownload !== "boolean")
23
+ throw new Error("Easy download must be a boolean");
24
+ if (options.easyDownload !== undefined && format !== "html")
25
+ throw new Error("Easy download applies to HTML builds only");
20
26
  if (options.sourceUrl !== undefined && format !== "html")
21
27
  throw new Error("Source URL applies to HTML builds only");
22
28
  const sourceBase = format === "html" ? sourceFileBase(root, options.sourceUrl) : undefined;
@@ -46,6 +52,9 @@ export const buildBundle = async (root, options) => {
46
52
  return compiled;
47
53
  };
48
54
  let entries = exportEntries(root);
55
+ const downloadSources = options.easyDownload
56
+ ? new Map(entries.map(({ name, data }) => [name, data]))
57
+ : undefined;
49
58
  let compiled = validate(root);
50
59
  if (urlPreview === "embed") {
51
60
  const plugins = format === "html" && !options.pluginTransport
@@ -65,7 +74,7 @@ export const buildBundle = async (root, options) => {
65
74
  mkdirSync(dirname(path), { recursive: true });
66
75
  writeFileSync(path, entry.data);
67
76
  }
68
- compiled = validate(temp);
77
+ compiled = validate(projectRoot(join(temp, manifestFile(root))));
69
78
  }
70
79
  finally {
71
80
  rmSync(temp, { recursive: true, force: true });
@@ -75,21 +84,28 @@ export const buildBundle = async (root, options) => {
75
84
  return { data: zip(entries), docs: compiled.docs.length };
76
85
  const config = await loadSiteLanguages(root);
77
86
  const { bundleClient, publishHtml, siteFrom } = await import("./serve.js");
87
+ const linkable = new Set(filesSnapshot(root).files.map((file) => file.path));
78
88
  const site = {
79
89
  ...siteFrom(compiled, config.languages, config),
80
90
  sourceBase,
81
91
  fonts: loadProjectFonts(root),
92
+ readLinkedFile: (file) => linkable.has(file) ? readFileSync(textfilePath(root, file)) : undefined,
82
93
  };
94
+ if (options.easyDownload)
95
+ site.ctx.downloads = new Map(entries.map(({ name, data }) => [
96
+ name,
97
+ `data:application/octet-stream;base64,${(downloadSources?.get(name) ?? data).toString("base64")}`,
98
+ ]));
83
99
  const blocks = walkBlocks(site.entries.flatMap((entry) => entry.blocks));
84
100
  const code = blocks.flatMap((block) => block.type === "code" && block.lang !== "mermaid" && !block.unavailable ? [block] : []);
85
101
  site.codeGrammars = selectCodeGrammars(site.codeGrammars ?? [], code.map((block) => block.lang ?? "text"));
86
102
  const diagrams = blocks.some((block) => block.type === "schemaGraph" ||
87
103
  (block.type === "code" && block.lang === "mermaid" && !block.unavailable));
88
104
  return {
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)
92
- ? await bundleClient("viewer/published-subformats.ts")
105
+ data: publishHtml(site, diagrams ? await bundleClient("schema-graph-global.tsx") : "", undefined, code.length ? await bundleClient("code-highlight.ts") : "", options.mode === "live" ? "live" : urlPreview === "embed" ? "static" : "network", options.mode === "live" && blocks.some((block) => block.type === "external")
106
+ ? await bundleClient("published-plugins.ts")
107
+ : "", compiled.docs.some((doc) => doc.subformat || doc.library)
108
+ ? await bundleClient("published-subformats.ts")
93
109
  : ""),
94
110
  docs: compiled.docs.length,
95
111
  };
@@ -3,42 +3,56 @@
3
3
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
  import { basename, dirname, join, resolve } from "node:path";
5
5
  import { parseArgs } from "node:util";
6
- import { projectRoot } from "./compiler/manifest.js";
7
- import { MANIFEST_FILE, serializeManifest } from "./core/content-metadata.js";
8
- import { prebuilt } from "./viewer/assets.js";
6
+ import { projectRoot } from "../engine/compiler/manifest.js";
7
+ import { isManifestFile, MANIFEST_FILE, serializeManifest, } from "../engine/core/content-metadata.js";
8
+ import { prebuilt } from "./assets.js";
9
9
  process.env.NODE_ENV = prebuilt ? "production" : "development";
10
10
  const USAGE = `usage: dooc <command>
11
11
 
12
12
  commands:
13
- ├─ init create dooc.yaml in the current directory
14
- ├─ edit [dooc.yaml] [port] open dooc in edit mode
15
- │ └─ --viewer-plugins <module> inject an external viewer plugin module
16
- ├─ view [dooc.yaml] [port] open dooc in view mode
17
- │ └─ --viewer-plugins <module> inject an external viewer plugin module
18
- ├─ build build the selected bundle (default <project>/dist)
19
- │ ├─ html [dooc.yaml] [out-dir] build bundle.html
20
- │ │ ├─ --mode static|live HTML snapshot or runtime plugin API
21
- │ │ ├─ --auth external host supplies live HTML authentication and transport
22
- │ │ └─ --source-url <url> source directory URL for card copy links
23
- │ ├─ zip [dooc.yaml] [out-dir] build bundle.zip
24
- │ ├─ --url_preview embed|network URL handling for either format (default: embed)
25
- │ └─ --viewer-plugins <module> inject an external build plugin module
26
- ├─ export [dooc.yaml] [out-dir] collect source dependencies into bundle.zip
27
- ├─ check [dooc.yaml] [options] JSON consistency report (check --help for options)
28
- ├─ plugin manage local plugins
29
- │ ├─ pack <built-dir> [zip] package bundled JS and assets as a plugin ZIP
30
- │ ├─ add <zip> [dooc.yaml] [port] install a local plugin and print login links
31
- │ └─ login <id> [dooc.yaml] [port] open a local login flow for an installed plugin
32
- ├─ font manage project fonts (.dooc/fonts/)
33
- │ ├─ add <file> [dooc.yaml] register a font in the project
34
- │ ├─ list [dooc.yaml] list registered project fonts
35
- │ └─ remove <name> [dooc.yaml] remove a registered project font
36
- ├─ mcp [dooc.yaml] stdio MCP server (all read / write operations)
37
- │ └─ --git-origin <module> inject gitOrigin from an external viewer plugin module
38
- └─ help, --help, -h show this help
13
+ init [path] create a manifest in a directory or at a manifest path
14
+ edit [dooc.yaml] [port] open dooc in edit mode
15
+ --viewer-plugins <module> inject an external viewer plugin module
16
+ --shared <branch> several people edit; snapshots are recorded on <branch>
17
+ --tls-cert <pem> --tls-key <pem> serve over HTTPS (or DOOC_TLS_CERT / DOOC_TLS_KEY)
18
+ server [dooc.yaml] [port] serve the workspace socket only (default: 5179)
19
+ --client-origin <origin> permit the static client origin (default: http://localhost:5180)
20
+ client [port] serve the static client only (default: 5180)
21
+ --server <ws-url> connect to an optional workspace server
22
+ view [dooc.yaml] [port] open dooc in view mode
23
+ --viewer-plugins <module> inject an external viewer plugin module
24
+ --tls-cert <pem> --tls-key <pem> serve over HTTPS (or DOOC_TLS_CERT / DOOC_TLS_KEY)
25
+ build build the selected bundle (default <project>/dist)
26
+ html [dooc.yaml] [out-dir] build bundle.html
27
+ --mode static|live HTML snapshot or runtime plugin API
28
+ --auth external host supplies live HTML authentication and transport
29
+ --source-url <url> source directory URL for card copy links
30
+ --easy-download enable resource downloads in HTML
31
+ client [out-dir] build the standalone static editor
32
+ --server <ws-url> preconfigure an optional workspace socket
33
+ zip [dooc.yaml] [out-dir] build bundle.zip
34
+ --url_preview embed|network URL handling for either format (default: embed)
35
+ --viewer-plugins <module> inject an external build plugin module
36
+ export [dooc.yaml] [out-dir] collect source dependencies into bundle.zip
37
+ check [dooc.yaml] [options] JSON consistency report (check --help for options)
38
+ plugin manage local plugins
39
+ pack <built-dir> [zip] package bundled JS and assets as a plugin ZIP
40
+ add <zip> [dooc.yaml] [port] install a local plugin and print login links
41
+ login <id> [dooc.yaml] [port] open a local login flow for an installed plugin
42
+ font manage project fonts (.dooc/fonts/)
43
+ add <file> [dooc.yaml] register a font in the project
44
+ list [dooc.yaml] list registered project fonts
45
+ remove <name> [dooc.yaml] remove a registered project font
46
+ self manage this dooc installation
47
+ update update dooc to the latest release
48
+ docs download GitHub docs and open the local viewer
49
+ mcp [dooc.yaml] stdio MCP server (all read / write operations)
50
+ --git-origin <module> inject gitOrigin from an external viewer plugin module
51
+ help, --help, -h show this help
39
52
 
40
- Details: dooc <command> --help (init, build, check, plugin, font, mcp).
41
- Default manifest: ./dooc.yaml. Paths and .dooc/ are relative to its directory.`;
53
+ Details: dooc <command> --help (init, build, check, plugin, font, self, mcp).
54
+ Default manifest: ./dooc.yaml. Named manifests (<name>.dooc.yaml) are also accepted.
55
+ Paths and .dooc/ are relative to the selected manifest's directory.`;
42
56
  const fail = (message) => {
43
57
  console.error(message);
44
58
  process.exit(1);
@@ -49,7 +63,52 @@ const writeOut = (out, data) => {
49
63
  };
50
64
  const [command, ...args] = process.argv.slice(2);
51
65
  switch (command) {
66
+ case "self": {
67
+ try {
68
+ const { positionals, values } = parseArgs({
69
+ args,
70
+ allowPositionals: true,
71
+ options: { help: { type: "boolean", short: "h" } },
72
+ });
73
+ if (values.help) {
74
+ console.log(`usage: dooc self <command>
75
+
76
+ commands:
77
+ update update a standalone executable or global npm installation to the latest release
78
+ docs download documentation from GitHub and open the local read-only viewer
79
+
80
+ Homebrew and mise installations must be updated through their package manager.
81
+ Documentation requires a network connection. Keep this command running while using the viewer.
82
+
83
+ options:
84
+ --help, -h show this help`);
85
+ break;
86
+ }
87
+ if (positionals.length !== 1 || !["update", "docs"].includes(positionals[0] ?? ""))
88
+ throw new Error("Expected: dooc self update or dooc self docs");
89
+ const { prepareSelfDocs, selfUpdate } = await import("./self.js");
90
+ if (positionals[0] === "update") {
91
+ selfUpdate();
92
+ }
93
+ else {
94
+ console.log("Downloading documentation from GitHub...");
95
+ const { root, dispose } = await prepareSelfDocs();
96
+ process.once("exit", dispose);
97
+ process.once("SIGINT", () => process.exit(130));
98
+ process.once("SIGTERM", () => process.exit(143));
99
+ process.env.DOCS_ROOT = root;
100
+ process.env.DOCS_HMR = "0";
101
+ const { startServer } = await import("./serve.js");
102
+ await startServer("preview", 5179, undefined, { open: true });
103
+ }
104
+ }
105
+ catch (error) {
106
+ fail(error instanceof Error ? error.message : String(error));
107
+ }
108
+ break;
109
+ }
52
110
  case "init": {
111
+ let file = resolve(MANIFEST_FILE);
53
112
  try {
54
113
  const { positionals, values } = parseArgs({
55
114
  args,
@@ -57,24 +116,27 @@ switch (command) {
57
116
  options: { help: { type: "boolean", short: "h" } },
58
117
  });
59
118
  if (values.help) {
60
- console.log(`usage: dooc init
119
+ console.log(`usage: dooc init [path]
61
120
 
62
- Create dooc.yaml in the current directory. Existing files are never overwritten.
63
- Run dooc edit to add your first document.
121
+ Create dooc.yaml in the selected directory (default: current directory), or specify
122
+ a dooc.yaml / <name>.dooc.yaml file path. Missing directories are created.
123
+ Existing files are never overwritten. Run dooc edit <manifest-path> to add your first document.
64
124
 
65
125
  options:
66
126
  --help, -h show this help`);
67
127
  break;
68
128
  }
69
- if (positionals.length)
70
- throw new Error("init does not accept positional arguments");
71
- const file = resolve(MANIFEST_FILE);
129
+ if (positionals.length > 1)
130
+ throw new Error("init accepts at most one path");
131
+ const target = resolve(positionals[0] ?? ".");
132
+ file = isManifestFile(basename(target)) ? target : join(target, MANIFEST_FILE);
133
+ mkdirSync(dirname(file), { recursive: true });
72
134
  writeFileSync(file, serializeManifest([], { format: "nested" }), { flag: "wx" });
73
- console.log(`Created ${file}\nRun dooc edit to add your first document.`);
135
+ console.log(`Created ${file}\nRun dooc edit '${file.replaceAll("'", "'\\''")}' to add your first document.`);
74
136
  }
75
137
  catch (error) {
76
138
  fail(error instanceof Error && "code" in error && error.code === "EEXIST"
77
- ? `${MANIFEST_FILE} already exists; nothing was overwritten.`
139
+ ? `${file} already exists; nothing was overwritten.`
78
140
  : error instanceof Error
79
141
  ? error.message
80
142
  : String(error));
@@ -93,9 +155,9 @@ options:
93
155
  console.log(`usage: dooc plugin <command>
94
156
 
95
157
  commands:
96
- ├─ pack <built-dir> [output.zip] package bundled JS and assets as a plugin ZIP
97
- ├─ add <zip> [dooc.yaml] [port] install a local plugin and print login links
98
- └─ login <plugin-id> [dooc.yaml] [port] open a local login flow for an installed plugin
158
+ pack <built-dir> [output.zip] package bundled JS and assets as a plugin ZIP
159
+ add <zip> [dooc.yaml] [port] install a local plugin and print login links
160
+ login <plugin-id> [dooc.yaml] [port] open a local login flow for an installed plugin
99
161
 
100
162
  options:
101
163
  --help, -h show this help
@@ -114,8 +176,8 @@ Storage and login:
114
176
  break;
115
177
  }
116
178
  if (action === "pack" && value && positionals.length <= 3) {
117
- const { packExtension } = await import("./viewer/extension-pack.js");
118
- const { extensionFile } = await import("./core/extension-package.js");
179
+ const { packExtension } = await import("./extension-pack.js");
180
+ const { extensionFile } = await import("../engine/core/extension-package.js");
119
181
  const output = resolve(rootArg ?? `${resolve(value)}.zip`);
120
182
  extensionFile(basename(output));
121
183
  writeOut(output, await packExtension(resolve(value), output));
@@ -124,13 +186,13 @@ Storage and login:
124
186
  else if ((action === "add" || action === "login") &&
125
187
  value &&
126
188
  positionals.length <= 4) {
127
- const { extensionFile, MAX_EXTENSION_BYTES } = await import("./core/extension-package.js");
189
+ const { extensionFile, MAX_EXTENSION_BYTES } = await import("../engine/core/extension-package.js");
128
190
  const port = Number(portArg ?? 5179);
129
191
  if (!Number.isInteger(port) || port < 1024 || port > 65535)
130
192
  throw new Error("Choose a local port between 1024 and 65535");
131
193
  process.env.DOCS_ROOT = projectRoot(rootArg);
132
194
  process.env.DOCS_HMR = "1";
133
- const { startServer } = await import("./viewer/serve.js");
195
+ const { startServer } = await import("./serve.js");
134
196
  if (action === "add") {
135
197
  const file = extensionFile(basename(value));
136
198
  const data = readFileSync(resolve(value));
@@ -156,7 +218,7 @@ Storage and login:
156
218
  break;
157
219
  }
158
220
  case "font": {
159
- const { addProjectFont, listProjectFonts, removeProjectFont } = await import("./compiler/fonts.js");
221
+ const { addProjectFont, listProjectFonts, removeProjectFont } = await import("../engine/compiler/fonts.js");
160
222
  try {
161
223
  const { positionals, values } = parseArgs({
162
224
  args,
@@ -167,9 +229,9 @@ Storage and login:
167
229
  console.log(`usage: dooc font <command>
168
230
 
169
231
  commands:
170
- ├─ add <file> [dooc.yaml] register a font in the project
171
- ├─ list [dooc.yaml] list registered project fonts
172
- └─ remove <name> [dooc.yaml] remove a registered project font
232
+ add <file> [dooc.yaml] register a font in the project
233
+ list [dooc.yaml] list registered project fonts
234
+ remove <name> [dooc.yaml] remove a registered project font
173
235
 
174
236
  options:
175
237
  --help, -h show this help
@@ -200,7 +262,7 @@ Fonts:
200
262
  break;
201
263
  }
202
264
  case "check": {
203
- const { checkSite } = await import("./compiler/check.js");
265
+ const { checkSite } = await import("../engine/compiler/check.js");
204
266
  let report;
205
267
  try {
206
268
  const { positionals, values } = parseArgs({
@@ -279,19 +341,75 @@ Report:
279
341
  process.exitCode = report.exitCode;
280
342
  break;
281
343
  }
344
+ case "server":
345
+ case "client": {
346
+ try {
347
+ const { positionals, values } = parseArgs({
348
+ args,
349
+ allowPositionals: true,
350
+ options: {
351
+ "client-origin": { type: "string" },
352
+ server: { type: "string" },
353
+ "viewer-plugins": { type: "string" },
354
+ help: { type: "boolean", short: "h" },
355
+ },
356
+ });
357
+ if (values.help) {
358
+ console.log(command === "server"
359
+ ? "usage: dooc server [dooc.yaml] [port] [--client-origin http://localhost:5180] [--viewer-plugins module]\nServes /api/workspace over WebSocket on loopback. No frontend assets."
360
+ : "usage: dooc client [port] [--server ws://localhost:5179/api/workspace]\nServes static assets only. Open local storage or connect to an optional workspace server.");
361
+ break;
362
+ }
363
+ if (positionals.length > (command === "server" ? 2 : 1))
364
+ throw new Error("Too many positional arguments");
365
+ const port = Number(positionals[command === "server" ? 1 : 0] ?? (command === "server" ? 5179 : 5180));
366
+ if (!Number.isInteger(port) || port < 1024 || port > 65535)
367
+ throw new Error("Choose a port between 1024 and 65535");
368
+ if (command === "server") {
369
+ const { startWorkspaceServer } = await import("./workspace-server.js");
370
+ await startWorkspaceServer(positionals[0] ?? "dooc.yaml", port, values["client-origin"], values["viewer-plugins"]);
371
+ }
372
+ else {
373
+ const { startStaticClient } = await import("./static-client.js");
374
+ await startStaticClient(port, values.server);
375
+ }
376
+ }
377
+ catch (error) {
378
+ fail(error instanceof Error ? error.message : String(error));
379
+ }
380
+ break;
381
+ }
282
382
  case "view":
283
383
  case "edit": {
284
384
  try {
285
385
  const { positionals, values } = parseArgs({
286
386
  args,
287
387
  allowPositionals: true,
288
- options: { "viewer-plugins": { type: "string" } },
388
+ options: {
389
+ "viewer-plugins": { type: "string" },
390
+ "tls-cert": { type: "string" },
391
+ "tls-key": { type: "string" },
392
+ shared: { type: "string" },
393
+ },
289
394
  });
395
+ const cert = values["tls-cert"] ?? process.env.DOOC_TLS_CERT;
396
+ const key = values["tls-key"] ?? process.env.DOOC_TLS_KEY;
397
+ if (!cert !== !key)
398
+ throw new Error("--tls-cert and --tls-key must be given together");
290
399
  process.env.DOCS_ROOT = projectRoot(positionals[0]);
291
400
  process.env.DOCS_HMR = "1";
292
401
  // serve.ts reads DOCS_ROOT at import time, so import it after the env is set.
293
- const { startServer } = await import("./viewer/serve.js");
294
- await startServer(command === "view" ? "preview" : "edit", Number(positionals[1] ?? 5179), values["viewer-plugins"] ?? process.env.DOOC_VIEWER_PLUGINS);
402
+ const { startServer } = await import("./serve.js");
403
+ await startServer(command === "view" ? "preview" : "edit", Number(positionals[1] ?? 5179), values["viewer-plugins"] ?? process.env.DOOC_VIEWER_PLUGINS, ...((cert && key) || values.shared !== undefined
404
+ ? [
405
+ {
406
+ ...(cert && key
407
+ ? { tls: { cert: resolve(cert), key: resolve(key) } }
408
+ : {}),
409
+ ...(values.shared === undefined ? {} : { shared: values.shared }),
410
+ },
411
+ ]
412
+ : []));
295
413
  }
296
414
  catch (error) {
297
415
  fail(error instanceof Error ? error.message : String(error));
@@ -304,7 +422,7 @@ Report:
304
422
  throw new Error("export accepts a dooc.yaml path and an output directory");
305
423
  const root = projectRoot(args[0]);
306
424
  const out = join(resolve(args[1] ?? join(root, "dist")), "bundle.zip");
307
- const { exportBundle } = await import("./compiler/export.js");
425
+ const { exportBundle } = await import("../engine/compiler/export.js");
308
426
  writeOut(out, exportBundle(root));
309
427
  console.log(out);
310
428
  }
@@ -319,24 +437,29 @@ Report:
319
437
  args,
320
438
  allowPositionals: true,
321
439
  options: {
440
+ server: { type: "string" },
322
441
  url_preview: { type: "string" },
323
442
  mode: { type: "string" },
324
443
  auth: { type: "string" },
325
444
  "viewer-plugins": { type: "string" },
326
445
  "source-url": { type: "string" },
446
+ "easy-download": { type: "boolean" },
327
447
  help: { type: "boolean", short: "h" },
328
448
  },
329
449
  });
330
450
  if (values.help) {
331
- console.log(`usage: dooc build <html|zip> [dooc.yaml] [out-dir] [options]
451
+ console.log(`usage: dooc build <html|zip|client> [dooc.yaml] [out-dir] [options]
332
452
 
333
453
  commands:
334
- ├─ html [dooc.yaml] [out-dir] build bundle.html
335
- │ ├─ --mode static|live HTML snapshot or runtime plugin API
336
- │ ├─ --auth external host supplies live HTML authentication and transport
337
- │ └─ --source-url <url> HTTP(S) directory URL for card copy links
338
- │ paths are relative to dooc.yaml; overrides GitHub origin/HEAD
339
- └─ zip [dooc.yaml] [out-dir] build bundle.zip
454
+ html [dooc.yaml] [out-dir] build bundle.html
455
+ --mode static|live HTML snapshot or runtime plugin API
456
+ --auth external host supplies live HTML authentication and transport
457
+ --source-url <url> HTTP(S) directory URL for card copy links
458
+ paths are relative to dooc.yaml; overrides GitHub origin/HEAD
459
+ --easy-download enable resource downloads (default: off)
460
+ client [out-dir] build a standalone static editor (default: ./dooc-client)
461
+ --server <ws-url> optional workspace socket
462
+ zip [dooc.yaml] [out-dir] build bundle.zip
340
463
 
341
464
  options (html and zip):
342
465
  --url_preview embed|network URL handling (default: embed; live HTML: network)
@@ -370,8 +493,17 @@ URL handling:
370
493
  break;
371
494
  }
372
495
  const [format, rootArg, outArg] = positionals;
496
+ if (format === "client") {
497
+ if (positionals.length > 2)
498
+ throw new Error("build client accepts one output directory");
499
+ const { buildStaticClient } = await import("./static-client.js");
500
+ const out = resolve(rootArg ?? "dooc-client");
501
+ await buildStaticClient(out, values.server);
502
+ console.log(`${out} — static client (serve index.html for document routes)`);
503
+ break;
504
+ }
373
505
  if (format !== "html" && format !== "zip")
374
- throw new Error("build format must be html | zip");
506
+ throw new Error("build format must be html | zip | client");
375
507
  if (positionals.length > 3)
376
508
  throw new Error(`build ${format} accepts a dooc.yaml path and an output directory`);
377
509
  const urlPreview = values.url_preview ?? (values.mode === "live" ? "network" : "embed");
@@ -379,7 +511,7 @@ URL handling:
379
511
  throw new Error("--url_preview must be embed | network");
380
512
  const root = projectRoot(rootArg);
381
513
  const out = join(resolve(outArg ?? join(root, "dist")), `bundle.${format}`);
382
- const { buildBundle } = await import("./viewer/build.js");
514
+ const { buildBundle } = await import("./build.js");
383
515
  const bundle = await buildBundle(root, {
384
516
  format,
385
517
  urlPreview,
@@ -387,6 +519,7 @@ URL handling:
387
519
  auth: values.auth,
388
520
  pluginModule: values["viewer-plugins"],
389
521
  sourceUrl: values["source-url"],
522
+ easyDownload: values["easy-download"],
390
523
  });
391
524
  writeOut(out, bundle.data);
392
525
  console.log(`${out} — ${bundle.docs} docs (url_preview=${urlPreview})`);
@@ -414,7 +547,7 @@ options:
414
547
  --help, -h show this help
415
548
 
416
549
  Server:
417
- Exposes docs, files, Statics, fonts, check, build and Git over stdio.
550
+ Exposes docs, files, Library, fonts, check, build and Git over stdio.
418
551
  Build accepts format=html|zip and url_preview=embed|network (default embed).
419
552
 
420
553
  Git origin:
@@ -426,7 +559,7 @@ Git origin:
426
559
  if (positionals.length > 1)
427
560
  throw new Error("mcp accepts at most one dooc.yaml path");
428
561
  const { startMcp } = await import("./mcp.js");
429
- const { loadViewerPlugins } = await import("./viewer/plugin-config.js");
562
+ const { loadViewerPlugins } = await import("./plugin-config.js");
430
563
  const { gitOrigin } = await loadViewerPlugins(values["git-origin"]);
431
564
  if (values["git-origin"] && !gitOrigin)
432
565
  throw new Error("Module must provide gitOrigin");
@@ -0,0 +1 @@
1
+ export * from "../workspace/editor-tools.js";
@@ -0,0 +1 @@
1
+ export * from "../workspace/editor-tools.js";
@@ -1,8 +1,8 @@
1
1
  import { lstatSync, readdirSync, readFileSync } from "node:fs";
2
2
  import { join, resolve } from "node:path";
3
3
  import { inflateRawSync } from "node:zlib";
4
- import { zip } from "../compiler/zip.js";
5
- import { MAX_EXTENSION_BYTES, MAX_EXTENSION_FILES, readExtensionZip, } from "../core/extension-package.js";
4
+ import { zip } from "../engine/compiler/zip.js";
5
+ import { MAX_EXTENSION_BYTES, MAX_EXTENSION_FILES, readExtensionZip, } from "../engine/core/extension-package.js";
6
6
  /** Package an already bundled module and its relative assets without running build scripts. */
7
7
  export const packExtension = async (root, output) => {
8
8
  const entries = [];
@@ -1,5 +1,5 @@
1
- import type { LocalPluginStorage } from "../plugins/local-storage.js";
2
1
  import { type ViewerPluginRegistry, type ViewerPlugins } from "./plugin-config.js";
2
+ import type { LocalPluginStorage } from "./plugins/local-storage.js";
3
3
  export declare const EXTENSIONS_DIR = ".dooc/plugins";
4
4
  /** ZIPs found on disk stay inactive until the browser approves their exact content hash. */
5
5
  export declare const createExtensionManager: (root: string, registry: ViewerPluginRegistry & {
@@ -4,9 +4,9 @@ import { tmpdir } from "node:os";
4
4
  import { dirname, join } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { inflateRawSync } from "node:zlib";
7
- import { textfilePath } from "../compiler/textfile.js";
8
- import { zip } from "../compiler/zip.js";
9
- import { extensionFile, extensionManifest, MAX_EXTENSION_BYTES, readExtensionZip, } from "../core/extension-package.js";
7
+ import { textfilePath } from "../engine/compiler/textfile.js";
8
+ import { zip } from "../engine/compiler/zip.js";
9
+ import { extensionFile, extensionManifest, MAX_EXTENSION_BYTES, readExtensionZip, } from "../engine/core/extension-package.js";
10
10
  import { validateViewerPlugins, } from "./plugin-config.js";
11
11
  export const EXTENSIONS_DIR = ".dooc/plugins";
12
12
  const hash = (source) => createHash("sha256").update(source).digest("hex");
@@ -0,0 +1,10 @@
1
+ import type { SubformatCollection } from "../engine/core/subformats.js";
2
+ /**
3
+ * `revision` identifies the working tree contents (filesSnapshot); with it the status is reused
4
+ * until the files, the index or HEAD change.
5
+ */
6
+ export declare const gitFileChanges: (root: string, revision?: string) => Map<string, "added" | "modified">;
7
+ /** Compare against HEAD so saving or staging does not clear the editor's changes. */
8
+ export declare const gitBaseText: (root: string, file: string) => string | null;
9
+ export declare const gitBaseBody: (root: string, file: string) => string | null;
10
+ export declare const setSubformatChanges: (root: string, collections: SubformatCollection[], revision?: string) => void;