@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.
Files changed (185) hide show
  1. package/README.md +26 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
  4. package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
  5. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
  6. package/dist/chunks/arc-rJj0TtXf.js +83 -0
  7. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
  8. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
  9. package/dist/chunks/browser-iNhbPsGc.js +40 -0
  10. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
  11. package/dist/chunks/channel-qMvPU6eH.js +5 -0
  12. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
  13. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
  14. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
  15. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
  16. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
  17. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
  18. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
  19. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
  20. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
  21. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
  22. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
  23. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
  24. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
  25. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
  26. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
  27. package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
  28. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
  29. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
  30. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
  31. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
  32. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
  33. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
  34. package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
  35. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
  36. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
  37. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
  38. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
  39. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
  40. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
  41. package/dist/chunks/graph-CKJmgLki.js +1541 -0
  42. package/dist/chunks/import-core-C-I1wGfw.js +145 -0
  43. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
  44. package/dist/chunks/init-DjUOC4st.js +16 -0
  45. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
  46. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
  47. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
  48. package/dist/chunks/katex-BsrBVQKd.js +11314 -0
  49. package/dist/chunks/linear-4t7D_ros.js +259 -0
  50. package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
  51. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
  52. package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
  53. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
  54. package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
  55. package/dist/chunks/ordinal-DfAQgscy.js +61 -0
  56. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
  57. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
  58. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
  59. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
  60. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
  61. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
  62. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
  63. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
  64. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
  65. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
  66. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
  67. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
  68. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
  69. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
  70. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
  71. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
  72. package/dist/element.js +36 -0
  73. package/dist/index.js +4 -0
  74. package/dist/types/src/cli/links.d.ts +4 -0
  75. package/dist/types/src/cli/pdf.d.ts +29 -0
  76. package/dist/types/src/cli/png.d.ts +23 -0
  77. package/dist/types/src/cli/svg.d.ts +4 -0
  78. package/dist/types/src/components/Icon.d.ts +14 -0
  79. package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
  80. package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
  81. package/dist/types/src/components/canvas/Frame.d.ts +22 -0
  82. package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
  83. package/dist/types/src/components/canvas/Notes.d.ts +5 -0
  84. package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
  85. package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
  86. package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
  87. package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
  88. package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
  89. package/dist/types/src/components/controls.d.ts +88 -0
  90. package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
  91. package/dist/types/src/components/scene/GroupView.d.ts +22 -0
  92. package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
  93. package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
  94. package/dist/types/src/components/scene/NodeView.d.ts +18 -0
  95. package/dist/types/src/components/scene/parts.d.ts +50 -0
  96. package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
  97. package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
  98. package/dist/types/src/components/session-context.d.ts +486 -0
  99. package/dist/types/src/dsl/cells.d.ts +91 -0
  100. package/dist/types/src/dsl/channels.d.ts +53 -0
  101. package/dist/types/src/dsl/compile.d.ts +162 -0
  102. package/dist/types/src/dsl/frame.d.ts +38 -0
  103. package/dist/types/src/dsl/lanes.d.ts +23 -0
  104. package/dist/types/src/dsl/layout-edits.d.ts +58 -0
  105. package/dist/types/src/dsl/legend-notes.d.ts +3 -0
  106. package/dist/types/src/dsl/project.d.ts +39 -0
  107. package/dist/types/src/dsl/source-edits.d.ts +37 -0
  108. package/dist/types/src/dsl/syntax.d.ts +317 -0
  109. package/dist/types/src/dsl/translate.d.ts +69 -0
  110. package/dist/types/src/editor/Editor.d.ts +6 -0
  111. package/dist/types/src/editor/element.d.ts +15 -0
  112. package/dist/types/src/editor/mount.d.ts +23 -0
  113. package/dist/types/src/import/browser.d.ts +3 -0
  114. package/dist/types/src/import/detect.d.ts +31 -0
  115. package/dist/types/src/import/dot-importer.d.ts +3 -0
  116. package/dist/types/src/import/import-core.d.ts +105 -0
  117. package/dist/types/src/import/mermaid-facade.d.ts +120 -0
  118. package/dist/types/src/import/mermaid-importer.d.ts +4 -0
  119. package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
  120. package/dist/types/src/import/scratch.d.ts +3 -0
  121. package/dist/types/src/lib/engine-tasks.d.ts +88 -0
  122. package/dist/types/src/lib/font-data.d.ts +9 -0
  123. package/dist/types/src/lib/saved-diagram.d.ts +4 -0
  124. package/dist/types/src/lib/scene-cache.d.ts +4 -0
  125. package/dist/types/src/lib/source-hash.d.ts +7 -0
  126. package/dist/types/src/lib/svg-export.d.ts +15 -0
  127. package/dist/types/src/model/appearance.d.ts +209 -0
  128. package/dist/types/src/model/bounds.d.ts +19 -0
  129. package/dist/types/src/model/camera.d.ts +21 -0
  130. package/dist/types/src/model/candidates.d.ts +53 -0
  131. package/dist/types/src/model/colors.d.ts +22 -0
  132. package/dist/types/src/model/document.d.ts +24 -0
  133. package/dist/types/src/model/edits.d.ts +133 -0
  134. package/dist/types/src/model/embed.d.ts +17 -0
  135. package/dist/types/src/model/examples.d.ts +15 -0
  136. package/dist/types/src/model/font-faces.d.ts +24 -0
  137. package/dist/types/src/model/fonts.d.ts +47 -0
  138. package/dist/types/src/model/footnote.d.ts +34 -0
  139. package/dist/types/src/model/frame.d.ts +71 -0
  140. package/dist/types/src/model/geometry.d.ts +29 -0
  141. package/dist/types/src/model/graph.d.ts +53 -0
  142. package/dist/types/src/model/heading.d.ts +38 -0
  143. package/dist/types/src/model/icons.d.ts +2 -0
  144. package/dist/types/src/model/label-hits.d.ts +27 -0
  145. package/dist/types/src/model/labels.d.ts +88 -0
  146. package/dist/types/src/model/legend.d.ts +25 -0
  147. package/dist/types/src/model/link.d.ts +63 -0
  148. package/dist/types/src/model/markers.d.ts +47 -0
  149. package/dist/types/src/model/note.d.ts +75 -0
  150. package/dist/types/src/model/panels.d.ts +11 -0
  151. package/dist/types/src/model/rich-text.d.ts +24 -0
  152. package/dist/types/src/model/routes.d.ts +170 -0
  153. package/dist/types/src/model/samples.d.ts +11 -0
  154. package/dist/types/src/model/stack.d.ts +8 -0
  155. package/dist/types/src/model/static-scene.d.ts +15 -0
  156. package/dist/types/src/model/status.d.ts +84 -0
  157. package/dist/types/src/model/styles.d.ts +13 -0
  158. package/dist/types/src/model/surface.d.ts +31 -0
  159. package/dist/types/src/model/types.d.ts +277 -0
  160. package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
  161. package/dist/types/src/server/file-session.d.ts +19 -0
  162. package/dist/types/src/server/workspace.d.ts +21 -0
  163. package/dist/types/src/state/active-session.d.ts +479 -0
  164. package/dist/types/src/state/commands.d.ts +529 -0
  165. package/dist/types/src/state/comparison.d.ts +151 -0
  166. package/dist/types/src/state/files.d.ts +61 -0
  167. package/dist/types/src/state/keyboard.d.ts +6 -0
  168. package/dist/types/src/state/keys.d.ts +5 -0
  169. package/dist/types/src/state/launch.d.ts +61 -0
  170. package/dist/types/src/state/links.d.ts +11 -0
  171. package/dist/types/src/state/session/actions.d.ts +77 -0
  172. package/dist/types/src/state/session/canvas-text.d.ts +24 -0
  173. package/dist/types/src/state/session/document.d.ts +84 -0
  174. package/dist/types/src/state/session/editor.d.ts +81 -0
  175. package/dist/types/src/state/session/emphasis.d.ts +11 -0
  176. package/dist/types/src/state/session/file-session.d.ts +98 -0
  177. package/dist/types/src/state/session/index.d.ts +496 -0
  178. package/dist/types/src/state/session/layout.d.ts +79 -0
  179. package/dist/types/src/state/session/pointer.d.ts +19 -0
  180. package/dist/types/src/state/session/routing.d.ts +20 -0
  181. package/dist/types/src/state/session/scene.d.ts +144 -0
  182. package/dist/types/src/state/session/sculpt.d.ts +70 -0
  183. package/dist/types/src/state/toast.d.ts +14 -0
  184. package/dist/types/src/state/ui.d.ts +39 -0
  185. package/package.json +41 -3
