@dooc-dev/dooc 0.0.5 → 0.0.7
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 +162 -67
- package/dist/code-worker.global.js +152 -0
- package/dist/code.global.js +101 -101
- package/dist/compiler/bundle-urls.js +2 -0
- package/dist/compiler/check.js +2 -0
- package/dist/compiler/compile.js +13 -3
- package/dist/compiler/dxf.d.ts +1 -0
- package/dist/compiler/dxf.js +81 -0
- package/dist/compiler/export.js +22 -15
- package/dist/compiler/figures.js +39 -10
- package/dist/compiler/files.js +2 -0
- package/dist/compiler/ignored-files.d.ts +2 -0
- package/dist/compiler/ignored-files.js +30 -0
- package/dist/compiler/ops.js +1 -1
- package/dist/compiler/subformat-schema.d.ts +14 -0
- package/dist/compiler/subformat-schema.js +92 -0
- package/dist/compiler/subformats.d.ts +5 -7
- package/dist/compiler/subformats.js +115 -75
- package/dist/core/code-file.js +7 -5
- package/dist/core/code-grammars.d.ts +5 -0
- package/dist/core/code-grammars.js +34 -0
- package/dist/core/content-metadata.d.ts +2 -1
- package/dist/core/content-metadata.js +7 -2
- package/dist/core/content-types.d.ts +1 -1
- package/dist/core/escape-html.d.ts +1 -0
- package/dist/core/escape-html.js +1 -0
- package/dist/core/figure-frame.js +1 -1
- package/dist/core/file-embed.js +7 -3
- package/dist/core/html.d.ts +4 -1
- package/dist/core/html.js +8 -7
- package/dist/core/language.js +5 -2
- package/dist/core/markdown.js +3 -1
- package/dist/core/previewers.d.ts +8 -0
- package/dist/core/previewers.js +2 -0
- package/dist/core/schema-fields.d.ts +13 -0
- package/dist/core/schema-fields.js +175 -0
- package/dist/core/schema-graph-mount.js +26 -3
- package/dist/core/schema-refs.d.ts +8 -0
- package/dist/core/schema-refs.js +82 -0
- package/dist/core/toc-ui.js +1 -1
- package/dist/edit.global.js +266 -285
- package/dist/flow.global.js +1031 -1057
- package/dist/graph/abnfDiagram-S7VZAUFO-GAGCW2J5.js +1 -0
- package/dist/graph/architecture-WOLXFQ4H-AWAC3VBS.js +1 -0
- package/dist/graph/architectureDiagram-YGSQEFNW-WQ7QKSUJ.js +36 -0
- package/dist/graph/blockDiagram-APKKGZFW-H7ZNJMOM.js +140 -0
- package/dist/graph/bpmnIcons-APHXDYXF-EAVPNTFE.js +1 -0
- package/dist/graph/c4Diagram-KJ2TOQU5-3IYS34YL.js +38 -0
- package/dist/graph/chunk-3CJU2RDX.js +1 -0
- package/dist/graph/chunk-3LU66YMI.js +1 -0
- package/dist/graph/chunk-3Y2PDVDE.js +1 -0
- package/dist/graph/chunk-4KILFWYV.js +339 -0
- package/dist/graph/chunk-4QDE4SUK.js +1 -0
- package/dist/graph/chunk-5N2X2DXU.js +1 -0
- package/dist/graph/chunk-5OO6DATX.js +1 -0
- package/dist/graph/chunk-67BPVAXC.js +1 -0
- package/dist/graph/chunk-6CDZONCA.js +1 -0
- package/dist/graph/chunk-7ASYMKN2.js +1 -0
- package/dist/graph/chunk-7JQUFVT4.js +10 -0
- package/dist/graph/chunk-7LSMJ4VU.js +72 -0
- package/dist/graph/chunk-7UKJADAE.js +213 -0
- package/dist/graph/chunk-AARGNXTW.js +32 -0
- package/dist/graph/chunk-ARAJTKOH.js +2 -0
- package/dist/graph/chunk-BOXAA5AP.js +62 -0
- package/dist/graph/chunk-BTMPKSGF.js +1 -0
- package/dist/graph/chunk-BVXT562I.js +1 -0
- package/dist/graph/chunk-DIDARDST.js +1 -0
- package/dist/graph/chunk-EWYECPNJ.js +1 -0
- package/dist/graph/chunk-FD7ZFC7R.js +3 -0
- package/dist/graph/chunk-GF4TOPUK.js +1 -0
- package/dist/graph/chunk-GWYODWCE.js +1 -0
- package/dist/graph/chunk-HKRJKXEE.js +1 -0
- package/dist/graph/chunk-I5LEUF24.js +1 -0
- package/dist/graph/chunk-ICJPOOXG.js +1 -0
- package/dist/graph/chunk-IVZHB6RS.js +135 -0
- package/dist/graph/chunk-JSHWCPFJ.js +1 -0
- package/dist/graph/chunk-JZGXHT3J.js +1 -0
- package/dist/graph/chunk-K4I76XBX.js +14 -0
- package/dist/graph/chunk-LSRL537V.js +88 -0
- package/dist/graph/chunk-LT6LXKCR.js +136 -0
- package/dist/graph/chunk-MPR575IN.js +1 -0
- package/dist/graph/chunk-N44XPVUD.js +15 -0
- package/dist/graph/chunk-NDAMZVXQ.js +1 -0
- package/dist/graph/chunk-O656ZI37.js +1 -0
- package/dist/graph/chunk-PDH25ALM.js +2 -0
- package/dist/graph/chunk-QLS7NIYR.js +2 -0
- package/dist/graph/chunk-QQIGL7OP.js +1 -0
- package/dist/graph/chunk-QYAXYFNI.js +1 -0
- package/dist/graph/chunk-QYTM6GY3.js +1 -0
- package/dist/graph/chunk-RJFVWYCA.js +1 -0
- package/dist/graph/chunk-SCEY3ZPT.js +1 -0
- package/dist/graph/chunk-SQE76S5B.js +1 -0
- package/dist/graph/chunk-WQHTQAFY.js +1 -0
- package/dist/graph/chunk-XQS73SBQ.js +1 -0
- package/dist/graph/chunk-Z4FIZ7CR.js +1 -0
- package/dist/graph/chunk-ZSZXN4BT.js +2 -0
- package/dist/graph/classDiagram-v2-L25IHNXF-HNTCDTNK.js +217 -0
- package/dist/graph/cose-bilkent-JH36ORCC-2GVA7XKO.js +1 -0
- package/dist/graph/cynefin-EF2NZ3EQ-TCI65RAQ.js +1 -0
- package/dist/graph/cynefinDiagram-L36ESFBY-OKQ5BLVF.js +62 -0
- package/dist/graph/dagre-SPEB5RXH-KZEBD52K.js +4 -0
- package/dist/graph/diagram-3B7GL73J-ESCBJM3O.js +200 -0
- package/dist/graph/diagram-DNEMPZML-ZIBUSQZI.js +24 -0
- package/dist/graph/diagram-L3MUGCDN-IGK62IPN.js +41 -0
- package/dist/graph/diagram-LA4NIPWU-2KZCOFJ5.js +24 -0
- package/dist/graph/diagram-MHCOC4E2-EYAAB236.js +3 -0
- package/dist/graph/diagram-XPFHEONP-OZ5ARGMG.js +30 -0
- package/dist/graph/ebnfDiagram-UZSYDL2S-M3XJHARD.js +1 -0
- package/dist/graph/erDiagram-EYBAPDEH-Y7KUBH7A.js +99 -0
- package/dist/graph/eventmodeling-K75KTNOO-ROLYRDEP.js +1 -0
- package/dist/graph/flowDiagram-MALGAFMO-AAUEIPCR.js +1 -0
- package/dist/graph/ganttDiagram-23REXITY-JSBTFSSJ.js +292 -0
- package/dist/graph/gitGraph-VSP46ZUC-ZCBCDVNF.js +1 -0
- package/dist/graph/gitGraphDiagram-STJD7YCW-3ZA5FT3G.js +106 -0
- package/dist/graph/info-OHQRW6UA-JKJGOQNY.js +1 -0
- package/dist/graph/infoDiagram-KBXO4MBG-6LFMPP2O.js +2 -0
- package/dist/graph/ishikawaDiagram-M35NCXHK-YLEU44DY.js +70 -0
- package/dist/graph/journeyDiagram-OPLOXDXO-ZHJV66ZT.js +139 -0
- package/dist/graph/kanban-definition-BZKZHSQY-SDU25WUM.js +89 -0
- package/dist/graph/katex-WSLZOTY7.js +257 -0
- package/dist/graph/mindmap-definition-I2QAS2VK-XQNBCYHN.js +98 -0
- package/dist/graph/packet-JDAUHWVQ-Y3H77ERD.js +1 -0
- package/dist/graph/pegDiagram-FD4XPPHP-YO4VWH6V.js +1 -0
- package/dist/graph/pie-XZMESJXO-PRER4XL5.js +1 -0
- package/dist/graph/pieDiagram-J4AKIIQI-TJ5WOOSV.js +39 -0
- package/dist/graph/quadrantDiagram-XTYBLID2-G6MSSZLW.js +7 -0
- package/dist/graph/radar-ABXABTNO-M6MV34GM.js +1 -0
- package/dist/graph/railroad-I3PHUGI6-YIWPGN6Q.js +1 -0
- package/dist/graph/railroad-abnf-LNEFI6M7-7JHLZ2R7.js +1 -0
- package/dist/graph/railroad-ebnf-DWYD2UWJ-V55BXEWY.js +1 -0
- package/dist/graph/railroad-peg-JR7BVNR7-XCGKDRMK.js +1 -0
- package/dist/graph/railroadDiagram-MRQ6NCDL-RACSFXC4.js +1 -0
- package/dist/graph/requirementDiagram-Y7LWUY3S-4LQIQWHQ.js +84 -0
- package/dist/graph/sankeyDiagram-WGJFYUXA-K3RXG5FB.js +40 -0
- package/dist/graph/schema-graph-global.js +639 -0
- package/dist/graph/sequenceDiagram-5NDRBG5M-Y6RBHRS3.js +169 -0
- package/dist/graph/sizeCapture-INFHLROL-TJW3VUGH.js +1 -0
- package/dist/graph/stateDiagram-v2-FJ4FJNEA-4M5WZORG.js +291 -0
- package/dist/graph/swimlanes-UMQ2AFYF-O4W6U4RO.js +1 -0
- package/dist/graph/swimlanesDiagram-OMPLPG4O-HZAKM45N.js +8 -0
- package/dist/graph/timeline-definition-SEUHKTQE-IHISQ4Q7.js +120 -0
- package/dist/graph/treeView-D4JQ5SDB-EVGY4VYS.js +1 -0
- package/dist/graph/treemap-SAJKECNS-LN3SMFRX.js +1 -0
- package/dist/graph/usecaseDiagram-AFA6YXN4-B645A3J6.js +370 -0
- package/dist/graph/vennDiagram-NNMJR3RB-K3HWMON6.js +34 -0
- package/dist/graph/wardley-7MLQ67FV-RRWOELC6.js +1 -0
- package/dist/graph/wardleyDiagram-S7YFUSEH-DMMWKJEK.js +78 -0
- package/dist/graph/xychartDiagram-GGNKY7IX-K6MUQVXR.js +7 -0
- package/dist/mcp.js +5 -4
- package/dist/plugins.global.js +71 -104
- package/dist/subformats.global.js +6 -112
- package/dist/ui.global.js +75 -108
- package/dist/viewer/build.d.ts +2 -0
- package/dist/viewer/build.js +22 -8
- package/dist/viewer/code-file.js +7 -2
- package/dist/viewer/figure-preview.d.ts +4 -0
- package/dist/viewer/figure-preview.js +54 -0
- package/dist/viewer/hmr.js +4 -3
- package/dist/viewer/lazy-preview.d.ts +2 -0
- package/dist/viewer/lazy-preview.js +43 -0
- package/dist/viewer/locales/eng.json +26 -3
- package/dist/viewer/locales/jpn.json +26 -3
- package/dist/viewer/locales/zho.json +26 -3
- package/dist/viewer/plugin-blocks.js +1 -1
- package/dist/viewer/plugins.js +1 -1
- package/dist/viewer/resource-library.d.ts +1 -1
- package/dist/viewer/resource-library.js +5 -4
- package/dist/viewer/serve.d.ts +2 -1
- package/dist/viewer/serve.js +148 -41
- package/dist/viewer/textfile.d.ts +2 -0
- package/dist/viewer/textfile.js +20 -5
- package/package.json +14 -4
- package/dist/viewer/lazy-graph.d.ts +0 -2
- package/dist/viewer/lazy-graph.js +0 -30
package/dist/viewer/serve.js
CHANGED
|
@@ -18,19 +18,20 @@ import { defaultFilePath, docIconFile, MAX_FILE_UPLOAD_BYTES, parseFileLayout, d
|
|
|
18
18
|
import { createHash } from "node:crypto";
|
|
19
19
|
import { existsSync, mkdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
20
20
|
import { createServer } from "node:http";
|
|
21
|
-
import { dirname, join, resolve } from "node:path";
|
|
21
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
22
22
|
import { fileURLToPath } from "node:url";
|
|
23
23
|
import { parseContentSource } from "../compiler/code-blocks.js";
|
|
24
24
|
import { compileDraft, createCompiler, } from "../compiler/compile.js";
|
|
25
25
|
import { figureName } from "../compiler/figures.js";
|
|
26
26
|
import { ICONS_DIR, squareSvg } from "../compiler/icons.js";
|
|
27
|
-
import { ignoredFiles } from "../compiler/ignored-files.js";
|
|
27
|
+
import { ignoredFiles, withIgnoredFilesCache } from "../compiler/ignored-files.js";
|
|
28
28
|
import { contentLanguageCode, contentLanguages, isContentLanguage, webLanguage, } from "../compiler/language-codes.js";
|
|
29
29
|
import { setDocTranslation, siteContentLanguages, translationFile, translationFiles, } from "../compiler/locales.js";
|
|
30
30
|
import { readManifest, writeManifest } from "../compiler/manifest.js";
|
|
31
31
|
import { assembleDoc, createDocOps, isOpError } from "../compiler/ops.js";
|
|
32
32
|
import { subformatResponse, validateSubformatFile } from "../compiler/subformats.js";
|
|
33
33
|
import { walkBlocks } from "../core/blocks.js";
|
|
34
|
+
import { selectCodeGrammars, subformatCodeGrammars } from "../core/code-grammars.js";
|
|
34
35
|
import { docIdOfFile, flattenTree } from "../core/content-metadata.js";
|
|
35
36
|
import { MAX_EXTENSION_BYTES } from "../core/extension-package.js";
|
|
36
37
|
import { figureFrameHtml, mountFigureFrames } from "../core/figure-frame.js";
|
|
@@ -54,6 +55,7 @@ import { mountBundleNetwork } from "./bundle-network.js";
|
|
|
54
55
|
import { codeFileResponse } from "./code-file.js";
|
|
55
56
|
import { isLocalToolRequest, runCodeTool, validateCodeTools, validateTextfileCode, } from "./editor-tools.js";
|
|
56
57
|
import { createExtensionManager, EXTENSIONS_DIR } from "./extensions.js";
|
|
58
|
+
import { deferredFigureHtml, mountFigurePreviews } from "./figure-preview.js";
|
|
57
59
|
import { fileReferences } from "./file-references.js";
|
|
58
60
|
import { mountFontPickers } from "./font-picker.js";
|
|
59
61
|
import { createFontSettings } from "./font-settings.js";
|
|
@@ -63,7 +65,7 @@ import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
|
|
|
63
65
|
import { createHmrHub, HMR_PATH, hmrClientScript, watchProject } from "./hmr.js";
|
|
64
66
|
import { translate } from "./i18n.js";
|
|
65
67
|
import { DEFAULT_SITE_LANGUAGES, loadSiteLanguages } from "./languages.js";
|
|
66
|
-
import {
|
|
68
|
+
import { loadPreviewScript } from "./lazy-preview.js";
|
|
67
69
|
import { focusNavTree } from "./nav-focus.js";
|
|
68
70
|
import { updateNav } from "./nav-update.js";
|
|
69
71
|
import { loadViewerPlugins } from "./plugin-config.js";
|
|
@@ -110,10 +112,17 @@ let siteLanguages = DEFAULT_SITE_LANGUAGES;
|
|
|
110
112
|
let compiler = createCompiler(root);
|
|
111
113
|
const ops = createDocOps(root);
|
|
112
114
|
/** Compile result → viewer Site (shared by the server's per-request path and one-off publish). */
|
|
113
|
-
export const siteFrom = ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages) => {
|
|
115
|
+
export const siteFrom = ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages, code = {}) => {
|
|
114
116
|
return {
|
|
115
117
|
previews,
|
|
116
118
|
subformats,
|
|
119
|
+
codeLanguages: [
|
|
120
|
+
...new Set([
|
|
121
|
+
...(code.codeLanguages ?? CODE_LANGS),
|
|
122
|
+
...(subformats ?? []).map(({ ext }) => `.${ext}`),
|
|
123
|
+
]),
|
|
124
|
+
],
|
|
125
|
+
codeGrammars: subformatCodeGrammars(code.codeGrammars ?? [], subformats),
|
|
117
126
|
...(contentLanguages ? { contentLanguages } : {}),
|
|
118
127
|
...(themes ? { themes } : {}),
|
|
119
128
|
...(title === undefined ? {} : { title }),
|
|
@@ -159,7 +168,7 @@ const watchEntryTextfiles = (entries) => {
|
|
|
159
168
|
...(entry.referencedFiles ?? []),
|
|
160
169
|
]));
|
|
161
170
|
};
|
|
162
|
-
const loadSite = (locale) => {
|
|
171
|
+
const loadSite = (locale) => withIgnoredFilesCache(() => {
|
|
163
172
|
const previews = applicationPreviews;
|
|
164
173
|
const manifest = readManifest(root);
|
|
165
174
|
const source = contentLanguageCode(manifest.defaultLang ?? DEFAULT_LANG);
|
|
@@ -169,7 +178,7 @@ const loadSite = (locale) => {
|
|
|
169
178
|
selected = localeCompilers.get(locale) ?? createCompiler(root, { locale, previews });
|
|
170
179
|
localeCompilers.set(locale, selected);
|
|
171
180
|
}
|
|
172
|
-
const site = siteFrom(selected.compile(), siteLanguages.languages);
|
|
181
|
+
const site = siteFrom(selected.compile(), siteLanguages.languages, siteLanguages);
|
|
173
182
|
const sourceLanguage = contentLanguageCode(site.defaultLang);
|
|
174
183
|
for (const entry of site.entries) {
|
|
175
184
|
entry.translatedLanguages = [sourceLanguage];
|
|
@@ -190,22 +199,21 @@ const loadSite = (locale) => {
|
|
|
190
199
|
watchEntryTextfiles(site.entries);
|
|
191
200
|
watchTextfiles?.([manifest.icon, ...Object.values(manifest.themeIcons ?? {})].filter((file) => !!file));
|
|
192
201
|
const workspace = workspaceSource ?? readWorkspaceSource(root);
|
|
193
|
-
const subformats = site.entries.flatMap((entry) =>
|
|
202
|
+
const subformats = site.entries.flatMap((entry) => entry.subformat ? [entry.subformat] : []);
|
|
194
203
|
if (workspace?.protocol === "git" && subformats.length)
|
|
195
204
|
setSubformatChanges(root, subformats);
|
|
196
205
|
return {
|
|
197
206
|
...site,
|
|
207
|
+
ctx: { ...site.ctx, figurePreview: deferredFigureHtml },
|
|
198
208
|
fonts: loadProjectFonts(root),
|
|
199
209
|
workspace,
|
|
200
210
|
sourceBase: sourceFileBase(root),
|
|
201
211
|
filePaths: manifest.errors.length
|
|
202
212
|
? undefined
|
|
203
213
|
: filesSnapshot(root).files.map((file) => file.path),
|
|
204
|
-
codeLanguages: siteLanguages.codeLanguages,
|
|
205
|
-
codeGrammars: siteLanguages.codeGrammars,
|
|
206
214
|
contentLanguage: locale,
|
|
207
215
|
};
|
|
208
|
-
};
|
|
216
|
+
});
|
|
209
217
|
const draftContext = (site) => ({
|
|
210
218
|
previews: site.previews,
|
|
211
219
|
root,
|
|
@@ -316,7 +324,8 @@ export const renderEntryHtml = (site, entry) => {
|
|
|
316
324
|
if (cached &&
|
|
317
325
|
cached.blocks === entry.blocks &&
|
|
318
326
|
cached.sig === sig &&
|
|
319
|
-
cached.figures === site.ctx.figures
|
|
327
|
+
cached.figures === site.ctx.figures &&
|
|
328
|
+
cached.figurePreview === site.ctx.figurePreview) {
|
|
320
329
|
return cached.value;
|
|
321
330
|
}
|
|
322
331
|
const value = {
|
|
@@ -327,6 +336,7 @@ export const renderEntryHtml = (site, entry) => {
|
|
|
327
336
|
blocks: entry.blocks,
|
|
328
337
|
sig,
|
|
329
338
|
figures: site.ctx.figures,
|
|
339
|
+
figurePreview: site.ctx.figurePreview,
|
|
330
340
|
value,
|
|
331
341
|
});
|
|
332
342
|
return value;
|
|
@@ -558,7 +568,8 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
|
|
|
558
568
|
.search-status:empty { display: none; }
|
|
559
569
|
.search-count { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
|
|
560
570
|
clip-path: inset(50%); white-space: nowrap; }
|
|
561
|
-
#doc-search-results {
|
|
571
|
+
#doc-search-results { position: relative; z-index: 1; overflow-y: auto; overscroll-behavior: contain;
|
|
572
|
+
scrollbar-gutter: stable; margin-right: -8px; padding-right: 8px;
|
|
562
573
|
min-height: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
563
574
|
#doc-search-results:not(:empty) { margin-top: 6px; }
|
|
564
575
|
#doc-search-results a { display: flex; flex: none; flex-direction: column; gap: 6px;
|
|
@@ -589,7 +600,7 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
|
|
|
589
600
|
align-self: flex-start; width: 320px; min-width: 240px; height: 100vh; min-height: 0; max-height: none; margin: 0;
|
|
590
601
|
padding: 8px 10px 10px; border: 0; border-left: 1px solid var(--c-line); border-radius: 0;
|
|
591
602
|
background: var(--c-bg1); box-shadow: none; backdrop-filter: none; }
|
|
592
|
-
.search-docked #doc-search-results { margin-right: -
|
|
603
|
+
.search-docked #doc-search-results { margin-right: -10px; padding-right: 10px; }
|
|
593
604
|
/* Keep the preview readable; the editor panel gives up width before the search sidebar does. */
|
|
594
605
|
body:has(#doc-search.search-docked[open]) main { min-width: 240px; }
|
|
595
606
|
body:has(#doc-search.search-docked[open]) #panel { flex-shrink: 100; min-width: 240px; }
|
|
@@ -784,6 +795,7 @@ body.files-over #nav-files { background: color-mix(in srgb, var(--c-accent) 10%,
|
|
|
784
795
|
|
|
785
796
|
/* ── main (document body) ── */
|
|
786
797
|
main { flex: 1; min-width: 0; padding: 20px 24px 50vh; }
|
|
798
|
+
main:not(.editor-workspace) { height: 100vh; overflow: auto; overscroll-behavior: contain; }
|
|
787
799
|
article { max-width: 860px; margin: 0 auto; font-family: var(--viewer-font, system-ui, sans-serif); }
|
|
788
800
|
.external-embed { margin: 18px 0; overflow-wrap: anywhere; }
|
|
789
801
|
.plugin { position: relative; min-width: 0; border: 2px solid var(--doc-border); border-top: 0; }
|
|
@@ -914,6 +926,10 @@ pre code.code-foldable { display: block; padding-left: 18px; }
|
|
|
914
926
|
.video-player [hidden] { display: none; }
|
|
915
927
|
@container (max-width: 420px) { .video-controls .video-volume { display: none; } }
|
|
916
928
|
.fig-frame { display: block; max-width: 100%; border: 0; background: transparent; }
|
|
929
|
+
.figure-placeholder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 120px; padding: 20px; border: 1px solid var(--doc-border); background: var(--doc-bg-2); color: var(--doc-fg-2); overflow-wrap: anywhere; }
|
|
930
|
+
.figure-placeholder button { font: inherit; padding: 6px 12px; border: 1px solid var(--doc-border); border-radius: 4px; background: var(--doc-bg); color: var(--doc-fg); cursor: pointer; }
|
|
931
|
+
.figure-placeholder button:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: 2px; }
|
|
932
|
+
.figure-placeholder button:disabled { cursor: wait; }
|
|
917
933
|
/* Code and file blocks share a border label; clicking it collapses the content. */
|
|
918
934
|
.codeblk { position: relative; margin: 12px 0; border: 2px solid var(--doc-border); border-top: 0; }
|
|
919
935
|
.codeblk > pre { margin: 0; background: transparent; padding: 8px 12px 6px; }
|
|
@@ -1166,6 +1182,11 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1166
1182
|
.subformat-picker-menu button { display: block; width: 100%; padding: 7px 10px; border: 0; background: transparent; color: var(--c-fg); font: inherit; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
|
|
1167
1183
|
.subformat-picker-menu button:is(:hover, :focus-visible, [aria-checked="true"]) { background: var(--c-raised); outline: none; }
|
|
1168
1184
|
.subformat-picker-menu [data-subformat-add] { margin-top: 4px; border-top: 1px solid var(--c-line); font-size: 13px; }
|
|
1185
|
+
.subformat-picker-option { display: flex; }
|
|
1186
|
+
.subformat-picker-option > button:first-child { flex: 1; min-width: 0; }
|
|
1187
|
+
.subformat-picker-option > [data-subformat-action] { flex: none; display: grid; place-items: center; width: 32px; padding: 0; }
|
|
1188
|
+
.subformat-picker-option > [data-subformat-action="delete"] { color: var(--c-danger); }
|
|
1189
|
+
.subformat-picker-option > button:disabled { opacity: .55; cursor: default; }
|
|
1169
1190
|
|
|
1170
1191
|
.resource-results [data-subformat-change="added"] { color: var(--c-ok); }
|
|
1171
1192
|
.resource-results [data-subformat-change="modified"] { color: var(--c-accent); }
|
|
@@ -1200,11 +1221,11 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1200
1221
|
font: 13px/1.5 var(--font-sans); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1201
1222
|
.subformat-columns { display: flex; flex: 1; gap: 20px; min-width: 0; overflow-x: auto; padding: 16px 2px 12px; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
|
|
1202
1223
|
.subformat-column { display: flex; flex-direction: column; flex: 1 0 248px; min-width: 0; }
|
|
1203
|
-
.subformat-cards { flex: 1; min-height: 100px; border-radius: 6px; }
|
|
1224
|
+
.subformat-cards { flex: 1; min-height: 100px; border-radius: 6px; transition: background-color 100ms ease-out; }
|
|
1204
1225
|
.subformat-cards.is-drop-target { background: var(--c-raised); }
|
|
1205
1226
|
.subformat-column > h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 0 2px 10px; border-bottom: 1px solid var(--c-line); color: var(--c-fg); font: 500 12px/20px var(--font-sans); overflow-wrap: anywhere; }
|
|
1206
1227
|
.subformat-count > span { flex: none; min-width: 10px; padding: 0 5px; border-radius: 4px; background: var(--c-raised); color: var(--c-fg-muted); font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
|
|
1207
|
-
.subformat-card { max-width: none; margin: 0 0 12px; padding: 14px; border: 1px solid var(--c-line); border-radius: 6px; background:
|
|
1228
|
+
.subformat-card { max-width: none; margin: 0 0 12px; padding: 14px; border: 1px solid var(--c-line); border-radius: 6px; background: transparent; color: var(--c-fg); font-family: var(--font-sans); overflow-wrap: anywhere; }
|
|
1208
1229
|
.subformat-card:hover, .subformat-card:focus-within { border-color: var(--c-fg-faint); }
|
|
1209
1230
|
.subformat-count { display: inline-flex; align-items: center; gap: 4px; }
|
|
1210
1231
|
.resource-results [data-record-change="added"] { --record-color: var(--c-ok); }
|
|
@@ -1221,14 +1242,14 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1221
1242
|
.subformat-create-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1222
1243
|
.subformat-card[draggable="true"] { cursor: grab; user-select: none; }
|
|
1223
1244
|
.subformat-card[draggable="true"] :is(.subformat-card-open, .subformat-card-toggle) { cursor: inherit; }
|
|
1224
|
-
.subformat-card.is-dragging {
|
|
1225
|
-
.subformat-card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; box-sizing: border-box; width: fit-content; max-width: 100%; height: 20px; margin: -25px -4px 8px auto; padding: 0 6px; background: var(--c-
|
|
1245
|
+
.subformat-card.is-dragging { visibility: hidden; }
|
|
1246
|
+
.subformat-card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; box-sizing: border-box; width: fit-content; max-width: 100%; height: 20px; margin: -25px -4px 8px auto; padding: 0 6px; background: var(--c-bg1); }
|
|
1226
1247
|
.subformat-card h3 { min-width: 0; margin: 0; font-size: 13px; line-height: 1.55; }
|
|
1227
1248
|
.subformat-card-open, .subformat-card-toggle, .subformat-card-copy { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
|
|
1228
1249
|
.subformat-card :focus-visible { outline-color: var(--c-fg-muted); }
|
|
1229
1250
|
.subformat-card .subformat-card-open:focus { outline: none; }
|
|
1230
1251
|
.subformat-card-open:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
|
|
1231
|
-
.subformat-card-open
|
|
1252
|
+
.subformat-card-open { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: left; font-weight: 500; overflow-wrap: anywhere; }
|
|
1232
1253
|
.subformat-card-toggle, .subformat-card-copy { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin: 0; border-radius: 4px; color: var(--c-fg-muted); }
|
|
1233
1254
|
.subformat-card-toggle:hover, .subformat-card-copy:hover { background: var(--c-raised); color: var(--c-fg); }
|
|
1234
1255
|
.subformat-card-copy .ic-ok, .subformat-card-copy[data-copied] svg:not(.ic-ok) { display: none; }
|
|
@@ -1236,7 +1257,6 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1236
1257
|
.subformat-card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
|
|
1237
1258
|
.subformat-card .subformat-card-file { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-fg-faint); font-family: var(--doc-mono); font-size: 11px; }
|
|
1238
1259
|
.subformat-card-tools .subformat-card-file { flex: 1; max-width: 170px; }
|
|
1239
|
-
.subformat-drag-preview .subformat-card-file { margin-top: 6px; }
|
|
1240
1260
|
.subformat-card-references { padding: 2px 0; border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--record-color, var(--c-fg-faint)); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
1241
1261
|
.subformat-card-references:disabled { cursor: default; }
|
|
1242
1262
|
.subformat-reference-list { position: fixed; margin: 0; box-sizing: border-box; width: min(320px, calc(100vw - 16px)); padding: 4px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); color: var(--c-fg); overflow-y: auto; font: 12px/1.6 var(--font-sans); }
|
|
@@ -1257,8 +1277,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1257
1277
|
.subformat-card-details dd, .subformat-detail dd { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1258
1278
|
.subformat-card-details label { margin-top: 12px; }
|
|
1259
1279
|
.subformat-card [hidden] { display: none; }
|
|
1260
|
-
.subformat-drag-preview { position: fixed;
|
|
1261
|
-
.subformat-drag-preview strong { font-size: 13px; }
|
|
1280
|
+
.subformat-drag-preview { position: fixed; z-index: 1000; box-sizing: border-box; pointer-events: none; background: var(--c-bg1); will-change: transform; }
|
|
1262
1281
|
.app-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
|
|
1263
1282
|
color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 90%, transparent);
|
|
1264
1283
|
border: 1px solid var(--c-fg-faint); border-radius: 10px; box-shadow: 0 16px 48px #0004; backdrop-filter: blur(16px); }
|
|
@@ -1317,6 +1336,7 @@ body:not(.edit) .subformat-page { padding-top: 64px; }
|
|
|
1317
1336
|
// (autosave / correspondence display / fm visibility) are gathered in the header gear's hover
|
|
1318
1337
|
// menu. Width is drag-resizable.
|
|
1319
1338
|
const EDIT_CSS = `
|
|
1339
|
+
body.line-wrap-off .cm-content { white-space: pre; }
|
|
1320
1340
|
body.git-diff-hidden .cm-lineNumbers :is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { box-shadow: none; }
|
|
1321
1341
|
body.git-diff-hidden .cm-line:is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { background-color: transparent; }
|
|
1322
1342
|
#site-title[role="button"] { cursor: text; position: relative; }
|
|
@@ -1346,8 +1366,8 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
|
|
|
1346
1366
|
#file-editor .cm-textfile-status { padding: 8px 12px; white-space: pre-wrap; }
|
|
1347
1367
|
#file-editor .cm-textfile-status[hidden] { display: none; }
|
|
1348
1368
|
#file-editor .cm-textfile-status.error { color: var(--doc-danger); }
|
|
1349
|
-
#file-editor[data-subformat-register] { position: static; width: auto; max-height: none; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
|
|
1350
|
-
#file-editor[data-subformat-register] fieldset { display: flex; flex-direction: column; flex: 1; min-height: 0; }
|
|
1369
|
+
#file-editor:is([data-subformat-register], [data-subformat-record]) { position: static; width: auto; max-height: none; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
|
|
1370
|
+
#file-editor:is([data-subformat-register], [data-subformat-record]) fieldset { display: flex; flex-direction: column; flex: 1; min-height: 0; }
|
|
1351
1371
|
.subformat-register-fields { display: grid; flex: 1; min-width: 0; grid-template-columns: minmax(36px, .5fr) 60px minmax(50px, 1.5fr); gap: 6px; margin: 0; padding: 0; border: 0; }
|
|
1352
1372
|
.subformat-register-fields :is(input, select) { width: 100%; min-width: 0; height: 28px; padding: 4px; background: transparent; color: var(--c-fg); border: 0; border-bottom: 1px solid var(--c-line); border-radius: 0; font: 12px/18px var(--font-sans); }
|
|
1353
1373
|
.subformat-register-fields input:hover, .subformat-register-fields input:focus-visible { background: transparent; outline: none; border-bottom-color: var(--c-fg-muted); }
|
|
@@ -1357,13 +1377,14 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
|
|
|
1357
1377
|
.subformat-register-fields .language-select-input { height: 24px; padding: 4px 18px 1px 6px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); font-size: 11px; line-height: 16px; }
|
|
1358
1378
|
.subformat-register-fields .language-select::after { right: 6px; top: 9px; width: 4px; height: 4px; }
|
|
1359
1379
|
.subformat-register-fields :disabled { opacity: .5; }
|
|
1380
|
+
.subformat-register-fields > input[name="file"] { grid-column: 1 / -1; }
|
|
1360
1381
|
.subformat-register-fields input::placeholder { color: var(--c-fg-muted); opacity: 1; }
|
|
1361
1382
|
.subformat-register-fields input[name="schema"]:not([placeholder="path"])::placeholder { opacity: .55; }
|
|
1362
1383
|
#phead:has(.subformat-register-fields) { padding-inline: 6px; }
|
|
1363
1384
|
.file-editor-heading:has(.subformat-register-fields) { gap: 4px; margin-left: 2px; }
|
|
1364
1385
|
[data-subformat-schema-editor] { flex: 1; min-height: 0; }
|
|
1365
|
-
#file-editor[data-subformat-register] .subformat-create-actions { flex: none; padding: 10px 14px; border-top: 1px solid var(--c-line); }
|
|
1366
|
-
#file-editor[data-subformat-register] [hidden] { display: none; }
|
|
1386
|
+
#file-editor:is([data-subformat-register], [data-subformat-record]) .subformat-create-actions { flex: none; padding: 10px 14px; border-top: 1px solid var(--c-line); }
|
|
1387
|
+
#file-editor:is([data-subformat-register], [data-subformat-record]) [hidden] { display: none; }
|
|
1367
1388
|
.schema-editor-host { display: flex; flex-direction: column; min-height: 0; }
|
|
1368
1389
|
.schema-editor-host > .cm-editor { flex: 1; min-height: 0; }
|
|
1369
1390
|
.schema-editor-host > [hidden] { display: none !important; }
|
|
@@ -1389,7 +1410,9 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
|
|
|
1389
1410
|
.schema-builder button:disabled { opacity: .45; cursor: default; }
|
|
1390
1411
|
.schema-field { position: relative; min-width: 0; }
|
|
1391
1412
|
.schema-builder > :is(.schema-field, .schema-add-field, .schema-draft-details) { max-width: 560px; }
|
|
1392
|
-
.schema-builder > .schema-field { margin-bottom:
|
|
1413
|
+
.schema-builder > .schema-field { margin-bottom: 12px; }
|
|
1414
|
+
.schema-root-settings { max-width: 560px; margin-block: 12px; }
|
|
1415
|
+
.schema-root-settings > summary { cursor: pointer; }
|
|
1393
1416
|
.schema-field-row, .schema-add-field { position: relative; display: grid; grid-template-columns: minmax(0, 260px) 112px minmax(128px, 1fr); align-items: center; gap: 8px; padding: 6px 0 2px; }
|
|
1394
1417
|
.schema-field-name { display: flex; align-items: center; gap: 2px; min-width: 0; }
|
|
1395
1418
|
.schema-field-name > :first-child { flex: 1; min-width: 0; }
|
|
@@ -1413,18 +1436,19 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
|
|
|
1413
1436
|
.schema-parameter-menu { width: 184px; overflow-y: auto; }
|
|
1414
1437
|
.schema-parameter-menu .language-options button { height: auto; min-height: 28px; width: 100%; display: block; padding: 5px 8px; text-align: left; }
|
|
1415
1438
|
.schema-parameter-menu .language-options button:focus-visible { background: var(--c-raised); outline: none; }
|
|
1416
|
-
.schema-parameter-group { margin:
|
|
1439
|
+
.schema-parameter-group { margin: 10px 0 16px 24px; }
|
|
1417
1440
|
.schema-parameter { display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 2px; min-width: 0; grid-column: 1 / -1; }
|
|
1418
1441
|
.schema-parameter[data-schema-bound="min"] { grid-column: 1; }
|
|
1419
1442
|
.schema-parameter[data-schema-bound="max"] { grid-column: 2; }
|
|
1420
1443
|
.schema-parameter label { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 8px; }
|
|
1421
1444
|
.schema-parameter label > span { overflow-wrap: anywhere; }
|
|
1445
|
+
.schema-parameter-help { grid-column: 1 / -1; color: var(--c-fg-muted); overflow-wrap: anywhere; }
|
|
1422
1446
|
.schema-parameter label:has(> textarea) { align-items: start; }
|
|
1423
1447
|
.schema-parameter label:has(> input[type="checkbox"]) { display: flex; flex-direction: row-reverse; align-items: center; justify-content: flex-end; gap: 8px; min-height: 28px; cursor: pointer; }
|
|
1424
1448
|
.schema-parameter > button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--c-fg-muted); }
|
|
1425
1449
|
.schema-parameter:has(textarea) > button { align-self: start; }
|
|
1426
1450
|
.schema-builder [hidden] { display: none; }
|
|
1427
|
-
.schema-
|
|
1451
|
+
.schema-parameters { display: grid; gap: 6px; }
|
|
1428
1452
|
.schema-parameter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
|
|
1429
1453
|
.schema-parameter-row:not(.schema-range) > .schema-parameter { grid-column: 1 / -1; }
|
|
1430
1454
|
.schema-range { grid-template-columns: minmax(0, 1fr) minmax(48px, .7fr) minmax(0, 1fr); align-items: center; }
|
|
@@ -1456,6 +1480,25 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
|
|
|
1456
1480
|
.subformat-value-form fieldset { min-width: 0; margin: 12px 0; padding: 0 12px; border: 1px solid var(--c-line); }
|
|
1457
1481
|
.subformat-value-form legend { padding-inline: 4px; }
|
|
1458
1482
|
.subformat-value-form small { overflow-wrap: anywhere; }
|
|
1483
|
+
.date-control { position: relative; }
|
|
1484
|
+
.schema-builder .date-control > input { padding-right: 34px; font-variant-numeric: tabular-nums; }
|
|
1485
|
+
.schema-builder .date-trigger { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 30px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--c-fg-muted); }
|
|
1486
|
+
.schema-builder .date-picker { box-sizing: border-box; width: min(272px, calc(100vw - 16px)); padding: 10px; overflow-y: auto; }
|
|
1487
|
+
.date-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
|
|
1488
|
+
.date-picker-header > span { color: var(--c-fg); font-weight: 500; }
|
|
1489
|
+
.schema-builder .date-picker button { display: grid; place-items: center; height: 32px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--c-fg); font: inherit; font-variant-numeric: tabular-nums; }
|
|
1490
|
+
.schema-builder .date-picker button:is(:hover, :focus-visible) { background: var(--c-raised); }
|
|
1491
|
+
.schema-builder .date-picker button:focus-visible { outline: 1px solid var(--c-accent); outline-offset: -1px; }
|
|
1492
|
+
.date-picker-header button { width: 32px; }
|
|
1493
|
+
.date-picker table { width: 100%; margin: 0; border: 0; border-collapse: collapse; table-layout: fixed; }
|
|
1494
|
+
.date-picker :is(th, td) { padding: 0; border: 0; text-align: center; }
|
|
1495
|
+
.date-picker th { height: 28px; color: var(--c-fg-muted); font-size: 11px; font-weight: inherit; }
|
|
1496
|
+
.date-picker td button { position: relative; width: 100%; }
|
|
1497
|
+
.schema-builder .date-picker [data-outside="true"] { color: var(--c-fg-muted); }
|
|
1498
|
+
.schema-builder .date-picker [aria-selected="true"] button { background: var(--c-raised); box-shadow: inset 0 0 0 1px var(--c-accent); }
|
|
1499
|
+
.date-picker [aria-current="date"]::after { content: ""; position: absolute; bottom: 3px; width: 3px; height: 3px; border-radius: 50%; background: var(--c-accent); }
|
|
1500
|
+
.date-picker-footer { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--c-line); }
|
|
1501
|
+
.schema-builder .date-picker-footer button { padding-inline: 8px; color: var(--c-fg-muted); }
|
|
1459
1502
|
@container(max-width:440px) { .schema-field-row, .schema-add-field { grid-template-columns: minmax(0, 1fr) 128px; } .schema-field-row > :first-child, .schema-add-field > :first-child { grid-column: 1 / -1; } }
|
|
1460
1503
|
@container(max-width:440px) { .schema-add-field { grid-template-columns: minmax(0, 1fr) auto; } }
|
|
1461
1504
|
@container(max-width:440px) { .schema-range { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; } .schema-range [data-schema-bound="max"] { grid-column: 2; } .schema-range > .schema-range-track { grid-column: 1 / -1; grid-row: 2; } .schema-range .schema-parameter label { grid-template-columns: minmax(0, 1fr); gap: 0; } }
|
|
@@ -1902,7 +1945,7 @@ const resourcePreview = (site, r) => {
|
|
|
1902
1945
|
// embedded the theme).
|
|
1903
1946
|
return f.kind === "image"
|
|
1904
1947
|
? f.markup.replace("<img ", '<img class="res-img" ')
|
|
1905
|
-
: figureFrameHtml(f, `fig-frame res-${f.kind}`);
|
|
1948
|
+
: (site.ctx.figurePreview ?? figureFrameHtml)(f, `fig-frame res-${f.kind}`);
|
|
1906
1949
|
}
|
|
1907
1950
|
const e = site.entries.find((x) => `${x.id}.svg` === r.file);
|
|
1908
1951
|
return e?.icon ? svgImg(e.icon, "res-img res-icon") : "";
|
|
@@ -1950,7 +1993,7 @@ export const textfilePreviewHtml = (site, file, source) => {
|
|
|
1950
1993
|
export const textfilePreviewErrors = (site, file, source) => {
|
|
1951
1994
|
const errors = textfilePreview(site, file, source).errors;
|
|
1952
1995
|
try {
|
|
1953
|
-
validateSubformatFile(root, file, source);
|
|
1996
|
+
validateSubformatFile(root, file, source, site.previews?.domains);
|
|
1954
1997
|
}
|
|
1955
1998
|
catch (error) {
|
|
1956
1999
|
errors.push(error instanceof Error ? error.message : String(error));
|
|
@@ -2002,7 +2045,7 @@ export const resourcesMain = (site, rest) => {
|
|
|
2002
2045
|
kind === "urls" ||
|
|
2003
2046
|
kind === "url-previews" ||
|
|
2004
2047
|
kind === "_subformats")) {
|
|
2005
|
-
const index = resourceIndex(root, site.filePaths ?? filesSnapshot(root).files.map((item) => item.path));
|
|
2048
|
+
const index = resourceIndex(root, site.filePaths ?? filesSnapshot(root).files.map((item) => item.path), site.previews?.domains);
|
|
2006
2049
|
if (site.workspace?.protocol === "git" && index.subformats.length)
|
|
2007
2050
|
setSubformatChanges(root, index.subformats);
|
|
2008
2051
|
return {
|
|
@@ -2142,9 +2185,9 @@ const page = (mode, site, opts) => {
|
|
|
2142
2185
|
: `<main><div class="page-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("viewer")}</div>${opts.main}</main>`;
|
|
2143
2186
|
const graphScript = opts.publish
|
|
2144
2187
|
? `<script>${inlineScript(opts.publish.graphJs)}</script>`
|
|
2145
|
-
: `<script>(${
|
|
2188
|
+
: `<script>(${loadPreviewScript.toString()})("/assets/graph.js", "svg[data-sg-layout], [data-mermaid]", "module");</script>`;
|
|
2146
2189
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8">
|
|
2147
|
-
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline' data:; img-src data: blob:; media-src data: blob:; font-src data: blob:; frame-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'">`}` : ""}
|
|
2190
|
+
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline' data:; img-src data: blob:; media-src data: blob:; object-src data:; font-src data: blob:; frame-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'">`}` : ""}
|
|
2148
2191
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2149
2192
|
<title>${escapeHtml(pageTitle(mode, opts.title, site.title))}</title>
|
|
2150
2193
|
<script>var __name = (f) => f;
|
|
@@ -2157,8 +2200,8 @@ ${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="
|
|
|
2157
2200
|
(${mountThemeVariants.toString()})(document);
|
|
2158
2201
|
</script>
|
|
2159
2202
|
${bootScripts}${graphScript}
|
|
2160
|
-
<script id="code-grammars" type="application/json">${JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c")}</script>
|
|
2161
|
-
${opts.publish ? `<script>${inlineScript(opts.publish.codeJs)}</script>` :
|
|
2203
|
+
<script id="code-grammars" type="application/json"${opts.publish ? "" : ' data-src="/assets/code-grammars.json"'}>${opts.publish ? JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c") : "[]"}</script>
|
|
2204
|
+
${opts.publish ? `<script>${inlineScript(opts.publish.codeJs)}</script>` : `<script>(${loadPreviewScript.toString()})("/assets/code.js", ".codeblk");</script>`}
|
|
2162
2205
|
<script>
|
|
2163
2206
|
// Functions toString'd under tsx (esbuild keepNames) contain __name(...) calls; define a no-op.
|
|
2164
2207
|
var __name = (f) => f;
|
|
@@ -2168,6 +2211,7 @@ const localeFetch = (url, init = {}) => fetch(url, { ...init, headers: { ...init
|
|
|
2168
2211
|
(${mountTables.toString()})(document);
|
|
2169
2212
|
(${mountToc.toString()})(document);
|
|
2170
2213
|
(${mountVideos.toString()})(document);
|
|
2214
|
+
${opts.publish ? "" : `(${mountFigurePreviews.toString()})();`}
|
|
2171
2215
|
void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.stringify(site.fonts ?? []).replace(/</g, "\\u003c")});
|
|
2172
2216
|
(() => {
|
|
2173
2217
|
const KEY = "docs:sidebar-open";
|
|
@@ -2771,7 +2815,7 @@ const publishRouterScript = (first) => `
|
|
|
2771
2815
|
(${focusNavTree.toString()})(document.getElementById("nav-groups"));
|
|
2772
2816
|
const target = anchor && document.getElementById(anchor);
|
|
2773
2817
|
requestAnimationFrame(() => {
|
|
2774
|
-
if (target) target.scrollIntoView(); else
|
|
2818
|
+
if (target) target.scrollIntoView(); else main.scrollTo(0, 0);
|
|
2775
2819
|
});
|
|
2776
2820
|
};
|
|
2777
2821
|
window.addEventListener("hashchange", show);
|
|
@@ -2905,6 +2949,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
2905
2949
|
<label><input type="checkbox" id="opt-autosave"><span data-i18n="Auto save">Auto save</span></label>
|
|
2906
2950
|
<label><input type="checkbox" id="opt-corr"><span data-i18n="Source mapping">Source mapping</span></label>
|
|
2907
2951
|
<label><input type="checkbox" id="opt-git-diff"><span data-i18n="Show Git changes">Show Git changes</span></label>
|
|
2952
|
+
<label><input type="checkbox" id="opt-line-wrap" checked><span data-i18n="Wrap lines">Wrap lines</span></label>
|
|
2908
2953
|
</div></div>
|
|
2909
2954
|
</div>
|
|
2910
2955
|
|
|
@@ -3271,6 +3316,7 @@ const PREBUILT = {
|
|
|
3271
3316
|
"viewer/edit-client.ts": "edit.global.js",
|
|
3272
3317
|
"viewer/ui-client.ts": "ui.global.js",
|
|
3273
3318
|
"viewer/code-highlight.ts": "code.global.js",
|
|
3319
|
+
"viewer/code-worker.ts": "code-worker.global.js",
|
|
3274
3320
|
"viewer/published-plugins.ts": "plugins.global.js",
|
|
3275
3321
|
"viewer/published-subformats.ts": "subformats.global.js",
|
|
3276
3322
|
};
|
|
@@ -3312,6 +3358,33 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
3312
3358
|
// invalidate explicitly on the watcher's "client" notification (changes to edit-client.ts /
|
|
3313
3359
|
// the schema graph interaction layer's src/*.tsx).
|
|
3314
3360
|
const bundleCache = createBundleCache();
|
|
3361
|
+
let graphChunks;
|
|
3362
|
+
const graphAsset = async (name) => {
|
|
3363
|
+
if (usePrebuiltAssets)
|
|
3364
|
+
return readViewerAsset(`graph/${name}`).toString("utf8");
|
|
3365
|
+
graphChunks ??= import("esbuild")
|
|
3366
|
+
.then(async (esbuild) => {
|
|
3367
|
+
const output = await esbuild.build({
|
|
3368
|
+
entryPoints: [join(pkgRoot, "src/core/schema-graph-global.tsx")],
|
|
3369
|
+
bundle: true,
|
|
3370
|
+
splitting: true,
|
|
3371
|
+
format: "esm",
|
|
3372
|
+
target: "es2022",
|
|
3373
|
+
outdir: join(pkgRoot, "dist/graph"),
|
|
3374
|
+
write: false,
|
|
3375
|
+
minify: true,
|
|
3376
|
+
});
|
|
3377
|
+
return new Map(output.outputFiles.map((file) => [basename(file.path), file.text]));
|
|
3378
|
+
})
|
|
3379
|
+
.catch((error) => {
|
|
3380
|
+
graphChunks = undefined;
|
|
3381
|
+
throw error;
|
|
3382
|
+
});
|
|
3383
|
+
const js = (await graphChunks).get(name);
|
|
3384
|
+
if (js === undefined)
|
|
3385
|
+
throw new Error("Diagram asset not found");
|
|
3386
|
+
return js;
|
|
3387
|
+
};
|
|
3315
3388
|
// HMR — bootId changes on every process start. It's how the client detects a tsx watch
|
|
3316
3389
|
// restart.
|
|
3317
3390
|
const hub = createHmrHub(`${process.pid}-${Date.now()}`);
|
|
@@ -3358,6 +3431,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
3358
3431
|
console.log(`hmr: ${kind} (${files.join(", ")})`);
|
|
3359
3432
|
if (kind === "client") {
|
|
3360
3433
|
bundleCache.clear();
|
|
3434
|
+
graphChunks = undefined;
|
|
3361
3435
|
}
|
|
3362
3436
|
hub.broadcast(kind, files);
|
|
3363
3437
|
});
|
|
@@ -3404,15 +3478,22 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
3404
3478
|
// preview / edit, edit.js is for the editing UI only.
|
|
3405
3479
|
const clientEntry = path === "/assets/code.js"
|
|
3406
3480
|
? "viewer/code-highlight.ts"
|
|
3407
|
-
: path === "/assets/
|
|
3408
|
-
? "
|
|
3481
|
+
: path === "/assets/code-worker.js"
|
|
3482
|
+
? "viewer/code-worker.ts"
|
|
3409
3483
|
: mode === "edit" && path === "/assets/edit.js"
|
|
3410
3484
|
? "viewer/edit-client.ts"
|
|
3411
3485
|
: path === "/assets/ui.js"
|
|
3412
3486
|
? "viewer/ui-client.ts"
|
|
3413
3487
|
: undefined;
|
|
3414
|
-
|
|
3415
|
-
|
|
3488
|
+
const graphName = path === "/assets/graph.js"
|
|
3489
|
+
? "schema-graph-global.js"
|
|
3490
|
+
: /^\/assets\/graph\/([\w-]+\.js)$/.exec(path)?.[1];
|
|
3491
|
+
if (req.method === "GET" && (clientEntry != null || graphName)) {
|
|
3492
|
+
const { js, etag } = await bundleCache.get(graphName ? path : (clientEntry ?? ""), () => graphName
|
|
3493
|
+
? path === "/assets/graph.js"
|
|
3494
|
+
? Promise.resolve('import "/assets/graph/schema-graph-global.js";')
|
|
3495
|
+
: graphAsset(graphName)
|
|
3496
|
+
: bundleClient(clientEntry ?? ""));
|
|
3416
3497
|
if (req.headers["if-none-match"] === etag) {
|
|
3417
3498
|
res.writeHead(304, { etag, "cache-control": "no-cache" });
|
|
3418
3499
|
res.end();
|
|
@@ -3518,7 +3599,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
3518
3599
|
});
|
|
3519
3600
|
return;
|
|
3520
3601
|
}
|
|
3521
|
-
const result = subformatResponse(root, await readJson(req));
|
|
3602
|
+
const result = subformatResponse(root, await readJson(req), applicationPreviews.domains);
|
|
3522
3603
|
sendJson(res, result.status, result.body);
|
|
3523
3604
|
return;
|
|
3524
3605
|
}
|
|
@@ -3725,7 +3806,33 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
|
|
|
3725
3806
|
return;
|
|
3726
3807
|
}
|
|
3727
3808
|
}
|
|
3809
|
+
if (req.method === "GET" && path === "/assets/code-grammars.json") {
|
|
3810
|
+
const grammars = subformatCodeGrammars(siteLanguages.codeGrammars ?? [], readManifest(root).subformats);
|
|
3811
|
+
const language = requestUrl.searchParams.get("language");
|
|
3812
|
+
const json = JSON.stringify(language === null ? grammars : selectCodeGrammars(grammars, [language]));
|
|
3813
|
+
const etag = `"${createHash("sha256").update(json).digest("hex")}"`;
|
|
3814
|
+
res.writeHead(req.headers["if-none-match"] === etag ? 304 : 200, {
|
|
3815
|
+
"content-type": "application/json; charset=utf-8",
|
|
3816
|
+
"cache-control": "no-cache",
|
|
3817
|
+
etag,
|
|
3818
|
+
});
|
|
3819
|
+
res.end(req.headers["if-none-match"] === etag ? undefined : json);
|
|
3820
|
+
return;
|
|
3821
|
+
}
|
|
3728
3822
|
const site = loadSite(locale);
|
|
3823
|
+
if (req.method === "GET" && path === "/api/figure-preview") {
|
|
3824
|
+
const figure = [...site.ctx.figures.values()].find((figure) => figure.file === requestUrl.searchParams.get("file"));
|
|
3825
|
+
if (!figure) {
|
|
3826
|
+
notFound(res, path);
|
|
3827
|
+
return;
|
|
3828
|
+
}
|
|
3829
|
+
res.writeHead(200, {
|
|
3830
|
+
"content-type": "text/html; charset=utf-8",
|
|
3831
|
+
"cache-control": "no-store",
|
|
3832
|
+
});
|
|
3833
|
+
res.end(figureFrameHtml(figure, `fig-frame res-${figure.kind}`, requestUrl.searchParams.get("label") ?? undefined));
|
|
3834
|
+
return;
|
|
3835
|
+
}
|
|
3729
3836
|
if (req.method === "GET" && path === "/api/search") {
|
|
3730
3837
|
sendJson(res, 200, searchIndex(site, mode === "edit"
|
|
3731
3838
|
? (site.filePaths ?? filesSnapshot(root).files.map((file) => file.path))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SchemaContext } from "../core/schema-refs.js";
|
|
1
2
|
export declare const previewTextfiles: (root: string, input: unknown) => ReadonlyMap<string, string>;
|
|
2
3
|
export declare const textfileResponse: (root: string, input: Record<string, unknown> | undefined, domains?: readonly string[]) => Promise<{
|
|
3
4
|
status: number;
|
|
@@ -8,5 +9,6 @@ export declare const textfileResponse: (root: string, input: Record<string, unkn
|
|
|
8
9
|
language?: string;
|
|
9
10
|
schema?: object;
|
|
10
11
|
schemaDocument?: boolean;
|
|
12
|
+
schemaContext?: SchemaContext;
|
|
11
13
|
};
|
|
12
14
|
}>;
|
package/dist/viewer/textfile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readManifest } from "../compiler/manifest.js";
|
|
2
|
-
import { validateSubformatFile } from "../compiler/subformats.js";
|
|
2
|
+
import { compileSubformatSchema, isSubformatSchemaFile, validateSubformatFile, } from "../compiler/subformats.js";
|
|
3
3
|
import { readTextfile, readTextfileAsync, textfilePath, writeTextfile, } from "../compiler/textfile.js";
|
|
4
4
|
import { TextfileUnavailable } from "../compiler/textfile-remote.js";
|
|
5
5
|
import { isRemoteTextfile } from "../core/textfile.js";
|
|
@@ -27,7 +27,7 @@ export const textfileResponse = async (root, input, domains = []) => {
|
|
|
27
27
|
if (typeof input.content !== "string" ||
|
|
28
28
|
(input.base !== null && typeof input.base !== "string"))
|
|
29
29
|
return { status: 400, body: { error: "Content and original text are required" } };
|
|
30
|
-
validateSubformatFile(root, input.file, input.content);
|
|
30
|
+
validateSubformatFile(root, input.file, input.content, domains);
|
|
31
31
|
if (!writeTextfile(root, input.file, input.content, input.base))
|
|
32
32
|
return {
|
|
33
33
|
status: 409,
|
|
@@ -38,17 +38,32 @@ export const textfileResponse = async (root, input, domains = []) => {
|
|
|
38
38
|
const configs = isRemoteTextfile(input.file) ? [] : (readManifest(root).subformats ?? []);
|
|
39
39
|
const extension = input.file.split(".").at(-1);
|
|
40
40
|
const format = configs.find((config) => config.ext === extension);
|
|
41
|
+
const compiled = format
|
|
42
|
+
? compileSubformatSchema(readTextfile(root, format.schema), {
|
|
43
|
+
root,
|
|
44
|
+
file: format.schema,
|
|
45
|
+
domains,
|
|
46
|
+
})
|
|
47
|
+
: undefined;
|
|
48
|
+
const content = await readTextfileAsync(root, input.file, true, domains).catch((error) => {
|
|
49
|
+
if (error.code === "ENOENT" ||
|
|
50
|
+
(error instanceof TextfileUnavailable && error.reason === "missing"))
|
|
51
|
+
return null;
|
|
52
|
+
throw error;
|
|
53
|
+
});
|
|
41
54
|
return {
|
|
42
55
|
status: 200,
|
|
43
56
|
body: {
|
|
44
|
-
content
|
|
57
|
+
content,
|
|
45
58
|
...(format
|
|
46
59
|
? {
|
|
47
60
|
language: format.format,
|
|
48
|
-
schema:
|
|
61
|
+
schema: compiled?.schema,
|
|
62
|
+
schemaContext: compiled?.context,
|
|
49
63
|
}
|
|
50
64
|
: {}),
|
|
51
|
-
...(
|
|
65
|
+
...(!isRemoteTextfile(input.file) &&
|
|
66
|
+
isSubformatSchemaFile(root, input.file, domains)
|
|
52
67
|
? { schemaDocument: true }
|
|
53
68
|
: {}),
|
|
54
69
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooc-dev/dooc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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": [
|
|
@@ -66,8 +66,8 @@
|
|
|
66
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",
|
|
67
67
|
"build:binary": "bun scripts/build/binary.mjs",
|
|
68
68
|
"build:css": "node --import tsx scripts/build/flow-css.ts",
|
|
69
|
-
"build:flow": "esbuild src/core/schema-graph-global.tsx --bundle --format=iife --target=es2022 --minify --outfile=dist/flow.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",
|
|
69
|
+
"build:flow": "esbuild src/core/schema-graph-global.tsx --bundle --format=iife --target=es2022 --minify --outfile=dist/flow.global.js && esbuild src/core/schema-graph-global.tsx --bundle --splitting --format=esm --target=es2022 --minify --outdir=dist/graph",
|
|
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/code-worker.ts --bundle --format=iife --target=es2022 --minify --outfile=dist/code-worker.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",
|
|
71
71
|
"test": "vitest run",
|
|
72
72
|
"test:binary": "node scripts/test/binary.mjs",
|
|
73
73
|
"test:install": "node scripts/test/install.mjs",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"@lezer/common": "^1.5.4",
|
|
90
90
|
"@lezer/highlight": "^1.2.5",
|
|
91
91
|
"@shikijs/themes": "^4.5.0",
|
|
92
|
+
"@types/dxf": "4.6.10",
|
|
92
93
|
"@types/mdast": "^4.0.4",
|
|
93
94
|
"@types/node": "^22.10.0",
|
|
94
95
|
"@types/react": "^19.2.17",
|
|
@@ -96,6 +97,7 @@
|
|
|
96
97
|
"@xyflow/react": "^12.11.2",
|
|
97
98
|
"diff": "8.0.4",
|
|
98
99
|
"esbuild": "^0.28.1",
|
|
100
|
+
"mermaid": "12.3.0",
|
|
99
101
|
"react": "^19.2.8",
|
|
100
102
|
"react-dom": "^19.2.8",
|
|
101
103
|
"textlint": "^15.8.0",
|
|
@@ -111,10 +113,10 @@
|
|
|
111
113
|
"@textlint/textlint-plugin-markdown": "^15.8.0",
|
|
112
114
|
"ajv": "8.20.0",
|
|
113
115
|
"ajv-formats": "3.0.1",
|
|
116
|
+
"dxf": "5.3.1",
|
|
114
117
|
"franc": "^6.2.0",
|
|
115
118
|
"ignore": "^7.0.14",
|
|
116
119
|
"iso-639-3": "^3.0.1",
|
|
117
|
-
"mermaid": "^12.3.0",
|
|
118
120
|
"parse5": "8.0.0",
|
|
119
121
|
"postcss": "8.5.32",
|
|
120
122
|
"postcss-value-parser": "4.2.0",
|
|
@@ -133,6 +135,14 @@
|
|
|
133
135
|
"vscode-languageserver-textdocument": "1.0.16",
|
|
134
136
|
"yaml": "^2.7.0"
|
|
135
137
|
},
|
|
138
|
+
"pnpm": {
|
|
139
|
+
"overrides": {
|
|
140
|
+
"mermaid@12.3.0>elkjs": "-"
|
|
141
|
+
},
|
|
142
|
+
"patchedDependencies": {
|
|
143
|
+
"mermaid@12.3.0": "patches/mermaid@12.3.0.patch"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
136
146
|
"repository": {
|
|
137
147
|
"type": "git",
|
|
138
148
|
"url": "git+https://github.com/dooc-dev/dooc.git"
|