@draftably/editor 0.0.0-stage → 0.1.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 (185) hide show
  1. package/README.md +26 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
  4. package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
  5. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
  6. package/dist/chunks/arc-rJj0TtXf.js +83 -0
  7. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
  8. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
  9. package/dist/chunks/browser-iNhbPsGc.js +40 -0
  10. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
  11. package/dist/chunks/channel-qMvPU6eH.js +5 -0
  12. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
  13. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
  14. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
  15. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
  16. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
  17. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
  18. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
  19. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
  20. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
  21. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
  22. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
  23. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
  24. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
  25. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
  26. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
  27. package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
  28. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
  29. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
  30. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
  31. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
  32. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
  33. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
  34. package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
  35. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
  36. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
  37. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
  38. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
  39. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
  40. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
  41. package/dist/chunks/graph-CKJmgLki.js +1541 -0
  42. package/dist/chunks/import-core-C-I1wGfw.js +145 -0
  43. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
  44. package/dist/chunks/init-DjUOC4st.js +16 -0
  45. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
  46. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
  47. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
  48. package/dist/chunks/katex-BsrBVQKd.js +11314 -0
  49. package/dist/chunks/linear-4t7D_ros.js +259 -0
  50. package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
  51. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
  52. package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
  53. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
  54. package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
  55. package/dist/chunks/ordinal-DfAQgscy.js +61 -0
  56. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
  57. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
  58. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
  59. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
  60. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
  61. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
  62. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
  63. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
  64. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
  65. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
  66. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
  67. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
  68. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
  69. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
  70. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
  71. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
  72. package/dist/element.js +36 -0
  73. package/dist/index.js +4 -0
  74. package/dist/types/src/cli/links.d.ts +4 -0
  75. package/dist/types/src/cli/pdf.d.ts +29 -0
  76. package/dist/types/src/cli/png.d.ts +23 -0
  77. package/dist/types/src/cli/svg.d.ts +4 -0
  78. package/dist/types/src/components/Icon.d.ts +14 -0
  79. package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
  80. package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
  81. package/dist/types/src/components/canvas/Frame.d.ts +22 -0
  82. package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
  83. package/dist/types/src/components/canvas/Notes.d.ts +5 -0
  84. package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
  85. package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
  86. package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
  87. package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
  88. package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
  89. package/dist/types/src/components/controls.d.ts +88 -0
  90. package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
  91. package/dist/types/src/components/scene/GroupView.d.ts +22 -0
  92. package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
  93. package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
  94. package/dist/types/src/components/scene/NodeView.d.ts +18 -0
  95. package/dist/types/src/components/scene/parts.d.ts +50 -0
  96. package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
  97. package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
  98. package/dist/types/src/components/session-context.d.ts +486 -0
  99. package/dist/types/src/dsl/cells.d.ts +91 -0
  100. package/dist/types/src/dsl/channels.d.ts +53 -0
  101. package/dist/types/src/dsl/compile.d.ts +162 -0
  102. package/dist/types/src/dsl/frame.d.ts +38 -0
  103. package/dist/types/src/dsl/lanes.d.ts +23 -0
  104. package/dist/types/src/dsl/layout-edits.d.ts +58 -0
  105. package/dist/types/src/dsl/legend-notes.d.ts +3 -0
  106. package/dist/types/src/dsl/project.d.ts +39 -0
  107. package/dist/types/src/dsl/source-edits.d.ts +37 -0
  108. package/dist/types/src/dsl/syntax.d.ts +317 -0
  109. package/dist/types/src/dsl/translate.d.ts +69 -0
  110. package/dist/types/src/editor/Editor.d.ts +6 -0
  111. package/dist/types/src/editor/element.d.ts +15 -0
  112. package/dist/types/src/editor/mount.d.ts +23 -0
  113. package/dist/types/src/import/browser.d.ts +3 -0
  114. package/dist/types/src/import/detect.d.ts +31 -0
  115. package/dist/types/src/import/dot-importer.d.ts +3 -0
  116. package/dist/types/src/import/import-core.d.ts +105 -0
  117. package/dist/types/src/import/mermaid-facade.d.ts +120 -0
  118. package/dist/types/src/import/mermaid-importer.d.ts +4 -0
  119. package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
  120. package/dist/types/src/import/scratch.d.ts +3 -0
  121. package/dist/types/src/lib/engine-tasks.d.ts +88 -0
  122. package/dist/types/src/lib/font-data.d.ts +9 -0
  123. package/dist/types/src/lib/saved-diagram.d.ts +4 -0
  124. package/dist/types/src/lib/scene-cache.d.ts +4 -0
  125. package/dist/types/src/lib/source-hash.d.ts +7 -0
  126. package/dist/types/src/lib/svg-export.d.ts +15 -0
  127. package/dist/types/src/model/appearance.d.ts +209 -0
  128. package/dist/types/src/model/bounds.d.ts +19 -0
  129. package/dist/types/src/model/camera.d.ts +21 -0
  130. package/dist/types/src/model/candidates.d.ts +53 -0
  131. package/dist/types/src/model/colors.d.ts +22 -0
  132. package/dist/types/src/model/document.d.ts +24 -0
  133. package/dist/types/src/model/edits.d.ts +133 -0
  134. package/dist/types/src/model/embed.d.ts +17 -0
  135. package/dist/types/src/model/examples.d.ts +15 -0
  136. package/dist/types/src/model/font-faces.d.ts +24 -0
  137. package/dist/types/src/model/fonts.d.ts +47 -0
  138. package/dist/types/src/model/footnote.d.ts +34 -0
  139. package/dist/types/src/model/frame.d.ts +71 -0
  140. package/dist/types/src/model/geometry.d.ts +29 -0
  141. package/dist/types/src/model/graph.d.ts +53 -0
  142. package/dist/types/src/model/heading.d.ts +38 -0
  143. package/dist/types/src/model/icons.d.ts +2 -0
  144. package/dist/types/src/model/label-hits.d.ts +27 -0
  145. package/dist/types/src/model/labels.d.ts +88 -0
  146. package/dist/types/src/model/legend.d.ts +25 -0
  147. package/dist/types/src/model/link.d.ts +63 -0
  148. package/dist/types/src/model/markers.d.ts +47 -0
  149. package/dist/types/src/model/note.d.ts +75 -0
  150. package/dist/types/src/model/panels.d.ts +11 -0
  151. package/dist/types/src/model/rich-text.d.ts +24 -0
  152. package/dist/types/src/model/routes.d.ts +170 -0
  153. package/dist/types/src/model/samples.d.ts +11 -0
  154. package/dist/types/src/model/stack.d.ts +8 -0
  155. package/dist/types/src/model/static-scene.d.ts +15 -0
  156. package/dist/types/src/model/status.d.ts +84 -0
  157. package/dist/types/src/model/styles.d.ts +13 -0
  158. package/dist/types/src/model/surface.d.ts +31 -0
  159. package/dist/types/src/model/types.d.ts +277 -0
  160. package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
  161. package/dist/types/src/server/file-session.d.ts +19 -0
  162. package/dist/types/src/server/workspace.d.ts +21 -0
  163. package/dist/types/src/state/active-session.d.ts +479 -0
  164. package/dist/types/src/state/commands.d.ts +529 -0
  165. package/dist/types/src/state/comparison.d.ts +151 -0
  166. package/dist/types/src/state/files.d.ts +61 -0
  167. package/dist/types/src/state/keyboard.d.ts +6 -0
  168. package/dist/types/src/state/keys.d.ts +5 -0
  169. package/dist/types/src/state/launch.d.ts +61 -0
  170. package/dist/types/src/state/links.d.ts +11 -0
  171. package/dist/types/src/state/session/actions.d.ts +77 -0
  172. package/dist/types/src/state/session/canvas-text.d.ts +24 -0
  173. package/dist/types/src/state/session/document.d.ts +84 -0
  174. package/dist/types/src/state/session/editor.d.ts +81 -0
  175. package/dist/types/src/state/session/emphasis.d.ts +11 -0
  176. package/dist/types/src/state/session/file-session.d.ts +98 -0
  177. package/dist/types/src/state/session/index.d.ts +496 -0
  178. package/dist/types/src/state/session/layout.d.ts +79 -0
  179. package/dist/types/src/state/session/pointer.d.ts +19 -0
  180. package/dist/types/src/state/session/routing.d.ts +20 -0
  181. package/dist/types/src/state/session/scene.d.ts +144 -0
  182. package/dist/types/src/state/session/sculpt.d.ts +70 -0
  183. package/dist/types/src/state/toast.d.ts +14 -0
  184. package/dist/types/src/state/ui.d.ts +39 -0
  185. package/package.json +41 -3
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Links on objects (`href=`): what a link points at, and where its mark sits on a shape.
3
+ *
4
+ * A link is kept as the author wrote it. A URL (`https://…`, `mailto:`) opens as written; a
5
+ * `.draft` opens in the viewer; anything else is a file path that opens in the editor. A file
6
+ * path may end in `:line` or `:line:col`, and a relative one starts at the link base: the git
7
+ * root of the diagram, unless the file sets `config link-base=`.
8
+ */
9
+ import { type TypeProfile } from './fonts';
10
+ export type LinkKind = 'url' | 'draft' | 'file';
11
+ export interface LinkTarget {
12
+ kind: LinkKind;
13
+ /** The URL, or the file path without its line and column. */
14
+ path: string;
15
+ line?: number;
16
+ col?: number;
17
+ }
18
+ export declare function linkTarget(href: string): LinkTarget;
19
+ /**
20
+ * A relative `href` against a URL `link-base` (`https://host/org/repo/blob/<sha>/`), as the URL
21
+ * it opens; null when the base is a folder or unset, or `href` is already a URL.
22
+ */
23
+ export declare function baseUrl(href: string, base: string | undefined): string | null;
24
+ /** Join and normalize forward-slash paths; an absolute `path` ignores `base`. */
25
+ export declare function joinPath(base: string, path: string): string;
26
+ /** The path from folder `from` to `to`, both absolute with forward slashes. */
27
+ export declare function relativePath(from: string, to: string): string;
28
+ /**
29
+ * A link as a static SVG carries it. A URL stays as written; a file or `.draft` becomes a path
30
+ * from the diagram's folder (a first guess at where the SVG is saved), without its line.
31
+ */
32
+ export declare function staticHref(href: string, base: string, folder: string): string;
33
+ /** Editors that open `<scheme>://file/<path>:<line>:<col>`. */
34
+ export declare const EDITORS: readonly ["vscode", "vscode-insiders", "cursor", "windsurf", "zed"];
35
+ export type Editor = (typeof EDITORS)[number];
36
+ /** File settings from `config` statements. */
37
+ export interface FileConfig {
38
+ /**
39
+ * Where relative links start: a folder relative to the diagram's (its git root when unset), or
40
+ * a URL that relative links are joined to.
41
+ */
42
+ linkBase?: string;
43
+ /** The editor file links open in; VS Code when unset. */
44
+ editor?: Editor;
45
+ /** Strike removed titles through in a diff; off when unset. */
46
+ strikeRemoved?: boolean;
47
+ }
48
+ export declare const editorUrl: (editor: Editor, file: string, line?: number, col?: number) => string;
49
+ /** The link mark: a small arrow out of a shape's top-right corner, inside the shape when it can be. */
50
+ export interface LinkMark {
51
+ x: number;
52
+ y: number;
53
+ size: number;
54
+ /** Inside the shape's fill (draw in its ink), or on the canvas beside it. */
55
+ inside: boolean;
56
+ }
57
+ export declare const LINK_MARK_SIZE = 10;
58
+ /** `badge` is the width of a `count` badge on the corner, which the mark steps left of. */
59
+ export declare function linkMark(shape: string, w: number, h: number, badge?: number): LinkMark;
60
+ /** The mark next to a container's title. */
61
+ export declare const groupLinkMark: (title: string, font: TypeProfile, band: number) => LinkMark;
62
+ /** The arrow, in a 10×10 box. */
63
+ export declare const LINK_MARK_PATH = "M2 8L8 2M3.5 2H8V6.5";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The marks at a connection's ends, `head=` and `tail=` in a file. The canvas and the CLI draw
3
+ * them from these definitions, so both give the same geometry.
4
+ */
5
+ import type { Point, Rect } from './types';
6
+ /** What `head=` and `tail=` accept. A plain edge is `head=arrow tail=none`. */
7
+ export declare const MARKERS: readonly ["arrow", "none", "triangle", "open-triangle", "diamond", "open-diamond", "circle", "cross"];
8
+ export type EndMarker = (typeof MARKERS)[number];
9
+ export interface MarkerShape {
10
+ w: number;
11
+ h: number;
12
+ /** Where the marker sits on its line, at the height of its middle. */
13
+ x: number;
14
+ d: string;
15
+ /** Solid marks take the line's ink. Open marks take the surface, which hides what is under. */
16
+ fill: 'ink' | 'surface' | 'none';
17
+ /** How far short of the end its line stops; the mark fills that gap, tip on the end. */
18
+ stop: number;
19
+ }
20
+ /** Each marker points along +x, in drawing units. `arrow` is the original open chevron. */
21
+ export declare const MARKER_SHAPES: Record<Exclude<EndMarker, 'none'>, MarkerShape>;
22
+ export declare const MARKER_STROKE = 1.5;
23
+ /** The `<marker>` box for an end. A tail's mark turns to face away from the line. */
24
+ export declare const markerBox: (kind: Exclude<EndMarker, "none">, tail: boolean) => {
25
+ markerWidth: number;
26
+ markerHeight: number;
27
+ refX: number;
28
+ refY: number;
29
+ orient: string;
30
+ };
31
+ /** The fill a marker takes on this line and surface. */
32
+ export declare function markerFill(kind: Exclude<EndMarker, 'none'>, ink: string, surface: string): string;
33
+ type Ends = {
34
+ directed?: boolean;
35
+ head?: EndMarker;
36
+ tail?: EndMarker;
37
+ };
38
+ /** An undirected edge has no marks, whatever else it holds. */
39
+ export declare const headOf: (e: Ends) => EndMarker;
40
+ export declare const tailOf: (e: Ends) => EndMarker;
41
+ /** Whether an edge has anything beyond the plain arrow, which labels and lines ignore. */
42
+ export declare const hasMarkers: (e: Ends) => boolean;
43
+ /** A route with each end pulled back to its marker's stop, so no line runs through a mark. */
44
+ export declare function stoppedPoints(points: Point[], e: Ends): Point[];
45
+ /** The room an edge's marks take. A label keeps off them. */
46
+ export declare function markerRects(points: Point[], e: Ends): Rect[];
47
+ export {};
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Notes: sentences on a diagram that never move its layout, from `note` statements. An anchored
3
+ * note (`near=`) is placed after layout in free space beside its object or sequence message; a
4
+ * note without one sits in the frame under the subtitle. The viewer, `inspect --svg` and the
5
+ * editor's exports all place and draw them from here.
6
+ */
7
+ import { type ResolvedAppearance } from './appearance';
8
+ import type { BoundedRoute } from './bounds';
9
+ import { type Run } from './rich-text';
10
+ import type { Diagram, Point, Rect } from './types';
11
+ export declare const NOTE_SIDES: readonly ["below", "above", "left", "right"];
12
+ export type NoteSide = (typeof NOTE_SIDES)[number];
13
+ export interface Note {
14
+ text: string;
15
+ /** The node, group or sequence message the note sits beside; the frame when unset. */
16
+ near?: string;
17
+ /** Which side of `near`; `below` when unset, or `right` for a message. */
18
+ side?: NoteSide;
19
+ /** Wrap width; `NOTE_WIDTH` when unset. */
20
+ width?: number;
21
+ }
22
+ /**
23
+ * A note with its box and wrapped lines. `inFrame` notes sit under the subtitle; `overlaps` is set
24
+ * on an anchored note when no clear spot was found.
25
+ */
26
+ export interface PlacedNote {
27
+ note: Note;
28
+ rect: Rect;
29
+ /** Wrapped lines, each as runs of plain text and links. */
30
+ lines: Run[][];
31
+ inFrame?: boolean;
32
+ overlaps?: boolean;
33
+ }
34
+ /** The side a note sits on: its `side`, or by default right of a message and below anything else. */
35
+ export declare const noteSide: (doc: Diagram, note: Note) => NoteSide;
36
+ /** Default wrap width, and the room between a note and its object. */
37
+ export declare const NOTE_WIDTH = 280;
38
+ /** Room between a note's panel and its text. */
39
+ export declare const NOTE_PAD: {
40
+ x: number;
41
+ y: number;
42
+ };
43
+ /** The note's wrapped lines and box size, at 0,0. */
44
+ export declare function noteBox(look: ResolvedAppearance, note: Note): PlacedNote;
45
+ /**
46
+ * Spots in a sequence's side margins, by index in `notes`, for notes on the messages in `rows`.
47
+ * `left` and `right` are the margins' inner edges and `top` the highest a note goes. A note is
48
+ * level with its row, or pushed down clear of the note above it. The panel grows round these, so
49
+ * no note here can cover the drawing.
50
+ */
51
+ export declare function marginNotes(look: ResolvedAppearance, notes: readonly Note[], rows: ReadonlyMap<string, number>, { left, right, top }: {
52
+ left: number;
53
+ right: number;
54
+ top: number;
55
+ }): (Rect | null)[];
56
+ /**
57
+ * Place every anchored note beside its object or message, clear of shapes, group borders, lines
58
+ * and earlier notes when a nearby spot allows it. Frame notes, and notes whose object is not drawn,
59
+ * come back `inFrame` at 0,0 for `diagramFrame` to place.
60
+ */
61
+ export declare function placeNotes(doc: Diagram, look: ResolvedAppearance, rects: ReadonlyMap<string, Rect>, routes: readonly BoundedRoute[]): PlacedNote[];
62
+ /**
63
+ * SVG markup for placed notes: a quiet panel with a bar on its left edge, then the text. Links
64
+ * are `<a>` elements with `href` as `write` gives it.
65
+ */
66
+ export declare function noteMarkup(look: ResolvedAppearance, notes: readonly PlacedNote[], write?: (href: string) => string | null): string;
67
+ /**
68
+ * Where a note dropped at `p` belongs: beside the closest object or (in a sequence) message, on
69
+ * the side of it `p` is on. Inside several objects the smallest wins, so a note dropped on a
70
+ * shape in a group goes to the shape. Undefined when nothing is within reach.
71
+ */
72
+ export declare function noteAnchor(p: Point, rects: ReadonlyMap<string, Rect>, messages?: readonly BoundedRoute[]): {
73
+ near: string;
74
+ side: NoteSide;
75
+ } | undefined;
@@ -0,0 +1,11 @@
1
+ import type { Diagram } from './types';
2
+ export type PanelSide = 'before' | 'after';
3
+ /**
4
+ * The merged document with each change as it was: old labels, shapes, counts, rows and phase
5
+ * bands. Every object stays in its place and every line stays in.
6
+ */
7
+ export declare function oldDoc(doc: Diagram): Diagram;
8
+ /** Panels repeat the drawing and put its notes in the frame, so a sequence drops its margins. */
9
+ export declare function withoutMargins(doc: Diagram): Diagram;
10
+ /** The document as it was (`before`: no added objects, old values) or is (`after`: no removed). */
11
+ export declare function panelDoc(doc: Diagram, side: PanelSide): Diagram;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Prose with links, for notes and footnotes: `[#1997](https://github.com/org/repo/pull/1997)`
3
+ * draws `#1997` as a link. Lines wrap exactly as the plain words would, so a link never moves
4
+ * anything; each line comes back as runs with their offsets, for SVG `<a>` and click targets.
5
+ */
6
+ import { type TypeProfile } from './fonts';
7
+ export interface Run {
8
+ text: string;
9
+ href?: string;
10
+ /** Offset from the line's start, and width. */
11
+ x: number;
12
+ w: number;
13
+ }
14
+ /** The text as drawn, with every link written as its label. */
15
+ export declare const plainText: (text: string) => string;
16
+ /** Every link's target, in order. */
17
+ export declare const textLinks: (text: string) => string[];
18
+ /** The text's lines at `width`, each as runs of plain text and links. */
19
+ export declare function richLines(text: string, width: number, type: TypeProfile): Run[][];
20
+ /**
21
+ * One line's content inside its `<text>`: plain runs as text, links as an underlined `<tspan>` in
22
+ * `link`, wrapped in `<a>` with `href` as `write` gives it.
23
+ */
24
+ export declare function runsMarkup(runs: Run[], link: string, write: (href: string) => string | null): string;
@@ -0,0 +1,170 @@
1
+ import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine.js';
2
+ import { type ResolvedAppearance } from './appearance';
3
+ import { type VisibleGraph } from './graph';
4
+ import type { Diagram, EdgeLayout, Point, Rect, ShapeKind, Side } from './types';
5
+ export declare const SIDE_VECTORS: Record<Side, Point>;
6
+ /** Where a connection meets a shape's outline on the given side. */
7
+ export declare function portPoint(shape: ShapeKind, r: Rect, side: Side, offset?: number): Point;
8
+ /** Side of `r` facing `p`. */
9
+ export declare function sideToward(r: Rect, p: Point): Side;
10
+ export interface EdgeLabelBox extends Point {
11
+ w: number;
12
+ h: number;
13
+ score?: number;
14
+ }
15
+ /** Lines and borders a label may sit on only when nothing better is free. */
16
+ export interface LabelAvoid {
17
+ /** Other edges' routes. Routes that leave from this edge's first point share its trunk. */
18
+ routes?: Point[][];
19
+ /** Thin strips along group borders. */
20
+ borders?: Rect[];
21
+ /** The marks at line ends. A spot that hides one costs as much as a line through the text. */
22
+ marks?: Rect[];
23
+ /** The open group that holds both ends. A spot not inside it costs a little less than a line. */
24
+ home?: Rect;
25
+ }
26
+ /** One edge label for `placeEdgeLabels`: its text, its route, and what it should keep clear of. */
27
+ export interface LabelJob {
28
+ label: string;
29
+ points: Point[];
30
+ avoid?: LabelAvoid;
31
+ /** The user's nudge, added to the chosen spot. */
32
+ dx?: number;
33
+ dy?: number;
34
+ }
35
+ /**
36
+ * Place every edge label at once, after all routes exist. Each label takes a spot on its own
37
+ * route that covers no shape, group title or other label, and crosses as few other lines as it
38
+ * can; a label closer to another than its own height costs as much as a line beside it. Labels
39
+ * with a clean spot go first, then one repair sweep moves each label to its best spot given all
40
+ * the others. Only a label with every spot near its route blocked moves away from it, and then as
41
+ * little as possible.
42
+ */
43
+ export declare function placeEdgeLabels(jobs: LabelJob[], obstacles: Rect[], look?: ResolvedAppearance, fixed?: Rect[]): EdgeLabelBox[];
44
+ /**
45
+ * Choose a label spot on the edge's own route, clear of the labels already placed: see
46
+ * `placeEdgeLabels`.
47
+ */
48
+ export declare function placeEdgeLabel(label: string, points: Point[], obstacles: Rect[], existing?: Rect[], look?: ResolvedAppearance, avoid?: LabelAvoid): EdgeLabelBox;
49
+ export interface DrawnRoute extends Route {
50
+ label: EdgeLabelBox | null;
51
+ path: string;
52
+ /**
53
+ * Short pieces of the line where it crosses another line or a group's frame: the only places a
54
+ * canvas-colored halo is drawn under it, so the crossing reads as a clean break. Empty when the
55
+ * line crosses nothing.
56
+ */
57
+ halo: string;
58
+ /**
59
+ * For a line to or from a cell with no side on its group's outline: the stretch from the outline
60
+ * across other cells to that cell's edge. It is drawn over the cells, with a dot at the edge.
61
+ */
62
+ cross?: [Point, Point];
63
+ }
64
+ export interface SceneRoutes {
65
+ routes: DrawnRoute[];
66
+ result: RoutingResult;
67
+ }
68
+ /**
69
+ * An edge's routing settings, with its lane turned into bends and sides: out of the source to
70
+ * the lane, along it, and into the target. A lane with `leave` or `enter` turns at that coordinate beside
71
+ * the source or target, to meet it side on. A lane that no longer lies between the two ends (a
72
+ * node was dragged across it) is ignored, as is any lane on an edge with its own bends.
73
+ */
74
+ export declare function laneBends(cfg: EdgeLayout, a: Rect, b: Rect): EdgeLayout;
75
+ export declare function routeInput(doc: Diagram, vg: VisibleGraph, all: Map<string, Rect>): {
76
+ nodes: ({
77
+ shape: ShapeKind;
78
+ x: number;
79
+ y: number;
80
+ w: number;
81
+ h: number;
82
+ id: string;
83
+ title: string;
84
+ was?: string;
85
+ wasShape?: ShapeKind;
86
+ wasCount?: number | string;
87
+ href?: string;
88
+ count?: number | string;
89
+ span?: number | "var";
90
+ parentId?: string;
91
+ image?: string;
92
+ lifeline?: number;
93
+ } | {
94
+ parentId?: string | undefined;
95
+ frame?: boolean | undefined;
96
+ shape: ShapeKind;
97
+ x: number;
98
+ y: number;
99
+ w: number;
100
+ h: number;
101
+ id: string;
102
+ title: string;
103
+ })[];
104
+ groups: {
105
+ titleHeight?: number | undefined;
106
+ collapsed: boolean;
107
+ titleWidth: number;
108
+ x: number;
109
+ y: number;
110
+ w: number;
111
+ h: number;
112
+ id: string;
113
+ title: string;
114
+ was?: string;
115
+ href?: string;
116
+ parentId?: string;
117
+ frame?: "soft" | "none";
118
+ titleLines?: number;
119
+ hull?: Rect[];
120
+ }[];
121
+ edges: {
122
+ from: string;
123
+ to: string;
124
+ cfg: EdgeLayout;
125
+ a: string;
126
+ b: string;
127
+ id: string;
128
+ label: string;
129
+ was?: string;
130
+ directed: boolean;
131
+ head?: import("./markers").EndMarker;
132
+ tail?: import("./markers").EndMarker;
133
+ emphasis: boolean;
134
+ dashed: boolean;
135
+ status?: import("./status.js").Status;
136
+ spot?: import("./status.js").Spot;
137
+ }[];
138
+ };
139
+ /**
140
+ * A labelled route with no run the label clears slides one bend along, so one run holds the label
141
+ * away from the bend; a label on the corner reads as part of neither run. `w` and `h` are the
142
+ * label's box. The bend moves the least that gives a run the label plus `LABEL_RUN` at each end,
143
+ * or as close to that as the route allows while the label still clears both ends. The move stands
144
+ * only when the route stays out of every box, crosses no more lines and runs beside no more.
145
+ */
146
+ export declare function roomForLabel(points: Point[], w: number, h: number, boxes: Rect[], others: Point[][]): Point[];
147
+ /** Add label positions and SVG paths to raw routes. */
148
+ export declare function drawRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, result: RoutingResult): DrawnRoute[];
149
+ /** Width of the halo under a connection, in drawing units. */
150
+ export declare const HALO_WIDTH = 8;
151
+ /** How far a halo piece runs each way from a crossing, along the line. */
152
+ export declare const HALO_REACH = 7;
153
+ /**
154
+ * The lines, by index, that another line's halo would cut at a mark. A halo there leaves half a
155
+ * mark, or on a short line almost nothing, so these lines stay whole.
156
+ */
157
+ export declare function wholeLines(lines: {
158
+ points: Point[];
159
+ marks: Rect[];
160
+ }[]): Set<number>;
161
+ /** The pieces of `points` around each place it crosses `others` or a frame's border, as a path. */
162
+ export declare function haloPath(points: Point[], others: Point[][], frames: Rect[]): string;
163
+ /** Full routes already computed for this drawing, or null. */
164
+ export declare function knownRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>): RoutingResult | null;
165
+ /** Record full routes computed elsewhere (the engine worker) for this drawing. */
166
+ export declare function rememberRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, result: RoutingResult): void;
167
+ export declare function computeRoutes(doc: Diagram, vg: VisibleGraph, rects: Map<string, Rect>, options?: {
168
+ previous?: PriorRoute[];
169
+ quick?: boolean;
170
+ }): SceneRoutes;
@@ -0,0 +1,11 @@
1
+ import type { Diagram } from './types';
2
+ export interface SampleInfo {
3
+ id: string;
4
+ title: string;
5
+ icon: string;
6
+ }
7
+ /** Examples in menu order. Each id names a file in `src/samples/`. */
8
+ export declare const SAMPLES: SampleInfo[];
9
+ export declare const DEFAULT_SAMPLE = "automatic-ports";
10
+ /** A fresh copy of an example, with its own document id. */
11
+ export declare function loadSample(id: string): Diagram;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A node with `count` stands for many things: two offset outlines behind it read as a stack, and
3
+ * a badge on its corner says how many. Shared by the canvas and the SVG output.
4
+ */
5
+ /** Offsets of the outlines behind the node, back to front. */
6
+ export declare const STACK_OFFSETS: number[];
7
+ /** The badge's text: `×42`, `×1.2k` for large counts, or `×N` for a symbol. */
8
+ export declare function countText(count: number | string): string;
@@ -0,0 +1,15 @@
1
+ import type { RoutingResult } from '../engines/routing-engine.js';
2
+ import { type VisibleGraph } from './graph';
3
+ import { type DrawnRoute } from './routes';
4
+ import type { Diagram, Point, Rect } from './types';
5
+ /** A read-only drawing of a document with precomputed routes, e.g. a comparison candidate. */
6
+ export interface StaticScene {
7
+ doc: Diagram;
8
+ vg: VisibleGraph;
9
+ rects: Map<string, Rect>;
10
+ routes: DrawnRoute[];
11
+ bounds: Rect;
12
+ }
13
+ export declare function buildStaticScene(doc: Diagram, routing: RoutingResult): StaticScene;
14
+ /** Center of an object in a scene, or of its nearest visible container when it is hidden. */
15
+ export declare function anchorPoint(scene: StaticScene, id: string): Point;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Change status: how an object or connection differs between two versions of a diagram, drawn
3
+ * the same way by the canvas, `inspect --svg` and the exports.
4
+ *
5
+ * A file with change marks is a diff, and in a diff color means change and nothing else:
6
+ * unchanged shapes turn neutral, containers become quiet outlines, unchanged lines go grey, and
7
+ * only added (green), changed (amber) and removed (red) objects keep a hue, as a tinted fill with
8
+ * a strong border. Each status also has a border weight, dash, fade or marker, so a diff still
9
+ * reads in grayscale. A removed title stays readable; `config strike-removed=on` strikes it.
10
+ */
11
+ import { type LegendEntry, type ResolvedAppearance, type Swatch } from './appearance';
12
+ import type { Diagram, DiagramEdge } from './types';
13
+ export type Status = 'same' | 'added' | 'removed' | 'changed' | 'context';
14
+ /**
15
+ * How an emphasis state draws an object or connection: in focus (a heavier border or line),
16
+ * ringed (in focus where nothing else fades, so it also takes an accent ring or line), or dimmed
17
+ * (faded and neutral, like a `.` context line). Unset means it draws as usual.
18
+ */
19
+ export type Spot = 'focus' | 'ring' | 'dim';
20
+ export declare const STATUSES: Status[];
21
+ /** Legend order and wording, after a count; `same` needs no entry. */
22
+ export declare const STATUS_LABELS: Partial<Record<Status, string>>;
23
+ export interface StatusCount {
24
+ status: Status;
25
+ /** Objects with the mark. */
26
+ count: number;
27
+ /** Connections with the mark. */
28
+ lines: number;
29
+ }
30
+ /**
31
+ * A legend entry's text: how many objects carry the mark and what it means, then how many
32
+ * connections, so five added boxes and their five lines read "5 added · 5 lines", not "10 added".
33
+ */
34
+ export declare const statusLabel: ({ status, count, lines }: StatusCount) => string;
35
+ export interface StatusPaint {
36
+ /** Line color for connections; shapes take theirs from `statusSwatch`. */
37
+ stroke?: string;
38
+ width?: number;
39
+ dash?: string;
40
+ opacity: number;
41
+ /** Strike the title through. */
42
+ strike: boolean;
43
+ /** Fade of the title text alone, on top of `opacity`. */
44
+ inkFade?: number;
45
+ /** Draw the removed marker, a minus in a disc, on the shape's top-right corner. */
46
+ marker?: boolean;
47
+ /** Draw an accent ring around the shape (`haloInk`). */
48
+ halo?: boolean;
49
+ }
50
+ /** The removed marker's radius and its inset from a shape's top-right corner. */
51
+ export declare const MARKER: {
52
+ r: number;
53
+ inset: number;
54
+ };
55
+ /** Room between a shape and its focus ring. */
56
+ export declare const HALO_GAP = 4;
57
+ /** The accent a ringed object or connection is drawn with: the theme's second accent. */
58
+ export declare const haloInk: (look: ResolvedAppearance) => string;
59
+ /** The paint for a change status, with an emphasis state's weight or fade on top. */
60
+ export declare function statusPaint(look: ResolvedAppearance, status?: Status, spot?: Spot): StatusPaint;
61
+ /** Whether the document is a diff: any object or connection carries a change mark. */
62
+ export declare const isDiff: (doc: Diagram) => boolean;
63
+ /**
64
+ * In a diff, the swatch a status draws a shape with: a pale tint of its hue with a strong border
65
+ * and dark ink, or the neutral surface (a quiet outline for containers) when unchanged.
66
+ */
67
+ export declare function statusSwatch(look: ResolvedAppearance, status: Status | undefined, kind: 'node' | 'group'): Swatch;
68
+ /** A connection's color: its status hue, or quiet grey for an unchanged line in a diff. */
69
+ export declare const edgeInk: (look: ResolvedAppearance, edge: DiagramEdge, diff: boolean) => string;
70
+ /**
71
+ * The document drawn in emphasis state `id`. Listed objects (a group with all its members) and
72
+ * listed connections are in focus, and so is a connection between two focused nodes. With
73
+ * `rest=dim`, everything else fades, except the containers that hold something in focus, so the
74
+ * context still reads. With `rest=plain` nothing fades, so focus also takes an accent ring.
75
+ * Nothing moves.
76
+ */
77
+ export declare function withState(doc: Diagram, id: string): Diagram;
78
+ /**
79
+ * The marks a document uses that the legend explains, in legend order, each with how many
80
+ * objects and connections carry it, so the key doubles as the change's size.
81
+ */
82
+ export declare function usedStatuses(doc: Diagram): StatusCount[];
83
+ /** The color key's rows: a diff draws no family colors, so it lists only its statuses. */
84
+ export declare const drawnLegend: (doc: Diagram) => LegendEntry[];
@@ -0,0 +1,13 @@
1
+ import type { NodeStyle, ShapeKind } from './types';
2
+ export declare const SHAPES: ShapeKind[];
3
+ export declare const SHAPE_LABELS: Record<ShapeKind, string>;
4
+ /** Icons offered in the inspector for a shape. */
5
+ export declare const NODE_ICONS: string[];
6
+ /** Styles for version 1 node types, used only when migrating old files. */
7
+ export declare const LEGACY_TYPE_STYLE: Record<string, NodeStyle>;
8
+ export declare const DEFAULT_STYLE: NodeStyle;
9
+ /** Default size for a new shape of the given kind. */
10
+ export declare function defaultShapeSize(shape: ShapeKind): {
11
+ w: number;
12
+ h: number;
13
+ };
@@ -0,0 +1,31 @@
1
+ import { type ResolvedAppearance } from './appearance';
2
+ import type { Diagram, Point } from './types';
3
+ /** What is drawn at a point: an opaque fill, and a phase band's tint over it. */
4
+ export interface Surface {
5
+ fill: string;
6
+ tint?: {
7
+ fill: string;
8
+ opacity: number;
9
+ };
10
+ }
11
+ /** The tint of each sequence phase band: alternate bands are stronger, so neighbours read apart. */
12
+ export declare const phaseOpacity: (i: number) => 0.12 | 0.03;
13
+ /**
14
+ * A sequence's panel border only when its lanes leave a participant outside them. Lanes that
15
+ * hold every participant already bound the exchange, and a second frame around them is cruft.
16
+ */
17
+ export declare function panelDrawn(doc: Diagram): boolean;
18
+ /**
19
+ * The surface under a point, as the scene paints it: the canvas, the sequence panel, the
20
+ * innermost group fill, then a phase band's tint. Halos and label cards take it, so a break in a
21
+ * line reads as the lane it sits on, not a patch of canvas. A label card is one piece with the
22
+ * surface under its center, so a label over a group's edge never reads as a half-tinted box. The
23
+ * group rects are read once here and
24
+ * not cached on `doc`: the editor's store keeps one `doc` object and updates it in place.
25
+ */
26
+ export declare function surfaces(doc: Diagram, look: ResolvedAppearance): (p: Point) => Surface;
27
+ /** A halo path's pieces, grouped by the surface under each piece's middle. */
28
+ export declare function haloPieces(under: (p: Point) => Surface, halo: string): {
29
+ surface: Surface;
30
+ d: string;
31
+ }[];