@pixerate/editor-svelte 0.4.0 → 0.5.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.
@@ -95,6 +95,122 @@ export interface CanvasInteractionPresetConfig {
95
95
  maxZoom?: number;
96
96
  }
97
97
 
98
+ /**
99
+ * Parametric point returned by a trajectory evaluation.
100
+ */
101
+ export interface TrajectoryPoint {
102
+ position: XYPosition;
103
+ scale?: number;
104
+ opacity?: number;
105
+ }
106
+
107
+ /**
108
+ * Trajectory evaluation function determining path, scale, and opacity over time t in [0, 1].
109
+ */
110
+ export type TrajectoryFunction = (
111
+ origin: XYPosition,
112
+ target: XYPosition,
113
+ progress: number,
114
+ index: number,
115
+ total: number
116
+ ) => TrajectoryPoint;
117
+
118
+ /**
119
+ * Options for fan-out trajectory generator.
120
+ */
121
+ export interface FanOutTrajectoryOptions {
122
+ curvature?: number;
123
+ spreadAngle?: number;
124
+ startScale?: number;
125
+ endScale?: number;
126
+ startOpacity?: number;
127
+ endOpacity?: number;
128
+ }
129
+
130
+ /**
131
+ * Single node animation transition definition.
132
+ */
133
+ export interface NodeTransition<TNode extends CanvasNode = CanvasNode> {
134
+ node: TNode;
135
+ from: XYPosition;
136
+ to: XYPosition;
137
+ trajectory?: TrajectoryFunction;
138
+ delay?: number;
139
+ duration?: number;
140
+ easing?: (t: number) => number;
141
+ index?: number;
142
+ total?: number;
143
+ }
144
+
145
+ /**
146
+ * Displacement axis / direction.
147
+ */
148
+ export type DisplacementDirection = 'right' | 'left' | 'down' | 'up';
149
+
150
+ /**
151
+ * Options for directional displacement calculation.
152
+ */
153
+ export interface DirectionalDisplacementOptions {
154
+ direction?: DisplacementDirection;
155
+ gap?: number;
156
+ spreadSiblingLanes?: boolean;
157
+ siblingTolerance?: number;
158
+ }
159
+
160
+ /**
161
+ * Options for Dagre reflow displacement calculation.
162
+ */
163
+ export interface ReflowDisplacementOptions extends CanvasLayoutOptions {
164
+ anchorNodeId: string;
165
+ }
166
+
167
+ /**
168
+ * Snapshot of canvas graph state prior to node explosion, enabling exact reversibility.
169
+ */
170
+ export interface ExplosionSnapshot<
171
+ TNode extends CanvasNode = CanvasNode,
172
+ TEdge extends CanvasEdge = CanvasEdge
173
+ > {
174
+ parentId: string;
175
+ childNodeIds: string[];
176
+ childEdgeIds: string[];
177
+ displacedNodes: { id: string; originalPosition: XYPosition }[];
178
+ timestamp: number;
179
+ }
180
+
181
+ /**
182
+ * Options for exploding a node.
183
+ */
184
+ export interface ExplodeNodeOptions<
185
+ TNode extends CanvasNode = CanvasNode,
186
+ TEdge extends CanvasEdge = CanvasEdge
187
+ > {
188
+ childNodes: TNode[];
189
+ childEdges?: TEdge[];
190
+ connectParentToChildren?: boolean | 'first' | 'all';
191
+ connectChildrenToDownstream?: boolean;
192
+ displacementStrategy?: 'directional' | 'dagre' | 'none';
193
+ directionalOptions?: DirectionalDisplacementOptions;
194
+ reflowOptions?: Partial<ReflowDisplacementOptions>;
195
+ trajectory?: TrajectoryFunction;
196
+ duration?: number;
197
+ staggerDelay?: number;
198
+ easing?: (t: number) => number;
199
+ onComplete?: () => void;
200
+ }
201
+
202
+ /**
203
+ * Options for collapsing an exploded node.
204
+ */
205
+ export interface CollapseNodeOptions {
206
+ duration?: number;
207
+ staggerDelay?: number;
208
+ easing?: (t: number) => number;
209
+ trajectory?: TrajectoryFunction;
210
+ onComplete?: () => void;
211
+ }
212
+
213
+
98
214
  /**
99
215
  * Pure calculation of graph differences between a current state and a baseline state.
100
216
  */
@@ -343,3 +459,114 @@ export declare const miroCompatiblePreset: CanvasInteractionPresetConfig;
343
459
  * Helper to ensure panels restore pointer events after selection rectangle releases.
344
460
  */
345
461
  export declare function restorePanelPointerEvents(panelSelector?: string): void;
