@open-document/core 0.9.0 → 0.10.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 (88) hide show
  1. package/dist/{build-CFL7nhz0.js → build-DJMLK50m.js} +1 -1
  2. package/dist/{check-CL0-0eB8.js → check-CUKuufBm.js} +3 -3
  3. package/dist/cli/bin.js +10 -6
  4. package/dist/{config-4nz5NnxW.js → config-CvzpyAUA.js} +558 -546
  5. package/dist/{context-BH8C-dSW.js → context-B4ip7SoI.js} +1 -1
  6. package/dist/{dev-BCSUczXW.js → dev-dnH7DTlD.js} +1 -1
  7. package/dist/{diagram-xlVDekYk.js → diagram-BK4jTZr4.js} +231 -158
  8. package/dist/diff-QTo0A5Rx.js +44 -0
  9. package/dist/{export-CmVJdl9a.js → export-BrRFrexj.js} +3 -3
  10. package/dist/{import-E6vRo7xm.js → import-C14Vn9ER.js} +2 -2
  11. package/dist/index.d.ts +54 -3
  12. package/dist/index.js +457 -18
  13. package/dist/ops/index.d.ts +72 -17
  14. package/dist/ops/index.js +3 -3
  15. package/dist/{ops-OZZVBgsM.js → ops-DKidjLXP.js} +642 -124
  16. package/dist/{preview-CwCrw-i3.js → preview-wKM4C6Uk.js} +1 -1
  17. package/dist/{sdk-BqU6mwD_.d.ts → sdk-CpDEGRIo.d.ts} +2 -0
  18. package/dist/vite/index.js +1 -1
  19. package/package.json +2 -2
  20. package/skills/doc-authoring/SKILL.md +13 -6
  21. package/skills/doc-authoring/references/pagination.md +1 -1
  22. package/skills/doc-authoring/references/tables-and-charts.md +18 -1
  23. package/src/app/components/browser/browser-ui.tsx +105 -0
  24. package/src/app/components/chart.tsx +239 -0
  25. package/src/app/components/command-palette.tsx +284 -0
  26. package/src/app/components/design-panel/design-panel.tsx +22 -20
  27. package/src/app/components/design-panel/design-provider.tsx +4 -2
  28. package/src/app/components/diagram.tsx +11 -1
  29. package/src/app/components/doc-assets.tsx +6 -5
  30. package/src/app/components/doc-search.tsx +12 -10
  31. package/src/app/components/doc-sidebar.tsx +24 -18
  32. package/src/app/components/flow-page.tsx +2 -0
  33. package/src/app/components/inspector/inspector.tsx +75 -48
  34. package/src/app/components/language-toggle.tsx +38 -0
  35. package/src/app/components/palette-items.ts +128 -0
  36. package/src/app/components/panel/edit-save-card.tsx +4 -2
  37. package/src/app/components/panel/fields.tsx +5 -2
  38. package/src/app/components/panel/save-card.tsx +18 -10
  39. package/src/app/components/sidebar/folder-item.tsx +10 -8
  40. package/src/app/components/sidebar/icon-picker.tsx +3 -1
  41. package/src/app/components/sidebar/sidebar.tsx +44 -13
  42. package/src/app/components/theme-toggle.tsx +5 -3
  43. package/src/app/components/ui/menu.tsx +5 -0
  44. package/src/app/lib/agent-bridge.ts +8 -2
  45. package/src/app/lib/chart.test.ts +108 -0
  46. package/src/app/lib/chart.ts +343 -0
  47. package/src/app/lib/doc-preview.tsx +0 -10
  48. package/src/app/lib/docs.ts +3 -0
  49. package/src/app/lib/docx/from-dom.ts +11 -11
  50. package/src/app/lib/docx/ooxml.test.ts +25 -9
  51. package/src/app/lib/docx/ooxml.ts +58 -37
  52. package/src/app/lib/export-docx.ts +13 -8
  53. package/src/app/lib/export-dom.ts +4 -0
  54. package/src/app/lib/export-image.ts +2 -0
  55. package/src/app/lib/export-pdf.ts +6 -0
  56. package/src/app/lib/flow-measure.ts +3 -0
  57. package/src/app/lib/flow.ts +1 -1
  58. package/src/app/lib/i18n-ja/browser.ts +88 -0
  59. package/src/app/lib/i18n-ja/doc.ts +65 -0
  60. package/src/app/lib/i18n-ja/index.ts +5 -0
  61. package/src/app/lib/i18n-ja/panels.ts +104 -0
  62. package/src/app/lib/i18n-ko/browser.ts +87 -0
  63. package/src/app/lib/i18n-ko/doc.ts +65 -0
  64. package/src/app/lib/i18n-ko/index.ts +5 -0
  65. package/src/app/lib/i18n-ko/panels.ts +102 -0
  66. package/src/app/lib/i18n-zh-cn/browser.ts +84 -0
  67. package/src/app/lib/i18n-zh-cn/doc.ts +64 -0
  68. package/src/app/lib/i18n-zh-cn/index.ts +5 -0
  69. package/src/app/lib/i18n-zh-cn/panels.ts +98 -0
  70. package/src/app/lib/i18n-zh-tw/browser.ts +84 -0
  71. package/src/app/lib/i18n-zh-tw/doc.ts +64 -0
  72. package/src/app/lib/i18n-zh-tw/index.ts +5 -0
  73. package/src/app/lib/i18n-zh-tw/panels.ts +99 -0
  74. package/src/app/lib/i18n.test.ts +24 -0
  75. package/src/app/lib/i18n.tsx +109 -0
  76. package/src/app/lib/outline.ts +23 -0
  77. package/src/app/lib/page-range.test.ts +10 -1
  78. package/src/app/lib/page-range.ts +26 -0
  79. package/src/app/lib/sdk.ts +2 -0
  80. package/src/app/lib/svg-ids.ts +37 -0
  81. package/src/app/main.tsx +4 -1
  82. package/src/app/routes/assets.tsx +193 -132
  83. package/src/app/routes/doc.tsx +666 -310
  84. package/src/app/routes/home-shell.tsx +115 -88
  85. package/src/app/routes/home.tsx +200 -67
  86. package/src/app/routes/themes.tsx +42 -35
  87. package/src/app/styles.css +99 -0
  88. package/src/app/virtual.d.ts +1 -0
