@dooc-dev/dooc 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +41 -3
- package/dist/compiler/asset-references.d.ts +4 -0
- package/dist/compiler/asset-references.js +117 -0
- package/dist/compiler/bundle-urls.d.ts +1 -1
- package/dist/compiler/bundle-urls.js +15 -5
- package/dist/compiler/check.js +8 -5
- package/dist/compiler/code-languages.js +7 -2
- package/dist/compiler/compile.d.ts +5 -0
- package/dist/compiler/compile.js +105 -10
- package/dist/compiler/config.js +2 -1
- package/dist/compiler/export.d.ts +4 -0
- package/dist/compiler/export.js +140 -0
- package/dist/compiler/figures.js +4 -0
- package/dist/compiler/files.js +80 -41
- package/dist/compiler/fonts.js +4 -1
- package/dist/compiler/icons.d.ts +1 -1
- package/dist/compiler/icons.js +11 -2
- package/dist/compiler/ignored-files.d.ts +3 -0
- package/dist/compiler/ignored-files.js +68 -0
- package/dist/compiler/locales.js +13 -8
- package/dist/compiler/ops.d.ts +6 -0
- package/dist/compiler/ops.js +98 -7
- package/dist/compiler/subformats.d.ts +24 -0
- package/dist/compiler/subformats.js +299 -0
- package/dist/compiler/textfile.js +3 -0
- package/dist/compiler/theme-variants.js +5 -2
- package/dist/core/content-metadata.d.ts +15 -6
- package/dist/core/content-metadata.js +278 -17
- package/dist/core/content-types.d.ts +3 -1
- package/dist/core/figure-frame.js +19 -1
- package/dist/core/files.d.ts +2 -1
- package/dist/core/files.js +6 -8
- package/dist/core/flow-base-css.generated.js +1 -1
- package/dist/core/html.js +3 -3
- package/dist/core/icons.d.ts +3 -0
- package/dist/core/icons.js +3 -0
- package/dist/core/json-tools.d.ts +1 -0
- package/dist/core/json-tools.js +12 -0
- package/dist/core/routing.d.ts +5 -2
- package/dist/core/routing.js +17 -5
- package/dist/core/subformat-record.d.ts +3 -0
- package/dist/core/subformat-record.js +131 -0
- package/dist/core/subformats.d.ts +43 -0
- package/dist/core/subformats.js +81 -0
- package/dist/core/toc-ui.js +25 -23
- package/dist/edit.global.js +322 -95
- package/dist/mcp.js +50 -9
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/transport.d.ts +22 -0
- package/dist/plugins/transport.js +1 -0
- package/dist/plugins.global.js +128 -0
- package/dist/subformats.global.js +127 -0
- package/dist/ui.global.js +91 -38
- package/dist/viewer/build-plugins.d.ts +7 -0
- package/dist/viewer/build-plugins.js +70 -0
- package/dist/viewer/build.d.ts +9 -0
- package/dist/viewer/build.js +32 -5
- package/dist/viewer/editor-tools.d.ts +7 -7
- package/dist/viewer/editor-tools.js +36 -5
- package/dist/viewer/font-picker.js +5 -1
- package/dist/viewer/git-diff.d.ts +3 -0
- package/dist/viewer/git-diff.js +47 -0
- package/dist/viewer/hmr.js +4 -1
- package/dist/viewer/i18n.js +7 -5
- package/dist/viewer/language-picker.d.ts +2 -2
- package/dist/viewer/language-picker.js +26 -9
- package/dist/viewer/lazy-graph.d.ts +2 -0
- package/dist/viewer/lazy-graph.js +30 -0
- package/dist/viewer/locales/eng.json +72 -10
- package/dist/viewer/locales/jpn.json +73 -11
- package/dist/viewer/locales/zho.json +73 -11
- package/dist/viewer/nav-focus.js +8 -1
- package/dist/viewer/nav-update.d.ts +2 -0
- package/dist/viewer/nav-update.js +117 -0
- package/dist/viewer/plugin-style.d.ts +1 -0
- package/dist/viewer/plugin-style.js +82 -0
- package/dist/viewer/resize.d.ts +0 -2
- package/dist/viewer/resize.js +2 -98
- package/dist/viewer/resource-library.d.ts +10 -8
- package/dist/viewer/resource-library.js +179 -30
- package/dist/viewer/search.d.ts +4 -2
- package/dist/viewer/search.js +252 -53
- package/dist/viewer/serve.d.ts +10 -5
- package/dist/viewer/serve.js +789 -278
- package/dist/viewer/site-icon.js +13 -6
- package/dist/viewer/site-title.js +15 -2
- package/dist/viewer/textfile.d.ts +3 -0
- package/dist/viewer/textfile.js +19 -2
- package/dist/viewer/theme-picker.d.ts +2 -0
- package/dist/viewer/theme-picker.js +24 -8
- package/dist/viewer/workspace.d.ts +2 -0
- package/dist/viewer/workspace.js +46 -1
- package/package.json +24 -9
- package/dist/compiler/bundle.d.ts +0 -2
- package/dist/compiler/bundle.js +0 -100
package/dist/viewer/site-icon.js
CHANGED
|
@@ -21,11 +21,15 @@ export const siteIconResponse = (root, input) => {
|
|
|
21
21
|
const manifest = parseManifestText(raw ?? "[]");
|
|
22
22
|
if (manifest.errors.length)
|
|
23
23
|
return { status: 409, body: { error: manifest.errors.join("\n") } };
|
|
24
|
-
const
|
|
24
|
+
const theme = input?.theme ?? "light";
|
|
25
|
+
if (theme !== "light" && theme !== "dark")
|
|
26
|
+
throw new Error("Expected a light or dark theme");
|
|
27
|
+
const file = (manifest.format === "nested" ? manifest.themeIcons?.[theme] : manifest.icon) ??
|
|
25
28
|
(manifest.files?.defaultLayout !== false
|
|
26
|
-
? defaultFilePath("_site.svg")
|
|
27
|
-
: `${ICONS_DIR}/_site.svg`);
|
|
28
|
-
|
|
29
|
+
? defaultFilePath(manifest.format === "nested" ? `_site-${theme}.svg` : "_site.svg")
|
|
30
|
+
: `${ICONS_DIR}/_site${manifest.format === "nested" ? `-${theme}` : ""}.svg`);
|
|
31
|
+
const configured = manifest.format === "nested" ? manifest.themeIcons?.[theme] : manifest.icon;
|
|
32
|
+
if (!configured && existsSync(textfilePath(root, file)))
|
|
29
33
|
return {
|
|
30
34
|
status: 409,
|
|
31
35
|
body: { error: `${file} already exists; set dooc.yaml's icon to use it` },
|
|
@@ -33,12 +37,15 @@ export const siteIconResponse = (root, input) => {
|
|
|
33
37
|
const base = existsSync(textfilePath(root, file)) ? readTextfile(root, file) : null;
|
|
34
38
|
if (!writeTextfile(root, file, svg, base))
|
|
35
39
|
return { status: 409, body: { error: "Icon changed externally. Try again." } };
|
|
36
|
-
if (!
|
|
40
|
+
if (!configured) {
|
|
37
41
|
const parsed = parseDocument(raw ?? "docs: []\n");
|
|
38
42
|
const document = isSeq(parsed.contents) || parsed.contents == null
|
|
39
43
|
? new Document({ docs: parsed.toJS() ?? [] })
|
|
40
44
|
: parsed;
|
|
41
|
-
|
|
45
|
+
if (manifest.format === "nested")
|
|
46
|
+
document.setIn(["left_sidebar", "icon", theme], file);
|
|
47
|
+
else
|
|
48
|
+
document.set("icon", file);
|
|
42
49
|
if (!writeTextfile(root, MANIFEST_FILE, document.toString(), raw))
|
|
43
50
|
return { status: 409, body: { error: "Manifest changed externally. Try again." } };
|
|
44
51
|
}
|
|
@@ -2,6 +2,7 @@ import { Document, isSeq, parseDocument } from "yaml";
|
|
|
2
2
|
import { parseManifestText } from "../compiler/manifest.js";
|
|
3
3
|
import { readTextfile, writeTextfile } from "../compiler/textfile.js";
|
|
4
4
|
import { MANIFEST_FILE } from "../core/content-metadata.js";
|
|
5
|
+
import { contentLanguageCode, DEFAULT_LANG } from "../core/language.js";
|
|
5
6
|
export const siteTitleResponse = (root, input) => {
|
|
6
7
|
if (typeof input?.title !== "string" ||
|
|
7
8
|
!input.title.trim() ||
|
|
@@ -14,7 +15,12 @@ export const siteTitleResponse = (root, input) => {
|
|
|
14
15
|
const manifest = parseManifestText(raw);
|
|
15
16
|
if (manifest.errors.length)
|
|
16
17
|
return { status: 409, body: { error: manifest.errors.join("\n") } };
|
|
17
|
-
|
|
18
|
+
const language = contentLanguageCode(typeof input.language === "string"
|
|
19
|
+
? input.language
|
|
20
|
+
: (manifest.defaultLang ?? DEFAULT_LANG));
|
|
21
|
+
if (manifest.languages && !manifest.languages.includes(language))
|
|
22
|
+
throw new Error("Language is not declared in system.languages");
|
|
23
|
+
if ((manifest.titles?.[language] ?? manifest.title ?? null) !== input.baseTitle)
|
|
18
24
|
return { status: 409, body: { error: "Site title changed externally. Try again." } };
|
|
19
25
|
const parsed = parseDocument(raw);
|
|
20
26
|
const document = isSeq(parsed.contents) || parsed.contents == null
|
|
@@ -23,7 +29,14 @@ export const siteTitleResponse = (root, input) => {
|
|
|
23
29
|
if (document !== parsed)
|
|
24
30
|
document.commentBefore = parsed.commentBefore;
|
|
25
31
|
const title = input.title.trim();
|
|
26
|
-
|
|
32
|
+
if (manifest.format === "nested") {
|
|
33
|
+
const titles = document.toJS().left_sidebar?.title ?? {};
|
|
34
|
+
const key = Object.keys(titles).find((tag) => contentLanguageCode(tag) === language) ??
|
|
35
|
+
language;
|
|
36
|
+
document.setIn(["left_sidebar", "title", key], title);
|
|
37
|
+
}
|
|
38
|
+
else
|
|
39
|
+
document.set("title", title);
|
|
27
40
|
if (!writeTextfile(root, MANIFEST_FILE, document.toString(), raw))
|
|
28
41
|
return { status: 409, body: { error: "Manifest changed externally. Try again." } };
|
|
29
42
|
return { status: 200, body: { title } };
|
package/dist/viewer/textfile.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readManifest } from "../compiler/manifest.js";
|
|
2
|
+
import { validateSubformatFile } from "../compiler/subformats.js";
|
|
3
|
+
import { readTextfile, readTextfileAsync, textfilePath, writeTextfile, } from "../compiler/textfile.js";
|
|
2
4
|
import { TextfileUnavailable } from "../compiler/textfile-remote.js";
|
|
3
5
|
import { isRemoteTextfile } from "../core/textfile.js";
|
|
4
6
|
export const previewTextfiles = (root, input) => {
|
|
@@ -25,6 +27,7 @@ export const textfileResponse = async (root, input, domains = []) => {
|
|
|
25
27
|
if (typeof input.content !== "string" ||
|
|
26
28
|
(input.base !== null && typeof input.base !== "string"))
|
|
27
29
|
return { status: 400, body: { error: "Content and original text are required" } };
|
|
30
|
+
validateSubformatFile(root, input.file, input.content);
|
|
28
31
|
if (!writeTextfile(root, input.file, input.content, input.base))
|
|
29
32
|
return {
|
|
30
33
|
status: 409,
|
|
@@ -32,9 +35,23 @@ export const textfileResponse = async (root, input, domains = []) => {
|
|
|
32
35
|
};
|
|
33
36
|
return { status: 200, body: { content: input.content } };
|
|
34
37
|
}
|
|
38
|
+
const configs = isRemoteTextfile(input.file) ? [] : (readManifest(root).subformats ?? []);
|
|
39
|
+
const extension = input.file.split(".").at(-1);
|
|
40
|
+
const format = configs.find((config) => config.ext === extension);
|
|
35
41
|
return {
|
|
36
42
|
status: 200,
|
|
37
|
-
body: {
|
|
43
|
+
body: {
|
|
44
|
+
content: await readTextfileAsync(root, input.file, true, domains),
|
|
45
|
+
...(format
|
|
46
|
+
? {
|
|
47
|
+
language: format.format,
|
|
48
|
+
schema: JSON.parse(readTextfile(root, format.schema)),
|
|
49
|
+
}
|
|
50
|
+
: {}),
|
|
51
|
+
...(configs.some((config) => config.schema === input.file)
|
|
52
|
+
? { schemaDocument: true }
|
|
53
|
+
: {}),
|
|
54
|
+
},
|
|
38
55
|
};
|
|
39
56
|
}
|
|
40
57
|
catch (error) {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** Run in the head before any themed content can be painted. */
|
|
2
|
+
export declare const initializeThemes: (themes?: string[]) => void;
|
|
1
3
|
/** Self-contained because published viewers embed this function directly. */
|
|
2
4
|
export declare const mountThemePickers: (icons: Record<string, string>, themes?: string[]) => void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export const
|
|
1
|
+
/** Run in the head before any themed content can be painted. */
|
|
2
|
+
export const initializeThemes = (themes = ["light", "dark"]) => {
|
|
3
3
|
const root = document.documentElement;
|
|
4
|
-
const documentChoices = themes.length === 1 ? themes : ["auto", ...themes];
|
|
5
4
|
const read = (key) => {
|
|
6
5
|
try {
|
|
7
6
|
const value = localStorage.getItem(key);
|
|
@@ -11,11 +10,20 @@ export const mountThemePickers = (icons, themes = ["light", "dark"]) => {
|
|
|
11
10
|
return "auto";
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
const stored = read("docs-preview:theme");
|
|
14
|
+
root.dataset.theme =
|
|
15
|
+
themes.length === 1 ? (themes[0] ?? "auto") : themes.includes(stored) ? stored : "auto";
|
|
16
|
+
root.dataset.editorTheme = read("docs-editor:theme");
|
|
17
|
+
};
|
|
18
|
+
/** Self-contained because published viewers embed this function directly. */
|
|
19
|
+
export const mountThemePickers = (icons, themes = ["light", "dark"]) => {
|
|
20
|
+
const root = document.documentElement;
|
|
21
|
+
const documentChoices = themes.length === 1 ? themes : ["auto", ...themes];
|
|
22
|
+
let documentDefault = root.dataset.theme ?? "auto";
|
|
15
23
|
if (!documentChoices.includes(documentDefault))
|
|
16
24
|
documentDefault = documentChoices[0] ?? "auto";
|
|
17
25
|
root.dataset.theme = documentDefault;
|
|
18
|
-
root.dataset.editorTheme
|
|
26
|
+
root.dataset.editorTheme ??= "auto";
|
|
19
27
|
const t = (key) => window.__docsTranslate?.(key) ??
|
|
20
28
|
key;
|
|
21
29
|
const popup = document.createElement("div");
|
|
@@ -32,7 +40,7 @@ export const mountThemePickers = (icons, themes = ["light", "dark"]) => {
|
|
|
32
40
|
? (root.dataset.editorTheme ?? "auto")
|
|
33
41
|
: (target(button).dataset.theme ?? "auto");
|
|
34
42
|
const sync = () => {
|
|
35
|
-
for (const pane of document.querySelectorAll(".resources-pane"))
|
|
43
|
+
for (const pane of document.querySelectorAll(".resources-pane, #sidebar, #panel"))
|
|
36
44
|
if (pane.dataset.theme !== root.dataset.editorTheme)
|
|
37
45
|
pane.dataset.theme = root.dataset.editorTheme;
|
|
38
46
|
for (const pane of document.querySelectorAll(".preview-pane:not(.resources-pane)"))
|
|
@@ -41,12 +49,20 @@ export const mountThemePickers = (icons, themes = ["light", "dark"]) => {
|
|
|
41
49
|
for (const button of document.querySelectorAll("[data-theme-picker]")) {
|
|
42
50
|
const value = current(button);
|
|
43
51
|
const markup = icons[value === "auto" ? "" : value] ?? "";
|
|
52
|
+
const valueLabel = button.querySelector("[data-picker-value]");
|
|
44
53
|
if (button.dataset.themeIcon !== value) {
|
|
45
|
-
|
|
54
|
+
const icon = valueLabel
|
|
55
|
+
? button.closest(".editor-setting")?.querySelector("[data-setting-theme-icon]")
|
|
56
|
+
: button;
|
|
57
|
+
if (icon)
|
|
58
|
+
icon.innerHTML = markup;
|
|
46
59
|
button.dataset.themeIcon = value;
|
|
47
60
|
}
|
|
61
|
+
const name = t(value === "auto" ? "Auto" : value === "light" ? "Light" : "Dark");
|
|
62
|
+
if (valueLabel && valueLabel.textContent !== name)
|
|
63
|
+
valueLabel.textContent = name;
|
|
48
64
|
const label = t(button.dataset.themePicker === "editor" ? "Editor theme" : "Preview theme");
|
|
49
|
-
button.title = `${label}: ${
|
|
65
|
+
button.title = `${label}: ${name}`;
|
|
50
66
|
button.setAttribute("aria-label", button.title);
|
|
51
67
|
button.setAttribute("aria-haspopup", "menu");
|
|
52
68
|
button.setAttribute("aria-controls", popup.id);
|
|
@@ -2,3 +2,5 @@ import type { WorkspaceSource } from "../core/workspace.js";
|
|
|
2
2
|
export declare const gitHeadFile: (root: string) => string | undefined;
|
|
3
3
|
/** Read only local metadata; no Git commands, credentials or network access are needed. */
|
|
4
4
|
export declare const readWorkspaceSource: (root: string) => WorkspaceSource;
|
|
5
|
+
/** Resolve source links locally; published HTML must not depend on Git or the build directory. */
|
|
6
|
+
export declare const sourceFileBase: (root: string, sourceUrl?: string) => string;
|
package/dist/viewer/workspace.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
1
2
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
3
4
|
/** Git worktrees use a .git file pointing at their own metadata directory. */
|
|
4
5
|
const gitMetadata = (root) => {
|
|
5
6
|
let directory = realpathSync(root);
|
|
@@ -45,3 +46,47 @@ export const readWorkspaceSource = (root) => {
|
|
|
45
46
|
}
|
|
46
47
|
return { protocol: "storage", folder: basename(resolve(root)) || root, service: "Local" };
|
|
47
48
|
};
|
|
49
|
+
/** Resolve source links locally; published HTML must not depend on Git or the build directory. */
|
|
50
|
+
export const sourceFileBase = (root, sourceUrl) => {
|
|
51
|
+
if (sourceUrl !== undefined) {
|
|
52
|
+
const url = new URL(sourceUrl);
|
|
53
|
+
if (!["https:", "http:"].includes(url.protocol) ||
|
|
54
|
+
url.username ||
|
|
55
|
+
url.password ||
|
|
56
|
+
url.search ||
|
|
57
|
+
url.hash)
|
|
58
|
+
throw new Error("Source URL must be an HTTP(S) directory URL without credentials, query or fragment");
|
|
59
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}/`;
|
|
60
|
+
return url.href;
|
|
61
|
+
}
|
|
62
|
+
const directory = realpathSync(root);
|
|
63
|
+
const metadata = gitMetadata(directory);
|
|
64
|
+
const workspace = readWorkspaceSource(directory);
|
|
65
|
+
const prefix = metadata ? relative(metadata.directory, directory).split(sep).join("/") : "";
|
|
66
|
+
const fallback = `${[
|
|
67
|
+
workspace.protocol === "git" ? workspace.repo : basename(metadata?.directory ?? directory),
|
|
68
|
+
prefix,
|
|
69
|
+
]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join("/")}/`;
|
|
72
|
+
if (!metadata)
|
|
73
|
+
return fallback;
|
|
74
|
+
try {
|
|
75
|
+
const git = (...args) => execFileSync("git", ["-C", directory, ...args], {
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
78
|
+
timeout: 2_000,
|
|
79
|
+
}).trim();
|
|
80
|
+
const remote = new URL(git("config", "--get", "remote.origin.url").replace(/^git@github\.com:/, "https://github.com/"));
|
|
81
|
+
const repository = /^\/([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/.exec(remote.pathname);
|
|
82
|
+
if (remote.hostname !== "github.com" || !repository)
|
|
83
|
+
return fallback;
|
|
84
|
+
const head = git("rev-parse", "HEAD");
|
|
85
|
+
if (!/^(?:[a-f\d]{40}|[a-f\d]{64})$/i.test(head))
|
|
86
|
+
return fallback;
|
|
87
|
+
return `https://github.com/${repository[1]}/${repository[2]}/blob/${head}/${prefix ? `${prefix.split("/").map(encodeURIComponent).join("/")}/` : ""}`;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return fallback;
|
|
91
|
+
}
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooc-dev/dooc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "View and edit source files with dooc.yaml configuration, and share them as source ZIPs or standalone HTML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -30,7 +30,15 @@
|
|
|
30
30
|
"types": "./dist/core/schema-graph-mount.d.ts",
|
|
31
31
|
"default": "./dist/core/schema-graph-mount.js"
|
|
32
32
|
},
|
|
33
|
-
"./flow.global.js": "./dist/flow.global.js"
|
|
33
|
+
"./flow.global.js": "./dist/flow.global.js",
|
|
34
|
+
"./build": {
|
|
35
|
+
"types": "./dist/viewer/build.d.ts",
|
|
36
|
+
"default": "./dist/viewer/build.js"
|
|
37
|
+
},
|
|
38
|
+
"./export": {
|
|
39
|
+
"types": "./dist/compiler/export.d.ts",
|
|
40
|
+
"default": "./dist/compiler/export.js"
|
|
41
|
+
}
|
|
34
42
|
},
|
|
35
43
|
"peerDependencies": {
|
|
36
44
|
"@xyflow/react": ">=12",
|
|
@@ -54,19 +62,19 @@
|
|
|
54
62
|
},
|
|
55
63
|
"scripts": {
|
|
56
64
|
"build:plugin": "node -e \"require('node:fs').rmSync('packages/dooc-plugin/dist', {recursive:true, force:true})\" && tsc -p tsconfig.plugin.json",
|
|
57
|
-
"test:plugin-package": "node --import tsx scripts/test
|
|
65
|
+
"test:plugin-package": "node --import tsx scripts/test/plugin-package.mjs",
|
|
58
66
|
"build": "node -e \"require('node:fs').rmSync('dist', {recursive:true, force:true})\" && pnpm run build:css && pnpm run build:fonts && tsc -p tsconfig.build.json && pnpm run build:flow && pnpm run build:edit",
|
|
59
|
-
"build:binary": "bun scripts/build
|
|
60
|
-
"build:css": "node --import tsx
|
|
67
|
+
"build:binary": "bun scripts/build/binary.mjs",
|
|
68
|
+
"build:css": "node --import tsx scripts/build/flow-css.ts",
|
|
61
69
|
"build:flow": "esbuild src/core/schema-graph-global.tsx --bundle --format=iife --target=es2022 --minify --outfile=dist/flow.global.js",
|
|
62
|
-
"build:edit": "esbuild src/viewer/edit-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/edit.global.js && esbuild src/viewer/ui-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/ui.global.js && esbuild src/viewer/code-highlight.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/code.global.js",
|
|
70
|
+
"build:edit": "esbuild src/viewer/edit-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/edit.global.js && esbuild src/viewer/ui-client.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/ui.global.js && esbuild src/viewer/code-highlight.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/code.global.js && esbuild src/viewer/published-plugins.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/plugins.global.js && esbuild src/viewer/published-subformats.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/subformats.global.js",
|
|
63
71
|
"test": "vitest run",
|
|
64
|
-
"test:binary": "node scripts/test
|
|
65
|
-
"test:install": "node scripts/test
|
|
72
|
+
"test:binary": "node scripts/test/binary.mjs",
|
|
73
|
+
"test:install": "node scripts/test/install.mjs",
|
|
66
74
|
"check": "biome check . && tsc --noEmit && pnpm run build && vitest run && pnpm run test:install && pnpm run test:plugin-package",
|
|
67
75
|
"fix": "biome check --write .",
|
|
68
76
|
"build:fonts": "node -e \"require('node:fs').cpSync('src/viewer/fonts', 'dist/viewer/fonts', {recursive:true})\"",
|
|
69
|
-
"build:sample-extension": "node --import tsx scripts/build
|
|
77
|
+
"build:sample-extension": "node --import tsx scripts/build/sample-extension.mjs"
|
|
70
78
|
},
|
|
71
79
|
"devDependencies": {
|
|
72
80
|
"@biomejs/biome": "2.4.15",
|
|
@@ -101,7 +109,10 @@
|
|
|
101
109
|
"@textlint/kernel": "^15.8.0",
|
|
102
110
|
"@textlint/module-interop": "^15.8.0",
|
|
103
111
|
"@textlint/textlint-plugin-markdown": "^15.8.0",
|
|
112
|
+
"ajv": "8.20.0",
|
|
113
|
+
"ajv-formats": "3.0.1",
|
|
104
114
|
"franc": "^6.2.0",
|
|
115
|
+
"ignore": "^7.0.14",
|
|
105
116
|
"iso-639-3": "^3.0.1",
|
|
106
117
|
"mermaid": "^12.3.0",
|
|
107
118
|
"parse5": "8.0.0",
|
|
@@ -112,10 +123,14 @@
|
|
|
112
123
|
"remark-parse": "^11.0.0",
|
|
113
124
|
"remark-stringify": "11.0.0",
|
|
114
125
|
"shiki": "^4.5.0",
|
|
126
|
+
"smol-toml": "1.9.1",
|
|
115
127
|
"string-width": "4.2.3",
|
|
116
128
|
"textlint-rule-preset-ja-technical-writing": "^12.0.2",
|
|
129
|
+
"toml-eslint-parser": "^0.10.0",
|
|
117
130
|
"unified": "^11.0.5",
|
|
118
131
|
"unist-util-visit": "^5.0.0",
|
|
132
|
+
"vscode-json-languageservice": "5.7.2",
|
|
133
|
+
"vscode-languageserver-textdocument": "1.0.16",
|
|
119
134
|
"yaml": "^2.7.0"
|
|
120
135
|
},
|
|
121
136
|
"repository": {
|
package/dist/compiler/bundle.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// A bundle contains dooc.yaml and its managed source files, assets and local configuration.
|
|
2
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
|
-
import { join, posix } from "node:path";
|
|
4
|
-
import { MANIFEST_FILE } from "../core/content-metadata.js";
|
|
5
|
-
import { isRemoteTextfile } from "../core/textfile.js";
|
|
6
|
-
import { CODE_LANGUAGES_DIR } from "./code-languages.js";
|
|
7
|
-
import { CONFIG_FILE } from "./config.js";
|
|
8
|
-
import { collectRefs, parseDoc } from "./dialect.js";
|
|
9
|
-
import { projectFiles } from "./files.js";
|
|
10
|
-
import { PROJECT_FONTS_DIR } from "./fonts.js";
|
|
11
|
-
import { readManifest } from "./manifest.js";
|
|
12
|
-
import { readTextfile, textfilePath } from "./textfile.js";
|
|
13
|
-
const LAYOUT_DIRS = [
|
|
14
|
-
"content",
|
|
15
|
-
"figures",
|
|
16
|
-
"icons",
|
|
17
|
-
"locales",
|
|
18
|
-
"themes",
|
|
19
|
-
".dooc/editor-tools",
|
|
20
|
-
PROJECT_FONTS_DIR,
|
|
21
|
-
];
|
|
22
|
-
export const bundleEntries = (root) => {
|
|
23
|
-
const entries = [
|
|
24
|
-
...[CONFIG_FILE, MANIFEST_FILE]
|
|
25
|
-
.filter((name) => existsSync(join(root, name)))
|
|
26
|
-
.map((name) => ({ name, data: readFileSync(join(root, name)) })),
|
|
27
|
-
...(existsSync(join(root, CODE_LANGUAGES_DIR))
|
|
28
|
-
? readdirSync(join(root, CODE_LANGUAGES_DIR))
|
|
29
|
-
.filter((file) => !file.startsWith(".") &&
|
|
30
|
-
file.endsWith(".json") &&
|
|
31
|
-
statSync(join(root, CODE_LANGUAGES_DIR, file)).isFile())
|
|
32
|
-
.sort()
|
|
33
|
-
.map((file) => ({
|
|
34
|
-
name: `${CODE_LANGUAGES_DIR}/${file}`,
|
|
35
|
-
data: readFileSync(join(root, CODE_LANGUAGES_DIR, file)),
|
|
36
|
-
}))
|
|
37
|
-
: []),
|
|
38
|
-
...LAYOUT_DIRS.filter((dir) => existsSync(join(root, dir))).flatMap((dir) => readdirSync(join(root, dir), { recursive: true, encoding: "utf8" })
|
|
39
|
-
.filter((rel) => !rel
|
|
40
|
-
.replaceAll("\\", "/")
|
|
41
|
-
.split("/")
|
|
42
|
-
.some((seg) => seg.startsWith(".")))
|
|
43
|
-
.map((rel) => `${dir}/${rel.replaceAll("\\", "/")}`)
|
|
44
|
-
.filter((name) => statSync(join(root, name)).isFile())
|
|
45
|
-
.sort()
|
|
46
|
-
.map((name) => ({ name, data: readFileSync(textfilePath(root, name)) }))),
|
|
47
|
-
];
|
|
48
|
-
const known = new Set(entries.map((entry) => entry.name));
|
|
49
|
-
const layout = readManifest(root).files;
|
|
50
|
-
const mapped = new Set([...(layout?.order ?? []), ...Object.values(layout?.documents ?? {})]);
|
|
51
|
-
for (const file of projectFiles(root))
|
|
52
|
-
if ((file.path.startsWith("files/") || mapped.has(file.path)) && !known.has(file.path))
|
|
53
|
-
entries.push({ name: file.path, data: readFileSync(join(root, file.path)) });
|
|
54
|
-
const bodies = entries
|
|
55
|
-
.filter((entry) => /\.(md|callouth)$/.test(entry.name))
|
|
56
|
-
.map((entry) => entry.data.toString("utf8"));
|
|
57
|
-
const included = new Set(entries.map((entry) => entry.name));
|
|
58
|
-
const { icon } = readManifest(root);
|
|
59
|
-
if (icon && !included.has(posix.normalize(icon))) {
|
|
60
|
-
const name = posix.normalize(icon);
|
|
61
|
-
entries.push({ name, data: Buffer.from(readTextfile(root, icon), "utf8") });
|
|
62
|
-
included.add(name);
|
|
63
|
-
}
|
|
64
|
-
for (const body of bodies) {
|
|
65
|
-
const refs = collectRefs(parseDoc(body).root);
|
|
66
|
-
for (const file of refs.figures) {
|
|
67
|
-
if (included.has(file))
|
|
68
|
-
continue;
|
|
69
|
-
try {
|
|
70
|
-
entries.push({ name: file, data: readFileSync(textfilePath(root, file)) });
|
|
71
|
-
included.add(file);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
if (error.code !== "ENOENT")
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
for (const file of [...refs.textfiles, ...refs.terms]) {
|
|
79
|
-
if (isRemoteTextfile(file))
|
|
80
|
-
continue;
|
|
81
|
-
let text;
|
|
82
|
-
try {
|
|
83
|
-
text = readTextfile(root, file);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
if (error.code === "ENOENT")
|
|
87
|
-
continue;
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
const name = posix.normalize(file);
|
|
91
|
-
if (included.has(name))
|
|
92
|
-
continue;
|
|
93
|
-
entries.push({ name, data: Buffer.from(text, "utf8") });
|
|
94
|
-
included.add(name);
|
|
95
|
-
if (name.endsWith(".callouth"))
|
|
96
|
-
bodies.push(text);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return entries;
|
|
100
|
-
};
|