462
+
463
+ /**
464
+ * Standard linear trajectory: straight line interpolation with linear scale & opacity progression.
465
+ */
466
+ export declare const linearTrajectory: TrajectoryFunction;
467
+
468
+ /**
469
+ * Creates a fan-out trajectory where nodes arc outward from origin to target.
470
+ */
471
+ export declare function createFanOutTrajectory(options?: FanOutTrajectoryOptions): TrajectoryFunction;
472
+
473
+ /**
474
+ * Creates a custom quadratic Bezier trajectory with a specified or dynamically calculated control point.
475
+ */
476
+ export declare function createBezierTrajectory(
477
+ getControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition
478
+ ): TrajectoryFunction;
479
+
480
+ /**
481
+ * Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.
482
+ */
483
+ export declare function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(
484
+ transitions: NodeTransition<TNode>[],
485
+ options?: {
486
+ defaultDuration?: number;
487
+ defaultEasing?: (t: number) => number;
488
+ onUpdate?: () => void;
489
+ onComplete?: () => void;
490
+ }
491
+ ): () => void;
492
+
493
+ /**
494
+ * Calculates a bounding rectangle for a set of nodes.
495
+ */
496
+ export declare function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(
497
+ nodes: TNode[],
498
+ defaultWidth?: number,
499
+ defaultHeight?: number
500
+ ): Rect;
501
+
502
+ /**
503
+ * Pure directional displacement calculation.
504
+ */
505
+ export declare function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {
506
+ existingNodes: TNode[];
507
+ originNode: TNode;
508
+ childNodes: TNode[];
509
+ getNodesBounds?: (nodes: TNode[]) => Rect;
510
+ options?: DirectionalDisplacementOptions;
511
+ }): Map<string, XYPosition>;
512
+
513
+ /**
514
+ * Pure hierarchical Dagre reflow displacement calculation.
515
+ */
516
+ export declare function calculateReflowDisplacement<
517
+ TNode extends CanvasNode = CanvasNode,
518
+ TEdge extends CanvasEdge = CanvasEdge
519
+ >(params: {
520
+ existingNodes: TNode[];
521
+ existingEdges: TEdge[];
522
+ originNode: TNode;
523
+ childNodes: TNode[];
524
+ childEdges?: TEdge[];
525
+ getNodesBounds?: (nodes: TNode[]) => Rect;
526
+ options?: CanvasLayoutOptions;
527
+ }): Map<string, XYPosition>;
528
+
529
+ export interface CanvasGraphTarget<
530
+ TNode extends CanvasNode = CanvasNode,
531
+ TEdge extends CanvasEdge = CanvasEdge
532
+ > {
533
+ nodes: TNode[];
534
+ edges: TEdge[];
535
+ setNodes: (nodes: TNode[], triggerCallback?: boolean) => void;
536
+ setEdges: (edges: TEdge[], triggerCallback?: boolean) => void;
537
+ addNodeOrNodes: (nodes: TNode | TNode[], animateFrom?: XYPosition, save?: boolean) => void;
538
+ addEdges: (edges: TEdge[], save?: boolean) => void;
539
+ removeNodes: (nodes: TNode[], save?: boolean) => void;
540
+ removeEdges: (edges: TEdge[], save?: boolean) => void;
541
+ createEdge?: (sourceId: string, targetId: string, options?: any) => TEdge;
542
+ onSave?: () => void;
543
+ }
544
+
545
+ export interface CreateCanvasExplosionOptions<TNode extends CanvasNode = CanvasNode> {
546
+ getNodesBounds?: (nodes: TNode[]) => Rect;
547
+ onSave?: () => void;
548
+ }
549
+
550
+ /**
551
+ * Headless Svelte 5 rune managing canvas node explosion, spatial layout displacement,
552
+ * coordinated multi-node animation paths, and reversible collapsing.
553
+ */
554
+ export declare function createCanvasExplosion<
555
+ TNode extends CanvasNode = CanvasNode,
556
+ TEdge extends CanvasEdge = CanvasEdge
557
+ >(
558
+ graph: CanvasGraphTarget<TNode, TEdge>,
559
+ options?: CreateCanvasExplosionOptions<TNode>
560
+ ): {
561
+ readonly explodedNodeIds: string[];
562
+ isExploded(nodeId: string): boolean;
563
+ explodeNode(parentId: string, explodeOptions: ExplodeNodeOptions<TNode, TEdge>): boolean;
564
+ collapseNode(parentId: string, collapseOptions?: CollapseNodeOptions): boolean;
565
+ toggleExplode(
566
+ parentId: string,
567
+ explodeOptions: ExplodeNodeOptions<TNode, TEdge>,
568
+ collapseOptions?: CollapseNodeOptions
569
+ ): boolean;
570
+ getSnapshot(parentId: string): ExplosionSnapshot<TNode, TEdge> | undefined;
571
+ };
572
+