PURPOSE
Stub module that exposes a React-ref hook for naming DOM anchor points in the UI. Anchors are intended targets for fly-to animations and positional FX (wallet counters, progress bars, nav tabs). The current implementation is a placeholder — it returns an unmanaged ref and does not register or track anchors anywhere.
OWNS
- The
useAnchorhook. - The intended contract for anchor identity (string
anchorIdkeys such aswallet-gems,bar-chapter).
READS FROM
- React’s
useRefto allocate the ref object returned to callers.
PUSHES TO
- Nothing. The hook returns a
RefObject<HTMLDivElement | null>to the calling component; no registry, store, or service is updated.
DOES NOT
- Register anchors in any global map or store.
- Track lifecycle (mount / unmount) of anchored elements.
- Resolve
anchorIdto a DOM node for animation systems — theanchorIdparameter is currently unused. - Compute screen-space coordinates or expose them to FX systems.
- Emit or subscribe to signals.
Signals
None. The stub does not publish or listen to any events.
Entry points
useAnchor(anchorId: string): React.RefObject<HTMLDivElement | null>— React hook. Callers spread the returned ref onto a JSX element viaref={...}. TheanchorIdargument is accepted but ignored in the stub.
Pattern notes
- Marked
STUB — not yet implementedin the source header. Treat this file as a placeholder API surface, not a working registry. - The
anchorIdparameter is prefixed with an underscore (_anchorId) to silence unused-arg warnings, signalling the value is reserved for a future implementation. - Return type is
RefObject<HTMLDivElement | null>, locking anchored elements todivnodes for now. - A real implementation would need a registry keyed by
anchorId, ref-callback wiring to capture mount/unmount, and a query API for FX systems to look up live DOM rects by id. - File lives under
src/starship-survivors/services/, alongside other engine-side service modules; the hook itself is React-side and intended for use by metagame UI components.