stormcloud-video-player 0.7.48 → 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.
@@ -6321,11 +6321,62 @@ function parseConfig(content) {
6321
6321
  return null;
6322
6322
  }
6323
6323
  }
6324
+ function parseClockMMSS(clock) {
6325
+ if (!clock) return null;
6326
+ var m = /^\s*(\d{1,3}):([0-5]?\d)\s*$/.exec(clock);
6327
+ if (!m) return null;
6328
+ return parseInt(m[1], 10) * 60 + parseInt(m[2], 10);
6329
+ }
6330
+ function formatClockMMSS(totalSec) {
6331
+ var s = Math.max(0, Math.floor(totalSec));
6332
+ var mm = Math.floor(s / 60);
6333
+ var ss = s % 60;
6334
+ return "".concat(mm, ":").concat(ss.toString().padStart(2, "0"));
6335
+ }
6336
+ function useScoreBugClock(overlayId, sourceClock) {
6337
+ var initialSec = parseClockMMSS(sourceClock);
6338
+ var _ref = _sliced_to_array((0, import_react.useState)(function() {
6339
+ return Date.now();
6340
+ }), 2), now = _ref[0], setNow = _ref[1];
6341
+ var startRef = (0, import_react.useRef)(null);
6342
+ (0, import_react.useEffect)(function() {
6343
+ if (initialSec === null) {
6344
+ startRef.current = null;
6345
+ return;
6346
+ }
6347
+ startRef.current = {
6348
+ id: overlayId,
6349
+ source: sourceClock || "",
6350
+ at: Date.now(),
6351
+ seconds: initialSec
6352
+ };
6353
+ setNow(Date.now());
6354
+ var tick = window.setInterval(function() {
6355
+ return setNow(Date.now());
6356
+ }, 500);
6357
+ return function() {
6358
+ return clearInterval(tick);
6359
+ };
6360
+ }, [
6361
+ overlayId,
6362
+ sourceClock,
6363
+ initialSec
6364
+ ]);
6365
+ if (initialSec === null || !startRef.current) return null;
6366
+ var elapsed = Math.floor((now - startRef.current.at) / 1e3);
6367
+ var remaining = Math.max(0, startRef.current.seconds - elapsed);
6368
+ return formatClockMMSS(remaining);
6369
+ }
6324
6370
  function ScoreBugOverlay(param) {
6325
6371
  var overlay = param.overlay, size = param.size;
6372
+ var _ref, _cfg_period;
6326
6373
  var cfg = parseConfig(overlay.content);
6374
+ var liveClock = useScoreBugClock(overlay.id, cfg === null || cfg === void 0 ? void 0 : cfg.clock);
6327
6375
  if (!cfg) return null;
6328
6376
  var f = Math.max(6, size.w * 0.052);
6377
+ var displayClock = (_ref = liveClock !== null && liveClock !== void 0 ? liveClock : cfg.clock) !== null && _ref !== void 0 ? _ref : "";
6378
+ var displayPeriod = (_cfg_period = cfg.period) !== null && _cfg_period !== void 0 ? _cfg_period : "";
6379
+ var showMiddleCol = Boolean(displayPeriod || displayClock);
6329
6380
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
6330
6381
  style: {
6331
6382
  width: "100%",
@@ -6383,7 +6434,7 @@ function ScoreBugOverlay(param) {
6383
6434
  })
6384
6435
  ]
6385
6436
  }),
6386
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
6437
+ showMiddleCol && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
6387
6438
  style: {
6388
6439
  fontSize: "0.88em",
6389
6440
  textAlign: "center",
@@ -6397,15 +6448,15 @@ function ScoreBugOverlay(param) {
6397
6448
  letterSpacing: "0.04em"
6398
6449
  },
6399
6450
  children: [
6400
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
6401
- children: cfg.period
6451
+ displayPeriod && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
6452
+ children: displayPeriod
6402
6453
  }),
6403
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
6454
+ displayClock && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
6404
6455
  style: {
6405
6456
  fontWeight: 700,
6406
6457
  opacity: 1
6407
6458
  },
6408
- children: cfg.clock
6459
+ children: displayClock
6409
6460
  })
6410
6461
  ]
6411
6462
  }),
@@ -7188,6 +7239,43 @@ function hexToRgb(hex) {
7188
7239
  return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
7189
7240
  }
7190
7241
  var FADE_DURATION_MS = 1e3;
7242
+ var VALID_ENTER_ANIMATIONS = /* @__PURE__ */ new Set([
7243
+ "fade",
7244
+ "slide_left",
7245
+ "slide_right",
7246
+ "slide_up",
7247
+ "slide_down"
7248
+ ]);
7249
+ function getEnterAnimation(overlay) {
7250
+ var flat = overlay.enter_animation;
7251
+ if (typeof flat === "string" && VALID_ENTER_ANIMATIONS.has(flat)) {
7252
+ return flat;
7253
+ }
7254
+ if (overlay.content) {
7255
+ try {
7256
+ var parsed = JSON.parse(overlay.content);
7257
+ var v = parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation;
7258
+ if (typeof v === "string" && VALID_ENTER_ANIMATIONS.has(v)) {
7259
+ return v;
7260
+ }
7261
+ } catch (unused) {}
7262
+ }
7263
+ return "fade";
7264
+ }
7265
+ function enterHiddenTransform(anim) {
7266
+ switch(anim){
7267
+ case "slide_left":
7268
+ return "translateX(-120%)";
7269
+ case "slide_right":
7270
+ return "translateX(120%)";
7271
+ case "slide_up":
7272
+ return "translateY(-120%)";
7273
+ case "slide_down":
7274
+ return "translateY(120%)";
7275
+ default:
7276
+ return "";
7277
+ }
7278
+ }
7191
7279
  var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
7192
7280
  var SHOWCASE_MIN_BEAT_MS = 6e3;
7193
7281
  var BEAT_POP_IN_MS = 520;
@@ -7610,6 +7698,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
7610
7698
  w: width,
7611
7699
  h: height
7612
7700
  };
7701
+ var enterAnim = getEnterAnimation(overlay);
7702
+ var hasSlide = enterAnim !== "fade" && !useShowcasePop;
7703
+ var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
7704
+ var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
7705
+ var combinedTransform = [
7706
+ slideTransform,
7707
+ popTransform
7708
+ ].filter(Boolean).join(" ");
7613
7709
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
7614
7710
  style: {
7615
7711
  position: "absolute",
@@ -7618,8 +7714,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
7618
7714
  width: "".concat(width, "px"),
7619
7715
  height: "".concat(height, "px"),
7620
7716
  opacity: opacity,
7621
- transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
7622
- transform: showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : void 0,
7717
+ 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"),
7718
+ transform: combinedTransform || void 0,
7623
7719
  transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
7624
7720
  zIndex: overlay.z_index,
7625
7721
  overflow: "hidden"