@stream-io/video-client 1.27.4 → 1.27.5
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 +6 -0
- package/dist/index.browser.es.js +72 -67
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +72 -67
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +72 -67
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamVideoClient.d.ts +6 -0
- package/dist/src/helpers/clientUtils.d.ts +7 -0
- package/dist/src/store/stateStore.d.ts +0 -7
- package/package.json +1 -1
- package/src/StreamVideoClient.ts +63 -64
- package/src/__tests__/StreamVideoClient.ringing.test.ts +167 -0
- package/src/__tests__/clientTestUtils.ts +72 -0
- package/src/__tests__/data.ts +621 -0
- package/src/helpers/__tests__/clientUtils.test.ts +8 -0
- package/src/helpers/clientUtils.ts +8 -0
- package/src/store/stateStore.ts +0 -8
package/dist/index.es.js
CHANGED
|
@@ -4301,13 +4301,6 @@ class StreamVideoWriteableStateStore {
|
|
|
4301
4301
|
*/
|
|
4302
4302
|
class StreamVideoReadOnlyStateStore {
|
|
4303
4303
|
constructor(store) {
|
|
4304
|
-
/**
|
|
4305
|
-
* This method allows you the get the current value of a state variable.
|
|
4306
|
-
*
|
|
4307
|
-
* @param observable the observable to get the current value of.
|
|
4308
|
-
* @returns the current value of the observable.
|
|
4309
|
-
*/
|
|
4310
|
-
this.getCurrentValue = getCurrentValue;
|
|
4311
4304
|
// convert and expose subjects as observables
|
|
4312
4305
|
this.connectedUser$ = store.connectedUserSubject.asObservable();
|
|
4313
4306
|
this.calls$ = store.callsSubject.asObservable();
|
|
@@ -5644,7 +5637,7 @@ const getSdkVersion = (sdk) => {
|
|
|
5644
5637
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
5645
5638
|
};
|
|
5646
5639
|
|
|
5647
|
-
const version = "1.27.
|
|
5640
|
+
const version = "1.27.5";
|
|
5648
5641
|
const [major, minor, patch] = version.split('.');
|
|
5649
5642
|
let sdkInfo = {
|
|
5650
5643
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -14544,7 +14537,7 @@ class StreamClient {
|
|
|
14544
14537
|
this.getUserAgent = () => {
|
|
14545
14538
|
if (!this.cachedUserAgent) {
|
|
14546
14539
|
const { clientAppIdentifier = {} } = this.options;
|
|
14547
|
-
const { sdkName = 'js', sdkVersion = "1.27.
|
|
14540
|
+
const { sdkName = 'js', sdkVersion = "1.27.5", ...extras } = clientAppIdentifier;
|
|
14548
14541
|
this.cachedUserAgent = [
|
|
14549
14542
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
14550
14543
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
@@ -14665,6 +14658,13 @@ class StreamClient {
|
|
|
14665
14658
|
const getInstanceKey = (apiKey, user) => {
|
|
14666
14659
|
return `${apiKey}/${user.id}`;
|
|
14667
14660
|
};
|
|
14661
|
+
/**
|
|
14662
|
+
* Returns a concurrency tag for call initialization.
|
|
14663
|
+
* @internal
|
|
14664
|
+
*
|
|
14665
|
+
* @param cid the call cid.
|
|
14666
|
+
*/
|
|
14667
|
+
const getCallInitConcurrencyTag = (cid) => `call.init-${cid}`;
|
|
14668
14668
|
/**
|
|
14669
14669
|
* Utility function to get the client app identifier.
|
|
14670
14670
|
*/
|
|
@@ -14733,7 +14733,7 @@ class StreamVideoClient {
|
|
|
14733
14733
|
this.registerEffects = () => {
|
|
14734
14734
|
if (this.effectsRegistered)
|
|
14735
14735
|
return;
|
|
14736
|
-
this.eventHandlersToUnregister.push(this.on('connection.changed', (event) => {
|
|
14736
|
+
this.eventHandlersToUnregister.push(this.on('call.created', (event) => this.initCallFromEvent(event)), this.on('call.ring', (event) => this.initCallFromEvent(event)), this.on('connection.changed', (event) => {
|
|
14737
14737
|
if (!event.online)
|
|
14738
14738
|
return;
|
|
14739
14739
|
const callsToReWatch = this.writeableStateStore.calls
|
|
@@ -14750,50 +14750,52 @@ class StreamVideoClient {
|
|
|
14750
14750
|
this.logger('error', 'Failed to re-watch calls', err);
|
|
14751
14751
|
});
|
|
14752
14752
|
}));
|
|
14753
|
-
this.
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
if (theCall) {
|
|
14780
|
-
await theCall.updateFromRingingEvent(event);
|
|
14781
|
-
}
|
|
14782
|
-
else {
|
|
14783
|
-
// if client doesn't have the call instance, create the instance and fetch the latest state
|
|
14784
|
-
// Note: related - we also have onRingingCall method to handle this case from push notifications
|
|
14785
|
-
const newCallInstance = new Call({
|
|
14753
|
+
this.effectsRegistered = true;
|
|
14754
|
+
};
|
|
14755
|
+
/**
|
|
14756
|
+
* Initializes a call from a call created or ringing event.
|
|
14757
|
+
* @param e the event.
|
|
14758
|
+
*/
|
|
14759
|
+
this.initCallFromEvent = async (e) => {
|
|
14760
|
+
if (this.state.connectedUser?.id === e.call.created_by.id) {
|
|
14761
|
+
this.logger('debug', `Ignoring ${e.type} event sent by the current user`);
|
|
14762
|
+
return;
|
|
14763
|
+
}
|
|
14764
|
+
try {
|
|
14765
|
+
const concurrencyTag = getCallInitConcurrencyTag(e.call_cid);
|
|
14766
|
+
await withoutConcurrency(concurrencyTag, async () => {
|
|
14767
|
+
const ringing = e.type === 'call.ring';
|
|
14768
|
+
let call = this.writeableStateStore.findCall(e.call.type, e.call.id);
|
|
14769
|
+
if (call) {
|
|
14770
|
+
if (ringing) {
|
|
14771
|
+
await call.updateFromRingingEvent(e);
|
|
14772
|
+
}
|
|
14773
|
+
else {
|
|
14774
|
+
call.state.updateFromCallResponse(e.call);
|
|
14775
|
+
}
|
|
14776
|
+
return;
|
|
14777
|
+
}
|
|
14778
|
+
call = new Call({
|
|
14786
14779
|
streamClient: this.streamClient,
|
|
14787
|
-
type: call.type,
|
|
14788
|
-
id: call.id,
|
|
14789
|
-
members,
|
|
14780
|
+
type: e.call.type,
|
|
14781
|
+
id: e.call.id,
|
|
14782
|
+
members: e.members,
|
|
14790
14783
|
clientStore: this.writeableStateStore,
|
|
14791
|
-
ringing
|
|
14784
|
+
ringing,
|
|
14792
14785
|
});
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14786
|
+
call.state.updateFromCallResponse(e.call);
|
|
14787
|
+
if (ringing) {
|
|
14788
|
+
await call.get();
|
|
14789
|
+
}
|
|
14790
|
+
else {
|
|
14791
|
+
this.writeableStateStore.registerCall(call);
|
|
14792
|
+
this.logger('info', `New call created and registered: ${call.cid}`);
|
|
14793
|
+
}
|
|
14794
|
+
});
|
|
14795
|
+
}
|
|
14796
|
+
catch (err) {
|
|
14797
|
+
this.logger('error', `Failed to init call from event ${e.type}`, err);
|
|
14798
|
+
}
|
|
14797
14799
|
};
|
|
14798
14800
|
/**
|
|
14799
14801
|
* Connects the given user to the client.
|
|
@@ -14893,6 +14895,7 @@ class StreamVideoClient {
|
|
|
14893
14895
|
*
|
|
14894
14896
|
* @param type the type of the call.
|
|
14895
14897
|
* @param id the id of the call.
|
|
14898
|
+
* @param options additional options for call creation.
|
|
14896
14899
|
*/
|
|
14897
14900
|
this.call = (type, id, options = {}) => {
|
|
14898
14901
|
const call = options.reuseInstance
|
|
@@ -15023,22 +15026,24 @@ class StreamVideoClient {
|
|
|
15023
15026
|
* @returns
|
|
15024
15027
|
*/
|
|
15025
15028
|
this.onRingingCall = async (call_cid) => {
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15036
|
-
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
15041
|
-
|
|
15029
|
+
return withoutConcurrency(getCallInitConcurrencyTag(call_cid), async () => {
|
|
15030
|
+
// if we find the call and is already ringing, we don't need to create a new call
|
|
15031
|
+
// as client would have received the call.ring state because the app had WS alive when receiving push notifications
|
|
15032
|
+
let call = this.state.calls.find((c) => c.cid === call_cid && c.ringing);
|
|
15033
|
+
if (!call) {
|
|
15034
|
+
// if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
|
|
15035
|
+
const [callType, callId] = call_cid.split(':');
|
|
15036
|
+
call = new Call({
|
|
15037
|
+
streamClient: this.streamClient,
|
|
15038
|
+
type: callType,
|
|
15039
|
+
id: callId,
|
|
15040
|
+
clientStore: this.writeableStateStore,
|
|
15041
|
+
ringing: true,
|
|
15042
|
+
});
|
|
15043
|
+
await call.get();
|
|
15044
|
+
}
|
|
15045
|
+
return call;
|
|
15046
|
+
});
|
|
15042
15047
|
};
|
|
15043
15048
|
/**
|
|
15044
15049
|
* Connects the given anonymous user to the client.
|