import { getContext } from 'svelte';

export const TINYFLOW_NODE_SIZE_OBSERVER = Symbol(
  'tinyflow_node_size_observer',
);

export type TinyflowNodeSizeObserver = {
  observe: (nodeId: string, element: Element) => void;
  unobserve: (element: Element) => void;
};

export function useTinyflowNodeSizeObserver() {
  return getContext<TinyflowNodeSizeObserver | undefined>(
    TINYFLOW_NODE_SIZE_OBSERVER,
  );
}
