@draftably/editor 0.2.0 → 0.4.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 (44) hide show
  1. package/README.md +5 -3
  2. package/dist/assets/engine.worker-C6o2x40z.js +7609 -0
  3. package/dist/element.js +171 -17
  4. package/dist/index.js +9837 -8468
  5. package/dist/types/src/cli/raster-fonts.d.ts +3 -0
  6. package/dist/types/src/components/canvas/Canvas.d.ts +4 -0
  7. package/dist/types/src/components/scene/NodeView.d.ts +7 -0
  8. package/dist/types/src/components/scene/parts.d.ts +7 -11
  9. package/dist/types/src/components/session-context.d.ts +4 -1
  10. package/dist/types/src/dsl/cells.d.ts +1 -0
  11. package/dist/types/src/dsl/compile.d.ts +15 -1
  12. package/dist/types/src/dsl/corridors.d.ts +38 -0
  13. package/dist/types/src/dsl/legend-notes.d.ts +14 -0
  14. package/dist/types/src/dsl/syntax.d.ts +3 -1
  15. package/dist/types/src/editor/css.d.ts +3 -0
  16. package/dist/types/src/editor/element.d.ts +8 -6
  17. package/dist/types/src/editor/internal.d.ts +483 -0
  18. package/dist/types/src/editor/mount.d.ts +70 -5
  19. package/dist/types/src/graph-api/core.d.ts +125 -0
  20. package/dist/types/src/model/appearance.d.ts +19 -0
  21. package/dist/types/src/model/colors.d.ts +10 -2
  22. package/dist/types/src/model/labels.d.ts +22 -6
  23. package/dist/types/src/model/types.d.ts +9 -0
  24. package/dist/types/src/runtime/anchors.d.ts +46 -0
  25. package/dist/types/src/runtime/camera.d.ts +41 -0
  26. package/dist/types/src/runtime/element-base.d.ts +40 -0
  27. package/dist/types/src/runtime/geometry.d.ts +72 -0
  28. package/dist/types/src/runtime/host.d.ts +46 -0
  29. package/dist/types/src/runtime/page-shared.d.ts +24 -0
  30. package/dist/types/src/runtime/policy.d.ts +7 -0
  31. package/dist/types/src/runtime/render.d.ts +10 -0
  32. package/dist/types/src/runtime/svg-renderer.d.ts +8 -0
  33. package/dist/types/src/runtime/types.d.ts +115 -0
  34. package/dist/types/src/runtime/version.d.ts +2 -0
  35. package/dist/types/src/runtime/viewer.d.ts +123 -0
  36. package/dist/types/src/state/active-session.d.ts +7 -1
  37. package/dist/types/src/state/dom-root.d.ts +8 -0
  38. package/dist/types/src/state/session/document.d.ts +3 -1
  39. package/dist/types/src/state/session/editor.d.ts +3 -2
  40. package/dist/types/src/state/session/index.d.ts +5 -1
  41. package/package.json +1 -1
  42. package/dist/assets/engine.worker-DwN9io_m.js +0 -6856
  43. package/dist/types/src/cli/png.d.ts +0 -23
  44. package/dist/types/src/model/embed.d.ts +0 -17
