@stream-io/video-react-sdk 0.0.12 → 0.0.13

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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.0.13](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.0.12...@stream-io/video-react-sdk-0.0.13) (2023-06-08)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@stream-io/video-client` updated to version `0.0.1`
10
+ * `@stream-io/video-react-bindings` updated to version `0.0.7`
11
+
12
+ ### Features
13
+
14
+ * StreamCall signature, video client creation ([#596](https://github.com/GetStream/stream-video-js/issues/596)) ([5c3000c](https://github.com/GetStream/stream-video-js/commit/5c3000cc6fc3f8b7904609d7b11fa025b7458cad))
15
+
5
16
  ### [0.0.12](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-0.0.11...@stream-io/video-react-sdk-0.0.12) (2023-06-07)
6
17
 
7
18
  ### Dependency Updates
@@ -1,73 +1,11 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { Call, JoinCallData } from '@stream-io/video-client';
2
+ import { Call } from '@stream-io/video-client';
3
3
  import { MediaDevicesProviderProps } from '../../contexts';
4
- type InitWithCallCID = {
5
- /**
6
- * The call type.
7
- */
8
- callType: string;
9
- /**
10
- * The call id.
11
- */
12
- callId: string;
13
- /**
14
- * The call instance to use.
15
- */
16
- call?: never;
17
- };
18
- type InitWithCallInstance = {
19
- /**
20
- * The call instance to use.
21
- */
22
- call: Call | undefined;
23
- /**
24
- * The call type.
25
- */
26
- callType?: never;
27
- /**
28
- * The call id.
29
- */
30
- callId?: never;
31
- };
32
- type InitStreamCall = InitWithCallCID | InitWithCallInstance;
33
- export type StreamCallProps = InitStreamCall & {
34
- /**
35
- * If true, the call will be joined automatically.
36
- * Set it to true if you want to join the call immediately.
37
- * Useful for scenarios where you want to skip prompting the user to join the call.
38
- *
39
- * @default false.
40
- */
41
- autoJoin?: boolean;
42
- /**
43
- * If true, the call data will be loaded automatically from the server.
44
- *
45
- * This property is useful for the scenarios where you declaratively create
46
- * the call instance by using the `callId` and `callType` props,
47
- * and you have a UI that depends on the call metadata.
48
- *
49
- * @example
50
- * ```jsx
51
- * <StreamCall callId="call-id" callType="call-type" autoLoad>
52
- * <CallMetadata /> // has access to `call.metadata` although not joined yet
53
- * <CallUI />
54
- * <CallControls />
55
- * </StreamCall>
56
- * ```
57
- *
58
- * This property is ignored if you pass the `call` prop or enable `autoJoin`.
59
- *
60
- * @default true.
61
- */
62
- autoLoad?: boolean;
63
- /**
64
- * An optional data to pass when joining the call.
65
- */
66
- data?: JoinCallData;
4
+ export type StreamCallProps = {
5
+ call: Call;
67
6
  /**
68
7
  * An optional props to pass to the `MediaDevicesProvider`.
69
8
  */
70
9
  mediaDevicesProviderProps?: MediaDevicesProviderProps;
71
10
  };
72
- export declare const StreamCall: ({ children, callId, callType, call, autoJoin, autoLoad, data, mediaDevicesProviderProps, }: PropsWithChildren<StreamCallProps>) => JSX.Element;
73
- export {};
11
+ export declare const StreamCall: ({ children, call, mediaDevicesProviderProps, }: PropsWithChildren<StreamCallProps>) => JSX.Element;
@@ -1,60 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- import { CallingState } from '@stream-io/video-client';
4
- import { StreamCallProvider, useConnectedUser, useStreamVideoClient, } from '@stream-io/video-react-bindings';
2
+ import { StreamCallProvider } from '@stream-io/video-react-bindings';
5
3
  import { MediaDevicesProvider, } from '../../contexts';
6
- export const StreamCall = ({ children, callId, callType, call, autoJoin = false, autoLoad = true, data, mediaDevicesProviderProps, }) => {
7
- const client = useStreamVideoClient();
8
- const [activeCall, setActiveCall] = useState(() => {
9
- if (call)
10
- return call;
11
- if (!client || !callId || !callType)
12
- return;
13
- return client.call(callType, callId);
14
- });
15
- useEffect(() => {
16
- if (!client)
17
- return;
18
- if (callId && callType && !activeCall) {
19
- const newCall = client.call(callType, callId);
20
- setActiveCall(newCall);
21
- }
22
- }, [activeCall, callId, callType, client]);
23
- const connectedUser = useConnectedUser();
24
- useEffect(() => {
25
- // run the effect only when the user is connected and the call
26
- // is created declaratively by using the `callId` and `callType` props.
27
- if (!connectedUser)
28
- return;
29
- if (activeCall && callType && callId && autoLoad && !autoJoin) {
30
- activeCall
31
- .getOrCreate({
32
- ring: data === null || data === void 0 ? void 0 : data.ring,
33
- data: data === null || data === void 0 ? void 0 : data.data,
34
- members_limit: data === null || data === void 0 ? void 0 : data.members_limit,
35
- })
36
- .catch((err) => {
37
- console.error(`Failed to get or create call`, err);
38
- });
39
- }
40
- }, [
41
- activeCall,
42
- autoJoin,
43
- autoLoad,
44
- callId,
45
- callType,
46
- connectedUser,
47
- data === null || data === void 0 ? void 0 : data.data,
48
- data === null || data === void 0 ? void 0 : data.members_limit,
49
- data === null || data === void 0 ? void 0 : data.ring,
50
- ]);
51
- useEffect(() => {
52
- if (autoJoin && (activeCall === null || activeCall === void 0 ? void 0 : activeCall.state.callingState) === CallingState.IDLE) {
53
- activeCall.join(data).catch((err) => {
54
- console.error(`Failed to join call`, err);
55
- });
56
- }
57
- }, [activeCall, autoJoin, data]);
58
- return (_jsx(StreamCallProvider, Object.assign({ call: activeCall }, { children: _jsx(MediaDevicesProvider, Object.assign({}, mediaDevicesProviderProps, { children: children })) })));
4
+ export const StreamCall = ({ children, call, mediaDevicesProviderProps, }) => {
5
+ return (_jsx(StreamCallProvider, Object.assign({ call: call }, { children: _jsx(MediaDevicesProvider, Object.assign({}, mediaDevicesProviderProps, { children: children })) })));
59
6
  };
60
7
  //# sourceMappingURL=StreamCall.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StreamCall.js","sourceRoot":"","sources":["../../../../../src/core/components/StreamCall/StreamCall.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,SAAS,EAAE,QAAQ,EAAE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amCall.js","sourceRoot":"","sources":["../../../../../src/core/components/StreamCall/StreamCall.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EACL,oBAAoB,GAErB,MAAM,gBAAgB,CAAC;AAWxB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,IAAI,EACJ,yBAAyB,GACU,EAAE,EAAE;IACvC,OAAO,CACL,KAAC,kBAAkB,kBAAC,IAAI,EAAE,IAAI,gBAC5B,KAAC,oBAAoB,oBAAK,yBAAyB,cAChD,QAAQ,IACY,IACJ,CACtB,CAAC;AACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -26,8 +26,8 @@
26
26
  "@nivo/core": "^0.80.0",
27
27
  "@nivo/line": "^0.80.0",
28
28
  "@stream-io/i18n": "^0.0.2",
29
- "@stream-io/video-client": "^0.0.6",
30
- "@stream-io/video-react-bindings": "^0.0.6",
29
+ "@stream-io/video-client": "^0.0.7",
30
+ "@stream-io/video-react-bindings": "^0.0.7",
31
31
  "clsx": "^1.2.1",
32
32
  "rxjs": "~7.8.1"
33
33
  },
@@ -47,5 +47,5 @@
47
47
  "typedoc": "^0.24.7",
48
48
  "typescript": "^4.9.5"
49
49
  },
50
- "version": "0.0.12"
50
+ "version": "0.0.13"
51
51
  }
@@ -1,83 +1,13 @@
1
- import { PropsWithChildren, useEffect, useState } from 'react';
2
- import { Call, CallingState, JoinCallData } from '@stream-io/video-client';
3
- import {
4
- StreamCallProvider,
5
- useConnectedUser,
6
- useStreamVideoClient,
7
- } from '@stream-io/video-react-bindings';
1
+ import { PropsWithChildren } from 'react';
2
+ import { Call } from '@stream-io/video-client';
3
+ import { StreamCallProvider } from '@stream-io/video-react-bindings';
8
4
  import {
9
5
  MediaDevicesProvider,
10
6
  MediaDevicesProviderProps,
11
7
  } from '../../contexts';
12
8
 
13
- type InitWithCallCID = {
14
- /**
15
- * The call type.
16
- */
17
- callType: string;
18
- /**
19
- * The call id.
20
- */
21
- callId: string;
22
- /**
23
- * The call instance to use.
24
- */
25
- call?: never;
26
- };
27
-
28
- type InitWithCallInstance = {
29
- /**
30
- * The call instance to use.
31
- */
32
- call: Call | undefined;
33
- /**
34
- * The call type.
35
- */
36
- callType?: never;
37
- /**
38
- * The call id.
39
- */
40
- callId?: never;
41
- };
42
-
43
- type InitStreamCall = InitWithCallCID | InitWithCallInstance;
44
-
45
- export type StreamCallProps = InitStreamCall & {
46
- /**
47
- * If true, the call will be joined automatically.
48
- * Set it to true if you want to join the call immediately.
49
- * Useful for scenarios where you want to skip prompting the user to join the call.
50
- *
51
- * @default false.
52
- */
53
- autoJoin?: boolean;
54
-
55
- /**
56
- * If true, the call data will be loaded automatically from the server.
57
- *
58
- * This property is useful for the scenarios where you declaratively create
59
- * the call instance by using the `callId` and `callType` props,
60
- * and you have a UI that depends on the call metadata.
61
- *
62
- * @example
63
- * ```jsx
64
- * <StreamCall callId="call-id" callType="call-type" autoLoad>
65
- * <CallMetadata /> // has access to `call.metadata` although not joined yet
66
- * <CallUI />
67
- * <CallControls />
68
- * </StreamCall>
69
- * ```
70
- *
71
- * This property is ignored if you pass the `call` prop or enable `autoJoin`.
72
- *
73
- * @default true.
74
- */
75
- autoLoad?: boolean;
76
-
77
- /**
78
- * An optional data to pass when joining the call.
79
- */
80
- data?: JoinCallData;
9
+ export type StreamCallProps = {
10
+ call: Call;
81
11
 
82
12
  /**
83
13
  * An optional props to pass to the `MediaDevicesProvider`.
@@ -87,68 +17,11 @@ export type StreamCallProps = InitStreamCall & {
87
17
 
88
18
  export const StreamCall = ({
89
19
  children,
90
- callId,
91
- callType,
92
20
  call,
93
- autoJoin = false,
94
- autoLoad = true,
95
- data,
96
21
  mediaDevicesProviderProps,
97
22
  }: PropsWithChildren<StreamCallProps>) => {
98
- const client = useStreamVideoClient();
99
- const [activeCall, setActiveCall] = useState<Call | undefined>(() => {
100
- if (call) return call;
101
- if (!client || !callId || !callType) return;
102
- return client.call(callType, callId);
103
- });
104
-
105
- useEffect(() => {
106
- if (!client) return;
107
-
108
- if (callId && callType && !activeCall) {
109
- const newCall = client.call(callType, callId);
110
- setActiveCall(newCall);
111
- }
112
- }, [activeCall, callId, callType, client]);
113
-
114
- const connectedUser = useConnectedUser();
115
- useEffect(() => {
116
- // run the effect only when the user is connected and the call
117
- // is created declaratively by using the `callId` and `callType` props.
118
- if (!connectedUser) return;
119
- if (activeCall && callType && callId && autoLoad && !autoJoin) {
120
- activeCall
121
- .getOrCreate({
122
- ring: data?.ring,
123
- data: data?.data,
124
- members_limit: data?.members_limit,
125
- })
126
- .catch((err) => {
127
- console.error(`Failed to get or create call`, err);
128
- });
129
- }
130
- }, [
131
- activeCall,
132
- autoJoin,
133
- autoLoad,
134
- callId,
135
- callType,
136
- connectedUser,
137
- data?.data,
138
- data?.members_limit,
139
- data?.ring,
140
- ]);
141
-
142
- useEffect(() => {
143
- if (autoJoin && activeCall?.state.callingState === CallingState.IDLE) {
144
- activeCall.join(data).catch((err) => {
145
- console.error(`Failed to join call`, err);
146
- });
147
- }
148
- }, [activeCall, autoJoin, data]);
149
-
150
23
  return (
151
- <StreamCallProvider call={activeCall}>
24
+ <StreamCallProvider call={call}>
152
25
  <MediaDevicesProvider {...mediaDevicesProviderProps}>
153
26
  {children}
154
27
  </MediaDevicesProvider>