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
|
@@ -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:
|
|
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:
|
|
6459
|
+
children: displayClock
|
|
6409
6460
|
})
|
|
6410
6461
|
]
|
|
6411
6462
|
}),
|
|
@@ -7188,6 +7239,49 @@ 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 ENTER_ANIMATION_ALIASES = {
|
|
7243
|
+
fade: "fade",
|
|
7244
|
+
slide_from_left: "slide_from_left",
|
|
7245
|
+
slide_from_right: "slide_from_right",
|
|
7246
|
+
slide_from_top: "slide_from_top",
|
|
7247
|
+
slide_from_bottom: "slide_from_bottom",
|
|
7248
|
+
slide_left: "slide_from_left",
|
|
7249
|
+
slide_right: "slide_from_right",
|
|
7250
|
+
slide_up: "slide_from_top",
|
|
7251
|
+
slide_down: "slide_from_bottom"
|
|
7252
|
+
};
|
|
7253
|
+
function normalizeEnterAnimation(v) {
|
|
7254
|
+
var _ENTER_ANIMATION_ALIASES_v;
|
|
7255
|
+
if (typeof v !== "string") return null;
|
|
7256
|
+
return (_ENTER_ANIMATION_ALIASES_v = ENTER_ANIMATION_ALIASES[v]) !== null && _ENTER_ANIMATION_ALIASES_v !== void 0 ? _ENTER_ANIMATION_ALIASES_v : null;
|
|
7257
|
+
}
|
|
7258
|
+
function getEnterAnimation(overlay) {
|
|
7259
|
+
var flat = overlay.enter_animation;
|
|
7260
|
+
var fromFlat = normalizeEnterAnimation(flat);
|
|
7261
|
+
if (fromFlat) return fromFlat;
|
|
7262
|
+
if (overlay.content) {
|
|
7263
|
+
try {
|
|
7264
|
+
var parsed = JSON.parse(overlay.content);
|
|
7265
|
+
var fromContent = normalizeEnterAnimation(parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation);
|
|
7266
|
+
if (fromContent) return fromContent;
|
|
7267
|
+
} catch (unused) {}
|
|
7268
|
+
}
|
|
7269
|
+
return "fade";
|
|
7270
|
+
}
|
|
7271
|
+
function enterHiddenTransform(anim) {
|
|
7272
|
+
switch(anim){
|
|
7273
|
+
case "slide_from_left":
|
|
7274
|
+
return "translateX(-120%)";
|
|
7275
|
+
case "slide_from_right":
|
|
7276
|
+
return "translateX(120%)";
|
|
7277
|
+
case "slide_from_top":
|
|
7278
|
+
return "translateY(-120%)";
|
|
7279
|
+
case "slide_from_bottom":
|
|
7280
|
+
return "translateY(120%)";
|
|
7281
|
+
default:
|
|
7282
|
+
return "";
|
|
7283
|
+
}
|
|
7284
|
+
}
|
|
7191
7285
|
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
7192
7286
|
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
7193
7287
|
var BEAT_POP_IN_MS = 520;
|
|
@@ -7610,6 +7704,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7610
7704
|
w: width,
|
|
7611
7705
|
h: height
|
|
7612
7706
|
};
|
|
7707
|
+
var enterAnim = getEnterAnimation(overlay);
|
|
7708
|
+
var hasSlide = enterAnim !== "fade" && !useShowcasePop;
|
|
7709
|
+
var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
|
|
7710
|
+
var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
|
|
7711
|
+
var combinedTransform = [
|
|
7712
|
+
slideTransform,
|
|
7713
|
+
popTransform
|
|
7714
|
+
].filter(Boolean).join(" ");
|
|
7613
7715
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
7614
7716
|
style: {
|
|
7615
7717
|
position: "absolute",
|
|
@@ -7618,8 +7720,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7618
7720
|
width: "".concat(width, "px"),
|
|
7619
7721
|
height: "".concat(height, "px"),
|
|
7620
7722
|
opacity: opacity,
|
|
7621
|
-
transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
|
|
7622
|
-
transform:
|
|
7723
|
+
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"),
|
|
7724
|
+
transform: combinedTransform || void 0,
|
|
7623
7725
|
transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
|
|
7624
7726
|
zIndex: overlay.z_index,
|
|
7625
7727
|
overflow: "hidden"
|