@@ -0,0 +1,162 @@
1
+ import { type ResolvedAppearance } from '../model/appearance';
2
+ import type { CellsChrome, Lane, SequenceLayout } from '../model/types';
3
+ import { GROUP_HEADER, GROUP_INSET, contentOrigin } from './frame';
4
+ import { type Model, type ModelEdge, type ModelLayout, type ModelObject } from './syntax';
5
+ /** The single render context. Browser window size changes the camera, never the layout. */
6
+ export declare const RENDER_CONTEXT: {
7
+ readonly width: 1100;
8
+ readonly height: 720;
9
+ };
10
+ export { GROUP_HEADER, GROUP_INSET, contentOrigin };
11
+ export interface SceneObject extends ModelObject {
12
+ /** World (diagram) coordinates. */
13
+ x: number;
14
+ y: number;
15
+ w: number;
16
+ h: number;
17
+ /** Position relative to the parent's content origin; `pin` and `stay` use these. */
18
+ localX: number;
19
+ localY: number;
20
+ /** Local position from the automatic recipe alone, before refinements; `nudge` offsets this. */
21
+ baseX: number;
22
+ baseY: number;
23
+ depth: number;
24
+ /** Sequence participants: how far the dashed lifeline runs below the box. */
25
+ lifeline?: number;
26
+ /** Soft groups: the tint's rectangles, relative to the group's top left; the first holds the label. */
27
+ hull?: Array<{
28
+ x: number;
29
+ y: number;
30
+ w: number;
31
+ h: number;
32
+ }>;
33
+ /** Groups: lines the title wraps to, when more than one. */
34
+ titleLines?: number;
35
+ }
36
+ export interface Diagnostic {
37
+ level: 'error' | 'warning' | 'info';
38
+ code: string;
39
+ message: string;
40
+ /** Source line of the rule involved, when there is one. */
41
+ line?: number;
42
+ ids: string[];
43
+ }
44
+ /** A connection as the file declares it, plus the lane a fold's wrap edge returns along. */
45
+ export interface SceneEdge extends ModelEdge {
46
+ lane?: Lane;
47
+ /** A sequence message: the height of its row; it is drawn straight between lifelines there. */
48
+ row?: number;
49
+ }
50
+ export interface Scene {
51
+ model: Model;
52
+ title: string;
53
+ objects: SceneObject[];
54
+ byId: Map<string, SceneObject>;
55
+ edges: SceneEdge[];
56
+ diagnostics: Diagnostic[];
57
+ /** The file's resolved appearance: the spacing and type every size above was computed with. */
58
+ look: ResolvedAppearance;
59
+ /** Rulers and run-on pieces of byte and bit layouts, by group. */
60
+ cells: Map<string, CellsChrome>;
61
+ /** Sequence diagrams: the panel they are drawn on and their phases' row bands. */
62
+ sequence?: SequenceLayout;
63
+ }
64
+ type Size = {
65
+ w: number;
66
+ h: number;
67
+ };
68
+ type Pos = {
69
+ x: number;
70
+ y: number;
71
+ };
72
+ export declare function compile(source: string): Promise<Scene>;
73
+ /**
74
+ * Check source synchronously: every error `compile` can report, without running layout engines
75
+ * (they never add errors). Engine-governed scopes keep their built-in recipe in the result.
76
+ */
77
+ export declare function checkSource(source: string): Scene;
78
+ /**
79
+ * The scene as layout sees it, for edits that write positions: soft and frameless groups left
80
+ * out, and each object under the container that lays it out, which its local position is
81
+ * relative to.
82
+ */
83
+ export declare function layoutView(scene: Scene): Scene;
84
+ /** How far a soft refinement may give way before `check` warns that it no longer holds. */
85
+ export declare const RELAXED_WARNING = 16;
86
+ /** Solver budget for engine recipes; the same budget Compare and the timeline use. */
87
+ export declare const ENGINE_ITERATIONS = 640;
88
+ /** A labelled edge between two siblings, with the room its label needs across and down a gap. */
89
+ interface LabelRoom {
90
+ a: string;
91
+ b: string;
92
+ w: number;
93
+ h: number;
94
+ }
95
+ export declare function layoutFor(m: Model, scope: string): ModelLayout;
96
+ /**
97
+ * Size of a node: its requested size, or the default width with a height that fits the title in
98
+ * the theme's type and padding. A requested size is kept exactly; `overflow` reports a title that
99
+ * no longer fits in it.
100
+ */
101
+ export declare function leafSize(o: ModelObject, size: {
102
+ width: number;
103
+ height?: number;
104
+ } | undefined, look: ResolvedAppearance): {
105
+ w: number;
106
+ h: number;
107
+ overflow: boolean;
108
+ };
109
+ /**
110
+ * Longest-path ranks, in declaration order. Cycles are broken first: a depth-first walk from the
111
+ * sources (then any node not yet reached), in declaration order, sets aside each edge that returns
112
+ * to a node still on the walk. A loop therefore keeps its path along the reading direction and
113
+ * only its return edge runs backwards.
114
+ */
115
+ export declare function rankLayers(ids: string[], pairs: Array<[string, string]>): string[][];
116
+ /** A folded run: each band's ids in reading order, and the axis the bands read along. */
117
+ export interface Fold {
118
+ bands: string[][];
119
+ axis: 'right' | 'down';
120
+ }
121
+ /**
122
+ * Fold a long run of ranks into bands, like lines of text: each band starts again at the
123
+ * beginning of the reading direction, and the bands stack across it. A run that is longer than
124
+ * the render context and more than `FOLD_ASPECT` times its depth is cut only between ranks (where
125
+ * no box spans the cut), into the fewest bands that bring it within both. Within a quarter of an
126
+ * even share, a cut is chosen for the fewest edges across it, keeping each decision with its
127
+ * branches and each loop whole, before an exact balance. Other runs are returned unchanged.
128
+ *
129
+ * `plan` is the same run laid out without its edge labels. Whether to fold, how many bands and
130
+ * where to cut are decided on it, so relabelling an edge never adds a band or moves a cut: the
131
+ * labels only widen the gaps they need inside their own band.
132
+ */
133
+ export declare function foldRanks(items: Array<{
134
+ id: string;
135
+ w: number;
136
+ h: number;
137
+ }>, positions: Map<string, Pos>, axis: 'right' | 'down', gap: number, pairs: Array<[string, string]>, rooms?: LabelRoom[], decisions?: Set<string>, plan?: Map<string, Pos>, { aspect, fewest, room, }?: {
138
+ aspect?: number;
139
+ fewest?: number;
140
+ room?: number;
141
+ }): {
142
+ positions: Map<string, Pos>;
143
+ fold?: Fold;
144
+ };
145
+ /** How many times orthogonal paths, given as points along and across, cross one another. */
146
+ export declare function crossings(paths: Array<Array<{
147
+ u: number;
148
+ v: number;
149
+ }>>): number;
150
+ /** The order of up to six items that scores fewest crossings; the first such, from `items`. */
151
+ export declare function fewestCrossings<T>(items: T[], score: (order: T[]) => number): T[];
152
+ /**
153
+ * Lay out a model. `arranged` holds world positions from layout engines; scopes that an engine
154
+ * governs take their children's relative placement from it instead of their built-in recipe.
155
+ *
156
+ * Nodes are laid out on slots: their size in the reference appearance (the default theme, with
157
+ * the file's own overrides), so a theme switch keeps rows, order and positions. Each node is drawn
158
+ * at its theme's size in its slot. A slot grows only where the theme's size is larger
159
+ * than the scope's gap can absorb (`SLOT_SPILL`), or where spilling would bring two boxes closer
160
+ * than `MIN_GAP`. With `slots`, objects come out at their slot size (the engines' input).
161
+ */
162
+ export declare function layoutModel(m: Model, arranged?: Map<string, Pos & Size>, slots?: boolean): Scene;
@@ -0,0 +1,38 @@
1
+ /** Group frame metrics shared by the compiler, the projection and the translator. */
2
+ /** Space between a group's frame and its content, on the sides and bottom. */
3
+ export declare const GROUP_INSET = 24;
4
+ /**
5
+ * Space between a group's top edge and its content in the default theme; the title sits in it.
6
+ * Themes with taller titles reserve more (`ResolvedAppearance.groupHeader`).
7
+ */
8
+ export declare const GROUP_HEADER = 48;
9
+ /**
10
+ * Horizontal room a group title needs besides its text: the icon and gap before it (33) and the
11
+ * frame controls after it (64), as `GroupView` and the SVG export truncate titles.
12
+ */
13
+ export declare const GROUP_TITLE_CHROME: number;
14
+ /** Room a soft group's tint leaves round its members, and above them for its label. */
15
+ export declare const SOFT_PAD = 10;
16
+ export declare const SOFT_LABEL = 18;
17
+ /** Where a soft group's label sits in its tint: in the annotation face, at the top left. */
18
+ export declare const SOFT_TITLE: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ /** Corner radius of each rectangle of a tint; small, so joined rectangles read as one shape. */
23
+ export declare const SOFT_RADIUS = 6;
24
+ /** Dash of a sequence participant's lifeline; quieter than a message line. */
25
+ export declare const LIFELINE: {
26
+ dash: string;
27
+ width: number;
28
+ };
29
+ /** Top-left of a group's content area, which its children's local positions are relative to. */
30
+ export declare const contentOrigin: (group: {
31
+ x: number;
32
+ y: number;
33
+ }, header?: number) => {
34
+ x: number;
35
+ y: number;
36
+ };
37
+ /** Horizontal room a `cells` group's title needs besides its text: padding and the collapse control. */
38
+ export declare const CELLS_TITLE_CHROME: number;
@@ -0,0 +1,23 @@
1
+ import type { Lane } from '../model/types';
2
+ import type { ModelEdge } from './syntax';
3
+ interface Box {
4
+ id: string;
5
+ type: string;
6
+ shape?: string;
7
+ parent: string;
8
+ x: number;
9
+ y: number;
10
+ w: number;
11
+ h: number;
12
+ }
13
+ /** A scope arranged along a reading axis, with its fold's bands when it folded. */
14
+ export interface FlowScope {
15
+ scope: string;
16
+ axis: 'right' | 'down';
17
+ bands?: string[][];
18
+ }
19
+ export declare function returnLanes(flows: FlowScope[], edges: ModelEdge[], byId: Map<string, Box>, taken: Set<string>, labelSize?: (label: string) => {
20
+ w: number;
21
+ h: number;
22
+ }): Map<string, Lane>;
23
+ export {};
@@ -0,0 +1,58 @@
1
+ import type { Diagram, LayoutSettings, RoutingSettings } from '../model/types';
2
+ import { type Scene } from './compile';
3
+ import { type Fit, type SourceDoc, type Statement, type Word } from './syntax';
4
+ export declare class UnstorableLayout extends Error {
5
+ }
6
+ /** The `layout` attributes for engine settings: the engine's own controls that differ from the defaults. */
7
+ export declare function engineAttrs(settings: LayoutSettings): Array<[string, Word]>;
8
+ /** The `layout` line a scope would get for these settings, or the reason it cannot. */
9
+ export declare function recipeText(scope: string, settings: LayoutSettings): string;
10
+ /** The scope's current `layout` line in `source`, or null when it uses the default recipe. */
11
+ export declare function currentRecipe(source: string, scope: string): string | null;
12
+ /** What a scope's `layout` line says about the drawing, as the Arrange panel shows it. */
13
+ export interface LayoutShape {
14
+ /** The built-in recipe, or the engine when the line names one. */
15
+ recipe: string;
16
+ engine: boolean;
17
+ direction: 'auto' | 'right' | 'down';
18
+ fit: Fit | null;
19
+ gap: number | null;
20
+ fold: 'auto' | 'never';
21
+ }
22
+ export type ShapeChange = Partial<Pick<LayoutShape, 'direction' | 'fit' | 'gap' | 'fold'>> & {
23
+ /** Drop an engine for the scope's built-in recipe, keeping what the author said of the result. */
24
+ builtin?: boolean;
25
+ };
26
+ /** Read a scope's layout line. A scope without one uses the built-in recipe. */
27
+ export declare function layoutShape(source: string, scope: string): LayoutShape;
28
+ /**
29
+ * Change what a scope's `layout` line says, keeping its recipe or engine. A `row` or `column`
30
+ * states its direction by name, so it swaps with the other. Soft refinements inside the scope are
31
+ * removed so the new shape shows; the count is returned. With no change, that is all it does.
32
+ */
33
+ export declare function setLayoutShape(source: SourceDoc, scene: Scene, scope: string, change: ShapeChange): number;
34
+ /**
35
+ * Arrange `scope` with the engine in `settings`. Its `layout` line is replaced, keeping what the
36
+ * author said about the result: `fit`, `min-width`, `min-height` and `direction`, unless
37
+ * `direction` asks for another. Soft position refinements inside it are removed so the engine's
38
+ * arrangement shows. Pins, sizes and nested `layout` lines stay. Returns the number of
39
+ * refinements removed.
40
+ */
41
+ export declare function setLayoutRecipe(source: SourceDoc, scene: Scene, scope: string, settings: LayoutSettings, direction?: 'right' | 'down'): number;
42
+ /** The `routing` statement for router settings, or null when they are all defaults. */
43
+ export declare function routingStatement(routing: RoutingSettings): Statement | null;
44
+ /** Replace the file's router settings. Defaults are left out; all defaults removes the line. */
45
+ export declare function setRouting(source: SourceDoc, routing: RoutingSettings): void;
46
+ /** Why the position tools stop in a sequence. */
47
+ export declare const LANES_HOLD = "A sequence keeps its lanes and rows, so layout tools have nothing to move.";
48
+ /**
49
+ * Save a drawing that a layout pass, a timeline step or the brush produced. Such results depend
50
+ * on the drawing they started from, so they cannot be recomputed from a recipe; instead each
51
+ * object that moved gets a soft `stay` at its new position, relative to its parent.
52
+ *
53
+ * Groups are fitted to their contents first, as the compiler sizes them, so a group whose
54
+ * children moved left or up moves with them instead of clipping them. Pinned objects never move.
55
+ * Returns the ids that were given a position. A sequence draws from its lanes and rows, so it
56
+ * takes no positions.
57
+ */
58
+ export declare function writeArrangement(source: SourceDoc, drawn: Scene, after: Diagram): string[];
@@ -0,0 +1,3 @@
1
+ import type { Diagnostic } from './compile';
2
+ import type { Model } from './syntax';
3
+ export declare function legendNotes(m: Model): Diagnostic[];
@@ -0,0 +1,39 @@
1
+ import type { Diagram, Rect } from '../model/types';
2
+ import type { Scene } from './compile';
3
+ /** Editor state that is not part of the source and survives a reprojection. */
4
+ export type ViewState = Partial<Pick<Diagram, 'settings' | 'camera' | 'theme' | 'collapsed'>>;
5
+ export declare function projectScene(scene: Scene, view?: ViewState): Diagram;
6
+ export interface CanonicalGeometry {
7
+ nodes: Array<{
8
+ id: string;
9
+ parent: string;
10
+ x: number;
11
+ y: number;
12
+ w: number;
13
+ h: number;
14
+ }>;
15
+ routes: Array<{
16
+ id: string;
17
+ points: Array<{
18
+ x: number;
19
+ y: number;
20
+ }>;
21
+ }>;
22
+ }
23
+ /** Rectangles for everything visible, as the canvas draws them. */
24
+ export declare function visibleRects(doc: Diagram): {
25
+ vg: import("../model/graph").VisibleGraph;
26
+ rects: Map<string, Rect>;
27
+ };
28
+ /**
29
+ * Node rectangles and route points for a projected document. Edge label positions are left out:
30
+ * the browser measures label text with real fonts, which Node cannot reproduce.
31
+ */
32
+ export declare function canonicalGeometry(doc: Diagram): CanonicalGeometry;
33
+ export declare function measured(doc: Diagram, rects: Map<string, Rect>, routes: Array<{
34
+ id: string;
35
+ points: Array<{
36
+ x: number;
37
+ y: number;
38
+ }>;
39
+ }>): CanonicalGeometry;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Targeted changes to `.draft` source lines. Each helper changes, adds or removes whole statements
3
+ * so comments and unrelated statements are kept.
4
+ */
5
+ import { bare, quoted, type SourceDoc, type SourceLine, type Statement, type Word } from './syntax';
6
+ export declare const isStatement: (line: SourceLine) => line is Statement;
7
+ export declare const statements: (doc: SourceDoc) => Statement[];
8
+ export declare function statement(command: string, args: Word[], attrs?: Array<[string, Word]>): Statement;
9
+ /** The `node` or `group` declaration of an object. */
10
+ export declare const declaration: (doc: SourceDoc, id: string) => Statement | undefined;
11
+ export declare const edgeStatement: (doc: SourceDoc, id: string) => Statement | undefined;
12
+ export declare const layoutStatement: (doc: SourceDoc, scope: string) => Statement | undefined;
13
+ export declare function getAttr(s: Statement, key: string): Word | undefined;
14
+ /** Set or (with `undefined`) remove an attribute, keeping the order of the others. */
15
+ export declare function setAttr(s: Statement, key: string, value: Word | undefined): void;
16
+ export declare function removeWhere(doc: SourceDoc, test: (s: Statement) => boolean): void;
17
+ /** Insert after the last statement that passes `near`, or at the end of the file. */
18
+ export declare function insertAfter(doc: SourceDoc, s: Statement, near: (s: Statement) => boolean): void;
19
+ /** Add a refinement statement to the refinements section, starting one when there is none. */
20
+ export declare function addRefinement(doc: SourceDoc, s: Statement): void;
21
+ /** Remove the positional refinements (`near`, `nudge`, `stay`, `pin`) for an object. */
22
+ export declare const clearPosition: (doc: SourceDoc, id: string) => void;
23
+ /**
24
+ * Every statement that mentions `id` as an object: refinements, edges and alignment lists. Its
25
+ * messages go with it, and they leave the phases and states that list them.
26
+ */
27
+ export declare function removeReferences(doc: SourceDoc, id: string): void;
28
+ /** Take an object or connection out of every `state` line; drop a line left with no IDs. */
29
+ export declare function removeFromStates(doc: SourceDoc, id: string): void;
30
+ /**
31
+ * Remove a connection and each mention of it, so its `phase`, `state` and `note` lines still
32
+ * compile. A phase left with no messages goes too; a comment on its line stays, on a line of its
33
+ * own.
34
+ */
35
+ export declare function removeEdge(doc: SourceDoc, id: string): void;
36
+ export declare const num: (n: number) => Word;
37
+ export { bare, quoted };