@open-document/core 0.12.0 → 0.13.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 (48) hide show
  1. package/dist/{build-DfUfpeTR.js → build-CbgIk6bA.js} +1 -1
  2. package/dist/{check-CHxiOkQG.js → check-BTroj-5Z.js} +3 -3
  3. package/dist/cli/bin.js +47 -10
  4. package/dist/config-BWtOZ1jc.d.ts +45 -0
  5. package/dist/{config-9IdbhVuT.js → config-DKKNIbvO.js} +68 -320
  6. package/dist/{context-BLI1-64_.js → context-DXNP8v9I.js} +2 -1
  7. package/dist/deploy-gcp-BUiSuqz7.js +758 -0
  8. package/dist/{dev-yNYKv5mm.js → dev-YXumw5iX.js} +1 -1
  9. package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
  10. package/dist/{diff-Bs205mOx.js → diff-CTFfU4Tz.js} +2 -2
  11. package/dist/{export-tkquS5O5.js → export-D2QLtF84.js} +3 -3
  12. package/dist/{sdk-CHEGeINh.d.ts → flow-CS5apebG.d.ts} +72 -3
  13. package/dist/{import-D1hIKIr3.js → import-CcmrFetU.js} +2 -2
  14. package/dist/index.d.ts +155 -59
  15. package/dist/index.js +896 -90
  16. package/dist/open-doc-plugin-DnX5usgI.js +320 -0
  17. package/dist/ops/index.d.ts +2 -2
  18. package/dist/ops/index.js +2 -2
  19. package/dist/{ops-Dgqujq5a.js → ops-DmEecq1k.js} +2 -1
  20. package/dist/{preview-BImdTH6K.js → preview-_mHpBhMk.js} +1 -1
  21. package/dist/{templates-DT5zzqHq.js → templates-MMblHwmT.js} +3 -3
  22. package/dist/vite/index.d.ts +1 -1
  23. package/dist/vite/index.js +2 -1
  24. package/package.json +1 -1
  25. package/skills/doc-authoring/SKILL.md +15 -16
  26. package/skills/doc-authoring/references/long-form.md +43 -2
  27. package/skills/doc-authoring/references/pagination.md +14 -2
  28. package/skills/doc-authoring/references/tables-and-charts.md +21 -17
  29. package/src/app/components/callout.tsx +101 -0
  30. package/src/app/components/chart.tsx +191 -33
  31. package/src/app/components/code-block.tsx +249 -0
  32. package/src/app/components/data-table.tsx +146 -18
  33. package/src/app/components/flow-page.tsx +57 -8
  34. package/src/app/components/numbering.tsx +226 -12
  35. package/src/app/components/page-frame.tsx +42 -0
  36. package/src/app/lib/chart.test.ts +15 -0
  37. package/src/app/lib/chart.ts +134 -9
  38. package/src/app/lib/diagnostics.ts +45 -1
  39. package/src/app/lib/export-dom.ts +15 -2
  40. package/src/app/lib/export-pdf.ts +9 -1
  41. package/src/app/lib/flow-measure.ts +33 -4
  42. package/src/app/lib/flow.test.ts +20 -1
  43. package/src/app/lib/flow.ts +120 -20
  44. package/src/app/lib/labels.ts +29 -10
  45. package/src/app/lib/sdk.ts +6 -0
  46. package/src/app/lib/use-doc-pages.ts +23 -8
  47. package/src/app/routes/doc.tsx +1 -0
  48. package/dist/config-P61niZMf.d.ts +0 -24
@@ -1,4 +1,4 @@
1
- import { t as createViteConfig } from "./config-9IdbhVuT.js";
1
+ import { t as createViteConfig } from "./config-DKKNIbvO.js";
2
2
  import { createServer, mergeConfig } from "vite";
3
3
  //#region src/cli/dev.ts
4
4
  async function dev(opts = {}) {
@@ -333,12 +333,151 @@ function route(from, to, horizontal) {
333
333
  end
334
334
  ];
335
335
  }
