@draftably/editor 0.3.0 → 0.5.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 (43) hide show
  1. package/README.md +5 -3
  2. package/dist/assets/engine.worker-BDrPGHQt.js +7634 -0
  3. package/dist/element.js +182 -17
  4. package/dist/index.js +8827 -7969
  5. package/dist/types/src/components/canvas/Canvas.d.ts +4 -0
  6. package/dist/types/src/components/scene/NodeView.d.ts +7 -0
  7. package/dist/types/src/components/scene/parts.d.ts +7 -11
  8. package/dist/types/src/components/session-context.d.ts +7 -1
  9. package/dist/types/src/dsl/cells.d.ts +1 -0
  10. package/dist/types/src/dsl/compile.d.ts +2 -1
  11. package/dist/types/src/dsl/legend-notes.d.ts +14 -0
  12. package/dist/types/src/dsl/syntax.d.ts +3 -1
  13. package/dist/types/src/dsl/translate.d.ts +1 -1
  14. package/dist/types/src/editor/css.d.ts +3 -0
  15. package/dist/types/src/editor/element.d.ts +8 -6
  16. package/dist/types/src/editor/internal.d.ts +486 -0
  17. package/dist/types/src/editor/mount.d.ts +77 -5
  18. package/dist/types/src/graph-api/core.d.ts +125 -0
  19. package/dist/types/src/model/appearance.d.ts +27 -1
  20. package/dist/types/src/model/colors.d.ts +10 -2
  21. package/dist/types/src/model/labels.d.ts +22 -6
  22. package/dist/types/src/runtime/anchors.d.ts +46 -0
  23. package/dist/types/src/runtime/camera.d.ts +41 -0
  24. package/dist/types/src/runtime/color-scheme.d.ts +15 -0
  25. package/dist/types/src/runtime/element-base.d.ts +40 -0
  26. package/dist/types/src/runtime/geometry.d.ts +72 -0
  27. package/dist/types/src/runtime/host.d.ts +78 -0
  28. package/dist/types/src/runtime/page-shared.d.ts +24 -0
  29. package/dist/types/src/runtime/policy.d.ts +7 -0
  30. package/dist/types/src/runtime/render.d.ts +10 -0
  31. package/dist/types/src/runtime/schemes.d.ts +2 -0
  32. package/dist/types/src/runtime/svg-renderer.d.ts +12 -0
  33. package/dist/types/src/runtime/types.d.ts +122 -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 +10 -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/emphasis.d.ts +3 -0
  41. package/dist/types/src/state/session/index.d.ts +13 -1
  42. package/package.json +1 -1
  43. package/dist/assets/engine.worker-BY9GKt7x.js +0 -7505