@@ -0,0 +1,483 @@
1
+ /** The session behind a mounted editor, for this repository's tests and proofs only. */
2
+ import type { DiagramSession } from '../state/session';
3
+ export declare const sessions: WeakMap<object, {
4
+ dispose: () => void;
5
+ } & {
6
+ selectedText: import("solid-js").Accessor<string | null>;
7
+ setSelectedText: import("solid-js").Setter<string | null>;
8
+ } & {
9
+ options: import("../state/session").SessionOptions;
10
+ doc: import("../model/types").Diagram;
11
+ setDoc: import("solid-js/store").SetStoreFunction<import("../model/types").Diagram>;
12
+ saveStatus: import("solid-js").Accessor<"saved" | "saving" | "preview" | "failed">;
13
+ undoStack: import("solid-js").Accessor<import("../state/session/document").HistoryEntry[]>;
14
+ redoStack: import("solid-js").Accessor<import("../state/session/document").HistoryEntry[]>;
15
+ revision: import("solid-js").Accessor<number>;
16
+ snapshotDoc: () => import("../model/types").Diagram;
17
+ snapshot: () => string;
18
+ selection: import("solid-js").Accessor<ReadonlySet<string>>;
19
+ selectedIds: () => string[];
20
+ isSelected: (id: string) => boolean;
21
+ singleSelection: () => string | undefined;
22
+ setSelection: (ids: Iterable<string>) => void;
23
+ selectItems: (ids: string[], { add, toggle }?: {
24
+ add?: boolean | undefined;
25
+ toggle?: boolean | undefined;
26
+ }) => void;
27
+ clearSelection: () => void;
28
+ selectText: (id: string) => void;
29
+ onBeforeEdit: (handler: () => void) => void;
30
+ prepareForEdit: () => void;
31
+ onSourceIdMap: (handler: (mapId: (id: string) => string) => void) => void;
32
+ mapSourceIds: (mapId: (id: string) => string) => void;
33
+ setCommitHandler: (handler: ((before: string, label: string, kind: import("../state/session/document").EditKind) => boolean) | null) => ((before: string, label: string, kind: import("../state/session/document").EditKind) => boolean) | null;
34
+ editsGoToFile: () => boolean;
35
+ commit: (before: string, label?: string, kind?: import("../state/session/document").EditKind) => boolean;
36
+ pushUndo: (entry: import("../state/session/document").HistoryEntry) => void;
37
+ annotateLastUndo: (holds: import("../state/session/document").HistoryEntry["holds"]) => void;
38
+ transact: (label: string, fn: (draft: import("../model/types").Diagram) => void, kind?: import("../state/session/document").EditKind) => boolean;
39
+ mutate: (fn: (draft: import("../model/types").Diagram) => void) => void;
40
+ restoreDocument: (next: import("../model/types").Diagram, { keepCamera }?: {
41
+ keepCamera?: boolean | undefined;
42
+ }) => void;
43
+ onHistoryStep: (handler: (entry: import("../state/session/document").HistoryEntry, direction: "undo" | "redo") => void) => void;
44
+ setHistoryHandler: (handler: import("../state/session/document").HistoryHandler | null) => import("../state/session/document").HistoryHandler | null;
45
+ undo: () => void;
46
+ redo: () => void;
47
+ canUndo: () => boolean;
48
+ canRedo: () => boolean;
49
+ setCamera: (camera: import("../model/types").Camera, reason?: import("./mount").CameraReason) => void;
50
+ onCamera: (listener: (reason: import("./mount").CameraReason) => void) => () => boolean;
51
+ disableBrowserStorage: () => boolean;
52
+ setPersistenceBlocked: (blocked: boolean) => void;
53
+ persist: () => void;
54
+ persistNow: () => void;
55
+ restoreSavedDocument: () => {
56
+ restored: boolean;
57
+ notice?: string;
58
+ };
59
+ watchOtherTabs: () => () => void;
60
+ } & {
61
+ openSource: (source: string, onChange?: (source: string) => void) => Promise<void>;
62
+ receiveSource: (source: string) => Promise<void>;
63
+ liveSource: import("solid-js").Accessor<string>;
64
+ sourceDraft: import("solid-js").Accessor<string | null>;
65
+ fileSession: import("solid-js").Accessor<import("../state/session/file-session").FileSessionInfo | null>;
66
+ fileMode: () => boolean;
67
+ exampleMode: () => boolean;
68
+ scratchName: () => "Draft" | "Example";
69
+ exampleEdited: () => boolean;
70
+ leaveAgreed: () => boolean;
71
+ agreeToLeave: () => undefined;
72
+ fileStatus: import("solid-js").Accessor<import("../state/session/file-session").FileStatus>;
73
+ sourceError: import("solid-js").Accessor<{
74
+ message: string;
75
+ line: number;
76
+ } | null>;
77
+ fileScene: import("solid-js").Accessor<import("../dsl/compile").Scene | null>;
78
+ fileDiagnostics: () => import("../dsl/compile").Diagnostic[];
79
+ conflictProposal: import("solid-js").Accessor<string | null>;
80
+ movedByChange: import("solid-js").Accessor<string[]>;
81
+ fileCompiling: import("solid-js").Accessor<boolean>;
82
+ exampleRestored: () => boolean;
83
+ currentSource: () => string;
84
+ setRouteSink: (sink: {
85
+ adopt: (routes: {
86
+ fingerprint: string;
87
+ result: import("../engines/routing-engine").RoutingResult;
88
+ }) => void;
89
+ quick: (on: boolean) => void;
90
+ awaiting: (on: boolean) => void;
91
+ }) => {
92
+ adopt: (routes: {
93
+ fingerprint: string;
94
+ result: import("../engines/routing-engine").RoutingResult;
95
+ }) => void;
96
+ quick: (on: boolean) => void;
97
+ awaiting: (on: boolean) => void;
98
+ };
99
+ showSource: (source: string, selection?: string[] | (() => string[]), mapId?: (id: string) => string) => Promise<import("../dsl/compile").Scene | null>;
100
+ keepDiskVersion: () => void;
101
+ saveProposalOverDisk: () => void;
102
+ retrySave: () => undefined;
103
+ typeSource: (next: string, burst: number) => Promise<null | undefined>;
104
+ commitSource: (next: string, label: string, message: string) => Promise<boolean>;
105
+ fileBlocked: () => string | null;
106
+ sourceWithRecipe: (scope: string, settings: import("../model/types").LayoutSettings, direction?: "right" | "down") => {
107
+ source: string;
108
+ removed: number;
109
+ };
110
+ sourceWithShape: (scope: string, change: import("../dsl/layout-edits").ShapeChange) => {
111
+ source: string;
112
+ removed: number;
113
+ };
114
+ changedLines: (source: string) => string[];
115
+ changedLine: (source: string) => string;
116
+ sourceWithRouting: (routing: import("../model/types").RoutingSettings, base?: string) => string;
117
+ projectSource: (source: string) => Promise<import("../model/types").Diagram>;
118
+ reflowSelectedGroup: (id: string) => void;
119
+ openFileSession: (file: string) => Promise<boolean>;
120
+ prefetchFile: (file: string) => Promise<void>;
121
+ settleSave: () => Promise<void>;
122
+ closeFileSession: () => void;
123
+ openExampleSession: (id: string, title: string, source: string, key?: string) => Promise<void>;
124
+ resetExample: () => void;
125
+ markExampleSaved: () => void;
126
+ fileStatusText: () => string;
127
+ } & {
128
+ sculptGeometry: import("solid-js").Accessor<import("../model/types").NodeGeometry | null>;
129
+ setSculptGeometry: import("solid-js").Setter<import("../model/types").NodeGeometry | null>;
130
+ animationGeometry: import("solid-js").Accessor<import("../model/types").NodeGeometry | null>;
131
+ setAnimationGeometry: import("solid-js").Setter<import("../model/types").NodeGeometry | null>;
132
+ setQuickRouting: import("solid-js").Setter<boolean>;
133
+ routePrior: import("solid-js").Accessor<import("../engines/routing-engine").PriorRoute[] | null>;
134
+ setRoutePrior: import("solid-js").Setter<import("../engines/routing-engine").PriorRoute[] | null>;
135
+ setAdoptedRoutes: import("solid-js").Setter<{
136
+ fingerprint: string;
137
+ result: import("../engines/routing-engine").RoutingResult;
138
+ } | null>;
139
+ geometry: (id: string) => import("../model/types").NodeLayout;
140
+ visibleScene: import("solid-js").Accessor<import("../model/graph").VisibleGraph>;
141
+ nodeIds: import("solid-js").Accessor<string[]>;
142
+ groupIds: import("solid-js").Accessor<string[]>;
143
+ edgeIds: import("solid-js").Accessor<string[]>;
144
+ sceneRects: import("solid-js").Accessor<Map<string, import("../model/types").Rect>>;
145
+ routing: import("solid-js").Accessor<import("../model/routes").SceneRoutes>;
146
+ routesById: import("solid-js").Accessor<Map<string, import("../model/routes").DrawnRoute>>;
147
+ routeIds: import("solid-js").Accessor<string[]>;
148
+ routesPending: () => boolean;
149
+ resetRoutes: () => void;
150
+ routeInputFor: () => {
151
+ nodes: ({
152
+ shape: import("../model/types").ShapeKind;
153
+ x: number;
154
+ y: number;
155
+ w: number;
156
+ h: number;
157
+ id: string;
158
+ title: string;
159
+ was?: string;
160
+ wasShape?: import("../model/types").ShapeKind;
161
+ wasCount?: number | string;
162
+ href?: string;
163
+ count?: number | string;
164
+ span?: number | "var";
165
+ parentId?: string;
166
+ image?: string;
167
+ lifeline?: number;
168
+ } | {
169
+ parentId?: string | undefined;
170
+ frame?: boolean | undefined;
171
+ shape: import("../model/types").ShapeKind;
172
+ x: number;
173
+ y: number;
174
+ w: number;
175
+ h: number;
176
+ id: string;
177
+ title: string;
178
+ })[];
179
+ groups: {
180
+ titleHeight?: number | undefined;
181
+ collapsed: boolean;
182
+ titleWidth: number;
183
+ x: number;
184
+ y: number;
185
+ w: number;
186
+ h: number;
187
+ id: string;
188
+ title: string;
189
+ was?: string;
190
+ href?: string;
191
+ parentId?: string;
192
+ frame?: "soft" | "none";
193
+ titleLines?: number;
194
+ hull?: import("../model/types").Rect[];
195
+ }[];
196
+ edges: {
197
+ from: string;
198
+ to: string;
199
+ cfg: import("../model/types").EdgeLayout;
200
+ a: string;
201
+ b: string;
202
+ id: string;
203
+ label: string;
204
+ was?: string;
205
+ directed: boolean;
206
+ head?: import("../model/markers").EndMarker;
207
+ tail?: import("../model/markers").EndMarker;
208
+ emphasis: boolean;
209
+ dashed: boolean;
210
+ status?: import("../model/status").Status;
211
+ spot?: import("../model/status").Spot;
212
+ }[];
213
+ };
214
+ routes: () => import("../model/routes").DrawnRoute[];
215
+ routingReport: () => import("../engines/routing-engine").RoutingReport;
216
+ blockedRouteIds: () => string[];
217
+ sceneBounds: () => import("../model/types").Rect;
218
+ viewerFrame: () => {
219
+ x: number;
220
+ y: number;
221
+ w: number;
222
+ h: number;
223
+ natural: number;
224
+ head: {
225
+ w: number;
226
+ h: number;
227
+ };
228
+ key: {
229
+ w: number;
230
+ h: number;
231
+ row: number;
232
+ items: {
233
+ x: number;
234
+ y: number;
235
+ legend?: import("../model/appearance").LegendEntry;
236
+ status?: import("../model/status").StatusCount;
237
+ label: string;
238
+ }[];
239
+ };
240
+ heading: {
241
+ x: number;
242
+ y: number;
243
+ wrap: number;
244
+ };
245
+ legend: {
246
+ x: number;
247
+ y: number;
248
+ };
249
+ foot: {
250
+ x: number;
251
+ y: number;
252
+ type: import("../model/fonts").TypeProfile;
253
+ gutter: number;
254
+ items: {
255
+ note: import("../model/footnote").Footnote;
256
+ lines: import("../model/rich-text").Run[][];
257
+ y: number;
258
+ }[];
259
+ h: number;
260
+ };
261
+ notes: import("../model/note").PlacedNote[];
262
+ };
263
+ } & {
264
+ states: () => import("../model/appearance").EmphasisState[];
265
+ activeState: () => string | null;
266
+ gridOpen: import("solid-js").Accessor<boolean>;
267
+ setGridOpen: import("solid-js").Setter<boolean>;
268
+ showState: (id: string | null) => void;
269
+ stepState: (by: 1 | -1) => boolean;
270
+ drawnDoc: () => import("../model/types").Diagram;
271
+ } & {
272
+ tool: import("solid-js").Accessor<import("../state/session/editor").Tool>;
273
+ setToolSignal: import("solid-js").Setter<import("../state/session/editor").Tool>;
274
+ connectFrom: import("solid-js").Accessor<{
275
+ id: string;
276
+ side: import("../model/types").PortSide;
277
+ } | null>;
278
+ setConnectFrom: import("solid-js").Setter<{
279
+ id: string;
280
+ side: import("../model/types").PortSide;
281
+ } | null>;
282
+ pointer: import("solid-js").Accessor<import("../model/types").Point | null>;
283
+ setPointer: import("solid-js").Setter<import("../model/types").Point | null>;
284
+ drag: import("solid-js").Accessor<import("../state/session/editor").DragFeedback | null>;
285
+ setDrag: import("solid-js").Setter<import("../state/session/editor").DragFeedback | null>;
286
+ inlineEditId: import("solid-js").Accessor<string | null>;
287
+ setInlineEditId: import("solid-js").Setter<string | null>;
288
+ spaceHeld: import("solid-js").Accessor<boolean>;
289
+ setSpaceHeld: import("solid-js").Setter<boolean>;
290
+ measuredStageSize: import("solid-js").Accessor<{
291
+ width: number;
292
+ height: number;
293
+ }>;
294
+ setMeasuredStageSize: import("solid-js").Setter<{
295
+ width: number;
296
+ height: number;
297
+ }>;
298
+ reducedMotion: import("solid-js").Accessor<boolean>;
299
+ setReducedMotion: import("solid-js").Setter<boolean>;
300
+ registerCanvas: (el: SVGSVGElement) => SVGSVGElement;
301
+ canvasElement: () => SVGSVGElement | undefined;
302
+ focusCanvas: () => void | undefined;
303
+ stageSize: () => {
304
+ width: number;
305
+ height: number;
306
+ };
307
+ screenToWorld: (clientX: number, clientY: number) => import("../model/types").Point;
308
+ canvasCenter: () => import("../model/types").Point;
309
+ zoomAt: (factor: number, clientX?: number, clientY?: number) => void;
310
+ panBy: (dx: number, dy: number) => void;
311
+ setStageSize: (size: {
312
+ width: number;
313
+ height: number;
314
+ }) => void;
315
+ fitView: () => void;
316
+ diagramClipped: () => boolean;
317
+ fitRects: (rects: import("../model/types").Rect[], reservedBottom?: number) => void;
318
+ revealObject: (id: string) => void;
319
+ centerSelection: () => void;
320
+ } & {
321
+ layoutBusy: import("solid-js").Accessor<boolean>;
322
+ layoutReport: import("solid-js").Accessor<import("../engines/layout-engine").LayoutReport | null>;
323
+ setLayoutReport: import("solid-js").Setter<import("../engines/layout-engine").LayoutReport | null>;
324
+ layoutPreview: import("solid-js").Accessor<import("../state/session/layout").LayoutPreview | null>;
325
+ labScope: import("solid-js").Accessor<import("../state/session/layout").LabScope>;
326
+ setLabScope: import("solid-js").Setter<import("../state/session/layout").LabScope>;
327
+ labEngine: import("solid-js").Accessor<import("../model/types").LayoutAlgorithmId | null>;
328
+ setLabEngine: import("solid-js").Setter<import("../model/types").LayoutAlgorithmId | null>;
329
+ layoutCheckpoint: import("solid-js").Accessor<import("../model/types").Diagram | null>;
330
+ currentScope: () => {
331
+ scope: import("../engines/layout-engine").LayoutScope;
332
+ containerId?: string;
333
+ };
334
+ layoutTarget: () => "the whole diagram" | "the selection and its neighbours" | "this group" | "the selection";
335
+ setFixedIdsProvider: (provider: () => string[]) => () => string[];
336
+ fixedIds: () => string[];
337
+ cancelLayout: () => void;
338
+ runLayout: (options?: import("../state/session/layout").RunLayoutOptions) => Promise<import("../state/session/layout").LayoutOutcome>;
339
+ runLabLayout: (mode?: "pass" | "rebuild", preview?: boolean, settings?: import("../engines/layout-engine").LayoutOptions) => Promise<import("../state/session/layout").LayoutOutcome>;
340
+ previewSettings: (patch: Partial<Pick<import("../engines/layout-engine").LayoutOptions, "direction" | "aspect">>) => Promise<void>;
341
+ arrangeScope: () => string | null;
342
+ movesBlocked: () => string | null;
343
+ rebuildBlocked: () => string | null;
344
+ routesBlocked: () => string | null;
345
+ previewShape: (change: import("../dsl/layout-edits").ShapeChange) => Promise<import("../state/session/layout").LayoutOutcome>;
346
+ previewRouting: (routing: import("../model/types").RoutingSettings) => Promise<import("../state/session/layout").LayoutOutcome>;
347
+ acceptPreview: () => void;
348
+ discardPreview: () => void;
349
+ holdPreviewBefore: (held: boolean) => void;
350
+ updateLayoutSettings: (patch: Partial<import("../model/types").Diagram["settings"]>) => void;
351
+ captureCheckpoint: () => void;
352
+ setDocumentOpener: (open: (doc: import("../model/types").Diagram, label: string) => void) => (doc: import("../model/types").Diagram, label: string) => void;
353
+ restoreCheckpoint: () => void;
354
+ } & {
355
+ inlineDraft: import("solid-js").Accessor<string>;
356
+ setInlineDraft: import("solid-js").Setter<string>;
357
+ setToolInterceptor: (fn: (tool: import("../state/session/editor").Tool) => boolean) => (tool: import("../state/session/editor").Tool) => boolean;
358
+ setTool: (next: import("../state/session/editor").Tool) => void;
359
+ startInlineEdit: (id: string) => void;
360
+ finishInlineEdit: (save?: boolean) => void;
361
+ addNode: (partial?: import("../model/edits").NewNode, at?: import("../model/types").Point, edit?: boolean) => string;
362
+ addEdge: (partial: import("../model/edits").NewEdge) => string;
363
+ completeConnection: (targetId: string, side?: import("../model/types").Side | "auto") => void;
364
+ quickExtend: ({ side, sibling, at, from, }?: {
365
+ side?: import("../model/types").Side | null;
366
+ sibling?: boolean;
367
+ at?: import("../model/types").Point | null;
368
+ from?: string | null;
369
+ }) => string | undefined;
370
+ insertStep: (edgeId: string, at?: import("../model/types").Point | null) => string | undefined;
371
+ buildFromList: (lines: string[], options?: {
372
+ mode?: import("../model/edits").BuildMode;
373
+ title?: string;
374
+ source?: string | null;
375
+ parentId?: string | null;
376
+ }) => string[];
377
+ wrapSelection: () => string;
378
+ drawContainer: (rect: {
379
+ x: number;
380
+ y: number;
381
+ w: number;
382
+ h: number;
383
+ }) => void;
384
+ deleteSelection: (deep?: boolean) => void;
385
+ ungroupSelection: () => void;
386
+ togglePin: () => void;
387
+ clearManualMarkers: () => void;
388
+ alignSelection: (kind: import("../model/edits").AlignKind) => void;
389
+ nudgeSelection: (dx: number, dy: number) => boolean;
390
+ setColor: (color: import("../model/types").Diagram["styles"][string]["color"]) => void;
391
+ chooseTheme: (theme: import("../model/appearance").ThemeId) => void;
392
+ setAppearanceOverrides: (patch: Partial<import("../model/appearance").AppearanceOverrides>, label?: string) => void;
393
+ setShade: (shade: import("../model/appearance").Shade | undefined) => void;
394
+ fitSelectedContainer: () => void;
395
+ toggleCollapse: (id?: string | undefined) => void;
396
+ reverseSelectedEdge: () => void;
397
+ resetSelectedBends: () => void;
398
+ setLayoutIntent: (role: import("../model/types").IntentRole, id: string | null, placement?: import("../model/types").IntentPlacement) => void;
399
+ markSelectedAs: (role: import("../model/types").IntentRole) => void;
400
+ addWaypointAt: (edgeId: string, point?: import("../model/types").Point) => void;
401
+ removeWaypoint: (edgeId: string, index: number) => void;
402
+ reroute: ({ auto }?: {
403
+ auto?: boolean | undefined;
404
+ }) => void;
405
+ toggleTheme: () => void;
406
+ copySelection: () => import("../model/edits").ClipboardFragment | null;
407
+ hasClipboard: () => boolean;
408
+ pasteFragment: (part?: import("../model/edits").ClipboardFragment | null) => void;
409
+ duplicateSelection: () => void;
410
+ openDocument: (input: unknown, { fit, label }?: {
411
+ fit?: boolean | undefined;
412
+ label?: string | undefined;
413
+ }) => import("../model/types").Diagram;
414
+ newDocument: () => void;
415
+ openSample: (id: string) => import("../model/types").Diagram | undefined;
416
+ } & {
417
+ setRouting: (patch: Partial<import("../model/types").RoutingSettings>, label: string) => void;
418
+ applyRoutePreset: (preset: import("../state/session/routing").RoutePreset) => void;
419
+ activeRoutePreset: () => "Balanced" | "Fewer crossings" | null;
420
+ } & {
421
+ importTimeline: (input: unknown) => void;
422
+ timeline: import("solid-js").Accessor<import("../state/session/sculpt").TimelineState | null>;
423
+ playing: import("solid-js").Accessor<boolean>;
424
+ brushActive: import("solid-js").Accessor<boolean>;
425
+ brushSettings: import("solid-js").Accessor<import("../engines/sculpt-engine").BrushSettings>;
426
+ brushPoint: import("solid-js").Accessor<import("../model/types").Point | null>;
427
+ brushHover: import("solid-js").Accessor<import("../engines/sculpt-engine").DabResult | null>;
428
+ stroking: import("solid-js").Accessor<boolean>;
429
+ restoreKey: import("solid-js").Accessor<boolean>;
430
+ referenceLabel: import("solid-js").Accessor<string>;
431
+ timelineOpen: () => boolean;
432
+ sculptInteracting: () => boolean;
433
+ heldIds: () => string[];
434
+ restoreArchive: () => void;
435
+ openTimeline: (options?: Record<string, unknown>) => Promise<void>;
436
+ closeTimeline: () => void;
437
+ scrub: (index: number, { peek }?: {
438
+ peek?: boolean | undefined;
439
+ }) => number | undefined;
440
+ endPeek: () => void;
441
+ setGhost: (ghost: import("../state/session/sculpt").GhostMode) => void;
442
+ bookmarkStep: () => void;
443
+ keepStep: ({ brush }?: {
444
+ brush?: boolean | undefined;
445
+ }) => boolean;
446
+ stopPlayback: () => void;
447
+ togglePlayback: () => void;
448
+ fitTimelinePath: (reservedBottom: number) => void;
449
+ reopenTimeline: () => void;
450
+ saveTimelineFile: () => void;
451
+ activateBrush: (options?: Partial<import("../engines/sculpt-engine").BrushSettings>) => void;
452
+ deactivateBrush: () => void;
453
+ toggleBrush: () => void;
454
+ updateBrushSettings: (patch: Partial<import("../engines/sculpt-engine").BrushSettings>) => void;
455
+ useCurrentAsReference: () => void;
456
+ brushPointerDown: (e: PointerEvent, target: Element) => boolean;
457
+ brushPointerMove: (e: PointerEvent) => boolean;
458
+ brushPointerUp: (e?: PointerEvent) => boolean;
459
+ brushPointerLeave: () => void;
460
+ cancelStroke: () => boolean;
461
+ brushDab: (point?: import("../model/types").Point) => import("../engines/sculpt-engine").DabResult;
462
+ clearHolds: () => void;
463
+ sculptUndo: () => boolean;
464
+ sculptKey: (e: KeyboardEvent) => boolean;
465
+ sculptBlur: () => void;
466
+ sculptBeforeUnload: () => void;
467
+ hasArchivedTimeline: import("solid-js").Accessor<boolean>;
468
+ setComparisonCloser: (fn: () => void) => () => void;
469
+ } & {
470
+ isDragging: () => boolean;
471
+ cancelGesture: () => void;
472
+ resetModifiers: () => void;
473
+ onWheel: (e: WheelEvent) => void;
474
+ onPointerDown: (e: PointerEvent) => void;
475
+ onPointerMove: (e: PointerEvent) => void;
476
+ onPointerUp: (e: PointerEvent | null) => void;
477
+ onDoubleClick: (e: MouseEvent) => void;
478
+ selectForContextMenu: (e: MouseEvent) => void;
479
+ dragKind: () => string | undefined;
480
+ } & {
481
+ describeLink: (href: string) => string;
482
+ }>;
483
+ export declare const sessionOf: (editor: object) => DiagramSession;
@@ -1,18 +1,79 @@
1
- import { type DiagramSession, type SessionOptions } from '../state/session';
1
+ import { type SessionOptions } from '../state/session';
2
+ import { type Camera, type CameraReason, type FrameOptions, type MoveResult } from '../runtime/camera';
3
+ import { type Geometry } from '../runtime/geometry';
4
+ import { type Anchor, type DraftSlot } from '../runtime/anchors';
5
+ import type { Diagnostic } from '../runtime/types';
2
6
  import '../styles/app.css';
