@draftably/editor 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/dist/LICENSE +21 -0
- package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
- package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
- package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
- package/dist/chunks/arc-rJj0TtXf.js +83 -0
- package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
- package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
- package/dist/chunks/browser-iNhbPsGc.js +40 -0
- package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
- package/dist/chunks/channel-qMvPU6eH.js +5 -0
- package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
- package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
- package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
- package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
- package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
- package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
- package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
- package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
- package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
- package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
- package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
- package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
- package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
- package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
- package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
- package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
- package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
- package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
- package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
- package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
- package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
- package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
- package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
- package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
- package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
- package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
- package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
- package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
- package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
- package/dist/chunks/graph-CKJmgLki.js +1541 -0
- package/dist/chunks/import-core-C-I1wGfw.js +145 -0
- package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
- package/dist/chunks/init-DjUOC4st.js +16 -0
- package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
- package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
- package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
- package/dist/chunks/katex-BsrBVQKd.js +11314 -0
- package/dist/chunks/linear-4t7D_ros.js +259 -0
- package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
- package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
- package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
- package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
- package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
- package/dist/chunks/ordinal-DfAQgscy.js +61 -0
- package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
- package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
- package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
- package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
- package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
- package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
- package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
- package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
- package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
- package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
- package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
- package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
- package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
- package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
- package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
- package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
- package/dist/element.js +36 -0
- package/dist/index.js +4 -0
- package/dist/types/src/cli/links.d.ts +4 -0
- package/dist/types/src/cli/pdf.d.ts +29 -0
- package/dist/types/src/cli/png.d.ts +23 -0
- package/dist/types/src/cli/svg.d.ts +4 -0
- package/dist/types/src/components/Icon.d.ts +14 -0
- package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
- package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
- package/dist/types/src/components/canvas/Frame.d.ts +22 -0
- package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
- package/dist/types/src/components/canvas/Notes.d.ts +5 -0
- package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
- package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
- package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
- package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
- package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
- package/dist/types/src/components/controls.d.ts +88 -0
- package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
- package/dist/types/src/components/scene/GroupView.d.ts +22 -0
- package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
- package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
- package/dist/types/src/components/scene/NodeView.d.ts +18 -0
- package/dist/types/src/components/scene/parts.d.ts +50 -0
- package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
- package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
- package/dist/types/src/components/session-context.d.ts +486 -0
- package/dist/types/src/dsl/cells.d.ts +91 -0
- package/dist/types/src/dsl/channels.d.ts +53 -0
- package/dist/types/src/dsl/compile.d.ts +162 -0
- package/dist/types/src/dsl/frame.d.ts +38 -0
- package/dist/types/src/dsl/lanes.d.ts +23 -0
- package/dist/types/src/dsl/layout-edits.d.ts +58 -0
- package/dist/types/src/dsl/legend-notes.d.ts +3 -0
- package/dist/types/src/dsl/project.d.ts +39 -0
- package/dist/types/src/dsl/source-edits.d.ts +37 -0
- package/dist/types/src/dsl/syntax.d.ts +317 -0
- package/dist/types/src/dsl/translate.d.ts +69 -0
- package/dist/types/src/editor/Editor.d.ts +6 -0
- package/dist/types/src/editor/element.d.ts +15 -0
- package/dist/types/src/editor/mount.d.ts +23 -0
- package/dist/types/src/import/browser.d.ts +3 -0
- package/dist/types/src/import/detect.d.ts +31 -0
- package/dist/types/src/import/dot-importer.d.ts +3 -0
- package/dist/types/src/import/import-core.d.ts +105 -0
- package/dist/types/src/import/mermaid-facade.d.ts +120 -0
- package/dist/types/src/import/mermaid-importer.d.ts +4 -0
- package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
- package/dist/types/src/import/scratch.d.ts +3 -0
- package/dist/types/src/lib/engine-tasks.d.ts +88 -0
- package/dist/types/src/lib/font-data.d.ts +9 -0
- package/dist/types/src/lib/saved-diagram.d.ts +4 -0
- package/dist/types/src/lib/scene-cache.d.ts +4 -0
- package/dist/types/src/lib/source-hash.d.ts +7 -0
- package/dist/types/src/lib/svg-export.d.ts +15 -0
- package/dist/types/src/model/appearance.d.ts +209 -0
- package/dist/types/src/model/bounds.d.ts +19 -0
- package/dist/types/src/model/camera.d.ts +21 -0
- package/dist/types/src/model/candidates.d.ts +53 -0
- package/dist/types/src/model/colors.d.ts +22 -0
- package/dist/types/src/model/document.d.ts +24 -0
- package/dist/types/src/model/edits.d.ts +133 -0
- package/dist/types/src/model/embed.d.ts +17 -0
- package/dist/types/src/model/examples.d.ts +15 -0
- package/dist/types/src/model/font-faces.d.ts +24 -0
- package/dist/types/src/model/fonts.d.ts +47 -0
- package/dist/types/src/model/footnote.d.ts +34 -0
- package/dist/types/src/model/frame.d.ts +71 -0
- package/dist/types/src/model/geometry.d.ts +29 -0
- package/dist/types/src/model/graph.d.ts +53 -0
- package/dist/types/src/model/heading.d.ts +38 -0
- package/dist/types/src/model/icons.d.ts +2 -0
- package/dist/types/src/model/label-hits.d.ts +27 -0
- package/dist/types/src/model/labels.d.ts +88 -0
- package/dist/types/src/model/legend.d.ts +25 -0
- package/dist/types/src/model/link.d.ts +63 -0
- package/dist/types/src/model/markers.d.ts +47 -0
- package/dist/types/src/model/note.d.ts +75 -0
- package/dist/types/src/model/panels.d.ts +11 -0
- package/dist/types/src/model/rich-text.d.ts +24 -0
- package/dist/types/src/model/routes.d.ts +170 -0
- package/dist/types/src/model/samples.d.ts +11 -0
- package/dist/types/src/model/stack.d.ts +8 -0
- package/dist/types/src/model/static-scene.d.ts +15 -0
- package/dist/types/src/model/status.d.ts +84 -0
- package/dist/types/src/model/styles.d.ts +13 -0
- package/dist/types/src/model/surface.d.ts +31 -0
- package/dist/types/src/model/types.d.ts +277 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
- package/dist/types/src/server/file-session.d.ts +19 -0
- package/dist/types/src/server/workspace.d.ts +21 -0
- package/dist/types/src/state/active-session.d.ts +479 -0
- package/dist/types/src/state/commands.d.ts +529 -0
- package/dist/types/src/state/comparison.d.ts +151 -0
- package/dist/types/src/state/files.d.ts +61 -0
- package/dist/types/src/state/keyboard.d.ts +6 -0
- package/dist/types/src/state/keys.d.ts +5 -0
- package/dist/types/src/state/launch.d.ts +61 -0
- package/dist/types/src/state/links.d.ts +11 -0
- package/dist/types/src/state/session/actions.d.ts +77 -0
- package/dist/types/src/state/session/canvas-text.d.ts +24 -0
- package/dist/types/src/state/session/document.d.ts +84 -0
- package/dist/types/src/state/session/editor.d.ts +81 -0
- package/dist/types/src/state/session/emphasis.d.ts +11 -0
- package/dist/types/src/state/session/file-session.d.ts +98 -0
- package/dist/types/src/state/session/index.d.ts +496 -0
- package/dist/types/src/state/session/layout.d.ts +79 -0
- package/dist/types/src/state/session/pointer.d.ts +19 -0
- package/dist/types/src/state/session/routing.d.ts +20 -0
- package/dist/types/src/state/session/scene.d.ts +144 -0
- package/dist/types/src/state/session/sculpt.d.ts +70 -0
- package/dist/types/src/state/toast.d.ts +14 -0
- package/dist/types/src/state/ui.d.ts +39 -0
- package/package.json +41 -3
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { emptyDiagram } from './document';
|
|
2
|
+
import type { ContainerLayout, Diagram, DiagramEdge, DiagramGroup, DiagramNode, EdgeLayout, IntentPlacement, IntentRole, NodeLayout, NodeStyle, Point, PortSide, Rect, Side } from './types';
|
|
3
|
+
export declare function moveObject(doc: Diagram, id: string, dx: number, dy: number, manual?: boolean): void;
|
|
4
|
+
/** Bounds of a container's direct children, including shape labels. */
|
|
5
|
+
export declare function contentBounds(doc: Diagram, id: string): Rect | null;
|
|
6
|
+
export declare const containerPadding: (doc: Diagram, id: string) => number;
|
|
7
|
+
/** Size a container around its contents. Without `shrink`, the frame only grows. */
|
|
8
|
+
export declare function fitContainer(doc: Diagram, id: string, shrink?: boolean): void;
|
|
9
|
+
/** Grow every enclosing container so the object stays inside. */
|
|
10
|
+
export declare function ensureParentsFit(doc: Diagram, id: string): void;
|
|
11
|
+
/** The deepest, smallest visible container under the center of `rect`. */
|
|
12
|
+
export declare function dropTarget(doc: Diagram, id: string, rect: Rect, frames?: Map<string, Rect>): DiagramGroup | undefined;
|
|
13
|
+
export type ResizeHandle = 'n' | 's' | 'e' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
|
|
14
|
+
/**
|
|
15
|
+
* Resize from a handle. Containers cannot shrink across their contents, and their children
|
|
16
|
+
* stay at the same world coordinates.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resizedRect(doc: Diagram, id: string, start: NodeLayout, dx: number, dy: number, handle: ResizeHandle, keepAspect?: boolean): NodeLayout;
|
|
19
|
+
export interface NewNode {
|
|
20
|
+
id?: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
parentId?: string | null;
|
|
23
|
+
image?: string;
|
|
24
|
+
style?: Partial<NodeStyle>;
|
|
25
|
+
/** Top-left corner; defaults to centering the shape on `at`. */
|
|
26
|
+
position?: Point;
|
|
27
|
+
w?: number;
|
|
28
|
+
h?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function addNode(doc: Diagram, partial: NewNode, at: Point): string;
|
|
31
|
+
export interface NewEdge {
|
|
32
|
+
id?: string;
|
|
33
|
+
from: string;
|
|
34
|
+
to: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
directed?: boolean;
|
|
37
|
+
emphasis?: boolean;
|
|
38
|
+
dashed?: boolean;
|
|
39
|
+
fromSide?: PortSide;
|
|
40
|
+
toSide?: PortSide;
|
|
41
|
+
}
|
|
42
|
+
export declare function addEdge(doc: Diagram, partial: NewEdge): string;
|
|
43
|
+
export interface ConnectedNode {
|
|
44
|
+
/** Connect from this shape. */
|
|
45
|
+
from?: string | null;
|
|
46
|
+
/** Create a sibling branch: connect from every source of this shape. */
|
|
47
|
+
siblingOf?: string | null;
|
|
48
|
+
side?: Side | null;
|
|
49
|
+
/** Center of the new shape; otherwise it is placed beside the reference shape. */
|
|
50
|
+
at?: Point | null;
|
|
51
|
+
title?: string;
|
|
52
|
+
/** Container for the new shape; `undefined` inherits the reference shape's container. */
|
|
53
|
+
parentId?: string | null;
|
|
54
|
+
style?: Partial<NodeStyle>;
|
|
55
|
+
}
|
|
56
|
+
/** Add a shape next to another one and connect it. `fallback` is used when nothing is referenced. */
|
|
57
|
+
export declare function addConnectedNode(doc: Diagram, options: ConnectedNode, fallback: Point): string;
|
|
58
|
+
/**
|
|
59
|
+
* Split a connection with a new shape. `routePoints` locates the longest segment
|
|
60
|
+
* when `at` is not given.
|
|
61
|
+
*/
|
|
62
|
+
export declare function insertStep(doc: Diagram, edgeId: string, routePoints: Point[] | undefined, at?: Point | null): string | undefined;
|
|
63
|
+
export type BuildMode = 'chain' | 'branches' | 'none';
|
|
64
|
+
export interface BuildOptions {
|
|
65
|
+
mode?: BuildMode;
|
|
66
|
+
/** Wrap the new shapes in a container with this title. */
|
|
67
|
+
title?: string;
|
|
68
|
+
/** Continue from this shape. */
|
|
69
|
+
source?: string | null;
|
|
70
|
+
parentId?: string | null;
|
|
71
|
+
/** Where to start when there is no source or container. */
|
|
72
|
+
origin: Point;
|
|
73
|
+
columns: number;
|
|
74
|
+
}
|
|
75
|
+
/** Create shapes from a list of titles. Returns the ids to select. */
|
|
76
|
+
export declare function buildFromList(doc: Diagram, lines: string[], options: BuildOptions): string[];
|
|
77
|
+
/** Delete objects. Containers release their contents unless `deep` is set. */
|
|
78
|
+
export declare function deleteObjects(doc: Diagram, selected: Iterable<string>, deep?: boolean): void;
|
|
79
|
+
export declare function createContainer(doc: Diagram, rect: Rect, { roots, parentId, title, fit, }?: {
|
|
80
|
+
roots?: string[];
|
|
81
|
+
parentId?: string | null;
|
|
82
|
+
title?: string;
|
|
83
|
+
fit?: boolean;
|
|
84
|
+
}): string;
|
|
85
|
+
/** Wrap the selected objects in a new container, or add an empty one at `fallback`. */
|
|
86
|
+
export declare function wrapInContainer(doc: Diagram, roots: string[], fallback: Point): string;
|
|
87
|
+
/** Draw a container: it adopts the objects it fully encloses inside the deepest enclosing container. */
|
|
88
|
+
export declare function drawContainer(doc: Diagram, r: Rect): string;
|
|
89
|
+
export declare function ungroup(doc: Diagram, selected: Iterable<string>): void;
|
|
90
|
+
export type AlignKind = 'left' | 'top' | 'center' | 'middle' | 'distribute-x' | 'distribute-y';
|
|
91
|
+
export declare function alignObjects(doc: Diagram, ids: string[], kind: AlignKind): void;
|
|
92
|
+
export declare function nudge(doc: Diagram, ids: string[], dx: number, dy: number): void;
|
|
93
|
+
export declare function toggleCollapsed(doc: Diagram, id: string): void;
|
|
94
|
+
export declare function setTitle(doc: Diagram, id: string, title: string): void;
|
|
95
|
+
export declare function setEdgeLabel(doc: Diagram, id: string, label: string): void;
|
|
96
|
+
export declare function setGeometry(doc: Diagram, id: string, key: 'x' | 'y' | 'w' | 'h', value: number): void;
|
|
97
|
+
export declare function setStyle(doc: Diagram, id: string, patch: Partial<NodeStyle>): void;
|
|
98
|
+
export declare function setLabelMode(doc: Diagram, id: string, mode: NonNullable<Diagram['layout']['labels'][string]['mode']>): void;
|
|
99
|
+
export declare function setParent(doc: Diagram, id: string, parentId: string | null): void;
|
|
100
|
+
export declare function setContainer(doc: Diagram, id: string, patch: Partial<ContainerLayout>): void;
|
|
101
|
+
export declare function setEdge(doc: Diagram, id: string, patch: Partial<Pick<DiagramEdge, 'directed' | 'dashed' | 'emphasis' | 'head' | 'tail'>>): void;
|
|
102
|
+
export declare function setEdgeLayout(doc: Diagram, id: string, patch: Partial<EdgeLayout>): void;
|
|
103
|
+
export declare function reverseEdge(doc: Diagram, id: string): void;
|
|
104
|
+
export declare function useAutomaticPorts(doc: Diagram, edgeIds: string[]): void;
|
|
105
|
+
/** True when the point is too close to a shape to hold a connection bend. */
|
|
106
|
+
export declare const bendInsideShape: (doc: Diagram, p: Point) => boolean;
|
|
107
|
+
export declare function addWaypoint(doc: Diagram, id: string, p: Point): void;
|
|
108
|
+
export declare function removeWaypoint(doc: Diagram, id: string, index: number): void;
|
|
109
|
+
export declare const INTENT_LABELS: Record<IntentPlacement, string>;
|
|
110
|
+
/** Placements offered for a role; only a start can sit in the center. */
|
|
111
|
+
export declare const intentPlacements: (role: IntentRole) => IntentPlacement[];
|
|
112
|
+
/** Mark a shape as the preferred start or end, or clear the role when `id` is null. */
|
|
113
|
+
export declare function setIntent(doc: Diagram, role: IntentRole, id: string | null, placement?: IntentPlacement): void;
|
|
114
|
+
export interface ClipboardFragment {
|
|
115
|
+
kind: 'diagram-studio/clipboard';
|
|
116
|
+
nodes: DiagramNode[];
|
|
117
|
+
groups: DiagramGroup[];
|
|
118
|
+
edges: DiagramEdge[];
|
|
119
|
+
layout: Partial<Record<'nodes' | 'edges' | 'labels' | 'containers', Record<string, unknown>>>;
|
|
120
|
+
styles: Record<string, NodeStyle>;
|
|
121
|
+
}
|
|
122
|
+
/** Copy the selection, including container contents and connections between copied shapes. */
|
|
123
|
+
export declare function copyFragment(doc: Diagram, selected: Iterable<string>): ClipboardFragment;
|
|
124
|
+
export declare const isClipboardFragment: (value: unknown) => value is ClipboardFragment;
|
|
125
|
+
/**
|
|
126
|
+
* Return a validated document with the fragment pasted at an offset, plus the new ids to select.
|
|
127
|
+
* The fragment is untrusted, so the whole result goes through `normalize`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function pasteFragment(doc: Diagram, part: ClipboardFragment): {
|
|
130
|
+
doc: Diagram;
|
|
131
|
+
selected: string[];
|
|
132
|
+
};
|
|
133
|
+
export { emptyDiagram };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const SOURCE_KEYWORD = "draftably";
|
|
2
|
+
export declare const VERSION_KEYWORD = "draftably-version";
|
|
3
|
+
export declare const DRAFTABLY_VERSION: string;
|
|
4
|
+
/** The PNG with `source` in a `draftably` chunk before its end, replacing any earlier one. */
|
|
5
|
+
export declare function embedPngSource(png: Uint8Array, source: string): Promise<Uint8Array>;
|
|
6
|
+
/** The source in a PNG's `draftably` chunk, or null when it has none. */
|
|
7
|
+
export declare function readPngSource(png: Uint8Array): Promise<string | null>;
|
|
8
|
+
/** The `<metadata>` element that carries `source` in an SVG. */
|
|
9
|
+
export declare const svgSourceElement: (source: string) => string;
|
|
10
|
+
/** The SVG with `source` in a metadata element just inside its root. */
|
|
11
|
+
export declare const embedSvgSource: (svg: string, source: string) => string;
|
|
12
|
+
/** The source in an SVG's `draftably-source` metadata, or null when it has none. */
|
|
13
|
+
export declare function readSvgSource(svg: string): string | null;
|
|
14
|
+
/** The source embedded in PNG or SVG bytes, or null when there is none. */
|
|
15
|
+
export declare function readImageSource(bytes: Uint8Array): Promise<string | null>;
|
|
16
|
+
/** True for a file name the CLI and viewer read source out of. */
|
|
17
|
+
export declare const isImageName: (name: string) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ExampleInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
/** The first comment in the file. */
|
|
5
|
+
summary: string;
|
|
6
|
+
source: string;
|
|
7
|
+
nodes: number;
|
|
8
|
+
groups: number;
|
|
9
|
+
edges: number;
|
|
10
|
+
/** Deepest container nesting: 0 for a flat diagram. */
|
|
11
|
+
depth: number;
|
|
12
|
+
}
|
|
13
|
+
/** All examples, flattest first, so the list reads as a ladder of nesting depth. */
|
|
14
|
+
export declare const EXAMPLES: ExampleInfo[];
|
|
15
|
+
export declare const findExample: (id: string) => ExampleInfo | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** SHA-256 prefix of the metric table and its four WOFF2 files, in declared face order. */
|
|
2
|
+
export declare const fontMetricsVersion = "269b2d3580f4";
|
|
3
|
+
export declare const FACES: {
|
|
4
|
+
'sans-500': {
|
|
5
|
+
family: string;
|
|
6
|
+
weight: number;
|
|
7
|
+
file: string;
|
|
8
|
+
};
|
|
9
|
+
'sans-600': {
|
|
10
|
+
family: string;
|
|
11
|
+
weight: number;
|
|
12
|
+
file: string;
|
|
13
|
+
};
|
|
14
|
+
'serif-600': {
|
|
15
|
+
family: string;
|
|
16
|
+
weight: number;
|
|
17
|
+
file: string;
|
|
18
|
+
};
|
|
19
|
+
'mono-500': {
|
|
20
|
+
family: string;
|
|
21
|
+
weight: number;
|
|
22
|
+
file: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type FontRole = 'sans' | 'serif' | 'mono';
|
|
2
|
+
export declare const FONT_ROLES: FontRole[];
|
|
3
|
+
export interface FontFace {
|
|
4
|
+
/** Registered family name; unique so an installed copy of the font is never used instead. */
|
|
5
|
+
family: string;
|
|
6
|
+
weight: number;
|
|
7
|
+
file: string;
|
|
8
|
+
}
|
|
9
|
+
export { FACES } from './font-faces';
|
|
10
|
+
import { FACES } from './font-faces';
|
|
11
|
+
export type FaceId = keyof typeof FACES;
|
|
12
|
+
/** Face used for each role: titles are a little heavier than annotations in sans-serif. */
|
|
13
|
+
export declare const faceFor: (role: FontRole, title: boolean) => FaceId;
|
|
14
|
+
export declare const fontStack: (role: FontRole) => string;
|
|
15
|
+
/** A text style: which face, at what size and line height. */
|
|
16
|
+
export interface TypeProfile {
|
|
17
|
+
role: FontRole;
|
|
18
|
+
face: FaceId;
|
|
19
|
+
family: string;
|
|
20
|
+
weight: number;
|
|
21
|
+
size: number;
|
|
22
|
+
lineHeight: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function typeProfile(role: FontRole, title: boolean, size: number, lineHeight: number): TypeProfile;
|
|
25
|
+
/**
|
|
26
|
+
* Width of `text` in `profile`, from the stored advance widths. Kerning is ignored, which only
|
|
27
|
+
* ever overstates a width slightly, so measured text fits where this says it fits.
|
|
28
|
+
*/
|
|
29
|
+
export declare function measureText(text: string, profile: Pick<TypeProfile, 'face' | 'size'>): number;
|
|
30
|
+
/**
|
|
31
|
+
* The pieces an identifier reads in, so a long one can break where a reader would: after a
|
|
32
|
+
* separator (`/`, `.`, `_`, `-`, `:`) or between a lower-case letter or digit and a capital
|
|
33
|
+
* (camelCase). `annotationCommands` → `annotation`, `Commands`; `src/viz/Treemap.tsx` → `src/`,
|
|
34
|
+
* `viz/`, `Treemap.tsx`. A word with none of these is one piece.
|
|
35
|
+
*/
|
|
36
|
+
export declare function wordPieces(word: string): string[];
|
|
37
|
+
/** Width of the widest piece of any word in `text`: the narrowest line it wraps into whole. */
|
|
38
|
+
export declare function widestPiece(text: string, profile: Pick<TypeProfile, 'face' | 'size'>): number;
|
|
39
|
+
/**
|
|
40
|
+
* Break text into lines no wider than `width`, starting a new line at each `\n`. A word longer
|
|
41
|
+
* than a line breaks between its pieces (`wordPieces`), and only a piece that is itself too long
|
|
42
|
+
* breaks by character. With `balance`, a paragraph that wraps keeps its line count but its lines
|
|
43
|
+
* run near equal (`even`), so no word sits alone on the last line when a better break exists.
|
|
44
|
+
*/
|
|
45
|
+
export declare function wrapLines(text: string, width: number, profile: TypeProfile, balance?: boolean): string[];
|
|
46
|
+
/** Shorten text with an ellipsis so it fits in `width`. */
|
|
47
|
+
export declare function truncateText(text: string, width: number, profile: TypeProfile): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footnotes: a block of short entries between the drawing and the key, from `footnote`
|
|
3
|
+
* statements, in file order, at body text size and wrapped to the frame. An entry may carry a
|
|
4
|
+
* marker (`1`, `a`, `*`) that a label can point at, and links in `[label](href)` form. The viewer,
|
|
5
|
+
* `inspect --svg`, PDF and the editor's exports all lay it out here.
|
|
6
|
+
*/
|
|
7
|
+
import { type ResolvedAppearance } from './appearance';
|
|
8
|
+
import { type Run } from './rich-text';
|
|
9
|
+
export interface Footnote {
|
|
10
|
+
text: string;
|
|
11
|
+
/** A short marker drawn before the entry, which labels can point at as `[1]`. */
|
|
12
|
+
mark?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The block's entries, wrapped to `width`, with their offsets from its top-left corner. */
|
|
15
|
+
export declare function footnoteSize(look: ResolvedAppearance, notes: readonly Footnote[], width: number): {
|
|
16
|
+
type: import("./fonts").TypeProfile;
|
|
17
|
+
gutter: number;
|
|
18
|
+
items: {
|
|
19
|
+
note: Footnote;
|
|
20
|
+
lines: Run[][];
|
|
21
|
+
y: number;
|
|
22
|
+
}[];
|
|
23
|
+
h: number;
|
|
24
|
+
};
|
|
25
|
+
export type FootnoteLayout = ReturnType<typeof footnoteSize>;
|
|
26
|
+
/** Where each line of every entry is drawn, from the block's top-left corner at (x, y). */
|
|
27
|
+
export declare function footnoteLines(layout: FootnoteLayout, x: number, y: number): {
|
|
28
|
+
entry: number;
|
|
29
|
+
runs: Run[];
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}[];
|
|
33
|
+
/** SVG markup for the block: a short rule, then each entry's marker and wrapped text. */
|
|
34
|
+
export declare function footnoteMarkup(look: ResolvedAppearance, layout: FootnoteLayout, x: number, y: number, write?: (href: string) => string | null): string;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame round a diagram: the heading above the drawing and the key under it. `inspect --svg`,
|
|
3
|
+
* the editor's exports and the viewer canvas all place them from here, so what the viewer shows is
|
|
4
|
+
* what an export draws.
|
|
5
|
+
*/
|
|
6
|
+
import type { Heading, LegendEntry, ResolvedAppearance } from './appearance';
|
|
7
|
+
import { type Footnote } from './footnote';
|
|
8
|
+
import type { PlacedNote } from './note';
|
|
9
|
+
import type { Rect } from './types';
|
|
10
|
+
import type { StatusCount } from './status';
|
|
11
|
+
/** Space between the frame's edge and the drawing; the heading and the key align to it. */
|
|
12
|
+
export declare const FRAME_PAD = 40;
|
|
13
|
+
/** Narrowest frame a `diagram width=` line or a drag can set. */
|
|
14
|
+
export declare const MIN_FRAME_WIDTH = 160;
|
|
15
|
+
/**
|
|
16
|
+
* Lay out the frame round `area`, the drawing with `FRAME_PAD` already round it. The heading sits
|
|
17
|
+
* above the area and the key at its bottom, both left-aligned with the drawing; footnotes sit
|
|
18
|
+
* between the drawing and the key, wrapped to the frame. Frame notes stack
|
|
19
|
+
* under the heading, and the area grows to hold anchored notes (`placeNotes`). The frame is at
|
|
20
|
+
* least as wide as the heading, the notes, the key and the heading's `width`; extra width goes to
|
|
21
|
+
* the right.
|
|
22
|
+
*/
|
|
23
|
+
export declare function diagramFrame(look: ResolvedAppearance, heading: Heading | undefined, legend: LegendEntry[], statuses: StatusCount[], drawing: Rect, notes?: readonly PlacedNote[], footnotes?: readonly Footnote[]): {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
w: number;
|
|
27
|
+
h: number;
|
|
28
|
+
/** Width without the heading's `width`, which a drag never narrows past. */
|
|
29
|
+
natural: number;
|
|
30
|
+
head: {
|
|
31
|
+
w: number;
|
|
32
|
+
h: number;
|
|
33
|
+
};
|
|
34
|
+
key: {
|
|
35
|
+
w: number;
|
|
36
|
+
h: number;
|
|
37
|
+
row: number;
|
|
38
|
+
items: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
legend?: LegendEntry;
|
|
42
|
+
status?: StatusCount;
|
|
43
|
+
label: string;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
heading: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
wrap: number;
|
|
50
|
+
};
|
|
51
|
+
legend: {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
};
|
|
55
|
+
/** The footnote block's top-left corner and layout. */
|
|
56
|
+
foot: {
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
type: import("./fonts").TypeProfile;
|
|
60
|
+
gutter: number;
|
|
61
|
+
items: {
|
|
62
|
+
note: Footnote;
|
|
63
|
+
lines: import("./rich-text").Run[][];
|
|
64
|
+
y: number;
|
|
65
|
+
}[];
|
|
66
|
+
h: number;
|
|
67
|
+
};
|
|
68
|
+
/** Every note, placed. */
|
|
69
|
+
notes: PlacedNote[];
|
|
70
|
+
};
|
|
71
|
+
export type DiagramFrame = ReturnType<typeof diagramFrame>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Point, Rect } from './types';
|
|
2
|
+
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
3
|
+
export declare const finite: (n: unknown) => n is number;
|
|
4
|
+
/** Document coordinates are stored with one decimal place. */
|
|
5
|
+
export declare const rounded: (n: number) => number;
|
|
6
|
+
export declare const center: (r: Rect) => Point;
|
|
7
|
+
export declare const manhattan: (a: Point, b: Point) => number;
|
|
8
|
+
export declare const inside: (p: Point, r: Rect, pad?: number) => boolean;
|
|
9
|
+
export declare const contains: (outer: Rect, inner: Rect) => boolean;
|
|
10
|
+
export declare const overlaps: (a: Rect, b: Rect, pad?: number) => boolean;
|
|
11
|
+
/** Bounding box of the given rectangles, or a placeholder area when there are none. */
|
|
12
|
+
export declare function rectUnion(rects: readonly Rect[], pad?: number): Rect;
|
|
13
|
+
/** Rectangle spanned by two corner points. */
|
|
14
|
+
export declare const rectFromPoints: (a: Point, b: Point) => Rect;
|
|
15
|
+
export type Segment = [Point, Point];
|
|
16
|
+
export declare const segments: (points: readonly Point[]) => Segment[];
|
|
17
|
+
export declare const shrink: (r: Rect, d: number) => Rect;
|
|
18
|
+
/** Overlap of two rectangles larger than half a pixel on both axes. */
|
|
19
|
+
export declare const covers: (a: Rect, b: Rect) => boolean;
|
|
20
|
+
/** Length of a segment inside a rectangle (Liang–Barsky clipping). */
|
|
21
|
+
export declare function segmentInside([a, b]: Segment, r: Rect): number;
|
|
22
|
+
/** SVG path for an orthogonal polyline with rounded corners. */
|
|
23
|
+
export declare function roundedPath(points: readonly Point[], radius: number): string;
|
|
24
|
+
export declare const clone: <T>(value: T) => T;
|
|
25
|
+
/**
|
|
26
|
+
* A rectangle whose left and right sides are zigzags, for a field of variable length: the reader
|
|
27
|
+
* sees it continue past what is drawn.
|
|
28
|
+
*/
|
|
29
|
+
export declare function brokenRectPath(r: Rect, step?: number, depth?: number): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Diagram, DiagramEdge, DiagramGroup, DiagramNode, Direction, Entity, NodeLayout, NodeStyle, Rect } from './types';
|
|
2
|
+
export declare const findNode: (doc: Diagram, id: string | null | undefined) => DiagramNode | undefined;
|
|
3
|
+
export declare const findGroup: (doc: Diagram, id: string | null | undefined) => DiagramGroup | undefined;
|
|
4
|
+
export declare const findEdge: (doc: Diagram, id: string | null | undefined) => DiagramEdge | undefined;
|
|
5
|
+
export declare const findObject: (doc: Diagram, id: string | null | undefined) => DiagramNode | DiagramGroup | undefined;
|
|
6
|
+
export declare const findEntity: (doc: Diagram, id: string | null | undefined) => Entity | undefined;
|
|
7
|
+
export declare const isNode: (doc: Diagram, id: string) => boolean;
|
|
8
|
+
export declare const isGroup: (doc: Diagram, id: string) => boolean;
|
|
9
|
+
export declare const isEdge: (doc: Diagram, id: string) => boolean;
|
|
10
|
+
export declare const styleOf: (doc: Diagram, id: string) => NodeStyle;
|
|
11
|
+
/** Direct children (shapes and containers) of a container, or of the diagram root. */
|
|
12
|
+
/** The title band of a `cells` group; undefined for any other group. */
|
|
13
|
+
export declare const cellsBandOf: (doc: Diagram, id: string | null | undefined) => number | undefined;
|
|
14
|
+
/** Whether a cell is a field of variable length in a byte or bit layout. */
|
|
15
|
+
export declare const isOpenCell: (doc: Diagram, id: string) => boolean;
|
|
16
|
+
/** Whether a node is a cell of a `cells` group, which holds it in place edge to edge. */
|
|
17
|
+
export declare const isCell: (doc: Diagram, id: string) => boolean;
|
|
18
|
+
export declare function childrenOf(doc: Diagram, parentId: string | null | undefined): (DiagramNode | DiagramGroup)[];
|
|
19
|
+
export declare function descendants(doc: Diagram, id: string): string[];
|
|
20
|
+
/** Containers enclosing an object, nearest first. */
|
|
21
|
+
export declare function ancestors(doc: Diagram, id: string): string[];
|
|
22
|
+
export declare const isCollapsed: (doc: Diagram, id: string) => boolean;
|
|
23
|
+
export declare const isHiddenByCollapse: (doc: Diagram, id: string) => boolean;
|
|
24
|
+
/** The visible object that stands in for `id`: its outermost collapsed container, if any. */
|
|
25
|
+
export declare function visibleProxy(doc: Diagram, id: string): string;
|
|
26
|
+
export interface VisibleEdge extends DiagramEdge {
|
|
27
|
+
/** Visible source, which may be a collapsed container. */
|
|
28
|
+
a: string;
|
|
29
|
+
/** Visible target, which may be a collapsed container. */
|
|
30
|
+
b: string;
|
|
31
|
+
}
|
|
32
|
+
export interface VisibleGraph {
|
|
33
|
+
nodes: DiagramNode[];
|
|
34
|
+
groups: DiagramGroup[];
|
|
35
|
+
edges: VisibleEdge[];
|
|
36
|
+
}
|
|
37
|
+
/** Objects and connections that are not hidden inside a collapsed container. */
|
|
38
|
+
export declare function visibleGraph(doc: Diagram): VisibleGraph;
|
|
39
|
+
/** Selected shapes and containers whose own container is not also selected. */
|
|
40
|
+
export declare function selectionRoots(doc: Diagram, selected: Iterable<string>): string[];
|
|
41
|
+
/** Layout direction for the contents of an object's container. */
|
|
42
|
+
export declare function inheritedDirection(doc: Diagram, id: string): Direction;
|
|
43
|
+
export declare const COLLAPSED_HEIGHT = 58;
|
|
44
|
+
export declare const CONTAINER_HEADER = 28;
|
|
45
|
+
/** Read geometry for an object, preferring a temporary override (preview, animation, brush). */
|
|
46
|
+
export type GeometryLookup = (id: string) => NodeLayout;
|
|
47
|
+
export declare function makeGeometry(doc: Diagram, override?: Record<string, NodeLayout> | null): (id: string) => NodeLayout;
|
|
48
|
+
/**
|
|
49
|
+
* Container frame as drawn: collapsed containers shrink to their title band plus a line for the
|
|
50
|
+
* shape count, so the title stays where it was in the open frame.
|
|
51
|
+
*/
|
|
52
|
+
export declare function frameRect(doc: Diagram, geometry: GeometryLookup, id: string): NodeLayout;
|
|
53
|
+
export declare const objectRect: (doc: Diagram, geometry: GeometryLookup, id: string) => Rect;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The title and subtitle drawn above an exported diagram, shared by `inspect --svg` and the
|
|
3
|
+
* editor's export, so a copied image still says what it shows.
|
|
4
|
+
*/
|
|
5
|
+
import type { Heading, ResolvedAppearance } from './appearance';
|
|
6
|
+
/** Title type: the theme's title face, larger; subtitle type: its annotation face. */
|
|
7
|
+
declare function types(look: ResolvedAppearance): {
|
|
8
|
+
title: import("./fonts").TypeProfile;
|
|
9
|
+
subtitle: import("./fonts").TypeProfile;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Width the subtitle wraps to over a drawing `room` wide: the drawing's width, held between 360px
|
|
13
|
+
* and about 70 characters, so a long subtitle wraps instead of widening the frame.
|
|
14
|
+
*/
|
|
15
|
+
export declare function subtitleMeasure(look: ResolvedAppearance, room: number): number;
|
|
16
|
+
/** Size of the heading block, including the gap under it. Zero when there is nothing to draw. */
|
|
17
|
+
export declare function headingSize(look: ResolvedAppearance, heading: Heading | undefined, wrap: number): {
|
|
18
|
+
w: number;
|
|
19
|
+
h: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Each line of the heading with its own type and box, top-left corner at (x, y). The title is one
|
|
23
|
+
* line; the subtitle wraps to `wrap` (`subtitleMeasure`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function headingLines(look: ResolvedAppearance, heading: Heading | undefined, x: number, y: number, wrap: number): {
|
|
26
|
+
key: "title" | "subtitle";
|
|
27
|
+
text: string;
|
|
28
|
+
type: Type;
|
|
29
|
+
fill: string;
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}[];
|
|
33
|
+
type Type = ReturnType<typeof types>['title'];
|
|
34
|
+
/** SVG markup for the heading with its top-left corner at (x, y). */
|
|
35
|
+
export declare function headingMarkup(look: ResolvedAppearance, heading: Heading | undefined, x: number, y: number, wrap: number): string;
|
|
36
|
+
/** Title and subtitle type, for drawing and editing them in the viewer. */
|
|
37
|
+
export declare const headingTypes: typeof types;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a drawing's text cannot be read: a connection label on another label, a shape, a group's
|
|
3
|
+
* title or a line, and a shape title too long for its shape. Compare counts these for each
|
|
4
|
+
* candidate and marks them on its card, so this has to stay cheap and read only the drawn scene.
|
|
5
|
+
*/
|
|
6
|
+
import { type ResolvedAppearance } from './appearance';
|
|
7
|
+
import type { DrawnRoute } from './routes';
|
|
8
|
+
import type { StaticScene } from './static-scene';
|
|
9
|
+
import type { DiagramGroup, Rect } from './types';
|
|
10
|
+
/** Connection labels as boxes. Labels are centred on their spot. */
|
|
11
|
+
export declare const labelBoxes: (routes: readonly DrawnRoute[]) => {
|
|
12
|
+
route: DrawnRoute;
|
|
13
|
+
box: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
/** A group's title: its icon and text, as the canvas draws them. */
|
|
21
|
+
export declare function groupTitleInk(g: DiagramGroup, r: Rect, look: ResolvedAppearance): Rect;
|
|
22
|
+
export interface LabelHit {
|
|
23
|
+
/** What cannot be read, and where to mark it. */
|
|
24
|
+
box: Rect;
|
|
25
|
+
note: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function labelHits(scene: StaticScene): LabelHit[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ResolvedAppearance } from './appearance';
|
|
2
|
+
import { type TypeProfile } from './fonts';
|
|
3
|
+
import type { Diagram, LabelMode, Rect, ShapeKind } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Room for a shape's title. Every size, wrap and overflow decision goes through these functions,
|
|
6
|
+
* in the compiler, the canvas and the CLI alike.
|
|
7
|
+
*/
|
|
8
|
+
export interface TitleArea {
|
|
9
|
+
/** Line width available to the title. */
|
|
10
|
+
width: number;
|
|
11
|
+
/** Tallest text block that fits inside the shape at its current height. */
|
|
12
|
+
maxHeight: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function titleArea(shape: ShapeKind, w: number, h: number, r: ResolvedAppearance, icon?: boolean): TitleArea;
|
|
15
|
+
/** Height a shape needs for `lines` title lines; never less than `base`. */
|
|
16
|
+
export declare function titleHeight(shape: ShapeKind, lines: number, base: number, r: ResolvedAppearance): number;
|
|
17
|
+
/** A shape's title in balanced lines no wider than `width` (see `wrapLines`). */
|
|
18
|
+
export declare const wrapTitle: (text: string, width: number, r: ResolvedAppearance) => string[];
|
|
19
|
+
/**
|
|
20
|
+
* Line width for a diamond's title, `s` its side. A text block W wide and H tall fits inside a
|
|
21
|
+
* square diamond when W + H <= s, so this takes the widest measure whose wrapped lines still fit:
|
|
22
|
+
* the title reads in as few lines as the shape allows. Undefined when no measure fits.
|
|
23
|
+
*/
|
|
24
|
+
export declare function diamondMeasure(title: string, s: number, r: ResolvedAppearance): number | undefined;
|
|
25
|
+
/** Most lines a group title wraps to; past that the frame widens instead. */
|
|
26
|
+
export declare const GROUP_TITLE_LINES = 3;
|
|
27
|
+
/** A group's header height when its title takes `lines` lines. */
|
|
28
|
+
export declare const groupHeaderFor: (r: ResolvedAppearance, lines?: number) => number;
|
|
29
|
+
/**
|
|
30
|
+
* A group title as drawn in a frame `w` wide: wrapped to at most `lines` lines (the compiler
|
|
31
|
+
* reserves that many), the last shortened with an ellipsis if the text runs on.
|
|
32
|
+
*/
|
|
33
|
+
export declare function groupTitleLines(title: string, w: number, r: ResolvedAppearance, lines?: number): string[];
|
|
34
|
+
export interface NodeLabel {
|
|
35
|
+
/** Center of the label, relative to the shape's top-left corner. */
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
lines: string[];
|
|
41
|
+
mode: LabelMode;
|
|
42
|
+
lineHeight: number;
|
|
43
|
+
leader: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Where a shape's title is drawn, relative to the shape. */
|
|
46
|
+
export declare function nodeLabel(doc: Diagram, id: string, title: string, r: Rect): NodeLabel;
|
|
47
|
+
/** Bounds of a shape together with its label. */
|
|
48
|
+
export declare function visualBounds(doc: Diagram, id: string, title: string, r: Rect): Rect;
|
|
49
|
+
/** Text width a sequence message's label wraps to; the gap between participants follows it. */
|
|
50
|
+
export declare const MESSAGE_WRAP = 168;
|
|
51
|
+
/**
|
|
52
|
+
* The type a connection label is set in: the annotation type, or a step larger for a sequence
|
|
53
|
+
* message (`message`), whose label is the main thing to read.
|
|
54
|
+
*/
|
|
55
|
+
export declare const edgeLabelType: (r: ResolvedAppearance, message?: boolean) => TypeProfile;
|
|
56
|
+
/**
|
|
57
|
+
* Text width a flow line's label wraps to: about 24 characters of the annotation type, so a short
|
|
58
|
+
* phrase stays on one line and a sentence stacks instead of widening its gap.
|
|
59
|
+
*/
|
|
60
|
+
export declare const LABEL_WRAP = 140;
|
|
61
|
+
/**
|
|
62
|
+
* A connection label's lines: split at each `\n` and wrapped to `LABEL_WRAP`, or a sequence
|
|
63
|
+
* message's to `MESSAGE_WRAP`.
|
|
64
|
+
*/
|
|
65
|
+
export declare const edgeLabelLines: (label: string, r: ResolvedAppearance, message?: boolean) => string[];
|
|
66
|
+
/**
|
|
67
|
+
* A self-message's loop: its run out to the right of the lifeline and its drop. Its label sits
|
|
68
|
+
* `label` past the loop, centred on the drop.
|
|
69
|
+
*/
|
|
70
|
+
export declare const SELF_LOOP: {
|
|
71
|
+
out: number;
|
|
72
|
+
down: number;
|
|
73
|
+
label: number;
|
|
74
|
+
};
|
|
75
|
+
/** Box for a connection label in the diagram's annotation type. */
|
|
76
|
+
export declare function edgeLabelSize(label: string, r?: ResolvedAppearance, message?: boolean): {
|
|
77
|
+
w: number;
|
|
78
|
+
h: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* What a self-message draws, measured from where its row meets the lifeline: how far right, how
|
|
82
|
+
* far above the row and how far below it.
|
|
83
|
+
*/
|
|
84
|
+
export declare function selfMessageInk(label: string | undefined, r: ResolvedAppearance): {
|
|
85
|
+
right: number;
|
|
86
|
+
above: number;
|
|
87
|
+
below: number;
|
|
88
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The color key drawn under an exported diagram, shared by `inspect --svg` and the editor's export. */
|
|
2
|
+
import { type LegendEntry, type ResolvedAppearance } from './appearance';
|
|
3
|
+
import { type StatusCount } from './status';
|
|
4
|
+
/** The removed marker, a minus in a disc of radius `r`, centred at (x, y). */
|
|
5
|
+
export declare const markerMarkup: (x: number, y: number, ink: string, canvas: string, r?: number) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Lay out the key: every `legend` entry, then every change mark used with its count, left to
|
|
8
|
+
* right, starting a new row only where the next entry would pass `max`. A short key is one row
|
|
9
|
+
* under the drawing. Zero size when there is nothing to show.
|
|
10
|
+
*/
|
|
11
|
+
export declare function legendSize(look: ResolvedAppearance, legend?: LegendEntry[], statuses?: StatusCount[], max?: number): {
|
|
12
|
+
w: number;
|
|
13
|
+
h: number;
|
|
14
|
+
row: number;
|
|
15
|
+
items: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
legend?: LegendEntry;
|
|
19
|
+
status?: StatusCount;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export type LegendLayout = ReturnType<typeof legendSize>;
|
|
24
|
+
/** SVG markup for the key laid out by `legendSize`, with its top-left corner at (x, y). */
|
|
25
|
+
export declare function legendMarkup(look: ResolvedAppearance, key: LegendLayout, x: number, y: number): string;
|