@@ -0,0 +1,486 @@
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
+ dark: import("solid-js").Accessor<boolean>;
272
+ setDark: import("solid-js").Setter<boolean>;
273
+ drawnAppearance: () => import("../model/appearance").DiagramAppearance;
274
+ } & {
275
+ tool: import("solid-js").Accessor<import("../state/session/editor").Tool>;
276
+ setToolSignal: import("solid-js").Setter<import("../state/session/editor").Tool>;
277
+ connectFrom: import("solid-js").Accessor<{
278
+ id: string;
279
+ side: import("../model/types").PortSide;
280
+ } | null>;
281
+ setConnectFrom: import("solid-js").Setter<{
282
+ id: string;
283
+ side: import("../model/types").PortSide;
284
+ } | null>;
285
+ pointer: import("solid-js").Accessor<import("../model/types").Point | null>;
286
+ setPointer: import("solid-js").Setter<import("../model/types").Point | null>;
287
+ drag: import("solid-js").Accessor<import("../state/session/editor").DragFeedback | null>;
288
+ setDrag: import("solid-js").Setter<import("../state/session/editor").DragFeedback | null>;
289
+ inlineEditId: import("solid-js").Accessor<string | null>;
290
+ setInlineEditId: import("solid-js").Setter<string | null>;
291
+ spaceHeld: import("solid-js").Accessor<boolean>;
292
+ setSpaceHeld: import("solid-js").Setter<boolean>;
293
+ measuredStageSize: import("solid-js").Accessor<{
294
+ width: number;
295
+ height: number;
296
+ }>;
297
+ setMeasuredStageSize: import("solid-js").Setter<{
298
+ width: number;
299
+ height: number;
300
+ }>;
301
+ reducedMotion: import("solid-js").Accessor<boolean>;
302
+ setReducedMotion: import("solid-js").Setter<boolean>;
303
+ registerCanvas: (el: SVGSVGElement) => SVGSVGElement;
304
+ canvasElement: () => SVGSVGElement | undefined;
305
+ focusCanvas: () => void | undefined;
306
+ stageSize: () => {
307
+ width: number;
308
+ height: number;
309
+ };
310
+ screenToWorld: (clientX: number, clientY: number) => import("../model/types").Point;
311
+ canvasCenter: () => import("../model/types").Point;
312
+ zoomAt: (factor: number, clientX?: number, clientY?: number) => void;
313
+ panBy: (dx: number, dy: number) => void;
314
+ setStageSize: (size: {
315
+ width: number;
316
+ height: number;
317
+ }) => void;
318
+ fitView: () => void;
319
+ diagramClipped: () => boolean;
320
+ fitRects: (rects: import("../model/types").Rect[], reservedBottom?: number) => void;
321
+ revealObject: (id: string) => void;
322
+ centerSelection: () => void;
323
+ } & {
324
+ layoutBusy: import("solid-js").Accessor<boolean>;
325
+ layoutReport: import("solid-js").Accessor<import("../engines/layout-engine").LayoutReport | null>;
326
+ setLayoutReport: import("solid-js").Setter<import("../engines/layout-engine").LayoutReport | null>;
327
+ layoutPreview: import("solid-js").Accessor<import("../state/session/layout").LayoutPreview | null>;
328
+ labScope: import("solid-js").Accessor<import("../state/session/layout").LabScope>;
329
+ setLabScope: import("solid-js").Setter<import("../state/session/layout").LabScope>;
330
+ labEngine: import("solid-js").Accessor<import("../model/types").LayoutAlgorithmId | null>;
331
+ setLabEngine: import("solid-js").Setter<import("../model/types").LayoutAlgorithmId | null>;
332
+ layoutCheckpoint: import("solid-js").Accessor<import("../model/types").Diagram | null>;
333
+ currentScope: () => {
334
+ scope: import("../engines/layout-engine").LayoutScope;
335
+ containerId?: string;
336
+ };
337
+ layoutTarget: () => "the whole diagram" | "the selection and its neighbours" | "this group" | "the selection";
338
+ setFixedIdsProvider: (provider: () => string[]) => () => string[];
339
+ fixedIds: () => string[];
340
+ cancelLayout: () => void;
341
+ runLayout: (options?: import("../state/session/layout").RunLayoutOptions) => Promise<import("../state/session/layout").LayoutOutcome>;
342
+ runLabLayout: (mode?: "pass" | "rebuild", preview?: boolean, settings?: import("../engines/layout-engine").LayoutOptions) => Promise<import("../state/session/layout").LayoutOutcome>;
343
+ previewSettings: (patch: Partial<Pick<import("../engines/layout-engine").LayoutOptions, "direction" | "aspect">>) => Promise<void>;
344
+ arrangeScope: () => string | null;
345
+ movesBlocked: () => string | null;
346
+ rebuildBlocked: () => string | null;
347
+ routesBlocked: () => string | null;
348
+ previewShape: (change: import("../dsl/layout-edits").ShapeChange) => Promise<import("../state/session/layout").LayoutOutcome>;
349
+ previewRouting: (routing: import("../model/types").RoutingSettings) => Promise<import("../state/session/layout").LayoutOutcome>;
350
+ acceptPreview: () => void;
351
+ discardPreview: () => void;
352
+ holdPreviewBefore: (held: boolean) => void;
353
+ updateLayoutSettings: (patch: Partial<import("../model/types").Diagram["settings"]>) => void;
354
+ captureCheckpoint: () => void;
355
+ setDocumentOpener: (open: (doc: import("../model/types").Diagram, label: string) => void) => (doc: import("../model/types").Diagram, label: string) => void;
356
+ restoreCheckpoint: () => void;
357
+ } & {
358
+ inlineDraft: import("solid-js").Accessor<string>;
359
+ setInlineDraft: import("solid-js").Setter<string>;
360
+ setToolInterceptor: (fn: (tool: import("../state/session/editor").Tool) => boolean) => (tool: import("../state/session/editor").Tool) => boolean;
361
+ setTool: (next: import("../state/session/editor").Tool) => void;
362
+ startInlineEdit: (id: string) => void;
363
+ finishInlineEdit: (save?: boolean) => void;
364
+ addNode: (partial?: import("../model/edits").NewNode, at?: import("../model/types").Point, edit?: boolean) => string;
365
+ addEdge: (partial: import("../model/edits").NewEdge) => string;
366
+ completeConnection: (targetId: string, side?: import("../model/types").Side | "auto") => void;
367
+ quickExtend: ({ side, sibling, at, from, }?: {
368
+ side?: import("../model/types").Side | null;
369
+ sibling?: boolean;
370
+ at?: import("../model/types").Point | null;
371
+ from?: string | null;
372
+ }) => string | undefined;
373
+ insertStep: (edgeId: string, at?: import("../model/types").Point | null) => string | undefined;
374
+ buildFromList: (lines: string[], options?: {
375
+ mode?: import("../model/edits").BuildMode;
376
+ title?: string;
377
+ source?: string | null;
378
+ parentId?: string | null;
379
+ }) => string[];
380
+ wrapSelection: () => string;
381
+ drawContainer: (rect: {
382
+ x: number;
383
+ y: number;
384
+ w: number;
385
+ h: number;
386
+ }) => void;
387
+ deleteSelection: (deep?: boolean) => void;
388
+ ungroupSelection: () => void;
389
+ togglePin: () => void;
390
+ clearManualMarkers: () => void;
391
+ alignSelection: (kind: import("../model/edits").AlignKind) => void;
392
+ nudgeSelection: (dx: number, dy: number) => boolean;
393
+ setColor: (color: import("../model/types").Diagram["styles"][string]["color"]) => void;
394
+ chooseTheme: (theme: import("../model/appearance").ThemeId) => void;
395
+ setAppearanceOverrides: (patch: Partial<import("../model/appearance").AppearanceOverrides>, label?: string) => void;
396
+ setShade: (shade: import("../model/appearance").Shade | undefined) => void;
397
+ fitSelectedContainer: () => void;
398
+ toggleCollapse: (id?: string | undefined) => void;
399
+ reverseSelectedEdge: () => void;
400
+ resetSelectedBends: () => void;
401
+ setLayoutIntent: (role: import("../model/types").IntentRole, id: string | null, placement?: import("../model/types").IntentPlacement) => void;
402
+ markSelectedAs: (role: import("../model/types").IntentRole) => void;
403
+ addWaypointAt: (edgeId: string, point?: import("../model/types").Point) => void;
404
+ removeWaypoint: (edgeId: string, index: number) => void;
405
+ reroute: ({ auto }?: {
406
+ auto?: boolean | undefined;
407
+ }) => void;
408
+ toggleTheme: () => void;
409
+ copySelection: () => import("../model/edits").ClipboardFragment | null;
410
+ hasClipboard: () => boolean;
411
+ pasteFragment: (part?: import("../model/edits").ClipboardFragment | null) => void;
412
+ duplicateSelection: () => void;
413
+ openDocument: (input: unknown, { fit, label }?: {
414
+ fit?: boolean | undefined;
415
+ label?: string | undefined;
416
+ }) => import("../model/types").Diagram;
417
+ newDocument: () => void;
418
+ openSample: (id: string) => import("../model/types").Diagram | undefined;
419
+ } & {
420
+ setRouting: (patch: Partial<import("../model/types").RoutingSettings>, label: string) => void;
421
+ applyRoutePreset: (preset: import("../state/session/routing").RoutePreset) => void;
422
+ activeRoutePreset: () => "Balanced" | "Fewer crossings" | null;
423
+ } & {
424
+ importTimeline: (input: unknown) => void;
425
+ timeline: import("solid-js").Accessor<import("../state/session/sculpt").TimelineState | null>;
426
+ playing: import("solid-js").Accessor<boolean>;
427
+ brushActive: import("solid-js").Accessor<boolean>;
428
+ brushSettings: import("solid-js").Accessor<import("../engines/sculpt-engine").BrushSettings>;
429
+ brushPoint: import("solid-js").Accessor<import("../model/types").Point | null>;
430
+ brushHover: import("solid-js").Accessor<import("../engines/sculpt-engine").DabResult | null>;
431
+ stroking: import("solid-js").Accessor<boolean>;
432
+ restoreKey: import("solid-js").Accessor<boolean>;
433
+ referenceLabel: import("solid-js").Accessor<string>;
434
+ timelineOpen: () => boolean;
435
+ sculptInteracting: () => boolean;
436
+ heldIds: () => string[];
437
+ restoreArchive: () => void;
438
+ openTimeline: (options?: Record<string, unknown>) => Promise<void>;
439
+ closeTimeline: () => void;
440
+ scrub: (index: number, { peek }?: {
441
+ peek?: boolean | undefined;
442
+ }) => number | undefined;
443
+ endPeek: () => void;
444
+ setGhost: (ghost: import("../state/session/sculpt").GhostMode) => void;
445
+ bookmarkStep: () => void;
446
+ keepStep: ({ brush }?: {
447
+ brush?: boolean | undefined;
448
+ }) => boolean;
449
+ stopPlayback: () => void;
450
+ togglePlayback: () => void;
451
+ fitTimelinePath: (reservedBottom: number) => void;
452
+ reopenTimeline: () => void;
453
+ saveTimelineFile: () => void;
454
+ activateBrush: (options?: Partial<import("../engines/sculpt-engine").BrushSettings>) => void;
455
+ deactivateBrush: () => void;
456
+ toggleBrush: () => void;
457
+ updateBrushSettings: (patch: Partial<import("../engines/sculpt-engine").BrushSettings>) => void;
458
+ useCurrentAsReference: () => void;
459
+ brushPointerDown: (e: PointerEvent, target: Element) => boolean;
460
+ brushPointerMove: (e: PointerEvent) => boolean;
461
+ brushPointerUp: (e?: PointerEvent) => boolean;
462
+ brushPointerLeave: () => void;
463
+ cancelStroke: () => boolean;
464
+ brushDab: (point?: import("../model/types").Point) => import("../engines/sculpt-engine").DabResult;
465
+ clearHolds: () => void;
466
+ sculptUndo: () => boolean;
467
+ sculptKey: (e: KeyboardEvent) => boolean;
468
+ sculptBlur: () => void;
469
+ sculptBeforeUnload: () => void;
470
+ hasArchivedTimeline: import("solid-js").Accessor<boolean>;
471
+ setComparisonCloser: (fn: () => void) => () => void;
472
+ } & {
473
+ isDragging: () => boolean;
474
+ cancelGesture: () => void;
475
+ resetModifiers: () => void;
476
+ onWheel: (e: WheelEvent) => void;
477
+ onPointerDown: (e: PointerEvent) => void;
478
+ onPointerMove: (e: PointerEvent) => void;
479
+ onPointerUp: (e: PointerEvent | null) => void;
480
+ onDoubleClick: (e: MouseEvent) => void;
481
+ selectForContextMenu: (e: MouseEvent) => void;
482
+ dragKind: () => string | undefined;
483
+ } & {
484
+ describeLink: (href: string) => string;
485
+ }>;
486
+ export declare const sessionOf: (editor: object) => DiagramSession;
@@ -1,18 +1,86 @@
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';
6
+ import type { EditorUpdate } from '../runtime/host';
2
7
  import '../styles/app.css';
