@stream-io/video-client 1.59.1 → 1.60.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.browser.es.js +495 -105
  3. package/dist/index.browser.es.js.map +1 -1
  4. package/dist/index.cjs.js +495 -105
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.es.js +495 -105
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/src/Call.d.ts +23 -3
  9. package/dist/src/coordinator/connection/types.d.ts +16 -0
  10. package/dist/src/events/call.d.ts +0 -11
  11. package/dist/src/gen/coordinator/index.d.ts +73 -0
  12. package/dist/src/reporting/ClientEventReporter.d.ts +11 -1
  13. package/dist/src/ringing/RingStatePoller.d.ts +46 -0
  14. package/dist/src/ringing/RingTimeout.d.ts +27 -0
  15. package/dist/src/ringing/index.d.ts +4 -0
  16. package/dist/src/ringing/reconcileRingState.d.ts +18 -0
  17. package/dist/src/ringing/resolveOwnRingOutcome.d.ts +32 -0
  18. package/dist/src/stats/utils.d.ts +6 -0
  19. package/dist/src/store/CallState.d.ts +10 -1
  20. package/package.json +1 -1
  21. package/src/Call.ts +93 -61
  22. package/src/StreamSfuClient.ts +6 -2
  23. package/src/__tests__/Call.autodrop.test.ts +116 -64
  24. package/src/__tests__/Call.getRingState.test.ts +87 -0
  25. package/src/__tests__/Call.lifecycle.test.ts +23 -0
  26. package/src/__tests__/Call.ringSettled.test.ts +71 -0
  27. package/src/__tests__/StreamSfuClient.test.ts +48 -0
  28. package/src/coordinator/connection/types.ts +19 -0
  29. package/src/events/__tests__/call.test.ts +2 -217
  30. package/src/events/call.ts +1 -73
  31. package/src/events/callEventHandlers.ts +12 -23
  32. package/src/gen/coordinator/index.ts +67 -0
  33. package/src/reporting/ClientEventReporter.ts +30 -4
  34. package/src/reporting/__tests__/ClientEventReporter.test.ts +184 -7
  35. package/src/ringing/RingStatePoller.ts +177 -0
  36. package/src/ringing/RingTimeout.ts +90 -0
  37. package/src/ringing/__tests__/RingStatePoller.test.ts +462 -0
  38. package/src/ringing/__tests__/RingTimeout.test.ts +199 -0
  39. package/src/ringing/__tests__/reconcileRingState.test.ts +330 -0
  40. package/src/ringing/__tests__/resolveOwnRingOutcome.test.ts +103 -0
  41. package/src/ringing/index.ts +4 -0
  42. package/src/ringing/reconcileRingState.ts +108 -0
  43. package/src/ringing/resolveOwnRingOutcome.ts +58 -0
  44. package/src/stats/__tests__/utils.test.ts +33 -0
  45. package/src/stats/utils.ts +15 -0
  46. package/src/store/CallState.ts +25 -0
  47. package/src/store/__tests__/CallState.test.ts +59 -0
@@ -24,6 +24,7 @@ import {
24
24
  CallAcceptedEvent,
25
25
  CallEndedEvent,
26
26
  CallUpdatedEvent,
27
+ type GetCallRingStateResponse,
27
28
  MemberResponse,
28
29
  OwnCapability,
29
30
  } from '../../gen/coordinator';
@@ -1474,4 +1475,62 @@ describe('CallState', () => {
1474
1475
  expect(state['closedCaptionsTasks'].size).toBe(0);
1475
1476
  });
1476
1477
  });
1478
+
1479
+ describe('updateFromRingState', () => {
1480
+ const ringState = fromPartial<GetCallRingStateResponse>({
1481
+ session_id: 'session-1',
1482
+ accepted_by: { bob: '2026-08-24T10:00:04Z' },
1483
+ rejected_by: { carol: '2026-08-24T10:00:09Z' },
1484
+ missed_by: { dave: '2026-08-24T10:00:35Z' },
1485
+ });
1486
+
1487
+ const withSession = (id: string) => {
1488
+ const state = new CallState();
1489
+ state['sessionSubject'].next(
1490
+ fromPartial({
1491
+ id,
1492
+ accepted_by: {},
1493
+ rejected_by: {},
1494
+ missed_by: {},
1495
+ participants: [fromPartial({ user_session_id: 'p1' })],
1496
+ }),
1497
+ );
1498
+ return state;
1499
+ };
1500
+
1501
+ it('merges the ring maps into the current session', () => {
1502
+ const state = withSession('session-1');
1503
+ state.updateFromRingState(ringState);
1504
+
1505
+ expect(state.session?.accepted_by).toEqual(ringState.accepted_by);
1506
+ expect(state.session?.rejected_by).toEqual(ringState.rejected_by);
1507
+ expect(state.session?.missed_by).toEqual(ringState.missed_by);
1508
+ });
1509
+
1510
+ it('leaves the session roster untouched', () => {
1511
+ const state = withSession('session-1');
1512
+ state.updateFromRingState(ringState);
1513
+
1514
+ expect(state.session?.participants).toHaveLength(1);
1515
+ });
1516
+
1517
+ it('ignores a ring state that belongs to another session', () => {
1518
+ const state = withSession('session-2');
1519
+ state.updateFromRingState(ringState);
1520
+
1521
+ expect(state.session?.accepted_by).toEqual({});
1522
+ });
1523
+
1524
+ it('applies the end timestamps', () => {
1525
+ const state = withSession('session-1');
1526
+ state.updateFromRingState({
1527
+ ...ringState,
1528
+ session_ended_at: '2026-08-24T10:01:00Z',
1529
+ call_ended_at: '2026-08-24T10:01:00Z',
1530
+ });
1531
+
1532
+ expect(state.session?.ended_at).toBe('2026-08-24T10:01:00Z');
1533
+ expect(state.endedAt).toEqual(new Date('2026-08-24T10:01:00Z'));
1534
+ });
1535
+ });
1477
1536
  });