@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.
Files changed (86) hide show
  1. package/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts +0 -4
  2. package/components/CameraStream/defaults/DefaultPhaseStreaming.d.ts.map +1 -1
  3. package/components/CameraStream/defaults/DefaultPhaseStreaming.js +33 -35
  4. package/components/CameraStreams/CameraStreamsProvider.d.ts +0 -5
  5. package/components/CameraStreams/CameraStreamsProvider.d.ts.map +1 -1
  6. package/components/CameraStreams/CameraStreamsProvider.js +11 -10
  7. package/components/CameraStreams/contexts/CameraStreamPlayersContext.d.ts +3 -7
  8. package/components/CameraStreams/contexts/CameraStreamPlayersContext.d.ts.map +1 -1
  9. package/components/CameraStreams/hooks/useStreamPolling.d.ts +11 -1
  10. package/components/CameraStreams/hooks/useStreamPolling.d.ts.map +1 -1
  11. package/components/CameraStreams/hooks/useStreamPolling.js +89 -84
  12. package/components/CameraStreams/hooks/useStreamRequest.d.ts +8 -7
  13. package/components/CameraStreams/hooks/useStreamRequest.d.ts.map +1 -1
  14. package/components/CameraStreams/hooks/useStreamRequest.js +50 -34
  15. package/components/CameraStreams/index.d.ts +0 -2
  16. package/components/CameraStreams/index.d.ts.map +1 -1
  17. package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.d.ts +18 -0
  18. package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.d.ts.map +1 -0
  19. package/components/CameraStreams/subcomponents/CameraStreamsSuspensionController.js +35 -0
  20. package/components/CameraStreams/types.d.ts +10 -23
  21. package/components/CameraStreams/types.d.ts.map +1 -1
  22. package/components/VideoPlayer/VideoPlayer.d.ts +3 -3
  23. package/components/VideoPlayer/VideoPlayer.d.ts.map +1 -1
  24. package/components/VideoPlayer/VideoPlayer.js +25 -29
  25. package/components/VideoPlayer/VideoPlayer.styles.d.ts.map +1 -1
  26. package/components/VideoPlayer/VideoPlayer.styles.js +6 -32
  27. package/components/VideoPlayer/VideojsDefaultSkin.styles.d.ts.map +1 -1
  28. package/components/VideoPlayer/VideojsDefaultSkin.styles.js +805 -934
  29. package/components/VideoPlayer/VideojsMinimalSkin.styles.d.ts.map +1 -1
  30. package/components/VideoPlayer/VideojsMinimalSkin.styles.js +807 -899
  31. package/components/VideoPlayer/constants.d.ts +0 -16
  32. package/components/VideoPlayer/constants.d.ts.map +1 -1
  33. package/components/VideoPlayer/constants.js +8 -27
  34. package/components/VideoPlayer/hlsConfig.d.ts +30 -0
  35. package/components/VideoPlayer/hlsConfig.d.ts.map +1 -0
  36. package/components/VideoPlayer/hlsConfig.js +33 -0
  37. package/components/VideoPlayer/hooks/usePlayerControl.d.ts +0 -6
  38. package/components/VideoPlayer/hooks/usePlayerControl.d.ts.map +1 -1
  39. package/components/VideoPlayer/hooks/usePlayerControl.js +25 -34
  40. package/components/VideoPlayer/hooks/usePlayerEvents.d.ts +1 -5
  41. package/components/VideoPlayer/hooks/usePlayerEvents.d.ts.map +1 -1
  42. package/components/VideoPlayer/hooks/usePlayerEvents.js +11 -10
  43. package/components/VideoPlayer/player.factory.d.ts +17 -24
  44. package/components/VideoPlayer/player.factory.d.ts.map +1 -1
  45. package/components/VideoPlayer/subcomponents/GclickVideoSkin.d.ts +2 -4
  46. package/components/VideoPlayer/subcomponents/GclickVideoSkin.d.ts.map +1 -1
  47. package/components/VideoPlayer/subcomponents/GclickVideoSkin.js +24 -36
  48. package/components/VideoPlayer/subcomponents/VideoPlayerStage.d.ts +3 -5
  49. package/components/VideoPlayer/subcomponents/VideoPlayerStage.d.ts.map +1 -1
  50. package/components/VideoPlayer/subcomponents/VideoPlayerStage.js +49 -64
  51. package/components/VideoPlayer/subcomponents/skin/VideoControlBar.d.ts +2 -14
  52. package/components/VideoPlayer/subcomponents/skin/VideoControlBar.d.ts.map +1 -1
  53. package/components/VideoPlayer/subcomponents/skin/VideoControlBar.js +62 -90
  54. package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.d.ts +0 -11
  55. package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.d.ts.map +1 -1
  56. package/components/VideoPlayer/subcomponents/skin/VideoErrorDialog.js +13 -16
  57. package/components/VideoPlayer/subcomponents/skin/VideoSettingsMenu.d.ts.map +1 -1
  58. package/components/VideoPlayer/subcomponents/skin/VideoSettingsMenu.js +12 -10
  59. package/components/VideoPlayer/subcomponents/skin/primitives.d.ts +2 -11
  60. package/components/VideoPlayer/subcomponents/skin/primitives.d.ts.map +1 -1
  61. package/components/VideoPlayer/subcomponents/skin/primitives.js +72 -74
  62. package/components/VideoPlayer/types.d.ts +5 -43
  63. package/components/VideoPlayer/types.d.ts.map +1 -1
  64. package/index.js +145 -149
  65. package/package.json +2 -4
  66. package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.d.ts +0 -15
  67. package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.d.ts.map +0 -1
  68. package/components/CameraStreams/contexts/CameraStreamsSuspensionContext.js +0 -5
  69. package/components/CameraStreams/hooks/useCameraStreamsSuspended.d.ts +0 -7
  70. package/components/CameraStreams/hooks/useCameraStreamsSuspended.d.ts.map +0 -1
  71. package/components/CameraStreams/hooks/useCameraStreamsSuspended.js +0 -8
  72. package/components/VideoPlayer/hlsSource.d.ts +0 -41
  73. package/components/VideoPlayer/hlsSource.d.ts.map +0 -1
  74. package/components/VideoPlayer/hlsSource.js +0 -35
  75. package/components/VideoPlayer/hooks/useMediaReadiness.d.ts +0 -22
  76. package/components/VideoPlayer/hooks/useMediaReadiness.d.ts.map +0 -1
  77. package/components/VideoPlayer/hooks/useMediaReadiness.js +0 -21
  78. package/components/VideoPlayer/hooks/usePlaybackIntent.d.ts +0 -14
  79. package/components/VideoPlayer/hooks/usePlaybackIntent.d.ts.map +0 -1
  80. package/components/VideoPlayer/hooks/usePlaybackIntent.js +0 -33
  81. package/components/VideoPlayer/storeSafety.d.ts +0 -15
  82. package/components/VideoPlayer/storeSafety.d.ts.map +0 -1
  83. package/components/VideoPlayer/storeSafety.js +0 -25
  84. package/components/VideoPlayer/subcomponents/skin/VideoInputIndicators.d.ts +0 -15
  85. package/components/VideoPlayer/subcomponents/skin/VideoInputIndicators.d.ts.map +0 -1
  86. 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":"AAUA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAcpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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,oDA0GrC"}
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 j, jsx as c } from "@emotion/react/jsx-runtime";
2
- import { useState as C, useRef as u, useContext as k, useEffect as l, useCallback as A } from "react";
3
- import { CameraStreamPlayersContext as v } from "../../CameraStreams/contexts/CameraStreamPlayersContext.js";
4
- import { useCameraStreamsSuspended as B } from "../../CameraStreams/hooks/useCameraStreamsSuspended.js";
5
- import { VideoPlayer as V } from "../../VideoPlayer/VideoPlayer.js";
6
- const U = 3, X = 2, Y = 2500;
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: m,
10
- ended: d,
11
- onEnded: f,
12
- onReplay: E,
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), [S, h] = C(0), p = u(null), n = k(v), F = B(), s = u(0), a = u(0), i = u(null);
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), h(0), s.current = 0, a.current = 0;
27
- }, [m]), l(() => () => {
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 = p.current;
29
+ const e = A.current;
31
30
  if (!(!n || !e))
32
31
  return n.register(t, e), () => n.unregister(t);
33
- }, [n, t, S]);
34
- const O = A((e, o) => {
35
- r(o), !o && Number.isFinite(e) && (s.current = e), R(e, o);
36
- }, [R]), I = A(() => {
37
- if (s.current < U && a.current < X) {
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
- s.current = 0, h((N) => N + 1);
40
- }, Y);
38
+ o.current = 0, S((I) => I + 1);
39
+ }, U);
41
40
  return;
