@cliff-studio/sanity-plugin-bunny-input 1.0.7 → 1.0.9
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 +10 -4
- package/dist/_chunks-es/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api.js +10 -3
- package/src/components/BunnyInput.jsx +13 -1
package/dist/_chunks-es/index.js
CHANGED
|
@@ -18493,8 +18493,9 @@ function getThumbnailUrl(cdnHostname, videoId) {
|
|
|
18493
18493
|
function getPlaybackUrl(cdnHostname, videoId) {
|
|
18494
18494
|
return `https://${cdnHostname}/${videoId}/playlist.m3u8`;
|
|
18495
18495
|
}
|
|
18496
|
-
function getMp4Url(cdnHostname, videoId,
|
|
18497
|
-
|
|
18496
|
+
function getMp4Url(cdnHostname, videoId, availableResolutions = "") {
|
|
18497
|
+
const parsedResolutions = (availableResolutions || "").split(",").map((s) => Number.parseInt(String(s.trim()).replace(/p$/i, ""), 10)).filter((n) => Number.isFinite(n)), bestResolution = parsedResolutions.length ? Math.max(...parsedResolutions) : 720;
|
|
18498
|
+
return `https://${cdnHostname}/${videoId}/play_${bestResolution}p.mp4`;
|
|
18498
18499
|
}
|
|
18499
18500
|
function createHeaders(config, includeJsonContentType = !1, useDirectApi = !1) {
|
|
18500
18501
|
const headers = {
|
|
@@ -18605,7 +18606,7 @@ function BunnyInput(props) {
|
|
|
18605
18606
|
const videoData = await getVideo(config, value.videoId), status = mapBunnyStatus(videoData.status);
|
|
18606
18607
|
if (status === "ready" || status === "error") {
|
|
18607
18608
|
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
|
+
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, orientation = hasDims ? width > height ? "landscape" : width < height ? "portrait" : "square" : null;
|
|
18609
18610
|
onChange(
|
|
18610
18611
|
set({
|
|
18611
18612
|
...value,
|
|
@@ -18614,9 +18615,14 @@ function BunnyInput(props) {
|
|
|
18614
18615
|
height: hasDims ? height : null,
|
|
18615
18616
|
width: hasDims ? width : null,
|
|
18616
18617
|
ratio,
|
|
18618
|
+
orientation,
|
|
18617
18619
|
thumbnailUrl: getThumbnailUrl(config.cdnHostname, value.videoId),
|
|
18618
18620
|
playbackUrl: getPlaybackUrl(config.cdnHostname, value.videoId),
|
|
18619
|
-
mp4Url: getMp4Url(
|
|
18621
|
+
mp4Url: getMp4Url(
|
|
18622
|
+
config.cdnHostname,
|
|
18623
|
+
value.videoId,
|
|
18624
|
+
videoData.availableResolutions
|
|
18625
|
+
)
|
|
18620
18626
|
})
|
|
18621
18627
|
);
|
|
18622
18628
|
}
|