@m4l/gclick 0.23.0 → 0.24.0
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/CameraStream.d.ts.map +1 -1
- package/components/CameraStream/CameraStream.js +30 -28
- package/components/CameraStream/CameraStream.styles.d.ts.map +1 -1
- package/components/CameraStream/CameraStream.styles.js +26 -2
- package/components/CameraStream/defaults/DefaultPhaseChannelBusy.d.ts +4 -4
- package/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts +1 -1
- package/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts.map +1 -1
- package/components/CameraStream/defaults/DefaultPhaseStreaming.js +40 -27
- package/components/CameraStream/defaults/DefaultSharedBadge.d.ts +10 -0
- package/components/CameraStream/defaults/DefaultSharedBadge.d.ts.map +1 -0
- package/components/CameraStream/defaults/DefaultSharedBadge.js +28 -0
- package/components/CameraStream/helpers/renderPhase.d.ts +3 -0
- package/components/CameraStream/helpers/renderPhase.d.ts.map +1 -1
- package/components/CameraStream/helpers/renderPhase.js +25 -19
- package/components/CameraStream/index.d.ts +2 -1
- package/components/CameraStream/index.d.ts.map +1 -1
- package/components/CameraStream/slots/CameraStreamEnum.d.ts +1 -0
- package/components/CameraStream/slots/CameraStreamEnum.d.ts.map +1 -1
- package/components/CameraStream/slots/CameraStreamEnum.js +2 -2
- package/components/CameraStream/slots/CameraStreamSlots.d.ts +3 -0
- package/components/CameraStream/slots/CameraStreamSlots.d.ts.map +1 -1
- package/components/CameraStream/slots/CameraStreamSlots.js +43 -39
- package/components/CameraStream/types.d.ts +23 -0
- package/components/CameraStream/types.d.ts.map +1 -1
- package/components/CameraStreams/dictionary.d.ts.map +1 -1
- package/components/CameraStreams/dictionary.js +27 -23
- package/components/CameraStreams/hooks/useStreamPolling.d.ts +9 -3
- package/components/CameraStreams/hooks/useStreamPolling.d.ts.map +1 -1
- package/components/CameraStreams/hooks/useStreamPolling.js +132 -70
- package/components/CameraStreams/hooks/useStreamRequest.d.ts.map +1 -1
- package/components/CameraStreams/hooks/useStreamRequest.js +51 -43
- package/components/CameraStreams/model.d.ts +28 -0
- package/components/CameraStreams/model.d.ts.map +1 -1
- package/components/CameraStreams/model.js +6 -0
- package/components/CameraStreams/store.d.ts.map +1 -1
- package/components/CameraStreams/store.js +21 -21
- package/components/CameraStreams/types.d.ts +25 -8
- package/components/CameraStreams/types.d.ts.map +1 -1
- package/index.js +79 -77
- package/package.json +2 -2
|
@@ -44,6 +44,14 @@ export interface CameraStreamReplayBadgeSlotProps {
|
|
|
44
44
|
onReplay: () => void;
|
|
45
45
|
replayLabel: string;
|
|
46
46
|
}
|
|
47
|
+
/** Props received by the `sharedBadge` slot. */
|
|
48
|
+
export interface CameraStreamSharedBadgeSlotProps {
|
|
49
|
+
label: string;
|
|
50
|
+
/** Countdown template; `{{time}}` is replaced with `mm:ss`. */
|
|
51
|
+
remainingLabel: string;
|
|
52
|
+
/** When the owner's requested duration runs out; absent when unknown. */
|
|
53
|
+
endsAt?: string;
|
|
54
|
+
}
|
|
47
55
|
export interface CameraStreamPhaseIdleSlotProps {
|
|
48
56
|
playerKey: PlayerKey;
|
|
49
57
|
onPlay: () => void;
|
|
@@ -94,6 +102,19 @@ export interface CameraStreamPhaseStreamingSlotProps {
|
|
|
94
102
|
* custom streaming views may use it or ignore it.
|
|
95
103
|
*/
|
|
96
104
|
ReplayBadgeSlot: ElementType<CameraStreamReplayBadgeSlotProps>;
|
|
105
|
+
/**
|
|
106
|
+
* The active `sharedBadge` slot resolved by the router. Default streaming
|
|
107
|
+
* view mounts it when `attached === true`.
|
|
108
|
+
*/
|
|
109
|
+
SharedBadgeSlot: ElementType<CameraStreamSharedBadgeSlotProps>;
|
|
110
|
+
/** The session belongs to another operator; we joined it. */
|
|
111
|
+
attached?: boolean;
|
|
112
|
+
/** When the owner's requested duration runs out. */
|
|
113
|
+
endsAt?: string;
|
|
114
|
+
/** Localized name of the shared-session state. */
|
|
115
|
+
sharedLabel: string;
|
|
116
|
+
/** Countdown template for the shared session (`{{time}}` → `mm:ss`). */
|
|
117
|
+
sharedRemainingLabel: string;
|
|
97
118
|
/**
|
|
98
119
|
* Which vendor skin the tile's player wears. Left to the consumer on purpose:
|
|
99
120
|
* a dense wall of tiles usually wants `'minimal'`, while a single large tile
|
|
@@ -134,6 +155,7 @@ export interface CameraStreamSlots {
|
|
|
134
155
|
label?: ElementType<CameraStreamLabelSlotProps>;
|
|
135
156
|
liveBadge?: ElementType<CameraStreamLiveBadgeSlotProps>;
|
|
136
157
|
replayBadge?: ElementType<CameraStreamReplayBadgeSlotProps>;
|
|
158
|
+
sharedBadge?: ElementType<CameraStreamSharedBadgeSlotProps>;
|
|
137
159
|
phaseIdle?: ElementType<CameraStreamPhaseIdleSlotProps>;
|
|
138
160
|
phaseRequesting?: ElementType<CameraStreamPhaseRequestingSlotProps>;
|
|
139
161
|
phasePolling?: ElementType<CameraStreamPhasePollingSlotProps>;
|
|
@@ -153,6 +175,7 @@ export interface CameraStreamSlotProps {
|
|
|
153
175
|
label?: Partial<CameraStreamLabelSlotProps> & Record<string, unknown>;
|
|
154
176
|
liveBadge?: Partial<CameraStreamLiveBadgeSlotProps> & Record<string, unknown>;
|
|
155
177
|
replayBadge?: Partial<CameraStreamReplayBadgeSlotProps> & Record<string, unknown>;
|
|
178
|
+
sharedBadge?: Partial<CameraStreamSharedBadgeSlotProps> & Record<string, unknown>;
|
|
156
179
|
phaseIdle?: Partial<CameraStreamPhaseIdleSlotProps> & Record<string, unknown>;
|
|
157
180
|
phaseRequesting?: Partial<CameraStreamPhaseRequestingSlotProps> & Record<string, unknown>;
|
|
158
181
|
phasePolling?: Partial<CameraStreamPhasePollingSlotProps> & Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStream/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,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E,OAAO,CAAC,CAAC;IAC1F,YAAY,CAAC,EAAE,OAAO,CAAC,iCAAiC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpF,cAAc,CAAC,EAAE,OAAO,CAAC,mCAAmC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxF,gBAAgB,CAAC,EAAE,OAAO,CAAC,qCAAqC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAC,+BAA+B,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChF,YAAY,CAAC,EAAE,OAAO,CAAC,iCAAiC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CACrD,2BAA2B,EAC3B,OAAO,qCAAqC,EAC5C,KAAK,CACN,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStream/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBA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B,CAAC;AAEhF;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CACrD,2BAA2B,EAC3B,OAAO,qCAAqC,EAC5C,KAAK,CACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStreams/dictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,gBAE/C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick/src/components/CameraStreams/dictionary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,gBAE/C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,mBAAmB,EAAE,MAAM,CAsB3E,CAAC;AAEX;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAChC,mBAAmB,CAwBrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const r = "camera_streams",
|
|
1
|
+
const r = "camera_streams", l = () => [r], e = {
|
|
2
2
|
loadingStream: `${r}.label_loading_stream`,
|
|
3
3
|
streamError: `${r}.label_stream_error`,
|
|
4
4
|
startAll: `${r}.label_start_all`,
|
|
@@ -8,6 +8,8 @@ const r = "camera_streams", e = () => [r], n = {
|
|
|
8
8
|
replayChannel: `${r}.label_replay_channel`,
|
|
9
9
|
channelLabel: `${r}.label_channel`,
|
|
10
10
|
channelBusy: `${r}.label_channel_busy`,
|
|
11
|
+
sharedSession: `${r}.label_shared_session`,
|
|
12
|
+
sharedSessionRemaining: `${r}.label_shared_session_remaining`,
|
|
11
13
|
pollingQueued: `${r}.label_polling_queued`,
|
|
12
14
|
pollingDispatching: `${r}.label_polling_dispatching`,
|
|
13
15
|
pollingTranscoding: `${r}.label_polling_transcoding`,
|
|
@@ -19,31 +21,33 @@ const r = "camera_streams", e = () => [r], n = {
|
|
|
19
21
|
requestErrorMaxRetriesDesc: `${r}.label_request_error_max_retries_desc`,
|
|
20
22
|
playerErrorPlayback: `${r}.label_player_error_playback`
|
|
21
23
|
};
|
|
22
|
-
function a(
|
|
24
|
+
function a(n) {
|
|
23
25
|
return {
|
|
24
|
-
loadingStream:
|
|
25
|
-
streamError:
|
|
26
|
-
startAll:
|
|
27
|
-
stopAll:
|
|
28
|
-
startChannel:
|
|
29
|
-
stopChannel:
|
|
30
|
-
replayChannel:
|
|
31
|
-
channelLabel:
|
|
32
|
-
channelBusy:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
loadingStream: n(e.loadingStream),
|
|
27
|
+
streamError: n(e.streamError),
|
|
28
|
+
startAll: n(e.startAll),
|
|
29
|
+
stopAll: n(e.stopAll),
|
|
30
|
+
startChannel: n(e.startChannel),
|
|
31
|
+
stopChannel: n(e.stopChannel),
|
|
32
|
+
replayChannel: n(e.replayChannel),
|
|
33
|
+
channelLabel: n(e.channelLabel),
|
|
34
|
+
channelBusy: n(e.channelBusy),
|
|
35
|
+
sharedSession: n(e.sharedSession),
|
|
36
|
+
sharedSessionRemaining: n(e.sharedSessionRemaining),
|
|
37
|
+
pollingQueued: n(e.pollingQueued),
|
|
38
|
+
pollingDispatching: n(e.pollingDispatching),
|
|
39
|
+
pollingTranscoding: n(e.pollingTranscoding),
|
|
40
|
+
pollingExtended: n(e.pollingExtended),
|
|
41
|
+
pollingLastAttempts: n(e.pollingLastAttempts),
|
|
42
|
+
requestErrorUnknown: n(e.requestErrorUnknown),
|
|
43
|
+
requestErrorUnknownPolling: n(e.requestErrorUnknownPolling),
|
|
44
|
+
requestErrorMaxRetries: n(e.requestErrorMaxRetries),
|
|
45
|
+
requestErrorMaxRetriesDesc: n(e.requestErrorMaxRetriesDesc),
|
|
46
|
+
playerErrorPlayback: n(e.playerErrorPlayback)
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
e as CAMERA_STREAMS_DICTIONARY_KEYS,
|
|
51
|
+
l as getCameraStreamsComponentDictionary,
|
|
48
52
|
a as resolveCameraStreamsDictionaryLabels
|
|
49
53
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { PlayerKey } from '../types';
|
|
2
2
|
interface UseStreamPollingArgs {
|
|
3
3
|
playerKey: PlayerKey;
|
|
4
|
-
/**
|
|
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
|
+
*/
|
|
5
8
|
commandUuid: string | undefined;
|
|
6
9
|
/** Command coordinates captured from the POST response. */
|
|
7
10
|
deviceId: number | null;
|
|
@@ -10,8 +13,11 @@ interface UseStreamPollingArgs {
|
|
|
10
13
|
endProgress: () => void;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
|
-
* Poll
|
|
14
|
-
*
|
|
16
|
+
* Poll for one player until its stream settles, publishing both the outcome
|
|
17
|
+
* and the intermediate waiting stage into the store. The source depends on
|
|
18
|
+
* who owns the stream: `devices/command` for a command of ours, or
|
|
19
|
+
* `video/streams/:uuid` for a session started by somebody else that the tile
|
|
20
|
+
* joined. Both share the budget deadline and the stage timeline.
|
|
15
21
|
*
|
|
16
22
|
* Split out of `useStreamRequest` so that hook owns only the POST and this one
|
|
17
23
|
* owns the wait: they have different lifetimes (the POST fires once, the poll
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamPolling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/gclick/src/components/CameraStreams/hooks/useStreamPolling.ts"],"names":[],"mappings":"
|
|
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,58 +1,67 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { useNetwork as
|
|
4
|
-
import { extractHlsUrlFromResponse as
|
|
5
|
-
import { resolvePollInterval as
|
|
6
|
-
import { pendingStageBoundaries as
|
|
7
|
-
import { useCameraStreamsStore as
|
|
8
|
-
import { useCloudFrontCookieManager as
|
|
9
|
-
const
|
|
1
|
+
import { useRef as x, useEffect as k } from "react";
|
|
2
|
+
import { useQuery as A } from "@tanstack/react-query";
|
|
3
|
+
import { useNetwork as D } from "@m4l/core";
|
|
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
|
+
return !!t.hlsUrl || t.status === "error";
|
|
17
|
+
}
|
|
18
|
+
function W({ createdAt: t, requestedDuration: c }) {
|
|
19
|
+
if (typeof c != "number")
|
|
20
|
+
return;
|
|
21
|
+
const h = new Date(t).getTime() + c * 1e3;
|
|
22
|
+
return Number.isFinite(h) ? new Date(h).toISOString() : void 0;
|
|
23
|
+
}
|
|
24
|
+
function X({
|
|
16
25
|
playerKey: t,
|
|
17
|
-
commandUuid:
|
|
18
|
-
deviceId:
|
|
19
|
-
createdAt:
|
|
20
|
-
endProgress:
|
|
26
|
+
commandUuid: c,
|
|
27
|
+
deviceId: h,
|
|
28
|
+
createdAt: v,
|
|
29
|
+
endProgress: o
|
|
21
30
|
}) {
|
|
22
|
-
const { networkOperation:
|
|
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);
|
|
23
32
|
l.current = i;
|
|
24
|
-
const
|
|
25
|
-
queryKey: ["cameraStreamRequest", t,
|
|
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],
|
|
26
35
|
/**
|
|
27
36
|
* Poll `devices/command` until the command associated with this player's
|
|
28
37
|
* `commandUuid` reaches a terminal status.
|
|
29
38
|
*/
|
|
30
|
-
queryFn: async () => !
|
|
39
|
+
queryFn: async () => !c || h === null || !v ? null : U({
|
|
31
40
|
method: "GET",
|
|
32
|
-
endPoint:
|
|
41
|
+
endPoint: O,
|
|
33
42
|
parms: {
|
|
34
|
-
deviceId:
|
|
35
|
-
createdAt:
|
|
36
|
-
uuid:
|
|
43
|
+
deviceId: h,
|
|
44
|
+
createdAt: v,
|
|
45
|
+
uuid: c
|
|
37
46
|
},
|
|
38
47
|
toastError: !1,
|
|
39
48
|
toastSuccess: !1,
|
|
40
49
|
responseToCamelCase: !0
|
|
41
50
|
}),
|
|
42
|
-
enabled: !!
|
|
51
|
+
enabled: !!c && S,
|
|
43
52
|
/**
|
|
44
53
|
* Staged interval from `helpers/pollSchedule.ts`. Returns `false` once the
|
|
45
54
|
* backend reports a terminal status or the budget is spent.
|
|
46
55
|
*/
|
|
47
56
|
refetchInterval: (e) => {
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
57
|
+
const r = e.state.data?.data?.statusId ?? "";
|
|
58
|
+
if (G.has(r))
|
|
50
59
|
return !1;
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
60
|
+
const s = l.current;
|
|
61
|
+
if (s?.phase.kind !== "polling")
|
|
53
62
|
return !1;
|
|
54
|
-
const a =
|
|
55
|
-
return
|
|
63
|
+
const a = s.phase.startedAt;
|
|
64
|
+
return R((Date.now() - a) / 1e3, d);
|
|
56
65
|
},
|
|
57
66
|
retry: !1,
|
|
58
67
|
refetchOnWindowFocus: !1,
|
|
@@ -63,92 +72,145 @@ function W({
|
|
|
63
72
|
// and the tile comes back frozen on a stale phase.
|
|
64
73
|
refetchIntervalInBackground: !0,
|
|
65
74
|
staleTime: 1 / 0
|
|
75
|
+
}), { data: w, error: C } = A({
|
|
76
|
+
queryKey: ["cameraStreamAttached", t, E],
|
|
77
|
+
/** Read the joined stream until it exposes an `hlsUrl` or fails. */
|
|
78
|
+
queryFn: async () => E ? U({
|
|
79
|
+
method: "GET",
|
|
80
|
+
endPoint: `${_}/${E}`,
|
|
81
|
+
toastError: !1,
|
|
82
|
+
toastSuccess: !1,
|
|
83
|
+
responseToCamelCase: !0
|
|
84
|
+
}) : null,
|
|
85
|
+
enabled: !!E,
|
|
86
|
+
/** Same staged cadence and budget cut-off as the command poll. */
|
|
87
|
+
refetchInterval: (e) => {
|
|
88
|
+
const r = e.state.data?.data;
|
|
89
|
+
if (r && V(r))
|
|
90
|
+
return !1;
|
|
91
|
+
const s = l.current;
|
|
92
|
+
return s?.phase.kind !== "polling" ? !1 : R((Date.now() - s.phase.startedAt) / 1e3, d);
|
|
93
|
+
},
|
|
94
|
+
retry: !1,
|
|
95
|
+
refetchOnWindowFocus: !1,
|
|
96
|
+
refetchOnReconnect: !1,
|
|
97
|
+
refetchOnMount: !1,
|
|
98
|
+
refetchIntervalInBackground: !0,
|
|
99
|
+
staleTime: 1 / 0
|
|
66
100
|
});
|
|
67
|
-
|
|
68
|
-
if (!
|
|
101
|
+
k(() => {
|
|
102
|
+
if (!S)
|
|
69
103
|
return;
|
|
70
104
|
const e = setTimeout(() => {
|
|
71
|
-
l.current?.phase.kind === "polling" && (
|
|
72
|
-
},
|
|
105
|
+
l.current?.phase.kind === "polling" && (n(t, { kind: "timeout" }), o());
|
|
106
|
+
}, d * 1e3);
|
|
73
107
|
return () => {
|
|
74
108
|
clearTimeout(e);
|
|
75
109
|
};
|
|
76
|
-
}, [
|
|
77
|
-
if (
|
|
110
|
+
}, [S, t, d, n, o]), k(() => {
|
|
111
|
+
if (I === null)
|
|
78
112
|
return;
|
|
79
|
-
const e = (Date.now() -
|
|
80
|
-
({ stage:
|
|
81
|
-
const
|
|
82
|
-
|
|
113
|
+
const e = (Date.now() - I) / 1e3, r = P(e, d).map(
|
|
114
|
+
({ stage: s, delayMs: a }) => setTimeout(() => {
|
|
115
|
+
const m = l.current;
|
|
116
|
+
m?.phase.kind === "polling" && n(t, { ...m.phase, stage: s });
|
|
83
117
|
}, a)
|
|
84
118
|
);
|
|
85
119
|
return () => {
|
|
86
|
-
|
|
120
|
+
r.forEach(clearTimeout);
|
|
87
121
|
};
|
|
88
|
-
}, [
|
|
89
|
-
const e =
|
|
122
|
+
}, [I, t, d, n]), k(() => {
|
|
123
|
+
const e = b?.data;
|
|
90
124
|
if (!e)
|
|
91
125
|
return;
|
|
92
|
-
const
|
|
93
|
-
if (!(!
|
|
126
|
+
const r = l.current;
|
|
127
|
+
if (!(!r || r.phase.kind !== "polling")) {
|
|
94
128
|
if (e.statusId === "executed") {
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
|
|
129
|
+
const s = F(e.response);
|
|
130
|
+
if (!s) {
|
|
131
|
+
n(t, { kind: "error", code: "missing-hls-url", message: u.playerErrorPlayback }), o();
|
|
98
132
|
return;
|
|
99
133
|
}
|
|
100
|
-
const { commandUuid: a, streamUuid:
|
|
101
|
-
|
|
134
|
+
const { commandUuid: a, streamUuid: m } = r.phase, p = () => {
|
|
135
|
+
n(t, {
|
|
102
136
|
kind: "streaming",
|
|
103
137
|
commandUuid: a,
|
|
104
|
-
streamUuid:
|
|
105
|
-
hlsUrl:
|
|
106
|
-
}),
|
|
138
|
+
streamUuid: m,
|
|
139
|
+
hlsUrl: s
|
|
140
|
+
}), o();
|
|
107
141
|
};
|
|
108
|
-
|
|
142
|
+
g().then(p).catch(p);
|
|
109
143
|
return;
|
|
110
144
|
}
|
|
111
145
|
if (e.statusId === "channel_busy") {
|
|
112
|
-
|
|
146
|
+
n(t, { kind: "channelBusy" }), o();
|
|
113
147
|
return;
|
|
114
148
|
}
|
|
115
149
|
if (e.statusId === "error") {
|
|
116
|
-
const
|
|
150
|
+
const s = q(e.response, {
|
|
117
151
|
error: { origin: "", message: "", status: 0, agent: "" },
|
|
118
152
|
body: ""
|
|
119
|
-
}), a =
|
|
120
|
-
|
|
153
|
+
}), a = B(s, u.playerErrorPlayback);
|
|
154
|
+
n(t, {
|
|
121
155
|
kind: "error",
|
|
122
156
|
code: "remote-error",
|
|
123
157
|
message: a
|
|
124
|
-
}),
|
|
158
|
+
}), o();
|
|
125
159
|
return;
|
|
126
160
|
}
|
|
127
161
|
if (e.statusId === "error_retries_max") {
|
|
128
|
-
|
|
162
|
+
n(t, { kind: "timeout" }), o();
|
|
129
163
|
return;
|
|
130
164
|
}
|
|
131
165
|
}
|
|
132
166
|
}, [
|
|
133
|
-
|
|
167
|
+
b,
|
|
134
168
|
t,
|
|
135
169
|
u.playerErrorPlayback,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]),
|
|
140
|
-
|
|
170
|
+
g,
|
|
171
|
+
n,
|
|
172
|
+
o
|
|
173
|
+
]), k(() => {
|
|
174
|
+
const e = w?.data;
|
|
175
|
+
if (!e)
|
|
141
176
|
return;
|
|
142
|
-
const
|
|
143
|
-
r
|
|
177
|
+
const r = l.current;
|
|
178
|
+
if (!(!r || r.phase.kind !== "polling")) {
|
|
179
|
+
if (e.hlsUrl) {
|
|
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();
|
|
182
|
+
};
|
|
183
|
+
g().then(p).catch(p);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
e.status === "error" && (n(t, {
|
|
187
|
+
kind: "error",
|
|
188
|
+
code: "attached-stream-failed",
|
|
189
|
+
message: u.playerErrorPlayback
|
|
190
|
+
}), o());
|
|
191
|
+
}
|
|
144
192
|
}, [
|
|
193
|
+
w,
|
|
194
|
+
t,
|
|
195
|
+
u.playerErrorPlayback,
|
|
145
196
|
g,
|
|
197
|
+
n,
|
|
198
|
+
o
|
|
199
|
+
]), k(() => {
|
|
200
|
+
const e = T ?? C;
|
|
201
|
+
if (!e)
|
|
202
|
+
return;
|
|
203
|
+
const r = M(e, u.requestErrorUnknownPolling);
|
|
204
|
+
n(t, { kind: "error", code: "polling-failed", message: r }), o();
|
|
205
|
+
}, [
|
|
206
|
+
T,
|
|
207
|
+
C,
|
|
146
208
|
t,
|
|
147
209
|
u.requestErrorUnknownPolling,
|
|
148
|
-
|
|
149
|
-
|
|
210
|
+
n,
|
|
211
|
+
o
|
|
150
212
|
]);
|
|
151
213
|
}
|
|
152
214
|
export {
|
|
153
|
-
|
|
215
|
+
X as useStreamPolling
|
|
154
216
|
};
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { useRef as
|
|
1
|
+
import { useRef as n, useCallback as P, useEffect as k } from "react";
|
|
2
2
|
import { useMutation as I } from "@tanstack/react-query";
|
|
3
|
-
import { useWindowToolsMF as
|
|
4
|
-
import { useNetwork as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
import { useWindowToolsMF as R } from "@m4l/components";
|
|
4
|
+
import { useNetwork as U } from "@m4l/core";
|
|
5
|
+
import { isAttachedStreamResponse as q } from "../model.js";
|
|
6
|
+
import { isBusyStreamError as T, extractErrorMessage as F } from "../helpers/commandError.js";
|
|
7
|
+
import { useCameraStreamsStore as s } from "./useCameraStreamsStore.js";
|
|
8
|
+
import { useStreamPolling as M } from "./useStreamPolling.js";
|
|
9
|
+
function z({ playerKey: t }) {
|
|
10
|
+
const { startProgress: l, stopProgress: a } = R(), { networkOperation: b } = U(), o = s((e) => e.players[t]), h = s((e) => e.labels), S = s((e) => e.config.endpointVideoPlay), w = s((e) => e.config.endpointVideoPlayback), c = s((e) => e.actions.setPhase), u = n(o);
|
|
11
|
+
u.current = o;
|
|
12
|
+
const i = n(!1), f = n(a);
|
|
13
|
+
f.current = a;
|
|
14
|
+
const A = P(() => {
|
|
15
|
+
i.current = !0, l();
|
|
16
|
+
}, [l]), p = P(() => {
|
|
17
|
+
i.current = !1, a();
|
|
18
|
+
}, [a]);
|
|
19
|
+
k(() => () => {
|
|
20
|
+
i.current && (i.current = !1, f.current());
|
|
20
21
|
}, []);
|
|
21
|
-
const
|
|
22
|
+
const C = u.current?.mode === "playback" ? w : S, g = o?.phase.kind, v = o?.phase.kind === "polling" ? o.phase.commandUuid : void 0, d = n(null), m = n(null), { mutate: y } = I({
|
|
22
23
|
/**
|
|
23
24
|
* Build and submit the stream request for the current player. Snake-case
|
|
24
25
|
* conversion is mandatory: stream endpoints validate `device_id`,
|
|
@@ -26,22 +27,22 @@ function W({ playerKey: t }) {
|
|
|
26
27
|
* drop unknown camelCase keys.
|
|
27
28
|
*/
|
|
28
29
|
mutationFn: async () => {
|
|
29
|
-
const e =
|
|
30
|
+
const e = u.current;
|
|
30
31
|
if (!e)
|
|
31
32
|
throw new Error("player-not-loaded");
|
|
32
|
-
const
|
|
33
|
+
const r = {
|
|
33
34
|
deviceId: e.unitId,
|
|
34
35
|
channelId: Number(e.channelId),
|
|
35
36
|
duration: e.durationSeconds
|
|
36
37
|
}, E = e.mode === "playback" && e.playbackParams ? {
|
|
37
|
-
...
|
|
38
|
+
...r,
|
|
38
39
|
beginTime: e.playbackParams.beginTime,
|
|
39
40
|
uuid: e.playbackParams.sourceCommandUuid,
|
|
40
41
|
createdAt: e.playbackParams.sourceCommandCreatedAt
|
|
41
|
-
} :
|
|
42
|
-
return
|
|
42
|
+
} : { ...r, allowAttach: !0 };
|
|
43
|
+
return b({
|
|
43
44
|
method: "POST",
|
|
44
|
-
endPoint:
|
|
45
|
+
endPoint: C,
|
|
45
46
|
toastError: !1,
|
|
46
47
|
toastSuccess: !1,
|
|
47
48
|
responseToCamelCase: !0,
|
|
@@ -49,16 +50,23 @@ function W({ playerKey: t }) {
|
|
|
49
50
|
data: E
|
|
50
51
|
});
|
|
51
52
|
},
|
|
52
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Move to `polling`. Two shapes land here: a stream created for us, which
|
|
55
|
+
* carries the command to follow, and one we joined, which does not — that
|
|
56
|
+
* one is followed through `video/streams/:uuid` by `useStreamPolling`.
|
|
57
|
+
*/
|
|
53
58
|
onSuccess: (e) => {
|
|
54
|
-
|
|
59
|
+
A();
|
|
60
|
+
const r = { stage: "queued", startedAt: Date.now() };
|
|
61
|
+
if (q(e)) {
|
|
62
|
+
m.current = null, d.current = null, c(t, { kind: "polling", streamUuid: e.stream.uuid, ...r });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
m.current = e.command.deviceId, d.current = e.command.createdAt, c(t, {
|
|
55
66
|
kind: "polling",
|
|
56
67
|
commandUuid: e.command.uuid,
|
|
57
68
|
streamUuid: e.stream.uuid,
|
|
58
|
-
|
|
59
|
-
// yet, so the wait starts as `queued` by definition.
|
|
60
|
-
stage: "queued",
|
|
61
|
-
startedAt: Date.now()
|
|
69
|
+
...r
|
|
62
70
|
});
|
|
63
71
|
},
|
|
64
72
|
/**
|
|
@@ -70,24 +78,24 @@ function W({ playerKey: t }) {
|
|
|
70
78
|
* toasts when several tiles are played simultaneously (grid play-all).
|
|
71
79
|
*/
|
|
72
80
|
onError: (e) => {
|
|
73
|
-
if (
|
|
74
|
-
|
|
81
|
+
if (p(), T(e)) {
|
|
82
|
+
c(t, { kind: "channelBusy" });
|
|
75
83
|
return;
|
|
76
84
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
85
|
+
const r = F(e, h.requestErrorUnknown);
|
|
86
|
+
c(t, { kind: "error", code: "request-failed", message: r });
|
|
79
87
|
}
|
|
80
88
|
});
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
}, [
|
|
89
|
+
return k(() => {
|
|
90
|
+
g === "requesting" && y();
|
|
91
|
+
}, [g, t]), M({
|
|
84
92
|
playerKey: t,
|
|
85
|
-
commandUuid:
|
|
86
|
-
deviceId:
|
|
87
|
-
createdAt:
|
|
88
|
-
endProgress:
|
|
93
|
+
commandUuid: v,
|
|
94
|
+
deviceId: m.current,
|
|
95
|
+
createdAt: d.current,
|
|
96
|
+
endProgress: p
|
|
89
97
|
}), void 0;
|
|
90
98
|
}
|
|
91
99
|
export {
|
|
92
|
-
|
|
100
|
+
z as useStreamRequest
|
|
93
101
|
};
|
|
@@ -31,6 +31,34 @@ export interface PostGenerateStreamResponse {
|
|
|
31
31
|
command: PostGenerateStreamCommand;
|
|
32
32
|
stream: PostGenerateStreamData;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Alternative response of `POST /operative/video/play` (HTTP 200) when the
|
|
36
|
+
* channel was already streaming and the request opted into `allowAttach`: the
|
|
37
|
+
* unit only sustains one session per channel, so instead of an error the caller
|
|
38
|
+
* joins the one already running. There is no command — nothing was asked of the
|
|
39
|
+
* unit — and the stream carries its original owner's duration.
|
|
40
|
+
*/
|
|
41
|
+
export interface PostAttachedStreamResponse {
|
|
42
|
+
attached: true;
|
|
43
|
+
stream: AttachedStreamData;
|
|
44
|
+
}
|
|
45
|
+
/** The already-running stream, as `video/streams/:uuid` also returns it. */
|
|
46
|
+
export interface AttachedStreamData extends PostGenerateStreamData {
|
|
47
|
+
status: 'loading' | 'success' | 'error';
|
|
48
|
+
requestedDuration: number;
|
|
49
|
+
hlsUrl?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Either a stream was created for us, or we joined one already in flight. */
|
|
52
|
+
export type PostStreamResponse = PostGenerateStreamResponse | PostAttachedStreamResponse;
|
|
53
|
+
/**
|
|
54
|
+
* Tell both `POST video/play` outcomes apart. A backend that predates the
|
|
55
|
+
* attach contract only ever answers the created shape, so this stays false.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isAttachedStreamResponse(response: PostStreamResponse): response is PostAttachedStreamResponse;
|
|
58
|
+
/** Single-row response of `GET /operative/video/streams/:uuid`. */
|
|
59
|
+
export interface VideoStreamResponse {
|
|
60
|
+
data: AttachedStreamData;
|
|
61
|
+
}
|
|
34
62
|
/**
|
|
35
63
|
* Single-row response from the `GET /operative/devices/command` polling
|
|
36
64
|
* endpoint. `statusId` is open-ended because the backend may evolve it;
|