yuhwa 1.10.0 → 1.11.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.
Files changed (56) hide show
  1. package/dist/{api-BrWeKQBu.d.ts → api-C3G57UWP.d.ts} +4 -4
  2. package/dist/{api-c1vlj6Xc.js → api-DgN94Ia1.js} +106 -50
  3. package/dist/astro.d.ts +1 -1
  4. package/dist/astro.js +1 -1
  5. package/dist/browser.d.ts +3 -3
  6. package/dist/browser.js +6 -6
  7. package/dist/canvas.js +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/edit-CGlOr7JF.js +1815 -0
  10. package/dist/editor/assets/{index-SdbT9cS9.css → index-BS6hb9gg.css} +1 -1
  11. package/dist/editor/assets/index-BwZSlP7B.js +983 -0
  12. package/dist/editor/assets/lsp.worker-dqJH5PcT.js +63 -0
  13. package/dist/editor/index.html +2 -2
  14. package/dist/{figure-DCSq2hum.d.ts → figure-DX7Wgxue.d.ts} +1 -1
  15. package/dist/{index-Ds9SPfCB.d.ts → index-D9DnkCVK.d.ts} +1 -1
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +6 -6
  18. package/dist/ironmark.d.ts +1 -1
  19. package/dist/ironmark.js +1 -1
  20. package/dist/{lex-BRb7NHAG.js → lex-BODknbgk.js} +9 -4
  21. package/dist/llms.txt +18 -6
  22. package/dist/lsp-browser.js +1 -1
  23. package/dist/lsp-node.js +1 -1
  24. package/dist/lsp-server.js +1 -1
  25. package/dist/lsp.js +1 -1
  26. package/dist/markdown-it.d.ts +1 -1
  27. package/dist/markdown-it.js +2 -2
  28. package/dist/{node-B_OPTkH3.js → node-CT1lI4A1.js} +4 -4
  29. package/dist/{plugin-YrxTJq_l.js → plugin-0SWraI4f.js} +1 -1
  30. package/dist/{plugin-C5-zqGvn.d.ts → plugin-C7_KZZrW.d.ts} +1 -1
  31. package/dist/plugin.d.ts +2 -2
  32. package/dist/plugin.js +2 -2
  33. package/dist/{plugins-CjPvqfCw.js → plugins-3oYK28f5.js} +13663 -6694
  34. package/dist/plugins.d.ts +7 -2
  35. package/dist/plugins.js +3 -3
  36. package/dist/{raster-BiNccV8g.js → raster-D1uJMbl7.js} +1 -1
  37. package/dist/remark.d.ts +1 -1
  38. package/dist/remark.js +1 -1
  39. package/dist/satteri.d.ts +1 -1
  40. package/dist/satteri.js +1 -1
  41. package/dist/{server-pVExpUnd.js → server-DqKDSDjt.js} +2 -2
  42. package/dist/{service-Bvjw54cn.js → service-C01nJa8B.js} +4 -4
  43. package/dist/{shapes-B4G5tuP8.d.ts → shapes-EDGQ3ksZ.d.ts} +15 -1
  44. package/dist/{shared-DwNQ218l.js → shared-pKyDW6fZ.js} +15559 -7718
  45. package/dist/slim.d.ts +2 -2
  46. package/dist/slim.js +4 -4
  47. package/dist/{src-CmIylF2R.js → src-DmT2jkJ-.js} +3 -3
  48. package/dist/vite.d.ts +1 -1
  49. package/dist/vite.js +3 -3
  50. package/dist/vuepress.d.ts +1 -1
  51. package/dist/vuepress.js +1 -1
  52. package/dist/yuhwa.iife.js +77 -71
  53. package/package.json +1 -1
  54. package/dist/editor/assets/index-BtmJRoSF.js +0 -844
  55. package/dist/editor/assets/lsp.worker-VcS9cd8g.js +0 -57
  56. package/dist/grammar-CvX2ko_b.js +0 -974
