import { type Entity, type MapInteractionState, type MapLayer, type ShapeEntity } from "@trackunit/react-map-adapter-shared"; import { type RefObject } from "react"; import type { MapApi } from "../../core/types"; import type { LayerHandle, ShapeStyle } from "../types"; type UseShapeDecorationsConfig = Readonly<{ onDecorationsChange: (layers: ReadonlyArray) => void; onStyleOverridesChange: (overrides: ReadonlyMap>) => void; api: MapApi | undefined; handles: ReadonlyArray; renderedSourceIds: RefObject>; hasSourceReadiness: boolean; readyRevision: number; interaction: MapInteractionState; select?: (entity: Entity | null) => void; hover?: (entity: Entity | null) => void; }>; /** * Interaction data for a single placed decoration. Layers matches portal * descriptors to entries via source ID and wraps interactive ones with * ``. */ export type InteractionEntry = Readonly<{ entity: ShapeEntity; onClick?: (entity: ShapeEntity) => void; onHover?: (entity: ShapeEntity | null) => void; }>; /** * External store for the interaction map, consumed by Layers via * `useSyncExternalStore` to avoid reading a ref during render. */ export type InteractionMapStore = Readonly<{ subscribe: (listener: () => void) => () => void; getSnapshot: () => ReadonlyMap; }>; /** * Unified decoration hook — replaces both the old `useShapeDecorations` and * `useEdgeLabels` with a single pass per feature. * * Processing per feature: * 1. Collect decorations from `handle.getDecorations` * 2. Partition: static anchors vs viewport-aware (`vertex-auto`, `edge-auto`) * 3. Resolve static anchors, compute edge properties for `edge-*` anchors * 4. `vertex-auto`: `findBestVisibleVertex` * 5. `edge-auto`: build `ShapeLabelResolutionContext`, invoke optional * `resolveLabel`, then `computeEdgeAutoPlacement` → placed / hidden * 6. Create `kind:"anchor"` marker sources for all placed decorations * 7. Build interaction map for Layers to wrap interactive portals * * Has no dependency on `api.annotations` — consumers that want chrome-bar * fallback opt in explicitly via `useMapAnnotation`. * * @returns Interaction map keyed by source ID. * @internal */ export declare const useShapeDecorations: ({ onDecorationsChange, onStyleOverridesChange, api, handles, renderedSourceIds, hasSourceReadiness, readyRevision, interaction, select, hover, }: UseShapeDecorationsConfig) => InteractionMapStore; export {};