@skygraph/core 0.0.0-placeholder.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/dist/calendar.cjs +404 -0
  3. package/dist/calendar.cjs.map +1 -0
  4. package/dist/calendar.d.cts +209 -0
  5. package/dist/calendar.d.ts +209 -0
  6. package/dist/calendar.js +12 -0
  7. package/dist/calendar.js.map +1 -0
  8. package/dist/chunk-5CCD5Q4B.js +36 -0
  9. package/dist/chunk-5CCD5Q4B.js.map +1 -0
  10. package/dist/chunk-AB3RLBLW.js +357 -0
  11. package/dist/chunk-AB3RLBLW.js.map +1 -0
  12. package/dist/chunk-GEMALROQ.js +258 -0
  13. package/dist/chunk-GEMALROQ.js.map +1 -0
  14. package/dist/chunk-IY6LJU3L.js +256 -0
  15. package/dist/chunk-IY6LJU3L.js.map +1 -0
  16. package/dist/chunk-KMGRNPLG.js +453 -0
  17. package/dist/chunk-KMGRNPLG.js.map +1 -0
  18. package/dist/chunk-KP75DEA4.js +1012 -0
  19. package/dist/chunk-KP75DEA4.js.map +1 -0
  20. package/dist/chunk-Y7FTBBYX.js +397 -0
  21. package/dist/chunk-Y7FTBBYX.js.map +1 -0
  22. package/dist/chunk-ZWB7JGAJ.js +488 -0
  23. package/dist/chunk-ZWB7JGAJ.js.map +1 -0
  24. package/dist/form.cjs +498 -0
  25. package/dist/form.cjs.map +1 -0
  26. package/dist/form.d.cts +130 -0
  27. package/dist/form.d.ts +130 -0
  28. package/dist/form.js +8 -0
  29. package/dist/form.js.map +1 -0
  30. package/dist/graph.cjs +1065 -0
  31. package/dist/graph.cjs.map +1 -0
  32. package/dist/graph.d.cts +542 -0
  33. package/dist/graph.d.ts +542 -0
  34. package/dist/graph.js +24 -0
  35. package/dist/graph.js.map +1 -0
  36. package/dist/index.cjs +3656 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.cts +144 -0
  39. package/dist/index.d.ts +144 -0
  40. package/dist/index.js +467 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/runtime-internal.cjs +339 -0
  43. package/dist/runtime-internal.cjs.map +1 -0
  44. package/dist/runtime-internal.d.cts +130 -0
  45. package/dist/runtime-internal.d.ts +130 -0
  46. package/dist/runtime-internal.js +67 -0
  47. package/dist/runtime-internal.js.map +1 -0
  48. package/dist/table.cjs +537 -0
  49. package/dist/table.cjs.map +1 -0
  50. package/dist/table.d.cts +215 -0
  51. package/dist/table.d.ts +215 -0
  52. package/dist/table.js +16 -0
  53. package/dist/table.js.map +1 -0
  54. package/dist/tree.cjs +442 -0
  55. package/dist/tree.cjs.map +1 -0
  56. package/dist/tree.d.cts +76 -0
  57. package/dist/tree.d.ts +76 -0
  58. package/dist/tree.js +8 -0
  59. package/dist/tree.js.map +1 -0
  60. package/dist/types-B-rKQJ4R.d.cts +35 -0
  61. package/dist/types-B-rKQJ4R.d.ts +35 -0
  62. package/dist/virtual.cjs +283 -0
  63. package/dist/virtual.cjs.map +1 -0
  64. package/dist/virtual.d.cts +96 -0
  65. package/dist/virtual.d.ts +96 -0
  66. package/dist/virtual.js +9 -0
  67. package/dist/virtual.js.map +1 -0
  68. package/package.json +98 -18
  69. package/README.md +0 -12
  70. package/index.js +0 -3
