stormcloud-video-player 0.7.47 → 0.7.49

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.
@@ -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: cfg.period
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: cfg.clock
1051
+ children: displayClock
1001
1052
  })
1002
1053
  ]
1003
1054
  }),
@@ -1780,6 +1831,43 @@ 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 VALID_ENTER_ANIMATIONS = /* @__PURE__ */ new Set([
1835
+ "fade",
1836
+ "slide_left",
1837
+ "slide_right",
1838
+ "slide_up",
1839
+ "slide_down"
1840
+ ]);
1841
+ function getEnterAnimation(overlay) {
1842
+ var flat = overlay.enter_animation;
1843
+ if (typeof flat === "string" && VALID_ENTER_ANIMATIONS.has(flat)) {
1844
+ return flat;
1845
+ }
1846
+ if (overlay.content) {
1847
+ try {
1848
+ var parsed = JSON.parse(overlay.content);
1849
+ var v = parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation;
1850
+ if (typeof v === "string" && VALID_ENTER_ANIMATIONS.has(v)) {
1851
+ return v;
1852
+ }
1853
+ } catch (unused) {}
1854
+ }
1855
+ return "fade";
1856
+ }
1857
+ function enterHiddenTransform(anim) {
1858
+ switch(anim){
1859
+ case "slide_left":
1860
+ return "translateX(-120%)";
1861
+ case "slide_right":
1862
+ return "translateX(120%)";
1863
+ case "slide_up":
1864
+ return "translateY(-120%)";
1865
+ case "slide_down":
1866
+ return "translateY(120%)";
1867
+ default:
1868
+ return "";
1869
+ }
1870
+ }
1783
1871
  var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
1784
1872
  var SHOWCASE_MIN_BEAT_MS = 6e3;
1785
1873
  var BEAT_POP_IN_MS = 520;
@@ -1792,7 +1880,8 @@ var SHOWCASE_PERSISTENT_TYPES = /* @__PURE__ */ new Set([
1792
1880
  "shape",
1793
1881
  "countdown",
1794
1882
  "qr_code",
1795
- "coming_up_next"
1883
+ "coming_up_next",
1884
+ "score_bug"
1796
1885
  ]);
1797
1886
  function easeOutCubic(t) {
1798
1887
  var u = 1 - t;
@@ -2201,6 +2290,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
2201
2290
  w: width,
2202
2291
  h: height
2203
2292
  };
2293
+ var enterAnim = getEnterAnimation(overlay);
2294
+ var hasSlide = enterAnim !== "fade" && !useShowcasePop;
2295
+ var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
2296
+ var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
2297
+ var combinedTransform = [
2298
+ slideTransform,
2299
+ popTransform
2300
+ ].filter(Boolean).join(" ");
2204
2301
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2205
2302
  style: {
2206
2303
  position: "absolute",
@@ -2209,8 +2306,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
2209
2306
  width: "".concat(width, "px"),
2210
2307
  height: "".concat(height, "px"),
2211
2308
  opacity: opacity,
2212
- transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
2213
- transform: showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : void 0,
2309
+ 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"),
2310
+ transform: combinedTransform || void 0,
2214
2311
  transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
2215
2312
  zIndex: overlay.z_index,
2216
2313
  overflow: "hidden"