3
- export interface MountOptions extends SessionOptions {
7
+ /** The options a host sets on `<draft-editor>`: every mount option but the text and `onChange`. */
8
+ export type EditorOptions = Pick<SessionOptions, 'storageKey' | 'openLink' | 'confirm' | 'onInteract'> & {
9
+ /** `auto` (default) hides slot bodies and shows titles again below a zoom of 0.4. */
10
+ detail?: 'auto' | 'full';
11
+ };
12
+ export interface MountOptions extends EditorOptions {
4
13
  /** The `.draft` text to edit. */
5
14
  source: string;
6
15
  /** Receives the new text after every kept edit, undo and redo. */
7
16
  onChange?: (source: string) => void;
8
17
  }
18
+ /** What `on` reports. `camera` comes at most once per animation frame. */
19
+ export interface EditorEvents {
20
+ /** After each drawing, after `anchor()`, and with `[]` before `destroy` detaches the targets. */
21
+ anchors: {
22
+ anchors: readonly Anchor[];
23
+ };
24
+ /** Slot warnings: an unknown slot, or content larger than its node. */
25
+ diagnostics: {
26
+ revision: number;
27
+ diagnostics: readonly Diagnostic[];
28
+ stale: boolean;
29
+ };
30
+ camera: {
31
+ camera: Camera;
32
+ reason: CameraReason;
33
+ };
34
+ /** The selection changed, by the user or through `select()`. */
35
+ select: {
36
+ ids: readonly string[];
37
+ reason: 'user' | 'api';
38
+ };
39
+ /** A right-click; `id` is null on the background. The editor shows no menu of its own. */
40
+ contextmenu: {
41
+ id: string | null;
42
+ kind?: 'node' | 'group' | 'edge';
43
+ clientX: number;
44
+ clientY: number;
45
+ preventDefault(): void;
46
+ };
47
+ }
48
+ /** An editor update's outcome. The editor draws in its own session, so it has no SVG value. */
49
+ export type EditorUpdateResult = {
50
+ status: 'committed' | 'error' | 'destroyed';
51
+ revision: number;
52
+ };
53
+ /** The editor's handle: the viewer's camera, plus editing. */
9
54
  export interface MountedEditor {
10
- session: DiagramSession;
55
+ /** Resolves once the first text is drawn. */
56
+ readonly ready: Promise<EditorUpdateResult>;
11
57
  /** The text as the editor holds it now. */
12
58
  source(): string;
13
59
  /** Show text the host changed. Resolves once it is drawn. */
14
- update(source: string): Promise<void>;
15
- /** Remove the editor and stop its session. */
60
+ update(source: string): Promise<EditorUpdateResult>;
61
+ /** Where each item is drawn, in world units: the viewer's shapes. The same object for one revision. */
62
+ geometry(): Geometry | null;
63
+ /** Select these items (unknown IDs are dropped); `[]` clears the selection. */
64
+ select(ids: readonly string[]): void;
65
+ selection(): readonly string[];
66
+ /** Plain-DOM hosts only: keep a target per slot; `<draft-editor>` sets this from its children. */
67
+ anchor(slots: readonly DraftSlot[]): void;
68
+ getCamera(): Camera;
69
+ /** Zoom is clamped to `ZOOM_MIN`–`ZOOM_MAX`, as in the viewer. */
70
+ setCamera(camera: Camera): void;
71
+ /** Frame these items, or the whole drawing without ids. At most actual size by default. */
72
+ fit(ids?: readonly string[], options?: FrameOptions): MoveResult;
73
+ /** The least move that shows the item; zooms out only if it does not fit. */
74
+ reveal(id: string, options?: FrameOptions): MoveResult;
75
+ on<K extends keyof EditorEvents>(type: K, listener: (event: EditorEvents[K]) => void): () => void;
76
+ /** Remove the editor and stop its session. Safe to call twice. */
16
77
  destroy(): void;
17
78
  }
18
79
  /**
@@ -21,3 +82,7 @@ export interface MountedEditor {
21
82
  * host a size; the canvas fills it.
22
83
  */
23
84
  export declare function mountEditor(host: HTMLElement, options: MountOptions): MountedEditor;
85
+ export type { Camera, CameraReason, FrameOptions, MoveResult } from '../runtime/camera';
86
+ export type { Box, EdgeOut, Geometry, PlacedBox } from '../runtime/geometry';
87
+ export type { Anchor, DraftSlot } from '../runtime/anchors';
88
+ export { ZOOM_MAX, ZOOM_MIN } from '../runtime/camera';