import { readable, writable } from 'svelte/store'; import { infiniteExtent, SelectionMode, ConnectionMode, ConnectionLineType, type SelectionRect, type Transform, type SnapGrid, type MarkerProps, type PanZoomInstance, type CoordinateExtent, type IsValidConnection, type GroupedEdges, type NodeOrigin, type OnError, devWarn } from '@xyflow/system'; import DefaultNode from '$lib/components/nodes/DefaultNode.svelte'; import InputNode from '$lib/components/nodes/InputNode.svelte'; import OutputNode from '$lib/components/nodes/OutputNode.svelte'; import BezierEdge from '$lib/components/edges/BezierEdge.svelte'; import StraightEdge from '$lib/components/edges/StraightEdge.svelte'; import SmoothStepEdge from '$lib/components/edges/SmoothStepEdge.svelte'; import StepEdge from '$lib/components/edges/StepEdge.svelte'; import type { NodeTypes, EdgeTypes, EdgeLayouted, Node, FitViewOptions } from '$lib/types'; import { createNodesStore, createEdgesStore } from './utils'; import { initConnectionProps, type ConnectionProps } from './derived-connection-props'; export const initialNodeTypes = { input: InputNode, output: OutputNode, default: DefaultNode }; export const initialEdgeTypes = { straight: StraightEdge, smoothstep: SmoothStepEdge, default: BezierEdge, step: StepEdge }; export const getInitialStore = () => ({ flowId: writable(null), nodes: createNodesStore([]), visibleNodes: readable([]), edges: createEdgesStore([]), edgeTree: readable[]>([]), height: writable(500), width: writable(500), minZoom: writable(0.5), maxZoom: writable(2), nodeOrigin: writable([0, 0]), nodeExtent: writable(infiniteExtent), translateExtent: writable(infiniteExtent), autoPanOnNodeDrag: writable(true), autoPanOnConnect: writable(true), fitViewOnInit: writable(false), fitViewOnInitDone: writable(false), fitViewOptions: writable(undefined), panZoom: writable(null), snapGrid: writable(null), dragging: writable(false), selectionRect: writable(null), selectionKeyPressed: writable(false), multiselectionKeyPressed: writable(false), deleteKeyPressed: writable(false), panActivationKeyPressed: writable(false), selectionRectMode: writable(null), selectionMode: writable(SelectionMode.Partial), nodeTypes: writable(initialNodeTypes), edgeTypes: writable(initialEdgeTypes), transform: writable([0, 0, 1]), connectionMode: writable(ConnectionMode.Strict), domNode: writable(null), connection: readable(initConnectionProps), connectionLineType: writable(ConnectionLineType.Bezier), connectionRadius: writable(20), isValidConnection: writable(() => true), nodesDraggable: writable(true), nodesConnectable: writable(true), elementsSelectable: writable(true), selectNodesOnDrag: writable(true), markers: readable([]), defaultMarkerColor: writable('#b1b1b7'), lib: readable('svelte'), onlyRenderVisibleElements: writable(false), onError: writable(devWarn) });