livekit-client 2.9.0 → 2.9.2

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 (55) hide show
  1. package/dist/livekit-client.esm.mjs +393 -75
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/connectionHelper/ConnectionCheck.d.ts +2 -0
  6. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  7. package/dist/src/connectionHelper/checks/Checker.d.ts +5 -2
  8. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -1
  9. package/dist/src/connectionHelper/checks/cloudRegion.d.ts +17 -0
  10. package/dist/src/connectionHelper/checks/cloudRegion.d.ts.map +1 -0
  11. package/dist/src/connectionHelper/checks/connectionProtocol.d.ts +19 -0
  12. package/dist/src/connectionHelper/checks/connectionProtocol.d.ts.map +1 -0
  13. package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -1
  14. package/dist/src/connectionHelper/checks/publishVideo.d.ts +1 -0
  15. package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -1
  16. package/dist/src/index.d.ts +2 -2
  17. package/dist/src/index.d.ts.map +1 -1
  18. package/dist/src/room/StreamReader.d.ts +4 -4
  19. package/dist/src/room/StreamReader.d.ts.map +1 -1
  20. package/dist/src/room/StreamWriter.d.ts +3 -3
  21. package/dist/src/room/StreamWriter.d.ts.map +1 -1
  22. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  23. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  24. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  25. package/dist/src/room/track/create.d.ts.map +1 -1
  26. package/dist/src/room/types.d.ts +0 -5
  27. package/dist/src/room/types.d.ts.map +1 -1
  28. package/dist/src/room/utils.d.ts +1 -0
  29. package/dist/src/room/utils.d.ts.map +1 -1
  30. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +2 -0
  31. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +5 -2
  32. package/dist/ts4.2/src/connectionHelper/checks/cloudRegion.d.ts +18 -0
  33. package/dist/ts4.2/src/connectionHelper/checks/connectionProtocol.d.ts +20 -0
  34. package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +1 -0
  35. package/dist/ts4.2/src/index.d.ts +2 -2
  36. package/dist/ts4.2/src/room/StreamReader.d.ts +4 -4
  37. package/dist/ts4.2/src/room/StreamWriter.d.ts +3 -12
  38. package/dist/ts4.2/src/room/types.d.ts +0 -5
  39. package/dist/ts4.2/src/room/utils.d.ts +1 -0
  40. package/package.json +17 -17
  41. package/src/connectionHelper/ConnectionCheck.ts +15 -0
  42. package/src/connectionHelper/checks/Checker.ts +41 -8
  43. package/src/connectionHelper/checks/cloudRegion.ts +94 -0
  44. package/src/connectionHelper/checks/connectionProtocol.ts +149 -0
  45. package/src/connectionHelper/checks/publishAudio.ts +8 -0
  46. package/src/connectionHelper/checks/publishVideo.ts +52 -0
  47. package/src/index.ts +1 -1
  48. package/src/room/StreamReader.ts +9 -16
  49. package/src/room/StreamWriter.ts +4 -4
  50. package/src/room/participant/LocalParticipant.ts +9 -26
  51. package/src/room/participant/publishUtils.ts +4 -0
  52. package/src/room/track/LocalTrack.ts +5 -2
  53. package/src/room/track/create.ts +9 -5
  54. package/src/room/types.ts +0 -6
  55. package/src/room/utils.ts +16 -0
@@ -2,7 +2,7 @@ import DeviceManager from '../DeviceManager';
2
2
  import { audioDefaults, videoDefaults } from '../defaults';
3
3
  import { DeviceUnsupportedError, TrackInvalidError } from '../errors';
4
4
  import { mediaTrackToLocalTrack } from '../participant/publishUtils';
5
- import { isAudioTrack, isSafari17, isVideoTrack } from '../utils';
5
+ import { isAudioTrack, isSafari17, isVideoTrack, unwrapConstraint } from '../utils';
6
6
  import LocalAudioTrack from './LocalAudioTrack';
7
7
  import type LocalTrack from './LocalTrack';
8
8
  import LocalVideoTrack from './LocalVideoTrack';
@@ -68,10 +68,14 @@ export async function createLocalTracks(
68
68
 
69
69
  // update the constraints with the device id the user gave permissions to in the permission prompt
70
70
  // otherwise each track restart (e.g. mute - unmute) will try to initialize the device again -> causing additional permission prompts
71
- if (trackConstraints) {
72
- trackConstraints.deviceId = mediaStreamTrack.getSettings().deviceId;
73
- } else {
74
- trackConstraints = { deviceId: mediaStreamTrack.getSettings().deviceId };
71
+ const newDeviceId = mediaStreamTrack.getSettings().deviceId;
72
+ if (
73
+ trackConstraints?.deviceId &&
74
+ unwrapConstraint(trackConstraints.deviceId) !== newDeviceId
75
+ ) {
76
+ trackConstraints.deviceId = newDeviceId;
77
+ } else if (!trackConstraints) {
78
+ trackConstraints = { deviceId: newDeviceId };
75
79
  }
76
80
 
77
81
  const track = mediaTrackToLocalTrack(mediaStreamTrack, trackConstraints);
package/src/room/types.ts CHANGED
@@ -119,9 +119,3 @@ export interface ByteStreamInfo extends BaseStreamInfo {
119
119
  }
120
120
 
121
121
  export interface TextStreamInfo extends BaseStreamInfo {}
122
-
123
- export type TextStreamChunk = {
124
- index: number;
125
- current: string;
126
- collected: string;
127
- };
package/src/room/utils.ts CHANGED
@@ -625,3 +625,19 @@ export function isLocalParticipant(p: Participant): p is LocalParticipant {
625
625
  export function isRemoteParticipant(p: Participant): p is RemoteParticipant {
626
626
  return !p.isLocal;
627
627
  }
628
+
629
+ export function splitUtf8(s: string, n: number): string[] {
630
+ // adapted from https://stackoverflow.com/a/6043797
631
+ const result: string[] = [];
632
+ while (s.length > n) {
633
+ let k = n;
634
+ // Move back to find the start of a UTF-8 character
635
+ while ((s.charCodeAt(k) & 0xc0) === 0x80) {
636
+ k--;
637
+ }
638
+ result.push(s.slice(0, k));
639
+ s = s.slice(k);
640
+ }
641
+ result.push(s);
642
+ return result;
643
+ }