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.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +103 -7
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +103 -7
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +103 -7
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +103 -7
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6333,11 +6333,62 @@ function parseConfig(content) {
|
|
|
6333
6333
|
return null;
|
|
6334
6334
|
}
|
|
6335
6335
|
}
|
|
6336
|
+
function parseClockMMSS(clock) {
|
|
6337
|
+
if (!clock) return null;
|
|
6338
|
+
var m = /^\s*(\d{1,3}):([0-5]?\d)\s*$/.exec(clock);
|
|
6339
|
+
if (!m) return null;
|
|
6340
|
+
return parseInt(m[1], 10) * 60 + parseInt(m[2], 10);
|
|
6341
|
+
}
|
|
6342
|
+
function formatClockMMSS(totalSec) {
|
|
6343
|
+
var s = Math.max(0, Math.floor(totalSec));
|
|
6344
|
+
var mm = Math.floor(s / 60);
|
|
6345
|
+
var ss = s % 60;
|
|
6346
|
+
return "".concat(mm, ":").concat(ss.toString().padStart(2, "0"));
|
|
6347
|
+
}
|
|
6348
|
+
function useScoreBugClock(overlayId, sourceClock) {
|
|
6349
|
+
var initialSec = parseClockMMSS(sourceClock);
|
|
6350
|
+
var _useState = _sliced_to_array(useState(function() {
|
|
6351
|
+
return Date.now();
|
|
6352
|
+
}), 2), now = _useState[0], setNow = _useState[1];
|
|
6353
|
+
var startRef = useRef(null);
|
|
6354
|
+
useEffect(function() {
|
|
6355
|
+
if (initialSec === null) {
|
|
6356
|
+
startRef.current = null;
|
|
6357
|
+
return;
|
|
6358
|
+
}
|
|
6359
|
+
startRef.current = {
|
|
6360
|
+
id: overlayId,
|
|
6361
|
+
source: sourceClock || "",
|
|
6362
|
+
at: Date.now(),
|
|
6363
|
+
seconds: initialSec
|
|
6364
|
+
};
|
|
6365
|
+
setNow(Date.now());
|
|
6366
|
+
var tick = window.setInterval(function() {
|
|
6367
|
+
return setNow(Date.now());
|
|
6368
|
+
}, 500);
|
|
6369
|
+
return function() {
|
|
6370
|
+
return clearInterval(tick);
|
|
6371
|
+
};
|
|
6372
|
+
}, [
|
|
6373
|
+
overlayId,
|
|
6374
|
+
sourceClock,
|
|
6375
|
+
initialSec
|
|
6376
|
+
]);
|
|
6377
|
+
if (initialSec === null || !startRef.current) return null;
|
|
6378
|
+
var elapsed = Math.floor((now - startRef.current.at) / 1e3);
|
|
6379
|
+
var remaining = Math.max(0, startRef.current.seconds - elapsed);
|
|
6380
|
+
return formatClockMMSS(remaining);
|
|
6381
|
+
}
|
|
6336
6382
|
function ScoreBugOverlay(param) {
|
|
6337
6383
|
var overlay = param.overlay, size = param.size;
|
|
6384
|
+
var _ref, _cfg_period;
|
|
6338
6385
|
var cfg = parseConfig(overlay.content);
|
|
6386
|
+
var liveClock = useScoreBugClock(overlay.id, cfg === null || cfg === void 0 ? void 0 : cfg.clock);
|
|
6339
6387
|
if (!cfg) return null;
|
|
6340
6388
|
var f = Math.max(6, size.w * 0.052);
|
|
6389
|
+
var displayClock = (_ref = liveClock !== null && liveClock !== void 0 ? liveClock : cfg.clock) !== null && _ref !== void 0 ? _ref : "";
|
|
6390
|
+
var displayPeriod = (_cfg_period = cfg.period) !== null && _cfg_period !== void 0 ? _cfg_period : "";
|
|
6391
|
+
var showMiddleCol = Boolean(displayPeriod || displayClock);
|
|
6341
6392
|
return /* @__PURE__ */ jsxs("div", {
|
|
6342
6393
|
style: {
|
|
6343
6394
|
width: "100%",
|
|
@@ -6395,7 +6446,7 @@ function ScoreBugOverlay(param) {
|
|
|
6395
6446
|
})
|
|
6396
6447
|
]
|
|
6397
6448
|
}),
|
|
6398
|
-
/* @__PURE__ */ jsxs("div", {
|
|
6449
|
+
showMiddleCol && /* @__PURE__ */ jsxs("div", {
|
|
6399
6450
|
style: {
|
|
6400
6451
|
fontSize: "0.88em",
|
|
6401
6452
|
textAlign: "center",
|
|
@@ -6409,15 +6460,15 @@ function ScoreBugOverlay(param) {
|
|
|
6409
6460
|
letterSpacing: "0.04em"
|
|
6410
6461
|
},
|
|
6411
6462
|
children: [
|
|
6412
|
-
/* @__PURE__ */ jsx("div", {
|
|
6413
|
-
children:
|
|
6463
|
+
displayPeriod && /* @__PURE__ */ jsx("div", {
|
|
6464
|
+
children: displayPeriod
|
|
6414
6465
|
}),
|
|
6415
|
-
/* @__PURE__ */ jsx("div", {
|
|
6466
|
+
displayClock && /* @__PURE__ */ jsx("div", {
|
|
6416
6467
|
style: {
|
|
6417
6468
|
fontWeight: 700,
|
|
6418
6469
|
opacity: 1
|
|
6419
6470
|
},
|
|
6420
|
-
children:
|
|
6471
|
+
children: displayClock
|
|
6421
6472
|
})
|
|
6422
6473
|
]
|
|
6423
6474
|
}),
|
|
@@ -7200,6 +7251,43 @@ function hexToRgb(hex) {
|
|
|
7200
7251
|
return "".concat(num >> 16 & 255, ",").concat(num >> 8 & 255, ",").concat(num & 255);
|
|
7201
7252
|
}
|
|
7202
7253
|
var FADE_DURATION_MS = 1e3;
|
|
7254
|
+
var VALID_ENTER_ANIMATIONS = /* @__PURE__ */ new Set([
|
|
7255
|
+
"fade",
|
|
7256
|
+
"slide_left",
|
|
7257
|
+
"slide_right",
|
|
7258
|
+
"slide_up",
|
|
7259
|
+
"slide_down"
|
|
7260
|
+
]);
|
|
7261
|
+
function getEnterAnimation(overlay) {
|
|
7262
|
+
var flat = overlay.enter_animation;
|
|
7263
|
+
if (typeof flat === "string" && VALID_ENTER_ANIMATIONS.has(flat)) {
|
|
7264
|
+
return flat;
|
|
7265
|
+
}
|
|
7266
|
+
if (overlay.content) {
|
|
7267
|
+
try {
|
|
7268
|
+
var parsed = JSON.parse(overlay.content);
|
|
7269
|
+
var v = parsed === null || parsed === void 0 ? void 0 : parsed.enterAnimation;
|
|
7270
|
+
if (typeof v === "string" && VALID_ENTER_ANIMATIONS.has(v)) {
|
|
7271
|
+
return v;
|
|
7272
|
+
}
|
|
7273
|
+
} catch (unused) {}
|
|
7274
|
+
}
|
|
7275
|
+
return "fade";
|
|
7276
|
+
}
|
|
7277
|
+
function enterHiddenTransform(anim) {
|
|
7278
|
+
switch(anim){
|
|
7279
|
+
case "slide_left":
|
|
7280
|
+
return "translateX(-120%)";
|
|
7281
|
+
case "slide_right":
|
|
7282
|
+
return "translateX(120%)";
|
|
7283
|
+
case "slide_up":
|
|
7284
|
+
return "translateY(-120%)";
|
|
7285
|
+
case "slide_down":
|
|
7286
|
+
return "translateY(120%)";
|
|
7287
|
+
default:
|
|
7288
|
+
return "";
|
|
7289
|
+
}
|
|
7290
|
+
}
|
|
7203
7291
|
var SHOWCASE_CYCLE_MS_DEFAULT = 36e3;
|
|
7204
7292
|
var SHOWCASE_MIN_BEAT_MS = 6e3;
|
|
7205
7293
|
var BEAT_POP_IN_MS = 520;
|
|
@@ -7622,6 +7710,14 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7622
7710
|
w: width,
|
|
7623
7711
|
h: height
|
|
7624
7712
|
};
|
|
7713
|
+
var enterAnim = getEnterAnimation(overlay);
|
|
7714
|
+
var hasSlide = enterAnim !== "fade" && !useShowcasePop;
|
|
7715
|
+
var slideTransform = hasSlide && !visible ? enterHiddenTransform(enterAnim) : "";
|
|
7716
|
+
var popTransform = showcaseMode && useShowcasePop ? "scale(".concat(popScale, ")") : "";
|
|
7717
|
+
var combinedTransform = [
|
|
7718
|
+
slideTransform,
|
|
7719
|
+
popTransform
|
|
7720
|
+
].filter(Boolean).join(" ");
|
|
7625
7721
|
return /* @__PURE__ */ jsxs("div", {
|
|
7626
7722
|
style: {
|
|
7627
7723
|
position: "absolute",
|
|
@@ -7630,8 +7726,8 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7630
7726
|
width: "".concat(width, "px"),
|
|
7631
7727
|
height: "".concat(height, "px"),
|
|
7632
7728
|
opacity: opacity,
|
|
7633
|
-
transition: useShowcasePop ? "none" : "opacity ".concat(FADE_DURATION_MS, "ms ease"),
|
|
7634
|
-
transform:
|
|
7729
|
+
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"),
|
|
7730
|
+
transform: combinedTransform || void 0,
|
|
7635
7731
|
transformOrigin: showcaseMode && useShowcasePop ? "center center" : void 0,
|
|
7636
7732
|
zIndex: overlay.z_index,
|
|
7637
7733
|
overflow: "hidden"
|