@stream-io/video-client 1.61.0 → 2.0.0-beta.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.
- package/CHANGELOG.md +10 -10
- package/dist/index.browser.es.js +358 -611
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +357 -611
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +358 -611
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +3 -3
- package/dist/src/StreamVideoClient.d.ts +15 -21
- package/dist/src/store/CallState.d.ts +108 -266
- package/dist/src/store/ClientState.d.ts +62 -0
- package/dist/src/store/index.d.ts +1 -1
- package/dist/src/store/subjects.d.ts +15 -0
- package/dist/src/store/types.d.ts +22 -0
- package/dist/src/types.d.ts +3 -3
- package/package.json +2 -2
- package/src/Call.ts +14 -18
- package/src/StreamVideoClient.ts +40 -47
- package/src/__tests__/Call.autodrop.test.ts +4 -4
- package/src/__tests__/Call.getRingState.test.ts +2 -2
- package/src/__tests__/Call.lifecycle.test.ts +8 -8
- package/src/__tests__/Call.publishing.test.ts +2 -2
- package/src/__tests__/Call.ringSettled.test.ts +4 -4
- package/src/__tests__/Call.ringingLifecycle.test.ts +2 -2
- package/src/__tests__/StreamVideoClient.disconnect.test.ts +62 -0
- package/src/devices/__tests__/CameraManager.test.ts +2 -2
- package/src/devices/__tests__/DeviceManager.test.ts +2 -2
- package/src/devices/__tests__/DeviceManagerFilters.test.ts +2 -2
- package/src/devices/__tests__/MicrophoneManager.test.ts +2 -2
- package/src/devices/__tests__/MicrophoneManagerRN.test.ts +2 -2
- package/src/devices/__tests__/ScreenShareManager.test.ts +3 -3
- package/src/devices/__tests__/SpeakerManager.test.ts +4 -4
- package/src/events/__tests__/call.test.ts +3 -3
- package/src/helpers/__tests__/AudioBindingsWatchdog.test.ts +2 -2
- package/src/helpers/__tests__/DynascaleManager.test.ts +2 -2
- package/src/helpers/__tests__/ViewportTracker.test.ts +2 -2
- package/src/ringing/__tests__/RingStatePoller.test.ts +7 -7
- package/src/ringing/__tests__/RingTimeout.test.ts +4 -4
- package/src/ringing/__tests__/reconcileRingState.test.ts +3 -3
- package/src/rtc/__tests__/Call.reconnect.test.ts +5 -5
- package/src/store/CallState.ts +281 -551
- package/src/store/ClientState.ts +101 -0
- package/src/store/__tests__/CallState.test.ts +1 -1
- package/src/store/__tests__/ClientState.test.ts +35 -0
- package/src/store/__tests__/rxUtils.test.ts +67 -1
- package/src/store/index.ts +1 -1
- package/src/store/rxUtils.ts +8 -4
- package/src/store/subjects.ts +30 -0
- package/src/store/types.ts +45 -0
- package/src/types.ts +3 -3
- package/dist/src/store/stateStore.d.ts +0 -84
- package/src/store/stateStore.ts +0 -156
|
@@ -10,7 +10,7 @@ import { CallingState } from '../store';
|
|
|
10
10
|
import { StreamClient } from '../coordinator/connection/client';
|
|
11
11
|
import { ClientEventReporter } from '../reporting';
|
|
12
12
|
import { generateUUIDv4 } from '../coordinator/connection/utils';
|
|
13
|
-
import {
|
|
13
|
+
import { ClientState } from '../store';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* The core's whole part in the React Native ringing lifecycle: await RN's
|
|
@@ -30,7 +30,7 @@ const createCall = (ringing: boolean) => {
|
|
|
30
30
|
streamClient,
|
|
31
31
|
enabled: false,
|
|
32
32
|
}),
|
|
33
|
-
|
|
33
|
+
clientState: new ClientState(),
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import '../rtc/__tests__/mocks/webrtc.mocks';
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { StreamVideoClient } from '../StreamVideoClient';
|
|
4
|
+
import { CallingState } from '../store';
|
|
5
|
+
|
|
6
|
+
const fakeCall = (cid: string, callingState: CallingState) => ({
|
|
7
|
+
cid,
|
|
8
|
+
state: { callingState },
|
|
9
|
+
leave: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
watching: false,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('disconnectUser leaves calls', () => {
|
|
14
|
+
it('leaves non-LEFT calls, before closing the connection', async () => {
|
|
15
|
+
const client = new StreamVideoClient('abc');
|
|
16
|
+
const order: string[] = [];
|
|
17
|
+
|
|
18
|
+
const active = fakeCall('default:active', CallingState.JOINED);
|
|
19
|
+
const left = fakeCall('default:left', CallingState.LEFT);
|
|
20
|
+
active.leave.mockImplementation(async () => {
|
|
21
|
+
order.push('leave:active');
|
|
22
|
+
});
|
|
23
|
+
left.leave.mockImplementation(async () => {
|
|
24
|
+
order.push('leave:left');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
client.state.setCalls([active, left] as never);
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error faking the minimum the guard needs
|
|
30
|
+
client.streamClient.user = { id: 'jane' };
|
|
31
|
+
vi.spyOn(client.streamClient, 'disconnectUser').mockImplementation(
|
|
32
|
+
async () => {
|
|
33
|
+
order.push('ws:close');
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
await client.disconnectUser();
|
|
38
|
+
|
|
39
|
+
expect(active.leave).toHaveBeenCalledWith({
|
|
40
|
+
message: 'client.disconnectUser() called',
|
|
41
|
+
});
|
|
42
|
+
expect(left.leave).not.toHaveBeenCalled();
|
|
43
|
+
expect(order).toEqual(['leave:active', 'ws:close']);
|
|
44
|
+
expect(client.state.connectedUser).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('a failing leave does not block the disconnect', async () => {
|
|
48
|
+
const client = new StreamVideoClient('abc');
|
|
49
|
+
const boom = fakeCall('default:boom', CallingState.JOINED);
|
|
50
|
+
boom.leave.mockRejectedValue(new Error('nope'));
|
|
51
|
+
client.state.setCalls([boom] as never);
|
|
52
|
+
|
|
53
|
+
// @ts-expect-error faking the minimum the guard needs
|
|
54
|
+
client.streamClient.user = { id: 'jane' };
|
|
55
|
+
vi.spyOn(client.streamClient, 'disconnectUser').mockResolvedValue(
|
|
56
|
+
undefined as never,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
await expect(client.disconnectUser()).resolves.toBeUndefined();
|
|
60
|
+
expect(boom.leave).toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Call } from '../../Call';
|
|
2
2
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
3
3
|
import { ClientEventReporter } from '../../reporting';
|
|
4
|
-
import { CallingState,
|
|
4
|
+
import { CallingState, ClientState } from '../../store';
|
|
5
5
|
|
|
6
6
|
import { afterEach, beforeEach, describe, expect, it, Mock, vi } from 'vitest';
|
|
7
7
|
import { fromPartial } from '@total-typescript/shoehorn';
|
|
@@ -89,7 +89,7 @@ describe('CameraManager', () => {
|
|
|
89
89
|
type: '',
|
|
90
90
|
streamClient,
|
|
91
91
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
92
|
-
|
|
92
|
+
clientState: new ClientState(),
|
|
93
93
|
});
|
|
94
94
|
manager = new CameraManager(call, devicePersistence);
|
|
95
95
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Call } from '../../Call';
|
|
3
3
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
4
4
|
import { ClientEventReporter } from '../../reporting';
|
|
5
|
-
import { CallingState,
|
|
5
|
+
import { CallingState, ClientState } from '../../store';
|
|
6
6
|
|
|
7
7
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
8
|
import {
|
|
@@ -99,7 +99,7 @@ describe('Device Manager', () => {
|
|
|
99
99
|
type: '',
|
|
100
100
|
streamClient,
|
|
101
101
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
102
|
-
|
|
102
|
+
clientState: new ClientState(),
|
|
103
103
|
}),
|
|
104
104
|
{ enabled: false, storageKey },
|
|
105
105
|
);
|
|
@@ -3,7 +3,7 @@ import { of } from 'rxjs';
|
|
|
3
3
|
import { Call } from '../../Call';
|
|
4
4
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
5
5
|
import { ClientEventReporter } from '../../reporting';
|
|
6
|
-
import {
|
|
6
|
+
import { ClientState } from '../../store';
|
|
7
7
|
import { DeviceManagerState } from '../DeviceManagerState';
|
|
8
8
|
import { DeviceManager } from '../DeviceManager';
|
|
9
9
|
import {
|
|
@@ -53,7 +53,7 @@ describe('MediaStream Filters', () => {
|
|
|
53
53
|
type: '',
|
|
54
54
|
streamClient,
|
|
55
55
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
56
|
-
|
|
56
|
+
clientState: new ClientState(),
|
|
57
57
|
}),
|
|
58
58
|
);
|
|
59
59
|
});
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
AudioBitrateProfile,
|
|
13
13
|
TrackType,
|
|
14
14
|
} from '../../gen/video/sfu/models/models';
|
|
15
|
-
import { CallingState,
|
|
15
|
+
import { CallingState, ClientState } from '../../store';
|
|
16
16
|
import {
|
|
17
17
|
createLocalStorageMock,
|
|
18
18
|
emitDeviceIds,
|
|
@@ -105,7 +105,7 @@ describe('MicrophoneManager', () => {
|
|
|
105
105
|
type: '',
|
|
106
106
|
streamClient,
|
|
107
107
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
108
|
-
|
|
108
|
+
clientState: new ClientState(),
|
|
109
109
|
});
|
|
110
110
|
const devicePersistence = { enabled: false, storageKey: '' };
|
|
111
111
|
manager = new MicrophoneManager(call, devicePersistence, 'disable-tracks');
|
|
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
2
2
|
import { MicrophoneManager } from '../MicrophoneManager';
|
|
3
3
|
import { Call } from '../../Call';
|
|
4
4
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
5
|
-
import {
|
|
5
|
+
import { ClientState } from '../../store';
|
|
6
6
|
import {
|
|
7
7
|
mockAudioDevices,
|
|
8
8
|
mockAudioStream,
|
|
@@ -91,7 +91,7 @@ describe('MicrophoneManager React Native', () => {
|
|
|
91
91
|
id: '',
|
|
92
92
|
type: '',
|
|
93
93
|
streamClient,
|
|
94
|
-
|
|
94
|
+
clientState: new ClientState(),
|
|
95
95
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
96
96
|
}),
|
|
97
97
|
devicePersistence,
|
|
@@ -3,7 +3,7 @@ import { ScreenShareManager } from '../ScreenShareManager';
|
|
|
3
3
|
import { Call } from '../../Call';
|
|
4
4
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
5
5
|
import { ClientEventReporter } from '../../reporting';
|
|
6
|
-
import { CallingState,
|
|
6
|
+
import { CallingState, ClientState } from '../../store';
|
|
7
7
|
import * as RxUtils from '../../store/rxUtils';
|
|
8
8
|
import { mockCall, mockDeviceIds$, mockScreenShareStream } from './mocks';
|
|
9
9
|
import { getScreenShareStream } from '../devices';
|
|
@@ -44,7 +44,7 @@ describe('ScreenShareManager', () => {
|
|
|
44
44
|
type: '',
|
|
45
45
|
streamClient,
|
|
46
46
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
47
|
-
|
|
47
|
+
clientState: new ClientState(),
|
|
48
48
|
}),
|
|
49
49
|
);
|
|
50
50
|
});
|
|
@@ -99,7 +99,7 @@ describe('ScreenShareManager', () => {
|
|
|
99
99
|
|
|
100
100
|
it('should use call settings to set up constraints', async () => {
|
|
101
101
|
const call = manager['call'];
|
|
102
|
-
|
|
102
|
+
RxUtils.setCurrentValue(call.state['settingsSubject'], {
|
|
103
103
|
// @ts-expect-error partial data
|
|
104
104
|
screensharing: {
|
|
105
105
|
target_resolution: {
|
|
@@ -17,7 +17,7 @@ import { checkIfAudioOutputChangeSupported } from '../devices';
|
|
|
17
17
|
import { Call } from '../../Call';
|
|
18
18
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
19
19
|
import { ClientEventReporter } from '../../reporting';
|
|
20
|
-
import {
|
|
20
|
+
import { ClientState } from '../../store';
|
|
21
21
|
import { defaultDeviceId } from '../devicePersistence';
|
|
22
22
|
|
|
23
23
|
vi.mock('../devices.ts', () => {
|
|
@@ -55,7 +55,7 @@ describe('SpeakerManager.test', () => {
|
|
|
55
55
|
type: '',
|
|
56
56
|
streamClient,
|
|
57
57
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
58
|
-
|
|
58
|
+
clientState: new ClientState(),
|
|
59
59
|
}),
|
|
60
60
|
devicePersistence,
|
|
61
61
|
);
|
|
@@ -162,7 +162,7 @@ describe('SpeakerManager.test', () => {
|
|
|
162
162
|
type: '',
|
|
163
163
|
streamClient,
|
|
164
164
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
165
|
-
|
|
165
|
+
clientState: new ClientState(),
|
|
166
166
|
}),
|
|
167
167
|
{ enabled: true, storageKey },
|
|
168
168
|
);
|
|
@@ -190,7 +190,7 @@ describe('SpeakerManager.test', () => {
|
|
|
190
190
|
type: '',
|
|
191
191
|
streamClient,
|
|
192
192
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
193
|
-
|
|
193
|
+
clientState: new ClientState(),
|
|
194
194
|
}),
|
|
195
195
|
{ enabled: true, storageKey },
|
|
196
196
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { CallingState,
|
|
2
|
+
import { CallingState, ClientState } from '../../store';
|
|
3
3
|
import { watchCallEnded, watchSfuCallEnded } from '../call';
|
|
4
4
|
import {
|
|
5
5
|
CallEndedEvent,
|
|
@@ -166,7 +166,7 @@ describe('Call lifecycle events', () => {
|
|
|
166
166
|
});
|
|
167
167
|
|
|
168
168
|
const fakeCall = ({ ring = true, currentUserId = 'test-user-id' } = {}) => {
|
|
169
|
-
const store = new
|
|
169
|
+
const store = new ClientState();
|
|
170
170
|
store.setConnectedUser({
|
|
171
171
|
id: currentUserId,
|
|
172
172
|
created_at: '',
|
|
@@ -181,7 +181,7 @@ const fakeCall = ({ ring = true, currentUserId = 'test-user-id' } = {}) => {
|
|
|
181
181
|
return new Call({
|
|
182
182
|
type: 'development',
|
|
183
183
|
id: '12345',
|
|
184
|
-
|
|
184
|
+
clientState: store,
|
|
185
185
|
streamClient: client,
|
|
186
186
|
clientEventReporter: new ClientEventReporter({ streamClient: client }),
|
|
187
187
|
ringing: ring,
|
|
@@ -9,7 +9,7 @@ import { AudioBindingsWatchdog } from '../AudioBindingsWatchdog';
|
|
|
9
9
|
import { Call } from '../../Call';
|
|
10
10
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
11
11
|
import { ClientEventReporter } from '../../reporting';
|
|
12
|
-
import { CallingState,
|
|
12
|
+
import { CallingState, ClientState } from '../../store';
|
|
13
13
|
import { noopComparator } from '../../sorting';
|
|
14
14
|
import { fromPartial } from '@total-typescript/shoehorn';
|
|
15
15
|
import { TrackType } from '../../gen/video/sfu/models/models';
|
|
@@ -28,7 +28,7 @@ describe('AudioBindingsWatchdog', () => {
|
|
|
28
28
|
type: 'default',
|
|
29
29
|
streamClient,
|
|
30
30
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
31
|
-
|
|
31
|
+
clientState: new ClientState(),
|
|
32
32
|
});
|
|
33
33
|
call.setSortParticipantsBy(noopComparator());
|
|
34
34
|
watchdog = new AudioBindingsWatchdog(call.state, call.tracer);
|
|
@@ -18,7 +18,7 @@ import { DynascaleManager } from '../DynascaleManager';
|
|
|
18
18
|
import { Call } from '../../Call';
|
|
19
19
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
20
20
|
import { ClientEventReporter } from '../../reporting';
|
|
21
|
-
import {
|
|
21
|
+
import { ClientState } from '../../store';
|
|
22
22
|
import { getCurrentValue } from '../../store/rxUtils';
|
|
23
23
|
import { VisibilityState } from '../../types';
|
|
24
24
|
import { noopComparator } from '../../sorting';
|
|
@@ -45,7 +45,7 @@ describe('DynascaleManager', () => {
|
|
|
45
45
|
type: 'default',
|
|
46
46
|
streamClient,
|
|
47
47
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
48
|
-
|
|
48
|
+
clientState: new ClientState(),
|
|
49
49
|
});
|
|
50
50
|
call.setSortParticipantsBy(noopComparator());
|
|
51
51
|
dynascaleManager = call.dynascaleManager;
|
|
@@ -8,7 +8,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
8
8
|
import { Call } from '../../Call';
|
|
9
9
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
10
10
|
import { ClientEventReporter } from '../../reporting';
|
|
11
|
-
import {
|
|
11
|
+
import { ClientState } from '../../store';
|
|
12
12
|
import { noopComparator } from '../../sorting';
|
|
13
13
|
import { VisibilityState } from '../../types';
|
|
14
14
|
import { ViewportTracker } from '../ViewportTracker';
|
|
@@ -26,7 +26,7 @@ describe('ViewportTracker', () => {
|
|
|
26
26
|
type: 'default',
|
|
27
27
|
streamClient,
|
|
28
28
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
29
|
-
|
|
29
|
+
clientState: new ClientState(),
|
|
30
30
|
});
|
|
31
31
|
call.setSortParticipantsBy(noopComparator());
|
|
32
32
|
viewportTracker = call.viewportTracker!;
|
|
@@ -7,7 +7,7 @@ import { RingStatePoller } from '../RingStatePoller';
|
|
|
7
7
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
8
8
|
import { ClientEventReporter } from '../../reporting';
|
|
9
9
|
import { generateUUIDv4 } from '../../coordinator/connection/utils';
|
|
10
|
-
import { CallingState,
|
|
10
|
+
import { CallingState, ClientState } from '../../store';
|
|
11
11
|
import {
|
|
12
12
|
ErrorFromResponse,
|
|
13
13
|
type StreamClientOptions,
|
|
@@ -37,18 +37,18 @@ describe('RingStatePoller', () => {
|
|
|
37
37
|
let poller: RingStatePoller;
|
|
38
38
|
|
|
39
39
|
const createCall = (options?: StreamClientOptions) => {
|
|
40
|
-
const
|
|
40
|
+
const clientState = new ClientState();
|
|
41
41
|
const streamClient = new StreamClient('abc', options);
|
|
42
42
|
const newCall = new Call({
|
|
43
43
|
type: 'test',
|
|
44
44
|
id: generateUUIDv4(),
|
|
45
45
|
streamClient,
|
|
46
46
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
47
|
-
|
|
47
|
+
clientState,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
// @ts-expect-error mocking only what we need for the test
|
|
51
|
-
|
|
51
|
+
clientState.setConnectedUser({ id: userId });
|
|
52
52
|
// @ts-expect-error mocking only what we need for the test
|
|
53
53
|
newCall.state['createdBySubject'].next({ id: userId });
|
|
54
54
|
// @ts-expect-error mocking only what we need for the test
|
|
@@ -391,19 +391,19 @@ describe('Call ring state polling', () => {
|
|
|
391
391
|
const userId = 'jane';
|
|
392
392
|
|
|
393
393
|
const createRingingCall = (options?: StreamClientOptions) => {
|
|
394
|
-
const
|
|
394
|
+
const clientState = new ClientState();
|
|
395
395
|
const streamClient = new StreamClient('abc', options);
|
|
396
396
|
const call = new Call({
|
|
397
397
|
type: 'test',
|
|
398
398
|
id: generateUUIDv4(),
|
|
399
399
|
streamClient,
|
|
400
400
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
401
|
-
|
|
401
|
+
clientState,
|
|
402
402
|
ringing: true,
|
|
403
403
|
});
|
|
404
404
|
|
|
405
405
|
// @ts-expect-error mocking only what we need for the test
|
|
406
|
-
|
|
406
|
+
clientState.setConnectedUser({ id: userId });
|
|
407
407
|
// @ts-expect-error mocking only what we need for the test
|
|
408
408
|
call.state['sessionSubject'].next({
|
|
409
409
|
id: SESSION_ID,
|
|
@@ -7,7 +7,7 @@ import { RingTimeout } from '../RingTimeout';
|
|
|
7
7
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
8
8
|
import { ClientEventReporter } from '../../reporting';
|
|
9
9
|
import { generateUUIDv4 } from '../../coordinator/connection/utils';
|
|
10
|
-
import { CallingState,
|
|
10
|
+
import { CallingState, ClientState } from '../../store';
|
|
11
11
|
import { CallSettingsResponse } from '../../gen/coordinator';
|
|
12
12
|
|
|
13
13
|
const TIMEOUT_MS = 30_000;
|
|
@@ -28,17 +28,17 @@ describe('RingTimeout', () => {
|
|
|
28
28
|
createdById?: string;
|
|
29
29
|
ring?: Partial<CallSettingsResponse['ring']> | null;
|
|
30
30
|
} = {}) => {
|
|
31
|
-
const
|
|
31
|
+
const clientState = new ClientState();
|
|
32
32
|
const streamClient = new StreamClient('abc');
|
|
33
33
|
const newCall = new Call({
|
|
34
34
|
type: 'test',
|
|
35
35
|
id: generateUUIDv4(),
|
|
36
36
|
streamClient,
|
|
37
37
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
38
|
-
|
|
38
|
+
clientState,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
clientState.setConnectedUser(fromPartial({ id: userId }));
|
|
42
42
|
newCall.state['createdBySubject'].next(fromPartial({ id: createdById }));
|
|
43
43
|
// leaving `settings` unset is how a call built from a push notification
|
|
44
44
|
// looks until `get()` resolves
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { fromPartial } from '@total-typescript/shoehorn';
|
|
3
3
|
import { reconcileRingState } from '../reconcileRingState';
|
|
4
|
-
import { CallingState,
|
|
4
|
+
import { CallingState, ClientState } from '../../store';
|
|
5
5
|
import {
|
|
6
6
|
CallResponse,
|
|
7
7
|
CallSessionResponse,
|
|
@@ -305,13 +305,13 @@ const ringingCall = ({
|
|
|
305
305
|
createdById: string;
|
|
306
306
|
members?: string[];
|
|
307
307
|
}) => {
|
|
308
|
-
const store = new
|
|
308
|
+
const store = new ClientState();
|
|
309
309
|
store.setConnectedUser(fromPartial({ id: currentUserId }));
|
|
310
310
|
const streamClient = new StreamClient('api-key');
|
|
311
311
|
const call = new Call({
|
|
312
312
|
type: 'development',
|
|
313
313
|
id: '12345',
|
|
314
|
-
|
|
314
|
+
clientState: store,
|
|
315
315
|
streamClient,
|
|
316
316
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
317
317
|
ringing: true,
|
|
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
4
4
|
import { Call } from '../../Call';
|
|
5
5
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
6
6
|
import { ClientEventReporter } from '../../reporting';
|
|
7
|
-
import {
|
|
7
|
+
import { ClientState } from '../../store';
|
|
8
8
|
import { CallingState } from '../../store';
|
|
9
9
|
import { NegotiationError } from '../NegotiationError';
|
|
10
10
|
import { ReconnectReason } from '../types';
|
|
@@ -27,7 +27,7 @@ vi.mock('../../StreamSfuClient', () => ({
|
|
|
27
27
|
|
|
28
28
|
const makeCall = ({ reportingEnabled = false } = {}) => {
|
|
29
29
|
const streamClient = new StreamClient('test-key');
|
|
30
|
-
const
|
|
30
|
+
const clientState = new ClientState();
|
|
31
31
|
return new Call({
|
|
32
32
|
type: 'default',
|
|
33
33
|
id: 'test-call',
|
|
@@ -36,7 +36,7 @@ const makeCall = ({ reportingEnabled = false } = {}) => {
|
|
|
36
36
|
streamClient,
|
|
37
37
|
enabled: reportingEnabled,
|
|
38
38
|
}),
|
|
39
|
-
|
|
39
|
+
clientState,
|
|
40
40
|
ringing: false,
|
|
41
41
|
watching: false,
|
|
42
42
|
});
|
|
@@ -729,13 +729,13 @@ describe('Call reconnect wiring (PC event → leave)', () => {
|
|
|
729
729
|
sfuClient.iceTrickleBuffer = new IceTrickleBuffer();
|
|
730
730
|
|
|
731
731
|
const streamClient = new StreamClient('test-key');
|
|
732
|
-
const
|
|
732
|
+
const clientState = new ClientState();
|
|
733
733
|
call = new Call({
|
|
734
734
|
type: 'default',
|
|
735
735
|
id: 'test-call',
|
|
736
736
|
streamClient,
|
|
737
737
|
clientEventReporter: new ClientEventReporter({ streamClient }),
|
|
738
|
-
|
|
738
|
+
clientState,
|
|
739
739
|
ringing: false,
|
|
740
740
|
watching: false,
|
|
741
741
|
});
|