@clockworkdog/cogs-client-react 2.8.0 → 2.9.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CogsAudioPlayer, CogsConnection, CogsPluginManifest, CogsVideoPlayer } from '@clockworkdog/cogs-client';
|
|
1
|
+
import { CogsAudioPlayer, CogsConnection, CogsPluginManifest, CogsVideoPlayer, ManifestTypes } from '@clockworkdog/cogs-client';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* Create a persistent connection to COGS which can be accessed with `useCogsConnection()`
|
|
@@ -48,13 +48,21 @@ import React, { ReactNode } from 'react';
|
|
|
48
48
|
* }
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export default function CogsConnectionProvider<Manifest extends CogsPluginManifest
|
|
51
|
+
export default function CogsConnectionProvider<Manifest extends CogsPluginManifest, DataT extends {
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
} = {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}>({ manifest, hostname, port, children, audioPlayer, videoPlayer, initialClientState, initialDataStoreData, }: {
|
|
52
56
|
manifest: Manifest;
|
|
53
57
|
hostname?: string;
|
|
54
58
|
port?: number;
|
|
55
59
|
children: React.ReactNode;
|
|
56
60
|
audioPlayer?: boolean;
|
|
57
61
|
videoPlayer?: boolean;
|
|
62
|
+
initialClientState?: Partial<ManifestTypes.StateAsObject<Manifest, {
|
|
63
|
+
writableFromClient: true;
|
|
64
|
+
}>>;
|
|
65
|
+
initialDataStoreData?: DataT;
|
|
58
66
|
}): ReactNode | null;
|
|
59
67
|
/**
|
|
60
68
|
* Get the connection from `<CogsConnectionProvider>`
|
|
@@ -108,18 +108,18 @@ const CogsConnectionContext = react_1.default.createContext({
|
|
|
108
108
|
* }
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
function CogsConnectionProvider({ manifest, hostname, port, children, audioPlayer, videoPlayer, }) {
|
|
111
|
+
function CogsConnectionProvider({ manifest, hostname, port, children, audioPlayer, videoPlayer, initialClientState, initialDataStoreData, }) {
|
|
112
112
|
const connectionRef = (0, react_1.useRef)(undefined);
|
|
113
113
|
const [, forceRender] = (0, react_1.useState)({});
|
|
114
114
|
(0, react_1.useEffect)(() => {
|
|
115
|
-
const connection = new cogs_client_1.CogsConnection(manifest, { hostname, port });
|
|
115
|
+
const connection = new cogs_client_1.CogsConnection(manifest, { hostname, port }, initialClientState, initialDataStoreData);
|
|
116
116
|
connectionRef.current = connection;
|
|
117
117
|
forceRender({});
|
|
118
118
|
return () => {
|
|
119
119
|
connectionRef.current = undefined;
|
|
120
120
|
connection.close();
|
|
121
121
|
};
|
|
122
|
-
}, [manifest, hostname, port]);
|
|
122
|
+
}, [manifest, hostname, port, initialClientState, initialDataStoreData]);
|
|
123
123
|
const audioPlayerRef = (0, react_1.useRef)(undefined);
|
|
124
124
|
(0, react_1.useEffect)(() => {
|
|
125
125
|
if (audioPlayer && !audioPlayerRef.current && connectionRef.current) {
|
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.
|
|
6
|
+
"version": "2.9.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.
|
|
30
|
+
"@clockworkdog/cogs-client": "^2.9.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0",
|