@draftably/editor 0.4.0 → 0.6.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 (82) hide show
  1. package/dist/assets/engine.worker-iJs-dOtM.js +8071 -0
  2. package/dist/element.js +27 -16
  3. package/dist/index.js +12154 -11312
  4. package/dist/types/src/components/scene/EdgeView.d.ts +2 -0
  5. package/dist/types/src/components/scene/Lifelines.d.ts +4 -3
  6. package/dist/types/src/components/session-context.d.ts +9 -2
  7. package/dist/types/src/dsl/compile.d.ts +2 -0
  8. package/dist/types/src/dsl/sequence-layout.d.ts +87 -0
  9. package/dist/types/src/dsl/source-edits.d.ts +2 -0
  10. package/dist/types/src/dsl/syntax.d.ts +8 -2
  11. package/dist/types/src/dsl/translate.d.ts +1 -1
  12. package/dist/types/src/editor/internal.d.ts +9 -2
  13. package/dist/types/src/editor/mount.d.ts +13 -6
  14. package/dist/types/src/engines/explorer-engine.d.ts +63 -0
  15. package/dist/types/src/engines/layout/arrange.d.ts +36 -0
  16. package/dist/types/src/engines/layout/compute.d.ts +7 -0
  17. package/dist/types/src/engines/layout/forces.d.ts +8 -0
  18. package/dist/types/src/engines/layout/grid.d.ts +10 -0
  19. package/dist/types/src/engines/layout/intent.d.ts +14 -0
  20. package/dist/types/src/engines/layout/layered.d.ts +5 -0
  21. package/dist/types/src/engines/layout/objective.d.ts +6 -0
  22. package/dist/types/src/engines/layout/packing.d.ts +7 -0
  23. package/dist/types/src/engines/layout/report.d.ts +7 -0
  24. package/dist/types/src/engines/layout/scene.d.ts +53 -0
  25. package/dist/types/src/engines/layout/seed.d.ts +3 -0
  26. package/dist/types/src/engines/layout/separation.d.ts +17 -0
  27. package/dist/types/src/engines/layout/settings.d.ts +6 -0
  28. package/dist/types/src/engines/layout/topology.d.ts +18 -0
  29. package/dist/types/src/engines/layout/trees.d.ts +8 -0
  30. package/dist/types/src/engines/layout/types.d.ts +133 -0
  31. package/dist/types/src/engines/layout/util.d.ts +19 -0
  32. package/dist/types/src/engines/layout-engine.d.ts +15 -0
  33. package/dist/types/src/engines/routing/compute.d.ts +6 -0
  34. package/dist/types/src/engines/routing/conflicts.d.ts +36 -0
  35. package/dist/types/src/engines/routing/context.d.ts +37 -0
  36. package/dist/types/src/engines/routing/cost.d.ts +13 -0
  37. package/dist/types/src/engines/routing/doglegs.d.ts +16 -0
  38. package/dist/types/src/engines/routing/find.d.ts +6 -0
  39. package/dist/types/src/engines/routing/geometry.d.ts +24 -0
  40. package/dist/types/src/engines/routing/heap.d.ts +20 -0
  41. package/dist/types/src/engines/routing/improve.d.ts +7 -0
  42. package/dist/types/src/engines/routing/nudge.d.ts +7 -0
  43. package/dist/types/src/engines/routing/paths.d.ts +8 -0
  44. package/dist/types/src/engines/routing/planned.d.ts +7 -0
  45. package/dist/types/src/engines/routing/ports.d.ts +10 -0
  46. package/dist/types/src/engines/routing/repair.d.ts +9 -0
  47. package/dist/types/src/engines/routing/score.d.ts +12 -0
  48. package/dist/types/src/engines/routing/search.d.ts +16 -0
  49. package/dist/types/src/engines/routing/settings.d.ts +4 -0
  50. package/dist/types/src/engines/routing/sidepairs.d.ts +20 -0
  51. package/dist/types/src/engines/routing/tidy-ports.d.ts +13 -0
  52. package/dist/types/src/engines/routing/tidy.d.ts +10 -0
  53. package/dist/types/src/engines/routing/tuning.d.ts +9 -0
  54. package/dist/types/src/engines/routing/types.d.ts +157 -0
  55. package/dist/types/src/engines/routing-engine.d.ts +20 -0
  56. package/dist/types/src/engines/sculpt-engine.d.ts +87 -0
  57. package/dist/types/src/lib/engine-tasks.d.ts +4 -4
  58. package/dist/types/src/model/appearance.d.ts +18 -2
  59. package/dist/types/src/model/edits.d.ts +19 -0
  60. package/dist/types/src/model/labels.d.ts +23 -0
  61. package/dist/types/src/model/markers.d.ts +7 -0
  62. package/dist/types/src/model/note.d.ts +11 -2
  63. package/dist/types/src/model/routes.d.ts +5 -3
  64. package/dist/types/src/model/status.d.ts +18 -0
  65. package/dist/types/src/model/types.d.ts +20 -1
  66. package/dist/types/src/runtime/color-scheme.d.ts +15 -0
  67. package/dist/types/src/runtime/host.d.ts +34 -2
  68. package/dist/types/src/runtime/page-shared.d.ts +1 -1
  69. package/dist/types/src/runtime/schemes.d.ts +2 -0
  70. package/dist/types/src/runtime/svg-renderer.d.ts +9 -4
  71. package/dist/types/src/runtime/types.d.ts +7 -0
  72. package/dist/types/src/state/active-session.d.ts +9 -2
  73. package/dist/types/src/state/canvas-commands.d.ts +37 -0
  74. package/dist/types/src/state/session/actions.d.ts +2 -0
  75. package/dist/types/src/state/session/emphasis.d.ts +3 -0
  76. package/dist/types/src/state/session/file-session.d.ts +1 -1
  77. package/dist/types/src/state/session/index.d.ts +14 -2
  78. package/dist/types/src/state/session/layout.d.ts +1 -1
  79. package/dist/types/src/state/session/scene.d.ts +11 -9
  80. package/dist/types/src/state/session/sculpt.d.ts +1 -1
  81. package/package.json +1 -1
  82. package/dist/assets/engine.worker-C6o2x40z.js +0 -7609
