Files
md-files/.claude/skills/reveal-3d/code/reveal/hooks/useRenderTarget.ts
T
2026-05-31 20:25:41 +00:00

31 lines
1.0 KiB
TypeScript

import { useContext } from 'react';
import {
InstanceStylingContext,
type InstanceStylingController,
} from '../context/instanceStylingContext';
export interface RenderTarget {
instanceStylingController: InstanceStylingController;
}
/**
* Hook to access the render target which includes the instance styling controller.
* This allows components to read and react to centralized styling state.
*
* The controller provides methods to:
* - registerStylingGroup(group): Register a new styling group and get its ID
* - unregisterStylingGroup(id): Remove a styling group by ID
* - getStylingGroups(): Get all current styling groups
* - addEventListener(callback): Subscribe to styling changes
* - removeEventListener(callback): Unsubscribe from styling changes
*/
export function useRenderTarget(): RenderTarget {
const stylingContext = useContext(InstanceStylingContext);
if (!stylingContext) {
throw new Error(
'useRenderTarget must be used within an InstanceStylingProvider'
);
}
return { instanceStylingController: stylingContext };
}