336
+ function layoutSequence(diagram, opts) {
337
+ const partNodes = diagram.nodes;
338
+ const messages = diagram.messages ?? [];
339
+ const labelSize = opts.fontSize * .85;
340
+ const boxSizes = partNodes.map((p) => {
341
+ const wrapped = wrapLabel(p.label, opts.fontSize, opts.maxLabelWidth);
342
+ const sz = sizeOf(p, wrapped, opts.fontSize);
343
+ return {
344
+ node: p,
345
+ lines: wrapped,
346
+ width: sz.width,
347
+ height: sz.height
348
+ };
349
+ });
350
+ const indexById = new Map(partNodes.map((p, i) => [p.id, i]));
351
+ const gapAfter = new Array(Math.max(0, partNodes.length - 1)).fill(opts.nodeGap + 36);
352
+ for (const msg of messages) {
353
+ const fi = indexById.get(msg.from) ?? 0;
354
+ const ti = indexById.get(msg.to) ?? 0;
355
+ if (fi === ti) continue;
356
+ const lo = Math.min(fi, ti);
357
+ if (Math.max(fi, ti) - lo === 1 && msg.label) {
358
+ const needed = measureText(msg.label, labelSize) + 36;
359
+ if (needed > gapAfter[lo]) gapAfter[lo] = needed;
360
+ }
361
+ }
362
+ const centres = [];
363
+ let cursorX = opts.padding;
364
+ boxSizes.forEach((box, i) => {
365
+ if (i === 0) {
366
+ centres.push(cursorX + box.width / 2);
367
+ cursorX += box.width;
368
+ } else {
369
+ const minCentreDist = (boxSizes[i - 1].width + box.width) / 2 + (gapAfter[i - 1] ?? opts.nodeGap);
370
+ const nextCentre = centres[i - 1] + minCentreDist;
371
+ centres.push(nextCentre);
372
+ cursorX = nextCentre + box.width / 2;
373
+ }
374
+ });
375
+ const topY = opts.padding;
376
+ const headerHeight = Math.max(...boxSizes.map((b) => b.height), 36);
377
+ const nodes = boxSizes.map((box, i) => ({
378
+ ...box.node,
379
+ lines: box.lines,
380
+ width: box.width,
381
+ height: headerHeight,
382
+ x: Math.round(centres[i] - box.width / 2),
383
+ y: topY
384
+ }));
385
+ const centreById = new Map(partNodes.map((p, i) => [p.id, Math.round(centres[i])]));
386
+ const edges = [];
387
+ let msgY = topY + headerHeight + 34;
388
+ const stepY = 42;
389
+ let maxRight = Math.max(...nodes.map((n) => n.x + n.width));
390
+ for (const msg of messages) {
391
+ const x1 = centreById.get(msg.from) ?? opts.padding;
392
+ const x2 = centreById.get(msg.to) ?? opts.padding;
393
+ if (msg.from === msg.to) {
394
+ const loopW = 36;
395
+ const loopH = 20;
396
+ const points = [
397
+ {
398
+ x: x1,
399
+ y: msgY
400
+ },
401
+ {
402
+ x: x1 + loopW,
403
+ y: msgY
404
+ },
405
+ {
406
+ x: x1 + loopW,
407
+ y: msgY + loopH
408
+ },
409
+ {
410
+ x: x1,
411
+ y: msgY + loopH
412
+ }
413
+ ];
414
+ const labelW = msg.label ? measureText(msg.label, labelSize) + 12 : 0;
415
+ const labelAt = msg.label ? {
416
+ x: x1 + loopW + labelW / 2 + 4,
417
+ y: msgY + loopH / 2
418
+ } : null;
419
+ if (labelAt) maxRight = Math.max(maxRight, labelAt.x + labelW / 2);
420
+ edges.push({
421
+ from: msg.from,
422
+ to: msg.to,
423
+ label: msg.label || null,
424
+ style: msg.style,
425
+ arrow: msg.arrow,
426
+ points,
427
+ labelAt
428
+ });
429
+ msgY += 52;
430
+ } else {
431
+ const points = [{
432
+ x: x1,
433
+ y: msgY
434
+ }, {
435
+ x: x2,
436
+ y: msgY
437
+ }];
438
+ const labelAt = msg.label ? {
439
+ x: (x1 + x2) / 2,
440
+ y: msgY - 10
441
+ } : null;
442
+ edges.push({
443
+ from: msg.from,
444
+ to: msg.to,
445
+ label: msg.label || null,
446
+ style: msg.style,
447
+ arrow: msg.arrow,
448
+ points,
449
+ labelAt
450
+ });
451
+ msgY += stepY;
452
+ }
453
+ }
454
+ const lifelineBottom = Math.max(topY + headerHeight + 28, msgY - 10);
455
+ return {
456
+ kind: "sequence",
457
+ direction: "LR",
458
+ nodes,
459
+ edges,
460
+ lifelines: partNodes.map((p, i) => ({
461
+ id: p.id,
462
+ x: Math.round(centres[i]),
463
+ y1: topY + headerHeight,
464
+ y2: lifelineBottom
465
+ })),
466
+ width: Math.round(maxRight + opts.padding),
467
+ height: Math.round(lifelineBottom + opts.padding)
468
+ };
469
+ }
336
470
  function layoutDiagram(diagram, options = {}) {
337
471
  const opts = {
338
472
  ...DEFAULTS,
339
473
  ...options
340
474
  };
475
+ if (diagram.kind === "sequence") return layoutSequence(diagram, opts);
341
476
  const horizontal = diagram.direction === "LR";
477
+ const hasSubgraphs = (diagram.subgraphs?.length ?? 0) > 0;
478
+ const effectiveRankGap = hasSubgraphs ? Math.max(opts.rankGap, 62) : opts.rankGap;
479
+ const effectiveNodeGap = hasSubgraphs ? Math.max(opts.nodeGap, 38) : opts.nodeGap;
480
+ const outerPad = hasSubgraphs ? Math.max(opts.padding, 24) : opts.padding;
342
481
  const lines = /* @__PURE__ */ new Map();
343
482
  const sizes = /* @__PURE__ */ new Map();
344
483
  for (const node of diagram.nodes) {
@@ -353,14 +492,14 @@ function layoutDiagram(diagram, options = {}) {
353
492
  for (const node of diagram.nodes) ranks[rankOf.get(node.id) ?? 0].push(node.id);
354
493
  orderRanks(ranks, diagram.edges);
355
494
  const rankOffset = [];
356
- let cursor = opts.padding;
495
+ let cursor = outerPad + (hasSubgraphs ? 18 : 0);
357
496
  for (const rank of ranks) {
358
497
  rankOffset.push(cursor);
359
498
  const extent = Math.max(...rank.map((id) => {
360
499
  const size = sizes.get(id);
361
500
  return horizontal ? size?.width ?? 0 : size?.height ?? 0;
362
501
  }));
363
- cursor += extent + opts.rankGap;
502
+ cursor += extent + effectiveRankGap;
364
503
  }
365
504
  const cross = /* @__PURE__ */ new Map();
366
505
  const rankSpan = [];
@@ -370,13 +509,13 @@ function layoutDiagram(diagram, options = {}) {
370
509
  const size = sizes.get(id);
371
510
  const extent = horizontal ? size?.height ?? 0 : size?.width ?? 0;
372
511
  cross.set(id, offset + extent / 2);
373
- offset += extent + opts.nodeGap;
512
+ offset += extent + effectiveNodeGap;
374
513
  }
375
- rankSpan[i] = Math.max(0, offset - opts.nodeGap);
514
+ rankSpan[i] = Math.max(0, offset - effectiveNodeGap);
376
515
  });
377
516
  const widest = Math.max(...rankSpan, 0);
378
517
  ranks.forEach((rank, i) => {
379
- const shift = (widest - rankSpan[i]) / 2 + opts.padding;
518
+ const shift = (widest - rankSpan[i]) / 2 + outerPad;
380
519
  for (const id of rank) cross.set(id, (cross.get(id) ?? 0) + shift);
381
520
  });
382
521
  const nodes = diagram.nodes.map((node) => {
@@ -410,17 +549,46 @@ function layoutDiagram(diagram, options = {}) {
410
549
  });
411
550
  }
412
551
  placeLabels(edges, opts.fontSize);
552
+ const subgraphs = [];
553
+ if (diagram.subgraphs) {
554
+ const sgPadX = 14;
555
+ const sgPadTop = 26;
556
+ const sgPadBottom = 12;
557
+ for (const sg of diagram.subgraphs) {
558
+ const members = sg.nodeIds.map((id) => byId.get(id)).filter((n) => n !== void 0);
559
+ if (members.length === 0) continue;
560
+ const minX = Math.min(...members.map((m) => m.x)) - sgPadX;
561
+ const minY = Math.min(...members.map((m) => m.y)) - sgPadTop;
562
+ const maxX = Math.max(...members.map((m) => m.x + m.width)) + sgPadX;
563
+ const maxY = Math.max(...members.map((m) => m.y + m.height)) + sgPadBottom;
564
+ const labelWidth = measureText(sg.label, opts.fontSize * .85) + 28;
565
+ subgraphs.push({
566
+ id: sg.id,
567
+ label: sg.label,
568
+ x: Math.max(2, Math.round(minX)),
569
+ y: Math.max(2, Math.round(minY)),
570
+ width: Math.round(Math.max(maxX - minX, labelWidth)),
571
+ height: Math.round(maxY - minY)
572
+ });
573
+ }
574
+ }
413
575
  const labelSize = opts.fontSize * .85;
414
576
  const reach = edges.flatMap((edge) => [...edge.points, ...edge.labelAt && edge.label ? [{
415
577
  x: edge.labelAt.x + (measureText(edge.label, labelSize) + 10) / 2,
416
578
  y: edge.labelAt.y + labelSize * .8
417
579
  }] : []]);
418
- const width = Math.max(...nodes.map((n) => n.x + n.width), ...reach.map((p) => p.x)) + opts.padding;
419
- const height = Math.max(...nodes.map((n) => n.y + n.height), ...reach.map((p) => p.y)) + opts.padding;
580
+ const sgReach = subgraphs.map((s) => ({
581
+ x: s.x + s.width,
582
+ y: s.y + s.height
583
+ }));
584
+ const width = Math.max(...nodes.map((n) => n.x + n.width), ...reach.map((p) => p.x), ...sgReach.map((p) => p.x)) + opts.padding;
585
+ const height = Math.max(...nodes.map((n) => n.y + n.height), ...reach.map((p) => p.y), ...sgReach.map((p) => p.y)) + opts.padding;
420
586
  return {
587
+ kind: "flowchart",
421
588
  direction: diagram.direction,
422
589
  nodes,
423
590
  edges,
591
+ ...subgraphs.length > 0 ? { subgraphs } : {},
424
592
  width,
425
593
  height
426
594
  };
@@ -580,6 +748,10 @@ var DiagramSyntaxError = class extends Error {
580
748
  }
581
749
  };
