@draftably/editor 0.0.0-stage → 0.2.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 (101) hide show
  1. package/README.md +25 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/assets/engine.worker-DwN9io_m.js +6856 -0
  4. package/dist/element.js +36 -0
  5. package/dist/index.js +19555 -0
  6. package/dist/types/src/cli/links.d.ts +4 -0
  7. package/dist/types/src/cli/pdf.d.ts +29 -0
  8. package/dist/types/src/cli/png.d.ts +23 -0
  9. package/dist/types/src/cli/svg.d.ts +4 -0
  10. package/dist/types/src/components/Icon.d.ts +14 -0
  11. package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
  12. package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
  13. package/dist/types/src/components/canvas/Frame.d.ts +22 -0
  14. package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
  15. package/dist/types/src/components/canvas/Notes.d.ts +5 -0
  16. package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
  17. package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
  18. package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
  19. package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
  20. package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
  21. package/dist/types/src/components/controls.d.ts +91 -0
  22. package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
  23. package/dist/types/src/components/scene/GroupView.d.ts +22 -0
  24. package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
  25. package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
  26. package/dist/types/src/components/scene/NodeView.d.ts +18 -0
  27. package/dist/types/src/components/scene/parts.d.ts +50 -0
  28. package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
  29. package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
  30. package/dist/types/src/components/session-context.d.ts +486 -0
  31. package/dist/types/src/dsl/cells.d.ts +91 -0
  32. package/dist/types/src/dsl/channels.d.ts +53 -0
  33. package/dist/types/src/dsl/compile.d.ts +162 -0
  34. package/dist/types/src/dsl/frame.d.ts +38 -0
  35. package/dist/types/src/dsl/lanes.d.ts +23 -0
  36. package/dist/types/src/dsl/layout-edits.d.ts +58 -0
  37. package/dist/types/src/dsl/legend-notes.d.ts +3 -0
  38. package/dist/types/src/dsl/project.d.ts +39 -0
  39. package/dist/types/src/dsl/source-edits.d.ts +37 -0
  40. package/dist/types/src/dsl/syntax.d.ts +317 -0
  41. package/dist/types/src/dsl/translate.d.ts +69 -0
  42. package/dist/types/src/editor/Editor.d.ts +6 -0
  43. package/dist/types/src/editor/element.d.ts +15 -0
  44. package/dist/types/src/editor/mount.d.ts +23 -0
  45. package/dist/types/src/lib/engine-tasks.d.ts +88 -0
  46. package/dist/types/src/lib/font-data.d.ts +9 -0
  47. package/dist/types/src/lib/saved-diagram.d.ts +4 -0
  48. package/dist/types/src/lib/scene-cache.d.ts +4 -0
  49. package/dist/types/src/lib/svg-export.d.ts +15 -0
  50. package/dist/types/src/model/appearance.d.ts +209 -0
  51. package/dist/types/src/model/bounds.d.ts +19 -0
  52. package/dist/types/src/model/camera.d.ts +21 -0
  53. package/dist/types/src/model/colors.d.ts +22 -0
  54. package/dist/types/src/model/document.d.ts +24 -0
  55. package/dist/types/src/model/edits.d.ts +133 -0
  56. package/dist/types/src/model/embed.d.ts +17 -0
  57. package/dist/types/src/model/font-faces.d.ts +24 -0
  58. package/dist/types/src/model/fonts.d.ts +47 -0
  59. package/dist/types/src/model/footnote.d.ts +34 -0
  60. package/dist/types/src/model/frame.d.ts +71 -0
  61. package/dist/types/src/model/geometry.d.ts +29 -0
  62. package/dist/types/src/model/graph.d.ts +53 -0
  63. package/dist/types/src/model/heading.d.ts +38 -0
  64. package/dist/types/src/model/icons.d.ts +2 -0
  65. package/dist/types/src/model/labels.d.ts +88 -0
  66. package/dist/types/src/model/legend.d.ts +25 -0
  67. package/dist/types/src/model/link.d.ts +63 -0
  68. package/dist/types/src/model/markers.d.ts +47 -0
  69. package/dist/types/src/model/note.d.ts +75 -0
  70. package/dist/types/src/model/panels.d.ts +11 -0
  71. package/dist/types/src/model/rich-text.d.ts +24 -0
  72. package/dist/types/src/model/routes.d.ts +170 -0
  73. package/dist/types/src/model/samples.d.ts +11 -0
  74. package/dist/types/src/model/stack.d.ts +8 -0
  75. package/dist/types/src/model/status.d.ts +84 -0
  76. package/dist/types/src/model/styles.d.ts +13 -0
  77. package/dist/types/src/model/surface.d.ts +31 -0
  78. package/dist/types/src/model/types.d.ts +277 -0
  79. package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
  80. package/dist/types/src/server/file-session.d.ts +19 -0
  81. package/dist/types/src/server/workspace.d.ts +21 -0
  82. package/dist/types/src/state/active-session.d.ts +479 -0
  83. package/dist/types/src/state/canvas-commands.d.ts +169 -0
  84. package/dist/types/src/state/canvas-keyboard.d.ts +15 -0
  85. package/dist/types/src/state/keys.d.ts +5 -0
  86. package/dist/types/src/state/links.d.ts +14 -0
  87. package/dist/types/src/state/session/actions.d.ts +77 -0
  88. package/dist/types/src/state/session/canvas-text.d.ts +24 -0
  89. package/dist/types/src/state/session/document.d.ts +84 -0
  90. package/dist/types/src/state/session/editor.d.ts +81 -0
  91. package/dist/types/src/state/session/emphasis.d.ts +11 -0
  92. package/dist/types/src/state/session/file-session.d.ts +98 -0
  93. package/dist/types/src/state/session/index.d.ts +496 -0
  94. package/dist/types/src/state/session/layout.d.ts +79 -0
  95. package/dist/types/src/state/session/pointer.d.ts +19 -0
  96. package/dist/types/src/state/session/routing.d.ts +20 -0
  97. package/dist/types/src/state/session/scene.d.ts +144 -0
  98. package/dist/types/src/state/session/sculpt.d.ts +70 -0
  99. package/dist/types/src/state/toast.d.ts +14 -0
  100. package/dist/types/src/state/workspace.d.ts +3 -0
  101. package/package.json +41 -3