@@ -0,0 +1,20 @@
1
+ import { compute } from './routing/compute.ts';
2
+ import { conflicts, parallelConflicts, type Line } from './routing/conflicts.ts';
3
+ import { blocked } from './routing/geometry.ts';
4
+ import { port } from './routing/ports.ts';
5
+ import { settings } from './routing/settings.ts';
6
+ export declare const RouteLab: {
7
+ compute: typeof compute;
8
+ settings: typeof settings;
9
+ defaults: import("./routing/types.ts").RoutingSettings;
10
+ port: typeof port;
11
+ blocked: typeof blocked;
12
+ conflicts: typeof conflicts;
13
+ parallelConflicts: typeof parallelConflicts;
14
+ /** Crossings and shared run length of a set of routes, each counted against the ones before it. */
15
+ metrics: (routes: Line[]) => {
16
+ crossings: number;
17
+ shared: number;
18
+ };
19
+ };
20
+ export type { PriorRoute, Route, RouteEdgeInput, RouteGroupInput, RouteInput, RouteMetrics, RouteNodeInput, RoutingOptions, RoutingReport, RoutingResult, } from './routing/types.ts';
@@ -0,0 +1,87 @@
1
+ import type { Diagram, LayoutSettings, NodeGeometry, Point, Rect } from '../model/types.ts';
2
+ import type { LayoutMetrics, LayoutOptions, LayoutReport, TraceFrame } from './layout-engine.ts';
3
+ export type BrushMode = 'tidy' | 'flow' | 'space' | 'restore' | 'protect';
4
+ export interface BrushSettings {
5
+ radius: number;
6
+ strength: number;
7
+ softness: number;
8
+ step: number;
9
+ mode: BrushMode;
10
+ holdRestored: boolean;
11
+ }
12
+ export interface DabOptions extends Partial<BrushSettings> {
13
+ point?: Point;
14
+ worldRadius?: number;
15
+ reference?: NodeGeometry | null;
16
+ protectedIds?: string[];
17
+ }
18
+ export interface DabResult {
19
+ document: Diagram;
20
+ weights: Record<string, number>;
21
+ locked: string[];
22
+ moved: string[];
23
+ maxDisplacement: number;
24
+ blocked: boolean;
25
+ attenuation?: number;
26
+ mode: BrushMode;
27
+ }
28
+ export interface TimelineFrame {
29
+ nodes: NodeGeometry;
30
+ iteration: number;
31
+ phase: string;
32
+ metrics: LayoutMetrics;
33
+ index: number;
34
+ moved: number;
35
+ travel: number;
36
+ cumulative: number;
37
+ maxMove: number;
38
+ }
39
+ export interface TimelineBookmark {
40
+ index: number;
41
+ title: string;
42
+ }
43
+ export interface Timeline {
44
+ schemaVersion: 1;
45
+ kind: 'diagram-studio-journey';
46
+ baseline: Diagram;
47
+ settings: LayoutSettings;
48
+ execution: Record<string, unknown>;
49
+ report: LayoutReport;
50
+ frames: TimelineFrame[];
51
+ finalDocument: Diagram;
52
+ bookmarks: TimelineBookmark[];
53
+ createdAt: string;
54
+ /** Added by the app: routes in effect when the timeline was recorded. */
55
+ routePrior?: unknown[];
56
+ }
57
+ declare function settings(input?: Partial<BrushSettings>): BrushSettings;
58
+ /** How strongly a brush of radius `r` acts at distance `d`: 1 in the core, eased to 0 at the rim. */
59
+ declare function weight(d: number, r: number, softness?: number): number;
60
+ declare function rectDistance(p: Point, r: Rect): number;
61
+ /** The brush weight of each visible shape it reaches, and the shapes it reaches but may not move. */
62
+ declare function field(doc: Diagram, point: Point, radius: number, softness?: number, protectedIds?: string[]): {
63
+ weights: Record<string, number>;
64
+ locked: string[];
65
+ };
66
+ declare function violationPairs(doc: Diagram, nodes: NodeGeometry): Map<string, number>;
67
+ declare function noWorse(doc: Diagram, before: NodeGeometry, after: NodeGeometry): boolean;
68
+ /** One brush dab at `options.point`: moves the shapes under it a step toward the brush's goal. */
69
+ declare function dab(input: Diagram, options?: DabOptions): DabResult;
70
+ declare function summarizeFrames(frames: TraceFrame[]): TimelineFrame[];
71
+ /** A rebuild recorded as frames, from the given arrangement to the computed finish. */
72
+ declare function journey(input: Diagram, options?: LayoutOptions): Promise<Timeline>;
73
+ declare function lookahead(frames: TimelineFrame[], index: number, pixels?: number, scale?: number): number;
74
+ export declare const SculptLab: {
75
+ defaults: BrushSettings;
76
+ settings: typeof settings;
77
+ weight: typeof weight;
78
+ rectDistance: typeof rectDistance;
79
+ field: typeof field;
80
+ dab: typeof dab;
81
+ journey: typeof journey;
82
+ lookahead: typeof lookahead;
83
+ summarizeFrames: typeof summarizeFrames;
84
+ violationPairs: typeof violationPairs;
85
+ noWorse: typeof noWorse;
86
+ };
87
+ export {};
@@ -1,7 +1,7 @@
1
- import { type CandidateResult, type CandidateSpec, type ComparisonConfig } from '../engines/explorer-engine.js';
2
- import { type LayoutOptions, type LayoutResult } from '../engines/layout-engine.js';
3
- import { type Timeline } from '../engines/sculpt-engine.js';
4
- import { type RouteInput, type RoutingOptions, type RoutingResult } from '../engines/routing-engine.js';
1
+ import { type CandidateResult, type CandidateSpec, type ComparisonConfig } from '../engines/explorer-engine';
2
+ import { type LayoutOptions, type LayoutResult } from '../engines/layout-engine';
3
+ import { type Timeline } from '../engines/sculpt-engine';
4
+ import { type RouteInput, type RoutingOptions, type RoutingResult } from '../engines/routing-engine';
5
5
  import { type Scene } from '../dsl/compile';
