yuhwa 1.10.0 → 1.12.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 (57) hide show
  1. package/dist/{api-c1vlj6Xc.js → api-B9O53_5U.js} +111 -51
  2. package/dist/{api-BrWeKQBu.d.ts → api-C3G57UWP.d.ts} +4 -4
  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 +6 -2
  9. package/dist/edit-Cm8DW_KO.js +1815 -0
  10. package/dist/editor/assets/{index-SdbT9cS9.css → index-BS6hb9gg.css} +1 -1
  11. package/dist/editor/assets/index-BTZWiMqP.js +983 -0
  12. package/dist/editor/assets/lsp.worker-C9inZHsl.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 +21 -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-BIfDM5Y3.js} +4 -4
  29. package/dist/{plugin-YrxTJq_l.js → plugin-BCLARrq1.js} +21 -10
  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-BoaNpGLq.js} +13623 -6645
  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-udkVD8Mc.js} +2 -2
  42. package/dist/{service-Bvjw54cn.js → service-FkOpMMOi.js} +4 -4
  43. package/dist/{shapes-B4G5tuP8.d.ts → shapes-EDGQ3ksZ.d.ts} +15 -1
  44. package/dist/{shared-DwNQ218l.js → shared-DF-gLxrJ.js} +15593 -7728
  45. package/dist/slim.d.ts +2 -2
  46. package/dist/slim.js +4 -4
  47. package/dist/{src-CmIylF2R.js → src-DUTNi3wt.js} +6 -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 +80 -71
  53. package/package.json +1 -1
  54. package/skills/yuhwa/SKILL.md +6 -3
  55. package/dist/editor/assets/index-BtmJRoSF.js +0 -844
  56. package/dist/editor/assets/lsp.worker-VcS9cd8g.js +0 -57
  57. package/dist/grammar-CvX2ko_b.js +0 -974
