@dooc-dev/dooc 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +16 -18
- package/dist/client.global.js +1 -0
- package/dist/code-worker.global.js +11 -11
- package/dist/code.global.js +75 -75
- package/dist/edit.global.js +234 -231
- package/dist/{compiler → engine/compiler}/bundle-urls.js +1 -4
- package/dist/{compiler → engine/compiler}/check-prose.d.ts +1 -1
- package/dist/{compiler → engine/compiler}/check-prose.js +1 -1
- package/dist/{compiler → engine/compiler}/check.js +15 -27
- package/dist/{compiler → engine/compiler}/code-blocks.js +3 -1
- package/dist/{compiler → engine/compiler}/code-languages.js +1 -2
- package/dist/{compiler → engine/compiler}/compile.d.ts +5 -4
- package/dist/{compiler → engine/compiler}/compile.js +91 -32
- package/dist/{compiler → engine/compiler}/config.js +1 -3
- package/dist/{compiler → engine/compiler}/dialect.d.ts +1 -3
- package/dist/{compiler → engine/compiler}/dialect.js +8 -52
- package/dist/{compiler → engine/compiler}/dxf.js +1 -1
- package/dist/{compiler → engine/compiler}/export.js +15 -8
- package/dist/{compiler → engine/compiler}/figures.js +26 -22
- package/dist/{compiler → engine/compiler}/file-cache.d.ts +1 -2
- package/dist/{compiler → engine/compiler}/file-cache.js +8 -15
- package/dist/{compiler → engine/compiler}/files.js +49 -38
- package/dist/{compiler → engine/compiler}/fonts.js +1 -3
- package/dist/{compiler → engine/compiler}/from-mdast.js +1 -1
- package/dist/engine/compiler/host.d.ts +10 -0
- package/dist/engine/compiler/host.js +16 -0
- package/dist/{compiler → engine/compiler}/icons.d.ts +3 -0
- package/dist/{compiler → engine/compiler}/icons.js +28 -10
- package/dist/{compiler → engine/compiler}/ignored-files.d.ts +2 -0
- package/dist/{compiler → engine/compiler}/ignored-files.js +12 -3
- package/dist/{compiler → engine/compiler}/locales.js +2 -8
- package/dist/{compiler → engine/compiler}/manifest.d.ts +3 -2
- package/dist/engine/compiler/manifest.js +46 -0
- package/dist/{compiler → engine/compiler}/ops.d.ts +4 -1
- package/dist/{compiler → engine/compiler}/ops.js +36 -21
- package/dist/engine/compiler/schema-file-references.d.ts +2 -0
- package/dist/engine/compiler/schema-file-references.js +82 -0
- package/dist/engine/compiler/serialize.d.ts +2 -0
- package/dist/engine/compiler/serialize.js +5 -0
- package/dist/{compiler → engine/compiler}/subformat-schema.js +1 -3
- package/dist/{compiler → engine/compiler}/subformats.d.ts +10 -0
- package/dist/{compiler → engine/compiler}/subformats.js +122 -18
- package/dist/{compiler → engine/compiler}/textfile-remote.js +1 -2
- package/dist/{compiler → engine/compiler}/textfile.js +4 -6
- package/dist/{compiler → engine/compiler}/theme-variants.js +1 -1
- package/dist/{compiler → engine/compiler}/zip.js +1 -1
- package/dist/{core → engine/core}/blocks.d.ts +6 -4
- package/dist/{core → engine/core}/content-metadata.d.ts +6 -1
- package/dist/{core → engine/core}/content-metadata.js +84 -18
- package/dist/{core → engine/core}/content-types.d.ts +4 -2
- package/dist/{core → engine/core}/html.d.ts +7 -0
- package/dist/{core → engine/core}/html.js +44 -3
- package/dist/{core → engine/core}/icons.d.ts +3 -0
- package/dist/engine/core/icons.js +20 -0
- package/dist/{core → engine/core}/routing.d.ts +2 -0
- package/dist/{core → engine/core}/routing.js +9 -0
- package/dist/{core → engine/core}/schema-refs.d.ts +1 -1
- package/dist/{core → engine/core}/schema-refs.js +3 -1
- package/dist/engine/core/subformat-references.d.ts +5 -0
- package/dist/engine/core/subformat-references.js +33 -0
- package/dist/{core → engine/core}/subformats.d.ts +7 -0
- package/dist/{core → engine/core}/subformats.js +5 -1
- package/dist/{core → engine/core}/taxonomy.d.ts +2 -3
- package/dist/{core → engine/core}/taxonomy.js +1 -5
- package/dist/flow.global.js +306 -306
- package/dist/frontend/application-request.d.ts +14 -0
- package/dist/frontend/application-request.js +36 -0
- package/dist/frontend/document-application.d.ts +200 -0
- package/dist/{viewer/serve.js → frontend/document-application.js} +1611 -1670
- package/dist/frontend/figure-preview.d.ts +4 -0
- package/dist/{viewer → frontend}/figure-preview.js +4 -4
- package/dist/{viewer → frontend}/file-references.d.ts +1 -1
- package/dist/{viewer → frontend}/file-references.js +3 -3
- package/dist/{viewer → frontend}/font-picker.d.ts +1 -1
- package/dist/{viewer → frontend}/font-settings.d.ts +1 -1
- package/dist/{viewer → frontend}/language-picker.js +112 -18
- package/dist/{viewer → frontend}/locales/eng.json +16 -2
- package/dist/{viewer → frontend}/locales/jpn.json +16 -2
- package/dist/{viewer → frontend}/locales/zho.json +16 -2
- package/dist/{viewer → frontend}/nav-focus.js +2 -0
- package/dist/{viewer → frontend}/plugin-blocks.js +2 -2
- package/dist/{viewer → frontend}/resize.js +14 -2
- package/dist/frontend/resource-download.d.ts +2 -0
- package/dist/frontend/resource-download.js +43 -0
- package/dist/{viewer → frontend}/resource-library.d.ts +9 -2
- package/dist/{viewer → frontend}/resource-library.js +133 -37
- package/dist/{core → frontend}/schema-graph-flow.d.ts +1 -1
- package/dist/{core → frontend}/schema-graph-flow.js +1 -1
- package/dist/{viewer → frontend}/search.d.ts +2 -2
- package/dist/{viewer → frontend}/search.js +26 -8
- package/dist/graph/schema-graph-global.js +17 -17
- package/dist/install.sh +68 -0
- package/dist/plugins.global.js +62 -62
- package/dist/{viewer → server}/assets.d.ts +2 -0
- package/dist/server/assets.js +7 -0
- package/dist/{viewer → server}/build-plugins.js +4 -4
- package/dist/{viewer → server}/build.d.ts +2 -1
- package/dist/{viewer → server}/build.js +31 -15
- package/dist/{cli.js → server/cli.js} +199 -66
- package/dist/server/editor-tools.d.ts +1 -0
- package/dist/server/editor-tools.js +1 -0
- package/dist/{viewer → server}/extension-pack.js +2 -2
- package/dist/{viewer → server}/extensions.d.ts +1 -1
- package/dist/{viewer → server}/extensions.js +3 -3
- package/dist/server/git-diff.d.ts +10 -0
- package/dist/{viewer → server}/git-diff.js +45 -10
- package/dist/server/git-origin.d.ts +4 -0
- package/dist/server/git-origin.js +103 -0
- package/dist/server/git.d.ts +9 -0
- package/dist/{viewer → server}/git.js +50 -6
- package/dist/server/history.d.ts +14 -0
- package/dist/server/history.js +205 -0
- package/dist/{viewer → server}/hmr.d.ts +0 -22
- package/dist/server/hmr.js +168 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/{index.js → server/index.js} +16 -16
- package/dist/{viewer → server}/ja-lint.d.ts +1 -1
- package/dist/{viewer → server}/languages.d.ts +1 -1
- package/dist/{viewer → server}/languages.js +3 -3
- package/dist/{mcp.d.ts → server/mcp.d.ts} +2 -2
- package/dist/{mcp.js → server/mcp.js} +60 -21
- package/dist/{viewer → server}/plugin-config.d.ts +2 -2
- package/dist/{viewer → server}/plugin-config.js +2 -2
- package/dist/{plugins → server/plugins}/local-storage.d.ts +1 -1
- package/dist/{plugins → server/plugins}/local-storage.js +1 -1
- package/dist/{plugins → server/plugins}/runtime.d.ts +4 -4
- package/dist/{plugins → server/plugins}/runtime.js +4 -4
- package/dist/{viewer → server}/plugins.d.ts +3 -3
- package/dist/{viewer → server}/plugins.js +14 -13
- package/dist/server/resource-library.d.ts +1 -0
- package/dist/server/resource-library.js +1 -0
- package/dist/server/self.d.ts +5 -0
- package/dist/server/self.js +98 -0
- package/dist/server/serve.d.ts +61 -0
- package/dist/server/serve.js +503 -0
- package/dist/server/static-client.d.ts +4 -0
- package/dist/server/static-client.js +117 -0
- package/dist/server/workspace-server.d.ts +16 -0
- package/dist/server/workspace-server.js +266 -0
- package/dist/{viewer → server}/workspace.d.ts +6 -1
- package/dist/{viewer → server}/workspace.js +46 -0
- package/dist/subformats.global.js +92 -6
- package/dist/ui.global.js +85 -72
- package/dist/workspace/client.d.ts +13 -0
- package/dist/workspace/client.js +114 -0
- package/dist/{viewer → workspace}/code-file.d.ts +1 -1
- package/dist/{viewer → workspace}/code-file.js +7 -7
- package/dist/workspace/connection.d.ts +27 -0
- package/dist/workspace/connection.js +38 -0
- package/dist/{viewer → workspace}/editor-tools.d.ts +7 -1
- package/dist/{viewer → workspace}/editor-tools.js +12 -9
- package/dist/{viewer → workspace}/git-types.d.ts +7 -0
- package/dist/workspace/github.d.ts +4 -0
- package/dist/workspace/github.js +99 -0
- package/dist/workspace/history.d.ts +46 -0
- package/dist/workspace/history.js +86 -0
- package/dist/workspace/protocol.d.ts +38 -0
- package/dist/workspace/protocol.js +20 -0
- package/dist/workspace/resource-download.d.ts +1 -0
- package/dist/workspace/resource-download.js +8 -0
- package/dist/workspace/server.d.ts +9 -0
- package/dist/workspace/server.js +48 -0
- package/dist/{viewer → workspace}/site-icon.js +9 -10
- package/dist/{viewer → workspace}/site-title.js +6 -7
- package/dist/{viewer → workspace}/textfile.d.ts +1 -1
- package/dist/{viewer → workspace}/textfile.js +5 -5
- package/dist/workspace-worker.global.js +2859 -0
- package/package.json +35 -20
- package/dist/compiler/manifest.js +0 -37
- package/dist/compiler/serialize.d.ts +0 -3
- package/dist/compiler/serialize.js +0 -16
- package/dist/core/icons.js +0 -5
- package/dist/index.d.ts +0 -17
- package/dist/viewer/assets.js +0 -3
- package/dist/viewer/figure-preview.d.ts +0 -4
- package/dist/viewer/git-diff.d.ts +0 -6
- package/dist/viewer/git.d.ts +0 -5
- package/dist/viewer/hmr.js +0 -341
- package/dist/viewer/serve.d.ts +0 -216
- /package/dist/{compiler → engine/compiler}/asset-references.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/asset-references.js +0 -0
- /package/dist/{compiler → engine/compiler}/bundle-urls.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.js +0 -0
- /package/dist/{compiler → engine/compiler}/check.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-blocks.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-languages.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/config.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.js +0 -0
- /package/dist/{compiler → engine/compiler}/dxf.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/export.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/figures.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/files.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/fonts.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.js +0 -0
- /package/dist/{compiler → engine/compiler}/from-mdast.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.js +0 -0
- /package/dist/{compiler → engine/compiler}/locales.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.js +0 -0
- /package/dist/{compiler → engine/compiler}/subformat-schema.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.js +0 -0
- /package/dist/{compiler → engine/compiler}/textfile-remote.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/textfile.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/theme-variants.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/zip.d.ts +0 -0
- /package/dist/{core → engine/core}/blocks.js +0 -0
- /package/dist/{core → engine/core}/code-file.d.ts +0 -0
- /package/dist/{core → engine/core}/code-file.js +0 -0
- /package/dist/{core → engine/core}/code-grammars.d.ts +0 -0
- /package/dist/{core → engine/core}/code-grammars.js +0 -0
- /package/dist/{core → engine/core}/content-types.js +0 -0
- /package/dist/{core → engine/core}/escape-html.d.ts +0 -0
- /package/dist/{core → engine/core}/escape-html.js +0 -0
- /package/dist/{core → engine/core}/extension-package.d.ts +0 -0
- /package/dist/{core → engine/core}/extension-package.js +0 -0
- /package/dist/{core → engine/core}/figure-frame.d.ts +0 -0
- /package/dist/{core → engine/core}/figure-frame.js +0 -0
- /package/dist/{core → engine/core}/file-embed.d.ts +0 -0
- /package/dist/{core → engine/core}/file-embed.js +0 -0
- /package/dist/{core → engine/core}/files.d.ts +0 -0
- /package/dist/{core → engine/core}/files.js +0 -0
- /package/dist/{core → engine/core}/graph-common.d.ts +0 -0
- /package/dist/{core → engine/core}/graph-common.js +0 -0
- /package/dist/{core → engine/core}/graph.d.ts +0 -0
- /package/dist/{core → engine/core}/graph.js +0 -0
- /package/dist/{core → engine/core}/inline.d.ts +0 -0
- /package/dist/{core → engine/core}/inline.js +0 -0
- /package/dist/{core → engine/core}/json-tools.d.ts +0 -0
- /package/dist/{core → engine/core}/json-tools.js +0 -0
- /package/dist/{core → engine/core}/language.d.ts +0 -0
- /package/dist/{core → engine/core}/language.js +0 -0
- /package/dist/{core → engine/core}/languages/ja.d.ts +0 -0
- /package/dist/{core → engine/core}/languages/ja.js +0 -0
- /package/dist/{core → engine/core}/markdown.d.ts +0 -0
- /package/dist/{core → engine/core}/markdown.js +0 -0
- /package/dist/{core → engine/core}/previewers.d.ts +0 -0
- /package/dist/{core → engine/core}/previewers.js +0 -0
- /package/dist/{core → engine/core}/schema-comments.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-comments.js +0 -0
- /package/dist/{core → engine/core}/schema-fields.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-fields.js +0 -0
- /package/dist/{core → engine/core}/schema-graph.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-graph.js +0 -0
- /package/dist/{core → engine/core}/subformat-record.d.ts +0 -0
- /package/dist/{core → engine/core}/subformat-record.js +0 -0
- /package/dist/{core → engine/core}/term-reference.d.ts +0 -0
- /package/dist/{core → engine/core}/term-reference.js +0 -0
- /package/dist/{core → engine/core}/textfile.d.ts +0 -0
- /package/dist/{core → engine/core}/textfile.js +0 -0
- /package/dist/{core → engine/core}/theme-variants.d.ts +0 -0
- /package/dist/{core → engine/core}/theme-variants.js +0 -0
- /package/dist/{core → engine/core}/workspace.d.ts +0 -0
- /package/dist/{core → engine/core}/workspace.js +0 -0
- /package/dist/{viewer → frontend}/bundle-network.d.ts +0 -0
- /package/dist/{viewer → frontend}/bundle-network.js +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.d.ts +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.js +0 -0
- /package/dist/{core → frontend}/flow-css.d.ts +0 -0
- /package/dist/{core → frontend}/flow-css.js +0 -0
- /package/dist/{viewer → frontend}/font-picker.js +0 -0
- /package/dist/{viewer → frontend}/font-settings.js +0 -0
- /package/dist/{viewer → frontend}/i18n.d.ts +0 -0
- /package/dist/{viewer → frontend}/i18n.js +0 -0
- /package/dist/{viewer → frontend}/language-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.js +0 -0
- /package/dist/{viewer → frontend}/nav-focus.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.js +0 -0
- /package/dist/{viewer → frontend}/plugin-blocks.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.js +0 -0
- /package/dist/{viewer → frontend}/plugin-view.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-view.js +0 -0
- /package/dist/{viewer → frontend}/resize.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.js +0 -0
- /package/dist/{core → frontend}/table-ui.d.ts +0 -0
- /package/dist/{core → frontend}/table-ui.js +0 -0
- /package/dist/{core → frontend}/terms-ui.d.ts +0 -0
- /package/dist/{core → frontend}/terms-ui.js +0 -0
- /package/dist/{viewer → frontend}/theme-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/theme-picker.js +0 -0
- /package/dist/{core → frontend}/toc-ui.d.ts +0 -0
- /package/dist/{core → frontend}/toc-ui.js +0 -0
- /package/dist/{core → frontend}/video-ui.d.ts +0 -0
- /package/dist/{core → frontend}/video-ui.js +0 -0
- /package/dist/{viewer → server}/build-plugins.d.ts +0 -0
- /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
- /package/dist/{viewer → server}/extension-pack.d.ts +0 -0
- /package/dist/{viewer → server}/fonts/LICENSE.txt +0 -0
- /package/dist/{viewer → server}/fonts/udev-gothic-regular.woff2 +0 -0
- /package/dist/{viewer → server}/fonts.d.ts +0 -0
- /package/dist/{viewer → server}/fonts.js +0 -0
- /package/dist/{viewer → server}/ja-lint.js +0 -0
- /package/dist/{viewer → workspace}/git-types.js +0 -0
- /package/dist/{viewer → workspace}/site-icon.d.ts +0 -0
- /package/dist/{viewer → workspace}/site-title.d.ts +0 -0
|
@@ -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 {
|
|
2
|
-
import {
|
|
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 {
|
|
6
|
-
import {
|
|
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 {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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("
|
|
90
|
-
? await bundleClient("
|
|
91
|
-
: "", compiled.docs.some((doc) => doc.subformat)
|
|
92
|
-
? await bundleClient("
|
|
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 "
|
|
7
|
-
import { MANIFEST_FILE, serializeManifest } from "
|
|
8
|
-
import { prebuilt } from "./
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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.
|
|
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
|
|
63
|
-
|
|
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
|
|
71
|
-
const
|
|
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
|
-
? `${
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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("./
|
|
118
|
-
const { extensionFile } = await import("
|
|
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("
|
|
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("./
|
|
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("
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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("
|
|
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: {
|
|
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("./
|
|
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("
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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("./
|
|
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,
|
|
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("./
|
|
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;
|