@getartisanflow/alpineflow 0.1.0-alpha
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 +21 -0
- package/README.md +88 -0
- package/dist/alpineflow-collab.esm.js +465 -0
- package/dist/alpineflow-collab.esm.js.map +1 -0
- package/dist/alpineflow-collab.js +247 -0
- package/dist/alpineflow-collab.js.map +1 -0
- package/dist/alpineflow-dagre.esm.js +1661 -0
- package/dist/alpineflow-dagre.esm.js.map +1 -0
- package/dist/alpineflow-dagre.js +1655 -0
- package/dist/alpineflow-dagre.js.map +1 -0
- package/dist/alpineflow-elk.esm.js +47378 -0
- package/dist/alpineflow-elk.esm.js.map +1 -0
- package/dist/alpineflow-elk.js +47373 -0
- package/dist/alpineflow-elk.js.map +1 -0
- package/dist/alpineflow-force.esm.js +599 -0
- package/dist/alpineflow-force.esm.js.map +1 -0
- package/dist/alpineflow-force.js +477 -0
- package/dist/alpineflow-force.js.map +1 -0
- package/dist/alpineflow-hierarchy.esm.js +398 -0
- package/dist/alpineflow-hierarchy.esm.js.map +1 -0
- package/dist/alpineflow-hierarchy.js +393 -0
- package/dist/alpineflow-hierarchy.js.map +1 -0
- package/dist/alpineflow-theme.css +473 -0
- package/dist/alpineflow-whiteboard.esm.js +922 -0
- package/dist/alpineflow-whiteboard.esm.js.map +1 -0
- package/dist/alpineflow-whiteboard.js +922 -0
- package/dist/alpineflow-whiteboard.js.map +1 -0
- package/dist/alpineflow.bundle.esm.js +12604 -0
- package/dist/alpineflow.bundle.esm.js.map +1 -0
- package/dist/alpineflow.css +1415 -0
- package/dist/alpineflow.esm.js +158 -0
- package/dist/alpineflow.esm.js.map +1 -0
- package/dist/alpineflow.js +5 -0
- package/dist/alpineflow.js.map +1 -0
- package/dist/export-DjmXOnKD.js +76 -0
- package/dist/export-DjmXOnKD.js.map +1 -0
- package/dist/geometry-DZSZoYHE.js +82 -0
- package/dist/geometry-DZSZoYHE.js.map +1 -0
- package/dist/index-C0N1DL3G.js +11728 -0
- package/dist/index-C0N1DL3G.js.map +1 -0
- package/dist/index-L3Zm-CoX.js +513 -0
- package/dist/index-L3Zm-CoX.js.map +1 -0
- package/dist/registry-CChkuoVJ.js +15 -0
- package/dist/registry-CChkuoVJ.js.map +1 -0
- package/dist/store-CaFAFEdD.js +9 -0
- package/dist/store-CaFAFEdD.js.map +1 -0
- package/dist/timer-B39XOBYL.js +124 -0
- package/dist/timer-B39XOBYL.js.map +1 -0
- package/dist/types/lib/collab.cdn.d.ts +1 -0
- package/dist/types/lib/collab.d.ts +2 -0
- package/dist/types/lib/core.cdn.d.ts +1 -0
- package/dist/types/lib/core.d.ts +2 -0
- package/dist/types/lib/dagre.cdn.d.ts +1 -0
- package/dist/types/lib/dagre.d.ts +1 -0
- package/dist/types/lib/elk.cdn.d.ts +1 -0
- package/dist/types/lib/elk.d.ts +1 -0
- package/dist/types/lib/force.cdn.d.ts +1 -0
- package/dist/types/lib/force.d.ts +1 -0
- package/dist/types/lib/hierarchy.cdn.d.ts +1 -0
- package/dist/types/lib/hierarchy.d.ts +1 -0
- package/dist/types/lib/whiteboard.cdn.d.ts +1 -0
- package/dist/types/lib/whiteboard.d.ts +1 -0
- package/dist/types/src/animate/animator.d.ts +57 -0
- package/dist/types/src/animate/easing.d.ts +4 -0
- package/dist/types/src/animate/edge-transitions.d.ts +22 -0
- package/dist/types/src/animate/engine.d.ts +37 -0
- package/dist/types/src/animate/index.d.ts +10 -0
- package/dist/types/src/animate/interpolators.d.ts +14 -0
- package/dist/types/src/animate/paths.d.ts +64 -0
- package/dist/types/src/animate/timeline.d.ts +149 -0
- package/dist/types/src/collab/awareness.d.ts +40 -0
- package/dist/types/src/collab/bridge.d.ts +36 -0
- package/dist/types/src/collab/directives/flow-cursors.d.ts +16 -0
- package/dist/types/src/collab/index.d.ts +19 -0
- package/dist/types/src/collab/providers/in-memory.d.ts +41 -0
- package/dist/types/src/collab/providers/reverb.d.ts +59 -0
- package/dist/types/src/collab/providers/websocket.d.ts +33 -0
- package/dist/types/src/collab/store.d.ts +22 -0
- package/dist/types/src/collab/types.d.ts +55 -0
- package/dist/types/src/core/__fixtures__/nodes.d.ts +42 -0
- package/dist/types/src/core/announcer.d.ts +21 -0
- package/dist/types/src/core/auto-pan.d.ts +37 -0
- package/dist/types/src/core/child-layout.d.ts +18 -0
- package/dist/types/src/core/child-validation.d.ts +23 -0
- package/dist/types/src/core/clipboard.d.ts +29 -0
- package/dist/types/src/core/collapse.d.ts +54 -0
- package/dist/types/src/core/color-mode.d.ts +11 -0
- package/dist/types/src/core/compute.d.ts +33 -0
- package/dist/types/src/core/connections.d.ts +32 -0
- package/dist/types/src/core/constants.d.ts +18 -0
- package/dist/types/src/core/controls-panel.d.ts +23 -0
- package/dist/types/src/core/debug.d.ts +10 -0
- package/dist/types/src/core/deep-merge.d.ts +10 -0
- package/dist/types/src/core/drag.d.ts +63 -0
- package/dist/types/src/core/edge-paths/avoidant.d.ts +25 -0
- package/dist/types/src/core/edge-paths/bezier.d.ts +26 -0
- package/dist/types/src/core/edge-paths/editable.d.ts +22 -0
- package/dist/types/src/core/edge-paths/index.d.ts +7 -0
- package/dist/types/src/core/edge-paths/orthogonal.d.ts +27 -0
- package/dist/types/src/core/edge-paths/smoothstep.d.ts +22 -0
- package/dist/types/src/core/edge-paths/straight.d.ts +12 -0
- package/dist/types/src/core/edge-paths/utils.d.ts +30 -0
- package/dist/types/src/core/edge-utils.d.ts +57 -0
- package/dist/types/src/core/export.d.ts +12 -0
- package/dist/types/src/core/floating-edge.d.ts +33 -0
- package/dist/types/src/core/geometry.d.ts +79 -0
- package/dist/types/src/core/gradients.d.ts +30 -0
- package/dist/types/src/core/graph.d.ts +38 -0
- package/dist/types/src/core/helper-lines.d.ts +32 -0
- package/dist/types/src/core/history.d.ts +19 -0
- package/dist/types/src/core/index.d.ts +17 -0
- package/dist/types/src/core/intersection.d.ts +30 -0
- package/dist/types/src/core/keyboard-shortcuts.d.ts +45 -0
- package/dist/types/src/core/lasso-hit-test.d.ts +25 -0
- package/dist/types/src/core/lasso.d.ts +10 -0
- package/dist/types/src/core/layout/dagre.d.ts +11 -0
- package/dist/types/src/core/layout/elk.d.ts +13 -0
- package/dist/types/src/core/layout/force.d.ts +15 -0
- package/dist/types/src/core/layout/hierarchy.d.ts +13 -0
- package/dist/types/src/core/long-press.d.ts +11 -0
- package/dist/types/src/core/markers.d.ts +49 -0
- package/dist/types/src/core/minimap.d.ts +18 -0
- package/dist/types/src/core/node-flags.d.ts +19 -0
- package/dist/types/src/core/pan-zoom.d.ts +62 -0
- package/dist/types/src/core/proximity-connect.d.ts +25 -0
- package/dist/types/src/core/registry.d.ts +16 -0
- package/dist/types/src/core/render-plan.d.ts +52 -0
- package/dist/types/src/core/resize.d.ts +31 -0
- package/dist/types/src/core/rotation.d.ts +8 -0
- package/dist/types/src/core/selection-box.d.ts +14 -0
- package/dist/types/src/core/shapes.d.ts +10 -0
- package/dist/types/src/core/sub-flow.d.ts +61 -0
- package/dist/types/src/core/svg-path.d.ts +5 -0
- package/dist/types/src/core/types.d.ts +1238 -0
- package/dist/types/src/core/wire-bridge.d.ts +36 -0
- package/dist/types/src/index.d.ts +43 -0
- package/dist/types/src/layout/dagre.d.ts +2 -0
- package/dist/types/src/layout/elk.d.ts +2 -0
- package/dist/types/src/layout/force.d.ts +2 -0
- package/dist/types/src/layout/hierarchy.d.ts +2 -0
- package/dist/types/src/plugin/connection-utils.d.ts +54 -0
- package/dist/types/src/plugin/data/__test-utils.d.ts +9 -0
- package/dist/types/src/plugin/data/canvas-animation.d.ts +62 -0
- package/dist/types/src/plugin/data/canvas-collapse.d.ts +35 -0
- package/dist/types/src/plugin/data/canvas-compute.d.ts +6 -0
- package/dist/types/src/plugin/data/canvas-condense.d.ts +19 -0
- package/dist/types/src/plugin/data/canvas-config.d.ts +4 -0
- package/dist/types/src/plugin/data/canvas-context.d.ts +570 -0
- package/dist/types/src/plugin/data/canvas-dom.d.ts +13 -0
- package/dist/types/src/plugin/data/canvas-edges.d.ts +37 -0
- package/dist/types/src/plugin/data/canvas-history.d.ts +53 -0
- package/dist/types/src/plugin/data/canvas-layout.d.ts +151 -0
- package/dist/types/src/plugin/data/canvas-nodes.d.ts +73 -0
- package/dist/types/src/plugin/data/canvas-rows.d.ts +13 -0
- package/dist/types/src/plugin/data/canvas-selection.d.ts +45 -0
- package/dist/types/src/plugin/data/canvas-validation.d.ts +21 -0
- package/dist/types/src/plugin/data/canvas-viewport.d.ts +111 -0
- package/dist/types/src/plugin/data/flow-canvas.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-action.d.ts +12 -0
- package/dist/types/src/plugin/directives/flow-animate.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-arrow-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-circle-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-collapse.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-condense.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-context-menu.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-detail.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-devtools.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-drag-handle.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-draggable.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-edge-toolbar.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-edge.d.ts +7 -0
- package/dist/types/src/plugin/directives/flow-eraser.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-filter.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-follow.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-freehand.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-handle-connectable.d.ts +12 -0
- package/dist/types/src/plugin/directives/flow-handle-limit.d.ts +9 -0
- package/dist/types/src/plugin/directives/flow-handle-validate.d.ts +10 -0
- package/dist/types/src/plugin/directives/flow-handle.d.ts +29 -0
- package/dist/types/src/plugin/directives/flow-highlighter.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-loading.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-node-toolbar.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-node.d.ts +10 -0
- package/dist/types/src/plugin/directives/flow-panel.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-rectangle-draw.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-resizer.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-rotate.d.ts +11 -0
- package/dist/types/src/plugin/directives/flow-row-select.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-snapshot.d.ts +14 -0
- package/dist/types/src/plugin/directives/flow-text-tool.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-timeline.d.ts +2 -0
- package/dist/types/src/plugin/directives/flow-viewport.d.ts +2 -0
- package/dist/types/src/plugin/magics/flow.d.ts +2 -0
- package/dist/types/src/plugin/store.d.ts +2 -0
- package/dist/types/src/whiteboard/index.d.ts +2 -0
- package/package.json +153 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FlowNode, Rect } from './types';
|
|
2
|
+
export interface Point {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Ray-casting algorithm: cast a horizontal ray from (px, py) to the right
|
|
8
|
+
* and count how many polygon edges it crosses. Odd = inside, even = outside.
|
|
9
|
+
*/
|
|
10
|
+
export declare function pointInPolygon(px: number, py: number, polygon: Point[]): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Test whether any edge of the polygon intersects the AABB, or if the AABB
|
|
13
|
+
* center lies inside the polygon.
|
|
14
|
+
*/
|
|
15
|
+
export declare function polygonIntersectsAABB(polygon: Point[], rect: Rect): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Return nodes that partially overlap the lasso polygon (center inside OR
|
|
18
|
+
* AABB edges intersect polygon edges). Skips hidden and non-selectable nodes.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getNodesInPolygon(nodes: FlowNode[], polygon: Point[]): FlowNode[];
|
|
21
|
+
/**
|
|
22
|
+
* Return nodes fully enclosed by the lasso polygon (all four AABB corners
|
|
23
|
+
* inside). Skips hidden and non-selectable nodes.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getNodesFullyInPolygon(nodes: FlowNode[], polygon: Point[]): FlowNode[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Viewport } from './types';
|
|
2
|
+
import type { Point } from './lasso-hit-test';
|
|
3
|
+
export interface LassoInstance {
|
|
4
|
+
start(containerX: number, containerY: number, mode?: 'partial' | 'full'): void;
|
|
5
|
+
update(containerX: number, containerY: number): void;
|
|
6
|
+
end(viewport: Viewport): Point[] | null;
|
|
7
|
+
isActive(): boolean;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createLasso(container: HTMLElement): LassoInstance;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from '../types';
|
|
2
|
+
export type DagreDirection = 'TB' | 'LR' | 'BT' | 'RL';
|
|
3
|
+
export interface DagreLayoutOptions {
|
|
4
|
+
direction?: DagreDirection;
|
|
5
|
+
nodesep?: number;
|
|
6
|
+
ranksep?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function computeDagreLayout(nodes: FlowNode[], edges: FlowEdge[], options?: DagreLayoutOptions): Map<string, {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from '../types';
|
|
2
|
+
export type ElkAlgorithm = 'layered' | 'force' | 'mrtree' | 'radial' | 'stress';
|
|
3
|
+
export type ElkDirection = 'DOWN' | 'RIGHT' | 'UP' | 'LEFT';
|
|
4
|
+
export interface ElkLayoutOptions {
|
|
5
|
+
algorithm?: ElkAlgorithm;
|
|
6
|
+
direction?: ElkDirection;
|
|
7
|
+
nodeSpacing?: number;
|
|
8
|
+
layerSpacing?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function computeElkLayout(nodes: FlowNode[], edges: FlowEdge[], options?: ElkLayoutOptions): Promise<Map<string, {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from '../types';
|
|
2
|
+
export interface ForceLayoutOptions {
|
|
3
|
+
strength?: number;
|
|
4
|
+
distance?: number;
|
|
5
|
+
charge?: number;
|
|
6
|
+
iterations?: number;
|
|
7
|
+
center?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function computeForceLayout(nodes: FlowNode[], edges: FlowEdge[], options?: ForceLayoutOptions): Map<string, {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from '../types';
|
|
2
|
+
export type HierarchyLayoutType = 'tree' | 'cluster';
|
|
3
|
+
export type HierarchyDirection = 'TB' | 'LR';
|
|
4
|
+
export interface HierarchyLayoutOptions {
|
|
5
|
+
layoutType?: HierarchyLayoutType;
|
|
6
|
+
direction?: HierarchyDirection;
|
|
7
|
+
nodeWidth?: number;
|
|
8
|
+
nodeHeight?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function computeHierarchyLayout(nodes: FlowNode[], edges: FlowEdge[], options?: HierarchyLayoutOptions): Map<string, {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface LongPressOptions {
|
|
2
|
+
/** Delay before firing in milliseconds. Default: 500 */
|
|
3
|
+
duration?: number;
|
|
4
|
+
/** Max movement in pixels before cancel. Default: 10 */
|
|
5
|
+
moveThreshold?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Attach long-press detection to an element.
|
|
9
|
+
* Returns a cleanup function that removes all listeners.
|
|
10
|
+
*/
|
|
11
|
+
export declare function attachLongPress(el: HTMLElement, callback: (event: PointerEvent) => void, options?: LongPressOptions): () => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type MarkerType = 'arrow' | 'arrowclosed' | (string & {});
|
|
2
|
+
export interface MarkerConfig {
|
|
3
|
+
type: MarkerType;
|
|
4
|
+
color?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
orient?: string;
|
|
8
|
+
offset?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Render function for a custom marker. Receives the marker config (with resolved
|
|
12
|
+
* defaults for color, width, height, orient) and the unique SVG id. Must return
|
|
13
|
+
* a complete `<marker>...</marker>` SVG string.
|
|
14
|
+
*/
|
|
15
|
+
export type CustomMarkerRenderer = (config: {
|
|
16
|
+
id: string;
|
|
17
|
+
color: string;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
orient: string;
|
|
21
|
+
}) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Register a custom marker type. The renderer receives resolved defaults and
|
|
24
|
+
* must return a complete `<marker>` SVG element string.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* registerMarker('diamond', ({ id, color, width, height, orient }) => `
|
|
28
|
+
* <marker id="${id}" viewBox="0 0 20 20" markerWidth="${width}" markerHeight="${height}"
|
|
29
|
+
* orient="${orient}" markerUnits="strokeWidth" refX="10" refY="10">
|
|
30
|
+
* <polygon points="10,0 20,10 10,20 0,10" fill="${color}" />
|
|
31
|
+
* </marker>
|
|
32
|
+
* `);
|
|
33
|
+
*
|
|
34
|
+
* // Then use on edges:
|
|
35
|
+
* { id: 'e1', source: 'a', target: 'b', markerEnd: 'diamond' }
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerMarker(type: string, renderer: CustomMarkerRenderer): void;
|
|
38
|
+
/**
|
|
39
|
+
* Normalize a marker shorthand (string type) into a full MarkerConfig.
|
|
40
|
+
*/
|
|
41
|
+
export declare function normalizeMarker(marker: MarkerType | MarkerConfig): MarkerConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Generate a unique marker ID for deduplication in SVG defs.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getMarkerId(marker: MarkerConfig, flowId: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Generate SVG marker element markup string.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getMarkerSvg(marker: MarkerConfig, id: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FlowNode, Viewport, FlowCanvasConfig } from './types';
|
|
2
|
+
export interface MiniMapState {
|
|
3
|
+
nodes: FlowNode[];
|
|
4
|
+
viewport: Viewport;
|
|
5
|
+
containerWidth: number;
|
|
6
|
+
containerHeight: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MiniMapOptions {
|
|
9
|
+
getState: () => MiniMapState;
|
|
10
|
+
setViewport: (vp: Partial<Viewport>) => void;
|
|
11
|
+
config: FlowCanvasConfig;
|
|
12
|
+
}
|
|
13
|
+
export interface MiniMapInstance {
|
|
14
|
+
render(): void;
|
|
15
|
+
updateViewport(): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function createMiniMap(container: HTMLElement, options: MiniMapOptions): MiniMapInstance;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal node shape for flag checking — allows partial node objects
|
|
3
|
+
* from connection-utils and other contexts where the full FlowNode
|
|
4
|
+
* type isn't available.
|
|
5
|
+
*/
|
|
6
|
+
interface NodeLike {
|
|
7
|
+
locked?: boolean;
|
|
8
|
+
draggable?: boolean;
|
|
9
|
+
deletable?: boolean;
|
|
10
|
+
connectable?: boolean;
|
|
11
|
+
selectable?: boolean;
|
|
12
|
+
resizable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function isDraggable(node: NodeLike): boolean;
|
|
15
|
+
export declare function isDeletable(node: NodeLike): boolean;
|
|
16
|
+
export declare function isConnectable(node: NodeLike): boolean;
|
|
17
|
+
export declare function isSelectable(node: NodeLike): boolean;
|
|
18
|
+
export declare function isResizable(node: NodeLike): boolean;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type ZoomTransform } from 'd3-zoom';
|
|
2
|
+
import 'd3-transition';
|
|
3
|
+
import type { Viewport } from './types';
|
|
4
|
+
export interface PanZoomOptions {
|
|
5
|
+
/** Called whenever the viewport transform changes */
|
|
6
|
+
onTransformChange: (viewport: Viewport) => void;
|
|
7
|
+
/** Called when a user gesture starts (d3-zoom 'start' event) */
|
|
8
|
+
onMoveStart?: (viewport: Viewport) => void;
|
|
9
|
+
/** Called each frame during a user gesture (d3-zoom 'zoom' event, user-only) */
|
|
10
|
+
onMove?: (viewport: Viewport) => void;
|
|
11
|
+
/** Called when a user gesture ends (d3-zoom 'end' event) */
|
|
12
|
+
onMoveEnd?: (viewport: Viewport) => void;
|
|
13
|
+
/** Minimum zoom level. Default: 0.5 */
|
|
14
|
+
minZoom?: number;
|
|
15
|
+
/** Maximum zoom level. Default: 2 */
|
|
16
|
+
maxZoom?: number;
|
|
17
|
+
/** Is panning enabled? Default: true */
|
|
18
|
+
pannable?: boolean;
|
|
19
|
+
/** Is zooming enabled? Default: true */
|
|
20
|
+
zoomable?: boolean;
|
|
21
|
+
/** Viewport pan boundaries [[minX, minY], [maxX, maxY]]. Limits how far the viewport can pan. */
|
|
22
|
+
translateExtent?: [[number, number], [number, number]];
|
|
23
|
+
/** Return true to block pan/zoom (e.g. during animation lock). */
|
|
24
|
+
isLocked?: () => boolean;
|
|
25
|
+
/** CSS class name that prevents pan/zoom when on or inside event target. */
|
|
26
|
+
noPanClassName?: string;
|
|
27
|
+
/** CSS class name that prevents wheel zoom when on or inside event target. */
|
|
28
|
+
noWheelClassName?: string;
|
|
29
|
+
/** Return true when touch selection mode is active (suppress single-finger pan). */
|
|
30
|
+
isTouchSelectionMode?: () => boolean;
|
|
31
|
+
/** Pan viewport on wheel instead of zooming. Ctrl/Cmd+wheel zooms. Default: false */
|
|
32
|
+
panOnScroll?: boolean;
|
|
33
|
+
/** Which axes scroll-panning applies to. Default: 'both' */
|
|
34
|
+
panOnScrollDirection?: 'both' | 'vertical' | 'horizontal';
|
|
35
|
+
/** Multiplier for scroll pan sensitivity. Default: 1 */
|
|
36
|
+
panOnScrollSpeed?: number;
|
|
37
|
+
/** Called when pan-on-scroll needs to pan the viewport. */
|
|
38
|
+
onScrollPan?: (dx: number, dy: number) => void;
|
|
39
|
+
/** Zoom in on double-click. Default: true */
|
|
40
|
+
zoomOnDoubleClick?: boolean;
|
|
41
|
+
/** Key code that temporarily enables panning when held. Default: 'Space' */
|
|
42
|
+
panActivationKeyCode?: string | null;
|
|
43
|
+
/** Key code that forces zoom (overrides panOnScroll) when held with wheel. Default: 'Control'.
|
|
44
|
+
* Note: Ctrl/Meta already force zoom when panOnScroll is enabled. Set to null to disable. */
|
|
45
|
+
zoomActivationKeyCode?: string | null;
|
|
46
|
+
/** Which mouse buttons trigger panning. true = left (0), array = specific buttons, false = none.
|
|
47
|
+
* Default: true (left button) */
|
|
48
|
+
panOnDrag?: boolean | number[];
|
|
49
|
+
}
|
|
50
|
+
export interface PanZoomInstance {
|
|
51
|
+
/** Set viewport programmatically */
|
|
52
|
+
setViewport(viewport: Partial<Viewport>, options?: {
|
|
53
|
+
duration?: number;
|
|
54
|
+
}): void;
|
|
55
|
+
/** Get current d3 transform */
|
|
56
|
+
getTransform(): ZoomTransform;
|
|
57
|
+
/** Update options at runtime (e.g. toggle pannable/zoomable) */
|
|
58
|
+
update(options: Partial<PanZoomOptions>): void;
|
|
59
|
+
/** Clean up d3 listeners */
|
|
60
|
+
destroy(): void;
|
|
61
|
+
}
|
|
62
|
+
export declare function createPanZoom(container: HTMLElement, options: PanZoomOptions): PanZoomInstance;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { XYPosition } from './types';
|
|
2
|
+
interface NodeCenter {
|
|
3
|
+
id: string;
|
|
4
|
+
center: XYPosition;
|
|
5
|
+
}
|
|
6
|
+
export interface ProximityCandidate {
|
|
7
|
+
source: string;
|
|
8
|
+
target: string;
|
|
9
|
+
targetId: string;
|
|
10
|
+
distance: number;
|
|
11
|
+
targetCenter: XYPosition;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Infer source/target direction from two node positions.
|
|
15
|
+
* Node further left = source. If X is similar (within 30px), node further up = source.
|
|
16
|
+
*/
|
|
17
|
+
export declare function inferDirection(centerA: XYPosition, centerB: XYPosition, idA: string, idB: string): {
|
|
18
|
+
source: string;
|
|
19
|
+
target: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Find the closest node to the dragged node within the proximity threshold.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findProximityCandidate(draggedId: string, draggedCenter: XYPosition, allNodes: NodeCenter[], threshold: number): ProximityCandidate | null;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addon registry — singleton via window global.
|
|
3
|
+
*
|
|
4
|
+
* When AlpineFlow core is loaded from one bundle (e.g., WireFlow's
|
|
5
|
+
* alpineflow.bundle.esm.js) and addons are loaded from separate ESM
|
|
6
|
+
* files, each bundle gets its own module scope. A module-scoped Map
|
|
7
|
+
* would create disconnected registries — addons would register on
|
|
8
|
+
* their copy, but the core would check its own empty copy.
|
|
9
|
+
*
|
|
10
|
+
* Using a window global ensures all bundles share one registry,
|
|
11
|
+
* regardless of how they're loaded (CDN, npm, Vite, WireFlow bundle).
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerAddon(name: string, value: any): void;
|
|
14
|
+
export declare function getAddon<T = any>(name: string): T | undefined;
|
|
15
|
+
/** Test-only: clear all registered addons. */
|
|
16
|
+
export declare function _resetRegistry(): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge, Rect, Viewport } from './types';
|
|
2
|
+
/** A single node in the render plan output. */
|
|
3
|
+
export interface RenderPlanNode {
|
|
4
|
+
id: string;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
class?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
data: Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
/** A single edge in the render plan output. */
|
|
14
|
+
export interface RenderPlanEdge {
|
|
15
|
+
id: string;
|
|
16
|
+
source: string;
|
|
17
|
+
target: string;
|
|
18
|
+
pathD: string;
|
|
19
|
+
markerStart?: string;
|
|
20
|
+
markerEnd?: string;
|
|
21
|
+
class?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
labelX?: number;
|
|
24
|
+
labelY?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Full render plan returned by computeRenderPlan(). */
|
|
27
|
+
export interface RenderPlan {
|
|
28
|
+
nodes: RenderPlanNode[];
|
|
29
|
+
edges: RenderPlanEdge[];
|
|
30
|
+
markers: string;
|
|
31
|
+
viewBox: Rect;
|
|
32
|
+
viewport: Viewport;
|
|
33
|
+
}
|
|
34
|
+
/** Optional configuration for computeRenderPlan(). */
|
|
35
|
+
export interface RenderPlanConfig {
|
|
36
|
+
/** Default dimensions for nodes without explicit dimensions. Default: { width: 150, height: 50 } */
|
|
37
|
+
defaultDimensions?: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
/** Padding around the viewBox in flow-space pixels. Default: 20 */
|
|
42
|
+
padding?: number;
|
|
43
|
+
/** Flow ID used for marker ID generation. Default: 'ssr' */
|
|
44
|
+
flowId?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Compute a complete render plan from nodes and edges.
|
|
48
|
+
*
|
|
49
|
+
* Pre-computes edge SVG paths, marker defs, and viewport so a flow diagram
|
|
50
|
+
* can be rendered server-side without any DOM or JavaScript.
|
|
51
|
+
*/
|
|
52
|
+
export declare function computeRenderPlan(nodes: FlowNode[], edges: FlowEdge[], config?: RenderPlanConfig): RenderPlan;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { XYPosition, Dimensions } from './types';
|
|
2
|
+
/** Which edge or corner is being dragged */
|
|
3
|
+
export type ResizeDirection = 'top-left' | 'top' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
|
|
4
|
+
/** Min/max size constraints for resizable nodes */
|
|
5
|
+
export interface ResizeConstraints {
|
|
6
|
+
minWidth: number;
|
|
7
|
+
minHeight: number;
|
|
8
|
+
maxWidth: number;
|
|
9
|
+
maxHeight: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_RESIZE_CONSTRAINTS: ResizeConstraints;
|
|
12
|
+
/** Result of a resize computation */
|
|
13
|
+
export interface ResizeResult {
|
|
14
|
+
position: XYPosition;
|
|
15
|
+
dimensions: Dimensions;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Compute the new position and dimensions after a resize drag.
|
|
19
|
+
*
|
|
20
|
+
* For left/top handles, position decreases by the same amount dimensions
|
|
21
|
+
* increase. The actual delta is derived after clamping to prevent position
|
|
22
|
+
* drift when hitting constraint boundaries.
|
|
23
|
+
*
|
|
24
|
+
* @param direction - Which handle is being dragged
|
|
25
|
+
* @param delta - Mouse movement in flow coordinates since drag start
|
|
26
|
+
* @param startPosition - Node position at drag start
|
|
27
|
+
* @param startDimensions - Node dimensions at drag start
|
|
28
|
+
* @param constraints - Min/max size constraints
|
|
29
|
+
* @param snapToGrid - Optional grid snapping [gridX, gridY]
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeResize(direction: ResizeDirection, delta: XYPosition, startPosition: XYPosition, startDimensions: Dimensions, constraints: ResizeConstraints, snapToGrid?: false | [number, number]): ResizeResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rotate a point (px, py) around a center (cx, cy) by the given angle in degrees.
|
|
3
|
+
* Returns the rotated coordinates.
|
|
4
|
+
*/
|
|
5
|
+
export declare function rotatePoint(px: number, py: number, cx: number, cy: number, degrees: number): {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rect, Viewport } from './types';
|
|
2
|
+
export interface SelectionBoxInstance {
|
|
3
|
+
/** Start a new selection at a position relative to the container */
|
|
4
|
+
start(containerX: number, containerY: number, mode?: 'partial' | 'full'): void;
|
|
5
|
+
/** Update the selection box to a new position relative to the container */
|
|
6
|
+
update(containerX: number, containerY: number): void;
|
|
7
|
+
/** Finish selection and return the rect in flow coordinates */
|
|
8
|
+
end(viewport: Viewport): Rect | null;
|
|
9
|
+
/** Whether a selection is in progress */
|
|
10
|
+
isActive(): boolean;
|
|
11
|
+
/** Remove from DOM */
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSelectionBox(container: HTMLElement): SelectionBoxInstance;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HandlePosition, ShapeDefinition } from './types';
|
|
2
|
+
/** Rectangular fallback — same as the default getHandleCoords logic. */
|
|
3
|
+
declare function rectPerimeter(w: number, h: number, position: HandlePosition): {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
/** Built-in shape definitions, keyed by NodeShape name. */
|
|
8
|
+
export declare const builtinShapes: Record<string, ShapeDefinition>;
|
|
9
|
+
/** Rectangular fallback for nodes without a shape or unknown shapes. */
|
|
10
|
+
export { rectPerimeter };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FlowNode, XYPosition, Dimensions, CoordinateExtent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Build a Map<string, FlowNode> for O(1) lookups by node ID.
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildNodeMap(nodes: FlowNode[]): Map<string, FlowNode>;
|
|
6
|
+
/**
|
|
7
|
+
* Walk the parentId chain and sum positions to get the absolute flow-space
|
|
8
|
+
* position of a node. Iterative with a visited-set cycle guard.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAbsolutePosition(node: FlowNode, nodeMap: Map<string, FlowNode>, globalOrigin?: [number, number]): XYPosition;
|
|
11
|
+
/**
|
|
12
|
+
* Create a shallow copy of a node with its position set to absolute
|
|
13
|
+
* flow-space coordinates. Shares all other property references.
|
|
14
|
+
*/
|
|
15
|
+
export declare function toAbsoluteNode(node: FlowNode, nodeMap: Map<string, FlowNode>, globalOrigin?: [number, number]): FlowNode;
|
|
16
|
+
/**
|
|
17
|
+
* Map all nodes to absolute-position wrappers.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toAbsoluteNodes(nodes: FlowNode[], nodeMap: Map<string, FlowNode>, globalOrigin?: [number, number]): FlowNode[];
|
|
20
|
+
/**
|
|
21
|
+
* BFS to collect all descendant IDs of a given node.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDescendantIds(nodeId: string, nodes: FlowNode[]): Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Sort nodes so parents appear before children. Preserves sibling order.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sortNodesTopological(nodes: FlowNode[]): FlowNode[];
|
|
28
|
+
/**
|
|
29
|
+
* Compute the effective z-index for a node.
|
|
30
|
+
*
|
|
31
|
+
* Base layering is handled by CSS:
|
|
32
|
+
* .flow-node-group { z-index: 0 } → .flow-edges { z-index: 1 } → .flow-node { z-index: 2 }
|
|
33
|
+
*
|
|
34
|
+
* This function is used by the directive to compute inline overrides for
|
|
35
|
+
* child nodes in sub-flows and nodes with explicit zIndex. Returns null
|
|
36
|
+
* when the CSS default is sufficient (regular root nodes without zIndex).
|
|
37
|
+
*
|
|
38
|
+
* - Group nodes (`type === 'group'`): 0 + (node.zIndex ?? 0) — below edge layer
|
|
39
|
+
* - Regular root nodes: 2 + (node.zIndex ?? 0) — above edge layer
|
|
40
|
+
* - Child nodes: parentComputedZ + 2 + (node.zIndex ?? 0) — above edge layer & parent
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeZIndex(node: FlowNode, nodeMap: Map<string, FlowNode>, visited?: Set<string>): number;
|
|
43
|
+
/**
|
|
44
|
+
* Clamp a position within a coordinate extent [[minX, minY], [maxX, maxY]].
|
|
45
|
+
* Subtracts node dimensions from max so the entire node stays in bounds.
|
|
46
|
+
*/
|
|
47
|
+
export declare function clampToExtent(position: XYPosition, extent: CoordinateExtent, dimensions?: Dimensions): XYPosition;
|
|
48
|
+
/**
|
|
49
|
+
* Clamp a relative position so the child stays within parent bounds.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clampToParent(relPos: XYPosition, childDims: Dimensions, parentDims: Dimensions): XYPosition;
|
|
52
|
+
/**
|
|
53
|
+
* Return expanded parent dimensions if the child exceeds the parent bounds.
|
|
54
|
+
* Grows right/bottom with padding. Returns null if no expansion needed.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Clamp a root-level node's position within its applicable extent.
|
|
58
|
+
* Skips nodes with parentId or 'parent' extent (those use clampToParent).
|
|
59
|
+
*/
|
|
60
|
+
export declare function clampRootNodePosition(position: XYPosition, node: FlowNode, globalExtent?: CoordinateExtent | 'parent'): XYPosition;
|
|
61
|
+
export declare function expandParentToFitChild(relPos: XYPosition, childDims: Dimensions, parentDims: Dimensions): Dimensions | null;
|