mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(site): add util reference pipeline (#537)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c11395ece1
commit
78112fbefd
@@ -26,24 +26,38 @@ export function PlayerContextProvider({
|
||||
return <PlayerContext.Provider value={value}>{children}</PlayerContext.Provider>;
|
||||
}
|
||||
|
||||
/** Access the full player context value. Throws if used outside a Player Provider. */
|
||||
export function usePlayerContext(): PlayerContextValue {
|
||||
const ctx = useContext(PlayerContext);
|
||||
if (!ctx) throw new Error('usePlayerContext must be used within a Player Provider');
|
||||
return ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the player store from within a Player Provider.
|
||||
*
|
||||
* @label Without Selector
|
||||
*/
|
||||
export function usePlayer(): UnknownStore;
|
||||
/**
|
||||
* Select a value from the player store. Re-renders when the selected value changes.
|
||||
*
|
||||
* @label With Selector
|
||||
* @param selector - Derives a value from the player store state.
|
||||
*/
|
||||
export function usePlayer<R>(selector: (state: UnknownState) => R): R;
|
||||
export function usePlayer<R>(selector?: (state: UnknownState) => R) {
|
||||
const { store } = usePlayerContext();
|
||||
return useStore(store, selector as any);
|
||||
}
|
||||
|
||||
/** Access the media element from within a Player Provider. */
|
||||
export function useMedia(): Media | null {
|
||||
const { media } = usePlayerContext();
|
||||
return media;
|
||||
}
|
||||
|
||||
/** Access the media registration setter for connecting a media element to the player. */
|
||||
export function useMediaRegistration(): Dispatch<SetStateAction<Media | null>> | undefined {
|
||||
const ctx = useContext(PlayerContext);
|
||||
return ctx?.setMedia;
|
||||
|
||||
@@ -40,10 +40,28 @@ export type UsePlayerHook<Store extends PlayerStore> = {
|
||||
<R>(selector: (state: InferStoreState<Store>) => R): R;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a player instance with typed store, Provider component, Container, and hooks.
|
||||
*
|
||||
* @label Video
|
||||
* @param config - Player configuration with features and optional display name.
|
||||
*/
|
||||
export function createPlayer(config: CreatePlayerConfig<VideoFeatures>): CreatePlayerResult<VideoPlayerStore>;
|
||||
|
||||
/**
|
||||
* Create a player for audio media.
|
||||
*
|
||||
* @label Audio
|
||||
* @param config - Player configuration with features and optional display name.
|
||||
*/
|
||||
export function createPlayer(config: CreatePlayerConfig<AudioFeatures>): CreatePlayerResult<AudioPlayerStore>;
|
||||
|
||||
/**
|
||||
* Create a player with custom features.
|
||||
*
|
||||
* @label Generic
|
||||
* @param config - Player configuration with features and optional display name.
|
||||
*/
|
||||
export function createPlayer<const Features extends AnyPlayerFeature[]>(
|
||||
config: CreatePlayerConfig<Features>
|
||||
): CreatePlayerResult<PlayerStore<Features>>;
|
||||
|
||||
Reference in New Issue
Block a user