6
6
  import { type ViewState } from '../dsl/project';
7
7
  import type { Diagram } from '../model/types';
@@ -9,7 +9,8 @@ import type { Footnote } from './footnote';
9
9
  import type { Note } from './note';
10
10
  import { type FontRole, type TypeProfile } from './fonts';
11
11
  import type { FileConfig } from './link';
12
- export type ThemeId = 'drafting' | 'fieldnotes' | 'signal' | 'ink' | 'blueprint';
12
+ import type { MessageKind } from './markers';
13
+ export type ThemeId = 'drafting' | 'fieldnotes' | 'signal' | 'ink' | 'blueprint' | 'drafting-dark';
13
14
  export declare const THEME_IDS: ThemeId[];
14
15
  export declare const DEFAULT_THEME: ThemeId;
15
16
  /** Shade stops. Lower numbers are lighter and higher numbers darker, in every theme. */
@@ -101,10 +102,18 @@ export interface Heading {
101
102
  /** The connection styles a `legend line` row can explain. */
102
103
  export declare const LEGEND_LINES: readonly ["dashed", "solid"];
103
104
  export type LegendLine = (typeof LEGEND_LINES)[number];
104
- /** One row of the key: a color swatch (`family`), or a short connection (`line`). */
105
+ /**
106
+ * One row of the key: a color swatch (`family`), a short connection (`line`), or the mark of a
107
+ * kind of sequence message (`message`), which the drawing adds for each kind it uses.
108
+ */
105
109
  export interface LegendEntry {
106
110
  family?: string;
107
111
  line?: LegendLine;
112
+ message?: MessageKind;
113
+ /** An activation bar, which a sequence with `activations=on` adds a row for. */
114
+ activation?: true;
115
+ /** Words with no swatch: a sequence's line that its rows show order, not time. */
116
+ caption?: true;
108
117
  /** Shade of the swatch; nodes' default when omitted. */
109
118
  shade?: Shade;
110
119
  label: string;
@@ -154,6 +163,13 @@ interface Preset {
154
163
  hues?: Partial<Record<string, [number, number]>>;
155
164
  }
156
165
  export declare const PRESETS: Record<ThemeId, Preset>;
166
+ /**
167
+ * The appearance to draw on a page of this scheme. The default theme follows the page, with or
168
+ * without a `theme drafting` line and its size and font overrides: dark draws it as
169
+ * `drafting-dark`. Another named theme, a `theme-color` line or a color override on the `theme`
170
+ * line keeps the file's colors on every page.
171
+ */
172
+ export declare function forScheme(appearance: DiagramAppearance, dark: boolean): DiagramAppearance;
157
173
  /** `a` moved toward `b` by `t` (0–1), in sRGB. */
158
174
  export declare function mixColors(a: string, b: string, t: number): string;
159
175
  export declare function contrast(a: string, b: string): number;
@@ -1,4 +1,5 @@
1
1
  import { emptyDiagram } from './document';
2
+ import type { MessageKind } from './markers';
2
3
  import type { ContainerLayout, Diagram, DiagramEdge, DiagramGroup, DiagramNode, EdgeLayout, IntentPlacement, IntentRole, NodeLayout, NodeStyle, Point, PortSide, Rect, Side } from './types';
3
4
  export declare function moveObject(doc: Diagram, id: string, dx: number, dy: number, manual?: boolean): void;
4
5
  /** Bounds of a container's direct children, including shape labels. */
@@ -99,6 +100,24 @@ export declare function setLabelMode(doc: Diagram, id: string, mode: NonNullable
99
100
  export declare function setParent(doc: Diagram, id: string, parentId: string | null): void;
100
101
  export declare function setContainer(doc: Diagram, id: string, patch: Partial<ContainerLayout>): void;
101
102
  export declare function setEdge(doc: Diagram, id: string, patch: Partial<Pick<DiagramEdge, 'directed' | 'dashed' | 'emphasis' | 'head' | 'tail'>>): void;
103
+ /**
104
+ * Give a sequence message a kind, or take it away. The kind draws the line and its ends, so the
105
+ * message keeps no style of its own. A reply to a message that can no longer take one is unpaired.
106
+ */
107
+ export declare function setMessage(doc: Diagram, id: string, kind: MessageKind | undefined): void;
108
+ /**
109
+ * Add an event to a sequence before or after another: a plain message between the same two
110
+ * participants, or an action beside an action. The file gives it its row when it draws again.
111
+ */
112
+ export declare function insertEvent(doc: Diagram, id: string, where: 'before' | 'after'): string | undefined;
113
+ /** Move a sequence event one place up or down among the events. False at either end. */
114
+ export declare function moveEvent(doc: Diagram, id: string, by: -1 | 1): boolean;
115
+ /** Turn a sequence's activation bars on or off. The file's layout line holds the switch. */
116
+ export declare function setActivations(doc: Diagram, on: boolean): void;
117
+ /** The earlier messages a reply can answer: those with a kind that run the other way. */
118
+ export declare function replyTargets(doc: Diagram, id: string): DiagramEdge[];
119
+ /** Say which message a reply answers, or that it names none. */
120
+ export declare function setReplyTo(doc: Diagram, id: string, target: string | undefined): void;
102
121
  export declare function setEdgeLayout(doc: Diagram, id: string, patch: Partial<EdgeLayout>): void;
103
122
  export declare function reverseEdge(doc: Diagram, id: string): void;
104
123
  export declare function useAutomaticPorts(doc: Diagram, edgeIds: string[]): void;
@@ -62,6 +62,12 @@ export interface NodeLabel {
62
62
  export declare function nodeLabel(doc: Diagram, id: string, title: string, r: Rect): NodeLabel;
63
63
  /** Bounds of a shape together with its label. */
64
64
  export declare function visualBounds(doc: Diagram, id: string, title: string, r: Rect): Rect;
65
+ /** Text width a sequence phase's label wraps to, so a long one does not push the lanes right. */
66
+ export declare const PHASE_WRAP = 96;
67
+ /** Inset of a phase label from its band's top left corner. */
68
+ export declare const PHASE_TAB = 8;
69
+ /** A phase label's lines, in the annotation type. */
70
+ export declare const phaseLabelLines: (label: string, r: ResolvedAppearance) => string[];
65
71
  /** Text width a sequence message's label wraps to; the gap between participants follows it. */
66
72
  export declare const MESSAGE_WRAP = 168;
67
73
  /**
@@ -93,6 +99,23 @@ export declare function edgeLabelSize(label: string, r?: ResolvedAppearance, mes
93
99
  w: number;
94
100
  h: number;
95
101
  };
102
+ /**
103
+ * An activation bar: its width, how far a nested bar steps to the right, how far it runs past
104
+ * its first and last rows, and the length of a bar whose call gets no reply.
105
+ */
106
+ export declare const ACTIVATION: {
107
+ w: number;
108
+ step: number;
109
+ over: number;
110
+ stub: number;
111
+ };
112
+ /** Room between a local action's label and its box, on each side. */
113
+ export declare const ACTION_PAD = 5;
114
+ /** The box of a local action: its label and `ACTION_PAD` round it, centred on the lifeline. */
115
+ export declare function actionSize(label: string, r: ResolvedAppearance): {
116
+ w: number;
117
+ h: number;
118
+ };
96
119
  /**
97
120
  * What a self-message draws, measured from where its row meets the lifeline: how far right, how
98
121
  * far above the row and how far below it.
@@ -30,10 +30,17 @@ export declare const markerBox: (kind: Exclude<EndMarker, "none">, tail: boolean
30
30
  };
31
31
  /** The fill a marker takes on this line and surface. */
32
32
  export declare function markerFill(kind: Exclude<EndMarker, 'none'>, ink: string, surface: string): string;
33
+ /**
34
+ * What `message=` accepts on a sequence message, plus `action`, which an `action` line makes.
35
+ * Each says what the author means; none is read from a line's style.
36
+ */
37
+ export declare const MESSAGE_KINDS: readonly ["interaction", "call", "send", "reply", "outcome"];
38
+ export type MessageKind = (typeof MESSAGE_KINDS)[number] | 'action';
33
39
  type Ends = {
34
40
  directed?: boolean;
35
41
  head?: EndMarker;
36
42
  tail?: EndMarker;
43
+ message?: MessageKind;
37
44
  };
38
45
  /** An undirected edge has no marks, whatever else it holds. */
39
46
  export declare const headOf: (e: Ends) => EndMarker;
@@ -46,13 +46,22 @@ export declare function noteBox(look: ResolvedAppearance, note: Note): PlacedNot
46
46
  * Spots in a sequence's side margins, by index in `notes`, for notes on the messages in `rows`.
47
47
  * `left` and `right` are the margins' inner edges and `top` the highest a note goes. A note is
48
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.
49
+ * no note here can cover the drawing. A note on a message in a phase stays inside that phase's
50
+ * band (`bands`, by message), which `marginNoteRoom` makes tall enough for its notes.
50
51
  */
51
52
  export declare function marginNotes(look: ResolvedAppearance, notes: readonly Note[], rows: ReadonlyMap<string, number>, { left, right, top }: {
52
53
  left: number;
53
54
  right: number;
54
55
  top: number;
55
- }): (Rect | null)[];
56
+ }, bands?: ReadonlyMap<string, {
57
+ y: number;
58
+ h: number;
59
+ }>): (Rect | null)[];
60
+ /**
61
+ * The height a phase band needs for the margin notes on its messages (`ids`): the taller of its
62
+ * two sides, each a stack of its notes.
63
+ */
64
+ export declare function marginNoteRoom(look: ResolvedAppearance, notes: readonly Note[], ids: string[]): number;
56
65
  /**
57
66
  * Place every anchored note beside its object or message, clear of shapes, group borders, lines
58
67
  * and earlier notes when a nearby spot allows it. Frame notes, and notes whose object is not drawn,
@@ -1,4 +1,4 @@
1
- import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine.js';
1
+ import { type PriorRoute, type Route, type RoutingResult } from '../engines/routing-engine';
2
2
  import { type ResolvedAppearance } from './appearance';
3
3
  import { type VisibleGraph } from './graph';
4
4
  import type { Diagram, EdgeLayout, Point, Rect, ShapeKind, Side } from './types';
@@ -132,8 +132,10 @@ export declare function routeInput(doc: Diagram, vg: VisibleGraph, all: Map<stri
132
132
  tail?: import("./markers").EndMarker;
133
133
  emphasis: boolean;
134
134
  dashed: boolean;
135
- status?: import("./status.js").Status;
136
- spot?: import("./status.js").Spot;
135
+ message?: import("./markers").MessageKind;
136
+ replyTo?: string;
137
+ status?: import("./status").Status;
138
+ spot?: import("./status").Spot;
137
139
  }[];
138
140
  };
139
141
  /**
@@ -82,3 +82,21 @@ export declare function withState(doc: Diagram, id: string): Diagram;
82
82
  export declare function usedStatuses(doc: Diagram): StatusCount[];
83
83
  /** The color key's rows: a diff draws no family colors, so it lists only its statuses. */
84
84
  export declare const drawnLegend: (doc: Diagram) => LegendEntry[];
85
+ /** What every sequence says under its drawing. */
86
+ export declare const SEQUENCE_CAPTION = "Rows show order, not elapsed time.";
87
+ /**
88
+ * The events that belong with one event of a sequence: a message, the reply that answers it,
89
+ * and the message a reply answers. Only pairs the file states, never a guess from direction.
90
+ */
91
+ export declare function replyPair(doc: Diagram, id: string): string[];
92
+ /**
93
+ * A sequence in words, for a reader who cannot see it: the participants, then each event in
94
+ * order with its kind. An exported SVG carries it as its description unless the host gives one.
95
+ */
96
+ export declare function sequenceDescription(doc: Diagram): string | undefined;
97
+ /**
98
+ * The key a sequence draws for its kinds of message: one row for each mark in use, so a reader
99
+ * never has to guess what a solid head or a box means. Nothing unless a message has a kind. A
100
+ * plain message and a shown result draw the same arrow, so they share a row.
101
+ */
102
+ export declare function messageKey(doc: Diagram): LegendEntry[];
@@ -13,7 +13,7 @@ export type PortSide = Side | 'auto';
13
13
  export type Direction = 'RIGHT' | 'DOWN';
14
14
  export type Theme = 'light' | 'dark';
15
15
  import type { DiagramAppearance, Shade } from './appearance';
16
- import type { EndMarker } from './markers';
16
+ import type { EndMarker, MessageKind } from './markers';
17
17
  import type { Spot, Status } from './status';
18
18
  export type ShapeKind = 'box' | 'pill' | 'circle' | 'diamond' | 'text' | 'icon' | 'image'
19
19
  /** A seam between two cells of a `cells` group. */
@@ -70,6 +70,13 @@ export interface DiagramEdge {
70
70
  tail?: EndMarker;
71
71
  emphasis: boolean;
72
72
  dashed: boolean;
73
+ /**
74
+ * A sequence message's meaning, from `message=`, or `action` for work one participant does
75
+ * (an `action` line; `from` and `to` are that participant). Unset for a plain message.
76
+ */
77
+ message?: MessageKind;
78
+ /** With `message: 'reply'`: the earlier message this one answers, from `answers=`. */
79
+ replyTo?: string;
73
80
  /** How it differs between two versions of the diagram. */
74
81
  status?: Status;
75
82
  /** How the drawn emphasis state treats it; see `withState`. */
@@ -93,6 +100,8 @@ export interface EdgeLayout {
93
100
  toOffset?: number;
94
101
  /** A sequence message: drawn straight between the two lifelines at this height, not routed. */
95
102
  row?: number;
103
+ /** A message between distant lanes: the middle of the gap between lifelines its label sits in. */
104
+ labelX?: number;
96
105
  /**
97
106
  * Set by the compiler for a forward line in a `flow` scope: its route planned from the ranks.
98
107
  * The quick router takes it as it is when it clears every box.
@@ -274,8 +283,18 @@ export interface SequenceLayout {
274
283
  rows: Record<string, number>;
275
284
  phases: SequencePhase[];
276
285
  grow: number;
286
+ activations?: Activation[];
277
287
  };
288
+ /** With `activations=on`: the bars on the lifelines of participants at work on a call. */
289
+ activations?: Activation[];
290
+ /** The `activations=on` switch itself, which the Inspector turns on and off. */
291
+ bars?: true;
278
292
  }
293
+ /** One activation bar: its participant, the call that opened it, and its box. */
294
+ export type Activation = Rect & {
295
+ node: string;
296
+ call: string;
297
+ };
279
298
  export type SequencePhase = {
280
299
  id: string;
281
300
  label: string;
@@ -0,0 +1,15 @@
1
+ /** Watches one host's scheme. `check` reads it again now; `stop` ends the watch. */
2
+ export interface SchemeWatch {
3
+ check(): void;
4
+ stop(): void;
5
+ }
6
+ /**
7
+ * Calls `onChange(dark)` now and whenever the scheme in `host` changes: an element, or a shadow
8
+ * root, whose children inherit the element's scheme. A hidden probe in `host` has a `light-dark()`
9
+ * color, so a scheme change anywhere above it (a class flip on the page, a style) starts a
10
+ * transition there; the media query covers a change of system setting under `light dark`. A
11
+ * transition cannot run while the host has no box (a hidden tab, a closed `<details>`, a detached
12
+ * mount), so a resize observer on the host reads the scheme again when it gets one. Callers also
13
+ * call `check` after each commit.
14
+ */
15
+ export declare function watchColorScheme(host: Element | ShadowRoot, onChange: (dark: boolean) => void): SchemeWatch;
@@ -3,6 +3,7 @@
3
3
  * packages loop over `HOST_EVENTS`, so a new event adds no lines to any of them.
4
4
  * This module has no side effects and no runtime imports.
5
5
  */
6
+ import type { RenderFailure } from './types';
6
7
  import type { UpdateResult, ViewerEvents } from './viewer';
7
8
  export type { Camera, CameraReason, FrameOptions, MoveResult } from './camera';
8
9
  export type { Box, EdgeOut, Geometry, PlacedBox } from './geometry';
@@ -10,8 +11,11 @@ export type { Anchor, DraftSlot } from './anchors';
10
11
  export interface HostEvents {
11
12
  /** After each commit, after the marked children change, and with `[]` before destroy. */
12
13
  anchors: ViewerEvents['anchors'];
13
- /** Each update's result: committed, error or a cancellation. */
14
- update: UpdateResult;
14
+ /**
15
+ * Each update's result, from the first source on: committed, error or a cancellation. The
16
+ * editor's commit has no `value` or `diagnostics` (see `EditorUpdate`).
17
+ */
18
+ update: UpdateResult | EditorUpdate;
15
19
  render: ViewerEvents['render'];
16
20
  diagnostics: ViewerEvents['diagnostics'];
17
21
  camera: ViewerEvents['camera'];
@@ -30,11 +34,39 @@ export interface HostEvents {
30
34
  source: string;
31
35
  };
32
36
  }
37
+ /**
38
+ * `<draft-editor>`'s update. The editor draws in its own session, not as one SVG, so a commit
39
+ * has no `value` and no `diagnostics`: the `diagnostics` event has them. A source that does not
40
+ * parse is an `error` with a `DRAFT_PARSE` diagnostic; the editor keeps the text and shows it.
41
+ */
42
+ export type EditorUpdate = {
43
+ status: 'committed';
44
+ revision: number;
45
+ value?: never;
46
+ diagnostics?: never;
47
+ } | {
48
+ status: 'error';
49
+ revision: number;
50
+ error: RenderFailure;
51
+ } | {
52
+ status: 'destroyed';
53
+ revision: number;
54
+ };
33
55
  export type HostEventName = keyof HostEvents;
34
56
  /** Every event, in one list. Each element dispatches these as bubbling `draft-<name>` events. */
35
57
  export declare const HOST_EVENTS: readonly ["anchors", "update", "render", "diagnostics", "camera", "itemactivate", "link", "contextmenu", "select", "change"];
36
58
  /** Events a host can cancel with `preventDefault()`. */
59
+ export type CancelableEventName = 'link' | 'contextmenu';
37
60
  export declare const CANCELABLE_EVENTS: readonly HostEventName[];
61
+ /**
62
+ * What a framework event prop receives: the event's `detail`, and on a cancelable event a
63
+ * `preventDefault()` that cancels the DOM event, so `onLink={e => e.preventDefault()}` works.
64
+ */
65
+ export type HostEventDetail<K extends HostEventName> = K extends CancelableEventName ? HostEvents[K] & {
66
+ preventDefault(): void;
67
+ } : HostEvents[K];
68
+ /** The value a framework event prop receives for a `draft-<name>` event. */
69
+ export declare function hostDetail(event: Event): unknown;
38
70
  export type DraftEventMap = {
39
71
  [K in HostEventName as `draft-${K}`]: CustomEvent<HostEvents[K]>;
40
72
  };
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { RenderOptions, RenderResult } from './types';
6
6
  /** Names the worker and the usual fix, so "worker failed" is not a dead end. */
7
- export declare const WORKER_HELP = "The worker is the module next to @draftably/runtime's viewer. With Vite, add optimizeDeps: { exclude: ['@draftably/runtime', '@draftably/editor'] } to vite.config.";
7
+ export declare const WORKER_HELP = "The worker is the module next to @draftably/runtime's viewer. With Vite 5\u20137, add optimizeDeps: { exclude: ['@draftably/runtime', '@draftably/editor'] } to vite.config.";
8
8
  /**
9
9
  * Render in the page's worker pool. Jobs queue on the main thread; an aborted job leaves the
10
10
  * queue before a worker sees it. A job that runs past `timeoutMs` stops its worker only.
@@ -0,0 +1,2 @@
1
+ /** Both drawings as one, or null when they differ in more than color. */
2
+ export declare function mergeSchemes(light: string, dark: string): string | null;
@@ -3,6 +3,7 @@
3
3
  * same appearance, shapes and title wrapping as the canvas and embeds the fonts it uses.
4
4
  */
5
5
  import { type ResolvedAppearance } from '../model/appearance';
6
+ import { PHASE_TAB } from '../model/labels';
6
7
  import { computeRoutes } from '../model/routes';
7
8
  import type { Diagram, Rect } from '../model/types';
8
9
  /** How an object's `href` is written into the file; as written unless the caller says. */
@@ -26,21 +27,25 @@ export interface SvgOptions {
26
27
  rects: Map<string, Rect>;
27
28
  routes: Route[];
28
29
  }) => void;
30
+ /**
31
+ * The routes `onDrawn` gave for this document, so drawing it again in other colors routes
32
+ * nothing again (not for compare or states).
33
+ */
34
+ routes?: Route[];
29
35
  }
30
36
  export declare class SvgLimitError extends Error {
31
37
  }
32
- type Route = ReturnType<typeof computeRoutes>['routes'][number];
38
+ export type Route = ReturnType<typeof computeRoutes>['routes'][number];
33
39
  /**
34
40
  * A sequence diagram's panel, a light surface with a border that bounds the exchange, and a row
35
41
  * band for each phase with its label in a tab at the left edge. Drawn under everything else.
36
42
  */
37
43
  export declare function sequenceBackdrop(doc: Diagram, look: ResolvedAppearance): {
38
44
  panel: string[];
45
+ bars: string[];
39
46
  phases: string[];
40
47
  };
41
- /** Inset of a phase label from its band's top left corner. */
42
- export declare const PHASE_TAB = 8;
48
+ export { PHASE_TAB };
43
49
  /** A thin stripe across the top of a box, inside its rounded corners. */
44
50
  export declare function accentPath(r: Rect, radius: number): string;
45
51
  export declare function renderSvg(doc: Diagram, opts?: SvgOptions): string;
46
- export {};
@@ -49,6 +49,13 @@ export interface CommonRenderOptions {
49
49
  sourceId?: string;
50
50
  signal?: AbortSignal;
51
51
  limits?: Partial<RenderLimits>;
52
+ /**
53
+ * `light` (default) draws the file's own colors. `dark` draws a file without a `theme` line in
54
+ * the default theme's dark variant. `auto` writes both as `light-dark()` colors, so the page's
55
+ * `color-scheme` picks one; the viewer and `<draft-diagram>` use it. A file's own theme line
56
+ * always wins.
57
+ */
58
+ colorScheme?: 'light' | 'dark' | 'auto';
52
59
  }
53
60
  export type RenderOptions = CommonRenderOptions & ({
54
61
  target?: 'image';
@@ -208,6 +208,8 @@ export declare const setActiveSession: (session: DiagramSession) => {
208
208
  tail?: import("../model/markers").EndMarker;
209
209
  emphasis: boolean;
210
210
  dashed: boolean;
211
+ message?: import("../model/markers").MessageKind;
212
+ replyTo?: string;
211
213
  status?: import("../model/status").Status;
212
214
  spot?: import("../model/status").Spot;
213
215
  }[];
@@ -216,7 +218,7 @@ export declare const setActiveSession: (session: DiagramSession) => {
216
218
  routingReport: () => import("../engines/routing-engine").RoutingReport;
217
219
  blockedRouteIds: () => string[];
218
220
  sceneBounds: () => import("../model/types").Rect;
219
- viewerFrame: () => {
221
+ viewerFrame: import("solid-js").Accessor<{
220
222
  x: number;
221
223
  y: number;
222
224
  w: number;
@@ -260,7 +262,7 @@ export declare const setActiveSession: (session: DiagramSession) => {
260
262
  h: number;
261
263
  };
262
264
  notes: import("../model/note").PlacedNote[];
263
- };
265
+ }>;
264
266
  } & {
265
267
  states: () => import("../model/appearance").EmphasisState[];
266
268
  activeState: () => string | null;
@@ -269,6 +271,9 @@ export declare const setActiveSession: (session: DiagramSession) => {
269
271
  showState: (id: string | null) => void;
270
272
  stepState: (by: 1 | -1) => boolean;
271
273
  drawnDoc: () => import("../model/types").Diagram;
274
+ dark: import("solid-js").Accessor<boolean>;
275
+ setDark: import("solid-js").Setter<boolean>;
276
+ drawnAppearance: () => import("../model/appearance").DiagramAppearance;
272
277
  } & {
273
278
  tool: import("solid-js").Accessor<import("./session/editor").Tool>;
274
279
  setToolSignal: import("solid-js").Setter<import("./session/editor").Tool>;
@@ -395,6 +400,8 @@ export declare const setActiveSession: (session: DiagramSession) => {
395
400
  fitSelectedContainer: () => void;
396
401
  toggleCollapse: (id?: string | undefined) => void;
397
402
  reverseSelectedEdge: () => void;
403
+ insertEvent: (where: "before" | "after") => string | undefined;
404
+ moveEvent: (by: -1 | 1) => void;
398
405
  resetSelectedBends: () => void;
399
406
  setLayoutIntent: (role: import("../model/types").IntentRole, id: string | null, placement?: import("../model/types").IntentPlacement) => void;
400
407
  markSelectedAs: (role: import("../model/types").IntentRole) => void;
@@ -17,6 +17,15 @@ export interface Command {
17
17
  declare function undoCommand(): void;
18
18
  declare function redoCommand(): void;
19
19
  export declare const hasSelection: () => boolean;
20
+ /** A sequence draws from its file, so its messages are added and moved in a file only. */
21
+ declare function sequenceFileOnly(): "Open the diagram as a file to add or move its messages." | null;
22
+ declare let nameInPanel: (() => boolean) | null;
23
+ /**
24
+ * Set by the app shell, which owns the Inspector: put the caret in its Label field and return
25
+ * true, or return false when the Inspector is not showing. The embedded editor has no
26
+ * Inspector and sets nothing, so it names a new message in place.
27
+ */
28
+ export declare const setLabelNamer: (fn: typeof nameInPanel) => (() => boolean) | null;
20
29
  export declare const canvasCommands: {
21
30
  undo: {
22
31
  hint: string;
@@ -49,6 +58,34 @@ export declare const canvasCommands: {
49
58
  icon: string;
50
59
  run: () => string | undefined;
51
60
  };
61
+ 'insert-event-after': {
62
+ label: string;
63
+ keys: string;
64
+ hint: string;
65
+ run: () => void;
66
+ blocked: typeof sequenceFileOnly;
67
+ };
68
+ 'insert-event-before': {
69
+ label: string;
70
+ keys: string;
71
+ hint: string;
72
+ run: () => void;
73
+ blocked: typeof sequenceFileOnly;
74
+ };
75
+ 'move-event-up': {
76
+ label: string;
77
+ keys: string;
78
+ hint: string;
79
+ run: () => void;
80
+ blocked: typeof sequenceFileOnly;
81
+ };
82
+ 'move-event-down': {
83
+ label: string;
84
+ keys: string;
85
+ hint: string;
86
+ run: () => void;
87
+ blocked: typeof sequenceFileOnly;
88
+ };
52
89
  duplicate: {
53
90
  hint: string;
54
91
  enabled: () => boolean;
@@ -54,6 +54,8 @@ export declare function createActions(s: EditorPart & DocumentPart & ScenePart &
54
54
  fitSelectedContainer: () => void;
55
55
  toggleCollapse: (id?: string | undefined) => void;
56
56
  reverseSelectedEdge: () => void;
57
+ insertEvent: (where: "before" | "after") => string | undefined;
58
+ moveEvent: (by: -1 | 1) => void;
57
59
  resetSelectedBends: () => void;
58
60
  setLayoutIntent: (role: IntentRole, id: string | null, placement?: IntentPlacement) => void;
59
61
  markSelectedAs: (role: IntentRole) => void;
@@ -7,5 +7,8 @@ export declare function createEmphasis(s: DocumentPart): {
7
7
  showState: (id: string | null) => void;
8
8
  stepState: (by: 1 | -1) => boolean;
9
9
  drawnDoc: () => import("../../model/types").Diagram;
10
+ dark: import("solid-js").Accessor<boolean>;
11
+ setDark: import("solid-js").Setter<boolean>;
12
+ drawnAppearance: () => import("../../model/appearance").DiagramAppearance;
10
13
  };
11
14
  export type EmphasisPart = ReturnType<typeof createEmphasis>;
@@ -1,6 +1,6 @@
1
1
  import { type Diagnostic, type Scene } from '../../dsl/compile';
2
2
  import { type ShapeChange, UnstorableLayout } from '../../dsl/layout-edits';
3
- import type { RoutingResult } from '../../engines/routing-engine.js';
3
+ import type { RoutingResult } from '../../engines/routing-engine';
4
4
  import type { Diagram, LayoutSettings, RoutingSettings } from '../../model/types';
5
5
  import type { DocumentPart } from './document';
6
6
  import type { CanvasTextPart } from './canvas-text';