@clockworkdog/cogs-client-react 2.10.1 → 2.11.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/dist/index.d.ts CHANGED
@@ -13,7 +13,6 @@ export { default as useWhenShowReset } from './hooks/useWhenShowReset';
13
13
  export * from './utils/types';
14
14
  export { default as useAudioClips } from './hooks/useAudioClips';
15
15
  export { default as useIsAudioPlaying } from './hooks/useIsAudioPlaying';
16
- export { default as RtspVideo, RtspVideoProps } from './components/RtspVideo';
17
16
  export { default as VideoContainer } from './components/VideoContainer';
18
17
  export { default as useHint } from './hooks/useHint';
19
18
  export { default as Hint } from './components/Hint';
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Images = exports.useImages = exports.Timer = exports.Hint = exports.useHint = exports.VideoContainer = exports.RtspVideo = exports.useIsAudioPlaying = exports.useAudioClips = exports.useWhenShowReset = exports.useShowPhase = exports.usePreloadedUrl = exports.useCogsMessage = exports.useCogsStateValues = exports.useCogsStateValue = exports.useCogsMediaConfig = exports.useCogsEvents = exports.useCogsEvent = exports.useCogsConfig = exports.useIsConnected = exports.useVideoPlayer = exports.useAudioPlayer = exports.useCogsConnection = exports.CogsConnectionProvider = void 0;
20
+ exports.Images = exports.useImages = exports.Timer = exports.Hint = exports.useHint = exports.VideoContainer = exports.useIsAudioPlaying = exports.useAudioClips = exports.useWhenShowReset = exports.useShowPhase = exports.usePreloadedUrl = exports.useCogsMessage = exports.useCogsStateValues = exports.useCogsStateValue = exports.useCogsMediaConfig = exports.useCogsEvents = exports.useCogsEvent = exports.useCogsConfig = exports.useIsConnected = exports.useVideoPlayer = exports.useAudioPlayer = exports.useCogsConnection = exports.CogsConnectionProvider = void 0;
21
21
  // Utilities
22
22
  var CogsConnectionProvider_1 = require("./providers/CogsConnectionProvider");
23
23
  Object.defineProperty(exports, "CogsConnectionProvider", { enumerable: true, get: function () { return __importDefault(CogsConnectionProvider_1).default; } });
@@ -52,9 +52,6 @@ var useAudioClips_1 = require("./hooks/useAudioClips");
52
52
  Object.defineProperty(exports, "useAudioClips", { enumerable: true, get: function () { return __importDefault(useAudioClips_1).default; } });
53
53
  var useIsAudioPlaying_1 = require("./hooks/useIsAudioPlaying");
54
54
  Object.defineProperty(exports, "useIsAudioPlaying", { enumerable: true, get: function () { return __importDefault(useIsAudioPlaying_1).default; } });
55
- // RTSP
56
- var RtspVideo_1 = require("./components/RtspVideo");
57
- Object.defineProperty(exports, "RtspVideo", { enumerable: true, get: function () { return __importDefault(RtspVideo_1).default; } });
58
55
  // Video
59
56
  var VideoContainer_1 = require("./components/VideoContainer");
60
57
  Object.defineProperty(exports, "VideoContainer", { enumerable: true, get: function () { return __importDefault(VideoContainer_1).default; } });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React components and hooks to connect to COGS to build a custom Media Master",
4
4
  "author": "Clockwork Dog <info@clockwork.dog>",
5
5
  "homepage": "https://github.com/clockwork-dog/cogs-sdk/tree/main/packages/react",
6
- "version": "2.10.1",
6
+ "version": "2.11.0",
7
7
  "keywords": [],
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "release": "yarn npm publish --access public"
28
28
  },
