@zuude-ui/video 0.1.35 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +223 -0
- package/dist/chunk-XV6ODTKT.js +2 -0
- package/dist/chunk-XV6ODTKT.js.map +1 -0
- package/dist/chunk-ZTXJNTLA.js +2 -0
- package/dist/chunk-ZTXJNTLA.js.map +1 -0
- package/dist/hooks/index.cjs +2 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +84 -0
- package/dist/hooks/index.d.ts +84 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -91
- package/dist/index.d.ts +59 -91
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/types-DejCaLAg.d.cts +9 -0
- package/dist/types-DejCaLAg.d.ts +9 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +51 -0
- package/dist/utils/index.d.ts +51 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +17 -12
- package/dist/chunk-WLYC6MHJ.js +0 -2
- package/dist/chunk-WLYC6MHJ.js.map +0 -1
- package/dist/new/index.cjs +0 -2
- package/dist/new/index.cjs.map +0 -1
- package/dist/new/index.d.cts +0 -36
- package/dist/new/index.d.ts +0 -36
- package/dist/new/index.js +0 -2
- package/dist/new/index.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,102 +1,70 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { V as VideoRef, a as VideoAutoplay } from './types-DejCaLAg.cjs';
|
|
4
|
+
export { C as CustomVideoRef } from './types-DejCaLAg.cjs';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
type VideoChildren = ReactNode | ((props: {
|
|
9
|
-
isPlaying: boolean;
|
|
10
|
-
togglePlay: () => void;
|
|
11
|
-
isMuted: boolean;
|
|
12
|
-
toggleMute: () => void;
|
|
13
|
-
speed: number;
|
|
14
|
-
onChangeSpeed: (speed: number) => void;
|
|
15
|
-
duration: number | null;
|
|
16
|
-
isFullscreen: boolean;
|
|
17
|
-
toggleFullscreen: () => void;
|
|
18
|
-
isPictureInPicture: boolean;
|
|
19
|
-
togglePictureInPicture: () => void;
|
|
20
|
-
showHidingElement: boolean;
|
|
21
|
-
}) => ReactNode);
|
|
22
|
-
type VideoConfig = {
|
|
23
|
-
startAt?: number;
|
|
24
|
-
range?: [number, number];
|
|
25
|
-
autoplayOnVisible?: boolean | number;
|
|
26
|
-
muteFallback?: (toggleMute: () => void) => ReactNode;
|
|
27
|
-
clickToPlay?: boolean;
|
|
28
|
-
};
|
|
29
|
-
interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
|
|
30
|
-
children?: VideoChildren;
|
|
31
|
-
autoPlay?: VideoAutoplay;
|
|
32
|
-
ratio?: string;
|
|
33
|
-
config?: VideoConfig;
|
|
34
|
-
controls?: boolean;
|
|
6
|
+
interface VideoConfig {
|
|
7
|
+
config?: Partial<{
|
|
8
|
+
clickToPlay: boolean;
|
|
9
|
+
}>;
|
|
35
10
|
}
|
|
36
|
-
interface VideoContextType {
|
|
11
|
+
interface VideoContextType extends VideoConfig {
|
|
37
12
|
videoRef: VideoRef;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
showHidingElement?: boolean;
|
|
44
|
-
setShowHidingElement?: (showHidingElement: boolean) => void;
|
|
13
|
+
setVideoRef: (video: VideoRef) => void;
|
|
14
|
+
error: string | null;
|
|
15
|
+
setError: (error: string | null) => void;
|
|
16
|
+
isFocused: boolean;
|
|
17
|
+
setIsFocused: (isFocused: boolean) => void;
|
|
45
18
|
}
|
|
46
|
-
|
|
47
|
-
interface HidingElementProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
19
|
+
type VideoProviderProps = Omit<React.ComponentProps<"div">, "onError"> & VideoConfig & {
|
|
48
20
|
children: React.ReactNode;
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Using compound components pattern
|
|
54
|
-
*/
|
|
55
|
-
declare const Video: React.ForwardRefExoticComponent<VideoProps & {
|
|
56
|
-
pause?: boolean;
|
|
57
|
-
} & React.RefAttributes<HTMLVideoElement>> & {
|
|
58
|
-
PlayPauseOnVideo: () => react_jsx_runtime.JSX.Element;
|
|
59
|
-
HidingElement: React.ComponentType<HidingElementProps>;
|
|
21
|
+
onError?: (error: string | null) => void;
|
|
60
22
|
};
|
|
61
|
-
|
|
23
|
+
declare const VideoProvider: React.MemoExoticComponent<({ children, config, onError, ...props }: VideoProviderProps) => react_jsx_runtime.JSX.Element>;
|
|
62
24
|
declare const useVideo: () => VideoContextType;
|
|
63
25
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
declare const useGetDuration: (ref: VideoRef) => {
|
|
77
|
-
duration: number | null;
|
|
78
|
-
isLoading: boolean;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
declare const usePlayPause: (ref: VideoRef, enabled: boolean) => {
|
|
82
|
-
togglePlay: () => void;
|
|
83
|
-
isPlaying: boolean;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
declare const useMuteUnmute: (ref: VideoRef, enabled: boolean) => {
|
|
87
|
-
toggleMute: () => void;
|
|
88
|
-
isMuted: boolean;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
declare const useStartAt: (ref: VideoRef, startAt?: VideoConfig["startAt"]) => void;
|
|
92
|
-
|
|
93
|
-
declare const useFullscreen: () => {
|
|
94
|
-
isFullscreen: boolean;
|
|
95
|
-
toggleFullscreen: () => void;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
declare const useAutoplayByForce: (ref: VideoRef | null, enabled: boolean, setError?: (error: string | null) => void) => void;
|
|
26
|
+
interface Props$1 extends Omit<React.ComponentProps<"video">, "autoPlay" | "preload"> {
|
|
27
|
+
src: string;
|
|
28
|
+
autoPlay?: VideoAutoplay;
|
|
29
|
+
controls?: boolean;
|
|
30
|
+
preload?: "none" | "metadata" | "auto";
|
|
31
|
+
muteFallback?: (onMute: () => void) => React.ReactNode;
|
|
32
|
+
autoPlayOnVisible?: boolean | number;
|
|
33
|
+
ranges?: number[];
|
|
34
|
+
}
|
|
35
|
+
declare const Video: React.ForwardRefExoticComponent<Omit<Props$1, "ref"> & React.RefAttributes<HTMLVideoElement>>;
|
|
99
36
|
|
|
100
|
-
|
|
37
|
+
interface ControlsProps extends React.ComponentProps<"div"> {
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const Controls: React.MemoExoticComponent<({ children, asChild, ...props }: ControlsProps) => react_jsx_runtime.JSX.Element>;
|
|
42
|
+
interface Props extends React.ComponentProps<"button"> {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
}
|
|
46
|
+
declare const Play: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
47
|
+
declare const Pause: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
48
|
+
declare const Mute: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
49
|
+
declare const Unmute: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
50
|
+
interface SpeedProps extends Props {
|
|
51
|
+
value: number;
|
|
52
|
+
onClick?: () => void;
|
|
53
|
+
}
|
|
54
|
+
declare const Speed: React.MemoExoticComponent<({ children, asChild, value, onClick, ...props }: SpeedProps) => react_jsx_runtime.JSX.Element>;
|
|
55
|
+
declare const SeekForward: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
56
|
+
declare const SeekBackward: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
57
|
+
declare const Fullscreen: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
58
|
+
declare const ExitFullscreen: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
59
|
+
declare const PictureInPicture: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
60
|
+
declare const Download: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
61
|
+
interface LoadingProps extends React.ComponentProps<"div"> {
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
asChild?: boolean;
|
|
64
|
+
}
|
|
65
|
+
declare const Loading: React.MemoExoticComponent<({ children, asChild, ...props }: LoadingProps) => react_jsx_runtime.JSX.Element>;
|
|
66
|
+
interface ShadowProps extends React.ComponentProps<"div"> {
|
|
67
|
+
}
|
|
68
|
+
declare const Shadow: ({ ...props }: ShadowProps) => react_jsx_runtime.JSX.Element | null;
|
|
101
69
|
|
|
102
|
-
export {
|
|
70
|
+
export { Controls, Download, ExitFullscreen, Fullscreen, Loading, Mute, Pause, PictureInPicture, Play, SeekBackward, SeekForward, Shadow, Speed, Unmute, Video, VideoAutoplay, VideoProvider, VideoRef, useVideo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,102 +1,70 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { V as VideoRef, a as VideoAutoplay } from './types-DejCaLAg.js';
|
|
4
|
+
export { C as CustomVideoRef } from './types-DejCaLAg.js';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
type VideoChildren = ReactNode | ((props: {
|
|
9
|
-
isPlaying: boolean;
|
|
10
|
-
togglePlay: () => void;
|
|
11
|
-
isMuted: boolean;
|
|
12
|
-
toggleMute: () => void;
|
|
13
|
-
speed: number;
|
|
14
|
-
onChangeSpeed: (speed: number) => void;
|
|
15
|
-
duration: number | null;
|
|
16
|
-
isFullscreen: boolean;
|
|
17
|
-
toggleFullscreen: () => void;
|
|
18
|
-
isPictureInPicture: boolean;
|
|
19
|
-
togglePictureInPicture: () => void;
|
|
20
|
-
showHidingElement: boolean;
|
|
21
|
-
}) => ReactNode);
|
|
22
|
-
type VideoConfig = {
|
|
23
|
-
startAt?: number;
|
|
24
|
-
range?: [number, number];
|
|
25
|
-
autoplayOnVisible?: boolean | number;
|
|
26
|
-
muteFallback?: (toggleMute: () => void) => ReactNode;
|
|
27
|
-
clickToPlay?: boolean;
|
|
28
|
-
};
|
|
29
|
-
interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
|
|
30
|
-
children?: VideoChildren;
|
|
31
|
-
autoPlay?: VideoAutoplay;
|
|
32
|
-
ratio?: string;
|
|
33
|
-
config?: VideoConfig;
|
|
34
|
-
controls?: boolean;
|
|
6
|
+
interface VideoConfig {
|
|
7
|
+
config?: Partial<{
|
|
8
|
+
clickToPlay: boolean;
|
|
9
|
+
}>;
|
|
35
10
|
}
|
|
36
|
-
interface VideoContextType {
|
|
11
|
+
interface VideoContextType extends VideoConfig {
|
|
37
12
|
videoRef: VideoRef;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
showHidingElement?: boolean;
|
|
44
|
-
setShowHidingElement?: (showHidingElement: boolean) => void;
|
|
13
|
+
setVideoRef: (video: VideoRef) => void;
|
|
14
|
+
error: string | null;
|
|
15
|
+
setError: (error: string | null) => void;
|
|
16
|
+
isFocused: boolean;
|
|
17
|
+
setIsFocused: (isFocused: boolean) => void;
|
|
45
18
|
}
|
|
46
|
-
|
|
47
|
-
interface HidingElementProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
19
|
+
type VideoProviderProps = Omit<React.ComponentProps<"div">, "onError"> & VideoConfig & {
|
|
48
20
|
children: React.ReactNode;
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Using compound components pattern
|
|
54
|
-
*/
|
|
55
|
-
declare const Video: React.ForwardRefExoticComponent<VideoProps & {
|
|
56
|
-
pause?: boolean;
|
|
57
|
-
} & React.RefAttributes<HTMLVideoElement>> & {
|
|
58
|
-
PlayPauseOnVideo: () => react_jsx_runtime.JSX.Element;
|
|
59
|
-
HidingElement: React.ComponentType<HidingElementProps>;
|
|
21
|
+
onError?: (error: string | null) => void;
|
|
60
22
|
};
|
|
61
|
-
|
|
23
|
+
declare const VideoProvider: React.MemoExoticComponent<({ children, config, onError, ...props }: VideoProviderProps) => react_jsx_runtime.JSX.Element>;
|
|
62
24
|
declare const useVideo: () => VideoContextType;
|
|
63
25
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
declare const useGetDuration: (ref: VideoRef) => {
|
|
77
|
-
duration: number | null;
|
|
78
|
-
isLoading: boolean;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
declare const usePlayPause: (ref: VideoRef, enabled: boolean) => {
|
|
82
|
-
togglePlay: () => void;
|
|
83
|
-
isPlaying: boolean;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
declare const useMuteUnmute: (ref: VideoRef, enabled: boolean) => {
|
|
87
|
-
toggleMute: () => void;
|
|
88
|
-
isMuted: boolean;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
declare const useStartAt: (ref: VideoRef, startAt?: VideoConfig["startAt"]) => void;
|
|
92
|
-
|
|
93
|
-
declare const useFullscreen: () => {
|
|
94
|
-
isFullscreen: boolean;
|
|
95
|
-
toggleFullscreen: () => void;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
declare const useAutoplayByForce: (ref: VideoRef | null, enabled: boolean, setError?: (error: string | null) => void) => void;
|
|
26
|
+
interface Props$1 extends Omit<React.ComponentProps<"video">, "autoPlay" | "preload"> {
|
|
27
|
+
src: string;
|
|
28
|
+
autoPlay?: VideoAutoplay;
|
|
29
|
+
controls?: boolean;
|
|
30
|
+
preload?: "none" | "metadata" | "auto";
|
|
31
|
+
muteFallback?: (onMute: () => void) => React.ReactNode;
|
|
32
|
+
autoPlayOnVisible?: boolean | number;
|
|
33
|
+
ranges?: number[];
|
|
34
|
+
}
|
|
35
|
+
declare const Video: React.ForwardRefExoticComponent<Omit<Props$1, "ref"> & React.RefAttributes<HTMLVideoElement>>;
|
|
99
36
|
|
|
100
|
-
|
|
37
|
+
interface ControlsProps extends React.ComponentProps<"div"> {
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const Controls: React.MemoExoticComponent<({ children, asChild, ...props }: ControlsProps) => react_jsx_runtime.JSX.Element>;
|
|
42
|
+
interface Props extends React.ComponentProps<"button"> {
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
}
|
|
46
|
+
declare const Play: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
47
|
+
declare const Pause: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
48
|
+
declare const Mute: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
49
|
+
declare const Unmute: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
50
|
+
interface SpeedProps extends Props {
|
|
51
|
+
value: number;
|
|
52
|
+
onClick?: () => void;
|
|
53
|
+
}
|
|
54
|
+
declare const Speed: React.MemoExoticComponent<({ children, asChild, value, onClick, ...props }: SpeedProps) => react_jsx_runtime.JSX.Element>;
|
|
55
|
+
declare const SeekForward: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
56
|
+
declare const SeekBackward: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
57
|
+
declare const Fullscreen: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
58
|
+
declare const ExitFullscreen: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
59
|
+
declare const PictureInPicture: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
60
|
+
declare const Download: React.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
61
|
+
interface LoadingProps extends React.ComponentProps<"div"> {
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
asChild?: boolean;
|
|
64
|
+
}
|
|
65
|
+
declare const Loading: React.MemoExoticComponent<({ children, asChild, ...props }: LoadingProps) => react_jsx_runtime.JSX.Element>;
|
|
66
|
+
interface ShadowProps extends React.ComponentProps<"div"> {
|
|
67
|
+
}
|
|
68
|
+
declare const Shadow: ({ ...props }: ShadowProps) => react_jsx_runtime.JSX.Element | null;
|
|
101
69
|
|
|
102
|
-
export {
|
|
70
|
+
export { Controls, Download, ExitFullscreen, Fullscreen, Loading, Mute, Pause, PictureInPicture, Play, SeekBackward, SeekForward, Shadow, Speed, Unmute, Video, VideoAutoplay, VideoProvider, VideoRef, useVideo };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
"use client";import{a as
|
|
2
|
-
`);import E from"react";import g from"react";import{jsx as Q}from"react/jsx-runtime";var O=g.createContext(void 0),l=()=>{let e=g.useContext(O);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},z=({children:e,videoRef:n,duration:r,showHidingElement:t,setShowHidingElement:u})=>{let[s,o]=g.useState(!1);return Q(O.Provider,{value:{videoRef:n,duration:r,isFullscreen:s,setIsFullscreen:o,showHidingElement:t,setShowHidingElement:u},children:e})};import X from"react";var T=(e,n)=>{X.useEffect(()=>{if(!(e!=null&&e.current)||!n)return;let r=e==null?void 0:e.current;r&&n&&(r.currentTime=n)},[n,e==null?void 0:e.current])};import Y from"react";var A=(e,n,r)=>{Y.useEffect(()=>{if(!r||!(e!=null&&e.current))return;let t=new IntersectionObserver(u=>{u.forEach(s=>{var o;e!=null&&e.current&&(s.isIntersecting?e.current.play().catch(a=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(a))}):(o=e.current)==null||o.pause())})},{threshold:n!=null?n:.5});return t.observe(e==null?void 0:e.current),()=>{t.disconnect()}},[r,e==null?void 0:e.current])};import L from"react";var V=(e,n)=>{let[r,t]=L.useState(!1),u=L.useCallback(()=>{console.log(e==null?void 0:e.current),e!=null&&e.current&&(e.current.paused?e.current.play():e.current.pause())},[e==null?void 0:e.current]);return L.useEffect(()=>{if(!n||!(e!=null&&e.current))return;let s=()=>{t(!0)},o=()=>{t(!1)};if(t(!(e!=null&&e.current.paused)),e!=null&&e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",o),()=>{var a,d;(a=e.current)==null||a.removeEventListener("play",s),(d=e.current)==null||d.removeEventListener("pause",o)}},[e==null?void 0:e.current,n]),{togglePlay:u,isPlaying:r}};import{jsx as Z}from"react/jsx-runtime";var N=()=>{let{videoRef:e}=l(),{togglePlay:n}=V(e,!0);return Z("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:n})};import te from"react";import F from"react";var M=(e,n)=>{let[r,t]=F.useState(!1),u=F.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e==null?void 0:e.current]);return F.useEffect(()=>{if(!n||!(e!=null&&e.current))return;t(e.current.muted);let s=()=>{e.current&&t(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var o;(o=e.current)==null||o.removeEventListener("volumechange",s)}},[e==null?void 0:e.current,n]),{toggleMute:u,isMuted:r}};import _ from"react";var w=()=>{let{videoRef:e,isFullscreen:n,setIsFullscreen:r}=l();_.useEffect(()=>{let u=()=>{r==null||r(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",u),()=>document.removeEventListener("fullscreenchange",u)},[]);let t=()=>{var a;let u=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e==null?void 0:e.current;if(s&&u){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let o=(a=e==null?void 0:e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");o&&(n?document.exitFullscreen():o.requestFullscreen())};return{isFullscreen:n!=null?n:!1,toggleFullscreen:t}};import ee from"react";var q=()=>{let{videoRef:e,isPictureInPicture:n,setIsPictureInPicture:r}=l();ee.useEffect(()=>{let u=()=>{r==null||r(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",u),()=>document.removeEventListener("pictureinpicturechange",u)},[]);let t=async()=>{let u=e==null?void 0:e.current;if(u)try{document.pictureInPictureElement?await document.exitPictureInPicture():await u.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))u.webkitEnterFullscreen?u.webkitEnterFullscreen():u.requestFullscreen&&u.requestFullscreen();else{let a=u.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:n!=null?n:!1,togglePictureInPicture:t}};import S from"react";var $=(e,n)=>{let[r,t]=S.useState(1),u=s=>{t(s)};return S.useEffect(()=>{e!=null&&e.current&&t(e.current.playbackRate)},[e==null?void 0:e.current]),S.useEffect(()=>{!n||!(e!=null&&e.current)||(e.current.playbackRate=r)},[r,n,e==null?void 0:e.current]),{speed:r,onChangeSpeed:u}};var B=te.forwardRef(({children:e},n)=>{let{duration:r,showHidingElement:t}=l(),{togglePlay:u,isPlaying:s}=V(n,typeof e=="function"),{speed:o,onChangeSpeed:a}=$(n,typeof e=="function"),{toggleMute:d,isMuted:m}=M(n,typeof e=="function"),{isFullscreen:v,toggleFullscreen:b}=w(),{isPictureInPicture:x,togglePictureInPicture:i}=q();return typeof e!="function"?null:e({isPlaying:s,togglePlay:u,isMuted:m,toggleMute:d,speed:o,onChangeSpeed:a,isFullscreen:v,toggleFullscreen:b,isPictureInPicture:x,togglePictureInPicture:i,duration:r,showHidingElement:t!=null?t:!1})});import re from"react";import{jsx as ne}from"react/jsx-runtime";var D=re.forwardRef(({children:e,className:n,...r})=>{let{videoRef:t}=l(),{isPlaying:u}=V(t,!0),{showHidingElement:s,setShowHidingElement:o}=l();return ne("div",{"data-zuude-hiding-element":!0,"data-show":!u||s,className:n,onMouseEnter:()=>{o==null||o(!0)},onMouseLeave:()=>{o==null||o(!1)},...r,children:e})});import{jsx as I,jsxs as ue}from"react/jsx-runtime";var U=E.forwardRef(({children:e,autoPlay:n,className:r,config:t,ratio:u,controls:s,pause:o,...a},d)=>{let[m,v]=E.useState(null),[b,x]=E.useState(null),i=d||E.useRef(null),[j,h]=E.useState(!1),y=E.useRef(null),G=()=>{var c;(c=i.current)!=null&&c.paused||(h(!0),y.current&&clearTimeout(y.current))},W=()=>{var c;(c=i.current)!=null&&c.paused||(h(!1),y.current&&clearTimeout(y.current))},J=()=>{var c;(c=i.current)!=null&&c.paused||(h(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{h(!1)},3e3))};return E.useEffect(()=>{var c,p;o!==void 0&&(o?(c=i.current)==null||c.pause():(p=i.current)==null||p.play())},[o,i.current]),C(i,n==="force"&&a.muted===void 0&&!(t!=null&&t.autoplayOnVisible),x),T(i,t==null?void 0:t.startAt),A(i,typeof(t==null?void 0:t.autoplayOnVisible)=="number"?t.autoplayOnVisible:void 0,t==null?void 0:t.autoplayOnVisible),I(z,{videoRef:i,duration:m,showHidingElement:j,setShowHidingElement:h,children:ue("div",{"data-zuude-video-wrapper":!0,className:r,style:{aspectRatio:u},children:[I("video",{"data-zuude-video":!0,ref:i,autoPlay:t!=null&&t.autoplayOnVisible?!1:n==="force"?!0:n,playsInline:!0,onMouseEnter:G,onMouseLeave:W,onMouseMove:J,onClick:()=>{var c,p,P;t!=null&&t.clickToPlay&&((c=i.current)!=null&&c.paused?(p=i.current)==null||p.play():(P=i.current)==null||P.pause())},onLoadedMetadata:c=>{console.log("loaded metadata"),v(c.target.duration)},onTimeUpdate:c=>{var p;if(t!=null&&t.range){let[P,K]=t.range;if(!(i!=null&&i.current))return;((p=i==null?void 0:i.current)==null?void 0:p.currentTime)<P&&(i.current.currentTime=P),i.current.currentTime>K&&(i.current.currentTime=P)}},className:r,style:{aspectRatio:u},...a}),typeof e=="function"?I(B,{ref:i,children:e}):e,b==="NotAllowedError"&&typeof(t==null?void 0:t.muteFallback)=="function"&&t.muteFallback(()=>{i.current&&(i.current.muted=!i.current.muted),x(null)})]})})});U.displayName="Video";var oe=Object.assign(U,{PlayPauseOnVideo:N,HidingElement:D});import H from"react";var se=()=>{let[e,n]=H.useState(100),{videoRef:r}=l(),t=u=>{n(u)};return H.useEffect(()=>{r!=null&&r.current&&n(r.current.volume*100)},[r==null?void 0:r.current]),H.useEffect(()=>{r!=null&&r.current&&(r.current.volume=e/100)},[e,r==null?void 0:r.current]),{volume:e,onChangeVolume:t}};import f from"react";var ie=()=>{let[e,n]=f.useState(!1),[r,t]=f.useState(0),[u,s]=f.useState(0),{videoRef:o,duration:a}=l();return f.useEffect(()=>{if(o!=null&&o.current&&e){let d=setInterval(()=>{var m,v;t(((m=o.current)==null?void 0:m.currentTime)||0),(v=o.current)!=null&&v.buffered.length&&s(o.current.buffered.end(o.current.buffered.length-1))},10);return()=>clearInterval(d)}},[o==null?void 0:o.current,e]),f.useEffect(()=>{if(o!=null&&o.current)return o.current.addEventListener("play",()=>n(!0)),o.current.addEventListener("pause",()=>n(!1)),()=>{var d,m;(d=o.current)==null||d.removeEventListener("play",()=>n(!0)),(m=o.current)==null||m.removeEventListener("pause",()=>n(!1))}},[]),{currentTime:r,duration:a,buffered:u,setCurrentTime:t}};import k from"react";var ae=e=>{let[n,r]=k.useState(!1),[t,u]=k.useState(null);return k.useEffect(()=>{if(e!=null&&e.current)return r(!0),e.current.addEventListener("loadedmetadata",()=>{var s,o;u((o=(s=e.current)==null?void 0:s.duration)!=null?o:null),r(!1)}),e.current.addEventListener("error",()=>{r(!1)}),()=>{var s,o;(s=e.current)==null||s.removeEventListener("loadedmetadata",()=>{}),(o=e.current)==null||o.removeEventListener("error",()=>{})}},[e==null?void 0:e.current]),{duration:t,isLoading:n}};function ce(e,n="mm:ss"){let r=Math.floor(e/60),t=Math.floor(e%60);return n==="h:mm:ss"?`${Math.floor(r/60)}:${r}:${t<10?"0":""}${t}`:`${r}:${t<10?"0":""}${t}`}export{oe as Video,ce as formatTime,C as useAutoplayByForce,w as useFullscreen,ae as useGetDuration,M as useMuteUnmute,V as usePlayPause,T as useStartAt,ie as useTimeline,l as useVideo,se as useVolume};
|
|
1
|
+
"use client";import{a as z,b as M,c as S,d as x,e as F,f as A,g as H,h as U,j as B,p as q}from"./chunk-XV6ODTKT.js";import _,{createContext as $,useContext as ee,useEffect as N,useRef as te,useState as D}from"react";import{jsx as K}from"react/jsx-runtime";var W=$(null),ne=_.memo(({children:n,config:o,onError:t,...e})=>{let[i,r]=D({current:null}),[s,d]=D(null),[v,a]=D(!1),h=te(null);return N(()=>{t==null||t(s)},[s]),N(()=>{let c=h.current;if(c){let P=c.querySelectorAll("[data-zuude-hide-elements]"),m=c.querySelector("[data-zuude-video]");if(P){let L=null,I=3e3,R=!1,g=()=>{L&&(clearTimeout(L),L=null),L=setTimeout(()=>{R&&m&&!m.paused&&P.forEach(T=>{T.setAttribute("data-hidden","true")}),L=null},I)},p=()=>{R=!0,P.forEach(T=>{T.removeAttribute("data-hidden")}),g()},k=()=>{R=!1,L&&(clearTimeout(L),L=null),m&&!m.paused&&P.forEach(T=>{T.setAttribute("data-hidden","true")})},C=()=>{R&&(P.forEach(T=>{T.hasAttribute("data-hidden")&&T.removeAttribute("data-hidden")}),g())},w=()=>{R||P.forEach(T=>{T.setAttribute("data-hidden","true")})};return c.addEventListener("mouseenter",p),c.addEventListener("mouseleave",k),c.addEventListener("mousemove",C),m.addEventListener("pause",p),m.addEventListener("play",w),()=>{L&&clearTimeout(L),c.removeEventListener("mouseenter",p),c.removeEventListener("mouseleave",k),c.removeEventListener("mousemove",C),m.removeEventListener("pause",p),m.removeEventListener("play",w)}}}},[]),N(()=>{if(v){let c=P=>{var m;(m=h.current)!=null&&m.contains(P.target)||a(!1)};return document.addEventListener("click",c),()=>{document.removeEventListener("click",c)}}},[v]),K(W.Provider,{value:{videoRef:i,setVideoRef:r,config:{clickToPlay:!0,...o},error:s,setError:d,isFocused:v,setIsFocused:a},children:K("div",{ref:h,"data-zuude-video-wrapper":!0,onClick:()=>a(!0),...e,children:n})})}),l=()=>{let n=ee(W);if(!n)throw new Error("useVideo must be used within a VideoProvider");return n};import{forwardRef as oe,useCallback as re,useEffect as J,useRef as O}from"react";var G=()=>{let{videoRef:n}=l(),{seekForward:o,seekBackward:t}=S(n),{togglePlay:e}=x(n),{toggleMute:i}=F(n),{toggleFullscreen:r}=A(n),{togglePictureInPicture:s}=H(n);return M("ArrowRight",()=>{o()}),M("ArrowLeft",()=>{t()}),M(" ",()=>{e()}),M("m",()=>{i()}),M("f",()=>{r()}),M("p",()=>{s()}),null};import{Fragment as ie,jsx as Q,jsxs as se}from"react/jsx-runtime";var X=oe(({src:n,autoPlay:o,muteFallback:t,controls:e,preload:i="metadata",autoPlayOnVisible:r,ranges:s,...d},v)=>{let{videoRef:a,setVideoRef:h,config:c,setError:P,error:m,isFocused:L}=l(),I=O(null),R=O(!1),g=O(null),p=O(null),k=s&&s.length>=2&&typeof s[0]=="number"&&typeof s[1]=="number"&&s[0]>=0&&s[1]>s[0]&&isFinite(s[0])&&isFinite(s[1]),C=k?s[0]:void 0,w=k?s[1]:void 0;J(()=>{let f=I.current,u=v;return u?h(u):f&&h({current:f}),()=>{R.current=!1,g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),p.current!==null&&(clearTimeout(p.current),p.current=null)}},[n,v,h]),J(()=>()=>{g.current!==null&&(cancelAnimationFrame(g.current),g.current=null),p.current!==null&&(clearTimeout(p.current),p.current=null)},[]),z(a,o==="force"&&d.muted===void 0,P),U(a,typeof r=="number"?r:r?void 0:.5,!!r);let T=re(()=>{var f,u,V;(f=a==null?void 0:a.current)!=null&&f.paused?(u=a.current)==null||u.play():(V=a==null?void 0:a.current)==null||V.pause()},[a]);return se(ie,{children:[Q("video",{ref:v||I,"data-zuude-video":!0,src:n,onClick:c!=null&&c.clickToPlay?T:void 0,autoPlay:o==="force"?!0:o,preload:i,playsInline:!0,onLoadedMetadata:f=>{var V;let u=f.currentTarget;k&&C!==void 0&&w!==void 0&&u.currentTime<.1&&(u.currentTime=C),(V=d.onLoadedMetadata)==null||V.call(d,f)},onCanPlay:f=>{var V;let u=f.currentTarget;if(k&&C!==void 0&&w!==void 0&&!u.seeking){let j=u.currentTime;j<.1&&j<C&&(u.currentTime=C)}(V=d.onCanPlay)==null||V.call(d,f)},onSeeked:f=>{var u;R.current=!1,(u=d.onSeeked)==null||u.call(d,f)},onTimeUpdate:f=>{var V;let u=f.currentTarget;k&&C!==void 0&&w!==void 0&&!R.current&&!u.paused&&!u.seeking&&u.readyState>=2&&u.currentTime>=w&&(R.current=!0,u.currentTime=C,p.current!==null&&clearTimeout(p.current),g.current=requestAnimationFrame(()=>{p.current=setTimeout(()=>{R.current&&(R.current=!1),p.current=null},100),g.current=null})),(V=d.onTimeUpdate)==null||V.call(d,f)},...d}),e&&L&&Q(G,{}),m==="NotAllowedError"&&typeof t=="function"&&t(()=>{a!=null&&a.current&&(a.current.muted=!a.current.muted),P(null)})]})});X.displayName="Video";import y,{useRef as ae}from"react";import{Slot as b}from"@radix-ui/react-slot";import Y from"react";var Z=n=>{let[o,t]=Y.useState(!1);return Y.useEffect(()=>{if(!(n!=null&&n.current))return;let e=n.current,i=()=>{t(!0)},r=()=>{},s=()=>{},d=()=>{t(!1)},v=()=>{t(!1)},a=()=>{t(!0)},h=()=>{t(!1)},c=()=>{t(!1)},P=()=>{t(!1)},m=()=>{};return e.addEventListener("loadstart",i),e.addEventListener("loadedmetadata",r),e.addEventListener("loadeddata",s),e.addEventListener("canplay",d),e.addEventListener("canplaythrough",v),e.addEventListener("waiting",a),e.addEventListener("playing",h),e.addEventListener("error",c),e.addEventListener("abort",P),e.addEventListener("suspend",m),e.readyState>=2&&t(!1),()=>{e.removeEventListener("loadstart",i),e.removeEventListener("loadedmetadata",r),e.removeEventListener("loadeddata",s),e.removeEventListener("canplay",d),e.removeEventListener("canplaythrough",v),e.removeEventListener("waiting",a),e.removeEventListener("playing",h),e.removeEventListener("error",c),e.removeEventListener("abort",P),e.removeEventListener("suspend",m)}},[n]),{isLoading:o}};import{jsx as E}from"react/jsx-runtime";var Be=y.memo(({children:n,asChild:o,...t})=>E("div",{"data-zuude-hide-elements":!0,...t,children:n})),qe=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{play:r}=x(i);return E(e,{...t,onClick:r,children:n})}),Ke=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{pause:r}=x(i);return E(e,{...t,onClick:r,children:n})}),We=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{mute:r}=F(i);return E(e,{...t,onClick:r,children:n})}),Ge=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{unmute:r}=F(i);return E(e,{...t,onClick:r,children:n})}),Je=y.memo(({children:n,asChild:o,value:t,onClick:e,...i})=>{let r=o?b:"button",{videoRef:s}=l(),{speed:d,onChangeSpeed:v}=B(s);return E(r,{...i,value:t,onClick:()=>{v(t),e==null||e()},children:n})}),Qe=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{seekForward:r}=S(i,10);return E(e,{...t,onClick:r,children:n})}),Xe=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{seekBackward:r}=S(i,10);return E(e,{...t,onClick:r,children:n})}),Ye=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{toggleFullscreen:r}=A(i);return E(e,{...t,onClick:r,children:n})}),Ze=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{toggleFullscreen:r}=A(i);return E(e,{...t,onClick:r,children:n})}),_e=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{togglePictureInPicture:r}=H(i);return E(e,{...t,onClick:r,children:n})}),$e=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"button",{videoRef:i}=l(),{downloadDirect:r}=q(i);return E(e,{...t,onClick:()=>r(),children:n})}),et=y.memo(({children:n,asChild:o,...t})=>{let e=o?b:"div",{videoRef:i}=l(),{isLoading:r}=Z(i);return E(e,{...t,style:{...t.style,pointerEvents:"none"},"data-loading":r,children:n})}),tt=({...n})=>{let{videoRef:o}=l(),t=ae(null);return y.useEffect(()=>{let e=o==null?void 0:o.current;if(t.current&&e){let i=0,r=!1,s=null,d=()=>{s&&clearInterval(s),s=setInterval(()=>{i=e.currentTime,t.current&&(t.current.currentTime=i)},100)},v=()=>{s&&(clearInterval(s),s=null)},a=()=>{r=!0,d()},h=()=>{r=!1,v()};return e.addEventListener("play",a),e.addEventListener("pause",h),()=>{v(),e.removeEventListener("play",a),e.removeEventListener("pause",h)}}},[o==null?void 0:o.current]),o!=null&&o.current?E("div",{...n,style:{...n.style,position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:E("video",{ref:t,src:o.current.src,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"cover"}})}):null};export{Be as Controls,$e as Download,Ze as ExitFullscreen,Ye as Fullscreen,et as Loading,We as Mute,Ke as Pause,_e as PictureInPicture,qe as Play,Xe as SeekBackward,Qe as SeekForward,tt as Shadow,Je as Speed,Ge as Unmute,X as Video,ne as VideoProvider,l as useVideo};
|
|
3
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-play-pause.tsx","../src/components/play-pause-on-video.tsx","../src/function-children.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/use-get-duration.tsx","../src/utils.ts"],"sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}\\n\")","import React from \"react\";\n\n// 📦 Types\nimport type { VideoProps, VideoRef } from \"./types\";\n\n// 🔍 Context\nimport { VideoProvider } from \"./context\";\n\n// 🔗 Hooks\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { useStartAt } from \"./hooks/use-start-at\";\nimport { useAutoplayOnVisible } from \"./hooks/use-autoplay-on-visible\";\n\n// 🔧 Components\nimport { PlayPauseOnVideo } from \"./components/play-pause-on-video\";\nimport { FunctionChildren } from \"./function-children\";\nimport { HidingElement, HidingElementProps } from \"./components/hiding-element\";\n\n/**\n * Main Video component structure\n * @param {VideoProps} props - Video component props\n */\n\nconst VideoComponent = React.forwardRef<\n HTMLVideoElement,\n VideoProps & { pause?: boolean }\n>(\n (\n { children, autoPlay, className, config, ratio, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n\n const videoRef = (ref as VideoRef) || React.useRef<VideoRef>(null);\n\n const [showHidingElement, setShowHidingElement] = React.useState(false);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n const handleMouseEnter = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseLeave = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(false);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseMove = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setShowHidingElement(false);\n }, 3000);\n };\n\n React.useEffect(() => {\n if (pause !== undefined) {\n if (pause) {\n videoRef.current?.pause();\n } else {\n videoRef.current?.play();\n }\n }\n }, [pause, videoRef.current]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" &&\n props.muted === undefined &&\n !config?.autoplayOnVisible,\n setError\n );\n useStartAt(videoRef, config?.startAt);\n useAutoplayOnVisible(\n videoRef,\n typeof config?.autoplayOnVisible === \"number\"\n ? config.autoplayOnVisible\n : undefined,\n config?.autoplayOnVisible\n );\n\n return (\n <VideoProvider\n videoRef={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n className={className}\n style={{ aspectRatio: ratio }}\n >\n <video\n data-zuude-video\n // @ts-ignore\n ref={videoRef}\n autoPlay={\n config?.autoplayOnVisible\n ? false\n : autoPlay === \"force\"\n ? true\n : autoPlay\n }\n playsInline\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onMouseMove={handleMouseMove}\n onClick={() => {\n if (config?.clickToPlay) {\n if (videoRef.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef.current?.pause();\n }\n }\n }}\n onLoadedMetadata={(e) => {\n console.log(\"loaded metadata\");\n setDuration((e.target as HTMLVideoElement).duration);\n }}\n onTimeUpdate={(e) => {\n /**\n * If the current time is less than the start time, set the current time to the start time\n * If the current time is greater than the end time, set the current time to the start time\n */\n if (config?.range) {\n const [start, end] = config.range;\n\n if (!videoRef?.current) return;\n\n if (videoRef?.current?.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\n className={className}\n style={{ aspectRatio: ratio }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\n )}\n {error === \"NotAllowedError\" &&\n typeof config?.muteFallback === \"function\" &&\n config.muteFallback(() => {\n if (videoRef.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </div>\n </VideoProvider>\n );\n }\n);\n\nVideoComponent.displayName = \"Video\";\n\n/**\n * Using compound components pattern\n */\nexport const Video = Object.assign(VideoComponent, {\n PlayPauseOnVideo,\n HidingElement: HidingElement as React.ComponentType<HidingElementProps>,\n});\n","import React from \"react\";\nimport type { VideoContextType } from \"./types.js\";\n\nconst VideoContext = React.createContext<VideoContextType | undefined>(\n undefined\n);\n\nconst useVideo = () => {\n const context = React.useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n\ninterface VideoProviderProps extends VideoContextType {\n children: React.ReactNode;\n}\n\nconst VideoProvider = ({\n children,\n videoRef,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n duration,\n isFullscreen: fullscreen,\n setIsFullscreen: setFullscreen,\n showHidingElement,\n setShowHidingElement,\n }}\n >\n {children}\n </VideoContext.Provider>\n );\n};\n\nexport { useVideo, VideoProvider };\n","import React from \"react\";\nimport type { VideoConfig, VideoRef } from \"../types\";\n\nexport const useStartAt = (ref: VideoRef, startAt?: VideoConfig[\"startAt\"]) => {\n React.useEffect(() => {\n if (!ref?.current || !startAt) return;\n\n const video = ref?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, ref?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n ref: VideoRef,\n threshold: number | undefined,\n enabled: boolean | number | null | undefined\n) => {\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!ref?.current) return;\n\n if (entry.isIntersecting) {\n ref.current.play().catch((error) => {\n if (!ref.current) return;\n\n ref.current.pause();\n ref.current.muted = true;\n ref.current.play();\n console.error(error);\n });\n } else {\n ref.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(ref?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [enabled, ref?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (ref: VideoRef, enabled: boolean) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n console.log(ref?.current);\n if (ref?.current) {\n ref.current.paused ? ref.current.play() : ref.current.pause();\n }\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!ref?.current.paused);\n\n if (ref?.current) {\n ref.current.addEventListener(\"play\", handlePlay);\n ref.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n ref.current?.removeEventListener(\"play\", handlePlay);\n ref.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [ref?.current, enabled]);\n\n return { togglePlay, isPlaying };\n};\n","import { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport const PlayPauseOnVideo = () => {\n const { videoRef } = useVideo();\n\n const { togglePlay } = usePlayPause(videoRef, true);\n\n return (\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n onClick={togglePlay}\n ></div>\n );\n};\n","import React from \"react\";\n\nimport type { VideoChildren, VideoRef } from \"./types\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useVideo } from \"./context\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useSpeed } from \"./hooks/use-speed\";\n\nexport const FunctionChildren = React.forwardRef<\n any,\n {\n children: VideoChildren;\n }\n>(({ children }, ref) => {\n const { duration, showHidingElement } = useVideo();\n\n /**\n * Only use these hooks if the children is a function\n */\n const { togglePlay, isPlaying } = usePlayPause(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { isFullscreen, toggleFullscreen } = useFullscreen();\n const { isPictureInPicture, togglePictureInPicture } = usePictureInPicture();\n\n if (typeof children !== \"function\") return null;\n\n return children({\n isPlaying,\n togglePlay,\n isMuted,\n toggleMute,\n speed,\n onChangeSpeed,\n isFullscreen,\n toggleFullscreen,\n isPictureInPicture,\n togglePictureInPicture,\n duration,\n showHidingElement: showHidingElement ?? false,\n });\n});\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (ref: VideoRef, enabled: boolean) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (ref?.current) {\n ref.current.muted = !ref.current.muted;\n }\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n // Set the initial state\n setIsMuted(ref.current.muted);\n\n const handleVolumeChange = () => {\n if (ref.current) {\n setIsMuted(ref.current.muted);\n }\n };\n\n ref.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n ref.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [ref?.current, enabled]);\n\n return { toggleMute, isMuted };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useFullscreen = () => {\n const { videoRef, isFullscreen, setIsFullscreen } = useVideo();\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = videoRef?.current?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const usePictureInPicture = () => {\n const { videoRef, isPictureInPicture, setIsPictureInPicture } = useVideo();\n\n React.useEffect(() => {\n const handlePictureInPictureChange = () => {\n setIsPictureInPicture?.(!!document.pictureInPictureElement);\n };\n\n document.addEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n return () =>\n document.removeEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n }, []);\n\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n return {\n isPictureInPicture: isPictureInPicture ?? false,\n togglePictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (ref: VideoRef, enabled: boolean) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!ref?.current) return;\n setSpeed(ref.current.playbackRate);\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n ref.current.playbackRate = speed;\n }, [speed, enabled, ref?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport interface HidingElementProps\n extends React.ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode;\n className?: string;\n}\n\nexport const HidingElement = React.forwardRef<\n HTMLDivElement,\n HidingElementProps\n>(({ children, className, ...props }: HidingElementProps) => {\n const { videoRef } = useVideo();\n const { isPlaying } = usePlayPause(videoRef, true);\n const { showHidingElement, setShowHidingElement } = useVideo();\n\n return (\n <div\n data-zuude-hiding-element\n data-show={!isPlaying || showHidingElement}\n className={className}\n onMouseEnter={() => {\n setShowHidingElement?.(true);\n }}\n onMouseLeave={() => {\n setShowHidingElement?.(false);\n }}\n {...props}\n >\n {children}\n </div>\n );\n});\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useVolume = () => {\n const [volume, setVolume] = React.useState(100);\n const { videoRef } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useTimeline = () => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n const [buffered, setBuffered] = React.useState(0);\n\n const { videoRef, duration } = useVideo();\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n currentTime,\n duration,\n buffered,\n setCurrentTime,\n };\n};\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useGetDuration = (ref: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!ref?.current) return;\n setIsLoading(true);\n\n ref.current.addEventListener(\"loadedmetadata\", () => {\n setDuration(ref.current?.duration ?? null);\n setIsLoading(false);\n });\n\n ref.current.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n ref.current?.removeEventListener(\"loadedmetadata\", () => {});\n ref.current?.removeEventListener(\"error\", () => {});\n };\n }, [ref?.current]);\n\n return { duration, isLoading };\n};\n","function formatTime(time: number, type: \"h:mm:ss\" | \"mm:ss\" = \"mm:ss\"): string {\n const minutes = Math.floor(time / 60);\n const seconds = Math.floor(time % 60);\n if (type === \"h:mm:ss\") {\n const hours = Math.floor(minutes / 60);\n return `${hours}:${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n }\n return `${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n}\n\nexport { formatTime };\n"],"mappings":"qDACyB,SAARA,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,CAACD,GAAO,OAAO,UAAa,YAAa,OAE7C,IAAME,EAAO,SAAS,MAAQ,SAAS,qBAAqB,MAAM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K,OAAO,CAAC,EAEV,CAAE,SAAAG,EAAU,UAAAF,CAAU,CAC/B,EC3BA,SAASM,GAAWC,EAAcC,EAA4B,QAAiB,CAC7E,IAAMC,EAAU,KAAK,MAAMF,EAAO,EAAE,EAC9BG,EAAU,KAAK,MAAMH,EAAO,EAAE,EACpC,OAAIC,IAAS,UAEJ,GADO,KAAK,MAAMC,EAAU,EAAE,CACtB,IAAIA,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,GAE1D,GAAGD,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,EACxD","names":["styleInject","css","insertAt","head","style","styleInject","React","React","jsx","VideoContext","useVideo","context","VideoProvider","children","videoRef","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","React","useStartAt","ref","startAt","video","React","useAutoplayOnVisible","ref","threshold","enabled","observer","entries","entry","_a","error","React","usePlayPause","ref","enabled","isPlaying","setIsPlaying","togglePlay","handlePlay","handlePause","_a","_b","jsx","PlayPauseOnVideo","videoRef","useVideo","togglePlay","usePlayPause","React","React","useMuteUnmute","ref","enabled","isMuted","setIsMuted","toggleMute","handleVolumeChange","_a","React","useFullscreen","videoRef","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","React","usePictureInPicture","videoRef","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","React","useSpeed","ref","enabled","speed","setSpeed","onChangeSpeed","FunctionChildren","React","children","ref","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","React","jsx","HidingElement","React","children","className","props","videoRef","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","jsx","jsxs","VideoComponent","React","children","autoPlay","className","config","ratio","controls","pause","props","ref","duration","setDuration","error","setError","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","_c","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","React","useVolume","volume","setVolume","React","videoRef","useVideo","onChangeVolume","React","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","videoRef","duration","useVideo","intervalId","_a","_b","React","useGetDuration","ref","isLoading","setIsLoading","duration","setDuration","_a","_b","formatTime","time","type","minutes","seconds"]}
|
|
1
|
+
{"version":3,"sources":["../src/wrapper.tsx","../src/video.tsx","../src/keyboard.tsx","../src/components.tsx","../src/hooks/use-loading.tsx"],"sourcesContent":["import React, {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef;\n setVideoRef: (video: VideoRef) => void;\n error: string | null;\n setError: (error: string | null) => void;\n isFocused: boolean;\n setIsFocused: (isFocused: boolean) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | null>(null);\n\ntype VideoProviderProps = Omit<React.ComponentProps<\"div\">, \"onError\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = React.memo(\n ({ children, config, onError, ...props }: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef>({ current: null });\n const [error, setError] = useState<string | null>(null);\n const [isFocused, setIsFocused] = useState(false);\n\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n useEffect(() => {\n const videoWrapper = videoWrapperRef.current;\n if (videoWrapper) {\n const controls = videoWrapper.querySelectorAll(\n \"[data-zuude-hide-elements]\"\n );\n const video = videoWrapper.querySelector(\n \"[data-zuude-video]\"\n ) as HTMLVideoElement;\n\n if (controls) {\n let hideTimeout: ReturnType<typeof setTimeout> | null = null;\n const hideDelay = 3000; // 3 seconds delay\n let isMouseOver = false;\n\n const resetTimer = () => {\n // Clear any pending hide timeout\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n hideTimeout = null;\n }\n\n // Start new timer to hide controls after delay\n hideTimeout = setTimeout(() => {\n if (isMouseOver) {\n // Check if video is paused - don't hide controls if paused\n if (video && !video.paused) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n }\n hideTimeout = null;\n }, hideDelay);\n };\n\n const showControls = () => {\n isMouseOver = true;\n controls.forEach((control) => {\n control.removeAttribute(\"data-hidden\");\n });\n resetTimer();\n };\n\n const hideControls = () => {\n isMouseOver = false;\n // Clear any pending hide timeout\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n hideTimeout = null;\n }\n // Hide controls immediately when mouse leaves\n if (video && !video.paused) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n };\n\n const handleMouseMove = () => {\n if (isMouseOver) {\n // If controls are hidden, show them\n controls.forEach((control) => {\n if (control.hasAttribute(\"data-hidden\")) {\n control.removeAttribute(\"data-hidden\");\n }\n });\n resetTimer();\n }\n };\n\n const handlePlay = () => {\n // Hide controls when video starts playing (autoplay)\n if (!isMouseOver) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n };\n\n videoWrapper.addEventListener(\"mouseenter\", showControls);\n videoWrapper.addEventListener(\"mouseleave\", hideControls);\n videoWrapper.addEventListener(\"mousemove\", handleMouseMove);\n video.addEventListener(\"pause\", showControls);\n video.addEventListener(\"play\", handlePlay);\n\n // Cleanup function\n return () => {\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n }\n videoWrapper.removeEventListener(\"mouseenter\", showControls);\n videoWrapper.removeEventListener(\"mouseleave\", hideControls);\n videoWrapper.removeEventListener(\"mousemove\", handleMouseMove);\n video.removeEventListener(\"pause\", showControls);\n video.removeEventListener(\"play\", handlePlay);\n };\n }\n }\n }, []);\n\n useEffect(() => {\n if (isFocused) {\n const handleClick = (event: MouseEvent) => {\n if (!videoWrapperRef.current?.contains(event.target as Node)) {\n setIsFocused(false);\n }\n };\n document.addEventListener(\"click\", handleClick);\n\n return () => {\n document.removeEventListener(\"click\", handleClick);\n };\n }\n }, [isFocused]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n isFocused,\n setIsFocused,\n }}\n >\n <div\n ref={videoWrapperRef}\n data-zuude-video-wrapper\n onClick={() => setIsFocused(true)}\n {...props}\n >\n {children}\n </div>\n </VideoContext.Provider>\n );\n }\n);\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, {\n forwardRef,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { Keyboards } from \"./keyboard\";\nimport { useAutoplayOnVisible } from \"./hooks\";\n\ninterface Props\n extends Omit<React.ComponentProps<\"video\">, \"autoPlay\" | \"preload\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n controls?: boolean;\n preload?: \"none\" | \"metadata\" | \"auto\";\n muteFallback?: (onMute: () => void) => React.ReactNode;\n autoPlayOnVisible?: boolean | number;\n ranges?: number[];\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n (\n {\n src,\n autoPlay,\n muteFallback,\n controls,\n preload = \"metadata\",\n autoPlayOnVisible,\n ranges,\n ...props\n },\n ref\n ) => {\n const { videoRef, setVideoRef, config, setError, error, isFocused } =\n useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n const isAdjustingRef = useRef(false);\n const rafIdRef = useRef<number | null>(null);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Validate ranges: ensure they're valid and start < end\n const isValidRange =\n ranges &&\n ranges.length >= 2 &&\n typeof ranges[0] === \"number\" &&\n typeof ranges[1] === \"number\" &&\n ranges[0] >= 0 &&\n ranges[1] > ranges[0] &&\n isFinite(ranges[0]) &&\n isFinite(ranges[1]);\n\n // Safely get range values (only use when isValidRange is true)\n const rangeStart = isValidRange ? ranges[0] : undefined;\n const rangeEnd = isValidRange ? ranges[1] : undefined;\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n\n // Safari: Reset adjustment flags when src changes to prevent stale state\n return () => {\n isAdjustingRef.current = false;\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, [src, ref, setVideoRef]);\n\n // Cleanup requestAnimationFrame and setTimeout on unmount (critical for Safari)\n useEffect(() => {\n return () => {\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, []);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n useAutoplayOnVisible(\n videoRef,\n typeof autoPlayOnVisible === \"number\"\n ? autoPlayOnVisible\n : !autoPlayOnVisible\n ? 0.5\n : undefined,\n !!autoPlayOnVisible\n );\n\n const onPlay = useCallback(() => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n }, [videoRef]);\n\n return (\n <>\n <video\n ref={ref || refVideo}\n data-zuude-video\n src={src}\n onClick={config?.clickToPlay ? onPlay : undefined}\n autoPlay={autoPlay === \"force\" ? true : autoPlay}\n preload={preload}\n playsInline\n onLoadedMetadata={(e) => {\n // Set initial position as early as possible when metadata loads\n // This ensures video starts at rangeStart even with autoplay\n // Only set if video is at the beginning (not if user has already seeked)\n const video = e.currentTarget;\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n video.currentTime < 0.1\n ) {\n // Only set to rangeStart on initial load (when currentTime is near 0)\n video.currentTime = rangeStart;\n }\n props.onLoadedMetadata?.(e);\n }}\n onCanPlay={(e) => {\n // Only set initial position when video first loads (not during seeking)\n const video = e.currentTarget;\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n !video.seeking\n ) {\n const currentTime = video.currentTime;\n // Only adjust on initial load (when currentTime is 0 or very close to it)\n // Don't adjust if user has manually seeked to a different position\n if (currentTime < 0.1 && currentTime < rangeStart) {\n video.currentTime = rangeStart;\n }\n }\n props.onCanPlay?.(e);\n }}\n onSeeked={(e) => {\n // Don't enforce ranges on seek - allow free seeking for trimming\n // Ranges are only enforced during playback (in onTimeUpdate)\n isAdjustingRef.current = false;\n props.onSeeked?.(e);\n }}\n onTimeUpdate={(e) => {\n const video = e.currentTarget;\n\n // Only enforce ranges during active playback\n // Completely skip range enforcement when paused (allows free seeking for trimming)\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n !isAdjustingRef.current &&\n !video.paused &&\n !video.seeking &&\n video.readyState >= 2 // Ensure video has loaded enough data\n ) {\n const currentTime = video.currentTime;\n\n // During playback: loop back when reaching or exceeding the end boundary\n if (currentTime >= rangeEnd) {\n isAdjustingRef.current = true;\n video.currentTime = rangeStart;\n // Reset flag after seek completes (onSeeked will handle this)\n // But add a fallback timeout in case onSeeked doesn't fire\n // Cleanup existing timeout before setting new one (Safari memory safety)\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n }\n rafIdRef.current = requestAnimationFrame(() => {\n timeoutIdRef.current = setTimeout(() => {\n if (isAdjustingRef.current) {\n isAdjustingRef.current = false;\n }\n timeoutIdRef.current = null;\n }, 100);\n rafIdRef.current = null;\n });\n }\n }\n\n props.onTimeUpdate?.(e);\n }}\n {...props}\n />\n\n {controls && isFocused && <Keyboards />}\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import { useVideo } from \"./wrapper\";\nimport { useHotKeys } from \"./hooks/use-hot-keys\";\nimport { useSeek } from \"./hooks/use-seek\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\n\nexport const Keyboards = () => {\n const { videoRef } = useVideo();\n\n const { seekForward, seekBackward } = useSeek(videoRef);\n const { togglePlay } = usePlayPause(videoRef);\n const { toggleMute } = useMuteUnmute(videoRef);\n const { toggleFullscreen } = useFullscreen(videoRef);\n const { togglePictureInPicture } = usePictureInPicture(videoRef);\n\n useHotKeys(\"ArrowRight\", () => {\n seekForward();\n });\n useHotKeys(\"ArrowLeft\", () => {\n seekBackward();\n });\n useHotKeys(\" \", () => {\n togglePlay();\n });\n useHotKeys(\"m\", () => {\n toggleMute();\n });\n useHotKeys(\"f\", () => {\n toggleFullscreen();\n });\n useHotKeys(\"p\", () => {\n togglePictureInPicture();\n });\n\n return null;\n};\n","import React, { RefObject, useRef } from \"react\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { useSeek } from \"./hooks/use-seek\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useCurrentTime } from \"./hooks/use-current-time\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useDownload } from \"./hooks/use-download\";\nimport { useSpeed } from \"./hooks\";\nimport { useLoading } from \"./hooks/use-loading\";\n\ninterface ControlsProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Controls = React.memo(\n ({ children, asChild, ...props }: ControlsProps) => {\n return (\n <div data-zuude-hide-elements {...props}>\n {children}\n </div>\n );\n }\n);\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { play } = usePlayPause(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={play}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { pause } = usePlayPause(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={pause}>\n {children}\n </Element>\n );\n});\n\nconst Mute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { mute } = useMuteUnmute(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={mute}>\n {children}\n </Element>\n );\n});\n\nconst Unmute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { unmute } = useMuteUnmute(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={unmute}>\n {children}\n </Element>\n );\n});\n\ninterface SpeedProps extends Props {\n value: number;\n onClick?: () => void;\n}\n\nconst Speed = React.memo(\n ({ children, asChild, value, onClick, ...props }: SpeedProps) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { speed, onChangeSpeed } = useSpeed(\n videoRef as RefObject<HTMLVideoElement>\n );\n\n return (\n <Element\n {...props}\n value={value}\n onClick={() => {\n onChangeSpeed(value);\n onClick?.();\n }}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst SeekForward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { seekForward } = useSeek(videoRef as RefObject<HTMLVideoElement>, 10);\n\n return (\n <Element {...props} onClick={seekForward}>\n {children}\n </Element>\n );\n});\n\nconst SeekBackward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { seekBackward } = useSeek(videoRef as RefObject<HTMLVideoElement>, 10);\n\n return (\n <Element {...props} onClick={seekBackward}>\n {children}\n </Element>\n );\n});\n\nconst Fullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(videoRef);\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst ExitFullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(videoRef);\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst PictureInPicture = React.memo(\n ({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { togglePictureInPicture } = usePictureInPicture(videoRef);\n\n return (\n <Element {...props} onClick={togglePictureInPicture}>\n {children}\n </Element>\n );\n }\n);\n\nconst Download = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { downloadDirect } = useDownload(videoRef);\n\n return (\n <Element {...props} onClick={() => downloadDirect()}>\n {children}\n </Element>\n );\n});\n\ninterface LoadingProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Loading = React.memo(({ children, asChild, ...props }: LoadingProps) => {\n const Element = asChild ? Slot : \"div\";\n const { videoRef } = useVideo();\n\n const { isLoading } = useLoading(videoRef);\n\n return (\n <Element\n {...props}\n style={{ ...props.style, pointerEvents: \"none\" }}\n data-loading={isLoading}\n >\n {children}\n </Element>\n );\n});\n\ninterface ShadowProps extends React.ComponentProps<\"div\"> {}\n\nconst Shadow = ({ ...props }: ShadowProps) => {\n const { videoRef } = useVideo();\n\n const shadowVideoRef = useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n const video = videoRef?.current;\n if (shadowVideoRef.current && video) {\n let currentTime = 0;\n let isPlaying = false;\n let interval: ReturnType<typeof setInterval> | null = null;\n\n const startInterval = () => {\n if (interval) clearInterval(interval);\n interval = setInterval(() => {\n currentTime = video.currentTime;\n if (shadowVideoRef.current) {\n shadowVideoRef.current.currentTime = currentTime;\n }\n }, 100);\n };\n\n const stopInterval = () => {\n if (interval) {\n clearInterval(interval);\n interval = null;\n }\n };\n\n const handlePlay = () => {\n isPlaying = true;\n startInterval();\n };\n\n const handlePause = () => {\n isPlaying = false;\n stopInterval();\n };\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n stopInterval();\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n if (!videoRef?.current) return null;\n\n return (\n <div\n {...props}\n style={{\n ...props.style,\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n }}\n >\n <video\n ref={shadowVideoRef}\n src={videoRef.current.src}\n muted\n playsInline\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n }}\n />\n </div>\n );\n};\n\nexport {\n Controls,\n Play,\n Pause,\n Mute,\n Unmute,\n Speed,\n SeekForward,\n SeekBackward,\n Fullscreen,\n ExitFullscreen,\n PictureInPicture,\n Download,\n Loading,\n Shadow,\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useLoading = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n const handleLoadStart = () => {\n setIsLoading(true);\n };\n\n const handleLoadedMetadata = () => {\n // Metadata loaded but video might not be ready to play yet\n // Keep loading true until canplay\n };\n\n const handleLoadedData = () => {\n // First frame loaded, but might still be buffering\n // Keep loading true until canplay\n };\n\n const handleCanPlay = () => {\n setIsLoading(false);\n };\n\n const handleCanPlayThrough = () => {\n setIsLoading(false);\n };\n\n const handleWaiting = () => {\n // Video is waiting for data (buffering)\n setIsLoading(true);\n };\n\n const handlePlaying = () => {\n // Video is playing, so it's not loading anymore\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const handleAbort = () => {\n setIsLoading(false);\n };\n\n const handleSuspend = () => {\n // Loading suspended (e.g., user paused)\n // Don't change loading state here\n };\n\n // Add event listeners\n video.addEventListener(\"loadstart\", handleLoadStart);\n video.addEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.addEventListener(\"loadeddata\", handleLoadedData);\n video.addEventListener(\"canplay\", handleCanPlay);\n video.addEventListener(\"canplaythrough\", handleCanPlayThrough);\n video.addEventListener(\"waiting\", handleWaiting);\n video.addEventListener(\"playing\", handlePlaying);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"abort\", handleAbort);\n video.addEventListener(\"suspend\", handleSuspend);\n\n // Check initial state\n if (video.readyState >= 2) {\n setIsLoading(false);\n }\n\n return () => {\n // Remove event listeners\n video.removeEventListener(\"loadstart\", handleLoadStart);\n video.removeEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.removeEventListener(\"loadeddata\", handleLoadedData);\n video.removeEventListener(\"canplay\", handleCanPlay);\n video.removeEventListener(\"canplaythrough\", handleCanPlayThrough);\n video.removeEventListener(\"waiting\", handleWaiting);\n video.removeEventListener(\"playing\", handlePlaying);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"abort\", handleAbort);\n video.removeEventListener(\"suspend\", handleSuspend);\n };\n }, [videoRef]);\n\n return { isLoading };\n};\n"],"mappings":"oHAAA,OAAOA,GACL,iBAAAC,EACA,cAAAC,GACA,aAAAC,EACA,UAAAC,GACA,YAAAC,MACK,QAuKC,cAAAC,MAAA,oBArJD,IAAMC,EAAeN,EAAuC,IAAI,EAQ1DO,GAAgBR,EAAM,KACjC,CAAC,CAAE,SAAAS,EAAU,OAAAC,EAAQ,QAAAC,EAAS,GAAGC,CAAM,IAA0B,CAC/D,GAAM,CAACC,EAAUC,CAAW,EAAIT,EAAmB,CAAE,QAAS,IAAK,CAAC,EAC9D,CAACU,EAAOC,CAAQ,EAAIX,EAAwB,IAAI,EAChD,CAACY,EAAWC,CAAY,EAAIb,EAAS,EAAK,EAE1Cc,EAAkBf,GAAuB,IAAI,EAGnD,OAAAD,EAAU,IAAM,CACdQ,GAAA,MAAAA,EAAUI,EACZ,EAAG,CAACA,CAAK,CAAC,EAEVZ,EAAU,IAAM,CACd,IAAMiB,EAAeD,EAAgB,QACrC,GAAIC,EAAc,CAChB,IAAMC,EAAWD,EAAa,iBAC5B,4BACF,EACME,EAAQF,EAAa,cACzB,oBACF,EAEA,GAAIC,EAAU,CACZ,IAAIE,EAAoD,KAClDC,EAAY,IACdC,EAAc,GAEZC,EAAa,IAAM,CAEnBH,IACF,aAAaA,CAAW,EACxBA,EAAc,MAIhBA,EAAc,WAAW,IAAM,CACzBE,GAEEH,GAAS,CAACA,EAAM,QAClBD,EAAS,QAASM,GAAY,CAC5BA,EAAQ,aAAa,cAAe,MAAM,CAC5C,CAAC,EAGLJ,EAAc,IAChB,EAAGC,CAAS,CACd,EAEMI,EAAe,IAAM,CACzBH,EAAc,GAC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C,EAAQtC,GAAA,YAAAA,EAAU,QACxB,GAAIoC,EAAe,SAAWE,EAAO,CACnC,IAAIC,EAAc,EACdC,EAAY,GACZC,EAAkD,KAEhDC,EAAgB,IAAM,CACtBD,GAAU,cAAcA,CAAQ,EACpCA,EAAW,YAAY,IAAM,CAC3BF,EAAcD,EAAM,YAChBF,EAAe,UACjBA,EAAe,QAAQ,YAAcG,EAEzC,EAAG,GAAG,CACR,EAEMI,EAAe,IAAM,CACrBF,IACF,cAAcA,CAAQ,EACtBA,EAAW,KAEf,EAEMG,EAAa,IAAM,CACvBJ,EAAY,GACZE,EAAc,CAChB,EAEMG,EAAc,IAAM,CACxBL,EAAY,GACZG,EAAa,CACf,EAEA,OAAAL,EAAM,iBAAiB,OAAQM,CAAU,EACzCN,EAAM,iBAAiB,QAASO,CAAW,EAEpC,IAAM,CACXF,EAAa,EACbL,EAAM,oBAAoB,OAAQM,CAAU,EAC5CN,EAAM,oBAAoB,QAASO,CAAW,CAChD,CACF,CACF,EAAG,CAAC7C,GAAA,YAAAA,EAAU,OAAO,CAAC,EAEjBA,GAAA,MAAAA,EAAU,QAGbT,EAAC,OACE,GAAGK,EACJ,MAAO,CACL,GAAGA,EAAM,MACT,SAAU,WACV,IAAK,EACL,KAAM,EACN,MAAO,OACP,OAAQ,OACR,cAAe,MACjB,EAEA,SAAAL,EAAC,SACC,IAAK6C,EACL,IAAKpC,EAAS,QAAQ,IACtB,MAAK,GACL,YAAW,GACX,MAAO,CACL,MAAO,OACP,OAAQ,OACR,UAAW,OACb,EACF,EACF,EA1B6B,IA4BjC","names":["React","createContext","useContext","useEffect","useRef","useState","jsx","VideoContext","VideoProvider","children","config","onError","props","videoRef","setVideoRef","error","setError","isFocused","setIsFocused","videoWrapperRef","videoWrapper","controls","video","hideTimeout","hideDelay","isMouseOver","resetTimer","control","showControls","hideControls","handleMouseMove","handlePlay","handleClick","event","_a","useVideo","context","forwardRef","useCallback","useEffect","useRef","Keyboards","videoRef","useVideo","seekForward","seekBackward","useSeek","togglePlay","usePlayPause","toggleMute","useMuteUnmute","toggleFullscreen","useFullscreen","togglePictureInPicture","usePictureInPicture","useHotKeys","Fragment","jsx","jsxs","Video","forwardRef","src","autoPlay","muteFallback","controls","preload","autoPlayOnVisible","ranges","props","ref","videoRef","setVideoRef","config","setError","error","isFocused","useVideo","refVideo","useRef","isAdjustingRef","rafIdRef","timeoutIdRef","isValidRange","rangeStart","rangeEnd","useEffect","video","thirdPartyRef","useAutoplayByForce","useAutoplayOnVisible","onPlay","useCallback","_a","_b","_c","e","currentTime","Keyboards","React","useRef","Slot","React","useLoading","videoRef","isLoading","setIsLoading","video","handleLoadStart","handleLoadedMetadata","handleLoadedData","handleCanPlay","handleCanPlayThrough","handleWaiting","handlePlaying","handleError","handleAbort","handleSuspend","jsx","Controls","React","children","asChild","props","Play","Element","Slot","videoRef","useVideo","play","usePlayPause","Pause","pause","Mute","mute","useMuteUnmute","Unmute","unmute","Speed","value","onClick","speed","onChangeSpeed","useSpeed","SeekForward","seekForward","useSeek","SeekBackward","seekBackward","Fullscreen","toggleFullscreen","useFullscreen","ExitFullscreen","PictureInPicture","togglePictureInPicture","usePictureInPicture","Download","downloadDirect","useDownload","Loading","isLoading","useLoading","Shadow","shadowVideoRef","useRef","video","currentTime","isPlaying","interval","startInterval","stopInterval","handlePlay","handlePause"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
type VideoAutoplay = boolean | "force";
|
|
4
|
+
type CustomVideoRef = RefObject<(Omit<HTMLVideoElement, "autoplay"> & {
|
|
5
|
+
autoplay?: VideoAutoplay;
|
|
6
|
+
}) | null>;
|
|
7
|
+
type VideoRef = RefObject<HTMLVideoElement | null> | null;
|
|
8
|
+
|
|
9
|
+
export type { CustomVideoRef as C, VideoRef as V, VideoAutoplay as a };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
type VideoAutoplay = boolean | "force";
|
|
4
|
+
type CustomVideoRef = RefObject<(Omit<HTMLVideoElement, "autoplay"> & {
|
|
5
|
+
autoplay?: VideoAutoplay;
|
|
6
|
+
}) | null>;
|
|
7
|
+
type VideoRef = RefObject<HTMLVideoElement | null> | null;
|
|
8
|
+
|
|
9
|
+
export type { CustomVideoRef as C, VideoRef as V, VideoAutoplay as a };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var x=(o,t)=>{for(var s in t)d(o,s,{get:t[s],enumerable:!0})},y=(o,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of F(t))!w.call(o,r)&&r!==s&&d(o,r,{get:()=>t[r],enumerable:!(n=T(t,r))||n.enumerable});return o};var L=o=>y(d({},"__esModule",{value:!0}),o);var Z={};x(Z,{compactTime:()=>b,detailedTime:()=>M,formatTime:()=>$,formatTimeForAccessibility:()=>O,formatTimeWithPercentage:()=>A,getTimeSegments:()=>H,humanizeTime:()=>g,parseTime:()=>W,timeRemaining:()=>z});module.exports=L(Z);function $(o,t="mm:ss"){let s=typeof t=="string"?{format:t}:t,{format:n="mm:ss",showHours:r=!0,showLeadingZeros:i=!0,showMilliseconds:c=!1,humanize:a=!1,compact:m=!1}=s;if(a)return g(o,{compact:m});let u=Math.floor(o),h=Math.floor(u/3600),l=Math.floor(u%3600/60),f=u%60,j=Math.floor(o%1*1e3),e=(p,S=2)=>i?p.toString().padStart(S,"0"):p.toString();switch(n){case"h:mm:ss":return`${e(h)}:${e(l)}:${e(f)}`;case"mm:ss":return r&&h>0?`${e(h)}:${e(l)}:${e(f)}`:`${e(l)}:${e(f)}`;case"ss":return`${u}s`;case"compact":return b(o);case"detailed":return M(o,{showMilliseconds:c});default:return`${e(l)}:${e(f)}`}}function g(o,t={}){let{compact:s=!1}=t,n=Math.floor(o);if(n<60)return`${n} second${n!==1?"s":""}`;let r=Math.floor(n/3600),i=Math.floor(n%3600/60),c=n%60,a=[];return r>0&&a.push(`${r} hour${r!==1?"s":""}`),i>0&&a.push(`${i} minute${i!==1?"s":""}`),c>0&&!s&&a.push(`${c} second${c!==1?"s":""}`),a.join(" ")}function b(o){let t=Math.floor(o),s=Math.floor(t/3600),n=Math.floor(t%3600/60),r=t%60;return s>0?`${s}:${n.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${n}:${r.toString().padStart(2,"0")}`}function M(o,t={}){let{showMilliseconds:s=!1}=t,n=Math.floor(o),r=Math.floor(n/3600),i=Math.floor(n%3600/60),c=n%60,a=Math.floor(o%1*1e3),m=`${r.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;return s&&(m+=`.${a.toString().padStart(3,"0")}`),m}function W(o){let t=o.toLowerCase().trim();if(t.endsWith("s"))return parseFloat(t.slice(0,-1));if(t.endsWith("m"))return parseFloat(t.slice(0,-1))*60;if(t.endsWith("h"))return parseFloat(t.slice(0,-1))*3600;let s=o.split(":").map(Number);return s.length===2?(s[0]||0)*60+(s[1]||0):s.length===3?(s[0]||0)*3600+(s[1]||0)*60+(s[2]||0):parseFloat(o)||0}function z(o,t,s="mm:ss"){let n=Math.max(0,t-o);return $(n,s)}function A(o,t,s="mm:ss"){let n=t>0?Math.round(o/t*100):0;return`${$(o,s)} (${n}%)`}function H(o,t=10){return Array.from({length:t+1},(s,n)=>o/t*n)}function O(o){let t=Math.floor(o),s=Math.floor(t/3600),n=Math.floor(t%3600/60),r=t%60;return s>0?`${s} hours, ${n} minutes, ${r} seconds`:n>0?`${n} minutes, ${r} seconds`:`${r} seconds`}0&&(module.exports={compactTime,detailedTime,formatTime,formatTimeForAccessibility,formatTimeWithPercentage,getTimeSegments,humanizeTime,parseTime,timeRemaining});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|