@open-document/core 0.11.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.
- package/dist/{build-BHFGY8eF.js → build-CbgIk6bA.js} +1 -1
- package/dist/{check-UEBmDfT_.js → check-BTroj-5Z.js} +3 -3
- package/dist/cli/bin.js +58 -34
- package/dist/config-BWtOZ1jc.d.ts +45 -0
- package/dist/{config-B_pdNbYg.js → config-DKKNIbvO.js} +1458 -983
- package/dist/{context-BM9_-u9P.js → context-DXNP8v9I.js} +3 -2
- package/dist/deploy-gcp-BUiSuqz7.js +758 -0
- package/dist/{dev-DX3QMIRi.js → dev-YXumw5iX.js} +1 -1
- package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
- package/dist/{diff-DayvbXfX.js → diff-CTFfU4Tz.js} +2 -2
- package/dist/{export-BPsXj1i6.js → export-D2QLtF84.js} +11 -4
- package/dist/flow-CS5apebG.d.ts +252 -0
- package/dist/{import-71wlAsrd.js → import-CcmrFetU.js} +3 -2
- package/dist/index.d.ts +155 -59
- package/dist/index.js +945 -104
- package/dist/open-doc-plugin-DnX5usgI.js +320 -0
- package/dist/ops/index.d.ts +112 -3
- package/dist/ops/index.js +3 -3
- package/dist/{ops-BUo67DaP.js → ops-DmEecq1k.js} +86 -164
- package/dist/package-version-C89gtYSk.js +36 -0
- package/dist/{preview-D3m1-gUL.js → preview-_mHpBhMk.js} +1 -1
- package/dist/templates-MMblHwmT.js +34 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +2 -1
- package/package.json +2 -1
- package/skills/apply-comments/SKILL.md +3 -1
- package/skills/create-doc/SKILL.md +2 -0
- package/skills/doc-authoring/SKILL.md +17 -16
- package/skills/doc-authoring/references/long-form.md +43 -2
- package/skills/doc-authoring/references/pagination.md +14 -2
- package/skills/doc-authoring/references/tables-and-charts.md +21 -17
- package/src/app/components/browser/browser-ui.tsx +21 -0
- package/src/app/components/browser/new-document-dialog.tsx +208 -0
- package/src/app/components/callout.tsx +101 -0
- package/src/app/components/changes/changes-overlay.tsx +68 -0
- package/src/app/components/changes/changes-panel.tsx +341 -0
- package/src/app/components/changes/use-changes.ts +85 -0
- package/src/app/components/chart.tsx +191 -33
- package/src/app/components/code-block.tsx +249 -0
- package/src/app/components/comments/comments-overlay.tsx +50 -0
- package/src/app/components/comments/comments-panel.tsx +272 -0
- package/src/app/components/comments/use-comments.ts +61 -0
- package/src/app/components/data-table.tsx +146 -18
- package/src/app/components/doc-sidebar.tsx +32 -2
- package/src/app/components/flow-page.tsx +57 -8
- package/src/app/components/inspector/field-source.tsx +41 -0
- package/src/app/components/inspector/inspector.tsx +64 -65
- package/src/app/components/numbering.tsx +226 -12
- package/src/app/components/overlay-frame.tsx +79 -0
- package/src/app/components/page-frame.tsx +46 -0
- package/src/app/components/page-placement.ts +68 -0
- package/src/app/components/record-picker.tsx +79 -0
- package/src/app/components/themes/theme-preview.tsx +5 -4
- package/src/app/lib/agent-bridge.ts +29 -1
- package/src/app/lib/chart.test.ts +15 -0
- package/src/app/lib/chart.ts +134 -9
- package/src/app/lib/diagnostics.ts +45 -1
- package/src/app/lib/docx/ooxml.test.ts +24 -1
- package/src/app/lib/docx/ooxml.ts +27 -1
- package/src/app/lib/export-docx.ts +3 -1
- package/src/app/lib/export-dom.ts +17 -3
- package/src/app/lib/export-html.ts +4 -2
- package/src/app/lib/export-image.ts +2 -1
- package/src/app/lib/export-pdf.ts +9 -1
- package/src/app/lib/flow-measure.test.ts +30 -0
- package/src/app/lib/flow-measure.ts +68 -14
- package/src/app/lib/flow.test.ts +20 -1
- package/src/app/lib/flow.ts +120 -20
- package/src/app/lib/i18n-ja/browser.ts +10 -0
- package/src/app/lib/i18n-ja/doc.ts +4 -0
- package/src/app/lib/i18n-ja/panels.ts +40 -0
- package/src/app/lib/i18n-ko/browser.ts +10 -0
- package/src/app/lib/i18n-ko/doc.ts +4 -0
- package/src/app/lib/i18n-ko/panels.ts +39 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +10 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +4 -0
- package/src/app/lib/i18n-zh-cn/panels.ts +38 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +10 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +4 -0
- package/src/app/lib/i18n-zh-tw/panels.ts +38 -0
- package/src/app/lib/labels.ts +29 -10
- package/src/app/lib/records.test.ts +38 -0
- package/src/app/lib/records.ts +127 -0
- package/src/app/lib/sdk.ts +35 -0
- package/src/app/lib/use-doc-module.ts +7 -0
- package/src/app/lib/use-doc-pages.ts +38 -17
- package/src/app/routes/doc.tsx +275 -13
- package/src/app/routes/home.tsx +30 -5
- package/src/app/styles.css +23 -0
- package/templates/blank/index.tsx +63 -0
- package/templates/blank/template.json +6 -0
- package/templates/certificate/data/recipients.csv +4 -0
- package/templates/certificate/index.tsx +128 -0
- package/templates/certificate/template.json +6 -0
- package/templates/letter/index.tsx +106 -0
- package/templates/letter/template.json +5 -0
- package/templates/meeting-notes/index.tsx +194 -0
- package/templates/meeting-notes/template.json +6 -0
- package/templates/proposal/index.tsx +264 -0
- package/templates/proposal/template.json +6 -0
- package/templates/report/data/metrics.csv +5 -0
- package/templates/report/index.tsx +224 -0
- package/templates/report/template.json +6 -0
- package/dist/config-P61niZMf.d.ts +0 -24
- package/dist/sdk-CpDEGRIo.d.ts +0 -138
|
@@ -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 =
|
|
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 +
|
|
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 +
|
|
512
|
+
offset += extent + effectiveNodeGap;
|
|
374
513
|
}
|
|
375
|
-
rankSpan[i] = Math.max(0, offset -
|
|
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 +
|
|
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
|
|
419
|
-
|
|
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
|
|
701
|
-
* report actually uses. Agents already write this
|
|
702
|
-
* the whole reason to borrow it rather than invent
|
|
703
|
-
* so the output follows the document's theme instead
|
|
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
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
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 {
|
|
2
|
-
import { t as cliContext } from "./context-
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import { t as cliContext } from "./context-
|
|
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;
|
|
@@ -20,8 +20,15 @@ async function exportDocs(docIds, opts = {}) {
|
|
|
20
20
|
for (const docId of targets) {
|
|
21
21
|
const result = await exportDocument(ctx, docId, {
|
|
22
22
|
format,
|
|
23
|
-
...opts.outDir !== void 0 ? { outDir: opts.outDir } : {}
|
|
23
|
+
...opts.outDir !== void 0 ? { outDir: opts.outDir } : {},
|
|
24
|
+
...opts.each ? { each: true } : {},
|
|
25
|
+
...opts.name !== void 0 ? { name: opts.name } : {}
|
|
24
26
|
});
|
|
27
|
+
if (result.records !== void 0) {
|
|
28
|
+
process.stdout.write(`${chalk.green("✓")} ${chalk.bold(docId)} ${chalk.dim(`${result.records} records, ${result.pageCount}p`)} → ${result.files.length} files\n`);
|
|
29
|
+
for (const file of result.files) process.stdout.write(chalk.dim(` ${file}\n`));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
25
32
|
const files = result.files.join(", ");
|
|
26
33
|
process.stdout.write(`${chalk.green("✓")} ${chalk.bold(docId)} ${chalk.dim(`${result.pageCount}p`)} → ${files}\n`);
|
|
27
34
|
}
|