@m4l/gclick 0.24.1-beta-fix-video-playback-lifecycle-beta32.0 → 0.24.1
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/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts +0 -4
- package/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts.map +1 -1
- package/components/CameraStream/defaults/DefaultPhaseStreaming.js +33 -35
- package/components/CameraStreams/CameraStreamsProvider.d.ts +0 -5
- package/components/CameraStreams/CameraStreamsProvider.d.ts.map +1 -1
- package/components/CameraStreams/CameraStreamsProvider.js +11 -10
- package/components/CameraStreams/contexts/CameraStreamPlayersContext.d.ts +3 -7
- package/components/CameraStreams/contexts/CameraStreamPlayersContext.d.ts.map +1 -1
- package/components/CameraStreams/hooks/useStreamPolling.d.ts +11 -1
- package/components/CameraStreams/hooks/useStreamPolling.d.ts.map +1 -1
- package/components/CameraStreams/hooks/useStreamPolling.js +89 -84
- package/components/CameraStreams/hooks/useStreamRequest.d.ts +8 -7
- package/components/CameraStreams/hooks/useStreamRequest.d.ts.map +1 -1
- package/components/CameraStreams/hooks/useStreamRequest.js +50 -34
- package/components/CameraStreams/index.d.ts +0 -2
- package/components/CameraStreams/index.d.ts.map +1 -1
- package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.d.ts +18 -0
- package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.d.ts.map +1 -0
- package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.js +35 -0
- package/components/CameraStreams/types.d.ts +10 -23
- package/components/CameraStreams/types.d.ts.map +1 -1
- package/components/VideoPlayer/VideoPlayer.d.ts +3 -3
- package/components/VideoPlayer/VideoPlayer.d.ts.map +1 -1
- package/components/VideoPlayer/VideoPlayer.js +25 -29
- package/components/VideoPlayer/VideoPlayer.styles.d.ts.map +1 -1
- package/components/VideoPlayer/VideoPlayer.styles.js +6 -32
- package/components/VideoPlayer/VideojsDefaultSkin.styles.d.ts.map +1 -1
- package/components/VideoPlayer/VideojsDefaultSkin.styles.js +805 -934
- package/components/VideoPlayer/VideojsMinimalSkin.styles.d.ts.map +1 -1
- package/components/VideoPlayer/VideojsMinimalSkin.styles.js +807 -899
- package/components/VideoPlayer/constants.d.ts +0 -16
- package/components/VideoPlayer/constants.d.ts.map +1 -1
- package/components/VideoPlayer/constants.js +8 -27
- package/components/VideoPlayer/hlsConfig.d.ts +30 -0
- package/components/VideoPlayer/hlsConfig.d.ts.map +1 -0
- package/components/VideoPlayer/hlsConfig.js +33 -0
- package/components/VideoPlayer/hooks/usePlayerControl.d.ts +0 -6
- package/components/VideoPlayer/hooks/usePlayerControl.d.ts.map +1 -1
- package/components/VideoPlayer/hooks/usePlayerControl.js +25 -34
- package/components/VideoPlayer/hooks/usePlayerEvents.d.ts +1 -5
- package/components/VideoPlayer/hooks/usePlayerEvents.d.ts.map +1 -1
- package/components/VideoPlayer/hooks/usePlayerEvents.js +11 -10
- package/components/VideoPlayer/player.factory.d.ts +17 -24
- package/components/VideoPlayer/player.factory.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/GclickVideoSkin.d.ts +2 -4
- package/components/VideoPlayer/subcomponents/GclickVideoSkin.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/GclickVideoSkin.js +24 -36
- package/components/VideoPlayer/subcomponents/VideoPlayerStage.d.ts +3 -5
- package/components/VideoPlayer/subcomponents/VideoPlayerStage.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/VideoPlayerStage.js +49 -64
- package/components/VideoPlayer/subcomponents/skin/VideoControlBar.d.ts +2 -14
- package/components/VideoPlayer/subcomponents/skin/VideoControlBar.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/skin/VideoControlBar.js +62 -90
- package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.d.ts +0 -11
- package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.js +13 -16
- package/components/VideoPlayer/subcomponents/skin/VideoSettingsMenu.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/skin/VideoSettingsMenu.js +12 -10
- package/components/VideoPlayer/subcomponents/skin/primitives.d.ts +2 -11
- package/components/VideoPlayer/subcomponents/skin/primitives.d.ts.map +1 -1
- package/components/VideoPlayer/subcomponents/skin/primitives.js +72 -74
- package/components/VideoPlayer/types.d.ts +5 -43
- package/components/VideoPlayer/types.d.ts.map +1 -1
- package/index.js +145 -149
- package/package.json +2 -4
- package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.d.ts +0 -15
- package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.d.ts.map +0 -1
- package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.js +0 -5
- package/components/CameraStreams/hooks/useCameraStreamsSuspended.d.ts +0 -7
- package/components/CameraStreams/hooks/useCameraStreamsSuspended.d.ts.map +0 -1
- package/components/CameraStreams/hooks/useCameraStreamsSuspended.js +0 -8
- package/components/VideoPlayer/hlsSource.d.ts +0 -41
- package/components/VideoPlayer/hlsSource.d.ts.map +0 -1
- package/components/VideoPlayer/hlsSource.js +0 -35
- package/components/VideoPlayer/hooks/useMediaReadiness.d.ts +0 -22
- package/components/VideoPlayer/hooks/useMediaReadiness.d.ts.map +0 -1
- package/components/VideoPlayer/hooks/useMediaReadiness.js +0 -21
- package/components/VideoPlayer/hooks/usePlaybackIntent.d.ts +0 -14
- package/components/VideoPlayer/hooks/usePlaybackIntent.d.ts.map +0 -1
- package/components/VideoPlayer/hooks/usePlaybackIntent.js +0 -33
- package/components/VideoPlayer/storeSafety.d.ts +0 -15
- package/components/VideoPlayer/storeSafety.d.ts.map +0 -1
- package/components/VideoPlayer/storeSafety.js +0 -25
- package/components/VideoPlayer/subcomponents/skin/VideoInputIndicators.d.ts +0 -15
- package/components/VideoPlayer/subcomponents/skin/VideoInputIndicators.d.ts.map +0 -1
- package/components/VideoPlayer/subcomponents/skin/VideoInputIndicators.js +0 -57
|
@@ -27,10 +27,6 @@ import { CameraStreamPhaseStreamingSlotProps } from '../types';
|
|
|
27
27
|
* (pause / mute / fullscreen / snapshot) from outside the slot. The
|
|
28
28
|
* registration is null-safe: if the slot is rendered without a provider (e.g.
|
|
29
29
|
* an isolated test), it simply skips registering.
|
|
30
|
-
*
|
|
31
|
-
* Forwards the provider's suspension flag to the player. A custom
|
|
32
|
-
* `phaseStreaming` slot must do the same, or its clips keep decoding behind a
|
|
33
|
-
* hidden tab.
|
|
34
30
|
*/
|
|
35
31
|
export declare function DefaultPhaseStreaming({ playerKey, hlsUrl, ended, onEnded, onReplay, replayLabel, onDurationChange, variant, LiveBadgeSlot, ReplayBadgeSlot, SharedBadgeSlot, attached, endsAt, sharedLabel, sharedRemainingLabel, }: CameraStreamPhaseStreamingSlotProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
36
32
|
//# sourceMappingURL=DefaultPhaseStreaming.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultPhaseStreaming.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStream/defaults/DefaultPhaseStreaming.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultPhaseStreaming.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStream/defaults/DefaultPhaseStreaming.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAcpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,eAAe,EACf,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,oBAAoB,GACrB,EAAE,mCAAmC,oDAqGrC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as C, useRef as u, useContext as
|
|
3
|
-
import { CameraStreamPlayersContext as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function Q({
|
|
1
|
+
import { jsxs as N, jsx as c } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState as C, useRef as u, useContext as j, useEffect as l, useCallback as E } from "react";
|
|
3
|
+
import { CameraStreamPlayersContext as k } from "../../CameraStreams/contexts/CameraStreamPlayersContext.js";
|
|
4
|
+
import { VideoPlayer as v } from "../../VideoPlayer/VideoPlayer.js";
|
|
5
|
+
const B = 3, V = 2, U = 2500;
|
|
6
|
+
function G({
|
|
8
7
|
playerKey: t,
|
|
9
|
-
hlsUrl:
|
|
10
|
-
ended:
|
|
11
|
-
onEnded:
|
|
12
|
-
onReplay:
|
|
8
|
+
hlsUrl: f,
|
|
9
|
+
ended: m,
|
|
10
|
+
onEnded: d,
|
|
11
|
+
onReplay: p,
|
|
13
12
|
replayLabel: _,
|
|
14
13
|
onDurationChange: R,
|
|
15
14
|
variant: g,
|
|
@@ -21,30 +20,30 @@ function Q({
|
|
|
21
20
|
sharedLabel: M,
|
|
22
21
|
sharedRemainingLabel: T
|
|
23
22
|
}) {
|
|
24
|
-
const [b, r] = C(!0), [
|
|
23
|
+
const [b, r] = C(!0), [h, S] = C(0), A = u(null), n = j(k), o = u(0), a = u(0), i = u(null);
|
|
25
24
|
l(() => {
|
|
26
|
-
r(!0),
|
|
27
|
-
}, [
|
|
25
|
+
r(!0), S(0), o.current = 0, a.current = 0;
|
|
26
|
+
}, [f]), l(() => () => {
|
|
28
27
|
i.current && clearTimeout(i.current);
|
|
29
28
|
}, []), l(() => {
|
|
30
|
-
const e =
|
|
29
|
+
const e = A.current;
|
|
31
30
|
if (!(!n || !e))
|
|
32
31
|
return n.register(t, e), () => n.unregister(t);
|
|
33
|
-
}, [n, t,
|
|
34
|
-
const
|
|
35
|
-
r(
|
|
36
|
-
}, [R]),
|
|
37
|
-
if (
|
|
32
|
+
}, [n, t, h]);
|
|
33
|
+
const F = E((e, s) => {
|
|
34
|
+
r(s), !s && Number.isFinite(e) && (o.current = e), R(e, s);
|
|
35
|
+
}, [R]), O = E(() => {
|
|
36
|
+
if (o.current < B && a.current < V) {
|
|
38
37
|
a.current += 1, r(!0), i.current = setTimeout(() => {
|
|
39
|
-
|
|
40
|
-
},
|
|
38
|
+
o.current = 0, S((I) => I + 1);
|
|
39
|
+
}, U);
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
|
-
r(!1),
|
|
44
|
-
}, [
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
b && !
|
|
47
|
-
|
|
42
|
+
r(!1), d();
|
|
43
|
+
}, [d]);
|
|
44
|
+
return /* @__PURE__ */ N("div", { "data-stream-player-key": t, style: { width: "100%", height: "100%" }, children: [
|
|
45
|
+
b && !m && /* @__PURE__ */ c(D, {}),
|
|
46
|
+
m && /* @__PURE__ */ c(P, { onReplay: p, replayLabel: _ }),
|
|
48
47
|
y && /* @__PURE__ */ c(
|
|
49
48
|
x,
|
|
50
49
|
{
|
|
@@ -54,19 +53,18 @@ function Q({
|
|
|
54
53
|
}
|
|
55
54
|
),
|
|
56
55
|
/* @__PURE__ */ c(
|
|
57
|
-
|
|
56
|
+
v,
|
|
58
57
|
{
|
|
59
|
-
ref:
|
|
60
|
-
src:
|
|
61
|
-
suspended: F,
|
|
58
|
+
ref: A,
|
|
59
|
+
src: f,
|
|
62
60
|
variant: g,
|
|
63
|
-
onDurationChange:
|
|
64
|
-
onEnded:
|
|
61
|
+
onDurationChange: F,
|
|
62
|
+
onEnded: O
|
|
65
63
|
},
|
|
66
|
-
|
|
64
|
+
h
|
|
67
65
|
)
|
|
68
66
|
] });
|
|
69
67
|
}
|
|
70
68
|
export {
|
|
71
|
-
|
|
69
|
+
G as DefaultPhaseStreaming
|
|
72
70
|
};
|
|
@@ -12,11 +12,6 @@ import { CameraStreamsProviderProps } from './types';
|
|
|
12
12
|
* ref-based map of live `VideoPlayerControl`s). The default `phaseStreaming`
|
|
13
13
|
* slot registers into it, so `useCameraStreamPlayers()` can drive the video
|
|
14
14
|
* transport (pause / mute / fullscreen / snapshot) from outside the slot.
|
|
15
|
-
*
|
|
16
|
-
* The third seam is `CameraStreamsSuspensionContext`, which publishes the
|
|
17
|
-
* `suspended` flag so each player synchronizes its own playback instead of
|
|
18
|
-
* being driven through the registry. See that context for why suspension is
|
|
19
|
-
* declared rather than pushed.
|
|
20
15
|
*/
|
|
21
16
|
export declare function CameraStreamsProvider(props: CameraStreamsProviderProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
22
17
|
//# sourceMappingURL=CameraStreamsProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraStreamsProvider.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStreams/CameraStreamsProvider.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"CameraStreamsProvider.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStreams/CameraStreamsProvider.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,oDAkCtE"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useRef as o } from "react";
|
|
3
|
-
import { useModuleDictionary as
|
|
4
|
-
import { resolveCameraStreamsDictionaryLabels as
|
|
3
|
+
import { useModuleDictionary as f } from "@m4l/core";
|
|
4
|
+
import { resolveCameraStreamsDictionaryLabels as u } from "./dictionary.js";
|
|
5
5
|
import { CameraStreamsContext as p } from "./contexts/CameraStreamsContext.js";
|
|
6
|
-
import { CameraStreamPlayersContext as
|
|
7
|
-
import { CameraStreamsSuspensionContext as C } from "./contexts/CameraStreamsSuspensionContext.js";
|
|
6
|
+
import { CameraStreamPlayersContext as C } from "./contexts/CameraStreamPlayersContext.js";
|
|
8
7
|
import { createCameraStreamsStore as S } from "./store.js";
|
|
9
|
-
import { createCameraStreamPlayersRegistry as
|
|
8
|
+
import { createCameraStreamPlayersRegistry as d } from "./helpers/createCameraStreamPlayersRegistry.js";
|
|
10
9
|
import { CameraStreamsEngine as y } from "./subcomponents/CameraStreamsEngine.js";
|
|
10
|
+
import { CameraStreamsSuspensionController as v } from "./subcomponents/CameraStreamsSuspensionController.js";
|
|
11
11
|
function M(a) {
|
|
12
|
-
const { children: m, labels:
|
|
12
|
+
const { children: m, labels: s, suspended: i = !1, ...n } = a, { getLabel: l } = f(), r = o(null);
|
|
13
13
|
r.current || (r.current = S({
|
|
14
14
|
...n,
|
|
15
15
|
labels: {
|
|
16
|
-
...
|
|
17
|
-
...
|
|
16
|
+
...u(l),
|
|
17
|
+
...s ?? {}
|
|
18
18
|
}
|
|
19
19
|
}));
|
|
20
20
|
const e = o(null);
|
|
21
|
-
return e.current || (e.current =
|
|
21
|
+
return e.current || (e.current = d()), /* @__PURE__ */ t(p.Provider, { value: r.current, children: /* @__PURE__ */ c(C.Provider, { value: e.current, children: [
|
|
22
22
|
/* @__PURE__ */ t(y, {}),
|
|
23
|
+
/* @__PURE__ */ t(v, { suspended: i }),
|
|
23
24
|
m
|
|
24
|
-
] }) })
|
|
25
|
+
] }) });
|
|
25
26
|
}
|
|
26
27
|
export {
|
|
27
28
|
M as CameraStreamsProvider
|
|
@@ -24,13 +24,9 @@ export interface CameraStreamPlayersRegistry {
|
|
|
24
24
|
keys(): PlayerKey[];
|
|
25
25
|
/**
|
|
26
26
|
* Subscribe to registration changes (a control registered or unregistered).
|
|
27
|
-
* Returns an unsubscribe function
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* Note that listeners run SYNCHRONOUSLY inside `register` / `unregister`,
|
|
31
|
-
* which means inside the registering component's own effect. Anything a
|
|
32
|
-
* listener does then runs against a player that has only just committed —
|
|
33
|
-
* which is why suspension no longer travels this way.
|
|
27
|
+
* Returns an unsubscribe function. Lets the suspension coordinator catch
|
|
28
|
+
* players that start streaming *after* the subtree was already suspended (an
|
|
29
|
+
* in-flight request resolving while hidden), which a one-shot snapshot misses.
|
|
34
30
|
*/
|
|
35
31
|
subscribe(listener: () => void): () => void;
|
|
36
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraStreamPlayersContext.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/contexts/CameraStreamPlayersContext.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5D,+DAA+D;IAC/D,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,2EAA2E;IAC3E,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,kBAAkB,GAAG,IAAI,CAAC;IAC/C,6CAA6C;IAC7C,IAAI,IAAI,SAAS,EAAE,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"CameraStreamPlayersContext.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/contexts/CameraStreamPlayersContext.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,2BAA2B;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5D,+DAA+D;IAC/D,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,2EAA2E;IAC3E,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,kBAAkB,GAAG,IAAI,CAAC;IAC/C,6CAA6C;IAC7C,IAAI,IAAI,SAAS,EAAE,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,6DACkB,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { PlayerKey } from '../types';
|
|
2
2
|
interface UseStreamPollingArgs {
|
|
3
3
|
playerKey: PlayerKey;
|
|
4
|
+
/**
|
|
5
|
+
* Command to poll for; `undefined` while the player is not `polling` — and
|
|
6
|
+
* also while it polls a session it joined, which has no command of ours.
|
|
7
|
+
*/
|
|
8
|
+
commandUuid: string | undefined;
|
|
9
|
+
/** Command coordinates captured from the POST response. */
|
|
10
|
+
deviceId: number | null;
|
|
11
|
+
createdAt: string | null;
|
|
12
|
+
/** Release the host progress indicator on a terminal transition. */
|
|
13
|
+
endProgress: () => void;
|
|
4
14
|
}
|
|
5
15
|
/**
|
|
6
16
|
* Poll for one player until its stream settles, publishing both the outcome
|
|
@@ -13,6 +23,6 @@ interface UseStreamPollingArgs {
|
|
|
13
23
|
* owns the wait: they have different lifetimes (the POST fires once, the poll
|
|
14
24
|
* runs for minutes) and different failure modes.
|
|
15
25
|
*/
|
|
16
|
-
export declare function useStreamPolling({ playerKey }: UseStreamPollingArgs): void;
|
|
26
|
+
export declare function useStreamPolling({ playerKey, commandUuid, deviceId, createdAt, endProgress, }: UseStreamPollingArgs): void;
|
|
17
27
|
export {};
|
|
18
28
|
//# sourceMappingURL=useStreamPolling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamPolling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/hooks/useStreamPolling.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA4B1C,UAAU,oBAAoB;IAC5B,SAAS,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useStreamPolling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/hooks/useStreamPolling.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA4B1C,UAAU,oBAAoB;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oEAAoE;IACpE,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,GACZ,EAAE,oBAAoB,GAAG,IAAI,CA2T7B"}
|
|
@@ -1,65 +1,67 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useQuery as
|
|
1
|
+
import { useRef as x, useEffect as k } from "react";
|
|
2
|
+
import { useQuery as A } from "@tanstack/react-query";
|
|
3
3
|
import { useNetwork as D } from "@m4l/core";
|
|
4
|
-
import { extractHlsUrlFromResponse as
|
|
5
|
-
import { resolvePollInterval as
|
|
6
|
-
import { pendingStageBoundaries as
|
|
7
|
-
import { useCameraStreamsStore as
|
|
8
|
-
import { useCloudFrontCookieManager as
|
|
9
|
-
const
|
|
4
|
+
import { extractHlsUrlFromResponse as F, safeParseJson as q, resolveCommandErrorMessage as B, extractErrorMessage as M } from "../helpers/commandError.js";
|
|
5
|
+
import { resolvePollInterval as R } from "../helpers/pollSchedule.js";
|
|
6
|
+
import { pendingStageBoundaries as P } from "../helpers/waitingStages.js";
|
|
7
|
+
import { useCameraStreamsStore as f } from "./useCameraStreamsStore.js";
|
|
8
|
+
import { useCloudFrontCookieManager as N } from "./useCloudFrontCookie.js";
|
|
9
|
+
const G = /* @__PURE__ */ new Set([
|
|
10
10
|
"executed",
|
|
11
11
|
"error",
|
|
12
12
|
"error_retries_max",
|
|
13
13
|
"channel_busy"
|
|
14
14
|
]);
|
|
15
|
-
function
|
|
15
|
+
function V(t) {
|
|
16
16
|
return !!t.hlsUrl || t.status === "error";
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
if (typeof
|
|
18
|
+
function W({ createdAt: t, requestedDuration: c }) {
|
|
19
|
+
if (typeof c != "number")
|
|
20
20
|
return;
|
|
21
|
-
const
|
|
22
|
-
return Number.isFinite(
|
|
21
|
+
const h = new Date(t).getTime() + c * 1e3;
|
|
22
|
+
return Number.isFinite(h) ? new Date(h).toISOString() : void 0;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} :
|
|
32
|
-
|
|
24
|
+
function X({
|
|
25
|
+
playerKey: t,
|
|
26
|
+
commandUuid: c,
|
|
27
|
+
deviceId: h,
|
|
28
|
+
createdAt: v,
|
|
29
|
+
endProgress: o
|
|
30
|
+
}) {
|
|
31
|
+
const { networkOperation: U } = D(), { ensureCookies: g } = N(), i = f((e) => e.players[t]), u = f((e) => e.labels), O = f((e) => e.config.endpointDevicesCommand), _ = f((e) => e.config.endpointVideoStreams), d = f((e) => e.config.pollBudgetSeconds), n = f((e) => e.actions.setPhase), l = x(i);
|
|
32
|
+
l.current = i;
|
|
33
|
+
const S = i?.phase.kind === "polling", I = S && i.phase.kind === "polling" ? i.phase.startedAt : null, E = i?.phase.kind === "polling" && !i.phase.commandUuid ? i.phase.streamUuid : void 0, { data: b, error: T } = A({
|
|
34
|
+
queryKey: ["cameraStreamRequest", t, c],
|
|
33
35
|
/**
|
|
34
36
|
* Poll `devices/command` until the command associated with this player's
|
|
35
37
|
* `commandUuid` reaches a terminal status.
|
|
36
38
|
*/
|
|
37
|
-
queryFn: async () => !
|
|
39
|
+
queryFn: async () => !c || h === null || !v ? null : U({
|
|
38
40
|
method: "GET",
|
|
39
|
-
endPoint:
|
|
41
|
+
endPoint: O,
|
|
40
42
|
parms: {
|
|
41
|
-
deviceId:
|
|
42
|
-
createdAt:
|
|
43
|
-
uuid:
|
|
43
|
+
deviceId: h,
|
|
44
|
+
createdAt: v,
|
|
45
|
+
uuid: c
|
|
44
46
|
},
|
|
45
47
|
toastError: !1,
|
|
46
48
|
toastSuccess: !1,
|
|
47
49
|
responseToCamelCase: !0
|
|
48
50
|
}),
|
|
49
|
-
enabled: !!
|
|
51
|
+
enabled: !!c && S,
|
|
50
52
|
/**
|
|
51
53
|
* Staged interval from `helpers/pollSchedule.ts`. Returns `false` once the
|
|
52
54
|
* backend reports a terminal status or the budget is spent.
|
|
53
55
|
*/
|
|
54
56
|
refetchInterval: (e) => {
|
|
55
57
|
const r = e.state.data?.data?.statusId ?? "";
|
|
56
|
-
if (
|
|
58
|
+
if (G.has(r))
|
|
57
59
|
return !1;
|
|
58
|
-
const s =
|
|
60
|
+
const s = l.current;
|
|
59
61
|
if (s?.phase.kind !== "polling")
|
|
60
62
|
return !1;
|
|
61
63
|
const a = s.phase.startedAt;
|
|
62
|
-
return
|
|
64
|
+
return R((Date.now() - a) / 1e3, d);
|
|
63
65
|
},
|
|
64
66
|
retry: !1,
|
|
65
67
|
refetchOnWindowFocus: !1,
|
|
@@ -70,24 +72,24 @@ function y({ playerKey: t }) {
|
|
|
70
72
|
// and the tile comes back frozen on a stale phase.
|
|
71
73
|
refetchIntervalInBackground: !0,
|
|
72
74
|
staleTime: 1 / 0
|
|
73
|
-
}), { data:
|
|
74
|
-
queryKey: ["cameraStreamAttached", t,
|
|
75
|
+
}), { data: w, error: C } = A({
|
|
76
|
+
queryKey: ["cameraStreamAttached", t, E],
|
|
75
77
|
/** Read the joined stream until it exposes an `hlsUrl` or fails. */
|
|
76
|
-
queryFn: async () =>
|
|
78
|
+
queryFn: async () => E ? U({
|
|
77
79
|
method: "GET",
|
|
78
|
-
endPoint: `${
|
|
80
|
+
endPoint: `${_}/${E}`,
|
|
79
81
|
toastError: !1,
|
|
80
82
|
toastSuccess: !1,
|
|
81
83
|
responseToCamelCase: !0
|
|
82
84
|
}) : null,
|
|
83
|
-
enabled: !!
|
|
85
|
+
enabled: !!E,
|
|
84
86
|
/** Same staged cadence and budget cut-off as the command poll. */
|
|
85
87
|
refetchInterval: (e) => {
|
|
86
88
|
const r = e.state.data?.data;
|
|
87
|
-
if (r &&
|
|
89
|
+
if (r && V(r))
|
|
88
90
|
return !1;
|
|
89
|
-
const s =
|
|
90
|
-
return s?.phase.kind !== "polling" ? !1 :
|
|
91
|
+
const s = l.current;
|
|
92
|
+
return s?.phase.kind !== "polling" ? !1 : R((Date.now() - s.phase.startedAt) / 1e3, d);
|
|
91
93
|
},
|
|
92
94
|
retry: !1,
|
|
93
95
|
refetchOnWindowFocus: !1,
|
|
@@ -97,115 +99,118 @@ function y({ playerKey: t }) {
|
|
|
97
99
|
staleTime: 1 / 0
|
|
98
100
|
});
|
|
99
101
|
k(() => {
|
|
100
|
-
if (!
|
|
102
|
+
if (!S)
|
|
101
103
|
return;
|
|
102
104
|
const e = setTimeout(() => {
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
+
l.current?.phase.kind === "polling" && (n(t, { kind: "timeout" }), o());
|
|
106
|
+
}, d * 1e3);
|
|
105
107
|
return () => {
|
|
106
108
|
clearTimeout(e);
|
|
107
109
|
};
|
|
108
|
-
}, [
|
|
110
|
+
}, [S, t, d, n, o]), k(() => {
|
|
109
111
|
if (I === null)
|
|
110
112
|
return;
|
|
111
|
-
const e = (Date.now() - I) / 1e3, r =
|
|
113
|
+
const e = (Date.now() - I) / 1e3, r = P(e, d).map(
|
|
112
114
|
({ stage: s, delayMs: a }) => setTimeout(() => {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
const m = l.current;
|
|
116
|
+
m?.phase.kind === "polling" && n(t, { ...m.phase, stage: s });
|
|
115
117
|
}, a)
|
|
116
118
|
);
|
|
117
119
|
return () => {
|
|
118
120
|
r.forEach(clearTimeout);
|
|
119
121
|
};
|
|
120
|
-
}, [I, t,
|
|
121
|
-
const e =
|
|
122
|
+
}, [I, t, d, n]), k(() => {
|
|
123
|
+
const e = b?.data;
|
|
122
124
|
if (!e)
|
|
123
125
|
return;
|
|
124
|
-
const r =
|
|
126
|
+
const r = l.current;
|
|
125
127
|
if (!(!r || r.phase.kind !== "polling")) {
|
|
126
128
|
if (e.statusId === "executed") {
|
|
127
|
-
const s =
|
|
129
|
+
const s = F(e.response);
|
|
128
130
|
if (!s) {
|
|
129
|
-
n(t, { kind: "error", code: "missing-hls-url", message:
|
|
131
|
+
n(t, { kind: "error", code: "missing-hls-url", message: u.playerErrorPlayback }), o();
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
|
-
const { commandUuid: a, streamUuid:
|
|
134
|
+
const { commandUuid: a, streamUuid: m } = r.phase, p = () => {
|
|
133
135
|
n(t, {
|
|
134
136
|
kind: "streaming",
|
|
135
137
|
commandUuid: a,
|
|
136
|
-
streamUuid:
|
|
138
|
+
streamUuid: m,
|
|
137
139
|
hlsUrl: s
|
|
138
|
-
});
|
|
140
|
+
}), o();
|
|
139
141
|
};
|
|
140
|
-
|
|
142
|
+
g().then(p).catch(p);
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
145
|
if (e.statusId === "channel_busy") {
|
|
144
|
-
n(t, { kind: "channelBusy" });
|
|
146
|
+
n(t, { kind: "channelBusy" }), o();
|
|
145
147
|
return;
|
|
146
148
|
}
|
|
147
149
|
if (e.statusId === "error") {
|
|
148
|
-
const s =
|
|
150
|
+
const s = q(e.response, {
|
|
149
151
|
error: { origin: "", message: "", status: 0, agent: "" },
|
|
150
152
|
body: ""
|
|
151
|
-
}), a =
|
|
153
|
+
}), a = B(s, u.playerErrorPlayback);
|
|
152
154
|
n(t, {
|
|
153
155
|
kind: "error",
|
|
154
156
|
code: "remote-error",
|
|
155
157
|
message: a
|
|
156
|
-
});
|
|
158
|
+
}), o();
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
159
161
|
if (e.statusId === "error_retries_max") {
|
|
160
|
-
n(t, { kind: "timeout" });
|
|
162
|
+
n(t, { kind: "timeout" }), o();
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
}, [
|
|
165
|
-
|
|
167
|
+
b,
|
|
166
168
|
t,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
n
|
|
169
|
+
u.playerErrorPlayback,
|
|
170
|
+
g,
|
|
171
|
+
n,
|
|
172
|
+
o
|
|
170
173
|
]), k(() => {
|
|
171
|
-
const e =
|
|
174
|
+
const e = w?.data;
|
|
172
175
|
if (!e)
|
|
173
176
|
return;
|
|
174
|
-
const r =
|
|
177
|
+
const r = l.current;
|
|
175
178
|
if (!(!r || r.phase.kind !== "polling")) {
|
|
176
179
|
if (e.hlsUrl) {
|
|
177
|
-
const { streamUuid: s } = r.phase, { hlsUrl: a } = e,
|
|
178
|
-
n(t, { kind: "streaming", streamUuid: s, hlsUrl: a, attached: !0, endsAt:
|
|
180
|
+
const { streamUuid: s } = r.phase, { hlsUrl: a } = e, m = W(e), p = () => {
|
|
181
|
+
n(t, { kind: "streaming", streamUuid: s, hlsUrl: a, attached: !0, endsAt: m }), o();
|
|
179
182
|
};
|
|
180
|
-
|
|
183
|
+
g().then(p).catch(p);
|
|
181
184
|
return;
|
|
182
185
|
}
|
|
183
|
-
e.status === "error" && n(t, {
|
|
186
|
+
e.status === "error" && (n(t, {
|
|
184
187
|
kind: "error",
|
|
185
188
|
code: "attached-stream-failed",
|
|
186
|
-
message:
|
|
187
|
-
});
|
|
189
|
+
message: u.playerErrorPlayback
|
|
190
|
+
}), o());
|
|
188
191
|
}
|
|
189
192
|
}, [
|
|
190
|
-
|
|
193
|
+
w,
|
|
191
194
|
t,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
n
|
|
195
|
+
u.playerErrorPlayback,
|
|
196
|
+
g,
|
|
197
|
+
n,
|
|
198
|
+
o
|
|
195
199
|
]), k(() => {
|
|
196
|
-
const e =
|
|
200
|
+
const e = T ?? C;
|
|
197
201
|
if (!e)
|
|
198
202
|
return;
|
|
199
|
-
const r =
|
|
200
|
-
n(t, { kind: "error", code: "polling-failed", message: r });
|
|
203
|
+
const r = M(e, u.requestErrorUnknownPolling);
|
|
204
|
+
n(t, { kind: "error", code: "polling-failed", message: r }), o();
|
|
201
205
|
}, [
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
T,
|
|
207
|
+
C,
|
|
204
208
|
t,
|
|
205
|
-
|
|
206
|
-
n
|
|
209
|
+
u.requestErrorUnknownPolling,
|
|
210
|
+
n,
|
|
211
|
+
o
|
|
207
212
|
]);
|
|
208
213
|
}
|
|
209
214
|
export {
|
|
210
|
-
|
|
215
|
+
X as useStreamPolling
|
|
211
216
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlayerKey } from '../types';
|
|
1
|
+
import { PlayerKey, StreamPhase } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Engine hook that opens a single player's stream lifecycle: POST to obtain
|
|
4
4
|
* the command/stream UUIDs and move the FSM into `polling`, then delegate the
|
|
@@ -6,15 +6,16 @@ import { PlayerKey } from '../types';
|
|
|
6
6
|
* poll budget, mode, and duration are all read from the scoped Zustand store
|
|
7
7
|
* so the hook stays agnostic of any MF-specific config.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* The request/poll busy indicator is driven through the mounting window's tools
|
|
10
|
+
* (`useWindowToolsMF`), so the spinner renders inside the owning module panel
|
|
11
|
+
* (omm / gps_devices) instead of the global host shell. Requires the subtree to
|
|
12
|
+
* live under a `WindowToolsMFProvider`, which both consumers already mount.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* an engine-owned indicator cannot be released reliably.
|
|
14
|
+
* One instance per `playerKey` — mounted by `<CameraStreamsEngine>` only
|
|
15
|
+
* while the player's `phase.kind === 'requesting'` or `'polling'`.
|
|
16
16
|
*/
|
|
17
17
|
export declare function useStreamRequest({ playerKey }: {
|
|
18
18
|
playerKey: PlayerKey;
|
|
19
19
|
}): void;
|
|
20
|
+
export type { StreamPhase };
|
|
20
21
|
//# sourceMappingURL=useStreamRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamRequest.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/hooks/useStreamRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useStreamRequest.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/hooks/useStreamRequest.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,QAqLvE;AAGD,YAAY,EAAE,WAAW,EAAE,CAAC"}
|