@@ -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
+ }[];
@@ -0,0 +1,277 @@
1
+ export type Point = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export type Rect = {
6
+ x: number;
7
+ y: number;
8
+ w: number;
9
+ h: number;
10
+ };
11
+ export type Side = 'left' | 'right' | 'top' | 'bottom';
12
+ export type PortSide = Side | 'auto';
13
+ export type Direction = 'RIGHT' | 'DOWN';
14
+ export type Theme = 'light' | 'dark';
15
+ import type { DiagramAppearance, Shade } from './appearance';
16
+ import type { EndMarker } from './markers';
17
+ import type { Spot, Status } from './status';
18
+ export type ShapeKind = 'box' | 'pill' | 'circle' | 'diamond' | 'text' | 'icon' | 'image'
19
+ /** A seam between two cells of a `cells` group. */
20
+ | 'marker';
21
+ /** A color family: a built-in one, one the file defines, or `auto` for the theme's surface. */
22
+ export type ColorKey = string;
23
+ export type LabelMode = 'center' | 'top' | 'bottom' | 'left' | 'right' | 'detached';
24
+ export interface DiagramNode {
25
+ id: string;
26
+ title: string;
27
+ /** Title before a change, from `was=` on a `~` line. */
28
+ was?: string;
29
+ /** Shape before a change, from `was-shape=` on a `~` line. */
30
+ wasShape?: ShapeKind;
31
+ /** Count before a change, from `was-count=` on a `~` line; 1 means a single box. */
32
+ wasCount?: number | string;
33
+ /** A link to open from exported drawings. */
34
+ href?: string;
35
+ /** How many things this box stands for, or a symbol such as `N`; drawn as a stack with a badge. */
36
+ count?: number | string;
37
+ /** A cell's columns (or units), or `var` for a field of variable length. */
38
+ span?: number | 'var';
39
+ parentId?: string;
40
+ image?: string;
41
+ /** A sequence participant: length of the dashed lifeline below the box. */
42
+ lifeline?: number;
43
+ }
44
+ export interface DiagramGroup {
45
+ id: string;
46
+ title: string;
47
+ /** Title before a change, from `was=` on a `~` line. */
48
+ was?: string;
49
+ /** A link to open from exported drawings. */
50
+ href?: string;
51
+ parentId?: string;
52
+ /** `soft` draws a tint behind the members instead of a frame; `none` draws nothing. */
53
+ frame?: 'soft' | 'none';
54
+ /** Lines the title wraps to, when more than one; the header grows by a line for each. */
55
+ titleLines?: number;
56
+ /** A soft group's tint: rectangles relative to the group's top left; the first holds the label. */
57
+ hull?: Rect[];
58
+ }
59
+ export interface DiagramEdge {
60
+ id: string;
61
+ from: string;
62
+ to: string;
63
+ label: string;
64
+ /** Label before a change, from `was=` on a `~` line. */
65
+ was?: string;
66
+ directed: boolean;
67
+ /** The mark at the target end, when it isn't the plain arrow; see `headOf`. */
68
+ head?: EndMarker;
69
+ /** The mark at the source end, when it has one; see `tailOf`. */
70
+ tail?: EndMarker;
71
+ emphasis: boolean;
72
+ dashed: boolean;
73
+ /** How it differs between two versions of the diagram. */
74
+ status?: Status;
75
+ /** How the drawn emphasis state treats it; see `withState`. */
76
+ spot?: Spot;
77
+ }
78
+ export interface NodeLayout extends Rect {
79
+ manual?: boolean;
80
+ pinned?: boolean;
81
+ }
82
+ export interface EdgeLayout {
83
+ fromSide?: PortSide;
84
+ toSide?: PortSide;
85
+ labelDx?: number;
86
+ labelDy?: number;
87
+ waypoints?: Point[];
88
+ /** The reading direction of the layout that places both ends; the edge runs along it. */
89
+ flow?: 'right' | 'down';
90
+ /** Set by the compiler for a fold's wrap edge: the line it returns along, between two bands. */
91
+ lane?: Lane;
92
+ /** From a lane, at route time: where along its target's side the edge arrives, off centre. */
93
+ toOffset?: number;
94
+ /** A sequence message: drawn straight between the two lifelines at this height, not routed. */
95
+ row?: number;
96
+ }
97
+ /**
98
+ * A channel between two bands of a fold: a level line at `y`, or an upright one at `x`. With
99
+ * `leave`, the edge leaves its source's side and turns onto the lane at that coordinate; with
100
+ * `enter`, it runs on along the lane to that coordinate and turns into its target's side.
101
+ * With `out`, it is a return or skip lane beyond both ends.
102
+ */
103
+ export type Lane = ({
104
+ y: number;
105
+ } | {
106
+ x: number;
107
+ }) & {
108
+ leave?: number;
109
+ enter?: number;
110
+ /**
111
+ * A lane beyond both ends, outside their band: the edge leaves by the side facing it, runs
112
+ * along it, and at `enter` turns into the target's side that faces back toward the source.
113
+ */
114
+ out?: boolean;
115
+ /**
116
+ * With `out`: the gap beside the target holds another edge's label, so the edge arrives square
117
+ * on the target's face toward the lane, at `enter` (its middle), instead of turning into that gap.
118
+ */
119
+ face?: boolean;
120
+ };
121
+ export interface LabelLayout {
122
+ mode?: LabelMode;
123
+ dx?: number;
124
+ dy?: number;
125
+ width?: number;
126
+ leader?: boolean;
127
+ }
128
+ export interface ContainerLayout {
129
+ direction: 'inherit' | Direction;
130
+ padding: number;
131
+ manualSize: boolean;
132
+ /** Set for a `cells` group: its members touch, under a title band this tall. */
133
+ cellsBand?: number;
134
+ /** A byte or bit layout's extra marks, relative to the group's top-left corner. */
135
+ cellsChrome?: CellsChrome;
136
+ }
137
+ /** What a byte or bit layout draws besides its cells. */
138
+ export interface CellsChrome {
139
+ /** Unit numbers in a strip under the title band. */
140
+ ruler?: {
141
+ y: number;
142
+ h: number;
143
+ ticks: Array<{
144
+ x: number;
145
+ label: string;
146
+ }>;
147
+ };
148
+ /** Further pieces of fields that run on past a row's end, by field. */
149
+ pieces?: Record<string, Rect[]>;
150
+ /** Fields of variable length, drawn with broken ends. */
151
+ open?: string[];
152
+ }
153
+ export type IntentRole = 'start' | 'end';
154
+ export type IntentPlacement = 'top-left' | 'left-center' | 'center' | 'top-center' | 'top-right' | 'right-center' | 'bottom-left' | 'bottom-center' | 'bottom-right';
155
+ export type LayoutIntent = Partial<Record<IntentRole, {
156
+ id: string;
157
+ placement: IntentPlacement;
158
+ }>>;
159
+ export interface NodeStyle {
160
+ shape: ShapeKind;
161
+ color: ColorKey;
162
+ /** Numeric shade; omitted means the default for the object (500 for nodes, 100 for groups). */
163
+ shade?: Shade;
164
+ icon: string;
165
+ /** How it differs between two versions of the diagram. */
166
+ status?: Status;
167
+ /** How the drawn emphasis state treats it; see `withState`. */
168
+ spot?: Spot;
169
+ }
170
+ export type LayoutAlgorithmId = 'compound-flow' | 'boundary-align' | 'compound-spring' | 'tidy' | 'stress' | 'force' | 'flow' | 'layered' | 'tree' | 'grid' | 'separate';
171
+ export type AspectSetting = 'canvas' | '1' | '1.333' | '1.6' | '2' | '0.75';
172
+ export interface LayoutSettings {
173
+ algorithm: LayoutAlgorithmId;
174
+ direction: Direction;
175
+ mode: 'pass' | 'rebuild';
176
+ maxMove: number;
177
+ stability: number;
178
+ iterations: number;
179
+ nodeGap: number;
180
+ rankGap: number;
181
+ edgeLength: number;
182
+ repulsion: number;
183
+ flowStrength: number;
184
+ alignment: number;
185
+ compactness: number;
186
+ gridStrength: number;
187
+ aspect: AspectSetting;
188
+ fold: 'auto' | 'never';
189
+ respectDirection: boolean;
190
+ ordering: 'stable' | 'crossings';
191
+ rootId: string;
192
+ respectManual: boolean;
193
+ growContainers: boolean;
194
+ boundaryPull: number;
195
+ hierarchySweeps: number;
196
+ groupGap: number;
197
+ }
198
+ export interface RoutingSettings {
199
+ clearance: number;
200
+ portGap: number;
201
+ edgeGap: number;
202
+ bendPenalty: number;
203
+ crossingPenalty: number;
204
+ sharedPenalty: number;
205
+ parallelPenalty: number;
206
+ portStability: number;
207
+ fanoutPenalty: number;
208
+ passes: number;
209
+ cornerRadius: number;
210
+ standoff: number;
211
+ }
212
+ export interface DiagramSettings extends LayoutSettings {
213
+ snap: boolean;
214
+ showManual: boolean;
215
+ routing: RoutingSettings;
216
+ }
217
+ export interface Camera {
218
+ x: number;
219
+ y: number;
220
+ k: number;
221
+ }
222
+ export interface Diagram {
223
+ schemaVersion: 2;
224
+ id: string;
225
+ title: string;
226
+ graph: {
227
+ nodes: DiagramNode[];
228
+ edges: DiagramEdge[];
229
+ groups: DiagramGroup[];
230
+ };
231
+ layout: {
232
+ nodes: Record<string, NodeLayout>;
233
+ edges: Record<string, EdgeLayout>;
234
+ labels: Record<string, LabelLayout>;
235
+ containers: Record<string, ContainerLayout>;
236
+ intent: LayoutIntent;
237
+ /** A sequence diagram's frame and the row bands of its `phase` statements. */
238
+ sequence?: SequenceLayout;
239
+ };
240
+ styles: Record<string, NodeStyle>;
241
+ collapsed: string[];
242
+ settings: DiagramSettings;
243
+ camera: Camera;
244
+ /** Editor light or dark mode; independent of the diagram's appearance. */
245
+ theme: Theme;
246
+ /** Diagram theme, overrides and color definitions. Saved with the diagram. */
247
+ appearance: DiagramAppearance;
248
+ }
249
+ export type NodeGeometry = Record<string, NodeLayout>;
250
+ /** The panel a sequence diagram is drawn on, and a row band for each `phase`. */
251
+ export interface SequenceLayout {
252
+ panel: Rect;
253
+ phases: SequencePhase[];
254
+ /** Left edge for phase labels, when a note in the left margin widens the panel past them. */
255
+ phaseX?: number;
256
+ /** Spots of the notes that sit in a side margin, by index in `appearance.notes`. */
257
+ notes?: Array<Rect | null>;
258
+ /** With `notes`: the panel without those margins, for drawings with their notes in the frame. */
259
+ inner?: Rect;
260
+ /**
261
+ * From `was-order`: each message's row and the phase bands in the older message order, and how
262
+ * much further that order runs down the panel.
263
+ */
264
+ before?: {
265
+ rows: Record<string, number>;
266
+ phases: SequencePhase[];
267
+ grow: number;
268
+ };
269
+ }
270
+ export type SequencePhase = {
271
+ id: string;
272
+ label: string;
273
+ y: number;
274
+ h: number;
275
+ };
276
+ /** Any object that can be selected: a shape, a container, or a connection. */
277
+ export type Entity = DiagramNode | DiagramGroup | DiagramEdge;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A standalone SVG of a projected diagram for terminal and agent inspection. It draws with the
3
+ * same appearance, shapes and title wrapping as the canvas and embeds the fonts it uses.
4
+ */
5
+ import { type ResolvedAppearance } from '../model/appearance';
6
+ import type { Diagram, Rect } from '../model/types';
7
+ /** How an object's `href` is written into the file; as written unless the caller says. */
8
+ export interface SvgOptions {
9
+ href?: (href: string) => string;
10
+ /** Writes a link in note or footnote text; null draws the text without a link. */
11
+ textHref?: (href: string) => string | null;
12
+ /** Draw every emphasis state as its own panel. */
13
+ states?: boolean;
14
+ /** Host-owned policies used by the portable runtime. */
15
+ idPrefix?: string;
16
+ fontCss?: string;
17
+ title?: string;
18
+ description?: string;
19
+ styleNonce?: string;
20
+ linkTarget?: '_self' | '_blank';
21
+ metadata?: string;
22
+ maxOutputBytes?: number;
23
+ }
24
+ export declare class SvgLimitError extends Error {
25
+ }
26
+ /**
27
+ * A sequence diagram's panel, a light surface with a border that bounds the exchange, and a row
28
+ * band for each phase with its label in a tab at the left edge. Drawn under everything else.
29
+ */
30
+ export declare function sequenceBackdrop(doc: Diagram, look: ResolvedAppearance): {
31
+ panel: string[];
32
+ phases: string[];
33
+ };
34
+ /** Inset of a phase label from its band's top left corner. */
35
+ export declare const PHASE_TAB = 8;
36
+ /** A thin stripe across the top of a box, inside its rounded corners. */
37
+ export declare function accentPath(r: Rect, radius: number): string;
38
+ export declare function renderSvg(doc: Diagram, opts?: SvgOptions): string;
@@ -0,0 +1,19 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export interface SessionInfo {
3
+ name: string;
4
+ path: string;
5
+ source: string;
6
+ revision: string;
7
+ /** Where the file's relative links start: its git root, or its folder outside a repository. */
8
+ root: string;
9
+ }
10
+ /** The nearest folder at or above `dir` that holds `.git`, or `dir` when there is none. */
11
+ export declare function gitRoot(dir: string): string;
12
+ export declare const revisionOf: (source: string) => string;
13
+ export interface FileSession {
14
+ readonly file: string;
15
+ /** Handle `/api/...` requests. Returns false for anything else. */
16
+ handle(req: IncomingMessage, res: ServerResponse): boolean;
17
+ close(): void;
18
+ }
19
+ export declare function createFileSession(file: string): FileSession;
@@ -0,0 +1,21 @@
1
+ import type { IncomingMessage, ServerResponse } from 'node:http';
2
+ export interface WorkspaceFile {
3
+ /** Path relative to the workspace root, with forward slashes. */
4
+ path: string;
5
+ title: string;
6
+ /** The `subtitle` line, when the file has one near its top. */
7
+ subtitle?: string;
8
+ modified: number;
9
+ }
10
+ export interface WorkspaceInfo {
11
+ name: string;
12
+ root: string;
13
+ files: WorkspaceFile[];
14
+ }
15
+ export interface Workspace {
16
+ readonly root: string;
17
+ /** Handle `/api/...` requests. Returns false for anything else. */
18
+ handle(req: IncomingMessage, res: ServerResponse): boolean;
19
+ close(): void;
20
+ }
21
+ export declare function createWorkspace(root: string): Workspace;