stormcloud-video-player 0.7.48 → 0.7.50
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/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +109 -7
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +109 -7
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +109 -7
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +109 -7
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -913,11 +913,62 @@ function parseConfig(content) {
|
|
|
913
913
|
return null;
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
+
function parseClockMMSS(clock) {
|
|
917
|
+
if (!clock) return null;
|
|
918
|
+
var m = /^\s*(\d{1,3}):([0-5]?\d)\s*$/.exec(clock);
|
|
919
|
+
if (!m) return null;
|
|
920
|
+
return parseInt(m[1], 10) * 60 + parseInt(m[2], 10);
|
|
921
|
+
}
|
|
922
|
+
function formatClockMMSS(totalSec) {
|
|
923
|
+
var s = Math.max(0, Math.floor(totalSec));
|
|
924
|
+
var mm = Math.floor(s / 60);
|
|
925
|
+
var ss = s % 60;
|
|
926
|
+
return "".concat(mm, ":").concat(ss.toString().padStart(2, "0"));
|
|
927
|
+
}
|
|
928
|
+
function useScoreBugClock(overlayId, sourceClock) {
|
|
929
|
+
var initialSec = parseClockMMSS(sourceClock);
|
|
930
|
+
var _ref = _sliced_to_array((0, import_react.useState)(function() {
|
|
931
|
+
return Date.now();
|
|
932
|
+
}), 2), now = _ref[0], setNow = _ref[1];
|
|
933
|
+
var startRef = (0, import_react.useRef)(null);
|
|
934
|
+
(0, import_react.useEffect)(function() {
|
|
935
|
+
if (initialSec === null) {
|
|
936
|
+
startRef.current = null;
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
startRef.current = {
|
|
940
|
+
id: overlayId,
|
|
941
|
+
source: sourceClock || "",
|
|
942
|
+
at: Date.now(),
|
|
943
|
+
seconds: initialSec
|
|
944
|
+
};
|
|
945
|
+
setNow(Date.now());
|
|
946
|
+
var tick = window.setInterval(function() {
|
|
947
|
+
return setNow(Date.now());
|
|
948
|
+
}, 500);
|
|
949
|
+
return function() {
|
|
950
|
+
return clearInterval(tick);
|
|
951
|
+
};
|
|
952
|
+
}, [
|
|
953
|
+
overlayId,
|
|
954
|
+
sourceClock,
|
|
955
|
+
initialSec
|
|
956
|
+
]);
|
|
957
|
+
if (initialSec === null || !startRef.current) return null;
|
|
958
|
+
var elapsed = Math.floor((now - startRef.current.at) / 1e3);
|
|
959
|
+
var remaining = Math.max(0, startRef.current.seconds - elapsed);
|
|
960
|
+
return formatClockMMSS(remaining);
|
|
961
|
+
}
|
|
916
962
|
function ScoreBugOverlay(param) {
|
|
917
963
|
var overlay = param.overlay, size = param.size;
|
|
964
|
+
var _ref, _cfg_period;
|
|
918
965
|
var cfg = parseConfig(overlay.content);
|
|
966
|
+
var liveClock = useScoreBugClock(overlay.id, cfg === null || cfg === void 0 ? void 0 : cfg.clock);
|
|
919
967
|
if (!cfg) return null;
|
|
920
968
|
var f = Math.max(6, size.w * 0.052);
|
|
969
|
+
var displayClock = (_ref = liveClock !== null && liveClock !== void 0 ? liveClock : cfg.clock) !== null && _ref !== void 0 ? _ref : "";
|
|
970
|
+
var displayPeriod = (_cfg_period = cfg.period) !== null && _cfg_period !== void 0 ? _cfg_period : "";
|
|
971
|
+
var showMiddleCol = Boolean(displayPeriod || displayClock);
|
|
921
972
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
922
973
|
style: {
|
|
923
974
|
width: "100%",
|
|
@@ -975,7 +1026,7 @@ function ScoreBugOverlay(param) {
|
|
|
975
1026
|
})
|
|
976
1027
|
]
|
|
977
1028
|
}),
|
|
978
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
1029
|
+
showMiddleCol && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
979
1030
|
style: {
|
|
980
1031
|
fontSize: "0.88em",
|
|
981
1032
|
textAlign: "center",
|
|
@@ -989,15 +1040,15 @@ function ScoreBugOverlay(param) {
|
|
|
989
1040
|
letterSpacing: "0.04em"
|
|
990
1041
|
},
|
|
991
1042
|
children: [
|
|
992
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
993
|
-
children:
|
|
1043
|
+
displayPeriod && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1044
|
+
children: displayPeriod
|
|
994
1045
|
}),
|
|
995
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1046
|
+
displayClock && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
996
1047
|
style: {
|
|
997
1048
|
fontWeight: 700,
|
|
998
1049
|
opacity: 1
|
|
999
1050
|
},
|
|
1000
|
-
children:
|
|
1051
|
+
children: displayClock
|
|
1001
1052
|
})
|
|
1002
1053
|
]
|
|
1003
1054
|
}),
|
|
@@ -1780,6 +1831,49 @@ function hexToRgb(hex) {
|
|
|
1780
1831
|
return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
|
|
1781
1832
|
}
|
|
1782
1833
|
var FADE_DURATION_MS = 1e3;
|
|
1834
|
+
var ENTER_ANIMATION_ALIASES = {
|
|
1835
|
+
fade: "fade",
|
|
1836
|
+
slide_from_left: "slide_from_left",
|
|
1837
|
+
slide_from_right: "slide_from_right",
|
|
1838
|
+
slide_from_top: "slide_from_top",
|
|
1839
|
+
slide_from_bottom: "slide_from_bottom",
|
|
1840
|
+
slide_left: "slide_from_left",
|
|
1841
|
+
slide_right: "slide_from_right",
|
|
1842
|
+
slide_up: "slide_from_top",
|
|
1843
|
+
slide_down: "slide_from_bottom"
|
|
1844
|
+
};
|
|
1845
|
+
function normalizeEnterAnimation(v) {
|
|
1846
|
+
var _ENTER_ANIMATION_ALIASES_v;
|
|
1847
|
+
if (typeof v !== "string") return null;
|
|
1848
|
+
return (_ENTER_ANIMATION_ALIASES_v = ENTER_ANIMATION_ALIASES[v]) !== null && _ENTER_ANIMATION_ALIASES_v !== void 0 ? _ENTER_ANIMATION_ALIASES_v : null;
|
|
1849
|
+
}
|
|
1850
|
+
function getEnterAnimation(overlay) {
|
|
1851
|
+
var flat = overlay.enter_animation;
|
|
1852
|
+
var fromFlat = normalizeEnterAnimation(flat);
|
|
1853
|
+
if (fromFlat) return fromFlat;
|
|
1854
|
+
if (overlay.content) {
|
|
1855
|
+
try {
|
|
1856
|
+
var parsed = JSON.parse(overlay.content);
|
|
1857
|
+
var fromContent = normalizeEnterAnimation(parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation);
|
|
1858
|
+
if (fromContent) return fromContent;
|
|
1859
|
+
} catch (unused) {}
|
|
1860
|
+
}
|
|
1861
|
+
return "fade";
|
|
1862
|
+
}
|
|
1863
|
+
function enterHiddenTransform(anim) {
|
|
1864
|
+
switch(anim){
|
|
1865
|
+
case "slide_from_left":
|
|
1866
|
+
return "translateX(-120%)";
|
|
1867
|
+
case "slide_from_right":
|
|
1868
|
+
return "translateX(120%)";
|
|
1869
|
+
case "slide_from_top":
|
|
1870
|
+
return "translateY(-120%)";
|
|
1871
|
+
case "slide_from_bottom":
|
|
1872
|
+
return "translateY(120%)";
|
|
1873
|
+
default:
|
|
1874
|
+
return "";
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1783
1877
|
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
1784
1878
|
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
1785
1879
|
var BEAT_POP_IN_MS = 520;
|
|
@@ -2202,6 +2296,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
2202
2296
|
w: width,
|
|
2203
2297
|
h: height
|
|
2204
2298
|
};
|
|
2299
|
+
var enterAnim = getEnterAnimation(overlay);
|
|
2300
|
+
var hasSlide = enterAnim !== "fade" && !useShowcasePop;
|
|
2301
|
+
var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
|
|
2302
|
+
var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
|
|
2303
|
+
var combinedTransform = [
|
|
2304
|
+
slideTransform,
|
|
2305
|
+
popTransform
|
|
2306
|
+
].filter(Boolean).join(" ");
|
|
2205
2307
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
2206
2308
|
style: {
|
|
2207
2309
|
position: "absolute",
|
|
@@ -2210,8 +2312,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
2210
2312
|
width: "".concat(width, "px"),
|
|
2211
2313
|
height: "".concat(height, "px"),
|
|
2212
2314
|
opacity: opacity,
|
|
2213
|
-
transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
|
|
2214
|
-
transform:
|
|
2315
|
+
transition: useShowcasePop ? "none" : hasSlide ? "opacity ".concat(FADE_DURATION_MS, "ms ease, transform ").concat(FADE_DURATION_MS, "ms cubic-bezier(0.22, 1, 0.36, 1)") : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
|
|
2316
|
+
transform: combinedTransform || void 0,
|
|
2215
2317
|
transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
|
|
2216
2318
|
zIndex: overlay.z_index,
|
|
2217
2319
|
overflow: "hidden"
|