42
41
  }
43
- r(!1), f();
44
- }, [f]);
45
- return /* @__PURE__ */ j("div", { "data-stream-player-key": t, style: { width: "100%", height: "100%" }, children: [
46
- b && !d && /* @__PURE__ */ c(D, {}),
47
- d && /* @__PURE__ */ c(P, { onReplay: E, replayLabel: _ }),
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
- V,
56
+ v,
58
57
  {
59
- ref: p,
60
- src: m,
61
- suspended: F,
58
+ ref: A,
59
+ src: f,
62
60
  variant: g,
63
- onDurationChange: O,
64
- onEnded: I
61
+ onDurationChange: F,
62
+ onEnded: O
65
63
  },
66
- S
64
+ h
67
65
  )
68
66
  ] });
69
67
  }
70
68
  export {
71
- Q as DefaultPhaseStreaming
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;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,oDAmCtE"}
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 u } from "@m4l/core";
4
- import { resolveCameraStreamsDictionaryLabels as f } from "./dictionary.js";
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 d } from "./contexts/CameraStreamPlayersContext.js";
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 v } from "./helpers/createCameraStreamPlayersRegistry.js";
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: i, suspended: s = !1, ...n } = a, { getLabel: l } = u(), r = o(null);
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
- ...f(l),
17
- ...i ?? {}
16
+ ...u(l),
17
+ ...s ?? {}
18
18
  }
