@arqlet/contracts 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/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Benjamin Becker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,18 @@
1
- # Temporary Holding Version
1
+ # @arqlet/contracts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TypeScript types of the Arqlet engine's contracts (`Snapshot`, `Scene`, `ConfigSet`,
4
+ `LayoutOptions`, ...), generated from the Rust types with ts-rs. Types only, no runtime code.
5
+
6
+ ```ts
7
+ import type {Scene, Snapshot} from '@arqlet/contracts';
8
+ ```
9
+
10
+ > **Status: prototype.** The API, the JSON protocol and the snapshot format are
11
+ > provisional and may change in any release.
12
+
13
+ Part of [Arqlet](https://github.com/intentweave/arqlet), an incremental graph-layout
14
+ engine in Rust. See the repository for documentation and the current status.
15
+
16
+ ## License
17
+
18
+ Licensed under either of Apache License, Version 2.0 or MIT license at your option.
@@ -0,0 +1,983 @@
1
+ // Generated by crates/contracts (ts-rs) and bundled by tools/npm-prepack.mjs. Do not edit by hand.
2
+
3
+ /**
4
+ * Provisional annotation shape; the annotation model of section 5 is not implemented yet.
5
+ */
6
+ export type Annotation = { id: string, target: string, text: string,
7
+ /**
8
+ * What the note is about (section 5 of the design). Optional; one of `ANNOTATION_CATEGORIES`.
9
+ */
10
+ category?: string | null,
11
+ /**
12
+ * How much the note matters. Optional; one of `ANNOTATION_SEVERITIES`.
13
+ */
14
+ severity?: string | null, };
15
+
16
+ /**
17
+ * Renderer settings never change graph topology or explicit port contracts.
18
+ */
19
+ export type AppearanceConfig = { showPorts: boolean, };
20
+
21
+ /**
22
+ * One entry of the bounded archive of measured candidates at a publication (metadata only; the snapshot is not kept).
23
+ */
24
+ export type ArchiveSummary = { index: number, strategy: string, key: Array<number>, geometryFingerprint: string, };
25
+
26
+ /**
27
+ * The authored size of one axis of a container (ADR 0010). Absent means content: the extent follows the children,
28
+ * padding and header.
29
+ */
30
+ export type AxisSize = { "min": number } | { "fixed": number };
31
+
32
+ export type BoundaryCrossing = { edgeId: string, containerId: string, ordinal: number, side: PortSide, position: Point, derived: boolean, };
33
+
34
+ export type Bundling = "none" | "complete";
35
+
36
+ /**
37
+ * An explicit bus (`Graph::buses`): edges drawn with one shared trunk. The edges that share an end (all one source,
38
+ * or all one target) leave (enter) that node by one port and share the way to where they branch off.
39
+ */
40
+ export type Bus = { id: string, edges: Array<string>,
41
+ /**
42
+ * What the bus is called in the drawing ("CAN 500 kbit/s"). Placed like an edge label when the options give its size
43
+ * under `edge_labels["bus:<id>"]`; omitted when none.
44
+ */
45
+ label?: string, };
46
+
47
+ export type ConfigSet = { schemaVersion: number, id: string, layout: LayoutConfig, routing: RoutingConfig,
48
+ /**
49
+ * Display preference. Absent means the config set leaves the current display unchanged.
50
+ */
51
+ appearance?: AppearanceConfig | null, };
52
+
53
+ /**
54
+ * The authored size of one container, per axis (ADR 0010). Each axis is content, a minimum or a fixed size.
55
+ */
56
+ export type ContainerSizing = { width?: AxisSize | null, height?: AxisSize | null, };
57
+
58
+ /**
59
+ * The outline a consumer reports for an element it has drawn, in layout units. It is the same description the engine uses
60
+ * for a node's shape: a `rect` with its width and height, or a `circle` with its diameter. The consumer owns colours,
61
+ * borders, icons and content; the engine reads only this geometry.
62
+ */
63
+ export type Contour = { "kind": "rect", width: number, height: number, } | { "kind": "circle", diameter: number, };
64
+
65
+ /**
66
+ * The extra width of the corridor between two neighbouring siblings (see `Snapshot::corridor_gaps`).
67
+ */
68
+ export type CorridorGap = { before: string, after: string, extra: number, };
69
+
70
+ /**
71
+ * Explicit curated geometry in absolute world coordinates.
72
+ */
73
+ export type CuratedScene = {
74
+ /**
75
+ * Node bounds keyed by node id.
76
+ */
77
+ nodes: { [key in string]: Rect },
78
+ /**
79
+ * Route polylines keyed by drawn edge id. Bundle members have no route of their own.
80
+ */
81
+ routes: { [key in string]: Array<Point> },
82
+ /**
83
+ * Ports keyed by port id: where each route end attaches to a node side.
84
+ */
85
+ ports: { [key in string]: PortRecord },
86
+ /**
87
+ * Routes whose node moved and that are not repaired yet. Drawn as provisional connectors; a draft with pending
88
+ * routes is never valid. Saved with the document, so a reopened draft shows the same state.
89
+ */
90
+ pendingRoutes: Array<string>,
91
+ /**
92
+ * Routes the curator has locked: the editor keeps their geometry and never marks them pending. Omitted when empty,
93
+ * so documents without locks keep their hashes.
94
+ */
95
+ lockedRoutes?: Array<string>,
96
+ /**
97
+ * Node sizes the curator has pinned, keyed by node id. The editor keeps a pinned size through resizing. The engine
98
+ * does not honour size pins yet. Omitted when empty.
99
+ */
100
+ sizePins?: { [key in string]: SizePin },
101
+ /**
102
+ * Label positions the curator has moved, keyed by the baseline label id: the top-left corner in world units. The
103
+ * label keeps its measured size. Label boxes are not measured by the metrics yet. Omitted when empty.
104
+ */
105
+ labels?: { [key in string]: Point }, };
106
+
107
+ export type Edge = { id: string, kind: string, source: string, target: string | null, };
108
+
109
+ export type EdgePorts = { edgeId: string, sourcePort: string | null, targetPort: string | null, };
110
+
111
+ /**
112
+ * How the edges of a drawing are drawn. Orthogonal routing is the default; straight segments are an option of their own,
113
+ * usable with any arrangement.
114
+ */
115
+ export type EdgeRouting = "orthogonal" | "straight";
116
+
117
+ /**
118
+ * The work of an edit that laid out and routed only part of the drawing (see `Snapshot::edit_report`).
119
+ */
120
+ export type EditReport = {
121
+ /**
122
+ * Routes that were carried over from the earlier drawing, and routes that were made again.
123
+ */
124
+ routesKept: number, routesRerouted: number,
125
+ /**
126
+ * Routes that run through a node after the edit, and before it.
127
+ */
128
+ routesThroughNodes: number, routesThroughNodesBefore: number,
129
+ /**
130
+ * The local result had more routes through nodes than the drawing before, and the complete layout was taken instead.
131
+ */
132
+ completeFallback?: boolean,
133
+ /**
134
+ * A step of a drag: the result is a preview and may still have routes through nodes; the step that ends the gesture
135
+ * decides (and falls back to the complete layout if it must).
136
+ */
137
+ preview?: boolean,
138
+ /**
139
+ * After a drag in an organic area: the damped steps run to let the other nodes settle (`settle`), the largest distance
140
+ * any node moved in the last step, and whether that was below the threshold. Absent otherwise.
141
+ */
142
+ settle?: Settle | null, };
143
+
144
+ export type GeometryIssue = { kind: string, nodeIds: Array<string>, message: string, };
145
+
146
+ /**
147
+ * A move gesture on one leaf node. `seq` is the last step applied; a step must carry a larger one. `previous` is the pin the
148
+ * node had before the gesture, which a cancel restores.
149
+ */
150
+ export type Gesture = { id: string, seq: bigint, node: string, active: boolean, previous: Point | null,
151
+ /**
152
+ * The pins the other moved nodes had before the gesture; a cancel restores them. Omitted for a single node.
153
+ */
154
+ previousOthers?: { [key in string]: Point | null },
155
+ /**
156
+ * Set only on the copy of the snapshot that the last step of a gesture (the finish or the cancel) continues from, so
157
+ * that the layout repairs that step moderately instead of locally. Never present in a published snapshot.
158
+ */
159
+ ending?: boolean,
160
+ /**
161
+ * Provisional: the position the node had when a gesture on a single-pass drawing began; its steps move only the node,
162
+ * and a cancel puts it back here. Omitted otherwise.
163
+ */
164
+ origin?: Point | null, };
165
+
166
+ /**
167
+ * A graph: the canonical data of a view. Direction and layout strategy are two constraints, each set for the root and for
168
+ * containers and inherited by containers that declare nothing (docs/adr/0003-container-direction-constraints.md).
169
+ */
170
+ export type Graph = { defaultDirection: "lr" | "rl" | "tb" | "bt" | "auto" | Array<"lr" | "rl" | "tb" | "bt">, containerDirections: { [key in string]: "lr" | "rl" | "tb" | "bt" | "auto" | Array<"lr" | "rl" | "tb" | "bt"> }, defaultStrategy?: "none" | "tree" | "radial" | "auto" | Array<"none" | "tree" | "radial">, containerStrategies?: { [key in string]: "none" | "tree" | "radial" | "auto" | Array<"none" | "tree" | "radial"> },
171
+ /**
172
+ * The edge routing of the root and its containers (docs/adr/0005-routing-constraints.md).
173
+ */
174
+ defaultRouting?: "straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus" | "auto" | Array<"straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus">, containerRouting?: { [key in string]: "straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus" | "auto" | Array<"straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus"> }, ports: Array<Port>, edgePorts: Array<EdgePorts>, nodes: Array<Node>, edges: Array<Edge>,
175
+ /**
176
+ * Provisional: explicit buses (ADR 0005): each groups edges drawn on one shared trunk with branches. Membership is never
177
+ * inferred. Omitted when empty, so earlier documents and drawings do not change.
178
+ */
179
+ buses?: Array<Bus>, };
180
+
181
+ export type HybridCriterion = "compact" | "endToEnd";
182
+
183
+ export type Integrity = {
184
+ /**
185
+ * SHA-256 of the canonical JSON of the document without the `integrity` member.
186
+ */
187
+ payloadHash: string, };
188
+
189
+ /**
190
+ * What the user decided about a view, as one value: the part of a snapshot that an undo or a redo restores. It holds the
191
+ * decisions (pins, sizes, shapes, collapsed containers, direction, strategy and routing requirements), never the geometry
192
+ * the layout derived from them. The engine reads it from a snapshot and restores it in one recomputation (`intent`,
193
+ * `restore`); a host keeps a stack of such values and treats them as opaque. Provisional.
194
+ */
195
+ export type Intent = { pins: { [key in string]: Point }, containerSizing: { [key in string]: ContainerSizing }, nodeSizes: { [key in string]: NodeSize }, collapsedIds: Array<string>,
196
+ /**
197
+ * The shape of every node that is not the default rectangle.
198
+ */
199
+ shapes: { [key in string]: NodeShape }, defaultDirection: "lr" | "rl" | "tb" | "bt" | "auto" | Array<"lr" | "rl" | "tb" | "bt">, containerDirections: { [key in string]: "lr" | "rl" | "tb" | "bt" | "auto" | Array<"lr" | "rl" | "tb" | "bt"> }, defaultStrategy: "none" | "tree" | "radial" | "auto" | Array<"none" | "tree" | "radial">, containerStrategies: { [key in string]: "none" | "tree" | "radial" | "auto" | Array<"none" | "tree" | "radial"> }, defaultRouting: "straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus" | "auto" | Array<"straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus">, containerRouting: { [key in string]: "straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus" | "auto" | Array<"straight" | "orthogonal" | "roundedOrthogonal" | "polyline" | "roundedPolyline" | "octilinear" | "curve" | "bus"> },
200
+ /**
201
+ * The ports the graph declares and the edge ends bound to them, which includes those a user placed by hand.
202
+ */
203
+ ports: Array<Port>, edgePorts: Array<EdgePorts>,
204
+ /**
205
+ * Where the user put labels.
206
+ */
207
+ labelPositions: { [key in string]: Point },
208
+ /**
209
+ * The orders the user chose by a drag.
210
+ */
211
+ orderHints?: { [key in string]: OrderHint }, };
212
+
213
+ /**
214
+ * Measured text rectangle. Hosts may supply exact font measurements.
215
+ */
216
+ export type LabelSpec = { text: string, width: number, height: number, };
217
+
218
+ export type LayoutConfig = { algorithm: string, candidates: Array<number>, hybridBy: HybridCriterion, minPortSpacing: number, placementGrid: number, freePlacement: boolean, placementSearch: number, portPlacement: PortPlacement,
219
+ /**
220
+ * Experimental flat-region candidate (A4b): nodes placed on the drawing grid of their planar skeleton. Only for
221
+ * flat, biconnected views; off by default and omitted when off.
222
+ */
223
+ flatRegion?: boolean, };
224
+
225
+ /**
226
+ * View configuration. Part of the portable snapshot, so backend and browser compute identically.
227
+ * The default value reproduces the prototype's behavior and is omitted from serialized snapshots.
228
+ */
229
+ export type LayoutOptions = {
230
+ /**
231
+ * Identity of the config set that produced these options (`<presetId>@<version>`). Absent for custom
232
+ * options. Every option change that does not come from a config set clears it (see runtime).
233
+ */
234
+ configId?: string | null, appearance: AppearanceConfig, edgeLabels: { [key in string]: LabelSpec }, portLabels: { [key in string]: LabelSpec },
235
+ /**
236
+ * Ordering strategies to evaluate, by mode number 1..=4 (see layout::CANDIDATES).
237
+ */
238
+ candidates: Array<number>,
239
+ /**
240
+ * Whether the routing-only candidate is evaluated.
241
+ */
242
+ routingCandidate: boolean, objectives: Array<Objective>, bundling: Bundling, hybridBy: HybridCriterion,
243
+ /**
244
+ * Measured leaf sizes reported by the visualization. Absent nodes use the default size.
245
+ */
246
+ nodeSizes: { [key in string]: NodeSize },
247
+ /**
248
+ * The revision of the latest geometry measurement applied to each element (see `Measurement`). A measurement with
249
+ * an older revision is refused. Omitted when empty, so default output does not change.
250
+ */
251
+ geometryRevisions?: { [key in string]: bigint },
252
+ /**
253
+ * Where the user put labels: the top-left corner in scene coordinates, keyed by the label's id (an edge or a port). A
254
+ * label is placed there while the place is free and reported as a routing issue otherwise. Omitted when empty.
255
+ */
256
+ labelPositions?: { [key in string]: Point },
257
+ /**
258
+ * Rows of leaf nodes (ADR 0011). A node with rows takes its size from them instead of from `node_sizes`.
259
+ */
260
+ nodeRows?: { [key in string]: Array<Row> },
261
+ /**
262
+ * Extra room, in layout units, for an edge that leaves a node and returns to it. Zero keeps the standard loop.
263
+ */
264
+ selfLoopClearance?: number,
265
+ /**
266
+ * How row ports on one row and side are placed (ADR 0011). The default `peer` is omitted from the output.
267
+ */
268
+ rowPortOrder?: RowPortOrder,
269
+ /**
270
+ * Minimum distance between neighbouring ports on one node side. Zero keeps the prototype sizing.
271
+ * When set, leaf sizes grow until every side has room for its ports.
272
+ */
273
+ minPortSpacing: number,
274
+ /**
275
+ * Placement grid for leaf sizes and positions. Zero means free placement.
276
+ */
277
+ placementGrid: number,
278
+ /**
279
+ * Where automatic ports sit along their side (see `PortPlacement`).
280
+ */
281
+ portPlacement?: PortPlacement,
282
+ /**
283
+ * Experimental flat-region candidate (A4b); see `LayoutConfig::flat_region`.
284
+ */
285
+ flatRegion?: boolean,
286
+ /**
287
+ * Experimental (P1): the channel router's later rounds also re-route edges whose routes cross another route or
288
+ * hug a node margin, and refinement adds a candidate that uses this wider selection. Off, nothing changes.
289
+ */
290
+ extendedConflictSelection?: boolean,
291
+ /**
292
+ * Minimum distance between routes and nodes they do not attach to. Zero keeps the prototype.
293
+ */
294
+ routingClearance: number,
295
+ /**
296
+ * Experimental: routes never enter the clearance band of a foreign node (channel engine). Edges that cannot be
297
+ * routed that way fall back to a direct line, which the routing issues report when it passes through a node.
298
+ * Omitted when off.
299
+ */
300
+ strictClearance?: boolean,
301
+ /**
302
+ * Places each weakly connected component of a container's children as its own block along the cross axis of every
303
+ * level, ordering components separately. The portfolio also tries the unpacked layout, and the published key
304
+ * decides between them. Omitted when off, so the default output does not change.
305
+ */
306
+ componentPacking?: boolean,
307
+ /**
308
+ * How edges are drawn: orthogonal routes (the default, omitted) or straight segments between the port positions.
309
+ * Straight routing never bends: an edge that would cross a foreign node is reported as a routing issue.
310
+ */
311
+ edgeRouting?: EdgeRouting | null,
312
+ /**
313
+ * Force-directed behaviour of organic areas: a layout that continues an earlier one does not hold the nodes where they
314
+ * are but relaxes the stress for a few steps from their positions. A node that is pinned (or is being dragged) is held,
315
+ * the others follow it like on springs, and a node that is let go settles. Omitted when off, so the default output does
316
+ * not change.
317
+ */
318
+ forceDirected?: boolean,
319
+ /**
320
+ * Iteration budget of the organic (stress) placement. Omitted when unset; the default is 300.
321
+ */
322
+ organicIterations?: number | null,
323
+ /**
324
+ * Experimental minimum-displacement overlap constraints for organic placement and repair. Off by default.
325
+ */
326
+ vpscOverlapRemoval?: boolean,
327
+ /**
328
+ * Experimental conflict-directed organic repair, with the exhaustive search as a fallback. Off by default.
329
+ */
330
+ directedRepair?: boolean,
331
+ /**
332
+ * Experimental bounded repulsion from projected edge chords at the end of organic stress. Off by default.
333
+ */
334
+ nodeEdgeRepulsion?: boolean,
335
+ /**
336
+ * Experimental sparse stress for organic placement: exact targets for graph neighbours and pivots instead of the full
337
+ * distance matrix, so an area may hold more children than the dense bound. Off by default.
338
+ */
339
+ sparseStress?: boolean,
340
+ /**
341
+ * Experimental scalable organic placement: pivot initialization, sparse stress whose pivot terms are weighted by the pivot
342
+ * regions (Ortmann, Klimenta and Brandes, GD 2016), then rounds that alternate a stress step with a separation of
343
+ * overlapping boxes. An area may hold up to `SCALABLE_MAX_NODES` children. Off by default; takes precedence over
344
+ * `sparseStress`.
345
+ */
346
+ scalableStress?: boolean,
347
+ /**
348
+ * Experimental size-aware stress targets for organic placement: a pair's target length adds the half-extents of both
349
+ * children, so large nodes are kept apart by the stress itself. Off by default.
350
+ */
351
+ sizeAwareStress?: boolean,
352
+ /**
353
+ * Use the hierarchical layered pipeline where the graph's area modes support it. Set false to use the previous
354
+ * layered layout for comparison. The pipeline does not change explicit tree, radial or organic area strategies.
355
+ */
356
+ layeredConstruction?: boolean,
357
+ /**
358
+ * Provisional opt-in complete abstract routing after placement, instead of the
359
+ * legacy constructor/probe loop. Requires a uniformly positive-flow layered
360
+ * hierarchy, default orthogonal routing, no bundling, pins or fixed sizes.
361
+ * Unsupported requests fail explicitly. Refinement keeps its incumbent and
362
+ * existing candidate portfolio; this option is not output-equivalent.
363
+ * On by default since engine 0.2, with `single_pass` and `single_pass_auto` (ADR 0016); written as `false` when a layout
364
+ * fell back to the other pipeline.
365
+ */
366
+ abstractRouting?: boolean,
367
+ /**
368
+ * Provisional opt-in (requires `abstract_routing`): construct once and do not correct afterwards. Abstract
369
+ * completion keeps plan, growth and construction, but draws edges the constructor delegates with their simple
370
+ * port-to-port seed route instead of searching or repairing them, and counts them in the layout diagnostics.
371
+ * The hierarchical order is chosen after the backward-edge border correction, and the placement keeps the border
372
+ * ranks it chose. Refinement plans no candidates. On by default since engine 0.2 (ADR 0016), accepted by its quality gate;
373
+ * written as `false` when a layout fell back to the other pipeline.
374
+ */
375
+ singlePass?: boolean,
376
+ /**
377
+ * Use single pass where it works, and the other pipeline, with a diagnostic, where it fails: on by default since engine
378
+ * 0.2 (ADR 0016; omitted when on, written as `false` when off). An import or a `configure` with this option on turns on
379
+ * `abstract_routing` and `single_pass`. A layout that fails with them turns them off, so these two options say which
380
+ * pipeline made the drawing, and later edits and the refinement stay on it until the next import or `configure`, which
381
+ * keeps an edit from changing pipeline twice.
382
+ */
383
+ singlePassAuto?: boolean,
384
+ /**
385
+ * Provisional, for measurement: the seed of the shuffled starts of the hierarchical order (runs from the fourth on).
386
+ * 0 (the default, omitted) keeps the order that was used before the option existed. Quality gates average over seeds
387
+ * (ADR 0016); a drawing made with one seed is as valid as with any other.
388
+ */
389
+ orderSeed?: number,
390
+ /**
391
+ * Experimental (plan section 4a, global layering, iteration 1): the most visible nodes the first view of an import lays
392
+ * out. Containers are collapsed to stay within it, the outermost first, and expanded level by level while it holds.
393
+ * 0 (the default, omitted) lays out every node.
394
+ */
395
+ visibleNodeBudget?: number,
396
+ /**
397
+ * Experimental (plan section 4a, global layering, iteration 2; needs `layered_construction`): in a layered area with a
398
+ * fixed flow, an expanded child container of the same flow axis takes part with its children in the area's ranks, as
399
+ * a contiguous block, instead of being laid out on its own. Off by default; omitted when off.
400
+ */
401
+ globalLayering?: boolean,
402
+ /**
403
+ * Find a shared order for hierarchical areas and route through their planned sections. Enabled with the default
404
+ * layered pipeline; set false to compare against the earlier per-area ordering.
405
+ */
406
+ hierarchicalOrdering?: boolean,
407
+ /**
408
+ * Experimental (needs `hierarchical_ordering`): the ranks of every layered area minimise the summed spans of its links,
409
+ * weighted by their edges (network simplex), instead of the longest paths. Off by default; omitted when off.
410
+ */
411
+ simplexRanks?: boolean,
412
+ /**
413
+ * Experimental (derived by the runtime, not set by a user): the size a collapsed container takes, estimated from its
414
+ * content (inside out), so that expanding it moves the outer picture little. Omitted when empty.
415
+ */
416
+ collapsedSizes?: { [key in string]: NodeSize },
417
+ /**
418
+ * Optional limit on the drawing's larger extent, in units. Not a constraint the search enforces: when the result
419
+ * spans more, a routing issue reports it (the search is not extent-aware, so this proves nothing about feasibility).
420
+ * Omitted when unset.
421
+ */
422
+ maxExtent?: number | null,
423
+ /**
424
+ * Experimental. Re-routes every ordering candidate before the key compares it, so an ordering's layout competes with
425
+ * its own routing. Off by default; on the benchmark corpus the effect is mixed (see
426
+ * `benchmarks/results/portfolio-coordinator-20261023.md`), so it is not a recommended setting.
427
+ */
428
+ routedCandidates?: boolean,
429
+ /**
430
+ * Authored container sizes by container ID (ADR 0010). An axis without a value follows its content. Omitted when
431
+ * empty, so default documents do not change.
432
+ */
433
+ containerSizing?: { [key in string]: ContainerSizing },
434
+ /**
435
+ * Experimental. The number of archive entries after the incumbent that each get one routing pass after the first
436
+ * stage, in archive order, whether or not they were published. Off (0) by default; the default portfolio is unchanged.
437
+ */
438
+ archiveRefinement?: number,
439
+ /**
440
+ * Spacing between parallel routes. The prototype uses 6.
441
+ */
442
+ trackSpacing: number,
443
+ /**
444
+ * Provisional: the least gap between two neighbours of a rank (across the flow), before label room is added. `None` (the
445
+ * default, omitted) keeps 24.
446
+ */
447
+ nodeSpacing?: number | null,
448
+ /**
449
+ * Provisional: the least gap between two ranks (along the flow), before label room is added and channels widen for their
450
+ * tracks. `None` (the default, omitted) keeps 64.
451
+ */
452
+ layerSpacing?: number | null,
453
+ /**
454
+ * Provisional (single pass): explicit ports on any side. An edge end whose port lies across the flow or on the side
455
+ * against it is constructed through a short lead around its node instead of being left to the fallback router. Off by
456
+ * default (omitted), so default drawings do not change.
457
+ */
458
+ portSides?: boolean,
459
+ /**
460
+ * Provisional (single pass): areas without a fixed flow (organic, tree, radial) and straight routing are allowed in a
461
+ * single-pass layout. Those areas keep their own placement and their edges go to the router that completes single pass;
462
+ * a layered child that grows moves its siblings apart. Off by default (omitted): such graphs use the pipeline before
463
+ * single pass, as before.
464
+ */
465
+ singlePassMixed?: boolean,
466
+ /**
467
+ * The clearance routes keep from nodes, their own nodes included beyond the stub at their port. It is a hard
468
+ * constraint (ADR 0005): the default is `DEFAULT_REQUIRED_CLEARANCE`, so it always applies. An explicit `null` is
469
+ * the opt-out: proximity is then a weighted quality term with the fixed `HUG_MARGIN` (docs/adr/0002-quality-model.md).
470
+ */
471
+ requiredClearance?: number | null,
472
+ /**
473
+ * Experimental: during clearance widening, re-place affected areas and reuse routes whose geometry is unchanged.
474
+ * Candidate selection and geometry validation still use the common rules; off by default.
475
+ */
476
+ incrementalClearanceWidening?: boolean,
477
+ /**
478
+ * Adds corridor centres as candidate tracks for routes.
479
+ */
480
+ routingCorridors: boolean,
481
+ /**
482
+ * Spreads parallel route segments to the track spacing after routing.
483
+ */
484
+ routingTrackSeparation: boolean,
485
+ /**
486
+ * Orthogonal routing engine.
487
+ */
488
+ routingEngine: RoutingEngine,
489
+ /**
490
+ * Lets nodes slide inside their layer towards the centre of their links (free positioning).
491
+ */
492
+ freePlacement: boolean,
493
+ /**
494
+ * Evaluations for the routing-aware placement search during refinement. Zero disables it.
495
+ */
496
+ placementSearch: number,
497
+ /**
498
+ * Node positions fixed by the curator, keyed by leaf node id: the top-left corner relative to the direct
499
+ * parent (the world origin for root nodes). Stored, validated and honoured by placement; the editor offers them
500
+ * as controls. Omitted when empty, so default output does not change.
501
+ */
502
+ pins?: { [key in string]: Point },
503
+ /**
504
+ * Provisional: orders the user chose by a drag in a layered area, keyed by node id. The node stands in its rank right
505
+ * after the named sibling, or first. A hint whose sibling is in another rank has no effect. Omitted when empty.
506
+ */
507
+ orderHints?: { [key in string]: OrderHint }, };
508
+
509
+ /**
510
+ * A layout strategy: a rule about how an area is arranged. `none` is the plain arrangement by direction; `hybrid` and
511
+ * `shortest` choose an orientation per area; `tree` places a tree or forest along the area's direction; `radial` places a
512
+ * tree or forest on rings. Compatible with the values `hybrid` and `shortest` of earlier graphs.
513
+ */
514
+ export type LayoutStrategy = "none" | "shortest" | "tree" | "radial" | "organic";
515
+
516
+ /**
517
+ * A geometry observation for one element: the realized outline and the revision of the measurement. The revision rises with
518
+ * every new measurement of that element, so that an old one is recognised when it arrives late.
519
+ */
520
+ export type Measurement = { contour: Contour, geometryRevision: bigint, };
521
+
522
+ export type Metrics = { version: number, nodes: number, edges: number, width: number, height: number, area: number,
523
+ /**
524
+ * Overlapping node pairs under the same parent.
525
+ */
526
+ siblingOverlaps: number,
527
+ /**
528
+ * Overlapping node pairs under different parents (independent container branches).
529
+ */
530
+ crossBranchOverlaps: number,
531
+ /**
532
+ * (edge, leaf node) pairs where a segment passes through the node interior, including the edge's own endpoint
533
+ * nodes. Containers are not leaves: routes may cross container borders by design.
534
+ */
535
+ lineNodeHits: number,
536
+ /**
537
+ * Edge pairs with an unintended collinear overlap. Overlaps are merged per line before they are measured.
538
+ */
539
+ sharedLinePairs: number, sharedLineLength: number,
540
+ /**
541
+ * Edge pairs with parallel segments closer than the track spacing, not on one line.
542
+ */
543
+ nearParallelPairs: number, nearParallelLength: number,
544
+ /**
545
+ * (edge, foreign leaf node) pairs with a segment within `HUG_MARGIN` of the border, without entering.
546
+ */
547
+ hugPairs: number,
548
+ /**
549
+ * Length of those segments inside the margin band, summed over pairs.
550
+ */
551
+ hugLength: number,
552
+ /**
553
+ * (edge, container) pairs where a segment passes through the interior of a container the edge does not belong to.
554
+ * A foreign container is not a passage corridor (algorithm document, rule 6), so each such pair is a violation.
555
+ */
556
+ containerTraversals: number,
557
+ /**
558
+ * (edge, container) pairs where a segment runs within `HUG_MARGIN` outside a container border that the edge
559
+ * does not belong to. Reported apart from node distance.
560
+ */
561
+ containerHugPairs: number, containerHugLength: number,
562
+ /**
563
+ * Proper crossing points between edges without a common endpoint node.
564
+ */
565
+ crossings: number,
566
+ /**
567
+ * Edge pairs with at least one such crossing point (the engine's routed-crossings unit).
568
+ */
569
+ crossingPairs: number,
570
+ /**
571
+ * Crossing points between edges that share an endpoint node (reported separately).
572
+ */
573
+ sharedEndpointCrossings: number,
574
+ /**
575
+ * Edge pairs with at least one shared-endpoint crossing point.
576
+ */
577
+ sharedEndpointCrossingPairs: number,
578
+ /**
579
+ * A segment endpoint lying on another edge's segment without crossing it.
580
+ */
581
+ touches: number,
582
+ /**
583
+ * Direction changes after removing repeated and collinear points.
584
+ */
585
+ bends: number, bendsMax: number, bendsMean: number, length: number, lengthMean: number, lengthMax: number, };
586
+
587
+ export type Node = { id: string, kind: string, label: string, parentId: string | null,
588
+ /**
589
+ * The outline of the node. `rect` (the default, omitted) uses its size as it is; `square` and `circle` use the larger
590
+ * of its two sizes on both axes. Collision and routing still use the bounding rectangle in this version.
591
+ */
592
+ shape?: NodeShape, };
593
+
594
+ /**
595
+ * The outline of a leaf node (docs/...: step 1 of the shape support). Containers use the same names later.
596
+ */
597
+ export type NodeShape = "rect" | "square" | "circle";
598
+
599
+ export type NodeSize = { width: number, height: number, };
600
+
601
+ /**
602
+ * Quality objectives in priority order. Earlier objectives dominate later ones.
603
+ */
604
+ export type Objective = "siblingOverlaps" | "edgeNodeHits" | "sharedRoutePairs" | "routedCrossings" | "projectedCrossings" | "cost" | "endToEnd" | "nearNodeSegments" | "bends";
605
+
606
+ export type OptimizationReport = { before: Quality, after: Quality, candidatesEvaluated: number, interrupted?: boolean,
607
+ /**
608
+ * A deterministic work budget dropped at least one candidate job or global round.
609
+ */
610
+ workLimited?: boolean,
611
+ /**
612
+ * Why refinement stopped early. Absent when it completed.
613
+ */
614
+ stopReason?: StopReason | null, strategy: string, };
615
+
616
+ /**
617
+ * Where a node stands in its rank, chosen by the user (`LayoutOptions::order_hints`).
618
+ */
619
+ export type OrderHint = {
620
+ /**
621
+ * The sibling it follows; none puts it first.
622
+ */
623
+ after: string | null, };
624
+
625
+ /**
626
+ * A layout orientation: where the ranks run. `Rl` and `Bt` are the mirror images of `Lr` and `Tb`: the same arrangement with
627
+ * the ranks reversed. Edges keep their logical direction in every orientation.
628
+ */
629
+ export type Orientation = "lr" | "rl" | "tb" | "bt";
630
+
631
+ export type PlacedLabel = { id: string, kind: string, text: string, bounds: Rect, };
632
+
633
+ export type Point = { x: number, y: number, };
634
+
635
+ export type Port = { id: string, nodeId: string, side: PortSide, offset: number,
636
+ /**
637
+ * Binds the port to a row of its node (ADR 0011). The port then sits on `side` (left or right) at the middle of the
638
+ * row, and `offset` is not used. Without a row the port is on the node's box, as before.
639
+ */
640
+ row?: string | null, };
641
+
642
+ /**
643
+ * Where automatic ports sit along their node side. `Symmetric` spaces them evenly, in the order of their peers.
644
+ * `Optimized` moves each port to its peer's position along the side (so the route can run straight) and keeps the
645
+ * minimum port spacing; a side without room for that falls back to symmetric. `Angular` orders the ports of a side by
646
+ * the direction of their peers (slope from the node centre), so the port order around a node follows the drawn
647
+ * direction of its neighbours; with a drawing that realises a rotation system, that is the rotation.
648
+ */
649
+ export type PortPlacement = "symmetric" | "optimized" | "angular";
650
+
651
+ /**
652
+ * One port: the attachment of a route end to a node side. `offset` is the fraction of the side length, as the
653
+ * engine places ports. `position` is derived from the node bounds, the side and the offset.
654
+ */
655
+ export type PortRecord = { nodeId: string, side: PortSide, edgeId: string,
656
+ /**
657
+ * "source" or "target": which end of the route this port serves.
658
+ */
659
+ endpoint: string, offset: number, position: Point,
660
+ /**
661
+ * Explicit ports come from the input configuration and cannot be changed by curation.
662
+ */
663
+ explicit: boolean, };
664
+
665
+ export type PortSide = "left" | "right" | "top" | "bottom";
666
+
667
+ /**
668
+ * The typed envelope of a streamed publication. A publication belongs to one job and one input: a host shows it only while the
669
+ * job is the one it waits for and the input is still current, takes the newest, and drops the rest as stale. The archive (the
670
+ * search state) is kept apart from the snapshot that is shown.
671
+ */
672
+ export type PublicationEnvelope = { jobId: string,
673
+ /**
674
+ * Position in the job's publications, starting at 1.
675
+ */
676
+ sequence: number, kind: PublicationKind, strategy: string, key: Array<number>, candidatesEvaluated: number, input: PublicationInput, snapshot: Snapshot, publicationVersion: number, score: PublicationScore, archive: Array<ArchiveSummary>, };
677
+
678
+ /**
679
+ * The input a job read: the graph revision, the layout version it started from, and the canonical options.
680
+ */
681
+ export type PublicationInput = { graphRevision: number, baseLayoutVersion: number, optionsKey: string, };
682
+
683
+ /**
684
+ * What a streamed publication of a refinement job is: a preview (a step of an edit that is not final), the best layout found so
685
+ * far, or the final result of the job.
686
+ */
687
+ export type PublicationKind = "preview" | "best" | "final";
688
+
689
+ /**
690
+ * The measured quality of a publication's snapshot (tiers of the shadow model; see `scene::quality`).
691
+ */
692
+ export type PublicationScore = { qualityVersion: number, hardViolations: number | null, shadowTotal: number | null, };
693
+
694
+ export type Quality = { siblingOverlaps: number, projectedCrossings: number, routedCrossings: number, edgeNodeHits: number, sharedRoutePairs: number, routeLength: number, area: number, movement: number,
695
+ /**
696
+ * Sum of endpoint-center distances over all edges. Computed only when an objective needs it.
697
+ */
698
+ endToEnd?: number,
699
+ /**
700
+ * Direction changes over all drawn routes. Computed only when an objective needs it.
701
+ */
702
+ bends?: number,
703
+ /**
704
+ * Drawn segments that come within the node margin of a foreign node without entering it.
705
+ * Computed only when an objective needs it.
706
+ */
707
+ nearNodeSegments?: number, };
708
+
709
+ export type Rect = { x: number, y: number, width: number, height: number, };
710
+
711
+ export type ReferenceDocument = { format: string, schemaVersion: number, referenceId: string, revision: number, status: Status, input: ReferenceInput,
712
+ /**
713
+ * SHA-256 of the canonical JSON of `input`.
714
+ */
715
+ inputHash: string, baseline: Snapshot, curated: CuratedScene, annotations: Array<Annotation>, validation: ValidationRecord | null, integrity: Integrity, };
716
+
717
+ /**
718
+ * The layout input: what the engine laid out, with the view and options it used.
719
+ */
720
+ export type ReferenceInput = { graph: Graph, collapsedIds: Array<string>, options: LayoutOptions, };
721
+
722
+ /**
723
+ * The outcome of validating a document that passed structural checks.
724
+ */
725
+ export type Report = {
726
+ /**
727
+ * No hard geometric violation, and the stored validation matches the current geometry.
728
+ */
729
+ valid: boolean,
730
+ /**
731
+ * The stored validation record was computed for the current geometry.
732
+ */
733
+ currentValidation: boolean,
734
+ /**
735
+ * Overlaps, route-through-node hits and foreign-container traversals.
736
+ */
737
+ hardViolations: number,
738
+ /**
739
+ * Routes still waiting for repair after a node moved.
740
+ */
741
+ pendingRoutes: number, payloadHash: string, inputHash: string, metrics: Metrics, };
742
+
743
+ export type ResolvedPort = { id: string, nodeId: string, edgeId: string, endpoint: string, side: PortSide, position: Point, explicit: boolean, };
744
+
745
+ export type Route = { id: string, points: Array<Point>,
746
+ /**
747
+ * Number of edges drawn along this route. One unless the route is a bundle leader.
748
+ */
749
+ weight?: number,
750
+ /**
751
+ * Leader edge id when this edge is a bundled member; members are not drawn separately.
752
+ */
753
+ bundle_of?: string | null, };
754
+
755
+ /**
756
+ * A drawn route that passes through a node it must not cross.
757
+ */
758
+ export type RouteConflict = { edgeId: string, nodeId: string, };
759
+
760
+ export type RoutingConfig = { style: string, bundling: Bundling, routingCandidate: boolean, clearance: number, trackSpacing: number, corridors: boolean, trackSeparation: boolean, engine: RoutingEngine, };
761
+
762
+ /**
763
+ * Orthogonal routing engine. `Legacy` is the candidate-track search; `Channel` is the grid router with
764
+ * negotiated congestion (see routing::channel).
765
+ */
766
+ export type RoutingEngine = "legacy" | "channel";
767
+
768
+ /**
769
+ * A row of a leaf node's content (ADR 0011): a piece of the content with its own size, stacked from the top in the order
770
+ * given. The node's size follows from its rows. A row is layout geometry, not a graph node: it takes no part in the
771
+ * arrangement of the diagram.
772
+ */
773
+ export type Row = { id: string,
774
+ /**
775
+ * The text the row shows. The engine does not read it; it is carried to the viewer.
776
+ */
777
+ label: string, width: number, height: number, };
778
+
779
+ /**
780
+ * How row ports that share a row and a side are placed (ADR 0011). `peer` orders them by where their peers lie and spreads
781
+ * them over the row; `middle` puts each at the middle of the row. The default is `peer`.
782
+ */
783
+ export type RowPortOrder = "peer" | "middle";
784
+
785
+ export type Scene = { schemaVersion: number, revision: number, layoutVersion: number, nodes: Array<SceneNode>, routes: Array<SceneRoute>, ports: Array<ResolvedPort>, labels: Array<PlacedLabel>, crossings: Array<BoundaryCrossing>, showPorts: boolean,
786
+ /**
787
+ * What does not hold in the drawing, with every party of it: overlaps and children that do not fit a container, authored
788
+ * sizes below their content, routes through nodes. Omitted when there is none, so a clean drawing is unchanged.
789
+ */
790
+ conflicts?: Array<SceneConflict>,
791
+ /**
792
+ * Explicit buses (ADR 0005), each as its edges' ids, for a renderer and for the shared conflict queries (members of one
793
+ * bus may share lines). Omitted when there is none.
794
+ */
795
+ buses?: Array<Array<string>>,
796
+ /**
797
+ * Where the lines of a bus branch: points at which its drawn routes run off in three or more directions. A renderer marks
798
+ * them as junction dots. Omitted when there is none.
799
+ */
800
+ junctions?: Array<Point>,
801
+ /**
802
+ * Extent of everything drawn, with a 30-unit margin. May start at negative coordinates.
803
+ */
804
+ bounds: Rect, };
805
+
806
+ /**
807
+ * One conflict of the drawing. A renderer marks every node and route it names and shows `reason` for them.
808
+ */
809
+ export type SceneConflict = {
810
+ /**
811
+ * The kind: a geometry issue's kind (`node_overlap`, `container_bounds`, `minimum_gap`, `container-fixed-below-content`, ...)
812
+ * or `route-through-node`.
813
+ */
814
+ kind: string,
815
+ /**
816
+ * The nodes it involves, and the routes (edge IDs).
817
+ */
818
+ nodes: Array<string>, routes: Array<string>, reason: string, };
819
+
820
+ export type SceneNode = {
821
+ /**
822
+ * Absolute bounds in scene coordinates.
823
+ */
824
+ bounds: Rect, container: boolean, aggregate: boolean, collapsed: boolean, invalid: boolean,
825
+ /**
826
+ * The rows of the node's content, top to bottom (empty for a node without rows).
827
+ */
828
+ rows?: Array<SceneRow>, id: string, kind: string, label: string, parentId: string | null,
829
+ /**
830
+ * The outline of the node. `rect` (the default, omitted) uses its size as it is; `square` and `circle` use the larger
831
+ * of its two sizes on both axes. Collision and routing still use the bounding rectangle in this version.
832
+ */
833
+ shape?: NodeShape, };
834
+
835
+ export type SceneRoute = { id: string,
836
+ /**
837
+ * The edge's kind: for a relationship, its type (the verb), drawn as the route's label.
838
+ */
839
+ kind?: string, source: string, target: string, points: Array<Point>, weight: number,
840
+ /**
841
+ * True when the engine reported a structured conflict for this route.
842
+ */
843
+ invalid: boolean,
844
+ /**
845
+ * True when the route is drawn with rounded corners (styles `roundedOrthogonal` and `roundedPolyline`). Its points
846
+ * already contain the arcs, sampled by the engine (`realize`); a renderer draws them as they are. Omitted otherwise.
847
+ */
848
+ rounded?: boolean,
849
+ /**
850
+ * Edges this drawn route stands for (a bundle leader's members). Absent when the route is one edge.
851
+ */
852
+ members?: Array<string>, };
853
+
854
+ /**
855
+ * A row of a node's content, with its absolute bounds (ADR 0011). The viewer draws the content inside it.
856
+ */
857
+ export type SceneRow = { id: string, label: string, bounds: Rect, };
858
+
859
+ /**
860
+ * The outcome of the settling steps after a drag (see `EditReport::settle`).
861
+ */
862
+ export type Settle = { steps: number, residual: number, converged: boolean, };
863
+
864
+ /**
865
+ * A pinned node size, in world units.
866
+ */
867
+ export type SizePin = { width: number, height: number, };
868
+
869
+ export type Snapshot = { labels: Array<PlacedLabel>, routingIssues: Array<string>,
870
+ /**
871
+ * Why the selected layout pipeline fell back from the requested default.
872
+ */
873
+ layoutDiagnostics?: Array<string>,
874
+ /**
875
+ * The corridors the layout widened for the routes that run through them, one entry per pair of neighbouring siblings.
876
+ * A later edit that lays out only part of the drawing starts its areas with these widths instead of from nothing.
877
+ * Omitted when no corridor was widened.
878
+ */
879
+ corridorGaps?: Array<CorridorGap>,
880
+ /**
881
+ * What an edit that laid out only part of the drawing did. Absent for a complete layout, so default output is unchanged.
882
+ */
883
+ editReport?: EditReport | null,
884
+ /**
885
+ * The orientation a free direction (`auto`) chose for each area, keyed by the container's ID (`<root>` for the view). Only areas
886
+ * with a free direction appear; omitted when there are none, so a layout with declared directions is unchanged.
887
+ */
888
+ areaOrientations?: { [key in string]: Orientation },
889
+ /**
890
+ * The strategy the structured optimisation chose for each area whose strategy is not fixed (`auto` or an allowed set), keyed like
891
+ * `area_orientations`. Only a result of the hierarchical composition carries it; a plain layout treats `auto` as `none` and records
892
+ * nothing, so the entry never outlives the drawing it describes.
893
+ */
894
+ areaStrategies?: { [key in string]: LayoutStrategy },
895
+ /**
896
+ * Structured counterpart of the routing diagnostics that name a passed-through node.
897
+ */
898
+ routeConflicts?: Array<RouteConflict>, schemaVersion: number, engineVersion: string, revision: number, layoutVersion: number, baseRevision: number | null, options?: LayoutOptions, graph: Graph, sourceGraph: Graph | null, collapsedIds: Array<string>, boxes: { [key in string]: Rect }, routes: Array<Route>, recomputedContainers: Array<string>, optimization?: OptimizationReport | null, omittedUnresolvedEdges: number, geometryIssues: Array<GeometryIssue>, resolvedPorts: Array<ResolvedPort>, boundaryCrossings: Array<BoundaryCrossing>,
899
+ /**
900
+ * The edges drawn as straight segments (the others are orthogonal). Empty when every edge is orthogonal.
901
+ */
902
+ straightEdges?: Array<string>,
903
+ /**
904
+ * Provisional: where the layout placed every backbone bus (`Graph::buses`) as a virtual node, by that node's id, relative
905
+ * to its parent like `boxes`. The bus is drawn on a line through it; a later layout continues from it. Omitted when the
906
+ * graph has none.
907
+ */
908
+ busBoxes?: { [key in string]: Rect },
909
+ /**
910
+ * The move gesture in progress or the last one finished, for sequence checks. Omitted when there was none.
911
+ */
912
+ gesture?: Gesture | null,
913
+ /**
914
+ * Provisional (experimental option `layeredConstruction`): the derived layout graph of every layered area, by area
915
+ * (`"<root>"` for the top level), kept so that a later pass reuses the plans of the areas it does not place again.
916
+ * Empty (and omitted) without the option.
917
+ */
918
+ layeredPlans?: { [key in string]: StoredAreaPlan }, };
919
+
920
+ export type Status = "draft" | "accepted" | "retired";
921
+
922
+ /**
923
+ * Why refinement stopped before it completed. The work budget is deterministic; the time budget and a cancellation
924
+ * depend on the host.
925
+ */
926
+ export type StopReason = "workBudget" | "timeBudget" | "cancelled";
927
+
928
+ /**
929
+ * Provisional: the derived layout graph of one layered area as stored with a snapshot (see `Snapshot::layered_plans`).
930
+ */
931
+ export type StoredAreaPlan = {
932
+ /**
933
+ * `STORED_PLAN_FORMAT` of the engine that wrote it.
934
+ */
935
+ format: number,
936
+ /**
937
+ * The flow runs along y.
938
+ */
939
+ vertical: boolean,
940
+ /**
941
+ * The flow runs against the axis.
942
+ */
943
+ reversed: boolean,
944
+ /**
945
+ * The ranks in flow order, each in its order across the flow: children of the area, long-edge dummies, border nodes.
946
+ */
947
+ ranks: Array<Array<string>>,
948
+ /**
949
+ * The links between the area's children in flow direction, each with the dummies it passes in order.
950
+ */
951
+ chains: Array<StoredChain>,
952
+ /**
953
+ * The links the cycle break reversed, as source and target of the logical direction.
954
+ */
955
+ reversedLinks?: Array<StoredLink>,
956
+ /**
957
+ * The place of every dummy in the area's frame.
958
+ */
959
+ dummies?: { [key in string]: Rect },
960
+ /**
961
+ * By edge, the border node where the edge crosses this area's border.
962
+ */
963
+ borders?: { [key in string]: string },
964
+ /**
965
+ * Provisional (single pass, ADR 0017): by edge, the side node where an edge leaves or enters this area on a side its
966
+ * parent's flow uses, when the parent's flow runs across this area's.
967
+ */
968
+ sides?: { [key in string]: string }, };
969
+
970
+ /**
971
+ * A link of a stored plan with the dummies it passes (see `StoredAreaPlan::chains`).
972
+ */
973
+ export type StoredChain = { source: string, target: string, dummies?: Array<string>, };
974
+
975
+ /**
976
+ * A link of a stored plan (see `StoredAreaPlan::reversed_links`).
977
+ */
978
+ export type StoredLink = { source: string, target: string, };
979
+
980
+ /**
981
+ * Metrics of the curated geometry, computed by the shared validator.
982
+ */
983
+ export type ValidationRecord = { metrics: Metrics, };
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@arqlet/contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "TypeScript types of Arqlet's engine contracts (Snapshot, Scene, ConfigSet, LayoutOptions, ...), generated from the Rust types. Types only; provisional.",
5
+ "keywords": [
6
+ "graph",
7
+ "layout",
8
+ "graph-layout",
9
+ "diagram",
10
+ "wasm",
11
+ "typescript",
12
+ "types"
13
+ ],
14
+ "license": "(MIT OR Apache-2.0)",
15
+ "author": "Benjamin Becker",
16
+ "homepage": "https://github.com/intentweave/arqlet#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/intentweave/arqlet.git",
20
+ "directory": "packages/contracts"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/intentweave/arqlet/issues"
24
+ },
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts"
30
+ }
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE-APACHE",
39
+ "LICENSE-MIT"
40
+ ],
41
+ "devDependencies": {
42
+ "typescript": "7.0.2"
43
+ },
44
+ "scripts": {
45
+ "generate": "cargo run -q -p arqlet-contracts --bin export-contracts -- src/generated",
46
+ "typecheck": "tsc -p tsconfig.json"
47
+ },
48
+ "types": "./dist/index.d.ts"
6
49
  }