@@ -0,0 +1,542 @@
1
+ import { C as Core } from './types-B-rKQJ4R.js';
2
+
3
+ /**
4
+ * GraphEngine types — the diagram (Visio-like) domain engine.
5
+ *
6
+ * Design intent (see ARCHITECTURE.md / chat-derived spec):
7
+ *
8
+ * - The engine knows ONLY topology + minimal geometry needed for routing /
9
+ * hit-testing. It does NOT know about React, DOM, SVG, canvas — those live
10
+ * in `@skygraph/react/<Diagram component>`.
11
+ * - A Node has an `outline` (rect / ellipse / polygon / flattened path),
12
+ * a `transform` (position in parent space), an optional `parentId` for
13
+ * hierarchy (groups, sub-groups), and an `anchorPolicy` describing how to
14
+ * generate connection points along the outline.
15
+ * - An Edge connects two anchors (each by node id + either an anchor id or
16
+ * a normalized perimeter parameter `s ∈ [0..1]`).
17
+ * - All anchor IDs are stable across `anchorPolicy` changes for the same
18
+ * outline kind, so existing edges do not get "torn off" when the user
19
+ * bumps `k` from 3 to 5.
20
+ */
21
+ type NodeId = string;
22
+ type EdgeId = string;
23
+ type AnchorId = string;
24
+ /**
25
+ * 2D point in the local coordinate space of an outline.
26
+ * The first element is x, the second is y.
27
+ */
28
+ type Point = readonly [number, number];
29
+ /**
30
+ * Axis-aligned bounding box in world space (no rotation).
31
+ * Computed from `transform` + `outline`. Used for broad-phase collision /
32
+ * spatial indexing in the routing layer.
33
+ */
34
+ interface AABB {
35
+ x: number;
36
+ y: number;
37
+ w: number;
38
+ h: number;
39
+ }
40
+ /**
41
+ * Oriented bounding box in world space — a rectangle that may be rotated
42
+ * relative to the world axes. Returned by {@link GraphEngine.getNodeOBB}
43
+ * and consumed by selection / manipulator overlays that need a tight fit
44
+ * around a rotated node. See `obb.ts` for the helper module.
45
+ *
46
+ * `halfWidth` / `halfHeight` are pre-multiplied by world scale, so an OBB
47
+ * with `angle === 0` describes the same rectangle as the matching AABB
48
+ * (modulo the centre-vs-top-left representation).
49
+ */
50
+ interface OBB$1 {
51
+ readonly center: Point;
52
+ readonly halfWidth: number;
53
+ readonly halfHeight: number;
54
+ readonly angle: number;
55
+ }
56
+ /**
57
+ * Visual outline of a node, expressed in the node's local coordinate space.
58
+ *
59
+ * - `rect` / `ellipse` are parametric primitives; the engine generates anchors
60
+ * along their boundary on demand.
61
+ * - `polygon` carries explicit vertices.
62
+ * - `path` is a "flattened approximation" — the visual layer (React) is free
63
+ * to render a curve (SVG path, Bezier, ...) but commits a discrete polyline
64
+ * to the engine. This way the engine never needs to know about cubic Beziers.
65
+ */
66
+ type Outline = {
67
+ readonly kind: 'rect';
68
+ readonly w: number;
69
+ readonly h: number;
70
+ } | {
71
+ readonly kind: 'ellipse';
72
+ readonly rx: number;
73
+ readonly ry: number;
74
+ } | {
75
+ readonly kind: 'polygon';
76
+ readonly verts: readonly Point[];
77
+ } | {
78
+ readonly kind: 'path';
79
+ readonly flatten: readonly Point[];
80
+ };
81
+ /**
82
+ * 2D affine-ish transform of a node within its parent.
83
+ * Only translate is required; rotate/scale are optional for the v0 engine.
84
+ */
85
+ interface NodeTransform {
86
+ /** X position in the parent's local space. */
87
+ x: number;
88
+ /** Y position in the parent's local space. */
89
+ y: number;
90
+ /** Rotation in radians. Optional; default 0. */
91
+ rot?: number;
92
+ /** Uniform scale factor. Optional; default 1. */
93
+ scale?: number;
94
+ }
95
+ /**
96
+ * Strategy for generating anchor points on a node outline.
97
+ *
98
+ * - `perEdge: { k: 1..10 }` — primitives only (rect, polygon).
99
+ * Corners are always anchors. `k` evenly-spaced anchors per edge,
100
+ * not counting corners (open interval) — bumping `k` does NOT shift
101
+ * existing anchor IDs.
102
+ *
103
+ * - `byLength: { density }` — uniform along the perimeter at the given
104
+ * distance step (in local units). Works for every outline kind.
105
+ *
106
+ * - `manual: anchors[]` — explicit anchor list with stable IDs and
107
+ * normalized perimeter parameter `s ∈ [0..1]`.
108
+ */
109
+ type AnchorPolicy = {
110
+ readonly kind: 'perEdge';
111
+ readonly k: number;
112
+ } | {
113
+ readonly kind: 'byLength';
114
+ readonly density: number;
115
+ } | {
116
+ readonly kind: 'manual';
117
+ readonly anchors: readonly {
118
+ id: AnchorId;
119
+ s: number;
120
+ }[];
121
+ };
122
+ /**
123
+ * A point on the outline where edges can attach.
124
+ * `s` is the normalized perimeter parameter (0..1, monotonically increasing
125
+ * around the outline). Persisting an edge endpoint by `s` makes it stable
126
+ * under outline edits / anchor regeneration.
127
+ */
128
+ interface Anchor {
129
+ /** Stable id assigned by the anchor generator (e.g. `nw`, `edge-0:1of3`). */
130
+ id: AnchorId;
131
+ /** Normalized perimeter parameter; `0` is the start of the outline traversal. */
132
+ s: number;
133
+ /** Local coordinates on the outline (x, y). */
134
+ point: Point;
135
+ }
136
+ /**
137
+ * A graph node — building block of the diagram. Can be a "shape" (with a
138
+ * visible outline), a "group" (`outline.kind === 'rect'` with `w=h=0` plus
139
+ * children, or any other size — visual layer decides whether to render
140
+ * border / background), or a leaf widget. The engine itself does NOT
141
+ * distinguish — it only sees outline + transform + children-by-parentId.
142
+ */
143
+ interface GraphNode {
144
+ /** Stable identity; unique within the graph. */
145
+ id: NodeId;
146
+ /** Parent node id, or `null` for root-level nodes. */
147
+ parentId: NodeId | null;
148
+ /** Position / rotation / scale in parent space. */
149
+ transform: NodeTransform;
150
+ /** Local-space outline. */
151
+ outline: Outline;
152
+ /** How anchors are generated along the outline. */
153
+ anchorPolicy: AnchorPolicy;
154
+ /** Optional application payload; the engine never inspects it. */
155
+ data?: unknown;
156
+ /** Monotonic revision; increments on transform / outline / anchorPolicy change. */
157
+ geomRevision: number;
158
+ }
159
+ /**
160
+ * An edge is a connection between two anchors on (possibly different) nodes.
161
+ *
162
+ * `endpoint.anchor` may be:
163
+ * - an `AnchorId` referring to an explicit / generated anchor;
164
+ * - a `{ s }` parameter binding the edge to a perimeter position even when
165
+ * the anchor list is regenerated.
166
+ */
167
+ type EdgeEndpoint = {
168
+ readonly node: NodeId;
169
+ readonly anchor: AnchorId;
170
+ } | {
171
+ readonly node: NodeId;
172
+ readonly anchor: {
173
+ readonly s: number;
174
+ };
175
+ };
176
+ interface GraphEdge {
177
+ /** Stable identity; unique within the graph. */
178
+ id: EdgeId;
179
+ /** Source endpoint. */
180
+ from: EdgeEndpoint;
181
+ /** Target endpoint. */
182
+ to: EdgeEndpoint;
183
+ /**
184
+ * Routing hint:
185
+ * • `straight` — single L line between the two anchors.
186
+ * • `orthogonal` — axis-aligned polyline (right-angled). Combined
187
+ * with `routeAroundNodes` in `<Diagram>` the
188
+ * router avoids other nodes via A*. The visual
189
+ * layer also draws rounded corners.
190
+ * • `bezier` — single cubic Bezier curve. Control handles
191
+ * extend perpendicular to each node's nearest
192
+ * side, matching React Flow's `getBezierPath`.
193
+ * • `manual` — explicit waypoint polyline.
194
+ */
195
+ routing: 'straight' | 'orthogonal' | 'bezier' | 'manual';
196
+ /** Optional waypoints for `manual` routing (in world coordinates). */
197
+ waypoints?: readonly Point[];
198
+ /** Optional application payload. */
199
+ data?: unknown;
200
+ }
201
+ /**
202
+ * Snapshot of the current graph state — read-model the engine exposes.
203
+ * This object is immutable from the consumer's perspective; the engine
204
+ * publishes a new snapshot on every commit by writing into the Core store
205
+ * under the `$graph.` prefix.
206
+ */
207
+ interface GraphState {
208
+ nodes: ReadonlyMap<NodeId, GraphNode>;
209
+ edges: ReadonlyMap<EdgeId, GraphEdge>;
210
+ /** Per-node list of incident edges (incoming + outgoing) for O(degree) lookup. */
211
+ edgesByNode: ReadonlyMap<NodeId, readonly EdgeId[]>;
212
+ }
213
+ /** Patch type for `moveNode` / `updateNode`. */
214
+ interface NodeUpdate {
215
+ transform?: Partial<NodeTransform>;
216
+ outline?: Outline;
217
+ anchorPolicy?: AnchorPolicy;
218
+ data?: unknown;
219
+ }
220
+ /** Options for `addNode`. */
221
+ interface NodeInit {
222
+ /** Optional pre-set id. If omitted, the engine generates one. */
223
+ id?: NodeId;
224
+ /** Parent for hierarchy. `null` (default) places the node at the root. */
225
+ parentId?: NodeId | null;
226
+ /** Transform in parent space. Defaults to `{ x: 0, y: 0 }`. */
227
+ transform?: NodeTransform;
228
+ /** Outline; defaults to a 100×60 rect. */
229
+ outline?: Outline;
230
+ /** Anchor strategy; defaults to `{ kind: 'perEdge', k: 1 }`. */
231
+ anchorPolicy?: AnchorPolicy;
232
+ /** Application payload. */
233
+ data?: unknown;
234
+ }
235
+ /** Options for `addEdge`. */
236
+ interface EdgeInit {
237
+ /** Optional pre-set id. If omitted, the engine generates one. */
238
+ id?: EdgeId;
239
+ from: EdgeEndpoint;
240
+ to: EdgeEndpoint;
241
+ /** Routing strategy. Defaults to `'straight'`. */
242
+ routing?: 'straight' | 'orthogonal' | 'bezier' | 'manual';
243
+ waypoints?: readonly Point[];
244
+ data?: unknown;
245
+ }
246
+ /**
247
+ * Public API of the Graph engine. Created via `createGraph(core, options?)`.
248
+ * The engine is a thin façade over a path-based Core store under `$graph.`.
249
+ */
250
+ interface GraphEngine {
251
+ /** Add a node and return its assigned id. */
252
+ addNode(init?: NodeInit): NodeId;
253
+ /** Remove a node and all edges incident to it. */
254
+ removeNode(id: NodeId): void;
255
+ /** Patch a node's transform / outline / anchorPolicy / data. */
256
+ updateNode(id: NodeId, patch: NodeUpdate): void;
257
+ /** Move a node by an absolute new (x, y) in parent space. */
258
+ moveNode(id: NodeId, x: number, y: number): void;
259
+ /** Re-parent a node (groups / sub-groups). `null` = root. */
260
+ setParent(id: NodeId, parentId: NodeId | null): void;
261
+ /** Add an edge between two endpoints. */
262
+ addEdge(init: EdgeInit): EdgeId;
263
+ /** Remove an edge by id. */
264
+ removeEdge(id: EdgeId): void;
265
+ /** Get a single node (or undefined). */
266
+ getNode(id: NodeId): GraphNode | undefined;
267
+ /** Get a single edge (or undefined). */
268
+ getEdge(id: EdgeId): GraphEdge | undefined;
269
+ /** Snapshot of the entire graph state. */
270
+ getState(): GraphState;
271
+ /** Direct children (immediate parentId match). */
272
+ childrenOf(id: NodeId | null): NodeId[];
273
+ /** Edges incident to a node (incoming + outgoing). */
274
+ edgesOf(id: NodeId): EdgeId[];
275
+ /** Compute anchors for a node according to its `anchorPolicy`. */
276
+ anchorsOf(id: NodeId): Anchor[];
277
+ /** Compute axis-aligned bounding box of a node in world coordinates. */
278
+ boundsOf(id: NodeId): AABB;
279
+ /**
280
+ * Compute the oriented bounding box of a node in world coordinates.
281
+ *
282
+ * For an axis-aligned node (`transform.rot === 0` everywhere up the
283
+ * parent chain) the OBB and AABB describe the same rectangle. When any
284
+ * ancestor has a non-zero rotation, the OBB is the tight fit and
285
+ * `boundsOf` (AABB) becomes a strict superset.
286
+ */
287
+ getNodeOBB(id: NodeId): OBB$1;
288
+ /**
289
+ * Subscribe to commits — callback fires after every snapshot publish
290
+ * (any `addNode`, `removeNode`, `addEdge`, etc.). Returns an unsubscribe fn.
291
+ *
292
+ * Prefer this for React adapters: it sidesteps the `$graph.snapshot.<id>`
293
+ * path lookup that varies per engine instance.
294
+ */
295
+ subscribe(cb: () => void): () => void;
296
+ /** Group multiple mutations into one history entry. Optional `label` is
297
+ * attached to the resulting `HistoryEntry`. */
298
+ transaction(fn: () => void, label?: string): void;
299
+ /**
300
+ * Add a label to the history without changing the visible state.
301
+ *
302
+ * Behaviour depends on context:
303
+ *
304
+ * - **Inside `transaction(fn)`**: commits the in-progress pending
305
+ * entry as a sub-boundary (with `label`) and starts a fresh
306
+ * capture for the rest of the transaction. Use this to split one
307
+ * batch into multiple undo entries.
308
+ *
309
+ * - **Outside a transaction**: re-labels the most recent undo entry.
310
+ * Does NOT push a duplicate snapshot — auto-push has already
311
+ * captured every meaningful boundary, so a standalone push would
312
+ * only clutter the stack.
313
+ */
314
+ pushHistory(label?: string): void;
315
+ /** Restore the previous state, returning `true` if anything was undone. */
316
+ undo(): boolean;
317
+ /** Re-apply the most recently undone state, returning `true` on success. */
318
+ redo(): boolean;
319
+ /** `true` when there is at least one entry on the undo stack. */
320
+ canUndo(): boolean;
321
+ /** `true` when there is at least one entry on the redo stack. */
322
+ canRedo(): boolean;
323
+ /** Drop all undo and redo entries (state itself is not affected). */
324
+ clearHistory(): void;
325
+ /**
326
+ * Reset the graph (drops all nodes / edges, clears history).
327
+ * @internal Test helper.
328
+ */
329
+ clear(): void;
330
+ }
331
+ /** Options accepted by `createGraph`. */
332
+ interface GraphEngineOptions {
333
+ /** Optional debug name for the engine instance. */
334
+ name?: string;
335
+ }
336
+
337
+ /**
338
+ * Reactive diagram engine — the fourth member of the form / table / tree /
339
+ * **graph** family. State is mirrored into the Core store under `$graph.`
340
+ * for cross-engine coordination, but the in-memory maps are the source of
341
+ * truth and the public read API.
342
+ *
343
+ * v0 scope (initial Graph engine stream — see CHANGELOG):
344
+ * - Node / Edge model + parent hierarchy
345
+ * - addNode / removeNode / updateNode / moveNode / setParent
346
+ * - addEdge / removeEdge
347
+ * - anchor generator (perEdge / byLength / manual)
348
+ * - bounds computation (AABB, no rotation)
349
+ * - geomRevision bump on geometry-affecting updates
350
+ *
351
+ * NOT in v0:
352
+ * - orthogonal routing (with obstacle avoidance)
353
+ * - undo / redo (covered separately by `plugins/history`)
354
+ * - snap-to-grid, drag-and-drop palette
355
+ * - rotated bounding boxes (OBB)
356
+ */
357
+ declare function createGraph(core: Core, options?: GraphEngineOptions): GraphEngine;
358
+
359
+ /** Options for {@link routeOrthogonal}. */
360
+ interface RouteOrthogonalOptions {
361
+ /**
362
+ * Bend preference for the no-obstacle case.
363
+ * - `auto` (default) picks H-then-V or V-then-H based on which leg is longer.
364
+ * - `hv` forces horizontal first.
365
+ * - `vh` forces vertical first.
366
+ *
367
+ * Ignored when `obstacles` is non-empty — A* picks bends from costs.
368
+ */
369
+ preferred?: 'auto' | 'hv' | 'vh';
370
+ /**
371
+ * Rectangular obstacles to avoid (in world coordinates). When omitted /
372
+ * empty, the router takes the cheap L-route path.
373
+ */
374
+ obstacles?: readonly AABB[];
375
+ /**
376
+ * Discretisation step for A*. Smaller values give smoother paths at the
377
+ * cost of more search nodes. Default: 10.
378
+ */
379
+ gridSize?: number;
380
+ /**
381
+ * Inflate every obstacle by this margin (world units) before clipping.
382
+ * Useful to keep edges from hugging node borders. Default: 0.
383
+ */
384
+ inflate?: number;
385
+ /**
386
+ * Hard cap on A* expansions. Acts as a safety net so a pathological
387
+ * search never hangs the renderer. Default: 5000.
388
+ */
389
+ maxNodes?: number;
390
+ /**
391
+ * AABB of the source node. When provided, the route exits the side of
392
+ * the rectangle nearest to `end` with a short perpendicular stub. The
393
+ * raw `start` point is kept as the first polyline vertex so the edge
394
+ * still meets the anchor exactly.
395
+ */
396
+ sourceBounds?: AABB;
397
+ /**
398
+ * AABB of the target node. When provided, the route enters the side of
399
+ * the rectangle nearest to `start` with a short perpendicular stub. The
400
+ * raw `end` point is kept as the last polyline vertex.
401
+ */
402
+ targetBounds?: AABB;
403
+ /**
404
+ * Length (world units) of the perpendicular stub generated when
405
+ * `sourceBounds` / `targetBounds` is set. Defaults to `max(8, gridSize)`.
406
+ */
407
+ stubLength?: number;
408
+ /**
409
+ * Snap intermediate waypoints to a grid of this step. Defaults to the
410
+ * effective `gridSize`. Set to `0` to disable snapping in the no-
411
+ * obstacle path. A* already operates on the grid so this option only
412
+ * affects the L-route fallback.
413
+ */
414
+ snap?: number;
415
+ }
416
+ /**
417
+ * Compute an orthogonal (right-angled) path between two points.
418
+ *
419
+ * - With no `sourceBounds` / `targetBounds` and no obstacles: a single-
420
+ * bend L-route, identical to the v0 implementation.
421
+ * - With `sourceBounds` / `targetBounds`: the route exits/enters from
422
+ * the side of each rectangle nearest to the other endpoint.
423
+ * - With obstacles: 4-connected A* on a grid of step `gridSize`. Uses
424
+ * a turn penalty so straight runs are preferred. Falls back to the
425
+ * L-route if A* cannot find a path within `maxNodes` expansions or
426
+ * either endpoint is unreachable.
427
+ *
428
+ * The third argument also accepts the legacy bare-string form
429
+ * (`'auto' | 'hv' | 'vh'`) for backwards compatibility with the v0 API.
430
+ */
431
+ declare function routeOrthogonal(start: Point, end: Point, options?: RouteOrthogonalOptions | 'auto' | 'hv' | 'vh'): readonly Point[];
432
+ /**
433
+ * Build an SVG path `d` attribute from a polyline.
434
+ *
435
+ * pointsToPath([[0,0], [10,0], [10,5]]) → "M 0 0 L 10 0 L 10 5"
436
+ */
437
+ declare function pointsToPath(points: readonly Point[]): string;
438
+ /**
439
+ * Build a rounded-corner SVG path from an orthogonal polyline.
440
+ *
441
+ * Every interior bend (where two consecutive segments meet at a right
442
+ * angle) is replaced with a quadratic Bezier whose control point sits
443
+ * exactly at the corner — this produces the visual signature of
444
+ * "smooth-step" edges found in React Flow / draw.io / Lucidchart
445
+ * without changing the underlying polyline geometry.
446
+ *
447
+ * pointsToRoundedPath([[0,0], [10,0], [10,5]], 4)
448
+ * → "M 0 0 L 6 0 Q 10 0 10 4 L 10 5"
449
+ *
450
+ * `radius` is clamped to half of the shorter adjacent segment so the
451
+ * curves never overshoot. Passing `0` makes it identical to
452
+ * {@link pointsToPath}.
453
+ */
454
+ declare function pointsToRoundedPath(points: readonly Point[], radius: number): string;
455
+ /** Side of an AABB that an endpoint exits / enters through. */
456
+ type Side = 'top' | 'right' | 'bottom' | 'left';
457
+ interface BezierPathOptions {
458
+ /** Source point — where the curve starts. */
459
+ source: Point;
460
+ /** Side of the source node the curve exits through. */
461
+ sourceSide: Side;
462
+ /** Target point — where the curve ends. */
463
+ target: Point;
464
+ /** Side of the target node the curve enters through. */
465
+ targetSide: Side;
466
+ /**
467
+ * Curve intensity. `0.25` is React Flow's default — strong enough
468
+ * to feel natural, soft enough not to loop. Range: `0..1`.
469
+ */
470
+ curvature?: number;
471
+ }
472
+ /**
473
+ * Cubic-bezier SVG path between two endpoints, with control handles
474
+ * extending perpendicular to each side. Mirrors React Flow's
475
+ * `getBezierPath` algorithm.
476
+ *
477
+ * `sourceSide` / `targetSide` tell the function which face of each
478
+ * node the endpoint sits on so the curve always exits and enters
479
+ * perpendicular to the node outline — this is the difference between
480
+ * a "wavy" edge and a "deliberate" one.
481
+ *
482
+ * Use {@link nearestSide} to derive the side from an AABB + opposite
483
+ * point when the caller doesn't already know it.
484
+ */
485
+ declare function getBezierPath(opts: BezierPathOptions): string;
486
+ /**
487
+ * Pick the side of `box` whose midpoint is closest to `target`. Same
488
+ * logic as the internal helper used by orthogonal routing — exposed
489
+ * publicly so consumers of `getBezierPath` don't need to re-implement
490
+ * it.
491
+ */
492
+ declare function nearestSide(box: AABB, target: Point): Side;
493
+
494
+ /**
495
+ * Oriented Bounding Box — a rectangle in world space described by its centre,
496
+ * half-extents along its local axes, and a rotation angle.
497
+ *
498
+ * Used when a node has a non-zero `transform.rot`: the AABB is no longer a
499
+ * tight fit, so callers that need a tight collision shape (selection
500
+ * outline, manipulator handles, etc.) should use the OBB instead.
501
+ *
502
+ * Conventions:
503
+ * - `center` is the centre of the rectangle in world coordinates.
504
+ * - `halfWidth` / `halfHeight` are the half-extents along the OBB's own
505
+ * local axes (already pre-multiplied by the world scale).
506
+ * - `angle` is the rotation of the OBB's local frame relative to world,
507
+ * in radians, positive counter-clockwise.
508
+ *
509
+ * For an axis-aligned node (`angle === 0`) the OBB and AABB coincide, modulo
510
+ * the (centre + half-extents) vs (top-left + size) representation.
511
+ */
512
+ interface OBB {
513
+ readonly center: Point;
514
+ readonly halfWidth: number;
515
+ readonly halfHeight: number;
516
+ readonly angle: number;
517
+ }
518
+ /**
519
+ * Compute the four corners of an OBB in world space.
520
+ *
521
+ * Order is: top-left → top-right → bottom-right → bottom-left in OBB-local
522
+ * space, after applying the rotation. Useful for SVG `<polygon>` rendering
523
+ * and for AABB derivation.
524
+ */
525
+ declare function obbCorners(obb: OBB): readonly [Point, Point, Point, Point];
526
+ /**
527
+ * Build the tightest axis-aligned bounding box that contains a given OBB.
528
+ *
529
+ * For a non-zero `angle` the resulting AABB is strictly larger (in area)
530
+ * than the OBB — it has to enclose all four rotated corners. This is the
531
+ * canonical "broad-phase" box used by the routing layer.
532
+ */
533
+ declare function aabbFromOBB(obb: OBB): AABB;
534
+ /**
535
+ * Test whether a world-space point lies inside an OBB.
536
+ *
537
+ * Inverse-rotates the point into OBB-local space and checks the
538
+ * half-extents. O(1).
539
+ */
540
+ declare function obbContainsPoint(obb: OBB, p: Point): boolean;
541
+
542
+ export { type AABB, type Anchor, type AnchorId, type AnchorPolicy, type BezierPathOptions, type EdgeEndpoint, type EdgeId, type EdgeInit, type GraphEdge, type GraphEngine, type GraphEngineOptions, type GraphNode, type GraphState, type NodeId, type NodeInit, type NodeTransform, type NodeUpdate, type OBB$1 as OBB, type Outline, type Point, type RouteOrthogonalOptions, type Side, aabbFromOBB, createGraph, getBezierPath, nearestSide, obbContainsPoint, obbCorners, pointsToPath, pointsToRoundedPath, routeOrthogonal };
package/dist/graph.js ADDED
@@ -0,0 +1,24 @@
1
+ import {
2
+ aabbFromOBB,
3
+ createGraph,
4
+ getBezierPath,
5
+ nearestSide,
6
+ obbContainsPoint,
7
+ obbCorners,
8
+ pointsToPath,
9
+ pointsToRoundedPath,
10
+ routeOrthogonal
11
+ } from "./chunk-KP75DEA4.js";
12
+ import "./chunk-5CCD5Q4B.js";
13
+ export {
14
+ aabbFromOBB,
15
+ createGraph,
16
+ getBezierPath,
17
+ nearestSide,
18
+ obbContainsPoint,
19
+ obbCorners,
20
+ pointsToPath,
21
+ pointsToRoundedPath,
22
+ routeOrthogonal
23
+ };
24
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}