@@ -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 STATEMENTS, S as PANELS, b as foreignHint, c as drawText, f as startMeasure, g as registry, u as approxMeasure, w as TRANSFORMS, x as unknownPanelHint, y as HASH_COMMENT } from "./plugin-BCLARrq1.js";
3
+ import { J as indentTree, a as taskLine, d as csvFields, r as labelToken, s as clampScore, u as toEbnf } from "./edit-Cm8DW_KO.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) {
@@ -1588,6 +1588,10 @@ function groupStmt(p, t, raw, li) {
1588
1588
  if (close >= 0) {
1589
1589
  ref.end = li;
1590
1590
  for (let j = k; j < close; j++) if (t[j].kind === "ident") touchNode(p, t[j].value).group = id;
1591
+ else if (t[j].value !== ",") {
1592
+ p.warn(li, `A one-line group lists ids only ("${t[j].value}" is ignored): declare labels and props inside a multi-line { } body`);
1593
+ break;
1594
+ }
1591
1595
  return;
1592
1596
  }
1593
1597
  p.stack.push({
@@ -1763,7 +1767,7 @@ function finish(p) {
1763
1767
  if (p.hasExport) checkExports(p);
1764
1768
  settlePanels(p);
1765
1769
  checkNames(p);
1766
- lint(p.d, (kind) => PANELS.get(kind)?.options);
1770
+ lint(p.d, (kind) => PANELS.get(kind));
1767
1771
  if (!p.opts.chain) collecting(p.d.diagnostics, () => TRANSFORMS.forEach((t) => t(p.d)));
1768
1772
  checkLayout(p);
1769
1773
  checkLanes(p);
@@ -2007,7 +2011,7 @@ function parse(source, opts = {}) {
2007
2011
  /** one source line: variables, components, then the statement itself */
2008
2012
  function step(p, raw0, li, done = false, scope = p.defs) {
2009
2013
  if (/^\s*#(\s|$)/.test(raw0)) {
2010
- p.warn(li, "Comments start with \"//\", not \"#\"", "error");
2014
+ p.warn(li, HASH_COMMENT, "error");
2011
2015
  return;
2012
2016
  }
2013
2017
  const top = p.stack[p.stack.length - 1];
@@ -5445,17 +5449,32 @@ const pie = (lines, ctx) => {
5445
5449
  return panel("chart", panelId(state.title, "pie"), state.title, ["type: pie"], body);
5446
5450
  };
5447
5451
  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 */
5452
+ const SERIES_RE = /^(bar|line)\b\s*(?:"([^"]*)")?\s*(\[.*\])\s*$/;
5453
+ const axisLabel = (s) => quoteIf(s, /[,[\]:"]/);
5454
+ /**
5455
+ * Series of one type become one multi-series chart under an `axes:` line;
5456
+ * a mix of bars and lines becomes one chart per series, since a yuhwa
5457
+ * chart has a single type.
5458
+ */
5450
5459
  function seriesCharts(series, categories, horizontal, title) {
5451
5460
  const base = panelId(title, "xy");
5452
5461
  if (!series.length) return panel("chart", base, title, ["type: column"], []);
5462
+ const typeOf = (s) => s.type === "line" ? "line" : horizontal ? "bar" : "column";
5463
+ const category = (i) => categories[i] ?? String(i + 1);
5464
+ if (series.length > 1 && series.every((s) => s.type === series[0].type)) {
5465
+ const n = Math.max(...series.map((s) => s.values.length));
5466
+ const body = [`axes: ${Array.from({ length: n }, (_, i) => axisLabel(category(i))).join(", ")}`];
5467
+ series.forEach((s, k) => {
5468
+ const values = Array.from({ length: n }, (_, i) => s.values[i] ?? "0");
5469
+ body.push(`${chartLabel(s.name || `Series ${k + 1}`)}: ${values.join(", ")}`);
5470
+ });
5471
+ return panel("chart", base, title, [`type: ${typeOf(series[0])}`], body);
5472
+ }
5453
5473
  const out = [];
5454
5474
  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";
5475
+ const body = s.values.map((v, i) => `${chartLabel(category(i))}: ${v}`);
5457
5476
  if (k) out.push("");
5458
- out.push(...panel("chart", k ? `${base}${k + 1}` : base, title, [`type: ${type}`], body));
5477
+ out.push(...panel("chart", k ? `${base}${k + 1}` : base, title, [`type: ${typeOf(s)}`], body));
5459
5478
  });
5460
5479
  return out;
5461
5480
  }
@@ -5478,12 +5497,14 @@ const xychart = (lines, ctx) => {
5478
5497
  const s = l.text.match(SERIES_RE);
5479
5498
  if (s) series.push({
5480
5499
  type: s[1],
5481
- values: splitList$1(s[2]),
5500
+ name: s[2],
5501
+ values: splitList$1(s[3]),
5482
5502
  line: l.line
5483
5503
  });
5484
5504
  return !!s;
5485
5505
  });
5486
- if (series.length > 1) ctx.warn(series[1].line, "each xychart series becomes its own chart; yuhwa charts plot one series");
5506
+ const mixed = series.find((s) => s.type !== series[0].type);
5507
+ if (mixed) ctx.warn(mixed.line, "bars and lines become separate charts; a yuhwa chart has one type");
5487
5508
  return seriesCharts(series, categories, /\bhorizontal\b/.test(ctx.header), state.title);
5488
5509
  };
5489
5510
  const QUADRANT_AXIS_RE = /^([xy])-axis\s+(.*)$/;
@@ -5652,7 +5673,7 @@ const gantt = (lines, ctx) => {
5652
5673
  return panel("gantt", panelId(state.title, "plan"), state.title, [], body);
5653
5674
  };
5654
5675
  // src/convert/mermaid/panels/boards.ts
5655
- /** Mermaid timeline, journey, mindmap and kanban: diagrams of sections and items. */
5676
+ /** Mermaid timeline, mindmap and kanban: diagrams of sections and items. */
5656
5677
  const timeline = (lines, ctx) => {
5657
5678
  const state = { title: ctx.title };
5658
5679
  const body = [];
@@ -5690,27 +5711,6 @@ const timeline = (lines, ctx) => {
5690
5711
  });
5691
5712
  return panel("timeline", panelId(state.title, "events"), state.title, [], body);
5692
5713
  };
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
5714
  const MM_SHAPES = [
5715
5715
  [
5716
5716
  "((",
@@ -5835,6 +5835,38 @@ const kanban = (lines, ctx) => {
5835
5835
  }
5836
5836
  return panel("kanban", panelId(ctx.title, "board"), ctx.title, [], body);
5837
5837
  };
5838
+ // src/convert/mermaid/panels/journey.ts
5839
+ /**
5840
+ * Mermaid journey to a yuhwa `journey` panel. The panel reads the same
5841
+ * sections and `task: score: actors` lines, so the body carries over; tasks
5842
+ * are indented under their section, and scores outside 1–5 are clamped.
5843
+ */
5844
+ const TASK_RE = /^(.+?)\s*:\s*(-?\d+(?:\.\d+)?)\s*(?::\s*(.*))?$/;
5845
+ const journey = (lines, ctx) => {
5846
+ const state = { title: ctx.title };
5847
+ const body = [];
5848
+ let indent = "";
5849
+ readStatements(lines, ctx, state, (l) => {
5850
+ const section = l.text.match(SECTION_RE);
5851
+ if (section) {
5852
+ const name = oneLine(section[1]);
5853
+ if (name) {
5854
+ body.push(`section ${name}`);
5855
+ indent = " ";
5856
+ }
5857
+ return true;
5858
+ }
5859
+ const m = l.text.match(TASK_RE);
5860
+ if (!m) return false;
5861
+ const [, task, raw, who] = m;
5862
+ const score = clampScore(Number(raw));
5863
+ if (score !== Number(raw)) ctx.warn(l.line, `score ${raw} of "${oneLine(task)}" was clamped to ${score}`);
5864
+ const actors = (who ?? "").split(",").map((a) => oneLine(a)).filter(Boolean);
5865
+ body.push(taskLine(indent, labelToken(oneLine(task)), void 0, score, actors));
5866
+ return true;
5867
+ });
5868
+ return panel("journey", panelId(state.title, "journey"), state.title, [], body);
5869
+ };
5838
5870
  // src/convert/mermaid/state.ts
5839
5871
  /**
5840
5872
  * Mermaid stateDiagram → yuhwa nodes and groups.
@@ -9357,15 +9389,38 @@ function editPart(source, panelId, edit, d = parse(source)) {
9357
9389
  id = r?.id;
9358
9390
  return r?.body ?? null;
9359
9391
  });
9392
+ if (out === source || !bracketsReadBack(out, panelId, edit, id)) return { source };
9360
9393
  return {
9361
9394
  source: out,
9362
- id: out === source ? void 0 : id
9395
+ id
9363
9396
  };
9364
9397
  }
9398
+ /**
9399
+ * A set value with brackets must read back as written: a trailing `[red]`
9400
+ * easily turns into the part's colour, and `[a [b]]` breaks a props tail.
9401
+ * Other values may come back normalised (`1w` as `7d`), so only these are checked.
9402
+ */
9403
+ function bracketsReadBack(out, panelId, edit, id) {
9404
+ if (edit.op !== "set" || edit.key === "color" || !/[[\]]/.test(edit.value ?? "")) return true;
9405
+ const decl = parse(out).panels.find((p) => p.id === panelId);
9406
+ 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();
9407
+ }
9365
9408
  /** Finish a panel drag. Prefer the declaration; a purely visual handle uses layout. */
9366
9409
  function writePanelDrag(source, d, id, handle) {
9367
9410
  const decl = d.panels.find((p) => p.id === id);
9368
9411
  const offset = d.layout.panels?.[id]?.parts?.[handle.part];
9412
+ if (offset && handle.editProps && decl?.ref && !decl.ref.generated) {
9413
+ const props = handle.editProps(offset);
9414
+ if (!props) return writeLayout(source, d.layout, d);
9415
+ let out = source;
9416
+ for (const [key, value] of Object.entries(props)) out = setProp(out, {
9417
+ kind: "panel",
9418
+ id
9419
+ }, key, value);
9420
+ const lines = splitLines(out);
9421
+ dropPartEntry(lines, parse(out).layoutBlock, id + ":" + handle.part);
9422
+ return joinLines(lines, out);
9423
+ }
9369
9424
  if (!offset || !handle.editPosition || !decl?.lines || decl.ref?.generated) return writeLayout(source, d.layout, d);
9370
9425
  const [start, end] = decl.lines;
9371
9426
  const lines = splitLines(source);
@@ -9375,25 +9430,30 @@ function writePanelDrag(source, d, id, handle) {
9375
9430
  if (first < 0) return writeLayout(source, d.layout, d);
9376
9431
  const editable = code.slice(first, first + decl.body.length);
9377
9432
  const edited = handle.editPosition(editable, offset);
9378
- if (!edited || edited.length !== editable.length) return writeLayout(source, d.layout, d);
9379
- edited.forEach((line, i) => {
9433
+ const commented = editable.some((line, i) => body[first + i].length !== line.length);
9434
+ if (!edited || edited.length !== editable.length && commented) return writeLayout(source, d.layout, d);
9435
+ if (edited.length === editable.length) edited.forEach((line, i) => {
9380
9436
  lines[start + 1 + first + i] = line + body[first + i].slice(editable[i].length);
9381
9437
  });
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
- }
9438
+ else lines.splice(start + 1 + first, editable.length, ...edited);
9439
+ const lb = d.layoutBlock;
9440
+ const shift = lb && lb[0] > start ? edited.length - editable.length : 0;
9441
+ dropPartEntry(lines, lb && [lb[0] + shift, lb[1] + shift], id + ":" + handle.part);
9395
9442
  return joinLines(lines, source);
9396
9443
  }
9444
+ /** drop the `key` entry from the layout block at `block`, and the block when nothing else is left in it */
9445
+ function dropPartEntry(lines, block, key) {
9446
+ if (!block) return;
9447
+ const [a, b] = block;
9448
+ const entries = lines.slice(a + 1, b);
9449
+ const keep = entries.filter((line) => line.trimStart().split(/\s+/, 1)[0] !== key);
9450
+ if (keep.length === entries.length) return;
9451
+ if (keep.some((line) => line.trim())) lines.splice(a + 1, entries.length, ...keep);
9452
+ else {
9453
+ const from = a > 0 && !lines[a - 1].trim() ? a - 1 : a;
9454
+ lines.splice(from, b - from + 1);
9455
+ }
9456
+ }
9397
9457
  /** rewrite a panel's body lines, re-indented like the old ones */
9398
9458
  function editBody(source, panelId, d, fn) {
9399
9459
  const decl = d.panels.find((p) => p.id === panelId);
@@ -9401,7 +9461,7 @@ function editBody(source, panelId, d, fn) {
9401
9461
  const at = decl?.bodyAt;
9402
9462
  if (!decl?.lines || at === void 0 || !kind || decl.failed || decl.ref?.generated) return source;
9403
9463
  const body = fn(kind, decl);
9404
- if (!body) return source;
9464
+ if (!body || body.some((l) => lex(l).codeEnd < l.trimEnd().length)) return source;
9405
9465
  const lines = splitLines(source);
9406
9466
  const indent = innerIndent(lines, decl.lines[0], decl.lines[1]);
9407
9467
  const n = decl.body.length;
@@ -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
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-BIfDM5Y3.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-DUTNi3wt.js";
2
+ import { S as PANELS, _ as unuse, d as canvasMeasure, g as registry, h as recolor, m as perPass, p as optionKind, u as approxMeasure, v as use } from "./plugin-BCLARrq1.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-BoaNpGLq.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-B9O53_5U.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-DF-gLxrJ.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";
@@ -335,6 +335,9 @@ Workflow: write the source, run \`yuhwa check file.yu --strict\` (\`--json\`
335
335
  for a machine-readable report, or read the \`diagnostics\` of \`render\`), fix
336
336
  every error and warning, then \`yuhwa render file.yu -o file.svg\`. Done when
337
337
  it reports 0 diagnostics; they name the fix ("did you mean ...", "write ...").
338
+ To see the layout without an image viewer, \`yuhwa render file.yu --text\`
339
+ draws it with box-drawing characters: check that every node, edge and label
340
+ landed where you meant.
338
341
 
339
342
  ## Example
340
343
 
@@ -1532,7 +1535,8 @@ url Print an embeddable image URL for a diagram (for \`serve\`).
1532
1535
  --view prints a link to a page that pans and zooms it instead:
1533
1536
  the hosted viewer, or your \`serve\` with --base.
1534
1537
  guide Print the language reference (same as llms.txt). AI agents: read
1535
- this first, then write source and run \`check --json\` until it is clean.
1538
+ this first, then write source and run \`check --json\` until it is clean,
1539
+ and \`render --text\` to look at the layout.
1536
1540
  `;
1537
1541
  /** flags that take a value; repeatable ones collect every value in a list */
1538
1542
  const VALUE_FLAGS = /* @__PURE__ */ new Set([