@dooc-dev/dooc 0.0.3 → 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 +98 -56
- 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.d.ts +1 -0
- package/dist/compiler/files.js +96 -38
- 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/manifest.d.ts +2 -0
- package/dist/compiler/manifest.js +9 -2
- 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/local-storage.js +3 -0
- package/dist/plugins/oauth.d.ts +1 -1
- package/dist/plugins/oauth.js +8 -2
- package/dist/plugins/runtime.d.ts +6 -0
- package/dist/plugins/runtime.js +166 -34
- package/dist/plugins/transport.d.ts +22 -0
- package/dist/plugins/transport.js +1 -0
- package/dist/plugins/types.d.ts +3 -1
- 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 +74 -10
- package/dist/viewer/locales/jpn.json +75 -11
- package/dist/viewer/locales/zho.json +75 -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/plugins.js +46 -3
- 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 +882 -287
- package/dist/viewer/site-icon.js +13 -6
- package/dist/viewer/site-title.d.ts +13 -0
- package/dist/viewer/site-title.js +50 -0
- 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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// browser-safe tree validation and manipulation.
|
|
6
|
-
import { docFile, localFile, parseFileLayout } from "./files.js";
|
|
1
|
+
// dooc.yaml owns document hierarchy and display settings. Nested manifests identify documents
|
|
2
|
+
// by complete source paths; legacy manifests retain their authored IDs during migration.
|
|
3
|
+
import { stringify } from "yaml";
|
|
4
|
+
import { docFile, fileDocumentId, localFile, parseFileLayout } from "./files.js";
|
|
7
5
|
import { contentLanguageCode, DEFAULT_LANG, isLangTag } from "./language.js";
|
|
6
|
+
import { parseSubformats } from "./subformats.js";
|
|
8
7
|
export const MANIFEST_FILE = "dooc.yaml";
|
|
9
8
|
export const DOC_ID_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
10
9
|
export const isDocId = (s) => DOC_ID_RE.test(s);
|
|
10
|
+
export const subformatPageId = (ext) => `subformat-${fileDocumentId(ext)}`;
|
|
11
11
|
/** Doc file name directly under content/ (`<id>.md`) → id. undefined if the shape differs. */
|
|
12
12
|
export const docIdOfFile = (name) => {
|
|
13
13
|
const id = name.endsWith(".md") ? name.slice(0, -3) : "";
|
|
@@ -19,6 +19,11 @@ export const docIdOfFile = (name) => {
|
|
|
19
19
|
* Validates id shape and duplicates.
|
|
20
20
|
*/
|
|
21
21
|
export const parseManifest = (value) => {
|
|
22
|
+
if (value &&
|
|
23
|
+
typeof value === "object" &&
|
|
24
|
+
!Array.isArray(value) &&
|
|
25
|
+
["system", "left_sidebar", "center_contents", "json_subformats"].some((key) => key in value))
|
|
26
|
+
return parseNestedManifest(value);
|
|
22
27
|
const errors = [];
|
|
23
28
|
let title;
|
|
24
29
|
let icon;
|
|
@@ -26,6 +31,8 @@ export const parseManifest = (value) => {
|
|
|
26
31
|
let files;
|
|
27
32
|
let languages;
|
|
28
33
|
let themes;
|
|
34
|
+
let subformats;
|
|
35
|
+
let defaultSubformatFolder;
|
|
29
36
|
if (value != null && typeof value === "object" && !Array.isArray(value)) {
|
|
30
37
|
const manifest = value;
|
|
31
38
|
for (const key of Object.keys(manifest))
|
|
@@ -35,7 +42,9 @@ export const parseManifest = (value) => {
|
|
|
35
42
|
key !== "docs" &&
|
|
36
43
|
key !== "files" &&
|
|
37
44
|
key !== "languages" &&
|
|
38
|
-
key !== "themes"
|
|
45
|
+
key !== "themes" &&
|
|
46
|
+
key !== "subformats" &&
|
|
47
|
+
key !== "default_subformat_folder")
|
|
39
48
|
errors.push(`${MANIFEST_FILE}: unknown field "${key}"`);
|
|
40
49
|
if (manifest.title !== undefined) {
|
|
41
50
|
if (typeof manifest.title !== "string" || !manifest.title.trim())
|
|
@@ -65,6 +74,22 @@ export const parseManifest = (value) => {
|
|
|
65
74
|
errors.push(`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`);
|
|
66
75
|
}
|
|
67
76
|
}
|
|
77
|
+
if (manifest.subformats !== undefined) {
|
|
78
|
+
try {
|
|
79
|
+
subformats = parseSubformats(manifest.subformats);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
errors.push(`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (manifest.default_subformat_folder !== undefined) {
|
|
86
|
+
const folder = manifest.default_subformat_folder;
|
|
87
|
+
if (!localFile(folder) ||
|
|
88
|
+
["node_modules", "dist", "locales", MANIFEST_FILE, "docs.config.mjs"].includes(folder.split("/")[0] ?? ""))
|
|
89
|
+
errors.push(`${MANIFEST_FILE}: default_subformat_folder must be a local project folder`);
|
|
90
|
+
else
|
|
91
|
+
defaultSubformatFolder = folder;
|
|
92
|
+
}
|
|
68
93
|
if (manifest.languages !== undefined) {
|
|
69
94
|
try {
|
|
70
95
|
if (!Array.isArray(manifest.languages) ||
|
|
@@ -108,6 +133,29 @@ export const parseManifest = (value) => {
|
|
|
108
133
|
const at = `${path}[${i}]`;
|
|
109
134
|
let id;
|
|
110
135
|
let children;
|
|
136
|
+
if (item && typeof item === "object" && !Array.isArray(item) && "subformat" in item) {
|
|
137
|
+
const config = subformats?.find((format) => format.ext === item.subformat);
|
|
138
|
+
if (!config ||
|
|
139
|
+
Object.keys(item).some((key) => !["subformat", "title", "children"].includes(key)) ||
|
|
140
|
+
(item.title !== undefined &&
|
|
141
|
+
(typeof item.title !== "string" || !item.title.trim()))) {
|
|
142
|
+
errors.push(`${MANIFEST_FILE}: ${at} requires a registered subformat and a non-empty title`);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const id = subformatPageId(config.ext);
|
|
146
|
+
if (seen.has(id)) {
|
|
147
|
+
errors.push(`${MANIFEST_FILE}: duplicate id "${id}"`);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
seen.add(id);
|
|
151
|
+
nodes.push({
|
|
152
|
+
id,
|
|
153
|
+
subformat: config.ext,
|
|
154
|
+
title: item.title?.trim() ?? config.ext,
|
|
155
|
+
children: walk(item.children, `${at}.children`),
|
|
156
|
+
});
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
111
159
|
if (typeof item === "string") {
|
|
112
160
|
id = item;
|
|
113
161
|
}
|
|
@@ -139,7 +187,9 @@ export const parseManifest = (value) => {
|
|
|
139
187
|
for (const id of [...Object.keys(files.documents), ...Object.keys(files.icons ?? {})])
|
|
140
188
|
if (!seen.has(id))
|
|
141
189
|
errors.push(`${MANIFEST_FILE}: files references unknown document "${id}"`);
|
|
142
|
-
const paths =
|
|
190
|
+
const paths = flattenTree(tree)
|
|
191
|
+
.filter((node) => !node.subformat)
|
|
192
|
+
.map(({ id }) => docFile(id, files));
|
|
143
193
|
if (new Set(paths).size !== paths.length)
|
|
144
194
|
errors.push(`${MANIFEST_FILE}: documents must use distinct files`);
|
|
145
195
|
}
|
|
@@ -151,11 +201,214 @@ export const parseManifest = (value) => {
|
|
|
151
201
|
...(files === undefined ? {} : { files }),
|
|
152
202
|
...(languages === undefined ? {} : { languages }),
|
|
153
203
|
...(themes === undefined ? {} : { themes }),
|
|
204
|
+
...(subformats === undefined ? {} : { subformats }),
|
|
205
|
+
...(defaultSubformatFolder === undefined ? {} : { defaultSubformatFolder }),
|
|
154
206
|
errors,
|
|
155
207
|
};
|
|
156
208
|
};
|
|
157
|
-
|
|
158
|
-
|
|
209
|
+
const parseNestedManifest = (input) => {
|
|
210
|
+
try {
|
|
211
|
+
const object = (value, keys, at) => {
|
|
212
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
213
|
+
throw new Error(`${at} must be an object`);
|
|
214
|
+
for (const key of Object.keys(value))
|
|
215
|
+
if (!keys.includes(key))
|
|
216
|
+
throw new Error(`${at}: unknown field "${key}"`);
|
|
217
|
+
return value;
|
|
218
|
+
};
|
|
219
|
+
const root = object(input, [
|
|
220
|
+
"system",
|
|
221
|
+
"left_sidebar",
|
|
222
|
+
"center_contents",
|
|
223
|
+
"json_subformats",
|
|
224
|
+
"default_subformat_folder",
|
|
225
|
+
], MANIFEST_FILE);
|
|
226
|
+
const system = object(root.system ?? {}, ["languages", "default_lang", "themes", "files"], "system");
|
|
227
|
+
const sidebar = object(root.left_sidebar ?? {}, ["title", "icon"], "left_sidebar");
|
|
228
|
+
const layout = object(system.files ?? {}, ["default_layout", "order"], "system.files");
|
|
229
|
+
const titles = {};
|
|
230
|
+
if (sidebar.title !== undefined) {
|
|
231
|
+
if (!sidebar.title || typeof sidebar.title !== "object" || Array.isArray(sidebar.title))
|
|
232
|
+
throw new Error("left_sidebar.title must map languages to titles");
|
|
233
|
+
for (const [tag, title] of Object.entries(sidebar.title)) {
|
|
234
|
+
if (!isLangTag(tag) || typeof title !== "string" || !title.trim())
|
|
235
|
+
throw new Error("Invalid localized site title");
|
|
236
|
+
const code = contentLanguageCode(tag);
|
|
237
|
+
if (Object.hasOwn(titles, code))
|
|
238
|
+
throw new Error(`Duplicate title language: ${code}`);
|
|
239
|
+
titles[code] = title.trim();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const themeIcons = {};
|
|
243
|
+
if (sidebar.icon !== undefined) {
|
|
244
|
+
const icons = object(sidebar.icon, ["light", "dark"], "left_sidebar.icon");
|
|
245
|
+
for (const [theme, file] of Object.entries(icons)) {
|
|
246
|
+
if (!localFile(file) || !file.endsWith(".svg"))
|
|
247
|
+
throw new Error("Site icons must be local SVG files");
|
|
248
|
+
themeIcons[theme] = file;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const documents = {};
|
|
252
|
+
const icons = {};
|
|
253
|
+
const walk = (value) => {
|
|
254
|
+
if (!Array.isArray(value))
|
|
255
|
+
throw new Error("center_contents and children must be lists");
|
|
256
|
+
return value.map((entry) => {
|
|
257
|
+
const node = object(entry, ["file", "icon", "children", "subformat", "title"], "center_contents");
|
|
258
|
+
if (node.icon !== undefined &&
|
|
259
|
+
(!localFile(node.icon) || !node.icon.endsWith(".svg")))
|
|
260
|
+
throw new Error("Document icons must be local SVG files");
|
|
261
|
+
if (node.subformat !== undefined) {
|
|
262
|
+
const config = parseSubformats(root.json_subformats ?? []).find((format) => format.ext === node.subformat);
|
|
263
|
+
if (!config ||
|
|
264
|
+
node.file !== undefined ||
|
|
265
|
+
(node.title !== undefined &&
|
|
266
|
+
(typeof node.title !== "string" || !node.title.trim())))
|
|
267
|
+
throw new Error("Subformat pages require a registered subformat and a non-empty title");
|
|
268
|
+
const id = subformatPageId(config.ext);
|
|
269
|
+
if (typeof node.icon === "string")
|
|
270
|
+
icons[id] = node.icon;
|
|
271
|
+
return {
|
|
272
|
+
id,
|
|
273
|
+
subformat: config.ext,
|
|
274
|
+
title: typeof node.title === "string" ? node.title.trim() : config.ext,
|
|
275
|
+
children: node.children === undefined ? [] : walk(node.children),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (!localFile(node.file) || !node.file.endsWith(".md"))
|
|
279
|
+
throw new Error("Each document requires a local .md file");
|
|
280
|
+
const id = fileDocumentId(node.file);
|
|
281
|
+
if (Object.hasOwn(documents, id))
|
|
282
|
+
throw new Error(`Duplicate document: ${node.file}`);
|
|
283
|
+
documents[id] = node.file;
|
|
284
|
+
if (typeof node.icon === "string")
|
|
285
|
+
icons[id] = node.icon;
|
|
286
|
+
return {
|
|
287
|
+
id,
|
|
288
|
+
file: node.file,
|
|
289
|
+
children: node.children === undefined ? [] : walk(node.children),
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
const tree = walk(root.center_contents);
|
|
294
|
+
const language = system.default_lang ?? DEFAULT_LANG;
|
|
295
|
+
if (typeof language !== "string" || !isLangTag(language))
|
|
296
|
+
throw new Error("system.default_lang must be a language tag");
|
|
297
|
+
const source = contentLanguageCode(language);
|
|
298
|
+
if (sidebar.title !== undefined && !titles[source])
|
|
299
|
+
throw new Error("left_sidebar.title must include system.default_lang");
|
|
300
|
+
const legacyTree = (nodes) => nodes.map((node) => node.subformat
|
|
301
|
+
? {
|
|
302
|
+
subformat: node.subformat,
|
|
303
|
+
title: node.title,
|
|
304
|
+
children: legacyTree(node.children),
|
|
305
|
+
}
|
|
306
|
+
: node.children.length
|
|
307
|
+
? { [node.id]: legacyTree(node.children) }
|
|
308
|
+
: node.id);
|
|
309
|
+
const parsed = parseManifest({
|
|
310
|
+
docs: legacyTree(tree),
|
|
311
|
+
defaultLang: language,
|
|
312
|
+
...(system.languages === undefined ? {} : { languages: system.languages }),
|
|
313
|
+
...(system.themes === undefined ? {} : { themes: system.themes }),
|
|
314
|
+
...(titles[source] ? { title: titles[source] } : {}),
|
|
315
|
+
...(themeIcons.light || themeIcons.dark
|
|
316
|
+
? { icon: themeIcons.light ?? themeIcons.dark }
|
|
317
|
+
: {}),
|
|
318
|
+
files: {
|
|
319
|
+
defaultLayout: layout.default_layout,
|
|
320
|
+
documents,
|
|
321
|
+
...(Object.keys(icons).length ? { icons } : {}),
|
|
322
|
+
},
|
|
323
|
+
...(root.json_subformats === undefined ? {} : { subformats: root.json_subformats }),
|
|
324
|
+
...(root.default_subformat_folder === undefined
|
|
325
|
+
? {}
|
|
326
|
+
: { default_subformat_folder: root.default_subformat_folder }),
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
...parsed,
|
|
330
|
+
format: "nested",
|
|
331
|
+
tree,
|
|
332
|
+
...(sidebar.title === undefined ? {} : { titles }),
|
|
333
|
+
...(sidebar.icon === undefined ? {} : { themeIcons }),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
return {
|
|
338
|
+
format: "nested",
|
|
339
|
+
tree: [],
|
|
340
|
+
errors: [`${MANIFEST_FILE}: ${error instanceof Error ? error.message : error}`],
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
/** Serialize the authored format; legacy manifests remain readable during migration. */
|
|
345
|
+
export const serializeManifest = (tree, { format, titles, themeIcons, title, icon, defaultLang, files, languages, themes, subformats, defaultSubformatFolder, } = {}) => {
|
|
346
|
+
if (format === "nested") {
|
|
347
|
+
const contents = (nodes) => nodes.map((node) => ({
|
|
348
|
+
...(node.subformat
|
|
349
|
+
? { subformat: node.subformat, title: node.title }
|
|
350
|
+
: { file: docFile(node.id, files) }),
|
|
351
|
+
...(files?.icons?.[node.id] ? { icon: files.icons[node.id] } : {}),
|
|
352
|
+
...(node.children.length ? { children: contents(node.children) } : {}),
|
|
353
|
+
}));
|
|
354
|
+
return stringify({
|
|
355
|
+
system: {
|
|
356
|
+
...(languages ? { languages } : {}),
|
|
357
|
+
default_lang: defaultLang ?? DEFAULT_LANG,
|
|
358
|
+
...(themes ? { themes } : {}),
|
|
359
|
+
...(files
|
|
360
|
+
? {
|
|
361
|
+
files: {
|
|
362
|
+
default_layout: files.defaultLayout,
|
|
363
|
+
},
|
|
364
|
+
}
|
|
365
|
+
: {}),
|
|
366
|
+
},
|
|
367
|
+
...(titles || title || themeIcons || icon
|
|
368
|
+
? {
|
|
369
|
+
left_sidebar: {
|
|
370
|
+
...(titles || title
|
|
371
|
+
? {
|
|
372
|
+
title: titles ?? {
|
|
373
|
+
[contentLanguageCode(defaultLang ?? DEFAULT_LANG)]: title,
|
|
374
|
+
},
|
|
375
|
+
}
|
|
376
|
+
: {}),
|
|
377
|
+
...(themeIcons || icon
|
|
378
|
+
? { icon: themeIcons ?? { light: icon, dark: icon } }
|
|
379
|
+
: {}),
|
|
380
|
+
},
|
|
381
|
+
}
|
|
382
|
+
: {}),
|
|
383
|
+
center_contents: contents(tree),
|
|
384
|
+
...(subformats ? { json_subformats: subformats } : {}),
|
|
385
|
+
...(defaultSubformatFolder
|
|
386
|
+
? { default_subformat_folder: defaultSubformatFolder }
|
|
387
|
+
: {}),
|
|
388
|
+
}, { lineWidth: 0 });
|
|
389
|
+
}
|
|
390
|
+
if (flattenTree(tree).some((node) => node.subformat)) {
|
|
391
|
+
const contents = (nodes) => nodes.map((node) => node.subformat
|
|
392
|
+
? {
|
|
393
|
+
subformat: node.subformat,
|
|
394
|
+
title: node.title,
|
|
395
|
+
...(node.children.length ? { children: contents(node.children) } : {}),
|
|
396
|
+
}
|
|
397
|
+
: node.children.length
|
|
398
|
+
? { [node.id]: contents(node.children) }
|
|
399
|
+
: node.id);
|
|
400
|
+
return stringify({
|
|
401
|
+
...(title ? { title } : {}),
|
|
402
|
+
...(icon ? { icon } : {}),
|
|
403
|
+
...(defaultLang ? { defaultLang } : {}),
|
|
404
|
+
...(files ? { files } : {}),
|
|
405
|
+
...(languages ? { languages } : {}),
|
|
406
|
+
...(themes ? { themes } : {}),
|
|
407
|
+
...(subformats ? { subformats } : {}),
|
|
408
|
+
...(defaultSubformatFolder ? { default_subformat_folder: defaultSubformatFolder } : {}),
|
|
409
|
+
docs: contents(tree),
|
|
410
|
+
});
|
|
411
|
+
}
|
|
159
412
|
const write = (nodes, indent) => nodes.flatMap((n) => n.children.length > 0
|
|
160
413
|
? [`${indent}- ${n.id}:`, ...write(n.children, `${indent} `)]
|
|
161
414
|
: [`${indent}- ${n.id}`]);
|
|
@@ -164,10 +417,12 @@ export const serializeManifest = (tree, { title, icon, defaultLang, files, langu
|
|
|
164
417
|
defaultLang !== undefined ||
|
|
165
418
|
files !== undefined ||
|
|
166
419
|
languages !== undefined ||
|
|
167
|
-
themes !== undefined
|
|
420
|
+
themes !== undefined ||
|
|
421
|
+
subformats !== undefined ||
|
|
422
|
+
defaultSubformatFolder !== undefined) {
|
|
168
423
|
const lines = write(tree, " ");
|
|
169
|
-
const metadata = `${title === undefined ? "" : `title: ${JSON.stringify(title)}\n`}${icon === undefined ? "" : `icon: ${JSON.stringify(icon)}\n`}${defaultLang === undefined ? "" : `defaultLang: ${JSON.stringify(defaultLang)}\n`}`;
|
|
170
|
-
return `${metadata}${files ? `files: ${JSON.stringify(files)}\n` : ""}${languages ? `languages: ${JSON.stringify(languages)}\n` : ""}${themes ? `themes: ${JSON.stringify(themes)}\n` : ""}docs:${lines.length ? `\n${lines.join("\n")}\n` : " []\n"}`;
|
|
424
|
+
const metadata = `${title === undefined ? "" : `title: ${JSON.stringify(title)}\n`}${icon === undefined ? "" : `icon: ${JSON.stringify(icon)}\n`}${defaultLang === undefined ? "" : `defaultLang: ${JSON.stringify(defaultLang)}\n`}${defaultSubformatFolder === undefined ? "" : `default_subformat_folder: ${JSON.stringify(defaultSubformatFolder)}\n`}`;
|
|
425
|
+
return `${metadata}${files ? `files: ${JSON.stringify(files)}\n` : ""}${languages ? `languages: ${JSON.stringify(languages)}\n` : ""}${themes ? `themes: ${JSON.stringify(themes)}\n` : ""}${subformats ? `subformats: ${JSON.stringify(subformats)}\n` : ""}docs:${lines.length ? `\n${lines.join("\n")}\n` : " []\n"}`;
|
|
171
426
|
}
|
|
172
427
|
const lines = write(tree, "");
|
|
173
428
|
return `# Doc hierarchy and order (each id = content/<id>.md)\n${lines.join("\n")}${lines.length > 0 ? "\n" : ""}`;
|
|
@@ -177,14 +432,20 @@ export const flattenTree = (tree) => {
|
|
|
177
432
|
const out = [];
|
|
178
433
|
const walk = (nodes, parent, depth) => {
|
|
179
434
|
for (const n of nodes) {
|
|
180
|
-
out.push(
|
|
435
|
+
out.push({
|
|
436
|
+
id: n.id,
|
|
437
|
+
...(n.file ? { file: n.file } : {}),
|
|
438
|
+
...(n.subformat ? { subformat: n.subformat, title: n.title } : {}),
|
|
439
|
+
...(parent == null ? {} : { parent }),
|
|
440
|
+
depth,
|
|
441
|
+
});
|
|
181
442
|
walk(n.children, n.id, depth + 1);
|
|
182
443
|
}
|
|
183
444
|
};
|
|
184
445
|
walk(tree, undefined, 0);
|
|
185
446
|
return out;
|
|
186
447
|
};
|
|
187
|
-
const clone = (tree) => tree.map((n) => ({
|
|
448
|
+
const clone = (tree) => tree.map((n) => ({ ...n, children: clone(n.children) }));
|
|
188
449
|
const findNode = (tree, id) => {
|
|
189
450
|
for (const n of tree) {
|
|
190
451
|
if (n.id === id) {
|
|
@@ -214,13 +475,13 @@ const detach = (tree, id) => {
|
|
|
214
475
|
/** Child list of parent (omitted = top level). undefined if parent doesn't exist. */
|
|
215
476
|
const childList = (tree, parent) => parent == null ? tree : findNode(tree, parent)?.children;
|
|
216
477
|
/** Append a new doc to the end of parent's children. Duplicate id / missing parent → undefined. */
|
|
217
|
-
export const insertDoc = (tree, id, parent) => {
|
|
478
|
+
export const insertDoc = (tree, id, parent, page = {}) => {
|
|
218
479
|
const next = clone(tree);
|
|
219
480
|
const list = childList(next, parent);
|
|
220
481
|
if (!list || findNode(next, id)) {
|
|
221
482
|
return undefined;
|
|
222
483
|
}
|
|
223
|
-
list.push({ id, children: [] });
|
|
484
|
+
list.push({ id, ...page, children: [] });
|
|
224
485
|
return next;
|
|
225
486
|
};
|
|
226
487
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Block, TocEntry } from "./blocks.js";
|
|
2
|
+
import type { SubformatCollection } from "./subformats.js";
|
|
2
3
|
import type { Frontmatter } from "./taxonomy.js";
|
|
3
4
|
export interface TermEntry {
|
|
4
5
|
/** Root-relative .termth path, or a document position for an inline definition. */
|
|
@@ -24,9 +25,10 @@ export interface FigureEntry {
|
|
|
24
25
|
}
|
|
25
26
|
export type CompiledDoc = Frontmatter & {
|
|
26
27
|
id: string;
|
|
28
|
+
subformat?: SubformatCollection;
|
|
27
29
|
/** Parent doc id (SoT: dooc.yaml). Omitted = top level. docs[] is in pre-order. */
|
|
28
30
|
parent?: string;
|
|
29
|
-
/**
|
|
31
|
+
/** Project-relative Markdown source path, or subformat:<ext> for a display page. */
|
|
30
32
|
file: string;
|
|
31
33
|
/** Resolved language (BCP 47): front-matter `lang`, else the site default (language.ts). */
|
|
32
34
|
lang: string;
|
|
@@ -57,17 +57,34 @@ export const figureFrameHtml = (fig, cls = "fig-frame", label) => {
|
|
|
57
57
|
export function mountFigureFrames(doc) {
|
|
58
58
|
const SEL = "iframe[data-doc-figure-frame]";
|
|
59
59
|
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
60
|
+
const watched = new WeakSet();
|
|
61
|
+
const loaded = new WeakSet();
|
|
60
62
|
const theme = (element) => {
|
|
61
63
|
const t = element.closest("[data-theme]")?.dataset.theme ??
|
|
62
64
|
doc.documentElement.dataset.theme;
|
|
63
65
|
return t === "light" || t === "dark" ? t : media.matches ? "dark" : "light";
|
|
64
66
|
};
|
|
65
67
|
const apply = (f) => {
|
|
68
|
+
if (!watched.has(f)) {
|
|
69
|
+
watched.add(f);
|
|
70
|
+
f.removeAttribute("data-theme-ready");
|
|
71
|
+
f.addEventListener("load", () => {
|
|
72
|
+
loaded.add(f);
|
|
73
|
+
apply(f);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
// Rewriting srcdoc during its initial load can leave the frame without layout.
|
|
77
|
+
if (!loaded.has(f))
|
|
78
|
+
return;
|
|
66
79
|
const src = f.getAttribute("srcdoc") ?? "";
|
|
67
80
|
const next = src.replace(/^(<!doctype html><html data-doc-theme=")[a-z]+"/, `$1${theme(f)}"`);
|
|
68
81
|
if (next !== src) {
|
|
82
|
+
loaded.delete(f);
|
|
83
|
+
f.removeAttribute("data-theme-ready");
|
|
69
84
|
f.setAttribute("srcdoc", next);
|
|
70
85
|
}
|
|
86
|
+
else
|
|
87
|
+
f.setAttribute("data-theme-ready", "true");
|
|
71
88
|
};
|
|
72
89
|
const all = () => {
|
|
73
90
|
for (const f of doc.querySelectorAll(SEL))
|
|
@@ -97,7 +114,8 @@ export function mountFigureFrames(doc) {
|
|
|
97
114
|
media.addEventListener("change", all);
|
|
98
115
|
window.addEventListener("message", (ev) => {
|
|
99
116
|
const h = ev.data?.docFigureHeight;
|
|
100
|
-
|
|
117
|
+
// A frame can report zero before layout; keep its initial viewport until measured.
|
|
118
|
+
if (typeof h !== "number" || !Number.isFinite(h) || h <= 0)
|
|
101
119
|
return;
|
|
102
120
|
for (const f of doc.querySelectorAll(`${SEL}[data-doc-figure-frame="html"]`)) {
|
|
103
121
|
if (f.contentWindow === ev.source)
|
package/dist/core/files.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface FileLayout {
|
|
2
2
|
defaultLayout: boolean;
|
|
3
3
|
documents: Record<string, string>;
|
|
4
|
-
order: string[];
|
|
5
4
|
icons?: Record<string, string>;
|
|
6
5
|
}
|
|
7
6
|
export declare const MAX_FILE_UPLOAD_BYTES: number;
|
|
@@ -10,6 +9,8 @@ export declare const isDocumentFileName: (value: unknown) => value is string;
|
|
|
10
9
|
export declare const suggestDocFileName: (title: string) => string;
|
|
11
10
|
export declare const fileExtension: (file: string) => string;
|
|
12
11
|
export declare const defaultFilePath: (file: string) => string;
|
|
12
|
+
/** Internal keys are derived from the complete path, never authored in the manifest. */
|
|
13
|
+
export declare const fileDocumentId: (file: string) => string;
|
|
13
14
|
export declare const docFile: (id: string, layout?: FileLayout) => string;
|
|
14
15
|
export declare const parseFileLayout: (value: unknown) => FileLayout;
|
|
15
16
|
export declare const docIconFile: (id: string, layout?: FileLayout) => string;
|
package/dist/core/files.js
CHANGED
|
@@ -19,6 +19,8 @@ export const fileExtension = (file) => {
|
|
|
19
19
|
return name.includes(".") ? name.slice(name.lastIndexOf(".") + 1).toLowerCase() : "other";
|
|
20
20
|
};
|
|
21
21
|
export const defaultFilePath = (file) => `files/${fileExtension(file)}/${file.split("/").pop()}`;
|
|
22
|
+
/** Internal keys are derived from the complete path, never authored in the manifest. */
|
|
23
|
+
export const fileDocumentId = (file) => `file-${Array.from(new TextEncoder().encode(file), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
22
24
|
export const docFile = (id, layout) => layout && Object.hasOwn(layout.documents, id)
|
|
23
25
|
? layout.documents[id]
|
|
24
26
|
: `content/${id}.md`;
|
|
@@ -26,11 +28,11 @@ export const parseFileLayout = (value) => {
|
|
|
26
28
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
27
29
|
throw new Error("files must be an object");
|
|
28
30
|
const v = value;
|
|
31
|
+
// Accept the retired order field when opening older manifests, without retaining it.
|
|
29
32
|
if (Object.keys(v).some((key) => !["defaultLayout", "documents", "order", "icons"].includes(key)) ||
|
|
30
33
|
(v.defaultLayout !== undefined && typeof v.defaultLayout !== "boolean"))
|
|
31
34
|
throw new Error("Invalid file layout");
|
|
32
35
|
const documents = v.documents ?? {};
|
|
33
|
-
const order = v.order ?? [];
|
|
34
36
|
const icons = v.icons;
|
|
35
37
|
if (icons !== undefined &&
|
|
36
38
|
(!icons ||
|
|
@@ -42,18 +44,14 @@ export const parseFileLayout = (value) => {
|
|
|
42
44
|
typeof documents !== "object" ||
|
|
43
45
|
Array.isArray(documents) ||
|
|
44
46
|
Object.entries(documents).some(([id, file]) => !/^[a-z0-9][a-z0-9-]*$/.test(id) || !localFile(file) || !file.endsWith(".md")) ||
|
|
45
|
-
new Set(Object.values(documents)).size !== Object.keys(documents).length
|
|
46
|
-
|
|
47
|
-
order.some((file) => !localFile(file)) ||
|
|
48
|
-
new Set(order).size !== order.length)
|
|
49
|
-
throw new Error("Invalid file paths or order");
|
|
47
|
+
new Set(Object.values(documents)).size !== Object.keys(documents).length)
|
|
48
|
+
throw new Error("Invalid file paths");
|
|
50
49
|
return {
|
|
51
50
|
defaultLayout: v.defaultLayout !== false,
|
|
52
51
|
documents: documents,
|
|
53
|
-
order,
|
|
54
52
|
...(icons ? { icons: icons } : {}),
|
|
55
53
|
};
|
|
56
54
|
};
|
|
57
55
|
export const docIconFile = (id, layout) => layout?.icons && Object.hasOwn(layout.icons, id)
|
|
58
56
|
? layout.icons[id]
|
|
59
|
-
: `icons/${id}.svg`;
|
|
57
|
+
: `icons/${layout?.documents[id] && fileDocumentId(layout.documents[id]) === id ? layout.documents[id] : id}.svg`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated — do not edit by hand (`pnpm run build:css` = build
|
|
1
|
+
// Generated — do not edit by hand (`pnpm run build:css` = scripts/build/flow-css.ts
|
|
2
2
|
// copies it from @xyflow/react/dist/base.css). A structure-only stylesheet; colors come from
|
|
3
3
|
// `--doc-*` injected by the consumer (React Flow's default theme = style.css is not included).
|
|
4
4
|
export const XYFLOW_BASE_CSS = "/* this will be exported as base.css and can be used for a basic styling */\n/* these are the necessary styles for React/Svelte Flow, they get used by base.css and style.css */\n.react-flow {\n direction: ltr;\n\n --xy-edge-stroke-default: #b1b1b7;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #555;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(255, 255, 255, 0.5);\n\n --xy-minimap-background-color-default: #fff;\n --xy-minimap-mask-background-color-default: rgba(240, 240, 240, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #e2e2e2;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: transparent;\n --xy-background-pattern-dots-color-default: #91919a;\n --xy-background-pattern-lines-color-default: #eee;\n --xy-background-pattern-cross-color-default: #e2e2e2;\n background-color: var(--xy-background-color, var(--xy-background-color-default));\n --xy-node-border-default: 1px solid #bbb;\n --xy-node-border-selected-default: 1px solid #555;\n\n --xy-handle-background-color-default: #333;\n\n --xy-selection-background-color-default: rgba(150, 150, 180, 0.1);\n --xy-selection-border-default: 1px dotted rgba(155, 155, 155, 0.8);\n --xy-resize-background-color-default: #3367d9;\n}\n.react-flow.dark {\n --xy-edge-stroke-default: #3e3e3e;\n --xy-edge-stroke-width-default: 1;\n --xy-edge-stroke-selected-default: #727272;\n\n --xy-connectionline-stroke-default: #b1b1b7;\n --xy-connectionline-stroke-width-default: 1;\n\n --xy-attribution-background-color-default: rgba(150, 150, 150, 0.25);\n\n --xy-minimap-background-color-default: #141414;\n --xy-minimap-mask-background-color-default: rgba(60, 60, 60, 0.6);\n --xy-minimap-mask-stroke-color-default: transparent;\n --xy-minimap-mask-stroke-width-default: 1;\n --xy-minimap-node-background-color-default: #2b2b2b;\n --xy-minimap-node-stroke-color-default: transparent;\n --xy-minimap-node-stroke-width-default: 2;\n\n --xy-background-color-default: #141414;\n --xy-background-pattern-dots-color-default: #555;\n --xy-background-pattern-lines-color-default: #333;\n --xy-background-pattern-cross-color-default: #333;\n --xy-node-color-default: #f8f8f8;\n}\n.react-flow__background {\n background-color: var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));\n pointer-events: none;\n z-index: -1;\n}\n.react-flow__container {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n}\n.react-flow__pane {\n z-index: 1;\n touch-action: none;\n}\n.react-flow__pane.draggable {\n cursor: grab;\n }\n.react-flow__pane.dragging {\n cursor: grabbing;\n }\n.react-flow__pane.selection {\n cursor: pointer;\n }\n.react-flow__viewport {\n transform-origin: 0 0;\n z-index: 2;\n pointer-events: none;\n}\n.react-flow__renderer {\n z-index: 4;\n}\n.react-flow__selection {\n z-index: 6;\n}\n.react-flow__nodesselection-rect:focus,\n.react-flow__nodesselection-rect:focus-visible {\n outline: none;\n}\n.react-flow__edge-path {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n stroke-width: var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));\n fill: none;\n}\n.react-flow__connection-path {\n stroke: var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));\n stroke-width: var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));\n fill: none;\n}\n.react-flow .react-flow__edges {\n position: absolute;\n}\n.react-flow .react-flow__edges svg {\n overflow: visible;\n position: absolute;\n pointer-events: none;\n }\n.react-flow__edge {\n pointer-events: visibleStroke;\n}\n.react-flow__edge.selectable {\n cursor: pointer;\n }\n.react-flow__edge.animated path {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\n.react-flow__edge.animated path.react-flow__edge-interaction {\n stroke-dasharray: none;\n animation: none;\n }\n.react-flow__edge.inactive {\n pointer-events: none;\n }\n.react-flow__edge.selected,\n .react-flow__edge:focus,\n .react-flow__edge:focus-visible {\n outline: none;\n }\n.react-flow__edge.selected .react-flow__edge-path,\n .react-flow__edge.selectable:focus .react-flow__edge-path,\n .react-flow__edge.selectable:focus-visible .react-flow__edge-path {\n stroke: var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default));\n }\n.react-flow__edge-textwrapper {\n pointer-events: all;\n }\n.react-flow__edge .react-flow__edge-text {\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n }\n/* Arrowhead marker styles - use CSS custom properties as default */\n.react-flow__arrowhead polyline {\n stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__arrowhead polyline.arrowclosed {\n fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default));\n}\n.react-flow__connection {\n pointer-events: none;\n}\n.react-flow__connection .animated {\n stroke-dasharray: 5;\n animation: dashdraw 0.5s linear infinite;\n }\nsvg.react-flow__connectionline {\n z-index: 1001;\n overflow: visible;\n position: absolute;\n}\n.react-flow__nodes {\n pointer-events: none;\n transform-origin: 0 0;\n}\n.react-flow__node {\n position: absolute;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n pointer-events: all;\n transform-origin: 0 0;\n box-sizing: border-box;\n cursor: default;\n}\n.react-flow__node.selectable {\n cursor: pointer;\n }\n.react-flow__node.draggable {\n cursor: grab;\n pointer-events: all;\n }\n.react-flow__node.draggable.dragging {\n cursor: grabbing;\n }\n.react-flow__nodesselection {\n z-index: 3;\n transform-origin: left top;\n pointer-events: none;\n}\n.react-flow__nodesselection-rect {\n position: absolute;\n pointer-events: all;\n cursor: grab;\n }\n.react-flow__handle {\n position: absolute;\n pointer-events: none;\n min-width: 5px;\n min-height: 5px;\n background-color: var(--xy-handle-background-color, var(--xy-handle-background-color-default));\n}\n.react-flow__handle.connectingfrom {\n pointer-events: all;\n }\n.react-flow__handle.connectionindicator {\n pointer-events: all;\n cursor: crosshair;\n }\n.react-flow__handle-bottom {\n top: auto;\n left: 50%;\n bottom: 0;\n transform: translate(-50%, 50%);\n }\n.react-flow__handle-top {\n top: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-left {\n top: 50%;\n left: 0;\n transform: translate(-50%, -50%);\n }\n.react-flow__handle-right {\n top: 50%;\n right: 0;\n transform: translate(50%, -50%);\n }\n.react-flow__edgeupdater {\n cursor: move;\n pointer-events: all;\n}\n.react-flow__pane.selection .react-flow__panel {\n pointer-events: none;\n}\n.react-flow__panel {\n position: absolute;\n z-index: 5;\n margin: 15px;\n}\n.react-flow__panel.top {\n top: 0;\n }\n.react-flow__panel.bottom {\n bottom: 0;\n }\n.react-flow__panel.top.center, .react-flow__panel.bottom.center {\n left: 50%;\n transform: translateX(-15px) translateX(-50%);\n }\n.react-flow__panel.left {\n left: 0;\n }\n.react-flow__panel.right {\n right: 0;\n }\n.react-flow__panel.left.center, .react-flow__panel.right.center {\n top: 50%;\n transform: translateY(-15px) translateY(-50%);\n }\n.react-flow__attribution {\n font-size: 10px;\n background: var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));\n padding: 2px 3px;\n margin: 0;\n}\n.react-flow__attribution a {\n text-decoration: none;\n color: #999;\n }\n@keyframes dashdraw {\n from {\n stroke-dashoffset: 10;\n }\n}\n.react-flow__edgelabel-renderer {\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n left: 0;\n top: 0;\n}\n.react-flow__viewport-portal {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n.react-flow__minimap {\n background: var(\n --xy-minimap-background-color-props,\n var(--xy-minimap-background-color, var(--xy-minimap-background-color-default))\n );\n}\n.react-flow__minimap-svg {\n display: block;\n }\n.react-flow__minimap-mask {\n fill: var(\n --xy-minimap-mask-background-color-props,\n var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default))\n );\n stroke: var(\n --xy-minimap-mask-stroke-color-props,\n var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-mask-stroke-width-props,\n var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default))\n );\n }\n.react-flow__minimap-node {\n fill: var(\n --xy-minimap-node-background-color-props,\n var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default))\n );\n stroke: var(\n --xy-minimap-node-stroke-color-props,\n var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default))\n );\n stroke-width: var(\n --xy-minimap-node-stroke-width-props,\n var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default))\n );\n }\n.react-flow__background-pattern.dots {\n fill: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default))\n );\n }\n.react-flow__background-pattern.lines {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default))\n );\n }\n.react-flow__background-pattern.cross {\n stroke: var(\n --xy-background-pattern-color-props,\n var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default))\n );\n }\n.react-flow__controls {\n display: flex;\n flex-direction: column;\n}\n.react-flow__controls.horizontal {\n flex-direction: row;\n }\n.react-flow__controls-button {\n display: flex;\n justify-content: center;\n align-items: center;\n height: 26px;\n width: 26px;\n padding: 4px;\n }\n.react-flow__controls-button svg {\n width: 100%;\n max-width: 12px;\n max-height: 12px;\n fill: currentColor;\n }\n.react-flow__node-input,\n.react-flow__node-default,\n.react-flow__node-output,\n.react-flow__node-group {\n border: var(--xy-node-border, var(--xy-node-border-default));\n color: var(--xy-node-color, var(--xy-node-color-default));\n}\n.react-flow__node-input.selected,\n .react-flow__node-input:focus,\n .react-flow__node-input:focus-visible,\n .react-flow__node-default.selected,\n .react-flow__node-default:focus,\n .react-flow__node-default:focus-visible,\n .react-flow__node-output.selected,\n .react-flow__node-output:focus,\n .react-flow__node-output:focus-visible,\n .react-flow__node-group.selected,\n .react-flow__node-group:focus,\n .react-flow__node-group:focus-visible {\n outline: none;\n border: var(--xy-node-border-selected, var(--xy-node-border-selected-default));\n }\n.react-flow__nodesselection-rect,\n.react-flow__selection {\n background: var(--xy-selection-background-color, var(--xy-selection-background-color-default));\n border: var(--xy-selection-border, var(--xy-selection-border-default));\n}\n.react-flow__resize-control {\n position: absolute;\n}\n.react-flow__resize-control.left,\n.react-flow__resize-control.right {\n cursor: ew-resize;\n}\n.react-flow__resize-control.top,\n.react-flow__resize-control.bottom {\n cursor: ns-resize;\n}\n.react-flow__resize-control.top.left,\n.react-flow__resize-control.bottom.right {\n cursor: nwse-resize;\n}\n.react-flow__resize-control.bottom.left,\n.react-flow__resize-control.top.right {\n cursor: nesw-resize;\n}\n/* handle styles */\n.react-flow__resize-control.handle {\n width: 5px;\n height: 5px;\n border: 1px solid #fff;\n border-radius: 1px;\n background-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n translate: -50% -50%;\n}\n.react-flow__resize-control.handle.left {\n left: 0;\n top: 50%;\n}\n.react-flow__resize-control.handle.right {\n left: 100%;\n top: 50%;\n}\n.react-flow__resize-control.handle.top {\n left: 50%;\n top: 0;\n}\n.react-flow__resize-control.handle.bottom {\n left: 50%;\n top: 100%;\n}\n.react-flow__resize-control.handle.top.left {\n left: 0;\n}\n.react-flow__resize-control.handle.bottom.left {\n left: 0;\n}\n.react-flow__resize-control.handle.top.right {\n left: 100%;\n}\n.react-flow__resize-control.handle.bottom.right {\n left: 100%;\n}\n/* line styles */\n.react-flow__resize-control.line {\n border-color: var(--xy-resize-background-color, var(--xy-resize-background-color-default));\n border-width: 0;\n border-style: solid;\n}\n.react-flow__resize-control.line.left,\n.react-flow__resize-control.line.right {\n width: 1px;\n transform: translate(-50%, 0);\n top: 0;\n height: 100%;\n}\n.react-flow__resize-control.line.left {\n left: 0;\n border-left-width: 1px;\n}\n.react-flow__resize-control.line.right {\n left: 100%;\n border-right-width: 1px;\n}\n.react-flow__resize-control.line.top,\n.react-flow__resize-control.line.bottom {\n height: 1px;\n transform: translate(0, -50%);\n left: 0;\n width: 100%;\n}\n.react-flow__resize-control.line.top {\n top: 0;\n border-top-width: 1px;\n}\n.react-flow__resize-control.line.bottom {\n border-bottom-width: 1px;\n top: 100%;\n}\n";
|
package/dist/core/html.js
CHANGED
|
@@ -425,7 +425,7 @@ export const blocksHtml = (blocks, ctx = emptyCtx) => {
|
|
|
425
425
|
.filter((h) => h !== "")
|
|
426
426
|
.join("\n");
|
|
427
427
|
};
|
|
428
|
-
//
|
|
428
|
+
// Keep the document outline beside its title in every viewer.
|
|
429
429
|
const inPageTocHtml = (toc, title = "Contents") => {
|
|
430
430
|
if (toc.length === 0) {
|
|
431
431
|
return "";
|
|
@@ -433,12 +433,12 @@ const inPageTocHtml = (toc, title = "Contents") => {
|
|
|
433
433
|
const items = toc
|
|
434
434
|
.map((t) => `<li class="lvl${t.depth}"><a href="#${escapeHtml(t.slug)}" data-toc-target="${escapeHtml(t.slug)}" title="${escapeHtml(t.text)}">${escapeHtml(t.text)}</a></li>`)
|
|
435
435
|
.join("");
|
|
436
|
-
return `<nav class="in-toc" aria-label="${escapeHtml(title)}"><button class="toc-current" type="button" aria-expanded="false">${escapeHtml(toc[0]?.text ?? "")}</button><ul class="toc-options" popover>${items}</ul
|
|
436
|
+
return `<nav class="in-toc" aria-label="${escapeHtml(title)}"><button class="toc-current" type="button" aria-expanded="false">${escapeHtml(toc[0]?.text ?? "")}</button><ul class="toc-options" popover>${items}</ul></nav>`;
|
|
437
437
|
};
|
|
438
438
|
export const docHtml = (fm, blocks, errors, ctx = emptyCtx, toc = []) => {
|
|
439
439
|
const errBox = errors.length > 0
|
|
440
440
|
? `<div class="errors">${errors.map((e) => `<div>${escapeHtml(e)}</div>`).join("")}</div>`
|
|
441
441
|
: "";
|
|
442
442
|
const lang = ctx.lang ? ` lang="${escapeHtml(ctx.lang)}"` : "";
|
|
443
|
-
return `<article${lang}>${errBox}<h1>${escapeHtml(docDisplayName(fm, ""))}</h1>${inPageTocHtml(toc, ctx.tocTitle)}
|
|
443
|
+
return `<article${lang}>${errBox}<header class="doc-title"><h1>${escapeHtml(docDisplayName(fm, ""))}</h1>${inPageTocHtml(toc, ctx.tocTitle)}</header>${blocksHtml(blocks, ctx)}</article>`;
|
|
444
444
|
};
|
package/dist/core/icons.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export declare const FOLDER_ICON_PATH = "M2 5h6l2 2h8v10H2Z";
|
|
2
|
+
export declare const RELOAD_ICON_PATH = "M17 8a7 7 0 1 0 0 5M17 3v5h-5";
|
|
3
|
+
export declare const SEARCH_ICON_PATH = "M14 14l4 4M15 9a6 6 0 1 1-12 0 6 6 0 0 1 12 0";
|
|
1
4
|
export declare const CHECK_ICON = "<svg class=\"ic-ok\" viewBox=\"0 0 20 20\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m4 10 4 4 8-8\"/></svg>";
|
|
2
5
|
export declare const PLUGINS_ICON = "<svg class=\"nav-icon\" viewBox=\"0 0 20 20\" width=\"18\" height=\"18\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m10 2 4 2v5l-4 2-4-2V4Zm-4 2 4 2 4-2m-4 2v5M6 9l-4 2v5l4 2 4-2v-5m-8 0 4 2 4-2m-4 2v5m8-9 4 2v5l-4 2-4-2m0-5 4 2 4-2m-4 2v5\"/></svg>";
|
package/dist/core/icons.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export const FOLDER_ICON_PATH = "M2 5h6l2 2h8v10H2Z";
|
|
2
|
+
export const RELOAD_ICON_PATH = "M17 8a7 7 0 1 0 0 5M17 3v5h-5";
|
|
3
|
+
export const SEARCH_ICON_PATH = "M14 14l4 4M15 9a6 6 0 1 1-12 0 6 6 0 0 1 12 0";
|
|
1
4
|
export const CHECK_ICON = '<svg class="ic-ok" viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 10 4 4 8-8"/></svg>';
|
|
2
5
|
export const PLUGINS_ICON = '<svg class="nav-icon" viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 2v5l-4 2-4-2V4Zm-4 2 4 2 4-2m-4 2v5M6 9l-4 2v5l4 2 4-2v-5m-8 0 4 2 4-2m-4 2v5m8-9 4 2v5l-4 2-4-2m0-5 4 2 4-2m-4 2v5"/></svg>';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatJson: (content: string) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getLanguageService } from "vscode-json-languageservice";
|
|
2
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
+
export const formatJson = (content) => {
|
|
4
|
+
JSON.parse(content);
|
|
5
|
+
const document = TextDocument.create("file:///document.json", "json", 0, content);
|
|
6
|
+
const edits = getLanguageService({}).format(document, undefined, {
|
|
7
|
+
tabSize: 2,
|
|
8
|
+
insertSpaces: true,
|
|
9
|
+
eol: content.includes("\r\n") ? "\r\n" : "\n",
|
|
10
|
+
});
|
|
11
|
+
return TextDocument.applyEdits(document, edits);
|
|
12
|
+
};
|
package/dist/core/routing.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { CompiledDoc } from "./content-types.js";
|
|
2
2
|
/** The minimal doc reference routing needs (a shape CompiledDoc satisfies). */
|
|
3
|
-
export type DocRef = Pick<CompiledDoc, "id" | "parent"
|
|
3
|
+
export type DocRef = Pick<CompiledDoc, "id" | "parent"> & {
|
|
4
|
+
file?: string;
|
|
5
|
+
sourceFile?: string;
|
|
6
|
+
};
|
|
4
7
|
/** Parse `<docId>` (leading/trailing `/` are ignored). undefined if the shape differs. */
|
|
5
8
|
export declare const parseRoutePath: (path: string) => string | undefined;
|
|
6
9
|
/** Document links use paths relative to the docs root and optional heading fragments. */
|
|
@@ -14,7 +17,7 @@ export declare const childrenOf: <D extends DocRef>(docs: readonly D[], parent?:
|
|
|
14
17
|
export declare const ancestorsOf: <D extends DocRef>(docs: readonly D[], id: string) => D[];
|
|
15
18
|
/** DOM anchor id for a heading — namespaced by doc id. */
|
|
16
19
|
export declare const headingAnchor: (docId: string, slug: string) => string;
|
|
17
|
-
/**
|
|
20
|
+
/** File routes cannot shadow API/tool routes; legacy IDs retain hierarchy paths. */
|
|
18
21
|
export declare const docPath: (docs: readonly DocRef[], id: string) => string;
|
|
19
22
|
/** Resolve only the complete hierarchy path; no legacy single-id aliases. */
|
|
20
23
|
export declare const resolveDocPath: (docs: readonly DocRef[], path: string) => string | undefined;
|