@zuude-ui/video 0.1.3 → 0.1.4
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/new/index.cjs +1 -1
- package/dist/new/index.cjs.map +1 -1
- package/dist/new/index.d.cts +18 -1
- package/dist/new/index.d.ts +18 -1
- package/dist/new/index.js +1 -1
- package/dist/new/index.js.map +1 -1
- package/package.json +15 -3
package/dist/new/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var S=Object.create;var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var n in r)h(e,n,{get:r[n],enumerable:!0})},v=(e,r,n,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of j(r))!q.call(e,t)&&t!==n&&h(e,t,{get:()=>r[t],enumerable:!(c=O(r,t))||c.enumerable});return e};var g=(e,r,n)=>(n=e!=null?S(R(e)):{},v(r||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),z=e=>v(h({},"__esModule",{value:!0}),e);var _={};B(_,{Controls:()=>U,ExitFullscreen:()=>Y,Fullscreen:()=>X,Loading:()=>Z,Mute:()=>J,Pause:()=>G,Play:()=>D,SeekBackward:()=>W,SeekForward:()=>Q,Unmute:()=>K,Video:()=>b,VideoProvider:()=>T,useFullscreen:()=>y,useVideoState:()=>I});module.exports=z(_);var d=require("react"),k=require("react/jsx-runtime"),w=(0,d.createContext)(void 0),T=({children:e,config:r,onError:n,...c})=>{let[t,o]=(0,d.useState)(null),[s,l]=(0,d.useState)(null);return(0,d.useEffect)(()=>{n==null||n(s)},[s]),(0,k.jsx)(w.Provider,{value:{videoRef:t,setVideoRef:o,config:{clickToPlay:!0,...r},error:s,setError:l},children:(0,k.jsx)("div",{"data-zuude-video-wrapper":!0,...c,children:e})})},u=()=>{let e=(0,d.useContext)(w);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e};var f=require("react");var M=g(require("react"),1),A=(e,r,n)=>{M.default.useEffect(()=>{if(!(e!=null&&e.current)||!r)return;(async()=>{var t;try{await((t=e.current)==null?void 0:t.play())}catch(o){if(o instanceof Error&&o.name==="NotAllowedError"){if(n==null||n("NotAllowedError"),console.error("NotAllowedError"),e!=null&&e.current){e.current.muted=!0;try{await e.current.play()}catch(s){console.error(s)}}}else console.error(o)}})()},[r,e==null?void 0:e.current])};var E=require("react/jsx-runtime"),b=(0,f.forwardRef)(({src:e,autoPlay:r,muteFallback:n,...c},t)=>{let{videoRef:o,setVideoRef:s,config:l,setError:C,error:N}=u(),x=(0,f.useRef)(null);(0,f.useEffect)(()=>{let V=x.current,P=t;P?s(P):V&&s({current:V})},[e]),A(o,r==="force"&&c.muted===void 0,C);let H=()=>{var V,P,L;(V=o==null?void 0:o.current)!=null&&V.paused?(P=o.current)==null||P.play():(L=o==null?void 0:o.current)==null||L.pause()};return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("video",{ref:t||x,src:e,onClick:l!=null&&l.clickToPlay?H:void 0,autoPlay:r==="force"?!0:r,...c}),N==="NotAllowedError"&&typeof n=="function"&&n(()=>{o!=null&&o.current&&(o.current.muted=!o.current.muted),C(null)})]})});b.displayName="Video";var a=g(require("react"),1),m=require("@radix-ui/react-slot");var p=require("react"),F=g(require("react"),1),I=e=>{let[r,n]=(0,p.useState)(!1),[c,t]=(0,p.useState)(!1),[o,s]=(0,p.useState)(!1);return(0,p.useEffect)(()=>{let l=e.current;if(l)return l.addEventListener("play",()=>n(!0)),l.addEventListener("pause",()=>n(!1)),()=>{l.removeEventListener("play",()=>n(!0)),l.removeEventListener("pause",()=>n(!1))}},[e]),(0,p.useEffect)(()=>{if(!(e!=null&&e.current))return;t(e.current.muted);let l=()=>{e.current&&t(e.current.muted)};return e.current.addEventListener("volumechange",l),()=>{var C;(C=e.current)==null||C.removeEventListener("volumechange",l)}},[e]),(0,p.useEffect)(()=>{if(!(e!=null&&e.current))return;let l=()=>{s(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[e]),{isPlaying:r,isMuted:c,isFullscreen:o}},y=e=>{let[r,n]=F.default.useState(!1);F.default.useEffect(()=>{let t=()=>{n==null||n(!!document.fullscreenElement),c()};return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[r]);let c=()=>{console.log("toggleFullscreen");let t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),o=e;if(o&&t){if(o.webkitEnterFullscreen){o.webkitEnterFullscreen();return}else if(o.requestFullscreen){o.requestFullscreen();return}}let s=o==null?void 0:o.closest("[data-zuude-video-wrapper]");s&&(r?(document.exitFullscreen(),o&&(o.style.objectFit="cover")):(s.requestFullscreen(),o&&(o.style.objectFit="contain")))};return{isFullscreen:r!=null?r:!1,toggleFullscreen:c}};var i=require("react/jsx-runtime"),U=a.default.memo(({children:e,asChild:r,...n})=>(0,i.jsx)("div",{...n,children:e})),D=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{var s,l;(s=t==null?void 0:t.current)!=null&&s.paused&&((l=t.current)==null||l.play())},children:e})}),G=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{var s;t!=null&&t.current&&((s=t.current)==null||s.pause())},children:e})}),J=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{t!=null&&t.current&&(t.current.muted=!0)},children:e})}),K=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{t!=null&&t.current&&(t.current.muted=!1)},children:e})}),Q=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{t!=null&&t.current&&(t.current.currentTime+=10)},children:e})}),W=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u();return(0,i.jsx)(c,{...n,onClick:()=>{t!=null&&t.current&&(t.current.currentTime-=10)},children:e})}),X=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u(),{toggleFullscreen:o}=y(t==null?void 0:t.current);return(0,i.jsx)(c,{...n,onClick:o,children:e})}),Y=a.default.memo(({children:e,asChild:r,...n})=>{let c=r?m.Slot:"button",{videoRef:t}=u(),{toggleFullscreen:o}=y(t==null?void 0:t.current);return(0,i.jsx)(c,{...n,onClick:o,children:e})}),Z=()=>(0,i.jsx)("div",{children:"Loading"});0&&(module.exports={Controls,ExitFullscreen,Fullscreen,Loading,Mute,Pause,Play,SeekBackward,SeekForward,Unmute,Video,VideoProvider,useFullscreen,useVideoState});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/new/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/new/index.ts","../../src/new/wrapper.tsx","../../src/new/video.tsx","../../src/hooks/use-autoplay-by-force.tsx","../../src/new/components.tsx","../../src/new/hook.tsx"],"sourcesContent":["\"use client\";\n\nexport { VideoProvider } from \"./wrapper\";\nexport { Video } from \"./video\";\nexport * from \"./components\";\nexport * from \"./hook\";\n","import {\n createContext,\n RefObject,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef | null;\n setVideoRef: (video: VideoRef | null) => void;\n error: string | null;\n setError: (error: string | null) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | undefined>(\n undefined\n);\n\ntype VideoProviderProps = React.ComponentProps<\"div\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = ({\n children,\n config,\n onError,\n ...props\n}: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n }}\n >\n <div {...props}>{children}</div>\n </VideoContext.Provider>\n );\n};\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, { forwardRef, RefObject, useEffect, useRef } from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"../hooks/use-autoplay-by-force\";\n\ninterface Props extends Omit<React.ComponentProps<\"video\">, \"autoPlay\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n muteFallback?: (onMute: () => void) => React.ReactNode;\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n ({ src, autoPlay, muteFallback, ...props }, ref) => {\n const { videoRef, setVideoRef, config, setError, error } = useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n }, [src]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n const onPlay = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n };\n\n return (\n <>\n <video\n ref={ref || refVideo}\n src={src}\n {...props}\n onClick={config?.clickToPlay ? onPlay : undefined}\n />\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (\n ref: VideoRef | null,\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\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current?.pause();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Loading = () => {\n return <div>Loading</div>;\n};\n\nexport { Play, Pause, Loading };\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n return { isPlaying };\n};\n\nexport { useVideoState };\n"],"mappings":"ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,UAAAC,EAAA,SAAAC,EAAA,UAAAC,EAAA,kBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAR,GCAA,IAAAS,EAMO,iBAkDDC,EAAA,6BAlCOC,KAAe,iBAC1B,MACF,EAQaC,EAAgB,CAAC,CAC5B,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,GAAGC,CACL,IAA0B,CACxB,GAAM,CAACC,EAAUC,CAAW,KAAI,YAA0B,IAAI,EACxD,CAACC,EAAOC,CAAQ,KAAI,YAAwB,IAAI,EAGtD,sBAAU,IAAM,CACdL,GAAA,MAAAA,EAAUI,EACZ,EAAG,CAACA,CAAK,CAAC,KAGR,OAACR,EAAa,SAAb,CACC,MAAO,CACL,SAAAM,EACA,YAAAC,EACA,OAAQ,CAAE,YAAa,GAAM,GAAGJ,CAAO,EACvC,MAAAK,EACA,SAAAC,CACF,EAEA,mBAAC,OAAK,GAAGJ,EAAQ,SAAAH,EAAS,EAC5B,CAEJ,EAEaQ,EAAW,IAAM,CAC5B,IAAMC,KAAU,cAAWX,CAAY,EACvC,GAAI,CAACW,EACH,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,ECnEA,IAAAC,EAAgE,iBCAhE,IAAAC,EAAkB,sBAGLC,EAAqB,CAChCC,EACAC,EACAC,IACG,CACH,EAAAC,QAAM,UAAU,IAAM,CACpB,GAAI,EAACH,GAAA,MAAAA,EAAK,UAAW,CAACC,EAAS,QAEb,SAAY,CA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AAMD,EAAa,EAAI,CAAC,EACvDC,EAAM,iBAAiB,QAAS,IAAMD,EAAa,EAAK,CAAC,EAElD,IAAM,CACXC,EAAM,oBAAoB,OAAQ,IAAMD,EAAa,EAAI,CAAC,EAC1DC,EAAM,oBAAoB,QAAS,IAAMD,EAAa,EAAK,CAAC,CAC9D,CAEJ,EAAG,CAACF,CAAQ,CAAC,EAEN,CAAE,UAAAC,CAAU,CACrB","names":["new_exports","__export","Loading","Pause","Play","Video","VideoProvider","useVideoState","__toCommonJS","import_react","import_jsx_runtime","VideoContext","VideoProvider","children","config","onError","props","videoRef","setVideoRef","error","setError","useVideo","context","import_react","import_react","useAutoplayByForce","ref","enabled","setError","React","_a","error","retryError","import_jsx_runtime","Video","src","autoPlay","muteFallback","props","ref","videoRef","setVideoRef","config","setError","error","useVideo","refVideo","video","thirdPartyRef","useAutoplayByForce","onPlay","_a","_b","_c","import_react","import_react_slot","import_jsx_runtime","Play","React","children","asChild","props","Element","videoRef","useVideo","_a","_b","Pause","Loading","import_react","useVideoState","videoRef","isPlaying","setIsPlaying","video"]}
|
|
1
|
+
{"version":3,"sources":["../../src/new/index.ts","../../src/new/wrapper.tsx","../../src/new/video.tsx","../../src/hooks/use-autoplay-by-force.tsx","../../src/new/components.tsx","../../src/new/hook.tsx"],"sourcesContent":["\"use client\";\n\nexport { VideoProvider } from \"./wrapper\";\nexport { Video } from \"./video\";\nexport * from \"./components\";\nexport * from \"./hook\";\n","import {\n createContext,\n RefObject,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef | null;\n setVideoRef: (video: VideoRef | null) => void;\n error: string | null;\n setError: (error: string | null) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | undefined>(\n undefined\n);\n\ntype VideoProviderProps = React.ComponentProps<\"div\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = ({\n children,\n config,\n onError,\n ...props\n}: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n }}\n >\n <div data-zuude-video-wrapper {...props}>\n {children}\n </div>\n </VideoContext.Provider>\n );\n};\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, { forwardRef, RefObject, useEffect, useRef } from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"../hooks/use-autoplay-by-force\";\n\ninterface Props extends Omit<React.ComponentProps<\"video\">, \"autoPlay\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n muteFallback?: (onMute: () => void) => React.ReactNode;\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n ({ src, autoPlay, muteFallback, ...props }, ref) => {\n const { videoRef, setVideoRef, config, setError, error } = useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n }, [src]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n const onPlay = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n };\n\n return (\n <>\n <video\n ref={ref || refVideo}\n src={src}\n onClick={config?.clickToPlay ? onPlay : undefined}\n autoPlay={autoPlay === \"force\" ? true : autoPlay}\n {...props}\n />\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (\n ref: VideoRef | null,\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\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\nimport { useFullscreen } from \"./hook\";\n\ninterface ControlsProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Controls = React.memo(\n ({ children, asChild, ...props }: ControlsProps) => {\n return <div {...props}>{children}</div>;\n }\n);\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current?.pause();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Mute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Unmute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst SeekForward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.currentTime += 10;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst SeekBackward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= 10;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Fullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(\n videoRef?.current as HTMLVideoElement | null\n );\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst ExitFullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(\n videoRef?.current as HTMLVideoElement | null\n );\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst Loading = () => {\n return <div>Loading</div>;\n};\n\nexport {\n Controls,\n Play,\n Pause,\n Mute,\n Unmute,\n SeekForward,\n SeekBackward,\n Fullscreen,\n ExitFullscreen,\n Loading,\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nimport React from \"react\";\n\nconst useFullscreen = (videoRef: HTMLVideoElement | null) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n toggleFullscreen();\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [isFullscreen]);\n\n const toggleFullscreen = () => {\n console.log(\"toggleFullscreen\");\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef;\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 = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n if (video) {\n video.style.objectFit = \"contain\";\n }\n } else {\n document.exitFullscreen();\n if (video) {\n video.style.objectFit = \"cover\";\n }\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useVideoState, useFullscreen };\n"],"mappings":"ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,mBAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,SAAAC,EAAA,UAAAC,EAAA,SAAAC,EAAA,iBAAAC,EAAA,gBAAAC,EAAA,WAAAC,EAAA,UAAAC,EAAA,kBAAAC,EAAA,kBAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAhB,GCAA,IAAAiB,EAMO,iBAkDDC,EAAA,6BAlCOC,KAAe,iBAC1B,MACF,EAQaC,EAAgB,CAAC,CAC5B,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,GAAGC,CACL,IAA0B,CACxB,GAAM,CAACC,EAAUC,CAAW,KAAI,YAA0B,IAAI,EACxD,CAACC,EAAOC,CAAQ,KAAI,YAAwB,IAAI,EAGtD,sBAAU,IAAM,CACdL,GAAA,MAAAA,EAAUI,EACZ,EAAG,CAACA,CAAK,CAAC,KAGR,OAACR,EAAa,SAAb,CACC,MAAO,CACL,SAAAM,EACA,YAAAC,EACA,OAAQ,CAAE,YAAa,GAAM,GAAGJ,CAAO,EACvC,MAAAK,EACA,SAAAC,CACF,EAEA,mBAAC,OAAI,2BAAwB,GAAE,GAAGJ,EAC/B,SAAAH,EACH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AAiB,EAAIC,EAC3BX,GAAA,YAAAA,EAAU,OACZ,EAEA,SACE,OAACD,EAAA,CAAS,GAAGF,EAAO,QAASa,EAC1B,SAAAf,EACH,CAEJ,CAAC,EAEKiB,EAAiB,EAAAlB,QAAM,KAAK,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAM,IAAa,CAC5E,IAAME,EAAUH,EAAU,OAAO,SAC3B,CAAE,SAAAI,CAAS,EAAIC,EAAS,EAExB,CAAE,iBAAAS,CAAiB,EAAIC,EAC3BX,GAAA,YAAAA,EAAU,OACZ,EAEA,SACE,OAACD,EAAA,CAAS,GAAGF,EAAO,QAASa,EAC1B,SAAAf,EACH,CAEJ,CAAC,EAEKkB,EAAU,OACP,OAAC,OAAI,mBAAO","names":["new_exports","__export","Controls","ExitFullscreen","Fullscreen","Loading","Mute","Pause","Play","SeekBackward","SeekForward","Unmute","Video","VideoProvider","useFullscreen","useVideoState","__toCommonJS","import_react","import_jsx_runtime","VideoContext","VideoProvider","children","config","onError","props","videoRef","setVideoRef","error","setError","useVideo","context","import_react","import_react","useAutoplayByForce","ref","enabled","setError","React","_a","error","retryError","import_jsx_runtime","Video","src","autoPlay","muteFallback","props","ref","videoRef","setVideoRef","config","setError","error","useVideo","refVideo","video","thirdPartyRef","useAutoplayByForce","onPlay","_a","_b","_c","import_react","import_react_slot","import_react","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","useFullscreen","React","toggleFullscreen","isSafari","videoContainer","import_jsx_runtime","Controls","React","children","asChild","props","Play","Element","videoRef","useVideo","_a","_b","Pause","Mute","Unmute","SeekForward","SeekBackward","Fullscreen","toggleFullscreen","useFullscreen","ExitFullscreen","Loading"]}
|
package/dist/new/index.d.cts
CHANGED
|
@@ -21,16 +21,33 @@ interface Props$1 extends Omit<React$1.ComponentProps<"video">, "autoPlay"> {
|
|
|
21
21
|
}
|
|
22
22
|
declare const Video: React$1.ForwardRefExoticComponent<Omit<Props$1, "ref"> & React$1.RefAttributes<HTMLVideoElement>>;
|
|
23
23
|
|
|
24
|
+
interface ControlsProps extends React$1.ComponentProps<"div"> {
|
|
25
|
+
children: React$1.ReactNode;
|
|
26
|
+
asChild?: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare const Controls: React$1.MemoExoticComponent<({ children, asChild, ...props }: ControlsProps) => react_jsx_runtime.JSX.Element>;
|
|
24
29
|
interface Props extends React$1.ComponentProps<"button"> {
|
|
25
30
|
children: React$1.ReactNode;
|
|
26
31
|
asChild?: boolean;
|
|
27
32
|
}
|
|
28
33
|
declare const Play: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
29
34
|
declare const Pause: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
35
|
+
declare const Mute: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
36
|
+
declare const Unmute: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
37
|
+
declare const SeekForward: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
38
|
+
declare const SeekBackward: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
39
|
+
declare const Fullscreen: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
40
|
+
declare const ExitFullscreen: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
30
41
|
declare const Loading: () => react_jsx_runtime.JSX.Element;
|
|
31
42
|
|
|
32
43
|
declare const useVideoState: (videoRef: RefObject<HTMLVideoElement | null>) => {
|
|
33
44
|
isPlaying: boolean;
|
|
45
|
+
isMuted: boolean;
|
|
46
|
+
isFullscreen: boolean;
|
|
47
|
+
};
|
|
48
|
+
declare const useFullscreen: (videoRef: HTMLVideoElement | null) => {
|
|
49
|
+
isFullscreen: boolean;
|
|
50
|
+
toggleFullscreen: () => void;
|
|
34
51
|
};
|
|
35
52
|
|
|
36
|
-
export { Loading, Pause, Play, Video, VideoProvider, useVideoState };
|
|
53
|
+
export { Controls, ExitFullscreen, Fullscreen, Loading, Mute, Pause, Play, SeekBackward, SeekForward, Unmute, Video, VideoProvider, useFullscreen, useVideoState };
|
package/dist/new/index.d.ts
CHANGED
|
@@ -21,16 +21,33 @@ interface Props$1 extends Omit<React$1.ComponentProps<"video">, "autoPlay"> {
|
|
|
21
21
|
}
|
|
22
22
|
declare const Video: React$1.ForwardRefExoticComponent<Omit<Props$1, "ref"> & React$1.RefAttributes<HTMLVideoElement>>;
|
|
23
23
|
|
|
24
|
+
interface ControlsProps extends React$1.ComponentProps<"div"> {
|
|
25
|
+
children: React$1.ReactNode;
|
|
26
|
+
asChild?: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare const Controls: React$1.MemoExoticComponent<({ children, asChild, ...props }: ControlsProps) => react_jsx_runtime.JSX.Element>;
|
|
24
29
|
interface Props extends React$1.ComponentProps<"button"> {
|
|
25
30
|
children: React$1.ReactNode;
|
|
26
31
|
asChild?: boolean;
|
|
27
32
|
}
|
|
28
33
|
declare const Play: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
29
34
|
declare const Pause: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
35
|
+
declare const Mute: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
36
|
+
declare const Unmute: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
37
|
+
declare const SeekForward: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
38
|
+
declare const SeekBackward: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
39
|
+
declare const Fullscreen: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
40
|
+
declare const ExitFullscreen: React$1.MemoExoticComponent<({ children, asChild, ...props }: Props) => react_jsx_runtime.JSX.Element>;
|
|
30
41
|
declare const Loading: () => react_jsx_runtime.JSX.Element;
|
|
31
42
|
|
|
32
43
|
declare const useVideoState: (videoRef: RefObject<HTMLVideoElement | null>) => {
|
|
33
44
|
isPlaying: boolean;
|
|
45
|
+
isMuted: boolean;
|
|
46
|
+
isFullscreen: boolean;
|
|
47
|
+
};
|
|
48
|
+
declare const useFullscreen: (videoRef: HTMLVideoElement | null) => {
|
|
49
|
+
isFullscreen: boolean;
|
|
50
|
+
toggleFullscreen: () => void;
|
|
34
51
|
};
|
|
35
52
|
|
|
36
|
-
export { Loading, Pause, Play, Video, VideoProvider, useVideoState };
|
|
53
|
+
export { Controls, ExitFullscreen, Fullscreen, Loading, Mute, Pause, Play, SeekBackward, SeekForward, Unmute, Video, VideoProvider, useFullscreen, useVideoState };
|
package/dist/new/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{a as
|
|
1
|
+
"use client";import{a as g}from"../chunk-WLYC6MHJ.js";import{createContext as T,useContext as M,useEffect as w,useState as k}from"react";import{jsx as y}from"react/jsx-runtime";var b=T(void 0),H=({children:t,config:o,onError:r,...c})=>{let[e,n]=k(null),[s,l]=k(null);return w(()=>{r==null||r(s)},[s]),y(b.Provider,{value:{videoRef:e,setVideoRef:n,config:{clickToPlay:!0,...o},error:s,setError:l},children:y("div",{"data-zuude-video-wrapper":!0,...c,children:t})})},u=()=>{let t=M(b);if(!t)throw new Error("useVideo must be used within a VideoProvider");return t};import{forwardRef as S,useEffect as N,useRef as O}from"react";import{Fragment as j,jsx as A,jsxs as q}from"react/jsx-runtime";var F=S(({src:t,autoPlay:o,muteFallback:r,...c},e)=>{let{videoRef:n,setVideoRef:s,config:l,setError:m,error:L}=u(),P=O(null);N(()=>{let f=P.current,p=e;p?s(p):f&&s({current:f})},[t]),g(n,o==="force"&&c.muted===void 0,m);let v=()=>{var f,p,h;(f=n==null?void 0:n.current)!=null&&f.paused?(p=n.current)==null||p.play():(h=n==null?void 0:n.current)==null||h.pause()};return q(j,{children:[A("video",{ref:e||P,src:t,onClick:l!=null&&l.clickToPlay?v:void 0,autoPlay:o==="force"?!0:o,...c}),L==="NotAllowedError"&&typeof r=="function"&&r(()=>{n!=null&&n.current&&(n.current.muted=!n.current.muted),m(null)})]})});F.displayName="Video";import a from"react";import{Slot as d}from"@radix-ui/react-slot";import{useEffect as E,useState as C}from"react";import x from"react";var Z=t=>{let[o,r]=C(!1),[c,e]=C(!1),[n,s]=C(!1);return E(()=>{let l=t.current;if(l)return l.addEventListener("play",()=>r(!0)),l.addEventListener("pause",()=>r(!1)),()=>{l.removeEventListener("play",()=>r(!0)),l.removeEventListener("pause",()=>r(!1))}},[t]),E(()=>{if(!(t!=null&&t.current))return;e(t.current.muted);let l=()=>{t.current&&e(t.current.muted)};return t.current.addEventListener("volumechange",l),()=>{var m;(m=t.current)==null||m.removeEventListener("volumechange",l)}},[t]),E(()=>{if(!(t!=null&&t.current))return;let l=()=>{s(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[t]),{isPlaying:o,isMuted:c,isFullscreen:n}},V=t=>{let[o,r]=x.useState(!1);x.useEffect(()=>{let e=()=>{r==null||r(!!document.fullscreenElement),c()};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[o]);let c=()=>{console.log("toggleFullscreen");let e=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=t;if(n&&e){if(n.webkitEnterFullscreen){n.webkitEnterFullscreen();return}else if(n.requestFullscreen){n.requestFullscreen();return}}let s=n==null?void 0:n.closest("[data-zuude-video-wrapper]");s&&(o?(document.exitFullscreen(),n&&(n.style.objectFit="cover")):(s.requestFullscreen(),n&&(n.style.objectFit="contain")))};return{isFullscreen:o!=null?o:!1,toggleFullscreen:c}};import{jsx as i}from"react/jsx-runtime";var oe=a.memo(({children:t,asChild:o,...r})=>i("div",{...r,children:t})),ce=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{var s,l;(s=e==null?void 0:e.current)!=null&&s.paused&&((l=e.current)==null||l.play())},children:t})}),le=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{var s;e!=null&&e.current&&((s=e.current)==null||s.pause())},children:t})}),se=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{e!=null&&e.current&&(e.current.muted=!0)},children:t})}),ue=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{e!=null&&e.current&&(e.current.muted=!1)},children:t})}),ie=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{e!=null&&e.current&&(e.current.currentTime+=10)},children:t})}),ae=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u();return i(c,{...r,onClick:()=>{e!=null&&e.current&&(e.current.currentTime-=10)},children:t})}),de=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u(),{toggleFullscreen:n}=V(e==null?void 0:e.current);return i(c,{...r,onClick:n,children:t})}),me=a.memo(({children:t,asChild:o,...r})=>{let c=o?d:"button",{videoRef:e}=u(),{toggleFullscreen:n}=V(e==null?void 0:e.current);return i(c,{...r,onClick:n,children:t})}),fe=()=>i("div",{children:"Loading"});export{oe as Controls,me as ExitFullscreen,de as Fullscreen,fe as Loading,se as Mute,le as Pause,ce as Play,ae as SeekBackward,ie as SeekForward,ue as Unmute,F as Video,H as VideoProvider,V as useFullscreen,Z as useVideoState};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/new/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/new/wrapper.tsx","../../src/new/video.tsx","../../src/new/components.tsx","../../src/new/hook.tsx"],"sourcesContent":["import {\n createContext,\n RefObject,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef | null;\n setVideoRef: (video: VideoRef | null) => void;\n error: string | null;\n setError: (error: string | null) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | undefined>(\n undefined\n);\n\ntype VideoProviderProps = React.ComponentProps<\"div\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = ({\n children,\n config,\n onError,\n ...props\n}: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n }}\n >\n <div {...props}>{children}</div>\n </VideoContext.Provider>\n );\n};\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, { forwardRef, RefObject, useEffect, useRef } from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"../hooks/use-autoplay-by-force\";\n\ninterface Props extends Omit<React.ComponentProps<\"video\">, \"autoPlay\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n muteFallback?: (onMute: () => void) => React.ReactNode;\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n ({ src, autoPlay, muteFallback, ...props }, ref) => {\n const { videoRef, setVideoRef, config, setError, error } = useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n }, [src]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n const onPlay = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n };\n\n return (\n <>\n <video\n ref={ref || refVideo}\n src={src}\n {...props}\n onClick={config?.clickToPlay ? onPlay : undefined}\n />\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import React from \"react\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current?.pause();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Loading = () => {\n return <div>Loading</div>;\n};\n\nexport { Play, Pause, Loading };\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n return { isPlaying };\n};\n\nexport { useVideoState };\n"],"mappings":"sDAAA,OACE,iBAAAA,EAEA,cAAAC,EACA,aAAAC,EACA,YAAAC,MACK,QAkDD,cAAAC,MAAA,oBAlCC,IAAMC,EAAeL,EAC1B,MACF,EAQaM,EAAgB,CAAC,CAC5B,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,GAAGC,CACL,IAA0B,CACxB,GAAM,CAACC,EAAUC,CAAW,EAAIT,EAA0B,IAAI,EACxD,CAACU,EAAOC,CAAQ,EAAIX,EAAwB,IAAI,EAGtD,OAAAD,EAAU,IAAM,CACdO,GAAA,MAAAA,EAAUI,EACZ,EAAG,CAACA,CAAK,CAAC,EAGRT,EAACC,EAAa,SAAb,CACC,MAAO,CACL,SAAAM,EACA,YAAAC,EACA,OAAQ,CAAE,YAAa,GAAM,GAAGJ,CAAO,EACvC,MAAAK,EACA,SAAAC,CACF,EAEA,SAAAV,EAAC,OAAK,GAAGM,EAAQ,SAAAH,EAAS,EAC5B,CAEJ,EAEaQ,EAAW,IAAM,CAC5B,IAAMC,EAAUf,EAAWI,CAAY,EACvC,GAAI,CAACW,EACH,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,ECnEA,OAAgB,cAAAC,EAAuB,aAAAC,EAAW,UAAAC,MAAc,QA6C1D,mBAAAC,EACE,OAAAC,EADF,QAAAC,MAAA,oBAlCC,IAAMC,EAAQC,EACnB,CAAC,CAAE,IAAAC,EAAK,SAAAC,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AAM,CAd5B,IAAAK,EAAAC,GAeQD,EAAAF,GAAA,YAAAA,EAAU,UAAV,MAAAE,EAAmB,UACrBC,EAAAH,EAAS,UAAT,MAAAG,EAAkB,OAEtB,EAIK,SAAAR,EACH,CAEJ,CAAC,EAEKS,EAAQV,EAAM,KAAK,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAM,IAAa,CACnE,IAAMC,EAAUF,EAAUG,EAAO,SAC3B,CAAE,SAAAC,CAAS,EAAIC,EAAS,EAQ9B,OACET,EAACM,EAAA,CAAS,GAAGD,EAAO,QAPF,IAAM,CA/B5B,IAAAK,EAgCQF,GAAA,MAAAA,EAAU,WACZE,EAAAF,EAAS,UAAT,MAAAE,EAAkB,QAEtB,EAIK,SAAAP,EACH,CAEJ,CAAC,EAEKU,EAAU,IACPb,EAAC,OAAI,mBAAO,EC7CrB,OAAoB,aAAAc,EAAW,YAAAC,MAAgB,QAE/C,IAAMC,GAAiBC,GAAiD,CACtE,GAAM,CAACC,EAAWC,CAAY,EAAIJ,EAAS,EAAK,EAEhD,OAAAD,EAAU,IAAM,CACd,IAAMM,EAAQH,EAAS,QAEvB,GAAIG,EACF,OAAAA,EAAM,iBAAiB,OAAQ,IAAMD,EAAa,EAAI,CAAC,EACvDC,EAAM,iBAAiB,QAAS,IAAMD,EAAa,EAAK,CAAC,EAElD,IAAM,CACXC,EAAM,oBAAoB,OAAQ,IAAMD,EAAa,EAAI,CAAC,EAC1DC,EAAM,oBAAoB,QAAS,IAAMD,EAAa,EAAK,CAAC,CAC9D,CAEJ,EAAG,CAACF,CAAQ,CAAC,EAEN,CAAE,UAAAC,CAAU,CACrB","names":["createContext","useContext","useEffect","useState","jsx","VideoContext","VideoProvider","children","config","onError","props","videoRef","setVideoRef","error","setError","useVideo","context","forwardRef","useEffect","useRef","Fragment","jsx","jsxs","Video","forwardRef","src","autoPlay","muteFallback","props","ref","videoRef","setVideoRef","config","setError","error","useVideo","refVideo","useRef","useEffect","video","thirdPartyRef","useAutoplayByForce","onPlay","_a","_b","_c","React","Slot","jsx","Play","React","children","asChild","props","Element","Slot","videoRef","useVideo","_a","_b","Pause","Loading","useEffect","useState","useVideoState","videoRef","isPlaying","setIsPlaying","video"]}
|
|
1
|
+
{"version":3,"sources":["../../src/new/wrapper.tsx","../../src/new/video.tsx","../../src/new/components.tsx","../../src/new/hook.tsx"],"sourcesContent":["import {\n createContext,\n RefObject,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef | null;\n setVideoRef: (video: VideoRef | null) => void;\n error: string | null;\n setError: (error: string | null) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | undefined>(\n undefined\n);\n\ntype VideoProviderProps = React.ComponentProps<\"div\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = ({\n children,\n config,\n onError,\n ...props\n}: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n }}\n >\n <div data-zuude-video-wrapper {...props}>\n {children}\n </div>\n </VideoContext.Provider>\n );\n};\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, { forwardRef, RefObject, useEffect, useRef } from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"../hooks/use-autoplay-by-force\";\n\ninterface Props extends Omit<React.ComponentProps<\"video\">, \"autoPlay\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n muteFallback?: (onMute: () => void) => React.ReactNode;\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n ({ src, autoPlay, muteFallback, ...props }, ref) => {\n const { videoRef, setVideoRef, config, setError, error } = useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n }, [src]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n const onPlay = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n };\n\n return (\n <>\n <video\n ref={ref || refVideo}\n src={src}\n onClick={config?.clickToPlay ? onPlay : undefined}\n autoPlay={autoPlay === \"force\" ? true : autoPlay}\n {...props}\n />\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import React from \"react\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\nimport { useFullscreen } from \"./hook\";\n\ninterface ControlsProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Controls = React.memo(\n ({ children, asChild, ...props }: ControlsProps) => {\n return <div {...props}>{children}</div>;\n }\n);\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current?.pause();\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Mute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Unmute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst SeekForward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.currentTime += 10;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst SeekBackward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const handleClick = () => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= 10;\n }\n };\n\n return (\n <Element {...props} onClick={handleClick}>\n {children}\n </Element>\n );\n});\n\nconst Fullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(\n videoRef?.current as HTMLVideoElement | null\n );\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst ExitFullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(\n videoRef?.current as HTMLVideoElement | null\n );\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst Loading = () => {\n return <div>Loading</div>;\n};\n\nexport {\n Controls,\n Play,\n Pause,\n Mute,\n Unmute,\n SeekForward,\n SeekBackward,\n Fullscreen,\n ExitFullscreen,\n Loading,\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nimport React from \"react\";\n\nconst useFullscreen = (videoRef: HTMLVideoElement | null) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n toggleFullscreen();\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [isFullscreen]);\n\n const toggleFullscreen = () => {\n console.log(\"toggleFullscreen\");\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef;\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 = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n if (video) {\n video.style.objectFit = \"contain\";\n }\n } else {\n document.exitFullscreen();\n if (video) {\n video.style.objectFit = \"cover\";\n }\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useVideoState, useFullscreen };\n"],"mappings":"sDAAA,OACE,iBAAAA,EAEA,cAAAC,EACA,aAAAC,EACA,YAAAC,MACK,QAkDD,cAAAC,MAAA,oBAlCC,IAAMC,EAAeL,EAC1B,MACF,EAQaM,EAAgB,CAAC,CAC5B,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,GAAGC,CACL,IAA0B,CACxB,GAAM,CAACC,EAAUC,CAAW,EAAIT,EAA0B,IAAI,EACxD,CAACU,EAAOC,CAAQ,EAAIX,EAAwB,IAAI,EAGtD,OAAAD,EAAU,IAAM,CACdO,GAAA,MAAAA,EAAUI,EACZ,EAAG,CAACA,CAAK,CAAC,EAGRT,EAACC,EAAa,SAAb,CACC,MAAO,CACL,SAAAM,EACA,YAAAC,EACA,OAAQ,CAAE,YAAa,GAAM,GAAGJ,CAAO,EACvC,MAAAK,EACA,SAAAC,CACF,EAEA,SAAAV,EAAC,OAAI,2BAAwB,GAAE,GAAGM,EAC/B,SAAAH,EACH,EACF,CAEJ,EAEaQ,EAAW,IAAM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I,EAAO,SAC3B,CAAE,SAAAC,CAAS,EAAIC,EAAS,EAQ9B,OACEV,EAACO,EAAA,CAAS,GAAGF,EAAO,QAPF,IAAM,CACpBI,GAAA,MAAAA,EAAU,UACZA,EAAS,QAAQ,aAAe,GAEpC,EAIK,SAAAN,EACH,CAEJ,CAAC,EAEKc,GAAef,EAAM,KAAK,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAM,IAAa,CAC1E,IAAME,EAAUH,EAAUI,EAAO,SAC3B,CAAE,SAAAC,CAAS,EAAIC,EAAS,EAQ9B,OACEV,EAACO,EAAA,CAAS,GAAGF,EAAO,QAPF,IAAM,CACpBI,GAAA,MAAAA,EAAU,UACZA,EAAS,QAAQ,aAAe,GAEpC,EAIK,SAAAN,EACH,CAEJ,CAAC,EAEKe,GAAahB,EAAM,KAAK,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAM,IAAa,CACxE,IAAME,EAAUH,EAAUI,EAAO,SAC3B,CAAE,SAAAC,CAAS,EAAIC,EAAS,EAExB,CAAE,iBAAAS,CAAiB,EAAIC,EAC3BX,GAAA,YAAAA,EAAU,OACZ,EAEA,OACET,EAACO,EAAA,CAAS,GAAGF,EAAO,QAASc,EAC1B,SAAAhB,EACH,CAEJ,CAAC,EAEKkB,GAAiBnB,EAAM,KAAK,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,GAAGC,CAAM,IAAa,CAC5E,IAAME,EAAUH,EAAUI,EAAO,SAC3B,CAAE,SAAAC,CAAS,EAAIC,EAAS,EAExB,CAAE,iBAAAS,CAAiB,EAAIC,EAC3BX,GAAA,YAAAA,EAAU,OACZ,EAEA,OACET,EAACO,EAAA,CAAS,GAAGF,EAAO,QAASc,EAC1B,SAAAhB,EACH,CAEJ,CAAC,EAEKmB,GAAU,IACPtB,EAAC,OAAI,mBAAO","names":["createContext","useContext","useEffect","useState","jsx","VideoContext","VideoProvider","children","config","onError","props","videoRef","setVideoRef","error","setError","useVideo","context","forwardRef","useEffect","useRef","Fragment","jsx","jsxs","Video","forwardRef","src","autoPlay","muteFallback","props","ref","videoRef","setVideoRef","config","setError","error","useVideo","refVideo","useRef","useEffect","video","thirdPartyRef","useAutoplayByForce","onPlay","_a","_b","_c","React","Slot","useEffect","useState","React","useVideoState","videoRef","isPlaying","setIsPlaying","isMuted","setIsMuted","isFullscreen","setIsFullscreen","video","handleVolumeChange","_a","handleFullscreenChange","useFullscreen","toggleFullscreen","isSafari","videoContainer","jsx","Controls","React","children","asChild","props","Play","Element","Slot","videoRef","useVideo","_a","_b","Pause","Mute","Unmute","SeekForward","SeekBackward","Fullscreen","toggleFullscreen","useFullscreen","ExitFullscreen","Loading"]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.4",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -11,6 +11,18 @@
|
|
|
11
11
|
"dist/**"
|
|
12
12
|
],
|
|
13
13
|
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.cjs",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./new": {
|
|
21
|
+
"types": "./dist/new/index.d.ts",
|
|
22
|
+
"import": "./dist/new/index.cjs",
|
|
23
|
+
"require": "./dist/new/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
14
26
|
"scripts": {
|
|
15
27
|
"build": "tsup",
|
|
16
28
|
"lint": "tsc"
|
|
@@ -20,12 +32,12 @@
|
|
|
20
32
|
"license": "ISC",
|
|
21
33
|
"description": "",
|
|
22
34
|
"dependencies": {
|
|
23
|
-
"@radix-ui/react-slot": "^1.1.2",
|
|
24
35
|
"tsup": "^8.5.0",
|
|
25
36
|
"typescript": "^5.8.3"
|
|
26
37
|
},
|
|
27
38
|
"peerDependencies": {
|
|
28
|
-
"react": "^19.0.0"
|
|
39
|
+
"react": "^19.0.0",
|
|
40
|
+
"@radix-ui/react-slot": "^1.1.2"
|
|
29
41
|
},
|
|
30
42
|
"devDependencies": {
|
|
31
43
|
"@types/react": "^19.0.10"
|