@lumiastream/ui 0.2.8-alpha.7 → 0.2.8-alpha.8
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/index.js +31 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3992,13 +3992,38 @@ function mapCredits(widget) {
|
|
|
3992
3992
|
}
|
|
3993
3993
|
});
|
|
3994
3994
|
}
|
|
3995
|
+
function inferSlideshowMediaType(mime, url) {
|
|
3996
|
+
if (typeof mime === "string") {
|
|
3997
|
+
if (mime.startsWith("video/")) return "video";
|
|
3998
|
+
if (mime.startsWith("image/")) return "image";
|
|
3999
|
+
}
|
|
4000
|
+
const ext = url.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase() ?? "";
|
|
4001
|
+
if (["mp4", "webm", "mov", "m4v", "ogv"].includes(ext)) return "video";
|
|
4002
|
+
return "image";
|
|
4003
|
+
}
|
|
4004
|
+
function nameFromUrl(url) {
|
|
4005
|
+
try {
|
|
4006
|
+
const path = url.split("?")[0].split("#")[0];
|
|
4007
|
+
return decodeURIComponent(path.split("/").pop() ?? url);
|
|
4008
|
+
} catch {
|
|
4009
|
+
return url;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
3995
4012
|
function mapSlideshow(widget) {
|
|
3996
4013
|
const v = widget.variables ?? {};
|
|
3997
|
-
const
|
|
4014
|
+
const items = (v.images ?? []).map((raw) => {
|
|
4015
|
+
const url = typeof raw === "string" ? raw : raw.url ?? raw.src ?? "";
|
|
4016
|
+
if (!url) return null;
|
|
4017
|
+
return {
|
|
4018
|
+
type: inferSlideshowMediaType(typeof raw === "object" ? raw?.type : void 0, url),
|
|
4019
|
+
src: url,
|
|
4020
|
+
name: nameFromUrl(url)
|
|
4021
|
+
};
|
|
4022
|
+
}).filter((item) => item !== null);
|
|
3998
4023
|
const seAnim = typeof v.animation === "object" && v.animation !== null ? v.animation : {};
|
|
3999
4024
|
return buildUnit(widget, "slideshow", {
|
|
4000
4025
|
content: {
|
|
4001
|
-
|
|
4026
|
+
src: items,
|
|
4002
4027
|
// `interval` of 0 = "rapid cycle" in SE (no delay between images); Lumia's
|
|
4003
4028
|
// `imageDuration` is the total ms per image. Distinguish three cases:
|
|
4004
4029
|
// - undefined → use 5000ms default
|
|
@@ -4009,7 +4034,10 @@ function mapSlideshow(widget) {
|
|
|
4009
4034
|
loopDelay: 0,
|
|
4010
4035
|
delay: 0,
|
|
4011
4036
|
playAudio: !!v.playAudio,
|
|
4012
|
-
|
|
4037
|
+
// Lumia's renderer reads `content.shuffle` (Slideshow/index.tsx:21);
|
|
4038
|
+
// mirroring SE's `random` to that name keeps "play in random order"
|
|
4039
|
+
// working out of the box.
|
|
4040
|
+
shuffle: !!v.random,
|
|
4013
4041
|
animation: {
|
|
4014
4042
|
enterAnimation: typeof v.animation === "string" ? v.animation : seAnim.in ?? "fadeIn",
|
|
4015
4043
|
exitAnimation: typeof v.animation === "string" ? v.animation : seAnim.out ?? "fadeOut",
|