UNPKG

@donverduyn/react-runtime

Version:
37 lines (36 loc) 1.29 kB
import type { RegisterId, ScopeId } from '@/types'; /** * Represents a node in the TreeMap. */ type TreeMapNode = { id: string; meta: TreeMapMeta; }; /** * Represents the meta data for a TreeMapNode. */ type TreeMapMeta = { [key: string]: unknown; }; /** * Store interface for managing TreeMap nodes and subscriptions. */ export type TreeMapStore = { update: (id: RegisterId, parentId: RegisterId) => void; register: (id: RegisterId, parentId: RegisterId) => void; unregister: (id: RegisterId) => void; getParent: (id: RegisterId) => RegisterId | null; isRoot: (id: RegisterId) => boolean; getRoot: () => RegisterId | null; }; /** * Creates a new TreeMapNode. * @param {string} id - The unique identifier for the node. * @param {TreeMapMeta} [meta={}] - Optional metadata for the node. * @returns {TreeMapNode} The created TreeMapNode. */ export declare function createTreeMapNode(id: RegisterId, meta?: TreeMapMeta): TreeMapNode; export declare const useTreeMap: (scopeId: ScopeId, id?: RegisterId, parentId?: RegisterId | null) => TreeMapStore; export declare const getTreeMap: (scopeId: ScopeId) => TreeMapStore; export declare const useTreeMapBinding: (id: RegisterId, parentId: RegisterId, treeMap: TreeMapStore) => () => void; export {};