@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,36 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import type { FlowNode, FlowEdge } from '../core/types';
|
|
3
|
+
import type { CollabProvider } from './types';
|
|
4
|
+
interface ReactiveState {
|
|
5
|
+
nodes: FlowNode[];
|
|
6
|
+
edges: FlowEdge[];
|
|
7
|
+
_rebuildNodeMap?: () => void;
|
|
8
|
+
_rebuildEdgeMap?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class CollabBridge {
|
|
11
|
+
private doc;
|
|
12
|
+
private state;
|
|
13
|
+
private yNodes;
|
|
14
|
+
private yEdges;
|
|
15
|
+
private destroyed;
|
|
16
|
+
private _initialSyncDone;
|
|
17
|
+
/** Node IDs currently being dragged locally — skip overwriting their position during pull */
|
|
18
|
+
private _draggingNodeIds;
|
|
19
|
+
private nodeObserver;
|
|
20
|
+
private edgeObserver;
|
|
21
|
+
constructor(doc: Y.Doc, state: ReactiveState, provider?: CollabProvider);
|
|
22
|
+
private _resolveInitialState;
|
|
23
|
+
private _pushInitialState;
|
|
24
|
+
pushLocalNodeUpdate(nodeId: string, changes: Record<string, any>): void;
|
|
25
|
+
pushLocalNodeAdd(node: FlowNode): void;
|
|
26
|
+
pushLocalNodeRemove(nodeId: string): void;
|
|
27
|
+
pushLocalEdgeAdd(edge: FlowEdge): void;
|
|
28
|
+
pushLocalEdgeRemove(edgeId: string): void;
|
|
29
|
+
/** Mark a node as being dragged locally — its position won't be overwritten by remote pulls. */
|
|
30
|
+
setDragging(nodeId: string, dragging: boolean): void;
|
|
31
|
+
private pullAllFromYjs;
|
|
32
|
+
private pullNodesFromYjs;
|
|
33
|
+
private pullEdgesFromYjs;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Alpine } from 'alpinejs';
|
|
2
|
+
import type { CollabAwarenessState } from '../types';
|
|
3
|
+
export declare const CURSOR_CLASS = "flow-collab-cursor";
|
|
4
|
+
/**
|
|
5
|
+
* Render remote user cursors into a container element.
|
|
6
|
+
* Reuses existing DOM elements when possible to avoid layout thrash.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderCursors(container: HTMLElement, remoteStates: Map<number, CollabAwarenessState>, localZoom: number): void;
|
|
9
|
+
/**
|
|
10
|
+
* Register the x-flow-cursors directive.
|
|
11
|
+
* Place inside x-flow-viewport to render remote user cursors.
|
|
12
|
+
*
|
|
13
|
+
* Handles async collab init — polls until collabStore entry is available,
|
|
14
|
+
* then subscribes to awareness changes for direct DOM cursor rendering.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerFlowCursorsDirective(Alpine: Alpine): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Alpine } from 'alpinejs';
|
|
2
|
+
import { Doc } from 'yjs';
|
|
3
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
4
|
+
import { CollabBridge } from './bridge';
|
|
5
|
+
import { CollabAwareness } from './awareness';
|
|
6
|
+
export interface CollabFactory {
|
|
7
|
+
Doc: typeof Doc;
|
|
8
|
+
Awareness: typeof Awareness;
|
|
9
|
+
CollabBridge: typeof CollabBridge;
|
|
10
|
+
CollabAwareness: typeof CollabAwareness;
|
|
11
|
+
}
|
|
12
|
+
export default function AlpineFlowCollab(Alpine: Alpine): void;
|
|
13
|
+
export { CollabBridge } from './bridge';
|
|
14
|
+
export { CollabAwareness } from './awareness';
|
|
15
|
+
export { WebSocketProvider } from './providers/websocket';
|
|
16
|
+
export { ReverbProvider } from './providers/reverb';
|
|
17
|
+
export { InMemoryProvider, linkProviders } from './providers/in-memory';
|
|
18
|
+
export { registerFlowCursorsDirective } from './directives/flow-cursors';
|
|
19
|
+
export type { CollabProvider, CollabConfig, CollabInstance, CollabUser, CollabAwarenessState, CollabStatus, } from './types';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory collaboration provider for demo/testing purposes.
|
|
3
|
+
*
|
|
4
|
+
* Connects two Yjs documents directly in the same browser tab,
|
|
5
|
+
* simulating two users without any network transport.
|
|
6
|
+
* In production, use WebSocketProvider or ReverbProvider instead.
|
|
7
|
+
*/
|
|
8
|
+
import * as Y from 'yjs';
|
|
9
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
10
|
+
import type { CollabProvider, CollabStatus } from '../types';
|
|
11
|
+
interface InMemoryProviderConfig {
|
|
12
|
+
roomId: string;
|
|
13
|
+
}
|
|
14
|
+
type StatusListener = (status: CollabStatus) => void;
|
|
15
|
+
type SyncListener = (synced: boolean) => void;
|
|
16
|
+
type Listener = StatusListener | SyncListener;
|
|
17
|
+
export declare class InMemoryProvider implements CollabProvider {
|
|
18
|
+
readonly roomId: string;
|
|
19
|
+
connected: boolean;
|
|
20
|
+
doc: Y.Doc | null;
|
|
21
|
+
awareness: Awareness | null;
|
|
22
|
+
peer: InMemoryProvider | null;
|
|
23
|
+
private _listeners;
|
|
24
|
+
private _synced;
|
|
25
|
+
private _docUpdateHandler;
|
|
26
|
+
private _peerDocUpdateHandler;
|
|
27
|
+
private _awarenessUpdateHandler;
|
|
28
|
+
private _peerAwarenessUpdateHandler;
|
|
29
|
+
constructor(config: InMemoryProviderConfig);
|
|
30
|
+
connect(doc: Y.Doc, awareness: Awareness): void;
|
|
31
|
+
disconnect(): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
on(event: 'status', cb: (status: CollabStatus) => void): void;
|
|
34
|
+
on(event: 'sync', cb: (synced: boolean) => void): void;
|
|
35
|
+
off(event: string, cb: Listener): void;
|
|
36
|
+
private _emit;
|
|
37
|
+
private _setupSync;
|
|
38
|
+
}
|
|
39
|
+
/** Link two InMemoryProviders so they sync when both connect. */
|
|
40
|
+
export declare function linkProviders(a: InMemoryProvider, b: InMemoryProvider): void;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { applyUpdate as yjsApplyUpdate, encodeStateAsUpdate, encodeStateVector } from 'yjs';
|
|
2
|
+
import type { Doc as YDoc } from 'yjs';
|
|
3
|
+
import type { Awareness } from 'y-protocols/awareness';
|
|
4
|
+
import type { CollabProvider, CollabStatus, CollabUser } from '../types';
|
|
5
|
+
/** @internal Called by AlpineFlowCollab to share yjs function references. */
|
|
6
|
+
export declare function setYjsFunctions(fns: {
|
|
7
|
+
applyUpdate: typeof yjsApplyUpdate;
|
|
8
|
+
encodeStateAsUpdate: typeof encodeStateAsUpdate;
|
|
9
|
+
encodeStateVector: typeof encodeStateVector;
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function base64Encode(bytes: Uint8Array): string;
|
|
12
|
+
export declare function base64Decode(str: string): Uint8Array;
|
|
13
|
+
interface ReverbProviderConfig {
|
|
14
|
+
roomId: string;
|
|
15
|
+
/** Echo channel pattern. `{roomId}` is replaced with the actual room ID. */
|
|
16
|
+
channel: string;
|
|
17
|
+
user: CollabUser;
|
|
18
|
+
/** URL for initial state fetch. `{roomId}` is replaced. Optional. */
|
|
19
|
+
stateUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
type EventMap = {
|
|
22
|
+
status: CollabStatus;
|
|
23
|
+
sync: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* ReverbProvider — Sends base64-encoded Yjs updates through Laravel Echo
|
|
27
|
+
* private channels (Reverb/Pusher protocol). Uses whisper events for
|
|
28
|
+
* low-latency peer-to-peer communication.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ReverbProvider implements CollabProvider {
|
|
31
|
+
readonly roomId: string;
|
|
32
|
+
private channelPattern;
|
|
33
|
+
private user;
|
|
34
|
+
private stateUrl?;
|
|
35
|
+
private channel;
|
|
36
|
+
private doc;
|
|
37
|
+
private awareness;
|
|
38
|
+
private listeners;
|
|
39
|
+
private _connected;
|
|
40
|
+
private updateHandler;
|
|
41
|
+
private awarenessHandler;
|
|
42
|
+
private _saveTimer;
|
|
43
|
+
private _saveDirty;
|
|
44
|
+
constructor(config: ReverbProviderConfig);
|
|
45
|
+
get connected(): boolean;
|
|
46
|
+
connect(doc: YDoc, awareness: Awareness): void;
|
|
47
|
+
disconnect(): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
on<K extends keyof EventMap>(event: K, cb: (val: EventMap[K]) => void): void;
|
|
50
|
+
off(event: string, cb: (...args: any[]) => void): void;
|
|
51
|
+
private emit;
|
|
52
|
+
private cleanupListeners;
|
|
53
|
+
/** Mark doc as dirty — will save to stateUrl within 5 seconds. */
|
|
54
|
+
private _markDirty;
|
|
55
|
+
/** Save current doc state to stateUrl. */
|
|
56
|
+
private _saveStateNow;
|
|
57
|
+
private fetchInitialState;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Doc as YDoc } from 'yjs';
|
|
2
|
+
import type { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
import type { CollabProvider, CollabStatus, CollabUser } from '../types';
|
|
4
|
+
interface WebSocketProviderConfig {
|
|
5
|
+
roomId: string;
|
|
6
|
+
url: string;
|
|
7
|
+
user: CollabUser;
|
|
8
|
+
}
|
|
9
|
+
type EventMap = {
|
|
10
|
+
status: CollabStatus;
|
|
11
|
+
sync: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* WebSocketProvider — Wraps y-websocket for direct WebSocket transport.
|
|
15
|
+
* Binary frames, most efficient. Requires a y-websocket server.
|
|
16
|
+
*/
|
|
17
|
+
export declare class WebSocketProvider implements CollabProvider {
|
|
18
|
+
readonly roomId: string;
|
|
19
|
+
private url;
|
|
20
|
+
private user;
|
|
21
|
+
private wsProvider;
|
|
22
|
+
private listeners;
|
|
23
|
+
private _connected;
|
|
24
|
+
constructor(config: WebSocketProviderConfig);
|
|
25
|
+
get connected(): boolean;
|
|
26
|
+
connect(doc: YDoc, awareness: Awareness): void;
|
|
27
|
+
disconnect(): void;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
on<K extends keyof EventMap>(event: K, cb: (val: EventMap[K]) => void): void;
|
|
30
|
+
off(event: string, cb: (...args: any[]) => void): void;
|
|
31
|
+
private emit;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global store for collaboration instances.
|
|
3
|
+
*
|
|
4
|
+
* Collab objects (Yjs Doc, CollabBridge, CollabAwareness) contain circular
|
|
5
|
+
* references that crash Alpine's deep-reactive proxy walker. Instead of
|
|
6
|
+
* attaching them to the Alpine data object, they live here in a WeakMap
|
|
7
|
+
* keyed by the canvas container element. Both flow-canvas.ts and the
|
|
8
|
+
* x-flow-cursors directive import from this module.
|
|
9
|
+
*
|
|
10
|
+
* Uses globalThis to ensure a single shared instance across bundles —
|
|
11
|
+
* when core loads from one bundle and the collab addon from another,
|
|
12
|
+
* both must read/write the same WeakMap.
|
|
13
|
+
*/
|
|
14
|
+
import type { CollabBridge } from './bridge';
|
|
15
|
+
import type { CollabAwareness } from './awareness';
|
|
16
|
+
export interface CollabEntry {
|
|
17
|
+
bridge: CollabBridge;
|
|
18
|
+
awareness: CollabAwareness;
|
|
19
|
+
doc: any;
|
|
20
|
+
cursorCleanup?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const collabStore: WeakMap<HTMLElement, CollabEntry>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Doc as YDoc } from 'yjs';
|
|
2
|
+
import type { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
export type CollabStatus = 'connecting' | 'connected' | 'disconnected';
|
|
4
|
+
export interface CollabProvider {
|
|
5
|
+
/** Connect the provider to a Yjs document and awareness instance. */
|
|
6
|
+
connect(doc: YDoc, awareness: Awareness): void;
|
|
7
|
+
/** Disconnect from the remote peer(s). */
|
|
8
|
+
disconnect(): void;
|
|
9
|
+
/** Permanently tear down the provider and release resources. */
|
|
10
|
+
destroy(): void;
|
|
11
|
+
readonly connected: boolean;
|
|
12
|
+
readonly roomId: string;
|
|
13
|
+
on(event: 'status', cb: (status: CollabStatus) => void): void;
|
|
14
|
+
on(event: 'sync', cb: (synced: boolean) => void): void;
|
|
15
|
+
off(event: string, cb: (...args: any[]) => void): void;
|
|
16
|
+
}
|
|
17
|
+
export interface CollabUser {
|
|
18
|
+
name: string;
|
|
19
|
+
color: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CollabAwarenessState {
|
|
22
|
+
user: CollabUser;
|
|
23
|
+
cursor: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
} | null;
|
|
27
|
+
selectedNodes: string[];
|
|
28
|
+
viewport: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
zoom: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface CollabConfig {
|
|
35
|
+
provider: CollabProvider;
|
|
36
|
+
user: CollabUser;
|
|
37
|
+
/** Show remote user cursors. Default true. */
|
|
38
|
+
cursors?: boolean;
|
|
39
|
+
/** Show remote user selections. Default true. */
|
|
40
|
+
selections?: boolean;
|
|
41
|
+
/** Cursor broadcast throttle in ms. Default 20. */
|
|
42
|
+
throttle?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface CollabInstance {
|
|
45
|
+
/** All connected users (reactive). */
|
|
46
|
+
readonly users: CollabUser[];
|
|
47
|
+
/** Number of connected users. */
|
|
48
|
+
readonly userCount: number;
|
|
49
|
+
/** Local user info. */
|
|
50
|
+
readonly me: CollabUser;
|
|
51
|
+
/** Whether the provider is currently connected. */
|
|
52
|
+
readonly connected: boolean;
|
|
53
|
+
/** Current connection status. */
|
|
54
|
+
readonly status: CollabStatus;
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from '../types';
|
|
2
|
+
export declare const nodeA: FlowNode;
|
|
3
|
+
export declare const nodeB: FlowNode;
|
|
4
|
+
export declare const nodeC: FlowNode;
|
|
5
|
+
export declare const nodeD: FlowNode;
|
|
6
|
+
export declare const hiddenNode: FlowNode;
|
|
7
|
+
export declare const undeletableNode: FlowNode;
|
|
8
|
+
export declare const hiddenEdge: FlowEdge;
|
|
9
|
+
export declare const undeletableEdge: FlowEdge;
|
|
10
|
+
export declare const groupNode: FlowNode;
|
|
11
|
+
export declare const childNode1: FlowNode;
|
|
12
|
+
export declare const childNode2: FlowNode;
|
|
13
|
+
export declare const grandchildNode: FlowNode;
|
|
14
|
+
export declare const edgeAB: FlowEdge;
|
|
15
|
+
export declare const edgeBC: FlowEdge;
|
|
16
|
+
export declare const edgeAC: FlowEdge;
|
|
17
|
+
export declare const edgeBD: FlowEdge;
|
|
18
|
+
export declare const nodes: FlowNode[];
|
|
19
|
+
export declare const edges: FlowEdge[];
|
|
20
|
+
export declare const subFlowNodes: FlowNode[];
|
|
21
|
+
export declare const collapsibleGroup: FlowNode;
|
|
22
|
+
export declare const cgChild1: FlowNode;
|
|
23
|
+
export declare const cgChild2: FlowNode;
|
|
24
|
+
export declare const cgExternalNode: FlowNode;
|
|
25
|
+
export declare const cgEdgeInternal: FlowEdge;
|
|
26
|
+
export declare const cgEdgeCrossing: FlowEdge;
|
|
27
|
+
export declare const collapseNodes: FlowNode[];
|
|
28
|
+
export declare const collapseEdges: FlowEdge[];
|
|
29
|
+
export declare const triggerNode: FlowNode;
|
|
30
|
+
export declare const outgoerA: FlowNode;
|
|
31
|
+
export declare const outgoerB: FlowNode;
|
|
32
|
+
export declare const outgoerC: FlowNode;
|
|
33
|
+
export declare const externalSrc: FlowNode;
|
|
34
|
+
export declare const edgeBasedNodes: FlowNode[];
|
|
35
|
+
export declare const edgeTriggerToA: FlowEdge;
|
|
36
|
+
export declare const edgeTriggerToB: FlowEdge;
|
|
37
|
+
export declare const edgeAToC: FlowEdge;
|
|
38
|
+
export declare const edgeExtToA: FlowEdge;
|
|
39
|
+
export declare const edgeBToExt: FlowEdge;
|
|
40
|
+
export declare const edgeBasedEdges: FlowEdge[];
|
|
41
|
+
export declare const groupWithCustomDims: FlowNode;
|
|
42
|
+
export declare function makeDOMRect(x: number, y: number, width: number, height: number): DOMRect;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARIA live region announcer for screen readers.
|
|
3
|
+
*
|
|
4
|
+
* Creates a visually-hidden div with aria-live="polite" that announces
|
|
5
|
+
* flow diagram changes. Hooks into _emit() via handleEvent().
|
|
6
|
+
*/
|
|
7
|
+
export type FormatAnnouncementFn = (event: string, detail: Record<string, any>) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Default event-to-announcement formatter.
|
|
10
|
+
* Returns null for events that should not be announced.
|
|
11
|
+
*/
|
|
12
|
+
export declare function defaultFormatAnnouncement(event: string, detail: Record<string, any>): string | null;
|
|
13
|
+
export declare class FlowAnnouncer {
|
|
14
|
+
private _el;
|
|
15
|
+
private _clearTimer;
|
|
16
|
+
private _formatMessage;
|
|
17
|
+
constructor(container: HTMLElement, formatMessage?: FormatAnnouncementFn);
|
|
18
|
+
announce(message: string): void;
|
|
19
|
+
handleEvent(event: string, detail: Record<string, any>): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the auto-pan delta for a single frame based on pointer proximity
|
|
3
|
+
* to container edges. Returns { dx, dy } where each value is 0 when the
|
|
4
|
+
* pointer is outside the detection zone, and scales linearly as the pointer
|
|
5
|
+
* moves closer to the edge.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAutoPanDelta(pointerX: number, pointerY: number, containerRect: DOMRect, speed: number): {
|
|
8
|
+
dx: number;
|
|
9
|
+
dy: number;
|
|
10
|
+
};
|
|
11
|
+
export interface AutoPanInstance {
|
|
12
|
+
/** Start the rAF pan loop */
|
|
13
|
+
start(): void;
|
|
14
|
+
/** Stop the rAF pan loop */
|
|
15
|
+
stop(): void;
|
|
16
|
+
/** Feed the latest pointer position (client coordinates) */
|
|
17
|
+
updatePointer(clientX: number, clientY: number): void;
|
|
18
|
+
/** Stop and clean up */
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
export interface AutoPanOptions {
|
|
22
|
+
/** The container element to read bounds from each frame */
|
|
23
|
+
container: HTMLElement;
|
|
24
|
+
/** Speed multiplier (default 15) */
|
|
25
|
+
speed: number;
|
|
26
|
+
/** Called each frame with the pixel delta to apply.
|
|
27
|
+
* Return `true` to signal that a boundary was hit and auto-pan should stop. */
|
|
28
|
+
onPan: (dx: number, dy: number) => void | boolean;
|
|
29
|
+
/** Return true to prevent auto-pan from activating (e.g. during animation lock). */
|
|
30
|
+
isLocked?: () => boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create an auto-pan instance that drives a rAF loop. Call `updatePointer()`
|
|
34
|
+
* on every pointermove/drag event; the loop reads the latest position each
|
|
35
|
+
* frame and invokes `onPan` when the pointer is inside the edge zone.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createAutoPan(options: AutoPanOptions): AutoPanInstance;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FlowNode, ChildLayout, XYPosition, Dimensions } from './types';
|
|
2
|
+
/** Result of a child layout computation. */
|
|
3
|
+
export interface ChildLayoutResult {
|
|
4
|
+
/** New positions for each child (relative to parent). */
|
|
5
|
+
positions: Map<string, XYPosition>;
|
|
6
|
+
/** Dimension overrides for stretched children. Only populated when stretch applies. */
|
|
7
|
+
dimensions: Map<string, Dimensions>;
|
|
8
|
+
/** Computed parent dimensions to fit all children. */
|
|
9
|
+
parentDimensions: Dimensions;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Compute child positions, dimension overrides, and parent auto-size
|
|
13
|
+
* for a layout parent. Pure function — does not mutate any nodes.
|
|
14
|
+
*
|
|
15
|
+
* @param availableSize - When the parent has been externally sized (e.g. stretched
|
|
16
|
+
* by its own parent), children stretch to fill this space instead of just maxW/maxH.
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeChildLayout(children: FlowNode[], config: ChildLayout, availableSize?: Dimensions): ChildLayoutResult;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FlowNode, ChildValidation, ChildValidationResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the effective ChildValidation rules for a parent node.
|
|
4
|
+
* Shallow-merges type-registry defaults with per-node overrides.
|
|
5
|
+
* Returns undefined if no rules apply.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveChildValidation(parent: FlowNode, typeRules: Record<string, ChildValidation>): ChildValidation | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Validate whether a child can be added to a parent.
|
|
10
|
+
* `currentChildren` is the list of existing children (before adding).
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateChildAdd(parent: FlowNode, child: FlowNode, currentChildren: FlowNode[], rules: ChildValidation | undefined): ChildValidationResult;
|
|
13
|
+
/**
|
|
14
|
+
* Validate whether a child can be removed from a parent.
|
|
15
|
+
* `currentChildren` includes the child being removed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateChildRemove(_parent: FlowNode, child: FlowNode, currentChildren: FlowNode[], rules: ChildValidation | undefined): ChildValidationResult;
|
|
18
|
+
/**
|
|
19
|
+
* Compute the current validation errors for a parent node.
|
|
20
|
+
* Returns an empty array when the parent is valid.
|
|
21
|
+
* Used for reactive state (not for blocking operations).
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeValidationErrors(_parent: FlowNode, currentChildren: FlowNode[], rules: ChildValidation | undefined): string[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Copy selected nodes and their internal edges to the clipboard.
|
|
4
|
+
* "Internal" means both source and target are in the selection.
|
|
5
|
+
*/
|
|
6
|
+
export declare function copySelection(nodes: FlowNode[], edges: FlowEdge[]): {
|
|
7
|
+
nodeCount: number;
|
|
8
|
+
edgeCount: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Paste clipboard contents with new IDs and accumulating offset.
|
|
12
|
+
* Returns null if clipboard is empty.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pasteClipboard(): {
|
|
15
|
+
nodes: FlowNode[];
|
|
16
|
+
edges: FlowEdge[];
|
|
17
|
+
} | null;
|
|
18
|
+
/**
|
|
19
|
+
* Copy selected nodes to clipboard and return their IDs for removal.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cutSelection(nodes: FlowNode[], edges: FlowEdge[]): {
|
|
22
|
+
nodeIds: string[];
|
|
23
|
+
edgeCount: number;
|
|
24
|
+
nodeCount: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Clear the clipboard.
|
|
28
|
+
*/
|
|
29
|
+
export declare function clearClipboard(): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FlowNode, FlowEdge, Dimensions, XYPosition } from './types';
|
|
2
|
+
/** Saved state needed to restore a node after expanding. */
|
|
3
|
+
export interface CollapseState {
|
|
4
|
+
targetPositions: Map<string, XYPosition>;
|
|
5
|
+
originalDimensions?: Dimensions;
|
|
6
|
+
reroutedEdges: Map<string, {
|
|
7
|
+
source: string;
|
|
8
|
+
target: string;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Determine which nodes to hide when collapsing a given node.
|
|
14
|
+
*
|
|
15
|
+
* Group nodes: returns all descendants via parentId hierarchy.
|
|
16
|
+
* Regular nodes: returns direct outgoers via edges, or all downstream
|
|
17
|
+
* outgoers when recursive is true.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCollapseTargets(nodeId: string, nodes: FlowNode[], edges: FlowEdge[], options?: {
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
}): Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Capture the current state of a node before collapsing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function captureCollapseState(node: FlowNode, allNodes: FlowNode[], targets: Set<string>): CollapseState;
|
|
26
|
+
/**
|
|
27
|
+
* Apply collapse: hide targets, optionally shrink node, set collapsed flag.
|
|
28
|
+
* When collapsedDimensions is provided the node is resized (typical for groups);
|
|
29
|
+
* when omitted the node keeps its current size (typical for regular nodes).
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyCollapse(node: FlowNode, allNodes: FlowNode[], state: CollapseState, collapsedDimensions?: Dimensions): void;
|
|
32
|
+
/**
|
|
33
|
+
* Apply expand: unhide targets, optionally restore dimensions, restore positions.
|
|
34
|
+
* For group nodes, respects nested collapsed groups — their descendants stay hidden.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyExpand(node: FlowNode, allNodes: FlowNode[], state: CollapseState, restoreDimensions?: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Reroute edges for collapse. Trigger-aware: edges between the trigger and
|
|
39
|
+
* hidden nodes are hidden (to prevent self-loops). External edges crossing
|
|
40
|
+
* the boundary are rerouted to the trigger. Returns saved originals for restore.
|
|
41
|
+
*/
|
|
42
|
+
export declare function rerouteEdgesForCollapse(triggerId: string, edges: FlowEdge[], hiddenSet: Set<string>): Map<string, {
|
|
43
|
+
source: string;
|
|
44
|
+
target: string;
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Restore edges to their original source/target after expanding.
|
|
49
|
+
*/
|
|
50
|
+
export declare function restoreReroutedEdges(edges: FlowEdge[], saved: Map<string, {
|
|
51
|
+
source: string;
|
|
52
|
+
target: string;
|
|
53
|
+
hidden?: boolean;
|
|
54
|
+
}>): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ColorMode = 'light' | 'dark' | 'system';
|
|
2
|
+
export interface ColorModeHandle {
|
|
3
|
+
/** Current resolved mode ('light' | 'dark'). */
|
|
4
|
+
readonly resolved: 'light' | 'dark';
|
|
5
|
+
/** Update the color mode. */
|
|
6
|
+
update(mode: ColorMode): void;
|
|
7
|
+
/** Clean up matchMedia listener. */
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
/** Create a color mode controller for a flow container element. */
|
|
11
|
+
export declare function createColorMode(container: HTMLElement, initial?: ColorMode): ColorModeHandle;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute engine for node-to-node data propagation.
|
|
3
|
+
*
|
|
4
|
+
* Nodes register compute functions by type. The engine runs in topological
|
|
5
|
+
* order, routing outputs through edges via handle port names.
|
|
6
|
+
*/
|
|
7
|
+
import type { FlowNode, FlowEdge } from './types';
|
|
8
|
+
export interface ComputeDefinition {
|
|
9
|
+
/** Compute function. Receives gathered inputs (keyed by target handle name)
|
|
10
|
+
* and the node's own data object. Returns outputs keyed by output port name. */
|
|
11
|
+
compute: (inputs: Record<string, any>, nodeData: Record<string, any>) => Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
export declare class ComputeEngine {
|
|
14
|
+
private _registry;
|
|
15
|
+
registerCompute(nodeType: string, definition: ComputeDefinition): void;
|
|
16
|
+
hasCompute(nodeType: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Kahn's algorithm topological sort. Skips back-edges in cycles
|
|
19
|
+
* by appending remaining nodes at the end.
|
|
20
|
+
*/
|
|
21
|
+
topologicalSort(nodes: FlowNode[], edges: FlowEdge[]): FlowNode[];
|
|
22
|
+
/**
|
|
23
|
+
* Run compute propagation.
|
|
24
|
+
*
|
|
25
|
+
* @param nodes All nodes in the graph
|
|
26
|
+
* @param edges All edges in the graph
|
|
27
|
+
* @param startNodeId If provided, only compute this node and its downstream descendants
|
|
28
|
+
* @returns Map of nodeId → output data for nodes that had a registered compute function
|
|
29
|
+
*/
|
|
30
|
+
compute(nodes: FlowNode[], edges: FlowEdge[], startNodeId?: string): Map<string, Record<string, any>>;
|
|
31
|
+
/** Get all downstream node IDs reachable from a start node. */
|
|
32
|
+
private _getDownstream;
|
|
33
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { XYPosition, HandlePosition, Connection } from './types';
|
|
2
|
+
export interface HandleBounds {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
handleId: string;
|
|
5
|
+
type: 'source' | 'target';
|
|
6
|
+
position: HandlePosition;
|
|
7
|
+
/** Absolute position of the handle center in flow coordinates */
|
|
8
|
+
absolutePosition: XYPosition;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check if a point is within the hit area of a handle.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPointInHandle(point: XYPosition, handle: HandleBounds, tolerance?: number): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Find the closest target handle to a given point.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findClosestHandle(point: XYPosition, handles: HandleBounds[], tolerance?: number): HandleBounds | null;
|
|
20
|
+
/**
|
|
21
|
+
* Validate whether a connection is allowed.
|
|
22
|
+
* Basic rules: no self-connections, no duplicate edges.
|
|
23
|
+
* Optional: reject connections that would create a directed cycle.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isValidConnection(connection: Connection, existingEdges: {
|
|
26
|
+
source: string;
|
|
27
|
+
target: string;
|
|
28
|
+
sourceHandle?: string;
|
|
29
|
+
targetHandle?: string;
|
|
30
|
+
}[], options?: {
|
|
31
|
+
preventCycles?: boolean;
|
|
32
|
+
}): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Stroke color applied to selected edges and active connection lines. */
|
|
2
|
+
export declare const CONNECTION_ACTIVE_COLOR = "#64748b";
|
|
3
|
+
/** Default stroke color for edge paths. */
|
|
4
|
+
export declare const DEFAULT_STROKE_COLOR = "#d4d4d8";
|
|
5
|
+
/** Stroke color applied to invalid connection lines. */
|
|
6
|
+
export declare const CONNECTION_INVALID_COLOR = "#ef4444";
|
|
7
|
+
/** Stroke width for temporary connection drag lines. */
|
|
8
|
+
export declare const TEMP_LINE_STROKE_WIDTH = "2";
|
|
9
|
+
/** Dash pattern for temporary connection drag lines. */
|
|
10
|
+
export declare const TEMP_LINE_DASH_PATTERN = "6 3";
|
|
11
|
+
/** Multiplier for zoom-in / zoom-out steps. */
|
|
12
|
+
export declare const ZOOM_STEP_FACTOR = 1.2;
|
|
13
|
+
/** Default padding ratio for fitView and layout operations. */
|
|
14
|
+
export declare const DEFAULT_FIT_PADDING = 0.2;
|
|
15
|
+
/** Minimum pointer movement (in px) before a click is treated as a drag. */
|
|
16
|
+
export declare const DRAG_THRESHOLD = 5;
|
|
17
|
+
/** Default snap radius (in flow-space px) for edge reconnection hit-detection. */
|
|
18
|
+
export declare const DEFAULT_RECONNECT_SNAP_RADIUS = 25;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ControlsPanelOptions {
|
|
2
|
+
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
3
|
+
orientation: 'vertical' | 'horizontal';
|
|
4
|
+
showZoom: boolean;
|
|
5
|
+
showFitView: boolean;
|
|
6
|
+
showInteractive: boolean;
|
|
7
|
+
showResetPanels: boolean;
|
|
8
|
+
external?: boolean;
|
|
9
|
+
onZoomIn: () => void;
|
|
10
|
+
onZoomOut: () => void;
|
|
11
|
+
onFitView: () => void;
|
|
12
|
+
onToggleInteractive: () => void;
|
|
13
|
+
onResetPanels: () => void;
|
|
14
|
+
}
|
|
15
|
+
export interface ControlsPanelInstance {
|
|
16
|
+
/** Update the interactive toggle icon to reflect current state */
|
|
17
|
+
update(state: {
|
|
18
|
+
isInteractive: boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
/** Remove the panel from the DOM */
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createControlsPanel(container: HTMLElement, options: ControlsPanelOptions): ControlsPanelInstance;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function setDebugEnabled(value: boolean): void;
|
|
2
|
+
export declare function isDebugEnabled(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Log a debug message to the console when debug mode is enabled.
|
|
5
|
+
*
|
|
6
|
+
* @param category - Log category (e.g. 'drag', 'viewport', 'edge', 'connection')
|
|
7
|
+
* @param message - Human-readable message
|
|
8
|
+
* @param data - Optional data to log alongside the message
|
|
9
|
+
*/
|
|
10
|
+
export declare function debug(category: string, message: string, data?: any): void;
|