@zuude-ui/video 0.0.5 → 0.0.6

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/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";"use client";var ae=Object.create;var x=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of de(t))!pe.call(e,r)&&r!==n&&x(e,r,{get:()=>t[r],enumerable:!(o=le(t,r))||o.enumerable});return e};var d=(e,t,n)=>(n=e!=null?ae(me(e)):{},O(t||!e||!e.__esModule?x(n,"default",{value:e,enumerable:!0}):n,e)),ye=e=>O(x({},"__esModule",{value:!0}),e);var ve={};fe(ve,{Video:()=>ee,formatTime:()=>oe,useFullscreen:()=>M,useGetDuration:()=>ne,useMuteUnmute:()=>L,usePlayPause:()=>f,useStartAt:()=>b,useTimeline:()=>re,useVideo:()=>i,useVolume:()=>te});module.exports=ye(ve);function S(e,{insertAt:t}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}S(`.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}
2
- `);var E=d(require("react"),1);var g=d(require("react"),1),z=require("react/jsx-runtime"),A=g.default.createContext(void 0),i=()=>{let e=g.default.useContext(A);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},N=({children:e,ref:t,duration:n,showHidingElement:o,setShowHidingElement:r})=>{let[s,u]=g.default.useState(!1);return(0,z.jsx)(A.Provider,{value:{ref:t,duration:n,isFullscreen:s,setIsFullscreen:u,showHidingElement:o,setShowHidingElement:r},children:e})};var k=d(require("react"),1),q=(e,t)=>{k.default.useEffect(()=>{if(!e.current||!t)return;(async()=>{var o;try{await((o=e.current)==null?void 0:o.play())}catch(r){if(r instanceof Error&&r.name==="NotAllowedError"){if(console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(s){console.error(s)}}}else console.error(r)}})()},[t,e.current])};var $=d(require("react"),1),b=(e,t)=>{$.default.useEffect(()=>{if(!e.current||!t)return;let n=e.current;n&&t&&(n.currentTime=t)},[t])};var B=d(require("react"),1),D=(e,t,n)=>{B.default.useEffect(()=>{if(!n||!e.current)return;let o=new IntersectionObserver(r=>{r.forEach(s=>{var u;e.current&&(s.isIntersecting?e.current.play().catch(a=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(a))}):(u=e.current)==null||u.pause())})},{threshold:t!=null?t:.5});return o.observe(e.current),()=>{o.disconnect()}},[n,e.current])};var C=d(require("react"),1),f=(e,t)=>{let[n,o]=C.default.useState(!1),r=C.default.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return C.default.useEffect(()=>{if(!t||!e.current)return;let s=()=>{o(!0)},u=()=>{o(!1)};if(o(!e.current.paused),e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",u),()=>{var a,m;(a=e.current)==null||a.removeEventListener("play",s),(m=e.current)==null||m.removeEventListener("pause",u)}},[e.current,t]),{togglePlay:r,isPlaying:n}};var U=require("react/jsx-runtime"),j=()=>{let{ref:e}=i(),{togglePlay:t}=f(e,!0);return(0,U.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:t})};var T=d(require("react"),1),L=(e,t)=>{let[n,o]=T.default.useState(!1),r=T.default.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return T.default.useEffect(()=>{if(!t||!e.current)return;o(e.current.muted);let s=()=>{e.current&&o(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var u;(u=e.current)==null||u.removeEventListener("volumechange",s)}},[e.current,t]),{toggleMute:r,isMuted:n}};var G=d(require("react"),1);var M=()=>{let{ref:e,isFullscreen:t,setIsFullscreen:n}=i();G.default.useEffect(()=>{let r=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[]);let o=()=>{var a;let r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&r){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let u=(a=e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");u&&(t?document.exitFullscreen():u.requestFullscreen())};return{isFullscreen:t!=null?t:!1,toggleFullscreen:o}};var W=d(require("react"),1);var J=()=>{let{ref:e,isPictureInPicture:t,setIsPictureInPicture:n}=i();W.default.useEffect(()=>{let r=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",r),()=>document.removeEventListener("pictureinpicturechange",r)},[]);let o=async()=>{let r=e.current;if(r)try{document.pictureInPictureElement?await document.exitPictureInPicture():await r.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen&&r.requestFullscreen();else{let a=r.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:t!=null?t:!1,togglePictureInPicture:o}};var I=d(require("react"),1),K=(e,t)=>{let[n,o]=I.default.useState(1),r=s=>{o(s)};return I.default.useEffect(()=>{!t||!e.current||(e.current.playbackRate=n)},[n,t,e.current]),{speed:n,onChangeSpeed:r}};var Q=({ref:e,children:t})=>{let{duration:n,showHidingElement:o}=i(),{togglePlay:r,isPlaying:s}=f(e,typeof t=="function"),{speed:u,onChangeSpeed:a}=K(e,typeof t=="function"),{toggleMute:m,isMuted:p}=L(e,typeof t=="function"),{isFullscreen:V,toggleFullscreen:c}=M(),{isPictureInPicture:F,togglePictureInPicture:y}=J();return typeof t!="function"?null:t({isPlaying:s,togglePlay:r,isMuted:p,toggleMute:m,speed:u,onChangeSpeed:a,isFullscreen:V,toggleFullscreen:c,isPictureInPicture:F,togglePictureInPicture:y,duration:n,showHidingElement:o!=null?o:!1})};var X=d(require("react"),1);var Z=require("react/jsx-runtime"),Y=X.default.forwardRef(({children:e,className:t,...n})=>{let{ref:o}=i(),{isPlaying:r}=f(o,!0),{showHidingElement:s,setShowHidingElement:u}=i();return(0,Z.jsx)("div",{"data-zuude-hiding-element":!0,"data-show":!r||s,className:t,onMouseEnter:()=>{u==null||u(!0)},onMouseLeave:()=>{u==null||u(!1)},...n,children:e})});var h=require("react/jsx-runtime"),_=E.default.forwardRef(({children:e,autoPlay:t,className:n,ratio:o,config:r,controls:s,pause:u,...a},m)=>{let[p,V]=E.default.useState(null),c=m||E.default.useRef(null),[F,y]=E.default.useState(!1),v=E.default.useRef(null),ue=()=>{var l;(l=c.current)!=null&&l.paused||(y(!0),v.current&&clearTimeout(v.current))},se=()=>{var l;(l=c.current)!=null&&l.paused||(y(!1),v.current&&clearTimeout(v.current))},ie=()=>{var l;(l=c.current)!=null&&l.paused||(y(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{y(!1)},3e3))};return E.default.useEffect(()=>{var l,P;u!==void 0&&(u?(l=c.current)==null||l.pause():(P=c.current)==null||P.play())},[u,c.current]),q(c,t==="force"&&a.muted===void 0&&!(r!=null&&r.autoplayOnVisible)),b(c,r==null?void 0:r.startAt),D(c,typeof(r==null?void 0:r.autoplayOnVisible)=="number"?r.autoplayOnVisible:void 0,r==null?void 0:r.autoplayOnVisible),(0,h.jsx)(N,{ref:c,duration:p,showHidingElement:F,setShowHidingElement:y,children:(0,h.jsxs)("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:o},className:n,children:[(0,h.jsx)("video",{"data-zuude-video":!0,ref:c,autoPlay:r!=null&&r.autoplayOnVisible?!1:t==="force"?!0:t,playsInline:!0,onMouseEnter:ue,onMouseLeave:se,onMouseMove:ie,onLoadedMetadata:l=>{V(l.target.duration)},onTimeUpdate:l=>{if(r!=null&&r.range){let[P,ce]=r.range;c.current.currentTime<P&&(c.current.currentTime=P),c.current.currentTime>ce&&(c.current.currentTime=P)}},...a}),typeof e=="function"?(0,h.jsx)(Q,{ref:c,children:e}):e]})})});_.displayName="Video";var ee=Object.assign(_,{PlayPauseOnVideo:j,HidingElement:Y});var H=d(require("react"),1);var te=()=>{let[e,t]=H.default.useState(100),{ref:n}=i(),o=r=>{t(r)};return H.default.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:o}};var R=d(require("react"),1);var re=()=>{let[e,t]=R.default.useState(!1),[n,o]=R.default.useState(0),[r,s]=R.default.useState(0),{ref:u,duration:a}=i();return R.default.useEffect(()=>{if(u.current&&e){let m=setInterval(()=>{var p,V;o(((p=u.current)==null?void 0:p.currentTime)||0),(V=u.current)!=null&&V.buffered.length&&s(u.current.buffered.end(u.current.buffered.length-1))},10);return()=>clearInterval(m)}},[u.current,e]),R.default.useEffect(()=>{if(u.current)return u.current.addEventListener("play",()=>t(!0)),u.current.addEventListener("pause",()=>t(!1)),()=>{var m,p;(m=u.current)==null||m.removeEventListener("play",()=>t(!0)),(p=u.current)==null||p.removeEventListener("pause",()=>t(!1))}},[]),{currentTime:n,duration:a,buffered:r,setCurrentTime:o}};var w=d(require("react"),1);var ne=e=>{let[t,n]=w.default.useState(!1),[o,r]=w.default.useState(null),{ref:s}=i();return w.default.useEffect(()=>{if(!s.current)return;n(!0);let u=document.createElement("video");return u.src=e,u.muted=!0,u.addEventListener("loadedmetadata",()=>{r(u.duration),n(!1)}),u.addEventListener("error",()=>{n(!1)}),()=>{u.remove()}},[e]),{duration:o,isLoading:t}};function oe(e,t="mm:ss"){let n=Math.floor(e/60),o=Math.floor(e%60);return t==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${o<10?"0":""}${o}`:`${n}:${o<10?"0":""}${o}`}0&&(module.exports={Video,formatTime,useFullscreen,useGetDuration,useMuteUnmute,usePlayPause,useStartAt,useTimeline,useVideo,useVolume});
1
+ "use strict";"use client";var de=Object.create;var b=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)b(e,n,{get:t[n],enumerable:!0})},A=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pe(t))!ye.call(e,r)&&r!==n&&b(e,r,{get:()=>t[r],enumerable:!(o=me(t,r))||o.enumerable});return e};var d=(e,t,n)=>(n=e!=null?de(fe(e)):{},A(t||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)),Ee=e=>A(b({},"__esModule",{value:!0}),e);var Ve={};ve(Ve,{Video:()=>te,formatTime:()=>ue,useFullscreen:()=>M,useGetDuration:()=>oe,useMuteUnmute:()=>w,usePlayPause:()=>f,useStartAt:()=>C,useTimeline:()=>ne,useVideo:()=>c,useVolume:()=>re});module.exports=Ee(Ve);function I(e,{insertAt:t}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",t==="top"&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}I(`.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}
2
+ `);var y=d(require("react"),1);var g=d(require("react"),1),z=require("react/jsx-runtime"),N=g.default.createContext(void 0),c=()=>{let e=g.default.useContext(N);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},k=({children:e,ref:t,duration:n,showHidingElement:o,setShowHidingElement:r})=>{let[s,u]=g.default.useState(!1);return(0,z.jsx)(N.Provider,{value:{ref:t,duration:n,isFullscreen:s,setIsFullscreen:u,showHidingElement:o,setShowHidingElement:r},children:e})};var q=d(require("react"),1),$=(e,t,n)=>{q.default.useEffect(()=>{if(!e.current||!t)return;(async()=>{var r;try{await((r=e.current)==null?void 0:r.play())}catch(s){if(s instanceof Error&&s.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(u){console.error(u)}}}else console.error(s)}})()},[t,e.current])};var B=d(require("react"),1),C=(e,t)=>{B.default.useEffect(()=>{if(!e.current||!t)return;let n=e.current;n&&t&&(n.currentTime=t)},[t])};var D=d(require("react"),1),j=(e,t,n)=>{D.default.useEffect(()=>{if(!n||!e.current)return;let o=new IntersectionObserver(r=>{r.forEach(s=>{var u;e.current&&(s.isIntersecting?e.current.play().catch(a=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(a))}):(u=e.current)==null||u.pause())})},{threshold:t!=null?t:.5});return o.observe(e.current),()=>{o.disconnect()}},[n,e.current])};var T=d(require("react"),1),f=(e,t)=>{let[n,o]=T.default.useState(!1),r=T.default.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return T.default.useEffect(()=>{if(!t||!e.current)return;let s=()=>{o(!0)},u=()=>{o(!1)};if(o(!e.current.paused),e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",u),()=>{var a,m;(a=e.current)==null||a.removeEventListener("play",s),(m=e.current)==null||m.removeEventListener("pause",u)}},[e.current,t]),{togglePlay:r,isPlaying:n}};var G=require("react/jsx-runtime"),U=()=>{let{ref:e}=c(),{togglePlay:t}=f(e,!0);return(0,G.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:t})};var L=d(require("react"),1),w=(e,t)=>{let[n,o]=L.default.useState(!1),r=L.default.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return L.default.useEffect(()=>{if(!t||!e.current)return;o(e.current.muted);let s=()=>{e.current&&o(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var u;(u=e.current)==null||u.removeEventListener("volumechange",s)}},[e.current,t]),{toggleMute:r,isMuted:n}};var W=d(require("react"),1);var M=()=>{let{ref:e,isFullscreen:t,setIsFullscreen:n}=c();W.default.useEffect(()=>{let r=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r)},[]);let o=()=>{var a;let r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&r){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let u=(a=e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");u&&(t?document.exitFullscreen():u.requestFullscreen())};return{isFullscreen:t!=null?t:!1,toggleFullscreen:o}};var J=d(require("react"),1);var K=()=>{let{ref:e,isPictureInPicture:t,setIsPictureInPicture:n}=c();J.default.useEffect(()=>{let r=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",r),()=>document.removeEventListener("pictureinpicturechange",r)},[]);let o=async()=>{let r=e.current;if(r)try{document.pictureInPictureElement?await document.exitPictureInPicture():await r.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))r.webkitEnterFullscreen?r.webkitEnterFullscreen():r.requestFullscreen&&r.requestFullscreen();else{let a=r.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:t!=null?t:!1,togglePictureInPicture:o}};var H=d(require("react"),1),Q=(e,t)=>{let[n,o]=H.default.useState(1),r=s=>{o(s)};return H.default.useEffect(()=>{!t||!e.current||(e.current.playbackRate=n)},[n,t,e.current]),{speed:n,onChangeSpeed:r}};var X=({ref:e,children:t})=>{let{duration:n,showHidingElement:o}=c(),{togglePlay:r,isPlaying:s}=f(e,typeof t=="function"),{speed:u,onChangeSpeed:a}=Q(e,typeof t=="function"),{toggleMute:m,isMuted:p}=w(e,typeof t=="function"),{isFullscreen:E,toggleFullscreen:S}=M(),{isPictureInPicture:x,togglePictureInPicture:i}=K();return typeof t!="function"?null:t({isPlaying:s,togglePlay:r,isMuted:p,toggleMute:m,speed:u,onChangeSpeed:a,isFullscreen:E,toggleFullscreen:S,isPictureInPicture:x,togglePictureInPicture:i,duration:n,showHidingElement:o!=null?o:!1})};var Y=d(require("react"),1);var _=require("react/jsx-runtime"),Z=Y.default.forwardRef(({children:e,className:t,...n})=>{let{ref:o}=c(),{isPlaying:r}=f(o,!0),{showHidingElement:s,setShowHidingElement:u}=c();return(0,_.jsx)("div",{"data-zuude-hiding-element":!0,"data-show":!r||s,className:t,onMouseEnter:()=>{u==null||u(!0)},onMouseLeave:()=>{u==null||u(!1)},...n,children:e})});var P=require("react/jsx-runtime"),ee=y.default.forwardRef(({children:e,autoPlay:t,className:n,ratio:o,config:r,controls:s,pause:u,...a},m)=>{let[p,E]=y.default.useState(null),[S,x]=y.default.useState(null),i=m||y.default.useRef(null),[se,R]=y.default.useState(!1),v=y.default.useRef(null),ie=()=>{var l;(l=i.current)!=null&&l.paused||(R(!0),v.current&&clearTimeout(v.current))},ae=()=>{var l;(l=i.current)!=null&&l.paused||(R(!1),v.current&&clearTimeout(v.current))},ce=()=>{var l;(l=i.current)!=null&&l.paused||(R(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{R(!1)},3e3))};return y.default.useEffect(()=>{var l,V;u!==void 0&&(u?(l=i.current)==null||l.pause():(V=i.current)==null||V.play())},[u,i.current]),$(i,t==="force"&&a.muted===void 0&&!(r!=null&&r.autoplayOnVisible),x),C(i,r==null?void 0:r.startAt),j(i,typeof(r==null?void 0:r.autoplayOnVisible)=="number"?r.autoplayOnVisible:void 0,r==null?void 0:r.autoplayOnVisible),(0,P.jsx)(k,{ref:i,duration:p,showHidingElement:se,setShowHidingElement:R,children:(0,P.jsxs)("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:o},className:n,children:[(0,P.jsx)("video",{"data-zuude-video":!0,ref:i,autoPlay:r!=null&&r.autoplayOnVisible?!1:t==="force"?!0:t,playsInline:!0,onMouseEnter:ie,onMouseLeave:ae,onMouseMove:ce,onLoadedMetadata:l=>{console.log("loaded metadata"),E(l.target.duration)},onTimeUpdate:l=>{if(r!=null&&r.range){let[V,le]=r.range;i.current.currentTime<V&&(i.current.currentTime=V),i.current.currentTime>le&&(i.current.currentTime=V)}},...a}),typeof e=="function"?(0,P.jsx)(X,{ref:i,children:e}):e,S==="NotAllowedError"&&typeof(r==null?void 0:r.muteFallback)=="function"&&r.muteFallback(()=>{i.current&&(i.current.muted=!i.current.muted),x(null)})]})})});ee.displayName="Video";var te=Object.assign(ee,{PlayPauseOnVideo:U,HidingElement:Z});var O=d(require("react"),1);var re=()=>{let[e,t]=O.default.useState(100),{ref:n}=c(),o=r=>{t(r)};return O.default.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:o}};var h=d(require("react"),1);var ne=()=>{let[e,t]=h.default.useState(!1),[n,o]=h.default.useState(0),[r,s]=h.default.useState(0),{ref:u,duration:a}=c();return h.default.useEffect(()=>{if(u.current&&e){let m=setInterval(()=>{var p,E;o(((p=u.current)==null?void 0:p.currentTime)||0),(E=u.current)!=null&&E.buffered.length&&s(u.current.buffered.end(u.current.buffered.length-1))},10);return()=>clearInterval(m)}},[u.current,e]),h.default.useEffect(()=>{if(u.current)return u.current.addEventListener("play",()=>t(!0)),u.current.addEventListener("pause",()=>t(!1)),()=>{var m,p;(m=u.current)==null||m.removeEventListener("play",()=>t(!0)),(p=u.current)==null||p.removeEventListener("pause",()=>t(!1))}},[]),{currentTime:n,duration:a,buffered:r,setCurrentTime:o}};var F=d(require("react"),1),oe=e=>{let[t,n]=F.default.useState(!1),[o,r]=F.default.useState(null);return F.default.useEffect(()=>{if(e.current)return n(!0),e.current.addEventListener("loadedmetadata",()=>{var s,u;r((u=(s=e.current)==null?void 0:s.duration)!=null?u:null),n(!1)}),e.current.addEventListener("error",()=>{n(!1)}),()=>{var s,u;(s=e.current)==null||s.removeEventListener("loadedmetadata",()=>{}),(u=e.current)==null||u.removeEventListener("error",()=>{})}},[e.current]),{duration:o,isLoading:t}};function ue(e,t="mm:ss"){let n=Math.floor(e/60),o=Math.floor(e%60);return t==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${o<10?"0":""}${o}`:`${n}:${o<10?"0":""}${o}`}0&&(module.exports={Video,formatTime,useFullscreen,useGetDuration,useMuteUnmute,usePlayPause,useStartAt,useTimeline,useVideo,useVolume});
3
3
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.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/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/get-duration.tsx","../src/utils.ts"],"sourcesContent":["\"use client\";\n\nimport \"./styles.css\";\n\nexport { Video } from \"./video\";\n\n// Context\nexport { useVideo } from \"./context\";\n\n// Hooks\nexport { useVolume } from \"./hooks/use-volume\";\nexport { useTimeline } from \"./hooks/use-timeline\";\nexport { useGetDuration } from \"./hooks/get-duration\";\nexport { usePlayPause } from \"./hooks/use-play-pause\";\nexport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nexport { useStartAt } from \"./hooks/use-start-at\";\nexport { useFullscreen } from \"./hooks/use-fullscreen\";\n\n// Utils\nexport { formatTime } from \"./utils\";\n","\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 } 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, ratio, config, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const videoRef =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(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 );\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 ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\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 onLoadedMetadata={(e) => {\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.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\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 ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\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 { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (ref: VideoRef, enabled: boolean) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, ref.current]);\n};\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]);\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 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 { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, 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\";\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 { ref, 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 = ref.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 = ref.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 { ref, 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 = ref.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 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\";\n\nimport type { VideoChildren } 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 = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\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,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\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 { 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 { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, 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 { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\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 { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.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 { useVideo } from \"../context\";\n\nexport const useGetDuration = (url: string) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const { ref } = useVideo();\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n setIsLoading(true);\n\n const video = document.createElement(\"video\");\n\n video.src = url;\n video.muted = true;\n\n video.addEventListener(\"loadedmetadata\", () => {\n setDuration(video.duration);\n setIsLoading(false);\n });\n\n video.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n video.remove();\n };\n }, [url]);\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":"mlBAAA,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AoB,QAAS,IAAMX,EAAa,EAAK,EACpE,CACF,EAAG,CAAC,CAAC,EAEE,CACL,YAAAE,EACA,SAAAK,EACA,SAAAH,EACA,eAAAD,CACF,CACF,EC5CA,IAAAS,EAAkB,sBAGX,IAAMC,GAAkBC,GAAgB,CAC7C,GAAM,CAACC,EAAWC,CAAY,EAAI,EAAAC,QAAM,SAAS,EAAK,EAChD,CAACC,EAAUC,CAAW,EAAI,EAAAF,QAAM,SAAwB,IAAI,EAE5D,CAAE,IAAAG,CAAI,EAAIC,EAAS,EAEzB,SAAAJ,QAAM,UAAU,IAAM,CACpB,GAAI,CAACG,EAAI,QAAS,OAElBJ,EAAa,EAAI,EAEjB,IAAMM,EAAQ,SAAS,cAAc,OAAO,EAE5C,OAAAA,EAAM,IAAMR,EACZQ,EAAM,MAAQ,GAEdA,EAAM,iBAAiB,iBAAkB,IAAM,CAC7CH,EAAYG,EAAM,QAAQ,EAC1BN,EAAa,EAAK,CACpB,CAAC,EAEDM,EAAM,iBAAiB,QAAS,IAAM,CACpCN,EAAa,EAAK,CACpB,CAAC,EAEM,IAAM,CACXM,EAAM,OAAO,CACf,CACF,EAAG,CAACR,CAAG,CAAC,EAED,CAAE,SAAAI,EAAU,UAAAH,CAAU,CAC/B,EClCA,SAASQ,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":["index_exports","__export","Video","formatTime","useFullscreen","useGetDuration","useMuteUnmute","usePlayPause","useStartAt","useTimeline","useVideo","useVolume","__toCommonJS","styleInject","css","insertAt","head","style","styleInject","import_react","import_react","import_jsx_runtime","VideoContext","React","useVideo","context","VideoProvider","children","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","import_react","useAutoplayByForce","ref","enabled","React","_a","error","retryError","import_react","useStartAt","ref","startAt","React","video","import_react","useAutoplayOnVisible","ref","threshold","enabled","React","observer","entries","entry","_a","error","import_react","usePlayPause","ref","enabled","isPlaying","setIsPlaying","React","togglePlay","handlePlay","handlePause","_a","_b","import_jsx_runtime","PlayPauseOnVideo","ref","useVideo","togglePlay","usePlayPause","import_react","useMuteUnmute","ref","enabled","isMuted","setIsMuted","React","toggleMute","handleVolumeChange","_a","import_react","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","import_react","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","import_react","useSpeed","ref","enabled","speed","setSpeed","React","onChangeSpeed","FunctionChildren","ref","children","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","import_react","import_jsx_runtime","HidingElement","React","children","className","props","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","import_jsx_runtime","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","import_react","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","import_react","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","import_react","useGetDuration","url","isLoading","setIsLoading","React","duration","setDuration","ref","useVideo","video","formatTime","time","type","minutes","seconds"]}
1
+ {"version":3,"sources":["../src/index.ts","#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.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/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.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":["\"use client\";\n\nimport \"./styles.css\";\n\nexport { Video } from \"./video\";\n\n// Context\nexport { useVideo } from \"./context\";\n\n// Hooks\nexport { useVolume } from \"./hooks/use-volume\";\nexport { useTimeline } from \"./hooks/use-timeline\";\nexport { useGetDuration } from \"./hooks/use-get-duration\";\nexport { usePlayPause } from \"./hooks/use-play-pause\";\nexport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nexport { useStartAt } from \"./hooks/use-start-at\";\nexport { useFullscreen } from \"./hooks/use-fullscreen\";\n\n// Utils\nexport { formatTime } from \"./utils\";\n","\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 } 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, ratio, config, 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 =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(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 ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\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 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.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\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 ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\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 { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (\n ref: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, ref.current]);\n};\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]);\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 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 { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, 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\";\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 { ref, 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 = ref.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 = ref.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 { ref, 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 = ref.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 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\";\n\nimport type { VideoChildren } 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 = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\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,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\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 { 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 { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, 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 { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\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 { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.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":"mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,WAAAE,GAAA,eAAAC,GAAA,kBAAAC,EAAA,mBAAAC,GAAA,kBAAAC,EAAA,iBAAAC,EAAA,eAAAC,EAAA,gBAAAC,GAAA,aAAAC,EAAA,cAAAC,KAAA,eAAAC,GAAAZ,ICCyB,SAARa,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,C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","names":["index_exports","__export","Video","formatTime","useFullscreen","useGetDuration","useMuteUnmute","usePlayPause","useStartAt","useTimeline","useVideo","useVolume","__toCommonJS","styleInject","css","insertAt","head","style","styleInject","import_react","import_react","import_jsx_runtime","VideoContext","React","useVideo","context","VideoProvider","children","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","import_react","useAutoplayByForce","ref","enabled","setError","React","_a","error","retryError","import_react","useStartAt","ref","startAt","React","video","import_react","useAutoplayOnVisible","ref","threshold","enabled","React","observer","entries","entry","_a","error","import_react","usePlayPause","ref","enabled","isPlaying","setIsPlaying","React","togglePlay","handlePlay","handlePause","_a","_b","import_jsx_runtime","PlayPauseOnVideo","ref","useVideo","togglePlay","usePlayPause","import_react","useMuteUnmute","ref","enabled","isMuted","setIsMuted","React","toggleMute","handleVolumeChange","_a","import_react","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","import_react","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","import_react","useSpeed","ref","enabled","speed","setSpeed","React","onChangeSpeed","FunctionChildren","ref","children","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","import_react","import_jsx_runtime","HidingElement","React","children","className","props","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","import_jsx_runtime","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","error","setError","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","import_react","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","import_react","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","import_react","useGetDuration","ref","isLoading","setIsLoading","React","duration","setDuration","_a","_b","formatTime","time","type","minutes","seconds"]}
package/dist/index.d.cts CHANGED
@@ -23,6 +23,7 @@ type VideoConfig = {
23
23
  startAt?: number;
24
24
  range?: [number, number];
25
25
  autoplayOnVisible?: boolean | number;
26
+ muteFallback?: (toggleMute: () => void) => ReactNode;
26
27
  };
27
28
  interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
28
29
  children?: VideoChildren;
@@ -71,7 +72,7 @@ declare const useTimeline: () => {
71
72
  setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
72
73
  };
73
74
 
74
- declare const useGetDuration: (url: string) => {
75
+ declare const useGetDuration: (ref: VideoRef) => {
75
76
  duration: number | null;
76
77
  isLoading: boolean;
77
78
  };
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ type VideoConfig = {
23
23
  startAt?: number;
24
24
  range?: [number, number];
25
25
  autoplayOnVisible?: boolean | number;
26
+ muteFallback?: (toggleMute: () => void) => ReactNode;
26
27
  };
27
28
  interface VideoProps extends Omit<ComponentPropsWithoutRef<"video">, "children" | "autoPlay" | "controls"> {
28
29
  children?: VideoChildren;
@@ -71,7 +72,7 @@ declare const useTimeline: () => {
71
72
  setCurrentTime: React.Dispatch<React.SetStateAction<number>>;
72
73
  };
73
74
 
74
- declare const useGetDuration: (url: string) => {
75
+ declare const useGetDuration: (ref: VideoRef) => {
75
76
  duration: number | null;
76
77
  isLoading: boolean;
77
78
  };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use client";function R(e,{insertAt:r}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r==="top"&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}R(`.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}
2
- `);import V from"react";import x from"react";import{jsx as W}from"react/jsx-runtime";var F=x.createContext(void 0),c=()=>{let e=x.useContext(F);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},S=({children:e,ref:r,duration:n,showHidingElement:o,setShowHidingElement:t})=>{let[s,u]=x.useState(!1);return W(F.Provider,{value:{ref:r,duration:n,isFullscreen:s,setIsFullscreen:u,showHidingElement:o,setShowHidingElement:t},children:e})};import J from"react";var I=(e,r)=>{J.useEffect(()=>{if(!e.current||!r)return;(async()=>{var o;try{await((o=e.current)==null?void 0:o.play())}catch(t){if(t instanceof Error&&t.name==="NotAllowedError"){if(console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(s){console.error(s)}}}else console.error(t)}})()},[r,e.current])};import K from"react";var g=(e,r)=>{K.useEffect(()=>{if(!e.current||!r)return;let n=e.current;n&&r&&(n.currentTime=r)},[r])};import Q from"react";var H=(e,r,n)=>{Q.useEffect(()=>{if(!n||!e.current)return;let o=new IntersectionObserver(t=>{t.forEach(s=>{var u;e.current&&(s.isIntersecting?e.current.play().catch(a=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(a))}):(u=e.current)==null||u.pause())})},{threshold:r!=null?r:.5});return o.observe(e.current),()=>{o.disconnect()}},[n,e.current])};import b from"react";var y=(e,r)=>{let[n,o]=b.useState(!1),t=b.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return b.useEffect(()=>{if(!r||!e.current)return;let s=()=>{o(!0)},u=()=>{o(!1)};if(o(!e.current.paused),e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",u),()=>{var a,d;(a=e.current)==null||a.removeEventListener("play",s),(d=e.current)==null||d.removeEventListener("pause",u)}},[e.current,r]),{togglePlay:t,isPlaying:n}};import{jsx as X}from"react/jsx-runtime";var O=()=>{let{ref:e}=c(),{togglePlay:r}=y(e,!0);return X("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:r})};import C from"react";var T=(e,r)=>{let[n,o]=C.useState(!1),t=C.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return C.useEffect(()=>{if(!r||!e.current)return;o(e.current.muted);let s=()=>{e.current&&o(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var u;(u=e.current)==null||u.removeEventListener("volumechange",s)}},[e.current,r]),{toggleMute:t,isMuted:n}};import Y from"react";var L=()=>{let{ref:e,isFullscreen:r,setIsFullscreen:n}=c();Y.useEffect(()=>{let t=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]);let o=()=>{var a;let t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&t){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let u=(a=e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");u&&(r?document.exitFullscreen():u.requestFullscreen())};return{isFullscreen:r!=null?r:!1,toggleFullscreen:o}};import Z from"react";var A=()=>{let{ref:e,isPictureInPicture:r,setIsPictureInPicture:n}=c();Z.useEffect(()=>{let t=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",t),()=>document.removeEventListener("pictureinpicturechange",t)},[]);let o=async()=>{let t=e.current;if(t)try{document.pictureInPictureElement?await document.exitPictureInPicture():await t.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))t.webkitEnterFullscreen?t.webkitEnterFullscreen():t.requestFullscreen&&t.requestFullscreen();else{let a=t.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:r!=null?r:!1,togglePictureInPicture:o}};import N from"react";var z=(e,r)=>{let[n,o]=N.useState(1),t=s=>{o(s)};return N.useEffect(()=>{!r||!e.current||(e.current.playbackRate=n)},[n,r,e.current]),{speed:n,onChangeSpeed:t}};var k=({ref:e,children:r})=>{let{duration:n,showHidingElement:o}=c(),{togglePlay:t,isPlaying:s}=y(e,typeof r=="function"),{speed:u,onChangeSpeed:a}=z(e,typeof r=="function"),{toggleMute:d,isMuted:m}=T(e,typeof r=="function"),{isFullscreen:v,toggleFullscreen:i}=L(),{isPictureInPicture:h,togglePictureInPicture:p}=A();return typeof r!="function"?null:r({isPlaying:s,togglePlay:t,isMuted:m,toggleMute:d,speed:u,onChangeSpeed:a,isFullscreen:v,toggleFullscreen:i,isPictureInPicture:h,togglePictureInPicture:p,duration:n,showHidingElement:o!=null?o:!1})};import _ from"react";import{jsx as ee}from"react/jsx-runtime";var q=_.forwardRef(({children:e,className:r,...n})=>{let{ref:o}=c(),{isPlaying:t}=y(o,!0),{showHidingElement:s,setShowHidingElement:u}=c();return ee("div",{"data-zuude-hiding-element":!0,"data-show":!t||s,className:r,onMouseEnter:()=>{u==null||u(!0)},onMouseLeave:()=>{u==null||u(!1)},...n,children:e})});import{jsx as M,jsxs as re}from"react/jsx-runtime";var $=V.forwardRef(({children:e,autoPlay:r,className:n,ratio:o,config:t,controls:s,pause:u,...a},d)=>{let[m,v]=V.useState(null),i=d||V.useRef(null),[h,p]=V.useState(!1),f=V.useRef(null),D=()=>{var l;(l=i.current)!=null&&l.paused||(p(!0),f.current&&clearTimeout(f.current))},j=()=>{var l;(l=i.current)!=null&&l.paused||(p(!1),f.current&&clearTimeout(f.current))},U=()=>{var l;(l=i.current)!=null&&l.paused||(p(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p(!1)},3e3))};return V.useEffect(()=>{var l,E;u!==void 0&&(u?(l=i.current)==null||l.pause():(E=i.current)==null||E.play())},[u,i.current]),I(i,r==="force"&&a.muted===void 0&&!(t!=null&&t.autoplayOnVisible)),g(i,t==null?void 0:t.startAt),H(i,typeof(t==null?void 0:t.autoplayOnVisible)=="number"?t.autoplayOnVisible:void 0,t==null?void 0:t.autoplayOnVisible),M(S,{ref:i,duration:m,showHidingElement:h,setShowHidingElement:p,children:re("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:o},className:n,children:[M("video",{"data-zuude-video":!0,ref:i,autoPlay:t!=null&&t.autoplayOnVisible?!1:r==="force"?!0:r,playsInline:!0,onMouseEnter:D,onMouseLeave:j,onMouseMove:U,onLoadedMetadata:l=>{v(l.target.duration)},onTimeUpdate:l=>{if(t!=null&&t.range){let[E,G]=t.range;i.current.currentTime<E&&(i.current.currentTime=E),i.current.currentTime>G&&(i.current.currentTime=E)}},...a}),typeof e=="function"?M(k,{ref:i,children:e}):e]})})});$.displayName="Video";var te=Object.assign($,{PlayPauseOnVideo:O,HidingElement:q});import B from"react";var ne=()=>{let[e,r]=B.useState(100),{ref:n}=c(),o=t=>{r(t)};return B.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:o}};import P from"react";var oe=()=>{let[e,r]=P.useState(!1),[n,o]=P.useState(0),[t,s]=P.useState(0),{ref:u,duration:a}=c();return P.useEffect(()=>{if(u.current&&e){let d=setInterval(()=>{var m,v;o(((m=u.current)==null?void 0:m.currentTime)||0),(v=u.current)!=null&&v.buffered.length&&s(u.current.buffered.end(u.current.buffered.length-1))},10);return()=>clearInterval(d)}},[u.current,e]),P.useEffect(()=>{if(u.current)return u.current.addEventListener("play",()=>r(!0)),u.current.addEventListener("pause",()=>r(!1)),()=>{var d,m;(d=u.current)==null||d.removeEventListener("play",()=>r(!0)),(m=u.current)==null||m.removeEventListener("pause",()=>r(!1))}},[]),{currentTime:n,duration:a,buffered:t,setCurrentTime:o}};import w from"react";var ue=e=>{let[r,n]=w.useState(!1),[o,t]=w.useState(null),{ref:s}=c();return w.useEffect(()=>{if(!s.current)return;n(!0);let u=document.createElement("video");return u.src=e,u.muted=!0,u.addEventListener("loadedmetadata",()=>{t(u.duration),n(!1)}),u.addEventListener("error",()=>{n(!1)}),()=>{u.remove()}},[e]),{duration:o,isLoading:r}};function se(e,r="mm:ss"){let n=Math.floor(e/60),o=Math.floor(e%60);return r==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${o<10?"0":""}${o}`:`${n}:${o<10?"0":""}${o}`}export{te as Video,se as formatTime,L as useFullscreen,ue as useGetDuration,T as useMuteUnmute,y as usePlayPause,g as useStartAt,oe as useTimeline,c as useVideo,ne as useVolume};
1
+ "use client";function x(e,{insertAt:r}={}){if(!e||typeof document=="undefined")return;let n=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.type="text/css",r==="top"&&n.firstChild?n.insertBefore(u,n.firstChild):n.appendChild(u),u.styleSheet?u.styleSheet.cssText=e:u.appendChild(document.createTextNode(e))}x(`.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}
2
+ `);import y from"react";import b from"react";import{jsx as K}from"react/jsx-runtime";var S=b.createContext(void 0),c=()=>{let e=b.useContext(S);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},I=({children:e,ref:r,duration:n,showHidingElement:u,setShowHidingElement:t})=>{let[s,o]=b.useState(!1);return K(S.Provider,{value:{ref:r,duration:n,isFullscreen:s,setIsFullscreen:o,showHidingElement:u,setShowHidingElement:t},children:e})};import Q from"react";var H=(e,r,n)=>{Q.useEffect(()=>{if(!e.current||!r)return;(async()=>{var t;try{await((t=e.current)==null?void 0:t.play())}catch(s){if(s instanceof Error&&s.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),e.current){e.current.muted=!0;try{await e.current.play()}catch(o){console.error(o)}}}else console.error(s)}})()},[r,e.current])};import X from"react";var g=(e,r)=>{X.useEffect(()=>{if(!e.current||!r)return;let n=e.current;n&&r&&(n.currentTime=r)},[r])};import Y from"react";var O=(e,r,n)=>{Y.useEffect(()=>{if(!n||!e.current)return;let u=new IntersectionObserver(t=>{t.forEach(s=>{var o;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:r!=null?r:.5});return u.observe(e.current),()=>{u.disconnect()}},[n,e.current])};import C from"react";var f=(e,r)=>{let[n,u]=C.useState(!1),t=C.useCallback(()=>{e.current&&(e.current.paused?e.current.play():e.current.pause())},[e.current]);return C.useEffect(()=>{if(!r||!e.current)return;let s=()=>{u(!0)},o=()=>{u(!1)};if(u(!e.current.paused),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.current,r]),{togglePlay:t,isPlaying:n}};import{jsx as Z}from"react/jsx-runtime";var A=()=>{let{ref:e}=c(),{togglePlay:r}=f(e,!0);return Z("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:r})};import T from"react";var L=(e,r)=>{let[n,u]=T.useState(!1),t=T.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e.current]);return T.useEffect(()=>{if(!r||!e.current)return;u(e.current.muted);let s=()=>{e.current&&u(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var o;(o=e.current)==null||o.removeEventListener("volumechange",s)}},[e.current,r]),{toggleMute:t,isMuted:n}};import _ from"react";var w=()=>{let{ref:e,isFullscreen:r,setIsFullscreen:n}=c();_.useEffect(()=>{let t=()=>{n==null||n(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]);let u=()=>{var a;let t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e.current;if(s&&t){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let o=(a=e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");o&&(r?document.exitFullscreen():o.requestFullscreen())};return{isFullscreen:r!=null?r:!1,toggleFullscreen:u}};import ee from"react";var N=()=>{let{ref:e,isPictureInPicture:r,setIsPictureInPicture:n}=c();ee.useEffect(()=>{let t=()=>{n==null||n(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",t),()=>document.removeEventListener("pictureinpicturechange",t)},[]);let u=async()=>{let t=e.current;if(t)try{document.pictureInPictureElement?await document.exitPictureInPicture():await t.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))t.webkitEnterFullscreen?t.webkitEnterFullscreen():t.requestFullscreen&&t.requestFullscreen();else{let a=t.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:r!=null?r:!1,togglePictureInPicture:u}};import k from"react";var z=(e,r)=>{let[n,u]=k.useState(1),t=s=>{u(s)};return k.useEffect(()=>{!r||!e.current||(e.current.playbackRate=n)},[n,r,e.current]),{speed:n,onChangeSpeed:t}};var q=({ref:e,children:r})=>{let{duration:n,showHidingElement:u}=c(),{togglePlay:t,isPlaying:s}=f(e,typeof r=="function"),{speed:o,onChangeSpeed:a}=z(e,typeof r=="function"),{toggleMute:d,isMuted:m}=L(e,typeof r=="function"),{isFullscreen:v,toggleFullscreen:R}=w(),{isPictureInPicture:h,togglePictureInPicture:i}=N();return typeof r!="function"?null:r({isPlaying:s,togglePlay:t,isMuted:m,toggleMute:d,speed:o,onChangeSpeed:a,isFullscreen:v,toggleFullscreen:R,isPictureInPicture:h,togglePictureInPicture:i,duration:n,showHidingElement:u!=null?u:!1})};import te from"react";import{jsx as re}from"react/jsx-runtime";var $=te.forwardRef(({children:e,className:r,...n})=>{let{ref:u}=c(),{isPlaying:t}=f(u,!0),{showHidingElement:s,setShowHidingElement:o}=c();return re("div",{"data-zuude-hiding-element":!0,"data-show":!t||s,className:r,onMouseEnter:()=>{o==null||o(!0)},onMouseLeave:()=>{o==null||o(!1)},...n,children:e})});import{jsx as M,jsxs as oe}from"react/jsx-runtime";var B=y.forwardRef(({children:e,autoPlay:r,className:n,ratio:u,config:t,controls:s,pause:o,...a},d)=>{let[m,v]=y.useState(null),[R,h]=y.useState(null),i=d||y.useRef(null),[j,V]=y.useState(!1),p=y.useRef(null),U=()=>{var l;(l=i.current)!=null&&l.paused||(V(!0),p.current&&clearTimeout(p.current))},G=()=>{var l;(l=i.current)!=null&&l.paused||(V(!1),p.current&&clearTimeout(p.current))},W=()=>{var l;(l=i.current)!=null&&l.paused||(V(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{V(!1)},3e3))};return y.useEffect(()=>{var l,E;o!==void 0&&(o?(l=i.current)==null||l.pause():(E=i.current)==null||E.play())},[o,i.current]),H(i,r==="force"&&a.muted===void 0&&!(t!=null&&t.autoplayOnVisible),h),g(i,t==null?void 0:t.startAt),O(i,typeof(t==null?void 0:t.autoplayOnVisible)=="number"?t.autoplayOnVisible:void 0,t==null?void 0:t.autoplayOnVisible),M(I,{ref:i,duration:m,showHidingElement:j,setShowHidingElement:V,children:oe("div",{"data-zuude-video-wrapper":!0,style:{aspectRatio:u},className:n,children:[M("video",{"data-zuude-video":!0,ref:i,autoPlay:t!=null&&t.autoplayOnVisible?!1:r==="force"?!0:r,playsInline:!0,onMouseEnter:U,onMouseLeave:G,onMouseMove:W,onLoadedMetadata:l=>{console.log("loaded metadata"),v(l.target.duration)},onTimeUpdate:l=>{if(t!=null&&t.range){let[E,J]=t.range;i.current.currentTime<E&&(i.current.currentTime=E),i.current.currentTime>J&&(i.current.currentTime=E)}},...a}),typeof e=="function"?M(q,{ref:i,children:e}):e,R==="NotAllowedError"&&typeof(t==null?void 0:t.muteFallback)=="function"&&t.muteFallback(()=>{i.current&&(i.current.muted=!i.current.muted),h(null)})]})})});B.displayName="Video";var ne=Object.assign(B,{PlayPauseOnVideo:A,HidingElement:$});import D from"react";var ue=()=>{let[e,r]=D.useState(100),{ref:n}=c(),u=t=>{r(t)};return D.useEffect(()=>{n.current&&(n.current.volume=e/100)},[e]),{volume:e,onChangeVolume:u}};import P from"react";var se=()=>{let[e,r]=P.useState(!1),[n,u]=P.useState(0),[t,s]=P.useState(0),{ref:o,duration:a}=c();return P.useEffect(()=>{if(o.current&&e){let d=setInterval(()=>{var m,v;u(((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.current,e]),P.useEffect(()=>{if(o.current)return o.current.addEventListener("play",()=>r(!0)),o.current.addEventListener("pause",()=>r(!1)),()=>{var d,m;(d=o.current)==null||d.removeEventListener("play",()=>r(!0)),(m=o.current)==null||m.removeEventListener("pause",()=>r(!1))}},[]),{currentTime:n,duration:a,buffered:t,setCurrentTime:u}};import F from"react";var ie=e=>{let[r,n]=F.useState(!1),[u,t]=F.useState(null);return F.useEffect(()=>{if(e.current)return n(!0),e.current.addEventListener("loadedmetadata",()=>{var s,o;t((o=(s=e.current)==null?void 0:s.duration)!=null?o:null),n(!1)}),e.current.addEventListener("error",()=>{n(!1)}),()=>{var s,o;(s=e.current)==null||s.removeEventListener("loadedmetadata",()=>{}),(o=e.current)==null||o.removeEventListener("error",()=>{})}},[e.current]),{duration:u,isLoading:r}};function ae(e,r="mm:ss"){let n=Math.floor(e/60),u=Math.floor(e%60);return r==="h:mm:ss"?`${Math.floor(n/60)}:${n}:${u<10?"0":""}${u}`:`${n}:${u<10?"0":""}${u}`}export{ne as Video,ae as formatTime,w as useFullscreen,ie as useGetDuration,L as useMuteUnmute,f as usePlayPause,g as useStartAt,se as useTimeline,c as useVideo,ue as useVolume};
3
3
  //# 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-autoplay-by-force.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/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/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 } 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, ratio, config, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const videoRef =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(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 );\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 ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\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 onLoadedMetadata={(e) => {\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.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\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 ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\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 { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (ref: VideoRef, enabled: boolean) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, ref.current]);\n};\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]);\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 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 { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, 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\";\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 { ref, 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 = ref.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 = ref.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 { ref, 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 = ref.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 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\";\n\nimport type { VideoChildren } 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 = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\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,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\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 { 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 { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, 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 { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\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 { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.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 { useVideo } from \"../context\";\n\nexport const useGetDuration = (url: string) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n const { ref } = useVideo();\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n setIsLoading(true);\n\n const video = document.createElement(\"video\");\n\n video.src = url;\n video.muted = true;\n\n video.addEventListener(\"loadedmetadata\", () => {\n setDuration(video.duration);\n setIsLoading(false);\n });\n\n video.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n video.remove();\n };\n }, [url]);\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":"aACyB,SAARA,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,CAACD,GAAO,OAAO,UAAa,YAAa,OAE7C,IAAME,EAAO,SAAS,MAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC,EAC/DC,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,KAAO,WAETF,IAAa,OACXC,EAAK,WACPA,EAAK,aAAaC,EAAOD,EAAK,UAAU,EAK1CA,EAAK,YAAYC,CAAK,EAGpBA,EAAM,WACRA,EAAM,WAAW,QAAUH,EAE3BG,EAAM,YAAY,SAAS,eAAeH,CAAG,CAAC,CAElD,CCvB8BI,EAAY;AAAA,CAA8L,ECAlP,OAAOC,MAAW,QCAlB,OAAOC,MAAW,QA6Bd,cAAAC,MAAA,oBA1BJ,IAAMC,EAAeF,EAAM,cACzB,MACF,EAEMG,EAAW,IAAM,CACrB,IAAMC,EAAUJ,EAAM,WAAWE,CAAY,EAC7C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,EAMMC,EAAgB,CAAC,CACrB,SAAAC,EACA,IAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,qBAAAC,CACF,IAA0B,CACxB,GAAM,CAACC,EAAYC,CAAa,EAAIZ,EAAM,SAAS,EAAK,EAExD,OACEC,EAACC,EAAa,SAAb,CACC,MAAO,CACL,IAAAK,EACA,SAAAC,EACA,aAAcG,EACd,gBAAiBC,EACjB,kBAAAH,EACA,qBAAAC,CACF,EAEC,SAAAJ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AK,EAAa,oBAAoB,QAAS,IAAMX,EAAa,EAAK,EACpE,CACF,EAAG,CAAC,CAAC,EAEE,CACL,YAAAE,EACA,SAAAK,EACA,SAAAH,EACA,eAAAD,CACF,CACF,EC5CA,OAAOS,MAAW,QAGX,IAAMC,GAAkBC,GAAgB,CAC7C,GAAM,CAACC,EAAWC,CAAY,EAAIC,EAAM,SAAS,EAAK,EAChD,CAACC,EAAUC,CAAW,EAAIF,EAAM,SAAwB,IAAI,EAE5D,CAAE,IAAAG,CAAI,EAAIC,EAAS,EAEzB,OAAAJ,EAAM,UAAU,IAAM,CACpB,GAAI,CAACG,EAAI,QAAS,OAElBJ,EAAa,EAAI,EAEjB,IAAMM,EAAQ,SAAS,cAAc,OAAO,EAE5C,OAAAA,EAAM,IAAMR,EACZQ,EAAM,MAAQ,GAEdA,EAAM,iBAAiB,iBAAkB,IAAM,CAC7CH,EAAYG,EAAM,QAAQ,EAC1BN,EAAa,EAAK,CACpB,CAAC,EAEDM,EAAM,iBAAiB,QAAS,IAAM,CACpCN,EAAa,EAAK,CACpB,CAAC,EAEM,IAAM,CACXM,EAAM,OAAO,CACf,CACF,EAAG,CAACR,CAAG,CAAC,EAED,CAAE,SAAAI,EAAU,UAAAH,CAAU,CAC/B,EClCA,SAASQ,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","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","React","useAutoplayByForce","ref","enabled","_a","error","retryError","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","ref","useVideo","togglePlay","usePlayPause","React","useMuteUnmute","ref","enabled","isMuted","setIsMuted","toggleMute","handleVolumeChange","_a","React","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","React","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","React","useSpeed","ref","enabled","speed","setSpeed","onChangeSpeed","FunctionChildren","ref","children","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","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","jsx","jsxs","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","React","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","React","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","React","useGetDuration","url","isLoading","setIsLoading","React","duration","setDuration","ref","useVideo","video","formatTime","time","type","minutes","seconds"]}
1
+ {"version":3,"sources":["#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.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/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/function-children.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 } 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, ratio, config, 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 =\n (ref as React.RefObject<HTMLVideoElement>) ||\n React.useRef<HTMLVideoElement>(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 ref={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n style={{\n aspectRatio: ratio,\n }}\n className={className}\n >\n <video\n data-zuude-video\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 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.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\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 ref,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n ref,\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 { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (\n ref: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!ref.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (ref.current) {\n ref.current.muted = true;\n try {\n await ref.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, ref.current]);\n};\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]);\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 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 { ref } = useVideo();\n\n const { togglePlay } = usePlayPause(ref, 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\";\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 { ref, 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 = ref.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 = ref.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 { ref, 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 = ref.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 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\";\n\nimport type { VideoChildren } 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 = ({\n ref,\n children,\n}: {\n ref: React.RefObject<HTMLVideoElement>;\n children: VideoChildren;\n}) => {\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,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref,\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 { 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 { ref } = useVideo();\n const { isPlaying } = usePlayPause(ref, 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 { ref } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.volume = volume / 100;\n }, [volume]);\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 { ref, duration } = useVideo();\n\n React.useEffect(() => {\n if (ref.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(ref.current?.currentTime || 0);\n\n if (ref.current?.buffered.length) {\n setBuffered(\n ref.current.buffered.end(ref.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [ref.current, isPlaying]);\n\n React.useEffect(() => {\n if (!ref.current) return;\n\n ref.current.addEventListener(\"play\", () => setIsPlaying(true));\n ref.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n ref.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n ref.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":"aACyB,SAARA,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,CAACD,GAAO,OAAO,UAAa,YAAa,OAE7C,IAAME,EAAO,SAAS,MAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC,EAC/DC,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,KAAO,WAETF,IAAa,OACXC,EAAK,WACPA,EAAK,aAAaC,EAAOD,EAAK,UAAU,EAK1CA,EAAK,YAAYC,CAAK,EAGpBA,EAAM,WACRA,EAAM,WAAW,QAAUH,EAE3BG,EAAM,YAAY,SAAS,eAAeH,CAAG,CAAC,CAElD,CCvB8BI,EAAY;AAAA,CAA8L,ECAlP,OAAOC,MAAW,QCAlB,OAAOC,MAAW,QA6Bd,cAAAC,MAAA,oBA1BJ,IAAMC,EAAeF,EAAM,cACzB,MACF,EAEMG,EAAW,IAAM,CACrB,IAAMC,EAAUJ,EAAM,WAAWE,CAAY,EAC7C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,EAMMC,EAAgB,CAAC,CACrB,SAAAC,EACA,IAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,qBAAAC,CACF,IAA0B,CACxB,GAAM,CAACC,EAAYC,CAAa,EAAIZ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B,QAAS,IAAM,CAAC,EACnD,CACF,EAAG,CAACN,EAAI,OAAO,CAAC,EAET,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","ref","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","React","useAutoplayByForce","ref","enabled","setError","_a","error","retryError","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","ref","useVideo","togglePlay","usePlayPause","React","useMuteUnmute","ref","enabled","isMuted","setIsMuted","toggleMute","handleVolumeChange","_a","React","useFullscreen","ref","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","React","usePictureInPicture","ref","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","React","useSpeed","ref","enabled","speed","setSpeed","onChangeSpeed","FunctionChildren","ref","children","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","ref","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","jsx","jsxs","VideoComponent","React","children","autoPlay","className","ratio","config","controls","pause","props","ref","duration","setDuration","error","setError","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","React","useVolume","volume","setVolume","React","ref","useVideo","onChangeVolume","React","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","ref","duration","useVideo","intervalId","_a","_b","React","useGetDuration","ref","isLoading","setIsLoading","duration","setDuration","_a","_b","formatTime","time","type","minutes","seconds"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.5",
6
+ "version": "0.0.6",
7
7
  "main": "./dist/index.js",
8
8
  "module": "./dist/index.mjs",
9
9
  "types": "./dist/index.d.ts",