@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260421115845 → 0.8.1-dev.20260422065945
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.
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
import React, { useRef, useEffect, useState, useCallback } from "react";
|
|
3
3
|
import Hls from "hls.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var resolveActiveSource = (sources) => {
|
|
6
|
+
for (const { src, media } of sources) {
|
|
7
|
+
if (media && window.matchMedia(media).matches) return src;
|
|
8
|
+
}
|
|
9
|
+
const fallback = sources.find((s) => !s.media);
|
|
10
|
+
return fallback?.src ?? sources[0]?.src ?? "";
|
|
11
|
+
};
|
|
5
12
|
var HlsPlayer = React.memo(
|
|
6
13
|
({
|
|
7
14
|
sources,
|
|
@@ -11,7 +18,8 @@ var HlsPlayer = React.memo(
|
|
|
11
18
|
intrinsicHeight,
|
|
12
19
|
showControls = true,
|
|
13
20
|
loop = false,
|
|
14
|
-
playOptions = "autoplay"
|
|
21
|
+
playOptions = "autoplay",
|
|
22
|
+
placementCode = ""
|
|
15
23
|
}) => {
|
|
16
24
|
const videoRef = useRef(null);
|
|
17
25
|
const hlsRef = useRef(null);
|
|
@@ -33,41 +41,41 @@ var HlsPlayer = React.memo(
|
|
|
33
41
|
window.addEventListener("resize", checkMobile);
|
|
34
42
|
return () => window.removeEventListener("resize", checkMobile);
|
|
35
43
|
}, []);
|
|
44
|
+
const [activeSrc, setActiveSrc] = useState("");
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (resolvedSources.length === 0) return;
|
|
47
|
+
const update = () => setActiveSrc(resolveActiveSource(resolvedSources));
|
|
48
|
+
update();
|
|
49
|
+
const mqls = resolvedSources.filter((s) => s.media).map((s) => window.matchMedia(s.media));
|
|
50
|
+
mqls.forEach((mql) => mql.addEventListener("change", update));
|
|
51
|
+
return () => mqls.forEach((mql) => mql.removeEventListener("change", update));
|
|
52
|
+
}, [JSON.stringify(resolvedSources)]);
|
|
36
53
|
useEffect(() => {
|
|
37
54
|
const v = videoRef.current;
|
|
38
|
-
if (!v ||
|
|
55
|
+
if (!v || !activeSrc) return;
|
|
39
56
|
if (hlsRef.current) {
|
|
40
57
|
hlsRef.current.destroy();
|
|
41
58
|
hlsRef.current = null;
|
|
42
59
|
}
|
|
43
60
|
if (Hls.isSupported()) {
|
|
44
61
|
const hls = new Hls();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
v.play().catch(console.error);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
v.addEventListener("loadstart", onLoadStart, { once: true });
|
|
57
|
-
v.load();
|
|
62
|
+
hls.loadSource(activeSrc);
|
|
63
|
+
hls.attachMedia(v);
|
|
64
|
+
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
|
65
|
+
if (isPlaying && !wasManuallyPausedRef.current) {
|
|
66
|
+
v.play().catch(console.error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
58
69
|
hlsRef.current = hls;
|
|
59
70
|
return () => {
|
|
60
|
-
v.removeEventListener("loadstart", onLoadStart);
|
|
61
71
|
hls.destroy();
|
|
62
72
|
hlsRef.current = null;
|
|
63
73
|
};
|
|
64
74
|
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
75
|
+
v.src = activeSrc;
|
|
65
76
|
v.load();
|
|
66
77
|
}
|
|
67
|
-
}, [
|
|
68
|
-
// Serialise the source array so the dependency is a stable primitive.
|
|
69
|
-
JSON.stringify(resolvedSources)
|
|
70
|
-
]);
|
|
78
|
+
}, [activeSrc]);
|
|
71
79
|
const handlePlayPause = useCallback(() => {
|
|
72
80
|
const v = videoRef.current;
|
|
73
81
|
if (!v) return;
|
|
@@ -115,16 +123,7 @@ var HlsPlayer = React.memo(
|
|
|
115
123
|
autoPlay: playOptions === "autoplay",
|
|
116
124
|
loop,
|
|
117
125
|
playsInline: true,
|
|
118
|
-
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
119
|
-
children: resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ jsx(
|
|
120
|
-
"source",
|
|
121
|
-
{
|
|
122
|
-
src,
|
|
123
|
-
type: "application/x-mpegURL",
|
|
124
|
-
...media ? { media } : {}
|
|
125
|
-
},
|
|
126
|
-
i
|
|
127
|
-
))
|
|
126
|
+
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
128
127
|
}
|
|
129
128
|
),
|
|
130
129
|
!isMobile && playOptions === "playOnHover" && posterUrl && /* @__PURE__ */ jsx(
|
package/dist/index.js
CHANGED
|
@@ -271,7 +271,7 @@ var HlsPlayer_exports = {};
|
|
|
271
271
|
__export(HlsPlayer_exports, {
|
|
272
272
|
default: () => HlsPlayer_default
|
|
273
273
|
});
|
|
274
|
-
var import_react33, import_hls, import_jsx_runtime42, HlsPlayer, HlsPlayer_default;
|
|
274
|
+
var import_react33, import_hls, import_jsx_runtime42, resolveActiveSource, HlsPlayer, HlsPlayer_default;
|
|
275
275
|
var init_HlsPlayer = __esm({
|
|
276
276
|
"src/components/HlsPlayer.tsx"() {
|
|
277
277
|
"use strict";
|
|
@@ -279,6 +279,13 @@ var init_HlsPlayer = __esm({
|
|
|
279
279
|
import_react33 = __toESM(require("react"));
|
|
280
280
|
import_hls = __toESM(require("hls.js"));
|
|
281
281
|
import_jsx_runtime42 = require("react/jsx-runtime");
|
|
282
|
+
resolveActiveSource = (sources) => {
|
|
283
|
+
for (const { src, media } of sources) {
|
|
284
|
+
if (media && window.matchMedia(media).matches) return src;
|
|
285
|
+
}
|
|
286
|
+
const fallback = sources.find((s) => !s.media);
|
|
287
|
+
return fallback?.src ?? sources[0]?.src ?? "";
|
|
288
|
+
};
|
|
282
289
|
HlsPlayer = import_react33.default.memo(
|
|
283
290
|
({
|
|
284
291
|
sources,
|
|
@@ -288,7 +295,8 @@ var init_HlsPlayer = __esm({
|
|
|
288
295
|
intrinsicHeight,
|
|
289
296
|
showControls = true,
|
|
290
297
|
loop = false,
|
|
291
|
-
playOptions = "autoplay"
|
|
298
|
+
playOptions = "autoplay",
|
|
299
|
+
placementCode = ""
|
|
292
300
|
}) => {
|
|
293
301
|
const videoRef = (0, import_react33.useRef)(null);
|
|
294
302
|
const hlsRef = (0, import_react33.useRef)(null);
|
|
@@ -310,41 +318,41 @@ var init_HlsPlayer = __esm({
|
|
|
310
318
|
window.addEventListener("resize", checkMobile);
|
|
311
319
|
return () => window.removeEventListener("resize", checkMobile);
|
|
312
320
|
}, []);
|
|
321
|
+
const [activeSrc, setActiveSrc] = (0, import_react33.useState)("");
|
|
322
|
+
(0, import_react33.useEffect)(() => {
|
|
323
|
+
if (resolvedSources.length === 0) return;
|
|
324
|
+
const update = () => setActiveSrc(resolveActiveSource(resolvedSources));
|
|
325
|
+
update();
|
|
326
|
+
const mqls = resolvedSources.filter((s) => s.media).map((s) => window.matchMedia(s.media));
|
|
327
|
+
mqls.forEach((mql) => mql.addEventListener("change", update));
|
|
328
|
+
return () => mqls.forEach((mql) => mql.removeEventListener("change", update));
|
|
329
|
+
}, [JSON.stringify(resolvedSources)]);
|
|
313
330
|
(0, import_react33.useEffect)(() => {
|
|
314
331
|
const v = videoRef.current;
|
|
315
|
-
if (!v ||
|
|
332
|
+
if (!v || !activeSrc) return;
|
|
316
333
|
if (hlsRef.current) {
|
|
317
334
|
hlsRef.current.destroy();
|
|
318
335
|
hlsRef.current = null;
|
|
319
336
|
}
|
|
320
337
|
if (import_hls.default.isSupported()) {
|
|
321
338
|
const hls = new import_hls.default();
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
v.play().catch(console.error);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
};
|
|
333
|
-
v.addEventListener("loadstart", onLoadStart, { once: true });
|
|
334
|
-
v.load();
|
|
339
|
+
hls.loadSource(activeSrc);
|
|
340
|
+
hls.attachMedia(v);
|
|
341
|
+
hls.on(import_hls.default.Events.MANIFEST_PARSED, () => {
|
|
342
|
+
if (isPlaying && !wasManuallyPausedRef.current) {
|
|
343
|
+
v.play().catch(console.error);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
335
346
|
hlsRef.current = hls;
|
|
336
347
|
return () => {
|
|
337
|
-
v.removeEventListener("loadstart", onLoadStart);
|
|
338
348
|
hls.destroy();
|
|
339
349
|
hlsRef.current = null;
|
|
340
350
|
};
|
|
341
351
|
} else if (v.canPlayType("application/vnd.apple.mpegurl")) {
|
|
352
|
+
v.src = activeSrc;
|
|
342
353
|
v.load();
|
|
343
354
|
}
|
|
344
|
-
}, [
|
|
345
|
-
// Serialise the source array so the dependency is a stable primitive.
|
|
346
|
-
JSON.stringify(resolvedSources)
|
|
347
|
-
]);
|
|
355
|
+
}, [activeSrc]);
|
|
348
356
|
const handlePlayPause = (0, import_react33.useCallback)(() => {
|
|
349
357
|
const v = videoRef.current;
|
|
350
358
|
if (!v) return;
|
|
@@ -392,16 +400,7 @@ var init_HlsPlayer = __esm({
|
|
|
392
400
|
autoPlay: playOptions === "autoplay",
|
|
393
401
|
loop,
|
|
394
402
|
playsInline: true,
|
|
395
|
-
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
396
|
-
children: resolvedSources.map(({ src, media }, i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
397
|
-
"source",
|
|
398
|
-
{
|
|
399
|
-
src,
|
|
400
|
-
type: "application/x-mpegURL",
|
|
401
|
-
...media ? { media } : {}
|
|
402
|
-
},
|
|
403
|
-
i
|
|
404
|
-
))
|
|
403
|
+
onClick: !isMobile && !isPlaying ? handlePlayPause : void 0
|
|
405
404
|
}
|
|
406
405
|
),
|
|
407
406
|
!isMobile && playOptions === "playOnHover" && posterUrl && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
@@ -5130,13 +5129,13 @@ var HlsPlayer3 = (0, import_dynamic5.default)(() => Promise.resolve().then(() =>
|
|
|
5130
5129
|
var deviceToMediaQuery = (device) => {
|
|
5131
5130
|
switch (device) {
|
|
5132
5131
|
case "sm":
|
|
5133
|
-
return "(max-width:
|
|
5132
|
+
return "(max-width: 480px)";
|
|
5134
5133
|
case "md":
|
|
5135
|
-
return "(
|
|
5134
|
+
return "(max-width: 768px)";
|
|
5136
5135
|
case "lg":
|
|
5137
|
-
return "(min-width:
|
|
5138
|
-
case "tv":
|
|
5139
|
-
|
|
5136
|
+
return "(min-width: 769px)";
|
|
5137
|
+
// case "tv":
|
|
5138
|
+
// return "(min-width: 1920px)";
|
|
5140
5139
|
default:
|
|
5141
5140
|
return null;
|
|
5142
5141
|
}
|
|
@@ -5192,22 +5191,23 @@ var ImageGalleryNode = (props) => {
|
|
|
5192
5191
|
right: "justify-end"
|
|
5193
5192
|
};
|
|
5194
5193
|
const formatClasses = FormatClass[props.node.format || ""] || "";
|
|
5195
|
-
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
5196
|
-
hlsSources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
5194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
5195
|
+
hlsSources.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
5197
5196
|
HlsPlayer3,
|
|
5198
5197
|
{
|
|
5199
5198
|
sources: hlsSources,
|
|
5200
5199
|
posterUrl: hlsPosterUrl,
|
|
5201
5200
|
intrinsicWidth: hlsIntrinsicWidth,
|
|
5202
5201
|
intrinsicHeight: hlsIntrinsicHeight,
|
|
5203
|
-
showControls:
|
|
5204
|
-
loop: false,
|
|
5205
|
-
playOptions:
|
|
5202
|
+
showControls: primaryHls?.showControls ?? false,
|
|
5203
|
+
loop: primaryHls?.loop ?? false,
|
|
5204
|
+
playOptions: primaryHls?.playOptions ?? "",
|
|
5205
|
+
placementCode: primaryHls?.placementCode ?? "",
|
|
5206
5206
|
apiBaseUrl: props.apiBaseUrl,
|
|
5207
5207
|
session: props.session
|
|
5208
5208
|
}
|
|
5209
5209
|
) }),
|
|
5210
|
-
staticFallback && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
5210
|
+
staticFallback && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_jsx_runtime67.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("picture", { children: [
|
|
5211
5211
|
DEVICE_ORDER.map((deviceKey) => {
|
|
5212
5212
|
const match = staticSources.find((img) => img.device === deviceKey);
|
|
5213
5213
|
if (!match) return null;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HlsPlayer_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VVEZGWP4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Button_default,
|
|
6
6
|
ServiceClient_default,
|
|
@@ -2638,7 +2638,7 @@ var DeviceAssetSelector_default = DeviceAssetSelector;
|
|
|
2638
2638
|
|
|
2639
2639
|
// src/components/pageRenderingEngine/nodes/ImageNode.tsx
|
|
2640
2640
|
import { Fragment as Fragment3, jsx as jsx39 } from "react/jsx-runtime";
|
|
2641
|
-
var HlsPlayer = dynamic(() => import("./HlsPlayer-
|
|
2641
|
+
var HlsPlayer = dynamic(() => import("./HlsPlayer-O6BEBDTQ.mjs"), {
|
|
2642
2642
|
ssr: false
|
|
2643
2643
|
});
|
|
2644
2644
|
var getNestedValue = (obj, path) => {
|
|
@@ -4106,18 +4106,18 @@ var Pagination_default = Pagination;
|
|
|
4106
4106
|
|
|
4107
4107
|
// src/components/pageRenderingEngine/nodes/ImageGalleryNode.tsx
|
|
4108
4108
|
import dynamic5 from "next/dynamic";
|
|
4109
|
-
import { jsx as jsx58, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4110
|
-
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-
|
|
4109
|
+
import { Fragment as Fragment9, jsx as jsx58, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4110
|
+
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-O6BEBDTQ.mjs"), { ssr: false });
|
|
4111
4111
|
var deviceToMediaQuery = (device) => {
|
|
4112
4112
|
switch (device) {
|
|
4113
4113
|
case "sm":
|
|
4114
|
-
return "(max-width:
|
|
4114
|
+
return "(max-width: 480px)";
|
|
4115
4115
|
case "md":
|
|
4116
|
-
return "(
|
|
4116
|
+
return "(max-width: 768px)";
|
|
4117
4117
|
case "lg":
|
|
4118
|
-
return "(min-width:
|
|
4119
|
-
case "tv":
|
|
4120
|
-
|
|
4118
|
+
return "(min-width: 769px)";
|
|
4119
|
+
// case "tv":
|
|
4120
|
+
// return "(min-width: 1920px)";
|
|
4121
4121
|
default:
|
|
4122
4122
|
return null;
|
|
4123
4123
|
}
|
|
@@ -4173,22 +4173,23 @@ var ImageGalleryNode = (props) => {
|
|
|
4173
4173
|
right: "justify-end"
|
|
4174
4174
|
};
|
|
4175
4175
|
const formatClasses = FormatClass[props.node.format || ""] || "";
|
|
4176
|
-
return /* @__PURE__ */ jsxs33(
|
|
4177
|
-
hlsSources.length > 0 && /* @__PURE__ */ jsx58(
|
|
4176
|
+
return /* @__PURE__ */ jsxs33(Fragment9, { children: [
|
|
4177
|
+
hlsSources.length > 0 && /* @__PURE__ */ jsx58(Fragment9, { children: /* @__PURE__ */ jsx58(
|
|
4178
4178
|
HlsPlayer2,
|
|
4179
4179
|
{
|
|
4180
4180
|
sources: hlsSources,
|
|
4181
4181
|
posterUrl: hlsPosterUrl,
|
|
4182
4182
|
intrinsicWidth: hlsIntrinsicWidth,
|
|
4183
4183
|
intrinsicHeight: hlsIntrinsicHeight,
|
|
4184
|
-
showControls:
|
|
4185
|
-
loop: false,
|
|
4186
|
-
playOptions:
|
|
4184
|
+
showControls: primaryHls?.showControls ?? false,
|
|
4185
|
+
loop: primaryHls?.loop ?? false,
|
|
4186
|
+
playOptions: primaryHls?.playOptions ?? "",
|
|
4187
|
+
placementCode: primaryHls?.placementCode ?? "",
|
|
4187
4188
|
apiBaseUrl: props.apiBaseUrl,
|
|
4188
4189
|
session: props.session
|
|
4189
4190
|
}
|
|
4190
4191
|
) }),
|
|
4191
|
-
staticFallback && /* @__PURE__ */ jsx58(
|
|
4192
|
+
staticFallback && /* @__PURE__ */ jsx58(Fragment9, { children: /* @__PURE__ */ jsxs33("picture", { children: [
|
|
4192
4193
|
DEVICE_ORDER.map((deviceKey) => {
|
|
4193
4194
|
const match = staticSources.find((img) => img.device === deviceKey);
|
|
4194
4195
|
if (!match) return null;
|
|
@@ -4656,7 +4657,7 @@ var PageBodyRenderer_default = PageBodyRenderer;
|
|
|
4656
4657
|
|
|
4657
4658
|
// src/components/Toast.tsx
|
|
4658
4659
|
import { useState as useState8 } from "react";
|
|
4659
|
-
import { Fragment as
|
|
4660
|
+
import { Fragment as Fragment10, jsx as jsx61, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4660
4661
|
var Toast = () => {
|
|
4661
4662
|
const [showToast, setShowToast] = useState8(false);
|
|
4662
4663
|
const [message, setMessage] = useState8("");
|
|
@@ -4699,7 +4700,7 @@ var Toast = () => {
|
|
|
4699
4700
|
const closeToast = () => {
|
|
4700
4701
|
setShowToast(false);
|
|
4701
4702
|
};
|
|
4702
|
-
return /* @__PURE__ */ jsx61(
|
|
4703
|
+
return /* @__PURE__ */ jsx61(Fragment10, { children: showToast && /* @__PURE__ */ jsx61("div", { className: "fixed top-2 flex justify-center w-1/2 max-w-xl left-1/2 -translate-x-1/2", style: { zIndex: 1e3 }, children: /* @__PURE__ */ jsxs35("div", { className: `w-full items-center flex justify-between p-3 rounded-md relative shadow border bg-${messageType}-soft`, children: [
|
|
4703
4704
|
/* @__PURE__ */ jsx61(
|
|
4704
4705
|
"span",
|
|
4705
4706
|
{
|
package/package.json
CHANGED