import type { MapApi } from "../../core/types"; import type { PanelPreloadInitiator, PanelPreloadInitiatorType } from "./preloadInitiators"; export type UsePanelPreloadOptions = Readonly<{ /** * Called at most once per entity per hook mount when any initiator * determines the entity's data should be prefetched. * * May be called for the same entity from multiple initiators — idempotency * is the consumer's responsibility. Apollo's `fetchPolicy: "cache-first"` * handles this naturally: a second call is a no-op when data is cached. */ onPreload: (entityId: string, initiator: PanelPreloadInitiatorType) => void; /** * One or more preload triggers. Each one independently decides which * entities to preload — pass both `hover` and `proximity` to get layered * coverage. */ initiators: ReadonlyArray; }>; /** * Registers preload initiators for a map panel. * * Fires `onPreload` when an initiator determines an entity's data should be * fetched before the panel opens — so the Apollo cache is warm by the time * the user selects the marker. * * The hook is data-agnostic: the consumer decides what to fetch in `onPreload`. * * ```tsx * const client = useApolloClient(); * usePanelPreload(api, { * onPreload: (entityId) => { * void client.query({ * query: GetEntityDocument, * variables: { entityId }, * fetchPolicy: "cache-first", * }); * }, * initiators: [ * { type: "hover", entityId: layers.interaction.hoveredEntity?.id ?? null }, * { type: "proximity", referenceEntityId: selectedEntityId, entities: markers, count: 3 }, * ], * }); * ``` */ export declare const usePanelPreload: (api: MapApi, options: UsePanelPreloadOptions) => void;