@pixerate/editor 0.280.0 → 0.281.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.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Edge path geometry for canvas edges, matching xyflow's (`getBezierPath`, `getStraightPath`,
3
+ * `getSimpleBezierPath`, `getSmoothStepPath`) so the same path is drawn with or without React Flow /
4
+ * Svelte Flow, plus a small SVG path measurer (`measureSvgPath`) for placing things along a path.
5
+ * No DOM and no xyflow import.
6
+ */
7
+ import type { CanvasConnectionLineType } from './connectors.js';
8
+ import type { Position } from './types.js';
9
+ export interface CanvasEdgePathParams {
10
+ sourceX: number;
11
+ sourceY: number;
12
+ targetX: number;
13
+ targetY: number;
14
+ /** Side of the source node the edge leaves from. Default `bottom`. */
15
+ sourcePosition?: Position;
16
+ /** Side of the target node the edge enters. Default `top`. */
17
+ targetPosition?: Position;
18
+ /** Path style, as xyflow's edge `type`. Default `default` (bézier). */
19
+ type?: CanvasConnectionLineType;
20
+ /** Bézier curvature (`default`). Default 0.25. */
21
+ curvature?: number;
22
+ /** Corner radius for `smoothstep`, in canvas units. Default 5 (`step` is 0). */
23
+ borderRadius?: number;
24
+ /** Distance the step paths run straight out of a handle before turning, in canvas units. Default 20. */
25
+ offset?: number;
26
+ }
27
+ export interface CanvasEdgePath {
28
+ /** SVG path data. */
29
+ path: string;
30
+ /** Where a label sits (xyflow's `labelX` / `labelY`). */
31
+ labelX: number;
32
+ labelY: number;
33
+ }
34
+ /**
35
+ * The SVG path of a canvas edge, the same as xyflow draws for that edge `type` (`default` bézier,
36
+ * `straight`, `step`, `smoothstep`, `simplebezier`), with the label position.
37
+ */
38
+ export declare function getCanvasEdgePath(params: CanvasEdgePathParams): CanvasEdgePath;
39
+ /** A point on a path with the direction of travel there (radians, 0 = +x). */
40
+ export interface SvgPathPoint {
41
+ x: number;
42
+ y: number;
43
+ angle: number;
44
+ }
45
+ export interface MeasuredSvgPath {
46
+ /** Total length in path units. */
47
+ length: number;
48
+ /** Bounding box of the flattened path. */
49
+ bounds: {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ };
55
+ /** The point `distance` along the path (clamped to [0, length]). */
56
+ pointAt(distance: number): SvgPathPoint;
57
+ }
58
+ /**
59
+ * Measures SVG path data (M, L, H, V, C, S, Q, T, Z, absolute or relative; arcs are drawn as
60
+ * straight lines). Curves are flattened to `segments` pieces each (default 24), which is well under
61
+ * a canvas unit of error for edge-sized curves.
62
+ */
63
+ export declare function measureSvgPath(d: string, segments?: number): MeasuredSvgPath;