29
29
  "dependencies": {
30
- "@clockworkdog/cogs-client": "^2.10.1"
30
+ "@clockworkdog/cogs-client": "^2.11.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": "^18.0.0 || ^19.0.0",
@@ -1,19 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- /**
3
- * @deprecated
4
- */
5
- export interface RtspVideoProps {
6
- uri: string;
7
- websocketHostname?: string;
8
- websocketPort?: number;
9
- websocketPath?: string;
10
- live?: boolean;
11
- }
12
- /**
13
- * Takes an RTSP video URL and streams it in a video element. By default this will open the TCP relay
14
- * websocket on the same hostname as COGS is running, but can be configured by passing in custom
15
- * websocket details.
16
- *
17
- * @deprecated
18
- */
19
- export default function RtspVideo({ uri, websocketHostname, websocketPort, websocketPath, live, ...rest }: RtspVideoProps & React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>): ReactNode;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.default = RtspVideo;
40
- const cogs_client_1 = require("@clockworkdog/cogs-client");
41
- const react_1 = __importStar(require("react"));
42
- const usePageVisibility_1 = __importDefault(require("../hooks/usePageVisibility"));
43
- /**
44
- * Takes an RTSP video URL and streams it in a video element. By default this will open the TCP relay
45
- * websocket on the same hostname as COGS is running, but can be configured by passing in custom
46
- * websocket details.
47
- *
48
- * @deprecated
49
- */
50
- function RtspVideo({ uri, websocketHostname, websocketPort, websocketPath, live, ...rest }) {
51
- // We need to monitor the page visibility as we only want the stream to play when the page is visible
52
- // This is needed because the stream will "pause" when the page looses focus and start playback when it
53
- // becomes visible again. This will essentially cause a delay to be introduced into the stream when loosing
54
- // page focus. To fix this, we simply stop and restart the stream when the page visibility changes.
55
- const isVisible = (0, usePageVisibility_1.default)();
56
- // For the video ref we actually use state so useEffect runs when the video ref changes
57
- const [videoRef, setVideoRef] = (0, react_1.useState)(null);
58
- const videoRefCallback = (0, react_1.useCallback)((newRef) => setVideoRef(newRef), []);
59
- // Get the RTSP streamer from the COGS provider
60
- const rtspStreamer = (0, react_1.useMemo)(() => new cogs_client_1.CogsRtspStreamer({
61
- hostname: websocketHostname,
62
- port: websocketPort,
63
- path: websocketPath,
64
- }), [websocketHostname, websocketPath, websocketPort]);
65
- // An effect which runs when the video element, page visibility, or URIs change
66
- // This will start playback of the camera stream in the given element
67
- (0, react_1.useEffect)(() => {
68
- // Nothing to do if we don't yet have a video element yet or if the page isn't visible
69
- if (!videoRef || !rtspStreamer || !isVisible) {
70
- return;
71
- }
72
- const pipeline = rtspStreamer.play({
73
- uri,
74
- videoElement: videoRef,
75
- playbackRate: live ? cogs_client_1.LIVE_VIDEO_PLAYBACK_RATE : undefined,
76
- restartIfStopped: live ? true : undefined,
77
- });
78
- return () => {
79
- pipeline.close();
80
- };
81
- }, [uri, isVisible, rtspStreamer, videoRef, live]);
82
- return react_1.default.createElement("video", { ref: videoRefCallback, autoPlay: true, ...rest });
83
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Uses the Page Visibility API to detect if the page is currently visible to the user.
3
- */
4
- export default function usePageVisibility(): boolean;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = usePageVisibility;
4
- const react_1 = require("react");
5
- /**
6
- * Uses the Page Visibility API to detect if the page is currently visible to the user.
7
- */
8
- function usePageVisibility() {
9
- const [isVisible, setIsVisible] = (0, react_1.useState)(() => !document.hidden);
10
- const onVisibilityChange = (0, react_1.useCallback)(() => setIsVisible(!document.hidden), []);
11
- (0, react_1.useEffect)(() => {
12
- document.addEventListener('visibilitychange', onVisibilityChange, false);
13
- return () => {
14
- document.removeEventListener('visibilitychange', onVisibilityChange);
15
- };
16
- });
17
- return isVisible;
18
- }