yuhwa 1.3.0 → 1.4.0
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/README.md +5 -3
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +4 -3
- package/dist/browser.d.ts +10 -4
- package/dist/browser.js +85 -22
- package/dist/canvas.d.ts +2 -0
- package/dist/canvas.js +40 -0
- package/dist/cli.js +485 -236
- package/dist/editor/assets/index-DWm3xV_v.js +689 -0
- package/dist/editor/assets/{lsp.worker-CMSpDTsX.js → lsp.worker-N6A9m364.js} +23 -17
- package/dist/editor/index.html +4 -1
- package/dist/{figure-QAwSU1Ry.d.ts → figure-BLHfxz_e.d.ts} +28 -5
- package/dist/{index-6ZPJGThY.d.ts → index-xVW43gqW.d.ts} +48 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/ironmark.d.ts +1 -1
- package/dist/ironmark.js +1 -1
- package/dist/lsp-browser.d.ts +2 -2
- package/dist/lsp-browser.js +2 -1
- package/dist/lsp-node.js +46 -26
- package/dist/lsp-server.d.ts +5 -1
- package/dist/lsp-server.js +1 -1
- package/dist/lsp.d.ts +1 -1
- package/dist/lsp.js +1 -1
- package/dist/markdown-it.d.ts +1 -1
- package/dist/markdown-it.js +5 -3
- package/dist/{node-CLu2Pp_2.js → node-CkrQnPFb.js} +90 -13
- package/dist/{plugin-Bs4eiAuz.js → parse--ljBMU60.js} +25 -307
- package/dist/plugin-CitzbblK.js +301 -0
- package/dist/{plugin-NSkNyoUj.d.ts → plugin-NMP_uf1a.d.ts} +15 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +3 -1
- package/dist/raster-iqi6XRPU.js +299 -0
- package/dist/remark.d.ts +1 -1
- package/dist/remark.js +1 -1
- package/dist/rolldown-runtime-CEjnN5Q1.js +37 -0
- package/dist/{server-D6BSNC1P.js → server-BTYtmr6B.js} +41 -63
- package/dist/{server--jHjJjOS.d.ts → server-DMAOtqqK.d.ts} +1 -1
- package/dist/{service-D7DNWBAU.js → service-C60VdeKS.js} +34 -3
- package/dist/{service-Brvpt7Do.d.ts → service-DimTFsE3.d.ts} +2 -0
- package/dist/{shared-6aCU_HaV.js → shared-h8tkFLY4.js} +231 -21
- package/dist/{src-BjOhvTAB.js → src-NCXCTK_4.js} +81 -45
- package/dist/svg-uri-Dx8SGV-n.js +7 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +3 -3
- package/dist/vuepress.d.ts +3 -2
- package/dist/vuepress.js +4 -2
- package/dist/watch-2VeW5DUN.js +35 -0
- package/dist/yuhwa.iife.js +55 -54
- package/dist/zoom-script-CaJ5MNUw.js +29 -0
- package/dist/{zoom-QeqB6QlH.js → zoom-yxhxX16c.js} +1 -1
- package/dist/zoom.d.ts +16 -7
- package/dist/zoom.js +2 -2
- package/package.json +19 -2
- package/skills/yuhwa/SKILL.md +12 -0
- package/dist/editor/assets/index-DAk6b1UB.js +0 -689
- package/dist/zoom-script-CVdAzMhX.js +0 -51
|
@@ -264,6 +264,7 @@ function ramp(tone, level) {
|
|
|
264
264
|
}
|
|
265
265
|
const SANS = "Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif";
|
|
266
266
|
const MONO = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
267
|
+
const SERIF$1 = "ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif";
|
|
267
268
|
const lightTone = (t) => RAMPS[t] && {
|
|
268
269
|
fill: ramp(t, 50),
|
|
269
270
|
stroke: ramp(t, 300),
|
|
@@ -405,15 +406,31 @@ const LINE_STYLES = [
|
|
|
405
406
|
];
|
|
406
407
|
/** the group border dash for a line style; `fallback` when no style is set */
|
|
407
408
|
const groupDash = (style, fallback) => style === "dashed" ? "6 4" : style === "dotted" ? "1.5 4" : style === "solid" ? null : fallback;
|
|
408
|
-
|
|
409
|
+
const FONT_KEYWORDS = {
|
|
410
|
+
sans: SANS,
|
|
411
|
+
serif: SERIF$1,
|
|
412
|
+
mono: MONO
|
|
413
|
+
};
|
|
414
|
+
const GENERIC_FONT = /^(serif|sans-serif|monospace|cursive|fantasy|math|emoji|system-ui|ui-(serif|sans-serif|monospace|rounded))$/i;
|
|
415
|
+
/** whether `family` is a CSS generic family such as `serif` or `system-ui` */
|
|
416
|
+
const isGenericFont = (family) => GENERIC_FONT.test(family);
|
|
417
|
+
/** the family names of a CSS font stack, unquoted */
|
|
418
|
+
const fontFamilies = (stack) => stack.split(",").map((f) => f.trim().replace(/^(['"])(.*)\1$/, "$2")).filter(Boolean);
|
|
419
|
+
/**
|
|
420
|
+
* a font setting as a CSS font stack: a family name or a fallback list such
|
|
421
|
+
* as `Lora, Georgia, serif`. `sans`, `serif` and `mono` expand to their
|
|
422
|
+
* stacks; a list that ends without a generic family gets one that matches
|
|
423
|
+
* the first font
|
|
424
|
+
*/
|
|
409
425
|
function fontStack(font) {
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
426
|
+
const names = font.split(",").map((f) => f.trim()).filter(Boolean);
|
|
427
|
+
const first = fontFamilies(font)[0] ?? "sans";
|
|
428
|
+
const mono = first === "mono" || /mono|code|courier/i.test(first);
|
|
429
|
+
const stack = names.map((f) => FONT_KEYWORDS[f] ?? f);
|
|
430
|
+
const last = names.at(-1) ?? "";
|
|
431
|
+
if (!FONT_KEYWORDS[last] && !isGenericFont(last)) stack.push(mono ? "ui-monospace, monospace" : "ui-sans-serif, system-ui, sans-serif");
|
|
415
432
|
return {
|
|
416
|
-
font:
|
|
433
|
+
font: stack.join(", "),
|
|
417
434
|
mono
|
|
418
435
|
};
|
|
419
436
|
}
|
|
@@ -2363,7 +2380,7 @@ const isShape = (k) => SHAPE_KINDS.has(k) || k in SHAPE_ALIASES;
|
|
|
2363
2380
|
*/
|
|
2364
2381
|
const isYuhwaPath = (path) => /\.(yu|yuhwa)$/i.test(path);
|
|
2365
2382
|
/** Join an import path to the importing file's folder and normalise `.`/`..`. */
|
|
2366
|
-
function joinPath(from, rel) {
|
|
2383
|
+
function joinPath$1(from, rel) {
|
|
2367
2384
|
if (/^[a-z][a-z0-9+.-]*:/i.test(rel)) return rel;
|
|
2368
2385
|
const base = rel.startsWith("/") || !from ? "" : from.replace(/[^/]*$/, "");
|
|
2369
2386
|
const abs = (base + rel).startsWith("/");
|
|
@@ -2802,7 +2819,7 @@ function parse(source, opts = {}) {
|
|
|
2802
2819
|
*/
|
|
2803
2820
|
const importFile = (rel, li, names) => {
|
|
2804
2821
|
if (!opts.resolve) return warn(li, `Cannot import "${rel}": no resolver (pass { resolve } to render, or use the CLI)`, "error");
|
|
2805
|
-
const path = joinPath(opts.file, rel);
|
|
2822
|
+
const path = joinPath$1(opts.file, rel);
|
|
2806
2823
|
if (!isYuhwaPath(path)) return warn(li, `Cannot import "${rel}": imports must be .yu files`, "error");
|
|
2807
2824
|
const chain = [...opts.chain ?? (opts.file ? [opts.file] : [])];
|
|
2808
2825
|
if (chain.includes(path)) return warn(li, `Import cycle: ${[...chain, path].join(" -> ")}`, "error");
|
|
@@ -8401,7 +8418,7 @@ const STATUS_MARK = {
|
|
|
8401
8418
|
renamed: "R",
|
|
8402
8419
|
ignored: ""
|
|
8403
8420
|
};
|
|
8404
|
-
const FLAGS = [
|
|
8421
|
+
const FLAGS$1 = [
|
|
8405
8422
|
"collapsed",
|
|
8406
8423
|
"highlight",
|
|
8407
8424
|
"dim",
|
|
@@ -8571,7 +8588,7 @@ function outsideBrackets(s) {
|
|
|
8571
8588
|
}
|
|
8572
8589
|
const bare$1 = (text) => text.replace(/\/$/, "");
|
|
8573
8590
|
function checkProps(props, warn) {
|
|
8574
|
-
for (const k of Object.keys(props)) if (!FLAGS.includes(k) && !KEYS.includes(k)) warn(`treeview: unknown prop "${k}" (use a colour, ${[...KEYS.slice(1), ...FLAGS].join(", ")})`);
|
|
8591
|
+
for (const k of Object.keys(props)) if (!FLAGS$1.includes(k) && !KEYS.includes(k)) warn(`treeview: unknown prop "${k}" (use a colour, ${[...KEYS.slice(1), ...FLAGS$1].join(", ")})`);
|
|
8575
8592
|
if (props.status && !STATUSES.includes(props.status)) warn(`treeview: unknown status "${props.status}" (use one of: ${STATUSES.join(", ")})`);
|
|
8576
8593
|
if (props.color && !isSafeCss(props.color)) delete props.color;
|
|
8577
8594
|
}
|
|
@@ -10755,8 +10772,8 @@ function computeBounds(box, d, theme, measure) {
|
|
|
10755
10772
|
decor
|
|
10756
10773
|
};
|
|
10757
10774
|
}
|
|
10758
|
-
/** height of a panel's title row
|
|
10759
|
-
const panelHead = (label, fs) => label ? fs *
|
|
10775
|
+
/** height of a panel's title row: the capitals (about 0.74 fs) plus a PANEL_PAD-sized gap to the content */
|
|
10776
|
+
const panelHead = (label, fs) => label ? fs * 1.95 : 0;
|
|
10760
10777
|
/** what a panel plugin gets in `measure`, `render` and `handles` */
|
|
10761
10778
|
function panelCtx(decl, offsets, theme, measure) {
|
|
10762
10779
|
return {
|
|
@@ -10948,11 +10965,11 @@ function renderPanel(p, L, measure, shadow, id) {
|
|
|
10948
10965
|
const T = p.ctx.theme;
|
|
10949
10966
|
const s = resolvePanelStyle(p.decl.props, T, base);
|
|
10950
10967
|
const { box } = p;
|
|
10951
|
-
const
|
|
10968
|
+
const capMid = p.ctx.fs * 1.05 * .35;
|
|
10952
10969
|
const tf = textFont(p.decl.props, p.ctx.fs, 650);
|
|
10953
10970
|
const out = [`<g${attr("data-panel", p.decl.id)}${attr("class", `panel panel-${p.decl.kind}`)}>`];
|
|
10954
10971
|
if (s.framed) out.push(`<rect x="${f(box.x)}" y="${f(box.y)}" width="${f(box.w)}" height="${f(box.h)}" rx="${f(s.radius)}" fill="${s.fill}" stroke="${s.stroke}" stroke-width="${f(s.width)}"${attr("stroke-dasharray", s.dash)}${s.shadow && shadow ? ` filter="url(#${shadow})"` : ""}/>`);
|
|
10955
|
-
if (p.decl.label) out.push(`<text x="${f(box.x + 16)}" y="${f(box.y + 16 +
|
|
10972
|
+
if (p.decl.label) out.push(`<text x="${f(box.x + 16)}" y="${f(box.y + 16 + capMid)}" dominant-baseline="central" font-size="${f(p.ctx.fs * 1.05)}" font-weight="${tf.weight}"${tf.italic ? " font-style=\"italic\"" : ""} fill="${s.text}" xml:space="preserve">${tspans(parseInline(p.decl.label), nodeInk(T, s.text), T)}</text>`);
|
|
10956
10973
|
p.ctx.idPrefix = `${id}-${p.decl.id}`;
|
|
10957
10974
|
if (!p.decl.failed) out.push(kind.render(p.decl.data, p.inner, !measure || measure === p.ctx.measure ? p.ctx : {
|
|
10958
10975
|
...p.ctx,
|
|
@@ -10970,9 +10987,11 @@ function renderGroup(g, L, interactive) {
|
|
|
10970
10987
|
const text = g.decl.label;
|
|
10971
10988
|
const ink = nodeInk(T, s.text, s.stroke);
|
|
10972
10989
|
const lines = g.lines ?? [text];
|
|
10973
|
-
const
|
|
10974
|
-
const
|
|
10975
|
-
const
|
|
10990
|
+
const inset = 14;
|
|
10991
|
+
const base = g.y + inset + Math.round(font.size * .7);
|
|
10992
|
+
const body = lines.length > 1 ? textLines(lines, g.x + inset, (i) => base + i * g.lineHeight, (l) => richText(l, ink, T, font.caps)) : richText(text, ink, T, font.caps);
|
|
10993
|
+
const label = text ? `<text x="${f(g.x + inset)}" y="${f(base)}" font-size="${f(font.size)}" font-weight="${font.weight}"${font.italic ? " font-style=\"italic\"" : ""} letter-spacing="${font.caps ? "0.1em" : "0.02em"}" fill="${s.text}" xml:space="preserve">${body}</text>` : "";
|
|
10994
|
+
const meta = p.meta ? `<text x="${f(g.x + g.w - inset)}" y="${f(base)}" text-anchor="end" font-size="${f(fs)}" fill="${T.node.sub}" xml:space="preserve">${richText(p.meta, subInk(ink), T)}</text>` : "";
|
|
10976
10995
|
return `<g${attr("data-group", g.id)}${interactive ? " cursor=\"move\"" : ""}><rect x="${f(g.x)}" y="${f(g.y)}" width="${f(g.w)}" height="${f(g.h)}" rx="${f(Math.min(14, T.radius + 4))}" fill="${s.fill}" stroke="${s.stroke}" stroke-width="1"${attr("stroke-dasharray", s.dash)}/>` + label + meta + "</g>";
|
|
10977
10996
|
}
|
|
10978
10997
|
/**
|
|
@@ -13031,6 +13050,171 @@ function findClose(s, from, close) {
|
|
|
13031
13050
|
}
|
|
13032
13051
|
return -1;
|
|
13033
13052
|
}
|
|
13053
|
+
// src/markdown.ts
|
|
13054
|
+
/**
|
|
13055
|
+
* Markdown integration.
|
|
13056
|
+
*
|
|
13057
|
+
* Diagrams live in Markdown as HTML comments, so the source stays next to the
|
|
13058
|
+
* docs but is invisible when rendered:
|
|
13059
|
+
*
|
|
13060
|
+
* <!--yuhwa checkout
|
|
13061
|
+
* a -> b
|
|
13062
|
+
* -->
|
|
13063
|
+
* 
|
|
13064
|
+
*
|
|
13065
|
+
* Fenced ```yuhwa (or ```yu) blocks are converted to that form on the first
|
|
13066
|
+
* run. `<!--yu name` opens a comment block too.
|
|
13067
|
+
* The image line right after a block is inserted or kept up to date.
|
|
13068
|
+
*/
|
|
13069
|
+
/** fence languages that hold a diagram */
|
|
13070
|
+
const MD_LANGUAGES = ["yuhwa", "yu"];
|
|
13071
|
+
const LANG = [...MD_LANGUAGES].sort((a, b) => b.length - a.length).join("|");
|
|
13072
|
+
/** `<!--yuhwa name` or `<!--yu name` */
|
|
13073
|
+
const COMMENT_OPEN = new RegExp(`^<!--\\s*(?:${LANG})(?:\\s+([\\w.-]+))?\\s*$`);
|
|
13074
|
+
/**
|
|
13075
|
+
* The diagrams of a Markdown page: fenced blocks in one of `languages` and
|
|
13076
|
+
* `<!--yuhwa name … -->` (or `<!--yu`) comments. Fences in other languages are
|
|
13077
|
+
* skipped whole, so a ```markdown fence that shows a yuhwa block is left alone.
|
|
13078
|
+
*/
|
|
13079
|
+
const isMarkdown = (file) => /\.(md|mdx|markdown)$/i.test(file);
|
|
13080
|
+
/** fence flags that are not a block name */
|
|
13081
|
+
const FLAGS = /* @__PURE__ */ new Set([
|
|
13082
|
+
"no-code",
|
|
13083
|
+
"zoom",
|
|
13084
|
+
"no-zoom"
|
|
13085
|
+
]);
|
|
13086
|
+
const FENCE = /^ {0,3}(`{3,}|~{3,})\s*([^\s`]*)(.*)$/;
|
|
13087
|
+
function pageBlocks(md, languages = MD_LANGUAGES) {
|
|
13088
|
+
const lines = md.split("\n");
|
|
13089
|
+
const blocks = [];
|
|
13090
|
+
for (let i = 0; i < lines.length; i++) {
|
|
13091
|
+
const line = lines[i].replace(/\r$/, "");
|
|
13092
|
+
let close;
|
|
13093
|
+
let lang;
|
|
13094
|
+
let meta = "";
|
|
13095
|
+
let m = line.match(FENCE);
|
|
13096
|
+
if (m) {
|
|
13097
|
+
const fence = m[1];
|
|
13098
|
+
const closer = new RegExp(`^ {0,3}${fence[0]}{${fence.length},}\\s*$`);
|
|
13099
|
+
close = (l) => closer.test(l);
|
|
13100
|
+
lang = m[2];
|
|
13101
|
+
meta = m[3].trim();
|
|
13102
|
+
} else if (m = line.match(COMMENT_OPEN)) {
|
|
13103
|
+
close = (l) => l.trim() === "-->";
|
|
13104
|
+
lang = "comment";
|
|
13105
|
+
meta = m[1] ?? "";
|
|
13106
|
+
} else continue;
|
|
13107
|
+
let j = i + 1;
|
|
13108
|
+
while (j < lines.length && !close(lines[j].replace(/\r$/, ""))) j++;
|
|
13109
|
+
if (j >= lines.length) break;
|
|
13110
|
+
if (lang === "comment" || languages.includes(lang) && !/(^|\s)no-render(\s|$)/.test(meta)) {
|
|
13111
|
+
const name = meta.split(/\s+/).find((w) => /^[\w.-]+$/.test(w) && !FLAGS.has(w));
|
|
13112
|
+
blocks.push({
|
|
13113
|
+
index: blocks.length,
|
|
13114
|
+
lang,
|
|
13115
|
+
...name ? { name } : {},
|
|
13116
|
+
line: i + 1,
|
|
13117
|
+
end: j + 1,
|
|
13118
|
+
source: lines.slice(i + 1, j).join("\n")
|
|
13119
|
+
});
|
|
13120
|
+
}
|
|
13121
|
+
i = j;
|
|
13122
|
+
}
|
|
13123
|
+
return blocks;
|
|
13124
|
+
}
|
|
13125
|
+
function imageRef(name, lightPath, darkPath, href) {
|
|
13126
|
+
if (darkPath) {
|
|
13127
|
+
const pic = `<picture><source media="(prefers-color-scheme: dark)" srcset="${darkPath}"><img alt="${name}" src="${lightPath}"></picture>`;
|
|
13128
|
+
return href ? `<a href="${href.replace(/"/g, "%22")}">${pic}</a>` : pic;
|
|
13129
|
+
}
|
|
13130
|
+
return href ? `[](${href})` : ``;
|
|
13131
|
+
}
|
|
13132
|
+
/** an image reference without the link `view` wraps it in */
|
|
13133
|
+
const unlinked = (ref) => ref.match(/^\[(!\[[^\]]*\]\([^)]*\))\]\([^)]*\)$/)?.[1] ?? ref.match(/^<a href="[^"]*">(<picture>.*<\/picture>)<\/a>$/)?.[1] ?? ref;
|
|
13134
|
+
function findBlocks(md, baseName = "diagram", outDir = "diagrams") {
|
|
13135
|
+
const lines = md.split("\n");
|
|
13136
|
+
const used = /* @__PURE__ */ new Set();
|
|
13137
|
+
return pageBlocks(md).map(({ index, name, source, lang, line, end }) => {
|
|
13138
|
+
let n = name ?? `${baseName}-${index + 1}`;
|
|
13139
|
+
while (used.has(n)) n += "-" + (index + 1);
|
|
13140
|
+
used.add(n);
|
|
13141
|
+
const b = {
|
|
13142
|
+
index,
|
|
13143
|
+
name: n,
|
|
13144
|
+
source,
|
|
13145
|
+
kind: lang === "comment" ? "comment" : "fence",
|
|
13146
|
+
start: line - 1,
|
|
13147
|
+
end: end - 1
|
|
13148
|
+
};
|
|
13149
|
+
let k = b.end + 1;
|
|
13150
|
+
while (k < lines.length && lines[k].trim() === "" && k <= b.end + 1) k++;
|
|
13151
|
+
const candidate = unlinked(lines[k]?.trim() ?? "");
|
|
13152
|
+
const path = joinPath(outDir, `${n}.svg`);
|
|
13153
|
+
if (candidate === imageRef(n, path) || candidate === imageRef(n, path, joinPath(outDir, `${n}.dark.svg`))) b.image = [k, k];
|
|
13154
|
+
return b;
|
|
13155
|
+
});
|
|
13156
|
+
}
|
|
13157
|
+
const joinPath = (dir, file) => dir ? dir.replace(/\/+$/, "") + "/" + file : file;
|
|
13158
|
+
function processMarkdown(md, opts = {}) {
|
|
13159
|
+
const outDir = opts.outDir ?? "diagrams";
|
|
13160
|
+
const blocks = findBlocks(md, opts.baseName, outDir);
|
|
13161
|
+
const lines = md.split("\n");
|
|
13162
|
+
const files = [];
|
|
13163
|
+
const diagnostics = [];
|
|
13164
|
+
for (const b of [...blocks].reverse()) {
|
|
13165
|
+
const io = {
|
|
13166
|
+
resolve: opts.resolve,
|
|
13167
|
+
file: opts.file
|
|
13168
|
+
};
|
|
13169
|
+
const light = render(b.source, io);
|
|
13170
|
+
for (const dg of light.diagnostics) diagnostics.push({
|
|
13171
|
+
block: b.name,
|
|
13172
|
+
line: dg.line,
|
|
13173
|
+
message: dg.message,
|
|
13174
|
+
severity: dg.severity
|
|
13175
|
+
});
|
|
13176
|
+
const lightPath = joinPath(outDir, `${b.name}.svg`);
|
|
13177
|
+
files.push({
|
|
13178
|
+
path: lightPath,
|
|
13179
|
+
svg: light.svg + "\n"
|
|
13180
|
+
});
|
|
13181
|
+
const href = light.diagram.imports?.length ? void 0 : opts.view?.(b.source);
|
|
13182
|
+
let ref = imageRef(b.name, lightPath, void 0, href);
|
|
13183
|
+
if (opts.dark) {
|
|
13184
|
+
const dark = render(b.source, {
|
|
13185
|
+
...io,
|
|
13186
|
+
theme: "midnight"
|
|
13187
|
+
});
|
|
13188
|
+
const darkPath = joinPath(outDir, `${b.name}.dark.svg`);
|
|
13189
|
+
files.push({
|
|
13190
|
+
path: darkPath,
|
|
13191
|
+
svg: dark.svg + "\n"
|
|
13192
|
+
});
|
|
13193
|
+
ref = imageRef(b.name, lightPath, darkPath, href);
|
|
13194
|
+
}
|
|
13195
|
+
const replacement = [];
|
|
13196
|
+
if (b.kind === "fence" && !opts.keepFences) replacement.push(`<!--yuhwa ${b.name}`, ...b.source.split("\n"), "-->");
|
|
13197
|
+
else replacement.push(...lines.slice(b.start, b.end + 1));
|
|
13198
|
+
replacement.push(ref);
|
|
13199
|
+
const end = b.image ? b.image[1] : b.end;
|
|
13200
|
+
lines.splice(b.start, end - b.start + 1, ...replacement);
|
|
13201
|
+
}
|
|
13202
|
+
files.reverse();
|
|
13203
|
+
return {
|
|
13204
|
+
markdown: lines.join("\n"),
|
|
13205
|
+
files,
|
|
13206
|
+
blocks,
|
|
13207
|
+
diagnostics
|
|
13208
|
+
};
|
|
13209
|
+
}
|
|
13210
|
+
/** Replace the source of block `index` in a markdown document. */
|
|
13211
|
+
function replaceBlockSource(md, index, source) {
|
|
13212
|
+
const b = findBlocks(md)[index];
|
|
13213
|
+
if (!b) throw new Error(`No yuhwa block #${index}`);
|
|
13214
|
+
const lines = md.split("\n");
|
|
13215
|
+
lines.splice(b.start + 1, b.end - b.start - 1, ...source.split("\n"));
|
|
13216
|
+
return lines.join("\n");
|
|
13217
|
+
}
|
|
13034
13218
|
// src/index.ts
|
|
13035
13219
|
/** Stable short hash, used for deterministic SVG ids. */
|
|
13036
13220
|
function hash(s) {
|
|
@@ -13185,7 +13369,7 @@ function verbatimBlocks(text, lines) {
|
|
|
13185
13369
|
}
|
|
13186
13370
|
/** Format yuhwa source. Returns the new text; whitespace is all that changes. */
|
|
13187
13371
|
function format(text) {
|
|
13188
|
-
if (isMermaid(text)) return text;
|
|
13372
|
+
if (isMermaid(text) || /^\s*\{/.test(text)) return text;
|
|
13189
13373
|
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
13190
13374
|
const lines = text.split(/\r?\n/);
|
|
13191
13375
|
const verbatim = /* @__PURE__ */ new Map();
|
|
@@ -13281,6 +13465,32 @@ function format(text) {
|
|
|
13281
13465
|
while (kept.length && kept[kept.length - 1] === "") kept.pop();
|
|
13282
13466
|
return kept.length ? kept.join(eol) + eol : "";
|
|
13283
13467
|
}
|
|
13468
|
+
/**
|
|
13469
|
+
* A Markdown page with its diagram blocks formatted like `.yu` files: fences
|
|
13470
|
+
* in `languages` and `<!--yuhwa` comments. `only` limits it to some blocks.
|
|
13471
|
+
* A fence indented by up to three spaces keeps that indent on every line.
|
|
13472
|
+
*/
|
|
13473
|
+
function formatPage(md, languages) {
|
|
13474
|
+
const lines = md.split("\n");
|
|
13475
|
+
const changed = [];
|
|
13476
|
+
for (const b of pageBlocks(md, languages).reverse()) {
|
|
13477
|
+
const body = lines.slice(b.line, b.end - 1);
|
|
13478
|
+
const cr = body.some((l) => l.endsWith("\r")) ? "\r" : "";
|
|
13479
|
+
const indent = lines[b.line - 1].match(/^ */)[0];
|
|
13480
|
+
const inner = body.map((l) => l.replace(/\r$/, ""));
|
|
13481
|
+
const strip = indent && inner.every((l) => !l.trim() || l.startsWith(indent)) ? indent.length : 0;
|
|
13482
|
+
const source = inner.map((l) => l.slice(strip)).join("\n");
|
|
13483
|
+
const out = format(source).replace(/\n+$/, "");
|
|
13484
|
+
if (out === source) continue;
|
|
13485
|
+
changed.unshift(b);
|
|
13486
|
+
const next = out ? out.split("\n").map((l) => (l && strip ? indent + l : l) + cr) : [];
|
|
13487
|
+
lines.splice(b.line, body.length, ...next);
|
|
13488
|
+
}
|
|
13489
|
+
return {
|
|
13490
|
+
text: lines.join("\n"),
|
|
13491
|
+
changed
|
|
13492
|
+
};
|
|
13493
|
+
}
|
|
13284
13494
|
/** One edit that turns `a` into `b`, covering only what differs. */
|
|
13285
13495
|
function diffEdits(a, b) {
|
|
13286
13496
|
if (a === b) return [];
|
|
@@ -13393,5 +13603,5 @@ function onTypeEdits(text, pos, ch) {
|
|
|
13393
13603
|
}
|
|
13394
13604
|
// src/version.ts
|
|
13395
13605
|
/** the package version, inlined by the build */
|
|
13396
|
-
const VERSION = "1.
|
|
13397
|
-
export {
|
|
13606
|
+
const VERSION = "1.4.0";
|
|
13607
|
+
export { BOOLS as A, SPAN_KEYS as B, blockBraces as C, parse as D, lex as E, NODE_PROPS as F, THEME_NAMES as G, parseSpanStyle as H, NUMBERS as I, themeNames as J, TONES as K, PANEL_PROPS as L, EDGE_PROPS as M, ENUMS as N, serializeProps as O, GROUP_PROPS as P, PLACEMENT_PROPS as R, SETTING_VALUES as S, joinPath$1 as T, spanKey as U, esc$1 as V, THEME_KEYS as W, table as Y, canvasMeasure as _, formatPage as a, KNOWN_SETTINGS as b, diskResolve as c, MD_LANGUAGES as d, findBlocks as f, replaceBlockSource as g, processMarkdown as h, format as i, COLORS as j, unquote as k, render as l, pageBlocks as m, applyChange as n, onTypeEdits as o, isMarkdown as p, isSafeCss as q, diffEdits as r, tidy as s, VERSION as t, toSource as u, optionKind as v, isYuhwaPath as w, PANELS as x, registry as y, SHAPES$2 as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as perPass, i as optionKind, l as use, n as approxMeasure, o as recolor, s as registry } from "./plugin-CitzbblK.js";
|
|
2
|
+
import { $ as panelTheme, A as placementOf, At as SANS, B as textOffset, Bt as getTheme, C as ENUMS, Ct as sumW, D as PANEL_PROPS, Dt as COLOR_TOKEN, Et as tspans, F as portOn, Ft as bool, G as renderHead, I as rectPath, It as createTheme, J as edgeFont, Jt as resolveColor, K as routeEdges, Kt as ramp, L as shapeDetail, Lt as cssHex, M as SHAPES$2, Mt as THEME_KEYS, Nt as THEME_NAMES, Ot as MONO, P as normalizeShape, Pt as TONES, Q as num$1, Qt as collecting, R as shapePath, S as EDGE_PROPS, St as subInk, T as NODE_PROPS, Tt as textLines, U as POST_RENDER, Ut as isSafeCss, V as AFTER_LAYOUT, Vt as isColor, Wt as isSafeLink, X as effectiveProps, Y as edgeWidthOf, Z as lineStyle, _ as setTrailingProp, _t as richText, at as textFont, ct as esc$1, d as parse, dt as lineHeight, en as table, et as posNum, f as parseProps, ft as nodeInk, g as setLineProp, gt as renderSegs, h as serializeProps, ht as plain, it as size, j as propLine, kt as RAMPS, l as lex, lt as f$1, m as quote$1, n as PANELS, nt as resolveNodeStyle, o as blockBraces, ot as withEdgeInk, p as propKey, pt as parseInline, q as dashFor, r as SETTING_VALUES, rt as resolvePanelStyle, t as KNOWN_SETTINGS, tt as resolveGroupStyle, u as onlyColor, ut as inkColor, v as splitTrailingProps, vt as richW, w as GROUP_PROPS, wt as textEl, x as COLORS, xt as splitWords, y as unquote, yt as segsW, z as sizeForShape, zt as fontStack } from "./parse--ljBMU60.js";
|
|
2
3
|
// src/plugins/shapes.ts
|
|
3
4
|
/** the content box grown by the default padding, before a shape's minimums */
|
|
4
5
|
const pad = (cw, ch) => ({
|
|
@@ -4254,7 +4255,7 @@ const STATUS_MARK = {
|
|
|
4254
4255
|
renamed: "R",
|
|
4255
4256
|
ignored: ""
|
|
4256
4257
|
};
|
|
4257
|
-
const FLAGS = [
|
|
4258
|
+
const FLAGS$1 = [
|
|
4258
4259
|
"collapsed",
|
|
4259
4260
|
"highlight",
|
|
4260
4261
|
"dim",
|
|
@@ -4424,7 +4425,7 @@ function outsideBrackets(s) {
|
|
|
4424
4425
|
}
|
|
4425
4426
|
const bare$1 = (text) => text.replace(/\/$/, "");
|
|
4426
4427
|
function checkProps(props, warn) {
|
|
4427
|
-
for (const k of Object.keys(props)) if (!FLAGS.includes(k) && !KEYS.includes(k)) warn(`treeview: unknown prop "${k}" (use a colour, ${[...KEYS.slice(1), ...FLAGS].join(", ")})`);
|
|
4428
|
+
for (const k of Object.keys(props)) if (!FLAGS$1.includes(k) && !KEYS.includes(k)) warn(`treeview: unknown prop "${k}" (use a colour, ${[...KEYS.slice(1), ...FLAGS$1].join(", ")})`);
|
|
4428
4429
|
if (props.status && !STATUSES.includes(props.status)) warn(`treeview: unknown status "${props.status}" (use one of: ${STATUSES.join(", ")})`);
|
|
4429
4430
|
if (props.color && !isSafeCss(props.color)) delete props.color;
|
|
4430
4431
|
}
|
|
@@ -6613,8 +6614,8 @@ function computeBounds(box, d, theme, measure) {
|
|
|
6613
6614
|
decor
|
|
6614
6615
|
};
|
|
6615
6616
|
}
|
|
6616
|
-
/** height of a panel's title row
|
|
6617
|
-
const panelHead = (label, fs) => label ? fs *
|
|
6617
|
+
/** height of a panel's title row: the capitals (about 0.74 fs) plus a PANEL_PAD-sized gap to the content */
|
|
6618
|
+
const panelHead = (label, fs) => label ? fs * 1.95 : 0;
|
|
6618
6619
|
/** what a panel plugin gets in `measure`, `render` and `handles` */
|
|
6619
6620
|
function panelCtx(decl, offsets, theme, measure) {
|
|
6620
6621
|
return {
|
|
@@ -6806,11 +6807,11 @@ function renderPanel(p, L, measure, shadow, id) {
|
|
|
6806
6807
|
const T = p.ctx.theme;
|
|
6807
6808
|
const s = resolvePanelStyle(p.decl.props, T, base);
|
|
6808
6809
|
const { box } = p;
|
|
6809
|
-
const
|
|
6810
|
+
const capMid = p.ctx.fs * 1.05 * .35;
|
|
6810
6811
|
const tf = textFont(p.decl.props, p.ctx.fs, 650);
|
|
6811
6812
|
const out = [`<g${attr("data-panel", p.decl.id)}${attr("class", `panel panel-${p.decl.kind}`)}>`];
|
|
6812
6813
|
if (s.framed) out.push(`<rect x="${f(box.x)}" y="${f(box.y)}" width="${f(box.w)}" height="${f(box.h)}" rx="${f(s.radius)}" fill="${s.fill}" stroke="${s.stroke}" stroke-width="${f(s.width)}"${attr("stroke-dasharray", s.dash)}${s.shadow && shadow ? ` filter="url(#${shadow})"` : ""}/>`);
|
|
6813
|
-
if (p.decl.label) out.push(`<text x="${f(box.x + 16)}" y="${f(box.y + 16 +
|
|
6814
|
+
if (p.decl.label) out.push(`<text x="${f(box.x + 16)}" y="${f(box.y + 16 + capMid)}" dominant-baseline="central" font-size="${f(p.ctx.fs * 1.05)}" font-weight="${tf.weight}"${tf.italic ? " font-style=\"italic\"" : ""} fill="${s.text}" xml:space="preserve">${tspans(parseInline(p.decl.label), nodeInk(T, s.text), T)}</text>`);
|
|
6814
6815
|
p.ctx.idPrefix = `${id}-${p.decl.id}`;
|
|
6815
6816
|
if (!p.decl.failed) out.push(kind.render(p.decl.data, p.inner, !measure || measure === p.ctx.measure ? p.ctx : {
|
|
6816
6817
|
...p.ctx,
|
|
@@ -6828,9 +6829,11 @@ function renderGroup(g, L, interactive) {
|
|
|
6828
6829
|
const text = g.decl.label;
|
|
6829
6830
|
const ink = nodeInk(T, s.text, s.stroke);
|
|
6830
6831
|
const lines = g.lines ?? [text];
|
|
6831
|
-
const
|
|
6832
|
-
const
|
|
6833
|
-
const
|
|
6832
|
+
const inset = 14;
|
|
6833
|
+
const base = g.y + inset + Math.round(font.size * .7);
|
|
6834
|
+
const body = lines.length > 1 ? textLines(lines, g.x + inset, (i) => base + i * g.lineHeight, (l) => richText(l, ink, T, font.caps)) : richText(text, ink, T, font.caps);
|
|
6835
|
+
const label = text ? `<text x="${f(g.x + inset)}" y="${f(base)}" font-size="${f(font.size)}" font-weight="${font.weight}"${font.italic ? " font-style=\"italic\"" : ""} letter-spacing="${font.caps ? "0.1em" : "0.02em"}" fill="${s.text}" xml:space="preserve">${body}</text>` : "";
|
|
6836
|
+
const meta = p.meta ? `<text x="${f(g.x + g.w - inset)}" y="${f(base)}" text-anchor="end" font-size="${f(fs)}" fill="${T.node.sub}" xml:space="preserve">${richText(p.meta, subInk(ink), T)}</text>` : "";
|
|
6834
6837
|
return `<g${attr("data-group", g.id)}${interactive ? " cursor=\"move\"" : ""}><rect x="${f(g.x)}" y="${f(g.y)}" width="${f(g.w)}" height="${f(g.h)}" rx="${f(Math.min(14, T.radius + 4))}" fill="${s.fill}" stroke="${s.stroke}" stroke-width="1"${attr("stroke-dasharray", s.dash)}/>` + label + meta + "</g>";
|
|
6835
6838
|
}
|
|
6836
6839
|
/**
|
|
@@ -9155,11 +9158,66 @@ function editBody(source, panelId, d, fn) {
|
|
|
9155
9158
|
* -->
|
|
9156
9159
|
* 
|
|
9157
9160
|
*
|
|
9158
|
-
* Fenced ```yuhwa blocks are converted to that form on the first
|
|
9161
|
+
* Fenced ```yuhwa (or ```yu) blocks are converted to that form on the first
|
|
9162
|
+
* run. `<!--yu name` opens a comment block too.
|
|
9159
9163
|
* The image line right after a block is inserted or kept up to date.
|
|
9160
9164
|
*/
|
|
9161
|
-
|
|
9162
|
-
const
|
|
9165
|
+
/** fence languages that hold a diagram */
|
|
9166
|
+
const MD_LANGUAGES = ["yuhwa", "yu"];
|
|
9167
|
+
const LANG = [...MD_LANGUAGES].sort((a, b) => b.length - a.length).join("|");
|
|
9168
|
+
/** `<!--yuhwa name` or `<!--yu name` */
|
|
9169
|
+
const COMMENT_OPEN = new RegExp(`^<!--\\s*(?:${LANG})(?:\\s+([\\w.-]+))?\\s*$`);
|
|
9170
|
+
/**
|
|
9171
|
+
* The diagrams of a Markdown page: fenced blocks in one of `languages` and
|
|
9172
|
+
* `<!--yuhwa name … -->` (or `<!--yu`) comments. Fences in other languages are
|
|
9173
|
+
* skipped whole, so a ```markdown fence that shows a yuhwa block is left alone.
|
|
9174
|
+
*/
|
|
9175
|
+
const isMarkdown = (file) => /\.(md|mdx|markdown)$/i.test(file);
|
|
9176
|
+
/** fence flags that are not a block name */
|
|
9177
|
+
const FLAGS = /* @__PURE__ */ new Set([
|
|
9178
|
+
"no-code",
|
|
9179
|
+
"zoom",
|
|
9180
|
+
"no-zoom"
|
|
9181
|
+
]);
|
|
9182
|
+
const FENCE = /^ {0,3}(`{3,}|~{3,})\s*([^\s`]*)(.*)$/;
|
|
9183
|
+
function pageBlocks(md, languages = MD_LANGUAGES) {
|
|
9184
|
+
const lines = md.split("\n");
|
|
9185
|
+
const blocks = [];
|
|
9186
|
+
for (let i = 0; i < lines.length; i++) {
|
|
9187
|
+
const line = lines[i].replace(/\r$/, "");
|
|
9188
|
+
let close;
|
|
9189
|
+
let lang;
|
|
9190
|
+
let meta = "";
|
|
9191
|
+
let m = line.match(FENCE);
|
|
9192
|
+
if (m) {
|
|
9193
|
+
const fence = m[1];
|
|
9194
|
+
const closer = new RegExp(`^ {0,3}${fence[0]}{${fence.length},}\\s*$`);
|
|
9195
|
+
close = (l) => closer.test(l);
|
|
9196
|
+
lang = m[2];
|
|
9197
|
+
meta = m[3].trim();
|
|
9198
|
+
} else if (m = line.match(COMMENT_OPEN)) {
|
|
9199
|
+
close = (l) => l.trim() === "-->";
|
|
9200
|
+
lang = "comment";
|
|
9201
|
+
meta = m[1] ?? "";
|
|
9202
|
+
} else continue;
|
|
9203
|
+
let j = i + 1;
|
|
9204
|
+
while (j < lines.length && !close(lines[j].replace(/\r$/, ""))) j++;
|
|
9205
|
+
if (j >= lines.length) break;
|
|
9206
|
+
if (lang === "comment" || languages.includes(lang) && !/(^|\s)no-render(\s|$)/.test(meta)) {
|
|
9207
|
+
const name = meta.split(/\s+/).find((w) => /^[\w.-]+$/.test(w) && !FLAGS.has(w));
|
|
9208
|
+
blocks.push({
|
|
9209
|
+
index: blocks.length,
|
|
9210
|
+
lang,
|
|
9211
|
+
...name ? { name } : {},
|
|
9212
|
+
line: i + 1,
|
|
9213
|
+
end: j + 1,
|
|
9214
|
+
source: lines.slice(i + 1, j).join("\n")
|
|
9215
|
+
});
|
|
9216
|
+
}
|
|
9217
|
+
i = j;
|
|
9218
|
+
}
|
|
9219
|
+
return blocks;
|
|
9220
|
+
}
|
|
9163
9221
|
function imageRef(name, lightPath, darkPath, href) {
|
|
9164
9222
|
if (darkPath) {
|
|
9165
9223
|
const pic = `<picture><source media="(prefers-color-scheme: dark)" srcset="${darkPath}"><img alt="${name}" src="${lightPath}"></picture>`;
|
|
@@ -9171,48 +9229,26 @@ function imageRef(name, lightPath, darkPath, href) {
|
|
|
9171
9229
|
const unlinked = (ref) => ref.match(/^\[(!\[[^\]]*\]\([^)]*\))\]\([^)]*\)$/)?.[1] ?? ref.match(/^<a href="[^"]*">(<picture>.*<\/picture>)<\/a>$/)?.[1] ?? ref;
|
|
9172
9230
|
function findBlocks(md, baseName = "diagram", outDir = "diagrams") {
|
|
9173
9231
|
const lines = md.split("\n");
|
|
9174
|
-
const blocks = [];
|
|
9175
9232
|
const used = /* @__PURE__ */ new Set();
|
|
9176
|
-
|
|
9177
|
-
const line = lines[i];
|
|
9178
|
-
let m = line.match(COMMENT_OPEN);
|
|
9179
|
-
let kind;
|
|
9180
|
-
let closer;
|
|
9181
|
-
let name;
|
|
9182
|
-
if (m) {
|
|
9183
|
-
kind = "comment";
|
|
9184
|
-
name = m[1];
|
|
9185
|
-
closer = (l) => l.trim() === "-->";
|
|
9186
|
-
} else if (m = line.match(FENCE_OPEN)) {
|
|
9187
|
-
kind = "fence";
|
|
9188
|
-
name = m[2];
|
|
9189
|
-
const fence = m[1];
|
|
9190
|
-
closer = (l) => l.trim() === fence;
|
|
9191
|
-
} else continue;
|
|
9192
|
-
let j = i + 1;
|
|
9193
|
-
while (j < lines.length && !closer(lines[j])) j++;
|
|
9194
|
-
if (j >= lines.length) break;
|
|
9195
|
-
const index = blocks.length;
|
|
9233
|
+
return pageBlocks(md).map(({ index, name, source, lang, line, end }) => {
|
|
9196
9234
|
let n = name ?? `${baseName}-${index + 1}`;
|
|
9197
9235
|
while (used.has(n)) n += "-" + (index + 1);
|
|
9198
9236
|
used.add(n);
|
|
9199
9237
|
const b = {
|
|
9200
9238
|
index,
|
|
9201
9239
|
name: n,
|
|
9202
|
-
source
|
|
9203
|
-
kind,
|
|
9204
|
-
start:
|
|
9205
|
-
end:
|
|
9240
|
+
source,
|
|
9241
|
+
kind: lang === "comment" ? "comment" : "fence",
|
|
9242
|
+
start: line - 1,
|
|
9243
|
+
end: end - 1
|
|
9206
9244
|
};
|
|
9207
|
-
let k =
|
|
9208
|
-
while (k < lines.length && lines[k].trim() === "" && k <=
|
|
9245
|
+
let k = b.end + 1;
|
|
9246
|
+
while (k < lines.length && lines[k].trim() === "" && k <= b.end + 1) k++;
|
|
9209
9247
|
const candidate = unlinked(lines[k]?.trim() ?? "");
|
|
9210
9248
|
const path = joinPath(outDir, `${n}.svg`);
|
|
9211
9249
|
if (candidate === imageRef(n, path) || candidate === imageRef(n, path, joinPath(outDir, `${n}.dark.svg`))) b.image = [k, k];
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
}
|
|
9215
|
-
return blocks;
|
|
9250
|
+
return b;
|
|
9251
|
+
});
|
|
9216
9252
|
}
|
|
9217
9253
|
const joinPath = (dir, file) => dir ? dir.replace(/\/+$/, "") + "/" + file : file;
|
|
9218
9254
|
function processMarkdown(md, opts = {}) {
|
|
@@ -9581,4 +9617,4 @@ function render(input, opts = {}) {
|
|
|
9581
9617
|
diagnostics: diagram.diagnostics
|
|
9582
9618
|
};
|
|
9583
9619
|
}
|
|
9584
|
-
export {
|
|
9620
|
+
export { gantt$1 as A, charts as B, GRID as C, treeview as D, builtins as E, sequence$1 as F, markers as H, legend as I, footer as L, git$1 as M, chart as N, kanban$1 as O, timeline$1 as P, frames as R, renderSvg as S, layout as T, shapes as U, themes as V, writeLayout as _, MD_LANGUAGES as a, isMermaid as b, pageBlocks as c, editPart as d, formatLayout as f, setSetting as g, setProp as h, GUIDE as i, mindmap$1 as j, quadrant$1 as k, processMarkdown as l, setPartTone as m, render as n, findBlocks as o, setLabel as p, toSource as r, isMarkdown as s, hash as t, replaceBlockSource as u, writePanelDrag as v, groupPath as w, fromJSON as x, fromMermaid as y, tables as z };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/svg-uri.ts
|
|
2
|
+
const PREFIX = "data:image/svg+xml,";
|
|
3
|
+
/** the SVG as a `data:` URI, for an `<img src>` */
|
|
4
|
+
const svgDataUri = (svg) => PREFIX + encodeURIComponent(svg);
|
|
5
|
+
/** the SVG inside a URI made by `svgDataUri`, or `undefined` for any other URI */
|
|
6
|
+
const svgFromDataUri = (uri) => uri.startsWith(PREFIX) ? decodeURIComponent(uri.slice(19)) : void 0;
|
|
7
|
+
export { svgFromDataUri as n, svgDataUri as t };
|
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as isYuhwaPath } from "./parse--ljBMU60.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
import { n as render } from "./src-
|
|
3
|
+
import { i as errorMessage, t as diskResolve } from "./node-CkrQnPFb.js";
|
|
4
|
+
import { n as render } from "./src-NCXCTK_4.js";
|
|
5
5
|
// src/integrations/vite.ts
|
|
6
6
|
/**
|
|
7
7
|
* Vite plugin: `import diagram from './arch.yu'` gives the rendered SVG
|
package/dist/vuepress.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* import { yuhwaPlugin } from 'yuhwa/vuepress';
|
|
6
6
|
* export default defineUserConfig({ plugins: [yuhwaPlugin()] });
|
|
7
7
|
*
|
|
8
|
-
* `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
|
|
8
|
+
* `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script. The
|
|
9
|
+
* canvas script always loads, for `output=canvas` fences.
|
|
9
10
|
*/
|
|
10
11
|
import yuhwaMarkdownIt from "./markdown-it.js";
|
|
11
|
-
import { t as YuhwaDocsOptions } from "./figure-
|
|
12
|
+
import { t as YuhwaDocsOptions } from "./figure-BLHfxz_e.js";
|
|
12
13
|
interface App {
|
|
13
14
|
writeTemp: (file: string, content: string) => Promise<string>;
|
|
14
15
|
}
|
package/dist/vuepress.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import yuhwaMarkdownIt from "./markdown-it.js";
|
|
2
|
+
import { r as clientImports } from "./node-CkrQnPFb.js";
|
|
2
3
|
// src/integrations/vuepress.ts
|
|
3
4
|
/**
|
|
4
5
|
* VuePress 2 plugin: renders ```yuhwa fences and adds the light/dark stylesheet.
|
|
@@ -7,7 +8,8 @@ import yuhwaMarkdownIt from "./markdown-it.js";
|
|
|
7
8
|
* import { yuhwaPlugin } from 'yuhwa/vuepress';
|
|
8
9
|
* export default defineUserConfig({ plugins: [yuhwaPlugin()] });
|
|
9
10
|
*
|
|
10
|
-
* `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script.
|
|
11
|
+
* `yuhwaPlugin({ zoom: true })` also loads the pan and zoom script. The
|
|
12
|
+
* canvas script always loads, for `output=canvas` fences.
|
|
11
13
|
*/
|
|
12
14
|
function yuhwaPlugin(opts = {}) {
|
|
13
15
|
return {
|
|
@@ -16,7 +18,7 @@ function yuhwaPlugin(opts = {}) {
|
|
|
16
18
|
...opts,
|
|
17
19
|
zoom: true
|
|
18
20
|
} : opts),
|
|
19
|
-
clientConfigFile: (app) => app.writeTemp("yuhwa/client.js",
|
|
21
|
+
clientConfigFile: (app) => app.writeTemp("yuhwa/client.js", clientImports(opts).map((m) => `import '${m}';\n`).join("") + "export default {};\n")
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
export { yuhwaPlugin as default, yuhwaPlugin };
|