@cliff-studio/sanity-plugin-bunny-input 1.0.4 → 1.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/_chunks-es/index.js
CHANGED
|
@@ -18602,21 +18602,24 @@ function BunnyInput(props) {
|
|
|
18602
18602
|
const { value, onChange, config } = props, [uploadProgress, setUploadProgress] = useState(0), [isUploading, setIsUploading] = useState(!1), [error, setError] = useState(null), fileInputRef = useRef(null), pollIntervalRef = useRef(null);
|
|
18603
18603
|
useEffect(() => (value?.videoId && value?.status === "processing" && (pollIntervalRef.current = window.setInterval(async () => {
|
|
18604
18604
|
try {
|
|
18605
|
-
const videoData = await getVideo(config, value.videoId);
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18615
|
-
|
|
18616
|
-
|
|
18617
|
-
|
|
18618
|
-
|
|
18619
|
-
|
|
18605
|
+
const videoData = await getVideo(config, value.videoId), status = mapBunnyStatus(videoData.status);
|
|
18606
|
+
if (status === "ready" || status === "error") {
|
|
18607
|
+
pollIntervalRef.current && (clearInterval(pollIntervalRef.current), pollIntervalRef.current = null);
|
|
18608
|
+
const width = Number(videoData.width), height = Number(videoData.height), hasDims = Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0, ratio = hasDims ? Number((width / height).toFixed(6)) : null;
|
|
18609
|
+
onChange(
|
|
18610
|
+
set({
|
|
18611
|
+
...value,
|
|
18612
|
+
status,
|
|
18613
|
+
duration: videoData.length,
|
|
18614
|
+
height: hasDims ? height : null,
|
|
18615
|
+
width: hasDims ? width : null,
|
|
18616
|
+
ratio,
|
|
18617
|
+
thumbnailUrl: getThumbnailUrl(config.cdnHostname, value.videoId),
|
|
18618
|
+
playbackUrl: getPlaybackUrl(config.cdnHostname, value.videoId),
|
|
18619
|
+
mp4Url: getMp4Url(config.cdnHostname, value.videoId)
|
|
18620
|
+
})
|
|
18621
|
+
);
|
|
18622
|
+
}
|
|
18620
18623
|
} catch (err) {
|
|
18621
18624
|
console.error("Error polling video status:", err);
|
|
18622
18625
|
}
|
|
@@ -18934,13 +18937,19 @@ const createBunnyVideoSchema = (config) => defineType({
|
|
|
18934
18937
|
defineField({
|
|
18935
18938
|
type: "number",
|
|
18936
18939
|
title: "Video width",
|
|
18937
|
-
name: "
|
|
18940
|
+
name: "width",
|
|
18938
18941
|
readOnly: !0
|
|
18939
18942
|
}),
|
|
18940
18943
|
defineField({
|
|
18941
18944
|
type: "number",
|
|
18942
18945
|
title: "Video height",
|
|
18943
|
-
name: "
|
|
18946
|
+
name: "height",
|
|
18947
|
+
readOnly: !0
|
|
18948
|
+
}),
|
|
18949
|
+
defineField({
|
|
18950
|
+
type: "string",
|
|
18951
|
+
title: "Video ratio",
|
|
18952
|
+
name: "ratio",
|
|
18944
18953
|
readOnly: !0
|
|
18945
18954
|
}),
|
|
18946
18955
|
defineField({
|