@pixerate/editor 0.9.0 → 0.11.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/dist/agent/index.cjs +563 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +436 -0
- package/dist/agent/index.d.ts +436 -0
- package/dist/agent/index.js +520 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/canvas/index.cjs +960 -0
- package/dist/canvas/index.cjs.map +1 -0
- package/dist/canvas/index.d.cts +277 -0
- package/dist/canvas/index.d.ts +277 -0
- package/dist/canvas/index.js +886 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/index.cjs +1296 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +1251 -4
- package/dist/index.js.map +1 -1
- package/dist/types-lGtRobRV.d.cts +213 -0
- package/dist/types-lGtRobRV.d.ts +213 -0
- package/package.json +13 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { R as Rect, d as CanvasNode, X as XYPosition, b as CanvasEdge, I as IncrementalLayoutOptions, S as Side, c as CanvasLayoutOptions, P as PlaceBesideOptions, T as TrajectoryFunction, F as FanOutTrajectoryOptions, N as NodeTransition, k as ReflowDisplacementOptions, D as DirectionalDisplacementOptions, C as CanvasClipboardPayload } from '../types-lGtRobRV.js';
|
|
2
|
+
export { a as CanvasDockingCallbacks, e as CollapseNodeOptions, f as DisplacementDirection, g as DockStrategy, E as ExplodeNodeOptions, h as ExplosionSnapshot, G as GraphDifferences, i as Point, j as Position, l as TrajectoryPoint } from '../types-lGtRobRV.js';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_NODE_WIDTH = 200;
|
|
5
|
+
declare const DEFAULT_NODE_HEIGHT = 60;
|
|
6
|
+
declare const DEFAULT_PLACEMENT_GAP = 48;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates upper-left flow coordinate for an element to be centered in the viewport.
|
|
9
|
+
*/
|
|
10
|
+
declare function getCenteredNodePosition(width: number | undefined, height: number | undefined, screenToFlowPosition: (position: XYPosition) => XYPosition, screenDimensions?: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}): XYPosition;
|
|
14
|
+
/**
|
|
15
|
+
* Updates positions of nodes so their collective bounding box is centered in the current viewport.
|
|
16
|
+
*/
|
|
17
|
+
declare function centerNodes<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], screenToFlowPosition: (position: XYPosition) => XYPosition, getNodesBounds: (nodes: TNode[]) => Rect, screenDimensions?: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}): TNode[];
|
|
21
|
+
/**
|
|
22
|
+
* Automatically calculates directed hierarchical layout of nodes and edges using Dagre.
|
|
23
|
+
*/
|
|
24
|
+
declare function getLayoutedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], getNodesBounds?: (nodes: TNode[]) => Rect, options?: CanvasLayoutOptions): TNode[];
|
|
25
|
+
/**
|
|
26
|
+
* Heuristic text-based node size estimator when DOM measurement is not available.
|
|
27
|
+
*/
|
|
28
|
+
declare function estimateNodeSize(node: CanvasNode, defaultWidth?: number, defaultHeight?: number): {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Computes bounding rectangle of an array of rectangles.
|
|
34
|
+
*/
|
|
35
|
+
declare function boundsOf(rects: Rect[]): Rect | null;
|
|
36
|
+
/**
|
|
37
|
+
* Center coordinate of a rectangle.
|
|
38
|
+
*/
|
|
39
|
+
declare function centre(r: Rect): XYPosition;
|
|
40
|
+
/**
|
|
41
|
+
* Determines whether two rectangles overlap, including an optional padding distance.
|
|
42
|
+
*/
|
|
43
|
+
declare function overlaps(a: Rect, b: Rect, pad?: number): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Maps directed layout flow to its natural forward growth side.
|
|
46
|
+
*/
|
|
47
|
+
declare function flowSide(direction?: 'LR' | 'TB' | 'RL' | 'BT'): Side;
|
|
48
|
+
/**
|
|
49
|
+
* Incremental layout blending:
|
|
50
|
+
* Keeps established/manual node positions intact. Runs Dagre on the entire graph,
|
|
51
|
+
* computes the centroid translation offset between auto and stored positions of existing nodes,
|
|
52
|
+
* and places unpositioned/new nodes at (auto + offset).
|
|
53
|
+
*/
|
|
54
|
+
declare function ensureLayout<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], options?: IncrementalLayoutOptions): TNode[];
|
|
55
|
+
/**
|
|
56
|
+
* Finds a free top-left coordinate for a node of `size` adjacent to `nearNodeId` (or the cluster),
|
|
57
|
+
* sliding along the perpendicular axis past any intersecting bounding boxes to guarantee non-overlapping placement.
|
|
58
|
+
*/
|
|
59
|
+
declare function placeBeside(rects: Record<string, Rect>, size: {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}, side: Side, nearNodeId?: string, options?: PlaceBesideOptions): XYPosition;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The time source that canvas animations and agent performances play on.
|
|
66
|
+
*
|
|
67
|
+
* Defaults to `realClock` (requestAnimationFrame and setTimeout).
|
|
68
|
+
* A `ManualClock` moves only when told to via `advance(ms)` or `tick(fps)`,
|
|
69
|
+
* enabling deterministic frame-by-frame stepping for testing, video generation,
|
|
70
|
+
* or headless server environments.
|
|
71
|
+
*/
|
|
72
|
+
interface Clock {
|
|
73
|
+
/** Current time in milliseconds. */
|
|
74
|
+
now(): number;
|
|
75
|
+
/** Resolves on the next animation frame. */
|
|
76
|
+
frame(): Promise<void>;
|
|
77
|
+
/** Resolves after `ms` milliseconds of this clock's time. */
|
|
78
|
+
sleep(ms: number): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the clock follows wall time. Live clocks stop or degrade when the
|
|
81
|
+
* tab is in the background (browsers pause animation frames), so transitions
|
|
82
|
+
* can commit immediately rather than leaving operations hanging.
|
|
83
|
+
*/
|
|
84
|
+
readonly live: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Whether the browser tab is hidden (where RAF pauses). */
|
|
87
|
+
declare const pageHidden: () => boolean;
|
|
88
|
+
/** Real-time clock using requestAnimationFrame and setTimeout. */
|
|
89
|
+
declare const realClock: Clock;
|
|
90
|
+
/**
|
|
91
|
+
* A deterministic clock that only moves forward when `advance` or `tick` is called.
|
|
92
|
+
* Allows step-by-step frame testing and video rendering without waiting for real time.
|
|
93
|
+
*/
|
|
94
|
+
declare class ManualClock implements Clock {
|
|
95
|
+
readonly live = false;
|
|
96
|
+
private time;
|
|
97
|
+
private frames;
|
|
98
|
+
private sleepers;
|
|
99
|
+
private seq;
|
|
100
|
+
constructor(start?: number);
|
|
101
|
+
now(): number;
|
|
102
|
+
frame(): Promise<void>;
|
|
103
|
+
sleep(ms: number): Promise<void>;
|
|
104
|
+
/** Whether any frames or sleep timers are currently pending. */
|
|
105
|
+
get pending(): boolean;
|
|
106
|
+
/** Advances time by `ms`, resolving due sleep timers in order, followed by queued frames. */
|
|
107
|
+
advance(ms: number): Promise<void>;
|
|
108
|
+
/** Convenience method to advance by 1 frame at a given fps (default: 60fps = 16.67ms). */
|
|
109
|
+
tick(fps?: number): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Standard cubic ease-out function (pure math, framework-agnostic).
|
|
114
|
+
*/
|
|
115
|
+
declare const defaultEasing: (t: number) => number;
|
|
116
|
+
/**
|
|
117
|
+
* Standard linear trajectory: straight line interpolation with linear scale & opacity progression.
|
|
118
|
+
*/
|
|
119
|
+
declare const linearTrajectory: TrajectoryFunction;
|
|
120
|
+
/**
|
|
121
|
+
* Linear position trajectory: pure position interpolation without altering scale or opacity.
|
|
122
|
+
*/
|
|
123
|
+
declare const linearPositionTrajectory: TrajectoryFunction;
|
|
124
|
+
/**
|
|
125
|
+
* Creates a fan-out trajectory where nodes arc outward from origin to target.
|
|
126
|
+
*/
|
|
127
|
+
declare function createFanOutTrajectory(options?: FanOutTrajectoryOptions): TrajectoryFunction;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a custom quadratic Bezier trajectory with a specified control point resolver.
|
|
130
|
+
*/
|
|
131
|
+
declare function createBezierTrajectory(getControlPoint: (origin: XYPosition, target: XYPosition) => XYPosition): TrajectoryFunction;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Coordinates and animates multiple node transitions simultaneously with zero per-frame array allocations.
|
|
135
|
+
*/
|
|
136
|
+
declare function runMultiNodeTransition<TNode extends CanvasNode = CanvasNode>(transitions: NodeTransition<TNode>[], options?: {
|
|
137
|
+
defaultDuration?: number;
|
|
138
|
+
defaultEasing?: (t: number) => number;
|
|
139
|
+
clock?: Clock;
|
|
140
|
+
onUpdate?: () => void;
|
|
141
|
+
onComplete?: () => void;
|
|
142
|
+
}): () => void;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Calculates a bounding rectangle for a set of nodes if not provided by getNodesBounds.
|
|
146
|
+
*/
|
|
147
|
+
declare function computeNodesBoundingBox<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], defaultWidth?: number, defaultHeight?: number): Rect;
|
|
148
|
+
/**
|
|
149
|
+
* Pure directional displacement calculation.
|
|
150
|
+
* Shifts downstream or surrounding nodes along an axis to clear space for newly inserted child nodes.
|
|
151
|
+
*/
|
|
152
|
+
declare function calculateDirectionalDisplacement<TNode extends CanvasNode = CanvasNode>(params: {
|
|
153
|
+
existingNodes: TNode[];
|
|
154
|
+
originNode: TNode;
|
|
155
|
+
childNodes: TNode[];
|
|
156
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
157
|
+
options?: DirectionalDisplacementOptions;
|
|
158
|
+
}): Map<string, XYPosition>;
|
|
159
|
+
/**
|
|
160
|
+
* Calculates Dagre reflow displacement preserving the position of an anchor node.
|
|
161
|
+
*/
|
|
162
|
+
declare function calculateDagreReflowDisplacement<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(params: {
|
|
163
|
+
currentNodes: TNode[];
|
|
164
|
+
currentEdges: TEdge[];
|
|
165
|
+
futureNodes: TNode[];
|
|
166
|
+
futureEdges: TEdge[];
|
|
167
|
+
options: ReflowDisplacementOptions;
|
|
168
|
+
getNodesBounds?: (nodes: TNode[]) => Rect;
|
|
169
|
+
}): Map<string, XYPosition>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Checks if an event originated from a text input, textarea, contenteditable element, or rich editor.
|
|
173
|
+
*/
|
|
174
|
+
declare function isEventFromTextInput(event: Event | {
|
|
175
|
+
target: EventTarget | null;
|
|
176
|
+
}): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Validates that an object conforms to minimal CanvasNode shape.
|
|
179
|
+
*/
|
|
180
|
+
declare function isValidCanvasNode(obj: unknown): obj is CanvasNode;
|
|
181
|
+
/**
|
|
182
|
+
* Checks if a string is a valid HTTP/HTTPS URL.
|
|
183
|
+
*/
|
|
184
|
+
declare function isValidUrl(url: string): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Serializes nodes and optional edges into clipboard JSON payload.
|
|
187
|
+
*/
|
|
188
|
+
declare function serializeCanvasNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[]): string;
|
|
189
|
+
/**
|
|
190
|
+
* Parses raw JSON string into a CanvasClipboardPayload if valid.
|
|
191
|
+
*/
|
|
192
|
+
declare function parseCanvasClipboardData<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(raw: string): CanvasClipboardPayload<TNode, TEdge> | null;
|
|
193
|
+
/**
|
|
194
|
+
* Generates unique new IDs for pasted nodes and updates edge references accordingly.
|
|
195
|
+
*/
|
|
196
|
+
declare function remapPastedNodes<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges?: TEdge[], offset?: XYPosition, idGenerator?: () => string): {
|
|
197
|
+
nodes: TNode[];
|
|
198
|
+
edges: TEdge[];
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Repositions nodes so their bounding box origin matches the given target position.
|
|
202
|
+
*/
|
|
203
|
+
declare function repositionNodesTo<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], targetOrigin: XYPosition): TNode[];
|
|
204
|
+
|
|
205
|
+
interface StreamingLayoutManagerOptions {
|
|
206
|
+
throttleMs?: number;
|
|
207
|
+
glideDurationMs?: number;
|
|
208
|
+
connectedOnly?: boolean;
|
|
209
|
+
clock?: Clock;
|
|
210
|
+
layoutOptions?: IncrementalLayoutOptions;
|
|
211
|
+
onLayoutUpdated?: (positions: Map<string, XYPosition>) => void;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Manages throttled incremental layout recalculation and smooth tweened node gliding
|
|
215
|
+
* during active streaming (e.g. LLM streaming or graph generation).
|
|
216
|
+
*/
|
|
217
|
+
declare class StreamingLayoutManager<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
|
|
218
|
+
private throttleMs;
|
|
219
|
+
private glideDurationMs;
|
|
220
|
+
private connectedOnly;
|
|
221
|
+
private clock;
|
|
222
|
+
private layoutOptions;
|
|
223
|
+
private onLayoutUpdated?;
|
|
224
|
+
private pendingTimer;
|
|
225
|
+
private activeTransitionCancel;
|
|
226
|
+
private targetPositions;
|
|
227
|
+
constructor(options?: StreamingLayoutManagerOptions);
|
|
228
|
+
/**
|
|
229
|
+
* Feed incoming nodes and edges into the streaming manager.
|
|
230
|
+
* Coalesces rapid streaming bursts and triggers smooth layout gliding.
|
|
231
|
+
*/
|
|
232
|
+
pushStreamUpdate(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
233
|
+
/**
|
|
234
|
+
* Forces immediate calculation and cancels pending throttled timers.
|
|
235
|
+
*/
|
|
236
|
+
flush(nodes: TNode[], edges: TEdge[], currentPositions: Map<string, XYPosition>): void;
|
|
237
|
+
private recalculateAndGlide;
|
|
238
|
+
destroy(): void;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface CanvasHeightOptions {
|
|
242
|
+
/** Smallest height returned (default 320). */
|
|
243
|
+
min?: number;
|
|
244
|
+
/** Largest height returned; taller content is scaled/zoomed (default 560). */
|
|
245
|
+
max?: number;
|
|
246
|
+
/** Extra padding around the content (default 48). */
|
|
247
|
+
padding?: number;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Calculates the bounding box extent of all positioned nodes, or `null` for an empty graph.
|
|
251
|
+
*/
|
|
252
|
+
declare function layoutBounds<TNode extends CanvasNode = CanvasNode>(nodes: TNode[]): Rect | null;
|
|
253
|
+
/**
|
|
254
|
+
* Returns a clamped container height that fits the layout at 1:1 scale without overflow.
|
|
255
|
+
*/
|
|
256
|
+
declare function canvasHeight<TNode extends CanvasNode = CanvasNode>(nodes: TNode[], options?: CanvasHeightOptions): number;
|
|
257
|
+
/**
|
|
258
|
+
* Estimates the container height to reserve before layout calculation finishes,
|
|
259
|
+
* based on node and edge counts alone. Prevents layout shift (CLS).
|
|
260
|
+
*/
|
|
261
|
+
declare function estimateCanvasHeight<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[], options?: CanvasHeightOptions): number;
|
|
262
|
+
/**
|
|
263
|
+
* Interpolates node positions and sizes between two layouts partway at progress `t` (0 = from, 1 = to).
|
|
264
|
+
* Nodes present in both interpolate smoothly; nodes newly added in `to` snap to target.
|
|
265
|
+
*/
|
|
266
|
+
declare function blendLayout<TNode extends CanvasNode = CanvasNode>(from: TNode[], to: TNode[], t: number): TNode[];
|
|
267
|
+
/**
|
|
268
|
+
* Filters out nodes that are not touched by any edge.
|
|
269
|
+
*
|
|
270
|
+
* During LLM streaming, nodes often arrive a chunk or token before the edge
|
|
271
|
+
* that connects them. Displaying them immediately causes them to be placed as root
|
|
272
|
+
* nodes only to jump into their correct position once the edge arrives.
|
|
273
|
+
* Hiding orphan nodes during active streaming keeps the layout calm and jitter-free.
|
|
274
|
+
*/
|
|
275
|
+
declare function connectedOnly<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(nodes: TNode[], edges: TEdge[]): TNode[];
|
|
276
|
+
|
|
277
|
+
export { CanvasClipboardPayload, CanvasEdge, type CanvasHeightOptions, CanvasLayoutOptions, CanvasNode, type Clock, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, FanOutTrajectoryOptions, IncrementalLayoutOptions, ManualClock, NodeTransition, PlaceBesideOptions, Rect, ReflowDisplacementOptions, Side, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canvasHeight, centerNodes, centre, computeNodesBoundingBox, connectedOnly, createBezierTrajectory, createFanOutTrajectory, defaultEasing, ensureLayout, estimateCanvasHeight, estimateNodeSize, flowSide, getCenteredNodePosition, getLayoutedNodes, isEventFromTextInput, isValidCanvasNode, isValidUrl, layoutBounds, linearPositionTrajectory, linearTrajectory, overlaps, pageHidden, parseCanvasClipboardData, placeBeside, realClock, remapPastedNodes, repositionNodesTo, runMultiNodeTransition, serializeCanvasNodes };
|