3
- export interface MountOptions extends SessionOptions {
8
+ /** The options a host sets on `<draft-editor>`: every mount option but the text and `onChange`. */
9
+ export type EditorOptions = Pick<SessionOptions, 'storageKey' | 'openLink' | 'confirm' | 'onInteract'> & {
10
+ /** `auto` (default) hides slot bodies and shows titles again below a zoom of 0.4. */
11
+ detail?: 'auto' | 'full';
12
+ };
13
+ export interface MountOptions extends EditorOptions {
4
14
  /** The `.draft` text to edit. */
5
15
  source: string;
6
16
  /** Receives the new text after every kept edit, undo and redo. */
7
17
  onChange?: (source: string) => void;
8
18
  }
19
+ /** What `on` reports. `camera` comes at most once per animation frame. */
20
+ export interface EditorEvents {
21
+ /** After each drawing, after `anchor()`, and with `[]` before `destroy` detaches the targets. */
22
+ anchors: {
23
+ anchors: readonly Anchor[];
24
+ };
25
+ /** A source that does not parse (`DRAFT_PARSE`), then slot warnings: an unknown slot, or content larger than its node. */
26
+ diagnostics: {
27
+ revision: number;
28
+ diagnostics: readonly Diagnostic[];
29
+ stale: boolean;
30
+ };
31
+ /** Each update's result, from the first text on. */
32
+ update: EditorUpdateResult;
33
+ /** A link mark was pressed. `preventDefault()` stops the editor opening it. */
34
+ link: {
35
+ itemId: string;
36
+ href: string;
37
+ target: '_blank';
38
+ preventDefault(): void;
39
+ };
40
+ camera: {
41
+ camera: Camera;
42
+ reason: CameraReason;
43
+ };
44
+ /** The selection changed, by the user or through `select()`. */
45
+ select: {
46
+ ids: readonly string[];
47
+ reason: 'user' | 'api';
48
+ };
49
+ /** A right-click; `id` is null on the background. The editor shows no menu of its own. */
50
+ contextmenu: {
51
+ id: string | null;
52
+ kind?: 'node' | 'group' | 'edge';
53
+ clientX: number;
54
+ clientY: number;
55
+ preventDefault(): void;
56
+ };
57
+ }
58
+ /** An editor update's outcome: `EditorUpdate` in `@draftably/runtime/host`. */
59
+ export type EditorUpdateResult = EditorUpdate;
60
+ /** The editor's handle: the viewer's camera, plus editing. */
9
61
  export interface MountedEditor {
10
- session: DiagramSession;
62
+ /** Resolves once the first text is drawn. */
63
+ readonly ready: Promise<EditorUpdateResult>;
11
64
  /** The text as the editor holds it now. */
12
65
  source(): string;
13
66
  /** Show text the host changed. Resolves once it is drawn. */
14
- update(source: string): Promise<void>;
15
- /** Remove the editor and stop its session. */
67
+ update(source: string): Promise<EditorUpdateResult>;
68
+ /** Where each item is drawn, in world units: the viewer's shapes. The same object for one revision. */
69
+ geometry(): Geometry | null;
70
+ /** Select these items (unknown IDs are dropped); `[]` clears the selection. */
71
+ select(ids: readonly string[]): void;
72
+ selection(): readonly string[];
73
+ /** Plain-DOM hosts only: keep a target per slot; `<draft-editor>` sets this from its children. */
74
+ anchor(slots: readonly DraftSlot[]): void;
75
+ getCamera(): Camera;
76
+ /** Zoom is clamped to `ZOOM_MIN`–`ZOOM_MAX`, as in the viewer. */
77
+ setCamera(camera: Camera): void;
78
+ /** Frame these items, or the whole drawing without ids. At most actual size by default. */
79
+ fit(ids?: readonly string[], options?: FrameOptions): MoveResult;
80
+ /** The least move that shows the item; zooms out only if it does not fit. */
81
+ reveal(id: string, options?: FrameOptions): MoveResult;
82
+ on<K extends keyof EditorEvents>(type: K, listener: (event: EditorEvents[K]) => void): () => void;
83
+ /** Remove the editor and stop its session. Safe to call twice. */
16
84
  destroy(): void;
17
85
  }
18
86
  /**
@@ -21,3 +89,7 @@ export interface MountedEditor {
21
89
  * host a size; the canvas fills it.
22
90
  */
23
91
  export declare function mountEditor(host: HTMLElement, options: MountOptions): MountedEditor;
92
+ export type { Camera, CameraReason, FrameOptions, MoveResult } from '../runtime/camera';
93
+ export type { Box, EdgeOut, Geometry, PlacedBox } from '../runtime/geometry';
94
+ export type { Anchor, DraftSlot } from '../runtime/anchors';
95
+ export { ZOOM_MAX, ZOOM_MIN } from '../runtime/camera';