@@ -1,5 +1,5 @@
1
1
  import { t as readCoreVersion } from "./cli/bin.js";
2
- import { A as loadUserConfig, O as makeContext } from "./config-4nz5NnxW.js";
2
+ import { A as loadUserConfig, O as makeContext } from "./config-CvzpyAUA.js";
3
3
  //#region src/cli/context.ts
4
4
  /** The same context the dev API and the MCP server run on, for commands that call `ops/`. */
5
5
  async function cliContext(userCwd = process.cwd()) {
@@ -1,4 +1,4 @@
1
- import { t as createViteConfig } from "./config-4nz5NnxW.js";
1
+ import { t as createViteConfig } from "./config-CvzpyAUA.js";
2
2
  import { createServer, mergeConfig } from "vite";
3
3
  //#region src/cli/dev.ts
4
4
  async function dev(opts = {}) {
@@ -1,147 +1,3 @@
1
- //#region src/app/lib/design.ts
2
- function designToCssVars(d) {
3
- return {
4
- "--od-bg": d.palette.bg,
5
- "--od-text": d.palette.text,
6
- "--od-muted": d.palette.muted,
7
- "--od-accent": d.palette.accent,
8
- "--od-rule": d.palette.rule,
9
- "--od-font-heading": d.fonts.heading,
10
- "--od-font-body": d.fonts.body,
11
- "--od-font-mono": d.fonts.mono,
12
- "--od-size-title": `${d.typeScale.title}px`,
13
- "--od-size-h1": `${d.typeScale.h1}px`,
14
- "--od-size-h2": `${d.typeScale.h2}px`,
15
- "--od-size-h3": `${d.typeScale.h3}px`,
16
- "--od-size-body": `${d.typeScale.body}px`,
17
- "--od-size-caption": `${d.typeScale.caption}px`,
18
- "--od-margin": `${d.margin}px`,
19
- "--od-leading": String(d.leading),
20
- "--od-radius": `${d.radius}px`
21
- };
22
- }
23
- function cssVarsToString(vars) {
24
- return Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n");
25
- }
26
- const defaultDesign = {
27
- palette: {
28
- bg: "#ffffff",
29
- text: "#16181d",
30
- muted: "#6b7280",
31
- accent: "#2563eb",
32
- rule: "#e5e7eb"
33
- },
34
- fonts: {
35
- heading: "-apple-system, BlinkMacSystemFont, \"Inter\", system-ui, sans-serif",
36
- body: "-apple-system, BlinkMacSystemFont, \"Inter\", system-ui, sans-serif",
37
- mono: "ui-monospace, \"SF Mono\", \"JetBrains Mono\", Menlo, monospace"
38
- },
39
- typeScale: {
40
- title: 44,
41
- h1: 28,
42
- h2: 20,
43
- h3: 16,
44
- body: 14,
45
- caption: 10
46
- },
47
- margin: 76,
48
- leading: 1.55,
49
- radius: 6
50
- };
51
- //#endregion
52
- //#region src/data/delimited.ts
53
- /**
54
- * RFC 4180 with the parts that actually show up in exported data: quoted
55
- * fields, doubled quotes inside them, embedded newlines, and CRLF.
56
- *
57
- * Hand-written because `core` ships to every user and a CSV dependency is a lot
58
- * of install size for something a report needs in one place.
59
- */
60
- function splitRecords(text, delimiter) {
61
- const records = [];
62
- let row = [];
63
- let field = "";
64
- let quoted = false;
65
- let started = false;
66
- const endField = () => {
67
- row.push(field);
68
- field = "";
69
- started = false;
70
- };
71
- const endRow = () => {
72
- endField();
73
- records.push(row);
74
- row = [];
75
- };
76
- for (let i = 0; i < text.length; i++) {
77
- const char = text[i];
78
- if (quoted) {
79
- if (char === "\"") {
80
- if (text[i + 1] === "\"") {
81
- field += "\"";
82
- i++;
83
- continue;
84
- }
85
- quoted = false;
86
- continue;
87
- }
88
- field += char;
89
- continue;
90
- }
91
- if (char === "\"" && !started) {
92
- quoted = true;
93
- started = true;
94
- continue;
95
- }
96
- if (char === delimiter) {
97
- endField();
98
- continue;
99
- }
100
- if (char === "\r") {
101
- if (text[i + 1] === "\n") i++;
102
- endRow();
103
- continue;
104
- }
105
- if (char === "\n") {
106
- endRow();
107
- continue;
108
- }
109
- field += char;
110
- started = true;
111
- }
112
- if (field !== "" || row.length > 0) endRow();
113
- return records;
114
- }
115
- /** Numbers stay numbers so a table can align and format them; nothing else is guessed at. */
116
- function coerce(raw) {
117
- const value = raw.trim();
118
- if (value === "") return null;
119
- if (/^-?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?$/.test(value)) {
120
- const n = Number(value);
121
- if (Number.isFinite(n)) return n;
122
- }
123
- return value;
124
- }
125
- function parseDelimited(text, opts = {}) {
126
- const delimiter = opts.delimiter ?? ",";
127
- const records = splitRecords(text.replace(/^/, ""), delimiter).filter((record) => record.length > 1 || (record[0] ?? "") !== "");
128
- if (records.length === 0) return {
129
- columns: [],
130
- rows: []
131
- };
132
- const header = opts.noHeader ? records[0].map((_, index) => `column${index + 1}`) : records[0].map((name, index) => name.trim() || `column${index + 1}`);
133
- return {
134
- columns: header,
135
- rows: (opts.noHeader ? records : records.slice(1)).map((record) => {
136
- const row = {};
137
- header.forEach((name, index) => {
138
- row[name] = coerce(record[index] ?? "");
139
- });
140
- return row;
141
- })
142
- };
143
- }
144
- //#endregion
145
1
  //#region src/diagram/layout.ts
146
2
  const DEFAULTS = {
147
3
  fontSize: 13,
@@ -196,6 +52,7 @@ function sizeOf(node, lines, fontSize) {
196
52
  const textHeight = lines.length * fontSize * LINE_HEIGHT$1;
197
53
  let width = Math.max(MIN_WIDTH, textWidth + 28);
198
54
  let height = textHeight + 20;
55
+ if (node.shape === "cylinder") height += 12;
199
56
  if (node.shape === "diamond") {
200
57
  width = textWidth * 2 + 28;
201
58
  height = textHeight * 2 + 20;
@@ -359,6 +216,66 @@ function placeLabels(edges, fontSize) {
359
216
  edge.labelAt = chosen;
360
217
  }
361
218
  }
219
+ const CHANNEL_GAP = 18;
220
+ /**
221
+ * A link that runs against the flow — a feedback arrow back to an earlier
222
+ * step. Drawn straight, it would cut through every box between the two ends
223
+ * and park its label on one of them; it goes round the side instead (the
224
+ * right in a column, underneath in a row), clear of everything it passes, and
225
+ * each such link a step further out than the last.
226
+ */
227
+ function routeBack(from, to, nodes, horizontal, lane) {
228
+ if (horizontal) {
229
+ const left = Math.min(from.x, to.x);
230
+ const right = Math.max(from.x + from.width, to.x + to.width);
231
+ const passed = nodes.filter((n) => n.x < right && n.x + n.width > left);
232
+ const channel = Math.max(...passed.map((n) => n.y + n.height)) + CHANNEL_GAP * (lane + 1);
233
+ const start = {
234
+ x: from.x + from.width / 2,
235
+ y: from.y + from.height
236
+ };
237
+ const end = {
238
+ x: to.x + to.width / 2,
239
+ y: to.y + to.height
240
+ };
241
+ return [
242
+ start,
243
+ {
244
+ x: start.x,
245
+ y: channel
246
+ },
247
+ {
248
+ x: end.x,
249
+ y: channel
250
+ },
251
+ end
252
+ ];
253
+ }
254
+ const top = Math.min(from.y, to.y);
255
+ const bottom = Math.max(from.y + from.height, to.y + to.height);
256
+ const passed = nodes.filter((n) => n.y < bottom && n.y + n.height > top);
257
+ const channel = Math.max(...passed.map((n) => n.x + n.width)) + CHANNEL_GAP * (lane + 1);
258
+ const start = {
259
+ x: from.x + from.width,
260
+ y: from.y + from.height / 2
261
+ };
262
+ const end = {
263
+ x: to.x + to.width,
264
+ y: to.y + to.height / 2
265
+ };
266
+ return [
267
+ start,
268
+ {
269
+ x: channel,
270
+ y: start.y
271
+ },
272
+ {
273
+ x: channel,
274
+ y: end.y
275
+ },
276
+ end
277
+ ];
278
+ }
362
279
  /** Straight where the two boxes line up, a single elbow where they do not. */
363
280
  function route(from, to, horizontal) {
364
281
  const fromCentre = {
@@ -480,11 +397,12 @@ function layoutDiagram(diagram, options = {}) {
480
397
  });
481
398
  const byId = new Map(nodes.map((n) => [n.id, n]));
482
399
  const edges = [];
400
+ let lanes = 0;
483
401
  for (const edge of diagram.edges) {
484
402
  const from = byId.get(edge.from);
485
403
  const to = byId.get(edge.to);
486
404
  if (!from || !to) continue;
487
- const points = route(from, to, horizontal);
405
+ const points = (rankOf.get(edge.to) ?? 0) < (rankOf.get(edge.from) ?? 0) ? routeBack(from, to, nodes, horizontal, lanes++) : route(from, to, horizontal);
488
406
  edges.push({
489
407
  ...edge,
490
408
  points,
@@ -492,8 +410,13 @@ function layoutDiagram(diagram, options = {}) {
492
410
  });
493
411
  }
494
412
  placeLabels(edges, opts.fontSize);
495
- const width = Math.max(...nodes.map((n) => n.x + n.width)) + opts.padding;
496
- const height = Math.max(...nodes.map((n) => n.y + n.height)) + opts.padding;
413
+ const labelSize = opts.fontSize * .85;
414
+ const reach = edges.flatMap((edge) => [...edge.points, ...edge.labelAt && edge.label ? [{
415
+ x: edge.labelAt.x + (measureText(edge.label, labelSize) + 10) / 2,
416
+ y: edge.labelAt.y + labelSize * .8
417
+ }] : []]);
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;
497
420
  return {
498
421
  direction: diagram.direction,
499
422
  nodes,
@@ -503,6 +426,150 @@ function layoutDiagram(diagram, options = {}) {
503
426
  };
504
427
  }
505
428
  //#endregion
429
+ //#region src/app/lib/design.ts
430
+ function designToCssVars(d) {
431
+ return {
432
+ "--od-bg": d.palette.bg,
433
+ "--od-text": d.palette.text,
434
+ "--od-muted": d.palette.muted,
435
+ "--od-accent": d.palette.accent,
436
+ "--od-rule": d.palette.rule,
437
+ "--od-font-heading": d.fonts.heading,
438
+ "--od-font-body": d.fonts.body,
439
+ "--od-font-mono": d.fonts.mono,
440
+ "--od-size-title": `${d.typeScale.title}px`,
441
+ "--od-size-h1": `${d.typeScale.h1}px`,
442
+ "--od-size-h2": `${d.typeScale.h2}px`,
443
+ "--od-size-h3": `${d.typeScale.h3}px`,
444
+ "--od-size-body": `${d.typeScale.body}px`,
445
+ "--od-size-caption": `${d.typeScale.caption}px`,
446
+ "--od-margin": `${d.margin}px`,
447
+ "--od-leading": String(d.leading),
448
+ "--od-radius": `${d.radius}px`
449
+ };
450
+ }
451
+ function cssVarsToString(vars) {
452
+ return Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join("\n");
453
+ }
454
+ const defaultDesign = {
455
+ palette: {
456
+ bg: "#ffffff",
457
+ text: "#16181d",
458
+ muted: "#6b7280",
459
+ accent: "#2563eb",
460
+ rule: "#e5e7eb"
461
+ },
462
+ fonts: {
463
+ heading: "-apple-system, BlinkMacSystemFont, \"Inter\", system-ui, sans-serif",
464
+ body: "-apple-system, BlinkMacSystemFont, \"Inter\", system-ui, sans-serif",
465
+ mono: "ui-monospace, \"SF Mono\", \"JetBrains Mono\", Menlo, monospace"
466
+ },
467
+ typeScale: {
468
+ title: 44,
469
+ h1: 28,
470
+ h2: 20,
471
+ h3: 16,
472
+ body: 14,
473
+ caption: 10
474
+ },
475
+ margin: 76,
476
+ leading: 1.55,
477
+ radius: 6
478
+ };
479
+ //#endregion
480
+ //#region src/data/delimited.ts
481
+ /**
482
+ * RFC 4180 with the parts that actually show up in exported data: quoted
483
+ * fields, doubled quotes inside them, embedded newlines, and CRLF.
484
+ *
485
+ * Hand-written because `core` ships to every user and a CSV dependency is a lot
486
+ * of install size for something a report needs in one place.
487
+ */
488
+ function splitRecords(text, delimiter) {
489
+ const records = [];
490
+ let row = [];
491
+ let field = "";
492
+ let quoted = false;
493
+ let started = false;
494
+ const endField = () => {
495
+ row.push(field);
496
+ field = "";
497
+ started = false;
498
+ };
499
+ const endRow = () => {
500
+ endField();
501
+ records.push(row);
502
+ row = [];
503
+ };
504
+ for (let i = 0; i < text.length; i++) {
505
+ const char = text[i];
506
+ if (quoted) {
507
+ if (char === "\"") {
508
+ if (text[i + 1] === "\"") {
509
+ field += "\"";
510
+ i++;
511
+ continue;
512
+ }
513
+ quoted = false;
514
+ continue;
515
+ }
516
+ field += char;
517
+ continue;
518
+ }
519
+ if (char === "\"" && !started) {
520
+ quoted = true;
521
+ started = true;
522
+ continue;
523
+ }
524
+ if (char === delimiter) {
525
+ endField();
526
+ continue;
527
+ }
528
+ if (char === "\r") {
529
+ if (text[i + 1] === "\n") i++;
530
+ endRow();
531
+ continue;
532
+ }
533
+ if (char === "\n") {
534
+ endRow();
535
+ continue;
536
+ }
537
+ field += char;
538
+ started = true;
539
+ }
540
+ if (field !== "" || row.length > 0) endRow();
541
+ return records;
542
+ }
543
+ /** Numbers stay numbers so a table can align and format them; nothing else is guessed at. */
544
+ function coerce(raw) {
545
+ const value = raw.trim();
546
+ if (value === "") return null;
547
+ if (/^-?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?$/.test(value)) {
548
+ const n = Number(value);
549
+ if (Number.isFinite(n)) return n;
550
+ }
551
+ return value;
552
+ }
553
+ function parseDelimited(text, opts = {}) {
554
+ const delimiter = opts.delimiter ?? ",";
555
+ const records = splitRecords(text.replace(/^/, ""), delimiter).filter((record) => record.length > 1 || (record[0] ?? "") !== "");
556
+ if (records.length === 0) return {
557
+ columns: [],
558
+ rows: []
559
+ };
560
+ const header = opts.noHeader ? records[0].map((_, index) => `column${index + 1}`) : records[0].map((name, index) => name.trim() || `column${index + 1}`);
561
+ return {
562
+ columns: header,
563
+ rows: (opts.noHeader ? records : records.slice(1)).map((record) => {
564
+ const row = {};
565
+ header.forEach((name, index) => {
566
+ row[name] = coerce(record[index] ?? "");
567
+ });
568
+ return row;
569
+ })
570
+ };
571
+ }
572
+ //#endregion
506
573
  //#region src/diagram/parse.ts
507
574
  var DiagramSyntaxError = class extends Error {
508
575
  line;
@@ -513,14 +580,15 @@ var DiagramSyntaxError = class extends Error {
513
580
  }
514
581
  };
515
582
  const HEADER_RE = /^(?:flowchart|graph)(?:\s+(TB|TD|BT|LR|RL))?$/i;
516
- /** `A[Label]`, `A(Label)`, `A([Label])`, `A{Label}`, `A((Label))`, or a bare `A`. */
517
- const NODE_RE = /^([A-Za-z0-9_.-]+)(?:(\(\(|\(\[|\[|\(|\{)([\s\S]*?)(\)\)|\]\)|\]|\)|\}))?$/;
583
+ /** `A[Label]`, `A(Label)`, `A([Label])`, `A[(Label)]`, `A{Label}`, `A((Label))`, or a bare `A`. */
584
+ const NODE_RE = /^([A-Za-z0-9_.-]+)(?:(\(\(|\(\[|\[\(|\[|\(|\{)([\s\S]*?)(\)\)|\]\)|\)\]|\]|\)|\}))?$/;
518
585
  const SHAPES = {
519
586
  "[": "rect",
520
587
  "(": "round",
521
588
  "([": "stadium",
522
589
  "{": "diamond",
523
- "((": "circle"
590
+ "((": "circle",
591
+ "[(": "cylinder"
524
592
  };
525
593
  /**
526
594
  * Links, longest first: `-.->` must be tried before `-->` or the dash prefix
@@ -695,11 +763,12 @@ function escapeXml(text) {
695
763
  * Every colour and face is a `--od-*` variable rather than a literal, which is
696
764
  * the entire reason this renderer exists: the drawing inherits the document's
697
765
  * theme, in the viewer and in the PDF, instead of arriving with a palette of
698
- * its own.
766
+ * its own. Each carries a fallback, since a document without a `design` sets
767
+ * none of them and an unset `fill` paints the shapes solid black.
699
768
  */
700
769
  function shapePath(node) {
701
770
  const { x, y, width: w, height: h } = node;
702
- const common = "fill=\"var(--od-bg)\" stroke=\"var(--od-text)\" stroke-width=\"1.25\"";
771
+ const common = "fill=\"var(--od-bg, #ffffff)\" stroke=\"var(--od-text, #16181d)\" stroke-width=\"1.25\"";
703
772
  switch (node.shape) {
704
773
  case "diamond": return `<polygon points="${[
705
774
  `${x + w / 2},${y}`,
@@ -709,27 +778,31 @@ function shapePath(node) {
709
778
  ].join(" ")}" ${common} />`;
710
779
  case "circle": return `<ellipse cx="${x + w / 2}" cy="${y + h / 2}" rx="${w / 2}" ry="${h / 2}" ${common} />`;
711
780
  case "stadium": return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${h / 2}" ry="${h / 2}" ${common} />`;
781
+ case "cylinder": {
782
+ const ry = Math.min(8, h / 6);
783
+ return `<path d="${`M${x},${y + ry} A${w / 2},${ry} 0 0 1 ${x + w},${y + ry} L${x + w},${y + h - ry} A${w / 2},${ry} 0 0 1 ${x},${y + h - ry} Z`}" ${common} /><path d="${`M${x},${y + ry} A${w / 2},${ry} 0 0 0 ${x + w},${y + ry}`}" fill="none" stroke="var(--od-text, #16181d)" stroke-width="1.25" />`;
784
+ }
712
785
  case "round": return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="10" ry="10" ${common} />`;
713
- default: return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="var(--od-radius, 2)" ${common} />`;
786
+ default: return `<rect x="${x}" y="${y}" width="${w}" height="${h}" style="rx: var(--od-radius, 2px)" ${common} />`;
714
787
  }
715
788
  }
716
789
  function nodeText(node, fontSize) {
717
790
  const firstBaseline = node.y + node.height / 2 - node.lines.length * fontSize * LINE_HEIGHT / 2 + fontSize * .98;
718
791
  return node.lines.map((line, i) => {
719
792
  const y = firstBaseline + i * fontSize * LINE_HEIGHT;
720
- return `<text x="${node.x + node.width / 2}" y="${y}" text-anchor="middle" font-family="var(--od-font-body)" font-size="${fontSize}" fill="var(--od-text)">${escapeXml(line)}</text>`;
793
+ return `<text x="${node.x + node.width / 2}" y="${y}" text-anchor="middle" font-family="var(--od-font-body, sans-serif)" font-size="${fontSize}" fill="var(--od-text, #16181d)">${escapeXml(line)}</text>`;
721
794
  }).join("");
722
795
  }
723
796
  function edgePath(edge, marker) {
724
797
  const d = edge.points.map((point, i) => `${i === 0 ? "M" : "L"}${round(point.x)},${round(point.y)}`).join(" ");
725
798
  const dash = edge.style === "dashed" ? " stroke-dasharray=\"5 4\"" : "";
726
- return `<path d="${d}" fill="none" stroke="var(--od-text)" stroke-width="${edge.style === "thick" ? 2.25 : 1.25}"${dash} stroke-linejoin="round"${edge.arrow ? ` marker-end="url(#${marker})"` : ""} />`;
799
+ return `<path d="${d}" fill="none" stroke="var(--od-text, #16181d)" stroke-width="${edge.style === "thick" ? 2.25 : 1.25}"${dash} stroke-linejoin="round"${edge.arrow ? ` marker-end="url(#${marker})"` : ""} />`;
727
800
  }
728
801
  function edgeLabel(edge, fontSize) {
729
802
  if (!edge.labelAt || !edge.label) return "";
730
803
  const size = fontSize * .85;
731
804
  const width = measureText(edge.label, size) + 10;
732
- return `<rect x="${round(edge.labelAt.x - width / 2)}" y="${round(edge.labelAt.y - size * .8)}" width="${round(width)}" height="${round(size * 1.6)}" fill="var(--od-bg)" /><text x="${round(edge.labelAt.x)}" y="${round(edge.labelAt.y + size * .34)}" text-anchor="middle" font-family="var(--od-font-body)" font-size="${size}" fill="var(--od-muted)">${escapeXml(edge.label)}</text>`;
805
+ return `<rect x="${round(edge.labelAt.x - width / 2)}" y="${round(edge.labelAt.y - size * .8)}" width="${round(width)}" height="${round(size * 1.6)}" fill="var(--od-bg, #ffffff)" /><text x="${round(edge.labelAt.x)}" y="${round(edge.labelAt.y + size * .34)}" text-anchor="middle" font-family="var(--od-font-body, sans-serif)" font-size="${size}" fill="var(--od-muted, #6b7280)">${escapeXml(edge.label)}</text>`;
733
806
  }
734
807
  function round(value) {
735
808
  return Math.round(value * 100) / 100;
@@ -737,7 +810,7 @@ function round(value) {
737
810
  function renderDiagram(diagram, options = {}) {
738
811
  const fontSize = options.fontSize ?? 13;
739
812
  const marker = `od-arrow${options.idSuffix ? `-${options.idSuffix}` : ""}`;
740
- 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)" /></marker></defs>`;
813
+ 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>`;
741
814
  const body = [
742
815
  ...diagram.edges.map((edge) => edgePath(edge, marker)),
743
816
  ...diagram.nodes.map((node) => shapePath(node)),
@@ -760,4 +833,4 @@ function compileDiagram(source, options = {}) {
760
833
  };
761
834
  }
762
835
  //#endregion
763
- export { defaultDesign as a, cssVarsToString as i, DiagramSyntaxError as n, designToCssVars as o, parseDelimited as r, compileDiagram as t };
836
+ export { defaultDesign as a, cssVarsToString as i, DiagramSyntaxError as n, designToCssVars as o, parseDelimited as r, measureText as s, compileDiagram as t };
@@ -0,0 +1,44 @@
1
+ import { g as diffDocument } from "./ops-DKidjLXP.js";
2
+ import { t as cliContext } from "./context-B4ip7SoI.js";
3
+ import chalk from "chalk";
4
+ //#region src/cli/diff.ts
5
+ const MARK = {
6
+ same: chalk.dim("·"),
7
+ changed: chalk.yellow("~"),
8
+ added: chalk.green("+"),
9
+ removed: chalk.red("-")
10
+ };
11
+ function where(change) {
12
+ if (change.status === "removed") return `p.${change.before} (removed)`;
13
+ if (change.before !== null && change.before !== change.after) return `p.${change.after} (was p.${change.before})`;
14
+ return `p.${change.after}`;
15
+ }
16
+ /**
17
+ * Renders the document as it is and as it was at a revision, and reports what
18
+ * changed page by page — on the terminal, and as a self-contained HTML report a
19
+ * reviewer can open without the repository.
20
+ */
21
+ async function diffDoc(docId, opts = {}) {
22
+ const ctx = await cliContext();
23
+ const result = await diffDocument(ctx, docId, {
24
+ ...opts.since ? { since: opts.since } : {},
25
+ ...opts.outDir ? { outDir: opts.outDir } : {}
26
+ });
27
+ if (opts.json) {
28
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
29
+ return;
30
+ }
31
+ const moved = result.pages.filter((page) => page.status !== "same");
32
+ process.stdout.write(`${chalk.bold(docId)} ${chalk.dim(`since ${result.since} (${result.commit.slice(0, 7)})`)} — ${moved.length === 0 ? chalk.green("no changes") : `${moved.length} of ${result.pages.length} page(s) changed`}\n`);
33
+ for (const change of moved) {
34
+ process.stdout.write(` ${MARK[change.status]} ${where(change)}\n`);
35
+ for (const line of change.lines.slice(0, 6)) {
36
+ const text = line.text.length > 90 ? `${line.text.slice(0, 89)}…` : line.text;
37
+ process.stdout.write(` ${line.op === "add" ? chalk.green(`+ ${text}`) : chalk.red(`- ${text}`)}\n`);
38
+ }
39
+ if (change.lines.length > 6) process.stdout.write(chalk.dim(` … ${change.lines.length - 6} more line(s)\n`));
40
+ }
41
+ process.stdout.write(`${chalk.dim("report")} ${result.file}\n`);
42
+ }
43
+ //#endregion
44
+ export { diffDoc };
@@ -1,7 +1,7 @@
1
1
  import { r as EXPORT_FORMATS } from "./sdk-CqNZzbkz.js";
2
- import { _ as listDocIds } from "./config-4nz5NnxW.js";
3
- import { d as closeRenderSession, f as exportDocument } from "./ops-OZZVBgsM.js";
4
- import { t as cliContext } from "./context-BH8C-dSW.js";
2
+ import { f as listDocIds } from "./config-CvzpyAUA.js";
3
+ import { d as closeRenderSession, f as exportDocument } from "./ops-DKidjLXP.js";
4
+ import { t as cliContext } from "./context-B4ip7SoI.js";
5
5
  import chalk from "chalk";
6
6
  //#region src/cli/export.ts
7
7
  const FORMATS = EXPORT_FORMATS;
@@ -1,5 +1,5 @@
1
- import { m as importMarkdown } from "./ops-OZZVBgsM.js";
2
- import { t as cliContext } from "./context-BH8C-dSW.js";
1
+ import { m as importMarkdown } from "./ops-DKidjLXP.js";
2
+ import { t as cliContext } from "./context-B4ip7SoI.js";
3
3
  import chalk from "chalk";
4
4
  import path from "node:path";
5
5
  //#region src/cli/import.ts
package/dist/index.d.ts CHANGED
@@ -1,6 +1,56 @@
1
- import { A as useDocLabels, C as cssVarsToString, D as LabelKind, E as LabelEntry, O as LabelVocabulary, S as DesignTypeScale, T as designToCssVars, _ as isPageSizeName, a as DocModule, b as DesignPalette, d as Orientation, f as PAGE_SIZES, g as isOrientation, h as PageSizeName, i as DocMeta, k as useDocLabel, l as FlowSection, m as PageGeometry, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PAGE_SIZE_NAMES, r as DocEntry, t as DEFAULT_ORIENTATION, u as ORIENTATIONS, v as resolvePageGeometry, w as defaultDesign, x as DesignSystem, y as DesignFonts } from "./sdk-BqU6mwD_.js";
1
+ import { A as useDocLabels, C as cssVarsToString, D as LabelKind, E as LabelEntry, O as LabelVocabulary, S as DesignTypeScale, T as designToCssVars, _ as isPageSizeName, a as DocModule, b as DesignPalette, d as Orientation, f as PAGE_SIZES, g as isOrientation, h as PageSizeName, i as DocMeta, k as useDocLabel, l as FlowSection, m as PageGeometry, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PAGE_SIZE_NAMES, r as DocEntry, t as DEFAULT_ORIENTATION, u as ORIENTATIONS, v as resolvePageGeometry, w as defaultDesign, x as DesignSystem, y as DesignFonts } from "./sdk-CpDEGRIo.js";
2
2
  import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-P61niZMf.js";
3
3
  import { CSSProperties, ComponentType, ReactNode } from "react";
4
+ //#region src/app/lib/chart.d.ts
5
+ /**
6
+ * Chart geometry, kept pure so it can be tested without a DOM.
7
+ *
8
+ * A chart is laid out synchronously from its data into a fixed box — no
9
+ * measuring pass, no async load — because the flow packer measures the page
10
+ * as it first renders, and a chart that settled a tick later would settle
11
+ * after the page break was decided. Text widths come from the same estimate
12
+ * the diagram compiler uses, for the same reason.
13
+ */
14
+ type ChartType = 'bar' | 'line' | 'pie';
15
+ type ChartFormat = 'number' | 'integer' | 'percent' | ((value: number) => string);
16
+ //#endregion
17
+ //#region src/app/components/chart.d.ts
18
+ type ChartProps = {
19
+ type?: ChartType;
20
+ /** Rows as parsed from a `.csv`/`.tsv` import, or any array of objects. */
21
+ data: Array<Record<string, unknown>>;
22
+ /** The key holding each row's category — the x axis, or a slice's name. */
23
+ x: string;
24
+ /** The key, or keys, holding the values. One key per series; a pie reads the first. */
25
+ y: string | string[];
26
+ /** Legend names for the `y` keys. */
27
+ labels?: Record<string, string>;
28
+ /** Stack the series instead of grouping them (bar charts). */
29
+ stacked?: boolean;
30
+ /** How axis ticks and value labels print. */
31
+ format?: ChartFormat;
32
+ /** Print each value on its bar, point or slice. */
33
+ values?: boolean;
34
+ /** Series colours, in order. Defaults to the document's accent and tints of it. */
35
+ colors?: string[];
36
+ /** Drawn size in CSS px; the drawing scales down to the column if it is wider. */
37
+ width?: number;
38
+ height?: number;
39
+ /** Caption text. Given one, the chart is numbered like any other figure. */
40
+ caption?: ReactNode;
41
+ captionText?: string;
42
+ kind?: LabelKind;
43
+ id?: string;
44
+ style?: CSSProperties;
45
+ className?: string;
46
+ };
47
+ /**
48
+ * A bar, line or pie chart drawn from data, in the document's own colours and
49
+ * type. It lays itself out synchronously into a fixed box, so it measures as
50
+ * it prints; the Word export places it as a picture.
51
+ */
52
+ declare function Chart({ type, data, x, y, labels, stacked, format, values, colors, width, height, caption, captionText, kind, id, style, className }: ChartProps): import("react").JSX.Element;
53
+ //#endregion
4
54
  //#region src/app/lib/source-loc.d.ts
5
55
  /**
6
56
  * In dev, `loc-tags-plugin` stamps `data-od-loc` onto the call site of a
@@ -214,6 +264,7 @@ declare function TableOfContents({ maxLevel, showPageNumbers, includeOwnPage, in
214
264
  * block — a heading, a paragraph, a table — that never straddles a page break.
215
265
  */
216
266
  declare function flow(children: ReactNode, opts?: {
267
+ header?: ComponentType;
217
268
  footer?: ComponentType;
218
269
  padding?: number;
219
270
  }): FlowSection;
@@ -287,7 +338,7 @@ declare function parseDelimited(text: string, opts?: ParseOptions): DelimitedTab
287
338
  //#endregion
288
339
  //#region src/diagram/parse.d.ts
289
340
  type Direction = 'TD' | 'LR';
290
- type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle';
341
+ type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle' | 'cylinder';
291
342
  type DiagramNode = {
292
343
  id: string;
293
344
  label: string;
@@ -342,4 +393,4 @@ type CompileOptions = LayoutOptions & RenderOptions;
342
393
  /** Mermaid-flavoured text in, themed SVG out. One call, no browser. */
343
394
  declare function compileDiagram(source: string, options?: CompileOptions): CompiledDiagram;
344
395
  //#endregion
345
- export { type BlockMetrics, type CellValue, type CompileOptions, type CompiledDiagram, DEFAULT_ORIENTATION, DEFAULT_PAGE_SIZE, type DataAlign, type DataColumn, type DataFormat, DataTable, type DataTableProps, type DelimitedTable, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, Diagram, type DiagramProps, type DiagramSource, DiagramSyntaxError, type DocEntry, type DocMeta, type DocModule, type DocPage, Figure, type FigureProps, type FlowSection, Footnote, type FootnoteProps, Footnotes, type FootnotesProps, ImagePlaceholder, type ImagePlaceholderProps, type LabelEntry, type LabelKind, type LabelVocabulary, ListOf, ListOfFigures, type ListOfProps, ListOfTables, ORIENTATIONS, type OpenDocBuildConfig, type OpenDocConfig, type Orientation, type OutlineEntry, PAGE_SIZES, PAGE_SIZE_NAMES, type PageGeometry, type PageSizeName, type PaginationResult, Ref, type RefProps, TableOfContents, type TableOfContentsProps, compileDiagram, cssVarsToString, defaultDesign, designToCssVars, flow, isFlowSection, isOrientation, isPageSizeName, paginateBlocks, parseDelimited, resolvePageGeometry, useDocLabel, useDocLabels, useDocOutline, useDocPageCount, useDocPageNumber };
396
+ export { type BlockMetrics, type CellValue, Chart, type ChartFormat, type ChartProps, type ChartType, type CompileOptions, type CompiledDiagram, DEFAULT_ORIENTATION, DEFAULT_PAGE_SIZE, type DataAlign, type DataColumn, type DataFormat, DataTable, type DataTableProps, type DelimitedTable, type DesignFonts, type DesignPalette, type DesignSystem, type DesignTypeScale, Diagram, type DiagramProps, type DiagramSource, DiagramSyntaxError, type DocEntry, type DocMeta, type DocModule, type DocPage, Figure, type FigureProps, type FlowSection, Footnote, type FootnoteProps, Footnotes, type FootnotesProps, ImagePlaceholder, type ImagePlaceholderProps, type LabelEntry, type LabelKind, type LabelVocabulary, ListOf, ListOfFigures, type ListOfProps, ListOfTables, ORIENTATIONS, type OpenDocBuildConfig, type OpenDocConfig, type Orientation, type OutlineEntry, PAGE_SIZES, PAGE_SIZE_NAMES, type PageGeometry, type PageSizeName, type PaginationResult, Ref, type RefProps, TableOfContents, type TableOfContentsProps, compileDiagram, cssVarsToString, defaultDesign, designToCssVars, flow, isFlowSection, isOrientation, isPageSizeName, paginateBlocks, parseDelimited, resolvePageGeometry, useDocLabel, useDocLabels, useDocOutline, useDocPageCount, useDocPageNumber };