@@ -1,4 +1,4 @@
1
- import { A as AlignSide, Ct as PanelKind, I as Diagram, J as LayoutOverrides, P as Diagnostic, Q as PanelHandle, d as TextOptions, kn as Measure, q as Layout, rt as PartEdit, un as Theme, wt as PanelOption } from "./shapes-B4G5tuP8.js";
1
+ import { A as AlignSide, Ct as PanelKind, I as Diagram, J as LayoutOverrides, P as Diagnostic, Q as PanelHandle, d as TextOptions, kn as Measure, q as Layout, rt as PartEdit, un as Theme } from "./shapes-EDGQ3ksZ.js";
2
2
  interface ParseOptions {
3
3
  /**
4
4
  * Reads a file named by `import "..."`. Gets the resolved path (relative
@@ -286,9 +286,9 @@ declare const ENUMS: Record<string, string[]>;
286
286
  declare const COLORS: string[];
287
287
  declare const BOOLS: string[];
288
288
  declare const NUMBERS: string[];
289
- /** a panel kind's typed header props, looked up by kind name */
290
- type PanelOptions = (kind: string) => Record<string, PanelOption> | undefined;
291
- declare function lint(d: Diagram, panelOptions?: PanelOptions): void;
289
+ /** the panel kind of a name, for its header options and where each applies */
290
+ type PanelKinds = (kind: string) => Pick<PanelKind, "options" | "applies"> | undefined;
291
+ declare function lint(d: Diagram, panelKinds?: PanelKinds): void;
292
292
  interface Options extends LayoutOptions, RenderOptions {
293
293
  /**
294
294
  * Reads files named by `import "..."`: gets the resolved path, returns the
@@ -1,6 +1,6 @@
1
- import { $ as AFTER_LAYOUT, $t as f$1, A as MAX_NUMBER, B as placementOf, Bt as panelTheme, C as SETTING_VALUES, Cn as SCHEMES, D as EDGE_PROPS, Dn as TONES, Dt as listsIds, Et as alignSide, Fn as isColor, G as normalizeShape, Gt as resolvePanelStyle, Ht as resolveEdgeStyle, I as SIDES$2, It as inheritedProp, Jn as errorText, Jt as withEdgeInk, Kt as size, L as didYouMean, Lt as isLane, Mn as fontStack, Mt as groupGap, Nn as getScheme, Nt as groupPadding, On as bool, Pn as getTheme, Pt as groupPath, Q as textOffset, Qt as esc, R as inRange, Rn as isSafeLink, S as SETTING_NAMES, Tn as THEME_KEYS, Tt as alignSets, Un as resolveColor, Ut as resolveGroupStyle, V as propLine, Vt as posNum, W as SIDE_NORMAL, Wn as themeNames, Wt as resolveNodeStyle, X as shapePath, Xn as ownerOf, Xt as bakeBaselines, Y as shapeDetail, Z as sizeForShape, Zn as table, Zt as dedent, _ as unescape, _n as tspans, _t as sub, a as lex, at as headSize, b as KNOWN_SETTINGS, c as parseProps, cn as richText, ct as trimFor, d as serializeProps, dt as center, en as fontAttrs, et as MARKER_KINDS, f as serializeValue, fn as splitWords, ft as hits, g as stripComment$1, gn as textLines, gt as sample, hn as textEl, ht as pointAtHalf, i as blockBraces, in as parseInline, it as endDirection, j as NODE_PROPS, jt as effectiveProps, k as GROUP_PROPS, kt as edgeFont, l as propKey, ln as richW, lt as SIDES$1, mn as sumW, mt as pathData, n as addNodeProps, nn as lineHeight, o as nodeProps, on as plain, ot as labelSpot, pn as subInk, pt as norm, q as portPoint, qn as collecting, qt as textFont, r as arrowInfo, rn as nodeInk, rt as renderHead, sn as renderSegs, st as trim, t as KEYED_TAIL_RE, tt as POST_RENDER, u as quote$1, un as segsW, ut as add, v as unquote, vt as orthoRoute, w as STATEMENT_KEYWORDS, wt as ALIGN_SIDES_HINT, y as DIRECTION_ALIASES, yn as MONO, yt as smoothRoute, z as lint, zt as num } from "./lex-BRb7NHAG.js";
2
- import { C as TRANSFORMS, S as STATEMENTS, b as unknownPanelHint, c as drawText, f as startMeasure, g as registry, u as approxMeasure, x as PANELS, y as foreignHint } from "./plugin-YrxTJq_l.js";
3
- import { d as indentTree, n as toEbnf, r as csvFields } from "./grammar-CvX2ko_b.js";
1
+ import { $ as AFTER_LAYOUT, $t as f$1, A as MAX_NUMBER, B as placementOf, Bt as panelTheme, C as SETTING_VALUES, Cn as SCHEMES, D as EDGE_PROPS, Dn as TONES, Dt as listsIds, Et as alignSide, Fn as isColor, G as normalizeShape, Gt as resolvePanelStyle, Ht as resolveEdgeStyle, I as SIDES$2, It as inheritedProp, Jn as errorText, Jt as withEdgeInk, Kt as size, L as didYouMean, Lt as isLane, Mn as fontStack, Mt as groupGap, Nn as getScheme, Nt as groupPadding, On as bool, Pn as getTheme, Pt as groupPath, Q as textOffset, Qt as esc, R as inRange, Rn as isSafeLink, S as SETTING_NAMES, Tn as THEME_KEYS, Tt as alignSets, Un as resolveColor, Ut as resolveGroupStyle, V as propLine, Vt as posNum, W as SIDE_NORMAL, Wn as themeNames, Wt as resolveNodeStyle, X as shapePath, Xn as ownerOf, Xt as bakeBaselines, Y as shapeDetail, Z as sizeForShape, Zn as table, Zt as dedent, _ as unescape, _n as tspans, _t as sub, a as lex, at as headSize, b as KNOWN_SETTINGS, c as parseProps, cn as richText, ct as trimFor, d as serializeProps, dt as center, en as fontAttrs, et as MARKER_KINDS, f as serializeValue, fn as splitWords, ft as hits, g as stripComment$1, gn as textLines, gt as sample, hn as textEl, ht as pointAtHalf, i as blockBraces, in as parseInline, it as endDirection, j as NODE_PROPS, jt as effectiveProps, k as GROUP_PROPS, kt as edgeFont, l as propKey, ln as richW, lt as SIDES$1, mn as sumW, mt as pathData, n as addNodeProps, nn as lineHeight, o as nodeProps, on as plain, ot as labelSpot, pn as subInk, pt as norm, q as portPoint, qn as collecting, qt as textFont, r as arrowInfo, rn as nodeInk, rt as renderHead, sn as renderSegs, st as trim, t as KEYED_TAIL_RE, tt as POST_RENDER, u as quote$1, un as segsW, ut as add, v as unquote, vt as orthoRoute, w as STATEMENT_KEYWORDS, wt as ALIGN_SIDES_HINT, y as DIRECTION_ALIASES, yn as MONO, yt as smoothRoute, z as lint, zt as num } from "./lex-BODknbgk.js";
2
+ import { C as TRANSFORMS, S as STATEMENTS, b as unknownPanelHint, c as drawText, f as startMeasure, g as registry, u as approxMeasure, x as PANELS, y as foreignHint } from "./plugin-0SWraI4f.js";
3
+ import { J as indentTree, a as taskLine, d as csvFields, r as labelToken, s as clampScore, u as toEbnf } from "./edit-CGlOr7JF.js";
4
4
  // src/core/route/sides.ts
5
5
  /** Choose the side of `box` facing `target`. */
6
6
  function autoSide(box, target, other, dir) {
@@ -1763,7 +1763,7 @@ function finish(p) {
1763
1763
  if (p.hasExport) checkExports(p);
1764
1764
  settlePanels(p);
1765
1765
  checkNames(p);
1766
- lint(p.d, (kind) => PANELS.get(kind)?.options);
1766
+ lint(p.d, (kind) => PANELS.get(kind));
1767
1767
  if (!p.opts.chain) collecting(p.d.diagnostics, () => TRANSFORMS.forEach((t) => t(p.d)));
1768
1768
  checkLayout(p);
1769
1769
  checkLanes(p);
@@ -5445,17 +5445,32 @@ const pie = (lines, ctx) => {
5445
5445
  return panel("chart", panelId(state.title, "pie"), state.title, ["type: pie"], body);
5446
5446
  };
5447
5447
  const X_AXIS_RE = /^x-axis\b\s*(?:"[^"]*"|[^\s[]+)?\s*(.*)$/;
5448
- const SERIES_RE = /^(bar|line)\b\s*(?:"[^"]*")?\s*(\[.*\])\s*$/;
5449
- /** one chart panel per series, since a yuhwa chart plots one series */
5448
+ const SERIES_RE = /^(bar|line)\b\s*(?:"([^"]*)")?\s*(\[.*\])\s*$/;
5449
+ const axisLabel = (s) => quoteIf(s, /[,[\]:"]/);
5450
+ /**
5451
+ * Series of one type become one multi-series chart under an `axes:` line;
5452
+ * a mix of bars and lines becomes one chart per series, since a yuhwa
5453
+ * chart has a single type.
5454
+ */
5450
5455
  function seriesCharts(series, categories, horizontal, title) {
5451
5456
  const base = panelId(title, "xy");
5452
5457
  if (!series.length) return panel("chart", base, title, ["type: column"], []);
5458
+ const typeOf = (s) => s.type === "line" ? "line" : horizontal ? "bar" : "column";
5459
+ const category = (i) => categories[i] ?? String(i + 1);
5460
+ if (series.length > 1 && series.every((s) => s.type === series[0].type)) {
5461
+ const n = Math.max(...series.map((s) => s.values.length));
5462
+ const body = [`axes: ${Array.from({ length: n }, (_, i) => axisLabel(category(i))).join(", ")}`];
5463
+ series.forEach((s, k) => {
5464
+ const values = Array.from({ length: n }, (_, i) => s.values[i] ?? "0");
5465
+ body.push(`${chartLabel(s.name || `Series ${k + 1}`)}: ${values.join(", ")}`);
5466
+ });
5467
+ return panel("chart", base, title, [`type: ${typeOf(series[0])}`], body);
5468
+ }
5453
5469
  const out = [];
5454
5470
  series.forEach((s, k) => {
5455
- const body = s.values.map((v, i) => `${chartLabel(categories[i] ?? String(i + 1))}: ${v}`);
5456
- const type = s.type === "line" ? "line" : horizontal ? "bar" : "column";
5471
+ const body = s.values.map((v, i) => `${chartLabel(category(i))}: ${v}`);
5457
5472
  if (k) out.push("");
5458
- out.push(...panel("chart", k ? `${base}${k + 1}` : base, title, [`type: ${type}`], body));
5473
+ out.push(...panel("chart", k ? `${base}${k + 1}` : base, title, [`type: ${typeOf(s)}`], body));
5459
5474
  });
5460
5475
  return out;
5461
5476
  }
@@ -5478,12 +5493,14 @@ const xychart = (lines, ctx) => {
5478
5493
  const s = l.text.match(SERIES_RE);
5479
5494
  if (s) series.push({
5480
5495
  type: s[1],
5481
- values: splitList$1(s[2]),
5496
+ name: s[2],
5497
+ values: splitList$1(s[3]),
5482
5498
  line: l.line
5483
5499
  });
5484
5500
  return !!s;
5485
5501
  });
5486
- if (series.length > 1) ctx.warn(series[1].line, "each xychart series becomes its own chart; yuhwa charts plot one series");
5502
+ const mixed = series.find((s) => s.type !== series[0].type);
5503
+ if (mixed) ctx.warn(mixed.line, "bars and lines become separate charts; a yuhwa chart has one type");
5487
5504
  return seriesCharts(series, categories, /\bhorizontal\b/.test(ctx.header), state.title);
5488
5505
  };
5489
5506
  const QUADRANT_AXIS_RE = /^([xy])-axis\s+(.*)$/;
@@ -5652,7 +5669,7 @@ const gantt = (lines, ctx) => {
5652
5669
  return panel("gantt", panelId(state.title, "plan"), state.title, [], body);
5653
5670
  };
5654
5671
  // src/convert/mermaid/panels/boards.ts
5655
- /** Mermaid timeline, journey, mindmap and kanban: diagrams of sections and items. */
5672
+ /** Mermaid timeline, mindmap and kanban: diagrams of sections and items. */
5656
5673
  const timeline = (lines, ctx) => {
5657
5674
  const state = { title: ctx.title };
5658
5675
  const body = [];
@@ -5690,27 +5707,6 @@ const timeline = (lines, ctx) => {
5690
5707
  });
5691
5708
  return panel("timeline", panelId(state.title, "events"), state.title, [], body);
5692
5709
  };
5693
- const JOURNEY_TASK_RE = /^(.+?)\s*:\s*(\d+(?:\.\d+)?)\s*(?::\s*(.*))?$/;
5694
- /** red for unhappy scores (≤ 2), amber in between, green from 4 */
5695
- const scoreTone = (score) => score <= 2 ? "red" : score < 4 ? "amber" : "green";
5696
- const journey = (lines, ctx) => {
5697
- const state = { title: ctx.title };
5698
- const body = [];
5699
- readStatements(lines, ctx, state, (l) => {
5700
- const section = l.text.match(SECTION_RE);
5701
- if (section) {
5702
- body.push(`// ${oneLine(section[1])}`);
5703
- return true;
5704
- }
5705
- const m = l.text.match(JOURNEY_TASK_RE);
5706
- if (!m) return false;
5707
- const [, task, score, actors] = m;
5708
- if (actors) ctx.warnOnce("actors", l.line, "journey actors are skipped; scores become a column chart");
5709
- body.push(`${chartLabel(oneLine(task))} [${scoreTone(Number(score))}]: ${score}`);
5710
- return true;
5711
- });
5712
- return panel("chart", panelId(state.title, "journey"), state.title, ["type: column"], body);
5713
- };
5714
5710
  const MM_SHAPES = [
5715
5711
  [
5716
5712
  "((",
@@ -5835,6 +5831,38 @@ const kanban = (lines, ctx) => {
5835
5831
  }
5836
5832
  return panel("kanban", panelId(ctx.title, "board"), ctx.title, [], body);
5837
5833
  };
5834
+ // src/convert/mermaid/panels/journey.ts
5835
+ /**
5836
+ * Mermaid journey to a yuhwa `journey` panel. The panel reads the same
5837
+ * sections and `task: score: actors` lines, so the body carries over; tasks
5838
+ * are indented under their section, and scores outside 1–5 are clamped.
5839
+ */
5840
+ const TASK_RE = /^(.+?)\s*:\s*(-?\d+(?:\.\d+)?)\s*(?::\s*(.*))?$/;
5841
+ const journey = (lines, ctx) => {
5842
+ const state = { title: ctx.title };
5843
+ const body = [];
5844
+ let indent = "";
5845
+ readStatements(lines, ctx, state, (l) => {
5846
+ const section = l.text.match(SECTION_RE);
5847
+ if (section) {
5848
+ const name = oneLine(section[1]);
5849
+ if (name) {
5850
+ body.push(`section ${name}`);
5851
+ indent = " ";
5852
+ }
5853
+ return true;
5854
+ }
5855
+ const m = l.text.match(TASK_RE);
5856
+ if (!m) return false;
5857
+ const [, task, raw, who] = m;
5858
+ const score = clampScore(Number(raw));
5859
+ if (score !== Number(raw)) ctx.warn(l.line, `score ${raw} of "${oneLine(task)}" was clamped to ${score}`);
5860
+ const actors = (who ?? "").split(",").map((a) => oneLine(a)).filter(Boolean);
5861
+ body.push(taskLine(indent, labelToken(oneLine(task)), void 0, score, actors));
5862
+ return true;
5863
+ });
5864
+ return panel("journey", panelId(state.title, "journey"), state.title, [], body);
5865
+ };
5838
5866
  // src/convert/mermaid/state.ts
5839
5867
  /**
5840
5868
  * Mermaid stateDiagram → yuhwa nodes and groups.
@@ -9357,15 +9385,38 @@ function editPart(source, panelId, edit, d = parse(source)) {
9357
9385
  id = r?.id;
9358
9386
  return r?.body ?? null;
9359
9387
  });
9388
+ if (out === source || !bracketsReadBack(out, panelId, edit, id)) return { source };
9360
9389
  return {
9361
9390
  source: out,
9362
- id: out === source ? void 0 : id
9391
+ id
9363
9392
  };
9364
9393
  }
9394
+ /**
9395
+ * A set value with brackets must read back as written: a trailing `[red]`
9396
+ * easily turns into the part's colour, and `[a [b]]` breaks a props tail.
9397
+ * Other values may come back normalised (`1w` as `7d`), so only these are checked.
9398
+ */
9399
+ function bracketsReadBack(out, panelId, edit, id) {
9400
+ if (edit.op !== "set" || edit.key === "color" || !/[[\]]/.test(edit.value ?? "")) return true;
9401
+ const decl = parse(out).panels.find((p) => p.id === panelId);
9402
+ return (id === void 0 ? void 0 : decl && PANELS.get(decl.kind)?.parts?.(decl.data).find((p) => p.id === id))?.values?.[edit.key] === edit.value.trim();
9403
+ }
9365
9404
  /** Finish a panel drag. Prefer the declaration; a purely visual handle uses layout. */
9366
9405
  function writePanelDrag(source, d, id, handle) {
9367
9406
  const decl = d.panels.find((p) => p.id === id);
9368
9407
  const offset = d.layout.panels?.[id]?.parts?.[handle.part];
9408
+ if (offset && handle.editProps && decl?.ref && !decl.ref.generated) {
9409
+ const props = handle.editProps(offset);
9410
+ if (!props) return writeLayout(source, d.layout, d);
9411
+ let out = source;
9412
+ for (const [key, value] of Object.entries(props)) out = setProp(out, {
9413
+ kind: "panel",
9414
+ id
9415
+ }, key, value);
9416
+ const lines = splitLines(out);
9417
+ dropPartEntry(lines, parse(out).layoutBlock, id + ":" + handle.part);
9418
+ return joinLines(lines, out);
9419
+ }
9369
9420
  if (!offset || !handle.editPosition || !decl?.lines || decl.ref?.generated) return writeLayout(source, d.layout, d);
9370
9421
  const [start, end] = decl.lines;
9371
9422
  const lines = splitLines(source);
@@ -9375,25 +9426,30 @@ function writePanelDrag(source, d, id, handle) {
9375
9426
  if (first < 0) return writeLayout(source, d.layout, d);
9376
9427
  const editable = code.slice(first, first + decl.body.length);
9377
9428
  const edited = handle.editPosition(editable, offset);
9378
- if (!edited || edited.length !== editable.length) return writeLayout(source, d.layout, d);
9379
- edited.forEach((line, i) => {
9429
+ const commented = editable.some((line, i) => body[first + i].length !== line.length);
9430
+ if (!edited || edited.length !== editable.length && commented) return writeLayout(source, d.layout, d);
9431
+ if (edited.length === editable.length) edited.forEach((line, i) => {
9380
9432
  lines[start + 1 + first + i] = line + body[first + i].slice(editable[i].length);
9381
9433
  });
9382
- if (d.layoutBlock) {
9383
- const [a, b] = d.layoutBlock;
9384
- const key = id + ":" + handle.part;
9385
- const entries = lines.slice(a + 1, b);
9386
- const keep = entries.filter((line) => line.trimStart().split(/\s+/, 1)[0] !== key);
9387
- if (keep.length !== entries.length) {
9388
- if (keep.some((line) => line.trim())) lines.splice(a + 1, entries.length, ...keep);
9389
- else {
9390
- const from = a > 0 && !lines[a - 1].trim() ? a - 1 : a;
9391
- lines.splice(from, b - from + 1);
9392
- }
9393
- }
9394
- }
9434
+ else lines.splice(start + 1 + first, editable.length, ...edited);
9435
+ const lb = d.layoutBlock;
9436
+ const shift = lb && lb[0] > start ? edited.length - editable.length : 0;
9437
+ dropPartEntry(lines, lb && [lb[0] + shift, lb[1] + shift], id + ":" + handle.part);
9395
9438
  return joinLines(lines, source);
9396
9439
  }
9440
+ /** drop the `key` entry from the layout block at `block`, and the block when nothing else is left in it */
9441
+ function dropPartEntry(lines, block, key) {
9442
+ if (!block) return;
9443
+ const [a, b] = block;
9444
+ const entries = lines.slice(a + 1, b);
9445
+ const keep = entries.filter((line) => line.trimStart().split(/\s+/, 1)[0] !== key);
9446
+ if (keep.length === entries.length) return;
9447
+ if (keep.some((line) => line.trim())) lines.splice(a + 1, entries.length, ...keep);
9448
+ else {
9449
+ const from = a > 0 && !lines[a - 1].trim() ? a - 1 : a;
9450
+ lines.splice(from, b - from + 1);
9451
+ }
9452
+ }
9397
9453
  /** rewrite a panel's body lines, re-indented like the old ones */
9398
9454
  function editBody(source, panelId, d, fn) {
9399
9455
  const decl = d.panels.find((p) => p.id === panelId);
@@ -9401,7 +9457,7 @@ function editBody(source, panelId, d, fn) {
9401
9457
  const at = decl?.bodyAt;
9402
9458
  if (!decl?.lines || at === void 0 || !kind || decl.failed || decl.ref?.generated) return source;
9403
9459
  const body = fn(kind, decl);
9404
- if (!body) return source;
9460
+ if (!body || body.some((l) => lex(l).codeEnd < l.trimEnd().length)) return source;
9405
9461
  const lines = splitLines(source);
9406
9462
  const indent = innerIndent(lines, decl.lines[0], decl.lines[1]);
9407
9463
  const n = decl.body.length;
package/dist/astro.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as YuhwaDocsOptions } from "./figure-DCSq2hum.js";
1
+ import { t as YuhwaDocsOptions } from "./figure-DX7Wgxue.js";
2
2
  interface Watcher {
3
3
  on: (event: "change" | "add", fn: (file: string) => void) => unknown;
4
4
  add: (files: string[]) => unknown;
package/dist/astro.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import remarkYuhwa from "./remark.js";
2
2
  import satteriYuhwa from "./satteri.js";
3
- import { n as onTrack, o as clientImports, r as pagesUsing } from "./node-B_OPTkH3.js";
3
+ import { n as onTrack, o as clientImports, r as pagesUsing } from "./node-CT1lI4A1.js";
4
4
  // src/integrations/astro.ts
5
5
  /**
6
6
  * Astro integration, also for Starlight: renders ```yuhwa blocks in .md and
package/dist/browser.d.ts CHANGED
@@ -11,10 +11,10 @@
11
11
  * <yuhwa-diagram render="canvas">a -> b</yuhwa-diagram> // or png; default svg
12
12
  * el.source = 'a -> b' // re-renders
13
13
  */
14
- import { $ as PanelOverride, $t as LineStyle, A as AlignSide, An as approxMeasure, At as optionKind, B as GroupDecl, Bt as Seg, C as serializeProps, Cn as isToneOrHex, Ct as PanelKind, Dt as RowPaint, E as splitTrailingProps, En as registerTheme, Et as RowKind, F as DiagnosticCode, Ft as use, G as LaidNode, Gt as parseInline, H as LabelRef, I as Diagram, It as MarkerKind, J as LayoutOverrides, Jt as segsW, K as LaidPanel, L as Direction, Lt as ShapeKind, M as Component, Mt as recolor, N as Curve, Nt as registry, On as themeNames, Ot as StatementKind, P as Diagnostic, Pt as unuse, Q as PanelHandle, R as EdgeDecl, Rt as renderHead, Sn as isSafeLink, St as PanelCtx, T as setTrailingProp, Tn as ramp, Tt as RowCtx, U as LaidEdge, V as HeadKind, Vt as esc, W as LaidGroup, X as NodeOverride, Y as NodeDecl, Z as PanelDecl, Zt as tspans, _ as TokKind, _n as getScheme, an as Scheme, at as Props, b as onlyColor, bn as isGenericFont, bt as Decoration, cn as THEME_NAMES, ct as ShapeName, d as TextOptions, dn as ThemeInput, dt as dashFor, et as PanelPart, g as Tok, gn as fontStack, gt as lineStyle, h as LexedLine, hn as fontFamilies, ht as groupProp, in as SCHEMES, it as Point, j as Box, jn as canvasMeasure, jt as perPass, k as Align, kt as YuhwaPlugin, ln as TONES, lt as Side, mt as groupPath, nn as RAMPS, nt as PartChange, on as THEMES, ot as ResolvedEdgeStyle, pn as createTheme, q as Layout, qt as renderSegs, r as portOn, rt as PartEdit, sn as THEME_KEYS, st as ResolvedNodeStyle, t as SHAPES, tn as PLAIN_THEMES, tt as PartAction, un as Theme, ut as SourceRef, v as blockBraces, vn as getTheme, w as setLineProp, wn as plainThemeNames, wt as PanelOption, x as parseProps, xn as isSafeCss, xt as FrameKind, y as lex, z as EdgeOverride, zt as InkColors } from "./shapes-B4G5tuP8.js";
15
- import { $ as isYuhwaPath, A as embedFonts, B as setPartTone, C as MdOptions, D as replaceBlockSource, E as processMarkdown, F as addNode, G as ALIGN_SIDES, H as setSetting, I as editPart, J as JsonResult, K as GRID, L as formatLayout, M as svgToCanvas, N as Target, O as FontSource, P as addEdge, Q as parse, R as removeElement, S as MdBlock, T as findBlocks, U as writeLayout, V as setProp, W as writePanelDrag, X as renderSvg, Y as fromJSON, Z as layout, _ as lint, at as ParseOptions, b as isMermaid, c as BOOLS, d as ENUMS, et as joinPath, f as GROUP_PROPS, g as PANEL_PROP_HELP, h as PANEL_PROPS, i as hash, it as SETTING_VALUES, j as loadFonts, k as RasterOptions, l as COLORS, m as NUMBERS, n as Options, nt as KNOWN_SETTINGS, o as renderText, p as NODE_PROPS, q as DiagramJSON, r as Result, rt as SETTING_HELP, s as toSource, t as InputFormat, tt as PANELS, u as EDGE_PROPS, v as ConvertResult, w as MdResult, x as MD_LANGUAGES, y as fromMermaid, z as setLabel } from "./api-BrWeKQBu.js";
14
+ import { $ as PanelOverride, $t as LineStyle, A as AlignSide, An as approxMeasure, At as optionKind, B as GroupDecl, Bt as Seg, C as serializeProps, Cn as isToneOrHex, Ct as PanelKind, Dt as RowPaint, E as splitTrailingProps, En as registerTheme, Et as RowKind, F as DiagnosticCode, Ft as use, G as LaidNode, Gt as parseInline, H as LabelRef, I as Diagram, It as MarkerKind, J as LayoutOverrides, Jt as segsW, K as LaidPanel, L as Direction, Lt as ShapeKind, M as Component, Mt as recolor, N as Curve, Nt as registry, On as themeNames, Ot as StatementKind, P as Diagnostic, Pt as unuse, Q as PanelHandle, R as EdgeDecl, Rt as renderHead, Sn as isSafeLink, St as PanelCtx, T as setTrailingProp, Tn as ramp, Tt as RowCtx, U as LaidEdge, V as HeadKind, Vt as esc, W as LaidGroup, X as NodeOverride, Y as NodeDecl, Z as PanelDecl, Zt as tspans, _ as TokKind, _n as getScheme, an as Scheme, at as Props, b as onlyColor, bn as isGenericFont, bt as Decoration, cn as THEME_NAMES, ct as ShapeName, d as TextOptions, dn as ThemeInput, dt as dashFor, et as PanelPart, g as Tok, gn as fontStack, gt as lineStyle, h as LexedLine, hn as fontFamilies, ht as groupProp, in as SCHEMES, it as Point, j as Box, jn as canvasMeasure, jt as perPass, k as Align, kt as YuhwaPlugin, ln as TONES, lt as Side, mt as groupPath, nn as RAMPS, nt as PartChange, on as THEMES, ot as ResolvedEdgeStyle, pn as createTheme, q as Layout, qt as renderSegs, r as portOn, rt as PartEdit, sn as THEME_KEYS, st as ResolvedNodeStyle, t as SHAPES, tn as PLAIN_THEMES, tt as PartAction, un as Theme, ut as SourceRef, v as blockBraces, vn as getTheme, w as setLineProp, wn as plainThemeNames, wt as PanelOption, x as parseProps, xn as isSafeCss, xt as FrameKind, y as lex, z as EdgeOverride, zt as InkColors } from "./shapes-EDGQ3ksZ.js";
15
+ import { $ as isYuhwaPath, A as embedFonts, B as setPartTone, C as MdOptions, D as replaceBlockSource, E as processMarkdown, F as addNode, G as ALIGN_SIDES, H as setSetting, I as editPart, J as JsonResult, K as GRID, L as formatLayout, M as svgToCanvas, N as Target, O as FontSource, P as addEdge, Q as parse, R as removeElement, S as MdBlock, T as findBlocks, U as writeLayout, V as setProp, W as writePanelDrag, X as renderSvg, Y as fromJSON, Z as layout, _ as lint, at as ParseOptions, b as isMermaid, c as BOOLS, d as ENUMS, et as joinPath, f as GROUP_PROPS, g as PANEL_PROP_HELP, h as PANEL_PROPS, i as hash, it as SETTING_VALUES, j as loadFonts, k as RasterOptions, l as COLORS, m as NUMBERS, n as Options, nt as KNOWN_SETTINGS, o as renderText, p as NODE_PROPS, q as DiagramJSON, r as Result, rt as SETTING_HELP, s as toSource, t as InputFormat, tt as PANELS, u as EDGE_PROPS, v as ConvertResult, w as MdResult, x as MD_LANGUAGES, y as fromMermaid, z as setLabel } from "./api-C3G57UWP.js";
16
16
  import { t as GUIDE } from "./index-Bab6qq3T.js";
17
- import { _ as markers, a as gantt, c as chart, d as legend, f as footer, g as themes, h as charts, i as quadrant, l as timeline, m as tables, n as treeview, o as mindmap, p as frames, r as kanban, s as git, t as builtins, u as sequence, v as shapes } from "./index-Ds9SPfCB.js";
17
+ import { _ as markers, a as gantt, c as chart, d as legend, f as footer, g as themes, h as charts, i as quadrant, l as timeline, m as tables, n as treeview, o as mindmap, p as frames, r as kanban, s as git, t as builtins, u as sequence, v as shapes } from "./index-D9DnkCVK.js";
18
18
  import { i as zoomable, n as Zoomer, r as zoomHeight, t as ZoomOptions } from "./zoom-CCSUbX1X.js";
19
19
  export declare function render(source: string, opts?: Options): Result;
20
20
  /** `render`, then draw the diagram into a canvas. */
package/dist/browser.js CHANGED
@@ -1,10 +1,10 @@
1
- import { t as GUIDE } from "./src-CmIylF2R.js";
2
- import { _ as unuse, d as canvasMeasure, g as registry, h as recolor, m as perPass, p as optionKind, u as approxMeasure, v as use, x as PANELS } from "./plugin-YrxTJq_l.js";
1
+ import { t as GUIDE } from "./src-DmT2jkJ-.js";
2
+ import { _ as unuse, d as canvasMeasure, g as registry, h as recolor, m as perPass, p as optionKind, u as approxMeasure, v as use, x as PANELS } from "./plugin-0SWraI4f.js";
3
3
  import { n as zoomable, t as zoomHeight } from "./zoom-D3Lahr1T.js";
4
- import { C as themes, S as charts, T as shapes, _ as sequence, b as frames, d as quadrant, f as gantt, g as timeline, h as chart, l as treeview, m as git, p as mindmap, t as builtins, u as kanban, v as legend, w as markers, x as tables, y as footer } from "./plugins-CjPvqfCw.js";
5
- import { a as svgFamilies, c as swapForRaster, n as embedFonts, r as loadFonts, s as svgToCanvas } from "./raster-BiNccV8g.js";
6
- import { Bn as plainThemeNames, C as SETTING_VALUES, Cn as SCHEMES, Ct as ALIGN_SIDES, D as EDGE_PROPS, Dn as TONES, E as COLORS, En as THEME_NAMES, Ft as groupProp, H as SHAPES, Hn as registerTheme, In as isGenericFont, K as portOn, Ln as isSafeCss, M as NUMBERS, Mn as fontStack, N as PANEL_PROPS, Nn as getScheme, O as ENUMS, Ot as dashFor, P as PANEL_PROP_HELP, Pn as getTheme, Pt as groupPath, Qt as esc, Rn as isSafeLink, Rt as lineStyle, T as BOOLS, Tn as THEME_KEYS, Vn as ramp, Wn as themeNames, _n as tspans, a as lex, b as KNOWN_SETTINGS, bn as PLAIN_THEMES, c as parseProps, d as serializeProps, h as splitTrailingProps, i as blockBraces, in as parseInline, j as NODE_PROPS, jn as fontFamilies, k as GROUP_PROPS, kn as createTheme, m as setTrailingProp, p as setLineProp, rt as renderHead, s as onlyColor, sn as renderSegs, un as segsW, v as unquote, wn as THEMES, x as SETTING_HELP, xn as RAMPS, z as lint, zn as isToneOrHex } from "./lex-BRb7NHAG.js";
7
- import { A as joinPath, C as isMermaid, D as GRID, E as layout, O as parse, S as fromMermaid, T as renderSvg, _ as setPartTone, a as MD_LANGUAGES, b as writeLayout, d as addEdge, f as addNode, g as setLabel, h as removeElement, i as toSource, k as isYuhwaPath, l as processMarkdown, m as formatLayout, n as render$1, o as findBlocks, p as editPart, r as renderText, t as hash, u as replaceBlockSource, v as setProp, w as fromJSON, x as writePanelDrag, y as setSetting } from "./api-c1vlj6Xc.js";
4
+ import { A as shapes, C as legend, D as charts, E as tables, O as themes, S as sequence, T as frames, _ as gantt, b as chart, g as quadrant, h as kanban, k as markers, m as treeview, t as builtins, v as mindmap, w as footer, x as timeline, y as git } from "./plugins-3oYK28f5.js";
5
+ import { a as svgFamilies, c as swapForRaster, n as embedFonts, r as loadFonts, s as svgToCanvas } from "./raster-D1uJMbl7.js";
6
+ import { Bn as plainThemeNames, C as SETTING_VALUES, Cn as SCHEMES, Ct as ALIGN_SIDES, D as EDGE_PROPS, Dn as TONES, E as COLORS, En as THEME_NAMES, Ft as groupProp, H as SHAPES, Hn as registerTheme, In as isGenericFont, K as portOn, Ln as isSafeCss, M as NUMBERS, Mn as fontStack, N as PANEL_PROPS, Nn as getScheme, O as ENUMS, Ot as dashFor, P as PANEL_PROP_HELP, Pn as getTheme, Pt as groupPath, Qt as esc, Rn as isSafeLink, Rt as lineStyle, T as BOOLS, Tn as THEME_KEYS, Vn as ramp, Wn as themeNames, _n as tspans, a as lex, b as KNOWN_SETTINGS, bn as PLAIN_THEMES, c as parseProps, d as serializeProps, h as splitTrailingProps, i as blockBraces, in as parseInline, j as NODE_PROPS, jn as fontFamilies, k as GROUP_PROPS, kn as createTheme, m as setTrailingProp, p as setLineProp, rt as renderHead, s as onlyColor, sn as renderSegs, un as segsW, v as unquote, wn as THEMES, x as SETTING_HELP, xn as RAMPS, z as lint, zn as isToneOrHex } from "./lex-BODknbgk.js";
7
+ import { A as joinPath, C as isMermaid, D as GRID, E as layout, O as parse, S as fromMermaid, T as renderSvg, _ as setPartTone, a as MD_LANGUAGES, b as writeLayout, d as addEdge, f as addNode, g as setLabel, h as removeElement, i as toSource, k as isYuhwaPath, l as processMarkdown, m as formatLayout, n as render$1, o as findBlocks, p as editPart, r as renderText, t as hash, u as replaceBlockSource, v as setProp, w as fromJSON, x as writePanelDrag, y as setSetting } from "./api-DgN94Ia1.js";
8
8
  // src/browser.ts
9
9
  /**
10
10
  * Drop-in browser runtime: <script src="yuhwa.js"><\/script>
package/dist/canvas.js CHANGED
@@ -17,7 +17,7 @@ function installCanvas() {
17
17
  const swap = async (img) => {
18
18
  const svg = svgFromDataUri(img.getAttribute("src") ?? "");
19
19
  if (svg === void 0) return;
20
- const { swapForRaster } = await import("./raster-BiNccV8g.js").then((n) => n.i);
20
+ const { swapForRaster } = await import("./raster-D1uJMbl7.js").then((n) => n.i);
21
21
  const canvas = await swapForRaster(img, svg, "canvas", img.alt);
22
22
  if (canvas) canvas.className = img.className;
23
23
  };
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3
- import { $ as THEME_KEYS, A as SETTING_VALUES, E as unquote, F as ENUMS, G as ALIGN_SIDES_HINT, I as GROUP_PROPS, J as esc, L as NODE_PROPS, N as COLORS, O as KNOWN_SETTINGS, P as EDGE_PROPS, Q as SCHEMES, S as registry, U as SHAPES, Z as PLAIN_THEMES, _ as replaceBlockSource, a as formatPage, b as canvasMeasure, c as diskResolve, d as toSource, et as THEME_NAMES, f as MD_LANGUAGES, g as processMarkdown, h as pageBlocks, i as format, l as render$1, m as isMarkdown, nt as isSafeCss, ot as isYuhwaPath, p as findBlocks, s as tidy, st as joinPath, t as VERSION, tt as TONES, u as renderText, x as optionKind, z as PANEL_PROPS } from "./shared-DwNQ218l.js";
3
+ import { $ as THEME_KEYS, A as SETTING_VALUES, E as unquote, F as ENUMS, G as ALIGN_SIDES_HINT, I as GROUP_PROPS, J as esc, L as NODE_PROPS, N as COLORS, O as KNOWN_SETTINGS, P as EDGE_PROPS, Q as SCHEMES, S as registry, U as SHAPES, Z as PLAIN_THEMES, _ as replaceBlockSource, a as formatPage, b as canvasMeasure, c as diskResolve, d as toSource, et as THEME_NAMES, f as MD_LANGUAGES, g as processMarkdown, h as pageBlocks, i as format, l as render$1, m as isMarkdown, nt as isSafeCss, ot as isYuhwaPath, p as findBlocks, s as tidy, st as joinPath, t as VERSION, tt as TONES, u as renderText, x as optionKind, z as PANEL_PROPS } from "./shared-pKyDW6fZ.js";
4
4
  import { createServer } from "node:http";
5
5
  import { basename, dirname, extname, join, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";