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
package/lib/index.cjs
CHANGED
|
@@ -6505,11 +6505,62 @@ function parseConfig(content) {
|
|
|
6505
6505
|
return null;
|
|
6506
6506
|
}
|
|
6507
6507
|
}
|
|
6508
|
+
function parseClockMMSS(clock) {
|
|
6509
|
+
if (!clock) return null;
|
|
6510
|
+
var m = /^\s*(\d{1,3}):([0-5]?\d)\s*$/.exec(clock);
|
|
6511
|
+
if (!m) return null;
|
|
6512
|
+
return parseInt(m[1], 10) * 60 + parseInt(m[2], 10);
|
|
6513
|
+
}
|
|
6514
|
+
function formatClockMMSS(totalSec) {
|
|
6515
|
+
var s = Math.max(0, Math.floor(totalSec));
|
|
6516
|
+
var mm = Math.floor(s / 60);
|
|
6517
|
+
var ss = s % 60;
|
|
6518
|
+
return "".concat(mm, ":").concat(ss.toString().padStart(2, "0"));
|
|
6519
|
+
}
|
|
6520
|
+
function useScoreBugClock(overlayId, sourceClock) {
|
|
6521
|
+
var initialSec = parseClockMMSS(sourceClock);
|
|
6522
|
+
var _ref = _sliced_to_array((0, import_react.useState)(function() {
|
|
6523
|
+
return Date.now();
|
|
6524
|
+
}), 2), now = _ref[0], setNow = _ref[1];
|
|
6525
|
+
var startRef = (0, import_react.useRef)(null);
|
|
6526
|
+
(0, import_react.useEffect)(function() {
|
|
6527
|
+
if (initialSec === null) {
|
|
6528
|
+
startRef.current = null;
|
|
6529
|
+
return;
|
|
6530
|
+
}
|
|
6531
|
+
startRef.current = {
|
|
6532
|
+
id: overlayId,
|
|
6533
|
+
source: sourceClock || "",
|
|
6534
|
+
at: Date.now(),
|
|
6535
|
+
seconds: initialSec
|
|
6536
|
+
};
|
|
6537
|
+
setNow(Date.now());
|
|
6538
|
+
var tick = window.setInterval(function() {
|
|
6539
|
+
return setNow(Date.now());
|
|
6540
|
+
}, 500);
|
|
6541
|
+
return function() {
|
|
6542
|
+
return clearInterval(tick);
|
|
6543
|
+
};
|
|
6544
|
+
}, [
|
|
6545
|
+
overlayId,
|
|
6546
|
+
sourceClock,
|
|
6547
|
+
initialSec
|
|
6548
|
+
]);
|
|
6549
|
+
if (initialSec === null || !startRef.current) return null;
|
|
6550
|
+
var elapsed = Math.floor((now - startRef.current.at) / 1e3);
|
|
6551
|
+
var remaining = Math.max(0, startRef.current.seconds - elapsed);
|
|
6552
|
+
return formatClockMMSS(remaining);
|
|
6553
|
+
}
|
|
6508
6554
|
function ScoreBugOverlay(param) {
|
|
6509
6555
|
var overlay = param.overlay, size = param.size;
|
|
6556
|
+
var _ref, _cfg_period;
|
|
6510
6557
|
var cfg = parseConfig(overlay.content);
|
|
6558
|
+
var liveClock = useScoreBugClock(overlay.id, cfg === null || cfg === void 0 ? void 0 : cfg.clock);
|
|
6511
6559
|
if (!cfg) return null;
|
|
6512
6560
|
var f = Math.max(6, size.w * 0.052);
|
|
6561
|
+
var displayClock = (_ref = liveClock !== null && liveClock !== void 0 ? liveClock : cfg.clock) !== null && _ref !== void 0 ? _ref : "";
|
|
6562
|
+
var displayPeriod = (_cfg_period = cfg.period) !== null && _cfg_period !== void 0 ? _cfg_period : "";
|
|
6563
|
+
var showMiddleCol = Boolean(displayPeriod || displayClock);
|
|
6513
6564
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
6514
6565
|
style: {
|
|
6515
6566
|
width: "100%",
|
|
@@ -6567,7 +6618,7 @@ function ScoreBugOverlay(param) {
|
|
|
6567
6618
|
})
|
|
6568
6619
|
]
|
|
6569
6620
|
}),
|
|
6570
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
6621
|
+
showMiddleCol && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
6571
6622
|
style: {
|
|
6572
6623
|
fontSize: "0.88em",
|
|
6573
6624
|
textAlign: "center",
|
|
@@ -6581,15 +6632,15 @@ function ScoreBugOverlay(param) {
|
|
|
6581
6632
|
letterSpacing: "0.04em"
|
|
6582
6633
|
},
|
|
6583
6634
|
children: [
|
|
6584
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
6585
|
-
children:
|
|
6635
|
+
displayPeriod && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
6636
|
+
children: displayPeriod
|
|
6586
6637
|
}),
|
|
6587
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
6638
|
+
displayClock && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
6588
6639
|
style: {
|
|
6589
6640
|
fontWeight: 700,
|
|
6590
6641
|
opacity: 1
|
|
6591
6642
|
},
|
|
6592
|
-
children:
|
|
6643
|
+
children: displayClock
|
|
6593
6644
|
})
|
|
6594
6645
|
]
|
|
6595
6646
|
}),
|
|
@@ -7372,6 +7423,49 @@ function hexToRgb(hex) {
|
|
|
7372
7423
|
return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
|
|
7373
7424
|
}
|
|
7374
7425
|
var FADE_DURATION_MS = 1e3;
|
|
7426
|
+
var ENTER_ANIMATION_ALIASES = {
|
|
7427
|
+
fade: "fade",
|
|
7428
|
+
slide_from_left: "slide_from_left",
|
|
7429
|
+
slide_from_right: "slide_from_right",
|
|
7430
|
+
slide_from_top: "slide_from_top",
|
|
7431
|
+
slide_from_bottom: "slide_from_bottom",
|
|
7432
|
+
slide_left: "slide_from_left",
|
|
7433
|
+
slide_right: "slide_from_right",
|
|
7434
|
+
slide_up: "slide_from_top",
|
|
7435
|
+
slide_down: "slide_from_bottom"
|
|
7436
|
+
};
|
|
7437
|
+
function normalizeEnterAnimation(v) {
|
|
7438
|
+
var _ENTER_ANIMATION_ALIASES_v;
|
|
7439
|
+
if (typeof v !== "string") return null;
|
|
7440
|
+
return (_ENTER_ANIMATION_ALIASES_v = ENTER_ANIMATION_ALIASES[v]) !== null && _ENTER_ANIMATION_ALIASES_v !== void 0 ? _ENTER_ANIMATION_ALIASES_v : null;
|
|
7441
|
+
}
|
|
7442
|
+
function getEnterAnimation(overlay) {
|
|
7443
|
+
var flat = overlay.enter_animation;
|
|
7444
|
+
var fromFlat = normalizeEnterAnimation(flat);
|
|
7445
|
+
if (fromFlat) return fromFlat;
|
|
7446
|
+
if (overlay.content) {
|
|
7447
|
+
try {
|
|
7448
|
+
var parsed = JSON.parse(overlay.content);
|
|
7449
|
+
var fromContent = normalizeEnterAnimation(parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation);
|
|
7450
|
+
if (fromContent) return fromContent;
|
|
7451
|
+
} catch (unused) {}
|
|
7452
|
+
}
|
|
7453
|
+
return "fade";
|
|
7454
|
+
}
|
|
7455
|
+
function enterHiddenTransform(anim) {
|
|
7456
|
+
switch(anim){
|
|
7457
|
+
case "slide_from_left":
|
|
7458
|
+
return "translateX(-120%)";
|
|
7459
|
+
case "slide_from_right":
|
|
7460
|
+
return "translateX(120%)";
|
|
7461
|
+
case "slide_from_top":
|
|
7462
|
+
return "translateY(-120%)";
|
|
7463
|
+
case "slide_from_bottom":
|
|
7464
|
+
return "translateY(120%)";
|
|
7465
|
+
default:
|
|
7466
|
+
return "";
|
|
7467
|
+
}
|
|
7468
|
+
}
|
|
7375
7469
|
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
7376
7470
|
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
7377
7471
|
var BEAT_POP_IN_MS = 520;
|
|
@@ -7794,6 +7888,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7794
7888
|
w: width,
|
|
7795
7889
|
h: height
|
|
7796
7890
|
};
|
|
7891
|
+
var enterAnim = getEnterAnimation(overlay);
|
|
7892
|
+
var hasSlide = enterAnim !== "fade" && !useShowcasePop;
|
|
7893
|
+
var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
|
|
7894
|
+
var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
|
|
7895
|
+
var combinedTransform = [
|
|
7896
|
+
slideTransform,
|
|
7897
|
+
popTransform
|
|
7898
|
+
].filter(Boolean).join(" ");
|
|
7797
7899
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
7798
7900
|
style: {
|
|
7799
7901
|
position: "absolute",
|
|
@@ -7802,8 +7904,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7802
7904
|
width: "".concat(width, "px"),
|
|
7803
7905
|
height: "".concat(height, "px"),
|
|
7804
7906
|
opacity: opacity,
|
|
7805
|
-
transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
|
|
7806
|
-
transform:
|
|
7907
|
+
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"),
|
|
7908
|
+
transform: combinedTransform || void 0,
|
|
7807
7909
|
transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
|
|
7808
7910
|
zIndex: overlay.z_index,
|
|
7809
7911
|
overflow: "hidden"
|