582
750
  const HEADER_RE = /^(?:flowchart|graph)(?:\s+(TB|TD|BT|LR|RL))?$/i;
751
+ const SEQ_HEADER_RE = /^sequenceDiagram$/i;
752
+ const SUBGRAPH_RE = /^subgraph\s+(?:([A-Za-z0-9_.-]+)\s*\[([\s\S]*?)\]|([\s\S]+))$/i;
753
+ const PARTICIPANT_RE = /^(?:participant|actor)\s+([A-Za-z0-9_.-]+)(?:\s+as\s+([\s\S]+))?$/i;
754
+ const SEQ_MSG_RE = /^([A-Za-z0-9_.-]+?)\s*(-->>|--\)|-->|->|->>|-\))\s*([+-]?[A-Za-z0-9_.-]+)\s*:\s*([\s\S]*)$/;
583
755
  /** `A[Label]`, `A(Label)`, `A([Label])`, `A[(Label)]`, `A{Label}`, `A((Label))`, or a bare `A`. */
584
756
  const NODE_RE = /^([A-Za-z0-9_.-]+)(?:(\(\(|\(\[|\[\(|\[|\(|\{)([\s\S]*?)(\)\)|\]\)|\)\]|\]|\)|\}))?$/;
585
757
  const SHAPES = {
@@ -696,21 +868,101 @@ function unquote(label) {
696
868
  if (trimmed.length > 1 && trimmed.startsWith("\"") && trimmed.endsWith("\"")) return trimmed.slice(1, -1);
697
869
  return trimmed;
698
870
  }
871
+ function parseSequence(lines) {
872
+ const participants = /* @__PURE__ */ new Map();
873
+ const messages = [];
874
+ const ensureParticipant = (id, label) => {
875
+ const cleanId = id.replace(/^[+-]/, "");
876
+ const existing = participants.get(cleanId);
877
+ if (!existing) participants.set(cleanId, {
878
+ id: cleanId,
879
+ label: label ? unquote(label) : cleanId
880
+ });
881
+ else if (label && existing.label === existing.id) existing.label = unquote(label);
882
+ return cleanId;
883
+ };
884
+ lines.forEach((rawLine, index) => {
885
+ const lineNumber = index + 1;
886
+ const line = stripComment(rawLine).trim();
887
+ if (!line || SEQ_HEADER_RE.test(line) || /^autonumber$/i.test(line)) return;
888
+ const partMatch = PARTICIPANT_RE.exec(line);
889
+ if (partMatch) {
890
+ ensureParticipant(partMatch[1], partMatch[2]);
891
+ return;
892
+ }
893
+ const msgMatch = SEQ_MSG_RE.exec(line);
894
+ if (msgMatch) {
895
+ const from = ensureParticipant(msgMatch[1]);
896
+ const arrowToken = msgMatch[2];
897
+ const to = ensureParticipant(msgMatch[3]);
898
+ const label = msgMatch[4].trim();
899
+ const dashed = arrowToken.startsWith("--");
900
+ messages.push({
901
+ from,
902
+ to,
903
+ label,
904
+ style: dashed ? "dashed" : "solid",
905
+ arrow: true
906
+ });
907
+ return;
908
+ }
909
+ throw new DiagramSyntaxError(`cannot read sequence line "${line}"`, lineNumber);
910
+ });
911
+ if (participants.size === 0) throw new DiagramSyntaxError("sequence diagram has no participants", 1);
912
+ const partList = [...participants.values()];
913
+ return {
914
+ kind: "sequence",
915
+ direction: "LR",
916
+ nodes: partList.map((p) => ({
917
+ id: p.id,
918
+ label: p.label,
919
+ shape: "rect"
920
+ })),
921
+ edges: messages.map((m) => ({
922
+ from: m.from,
923
+ to: m.to,
924
+ label: m.label || null,
925
+ style: m.style,
926
+ arrow: m.arrow
927
+ })),
928
+ participants: partList,
929
+ messages
930
+ };
931
+ }
699
932
  /**
700
- * A practical subset of Mermaid's flowchart syntax — the shapes and links a
701
- * report actually uses. Agents already write this dialect fluently, which is
702
- * the whole reason to borrow it rather than invent one; the renderer is ours,
703
- * so the output follows the document's theme instead of Mermaid's.
933
+ * A practical subset of Mermaid's flowchart and sequenceDiagram syntax — the
934
+ * shapes, subgraphs and links a report actually uses. Agents already write this
935
+ * dialect fluently, which is the whole reason to borrow it rather than invent
936
+ * one; the renderer is ours, so the output follows the document's theme instead
937
+ * of Mermaid's.
704
938
  */
705
939
  function parseDiagram(source) {
706
940
  const lines = source.split("\n");
941
+ const firstMeaningful = lines.map((l) => stripComment(l).trim()).find((l) => l.length > 0);
942
+ if (firstMeaningful && SEQ_HEADER_RE.test(firstMeaningful)) return parseSequence(lines);
707
943
  let direction = "TD";
708
944
  let sawHeader = false;
709
945
  const nodes = /* @__PURE__ */ new Map();
710
946
  const edges = [];
947
+ const subgraphs = [];
948
+ const subgraphStack = [];
711
949
  const remember = (node) => {
950
+ const activeSubgraph = subgraphStack[subgraphStack.length - 1];
712
951
  const existing = nodes.get(node.id);
713
- if (!existing || existing.label === existing.id && node.label !== node.id) nodes.set(node.id, node);
952
+ if (!existing) {
953
+ const created = activeSubgraph ? {
954
+ ...node,
955
+ subgraph: activeSubgraph.id
956
+ } : node;
957
+ nodes.set(node.id, created);
958
+ } else {
959
+ if (existing.label === existing.id && node.label !== node.id) {
960
+ existing.label = node.label;
961
+ existing.shape = node.shape;
962
+ }
963
+ if (!existing.subgraph && activeSubgraph) existing.subgraph = activeSubgraph.id;
964
+ }
965
+ if (activeSubgraph && !activeSubgraph.nodeIds.includes(node.id)) activeSubgraph.nodeIds.push(node.id);
714
966
  return node.id;
715
967
  };
716
968
  lines.forEach((rawLine, index) => {
@@ -725,6 +977,23 @@ function parseDiagram(source) {
725
977
  return;
726
978
  }
727
979
  }
980
+ if (/^end$/i.test(line)) {
981
+ subgraphStack.pop();
982
+ return;
983
+ }
984
+ const subMatch = SUBGRAPH_RE.exec(line);
985
+ if (subMatch) {
986
+ const id = subMatch[1] ?? `sg-${subgraphs.length + 1}`;
987
+ const sg = {
988
+ id,
989
+ label: unquote(subMatch[2] ?? subMatch[3] ?? id),
990
+ nodeIds: []
991
+ };
992
+ subgraphs.push(sg);
993
+ subgraphStack.push(sg);
994
+ return;
995
+ }
996
+ if (/^direction\s+(?:TB|TD|BT|LR|RL)$/i.test(line)) return;
728
997
  const chain = splitChain(line);
729
998
  if (chain.length === 1) {
730
999
  remember(parseNode(chain[0].raw, lineNumber));
@@ -748,9 +1017,11 @@ function parseDiagram(source) {
748
1017
  });
749
1018
  if (nodes.size === 0) throw new DiagramSyntaxError("diagram has no nodes", 1);
750
1019
  return {
1020
+ kind: "flowchart",
751
1021
  direction,
752
1022
  nodes: [...nodes.values()],
753
- edges
1023
+ edges,
1024
+ ...subgraphs.length > 0 ? { subgraphs } : {}
754
1025
  };
755
1026
  }
756
1027
  //#endregion
@@ -759,6 +1030,13 @@ const LINE_HEIGHT = 1.35;
759
1030
  function escapeXml(text) {
760
1031
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
761
1032
  }
1033
+ function subgraphMarkup(sg, fontSize) {
1034
+ const titleSize = round(fontSize * .85);
1035
+ return `<rect x="${round(sg.x)}" y="${round(sg.y)}" width="${round(sg.width)}" height="${round(sg.height)}" style="rx: var(--od-radius, 4px)" fill="color-mix(in srgb, var(--od-accent, #2563eb) 5%, var(--od-bg, #ffffff))" stroke="var(--od-rule, #d1d5db)" stroke-width="1" stroke-dasharray="4 3" /><text x="${round(sg.x + 10)}" y="${round(sg.y + titleSize + 5)}" font-family="var(--od-font-heading, sans-serif)" font-size="${titleSize}" font-weight="600" fill="var(--od-muted, #6b7280)">${escapeXml(sg.label)}</text>`;
1036
+ }
1037
+ function lifelineMarkup(line) {
1038
+ return `<line x1="${round(line.x)}" y1="${round(line.y1)}" x2="${round(line.x)}" y2="${round(line.y2)}" stroke="var(--od-rule, #d1d5db)" stroke-width="1.25" stroke-dasharray="4 4" />`;
1039
+ }
762
1040
  /**
763
1041
  * Every colour and face is a `--od-*` variable rather than a literal, which is
764
1042
  * the entire reason this renderer exists: the drawing inherits the document's
@@ -812,6 +1090,8 @@ function renderDiagram(diagram, options = {}) {
812
1090
  const marker = `od-arrow${options.idSuffix ? `-${options.idSuffix}` : ""}`;
813
1091
  const defs = `<defs><marker id="${marker}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,1 L10,5 L0,9 z" fill="var(--od-text, #16181d)" /></marker></defs>`;
814
1092
  const body = [
1093
+ ...(diagram.subgraphs ?? []).map((sg) => subgraphMarkup(sg, fontSize)),
1094
+ ...(diagram.lifelines ?? []).map((ll) => lifelineMarkup(ll)),
815
1095
  ...diagram.edges.map((edge) => edgePath(edge, marker)),
816
1096
  ...diagram.nodes.map((node) => shapePath(node)),
817
1097
  ...diagram.nodes.map((node) => nodeText(node, fontSize)),
@@ -1,5 +1,5 @@
1
- import { s as diffDocument } from "./ops-Dgqujq5a.js";
2
- import { t as cliContext } from "./context-BLI1-64_.js";
1
+ import { s as diffDocument } from "./ops-DmEecq1k.js";
2
+ import { t as cliContext } from "./context-DXNP8v9I.js";
3
3
  import chalk from "chalk";
4
4
  //#region src/cli/diff.ts
5
5
  const MARK = {
@@ -1,7 +1,7 @@
1
1
  import { r as EXPORT_FORMATS } from "./sdk-CqNZzbkz.js";
2
- import { D as listDocIds } from "./config-9IdbhVuT.js";
3
- import { n as closeRenderSession, r as exportDocument } from "./ops-Dgqujq5a.js";
4
- import { t as cliContext } from "./context-BLI1-64_.js";
2
+ import { D as listDocIds } from "./config-DKKNIbvO.js";
3
+ import { n as closeRenderSession, r as exportDocument } from "./ops-DmEecq1k.js";
4
+ import { t as cliContext } from "./context-DXNP8v9I.js";
5
5
  import chalk from "chalk";
6
6
  //#region src/cli/export.ts
7
7
  const FORMATS = EXPORT_FORMATS;
@@ -1,6 +1,6 @@
1
1
  import { ComponentType, ReactNode } from "react";
2
2
  //#region src/app/lib/labels.d.ts
3
- type LabelKind = 'figure' | 'table' | 'footnote';
3
+ type LabelKind = 'figure' | 'table' | 'footnote' | 'citation';
4
4
  type LabelEntry = {
5
5
  /** Author-supplied id for `<Ref to>`, or a generated one. */
6
6
  id: string;
@@ -22,13 +22,15 @@ type LabelVocabulary = {
22
22
  table: string;
23
23
  /** Heading above a page's footnotes. Empty string renders no heading. */
24
24
  footnotes: string;
25
+ /** Heading above a bibliography section when not overridden. */
26
+ bibliography: string;
25
27
  /** Page suffix for a cross-reference. `{page}` is replaced. */
26
28
  onPage: string;
27
29
  };
28
30
  /** The document's numbered items of one kind, in order. Empty on the first render pass. */
29
31
  declare function useDocLabels(kind: LabelKind): LabelEntry[];
30
32
  /** One numbered item by id, once the scan has run. */
31
- declare function useDocLabel(id: string): LabelEntry | null;
33
+ declare function useDocLabel(id: string, kind?: LabelKind): LabelEntry | null;
32
34
  //#endregion
33
35
  //#region src/app/lib/design.d.ts
34
36
  type DesignPalette = {
@@ -131,6 +133,10 @@ type FlowSection = {
131
133
  footer?: ComponentType;
132
134
  /** Page padding override in px; defaults to the design's `margin`. */
133
135
  padding?: number;
136
+ /** Number of columns for body content inside each page of this flow section. */
137
+ columns?: 1 | 2 | 3;
138
+ /** Gap in px between columns when `columns > 1`; defaults to 24. */
139
+ columnGap?: number;
134
140
  };
135
141
  /** What a document's default export may contain: fixed pages, flow sections, or both. */
136
142
  type DocEntry = DocPage | FlowSection;
@@ -167,6 +173,8 @@ type DocMeta = {
167
173
  recordName?: string;
168
174
  /** With `records`: the column that names a row in the viewer's picker. */
169
175
  recordLabel?: string;
176
+ /** Diagonal watermark text stamped across every sheet (e.g. 'CONFIDENTIAL', 'DRAFT'). */
177
+ watermark?: string;
170
178
  };
171
179
  type DocModule = {
172
180
  default: DocEntry[];
@@ -180,4 +188,65 @@ type DocModule = {
180
188
  };
181
189
  declare function resolvePageGeometry(meta?: DocMeta): PageGeometry;
182
190
  //#endregion
183
- export { LabelEntry as A, DesignFonts as C, cssVarsToString as D, DesignTypeScale as E, LabelVocabulary as M, useDocLabel as N, defaultDesign as O, useDocLabels as P, useRecord as S, DesignSystem as T, isPageSizeName as _, DocModule as a, Field as b, ExportFormat as c, Orientation as d, PAGE_SIZES as f, isOrientation as g, PageSizeName as h, DocMeta as i, LabelKind as j, designToCssVars as k, FlowSection as l, PageGeometry as m, DEFAULT_PAGE_SIZE as n, DocPage as o, PAGE_SIZE_NAMES as p, DocEntry as r, EXPORT_FORMATS as s, DEFAULT_ORIENTATION as t, ORIENTATIONS as u, resolvePageGeometry as v, DesignPalette as w, FieldProps as x, DataRecord as y };
191
+ //#region src/app/lib/flow.d.ts
192
+ /**
193
+ * Wraps continuous content so the framework paginates it, instead of the author
194
+ * hand-splitting sections into fixed pages. Each direct child is one atomic
195
+ * block — a heading, a paragraph, a table — that never straddles a page break.
196
+ */
197
+ declare function flow(children: ReactNode, opts?: {
198
+ header?: ComponentType;
199
+ footer?: ComponentType;
200
+ padding?: number;
201
+ columns?: 1 | 2 | 3;
202
+ columnGap?: number;
203
+ }): FlowSection;
204
+ declare function isFlowSection(entry: DocEntry): entry is FlowSection;
205
+ type BlockSlice = {
206
+ index: number;
207
+ rowStart?: number;
208
+ rowEnd?: number;
209
+ };
210
+ type BlockMetrics = {
211
+ height: number;
212
+ /** Height this block's footnotes add to the foot of whatever page it lands on. */
213
+ footnoteHeight?: number;
214
+ /** A heading must not be the last block on a page. */
215
+ keepWithNext?: boolean;
216
+ /** A caption must not open a page without the figure it belongs to. */
217
+ keepWithPrevious?: boolean;
218
+ /** Always start a new page before this block. */
219
+ breakBefore?: boolean;
220
+ /** When present, this block is a table that can split between rows across page breaks. */
221
+ splittable?: {
222
+ headerHeight: number;
223
+ footerHeight: number;
224
+ rowHeights: number[];
225
+ };
226
+ };
227
+ type PaginationResult = {
228
+ /** Block indices per page, in order. */
229
+ pages: number[][];
230
+ /** Detailed block slices per page, carrying row ranges when a table splits across pages. */
231
+ slices: BlockSlice[][];
232
+ /** Blocks taller than one page — they stay whole and overflow. */
233
+ overflowing: number[];
234
+ };
235
+ type PaginateOptions = {
236
+ /** Rule and padding a page's footnote area costs before its first note. */
237
+ footnoteOverhead?: number;
238
+ };
239
+ /**
240
+ * Greedy top-to-bottom packing: fill a page until the next block would cross
241
+ * the bottom edge, then push that block — plus anything glued to it — onto the
242
+ * next page. Blocks are atomic unless marked `splittable`, in which case rows
243
+ * pack into the remaining space and continue on the next sheet with the header
244
+ * repeated.
245
+ *
246
+ * Footnotes are packed from the same budget: a block that carries notes brings
247
+ * their height with it, because those notes print at the foot of whichever page
248
+ * the block lands on.
249
+ */
250
+ declare function paginateBlocks(blocks: BlockMetrics[], available: number, opts?: PaginateOptions): PaginationResult;
251
+ //#endregion
252
+ export { DesignPalette as A, useDocLabels as B, isPageSizeName as C, FieldProps as D, Field as E, designToCssVars as F, LabelEntry as I, LabelKind as L, DesignTypeScale as M, cssVarsToString as N, useRecord as O, defaultDesign as P, LabelVocabulary as R, isOrientation as S, DataRecord as T, Orientation as _, isFlowSection as a, PageGeometry as b, DEFAULT_PAGE_SIZE as c, DocModule as d, DocPage as f, ORIENTATIONS as g, FlowSection as h, flow as i, DesignSystem as j, DesignFonts as k, DocEntry as l, ExportFormat as m, BlockSlice as n, paginateBlocks as o, EXPORT_FORMATS as p, PaginationResult as r, DEFAULT_ORIENTATION as s, BlockMetrics as t, DocMeta as u, PAGE_SIZES as v, resolvePageGeometry as w, PageSizeName as x, PAGE_SIZE_NAMES as y, useDocLabel as z };
@@ -1,5 +1,5 @@
1
- import { a as importMarkdown } from "./ops-Dgqujq5a.js";
2
- import { t as cliContext } from "./context-BLI1-64_.js";
1
+ import { a as importMarkdown } from "./ops-DmEecq1k.js";
2
+ import { t as cliContext } from "./context-DXNP8v9I.js";
3
3
  import chalk from "chalk";
4
4
  import path from "node:path";
5
5
  //#region src/cli/import.ts