19
19
  }));
20
20
  const e = o(null);
21
- return e.current || (e.current = v()), /* @__PURE__ */ t(p.Provider, { value: r.current, children: /* @__PURE__ */ t(d.Provider, { value: e.current, children: /* @__PURE__ */ c(C.Provider, { value: s, children: [
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, so a consumer holding a snapshot of the
28
- * registry can keep it current as players mount and unmount.
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;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,6DACkB,CAAC"}
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;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE,oBAAoB,GAAG,IAAI,CA0T1E"}
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 R, useEffect as k } from "react";
2
- import { useQuery as b } from "@tanstack/react-query";
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 O, safeParseJson as _, resolveCommandErrorMessage as x, extractErrorMessage as F } from "../helpers/commandError.js";
5
- import { resolvePollInterval as T } from "../helpers/pollSchedule.js";
6
- import { pendingStageBoundaries as q } from "../helpers/waitingStages.js";
7
- import { useCameraStreamsStore as h } from "./useCameraStreamsStore.js";
8
- import { useCloudFrontCookieManager as B } from "./useCloudFrontCookie.js";
9
- const M = /* @__PURE__ */ new Set([
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 N(t) {
15
+ function V(t) {
16
16
  return !!t.hlsUrl || t.status === "error";
17
17
  }
18
- function G({ createdAt: t, requestedDuration: p }) {
19
- if (typeof p != "number")
18
+ function W({ createdAt: t, requestedDuration: c }) {
19
+ if (typeof c != "number")
20
20
  return;
21
- const i = new Date(t).getTime() + p * 1e3;
22
- return Number.isFinite(i) ? new Date(i).toISOString() : void 0;
21
+ const h = new Date(t).getTime() + c * 1e3;
22
+ return Number.isFinite(h) ? new Date(h).toISOString() : void 0;
23
23
  }
24
- function y({ playerKey: t }) {
25
- const { networkOperation: p } = D(), { ensureCookies: i } = B(), o = h((e) => e.players[t]), c = h((e) => e.labels), C = h((e) => e.config.endpointDevicesCommand), w = h((e) => e.config.endpointVideoStreams), l = h((e) => e.config.pollBudgetSeconds), n = h((e) => e.actions.setPhase), d = R(o);
26
- d.current = o;
27
- const m = o?.phase.kind === "polling", I = m && o.phase.kind === "polling" ? o.phase.startedAt : null, u = m && o.phase.kind === "polling" ? {
28
- uuid: o.phase.commandUuid,
29
- deviceId: o.phase.commandDeviceId,
30
- createdAt: o.phase.commandCreatedAt
31
- } : void 0, S = u?.uuid, v = m && o.phase.kind === "polling" && !S ? o.phase.streamUuid : void 0, { data: E, error: U } = b({
32
- queryKey: ["cameraStreamRequest", t, S],
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 () => !u?.uuid || u.deviceId === void 0 || !u.createdAt ? null : p({
39
+ queryFn: async () => !c || h === null || !v ? null : U({
38
40
  method: "GET",
39
- endPoint: C,
41
+ endPoint: O,
40
42
  parms: {
41
- deviceId: u.deviceId,
42
- createdAt: u.createdAt,
43
- uuid: u.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: !!S && m,
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 (M.has(r))
58
+ if (G.has(r))
57
59
  return !1;
58
- const s = d.current;
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 T((Date.now() - a) / 1e3, l);
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: P, error: A } = b({
74
- queryKey: ["cameraStreamAttached", t, v],
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 () => v ? p({
78
+ queryFn: async () => E ? U({
77
79
  method: "GET",
78
- endPoint: `${w}/${v}`,
80
+ endPoint: `${_}/${E}`,
79
81
  toastError: !1,
80
82
  toastSuccess: !1,
81
83
  responseToCamelCase: !0
82
84
  }) : null,
83
- enabled: !!v,
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 && N(r))
89
+ if (r && V(r))
88
90
  return !1;
89
- const s = d.current;
90
- return s?.phase.kind !== "polling" ? !1 : T((Date.now() - s.phase.startedAt) / 1e3, l);
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 (!m)
102
+ if (!S)
101
103
  return;
102
104
  const e = setTimeout(() => {
103
- d.current?.phase.kind === "polling" && n(t, { kind: "timeout" });
104
- }, l * 1e3);
105
+ l.current?.phase.kind === "polling" && (n(t, { kind: "timeout" }), o());
106
+ }, d * 1e3);
105
107
  return () => {
106
108
  clearTimeout(e);
107
109
  };
108
- }, [m, t, l, n]), k(() => {
110
+ }, [S, t, d, n, o]), k(() => {
109
111
  if (I === null)
110
112
  return;
111
- const e = (Date.now() - I) / 1e3, r = q(e, l).map(
113
+ const e = (Date.now() - I) / 1e3, r = P(e, d).map(
112
114
  ({ stage: s, delayMs: a }) => setTimeout(() => {
113
- const f = d.current;
114
- f?.phase.kind === "polling" && n(t, { ...f.phase, stage: s });
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, l, n]), k(() => {
121
- const e = E?.data;
122
+ }, [I, t, d, n]), k(() => {
123
+ const e = b?.data;
122
124
  if (!e)
123
125
  return;
124
- const r = d.current;
126
+ const r = l.current;
125
127
  if (!(!r || r.phase.kind !== "polling")) {
126
128
  if (e.statusId === "executed") {
127
- const s = O(e.response);
129
+ const s = F(e.response);
128
130
  if (!s) {
129
- n(t, { kind: "error", code: "missing-hls-url", message: c.playerErrorPlayback });
131
+ n(t, { kind: "error", code: "missing-hls-url", message: u.playerErrorPlayback }), o();
130
132
  return;
131
133
  }
132
- const { commandUuid: a, streamUuid: f } = r.phase, g = () => {
134
+ const { commandUuid: a, streamUuid: m } = r.phase, p = () => {
133
135
  n(t, {
134
136
  kind: "streaming",
135
137
  commandUuid: a,
136
- streamUuid: f,
138
+ streamUuid: m,
137
139
  hlsUrl: s
138
- });
140
+ }), o();
139
141
  };
140
- i().then(g).catch(g);
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 = _(e.response, {
150
+ const s = q(e.response, {
149
151
  error: { origin: "", message: "", status: 0, agent: "" },
150
152
  body: ""
151
- }), a = x(s, c.playerErrorPlayback);
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
- E,
167
+ b,
166
168
  t,
167
- c.playerErrorPlayback,
168
- i,
169
- n
169
+ u.playerErrorPlayback,
170
+ g,
171
+ n,
172
+ o
170
173
  ]), k(() => {
171
- const e = P?.data;
174
+ const e = w?.data;
172
175
  if (!e)
173
176
  return;
174
- const r = d.current;
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, f = G(e), g = () => {
178
- n(t, { kind: "streaming", streamUuid: s, hlsUrl: a, attached: !0, endsAt: f });
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
- i().then(g).catch(g);
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: c.playerErrorPlayback
187
- });
189
+ message: u.playerErrorPlayback
190
+ }), o());
188
191
  }
189
192
  }, [
190
- P,
193
+ w,
191
194
  t,
192
- c.playerErrorPlayback,
193
- i,
194
- n
195
+ u.playerErrorPlayback,
196
+ g,
197
+ n,
198
+ o
195
199
  ]), k(() => {
196
- const e = U ?? A;
200
+ const e = T ?? C;
197
201
  if (!e)
198
202
  return;
199
- const r = F(e, c.requestErrorUnknownPolling);
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
- U,
203
- A,
206
+ T,
207
+ C,
204
208
  t,
205
- c.requestErrorUnknownPolling,
206
- n
209
+ u.requestErrorUnknownPolling,
210
+ n,
211
+ o
207
212
  ]);
208
213
  }
209
214
  export {
210
- y as useStreamPolling
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
- * One instance per `playerKey`, mounted by `<CameraStreamsEngine>` for as long
10
- * as the player slice exists — including while it sits `idle`. No network work
11
- * happens outside `requesting` / `polling`.
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
- * It deliberately owns no module-level busy indicator; the tile's own
14
- * `requesting` / `polling` phases are the wait. See the README gotcha for why
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":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAgI9E"}
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"}