livekit-client 0.18.6 → 1.0.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 (46) hide show
  1. package/README.md +1 -1
  2. package/dist/api/SignalClient.d.ts +2 -2
  3. package/dist/api/SignalClient.d.ts.map +1 -1
  4. package/dist/index.d.ts +2 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/livekit-client.esm.mjs +131 -215
  7. package/dist/livekit-client.esm.mjs.map +1 -1
  8. package/dist/livekit-client.umd.js +1 -1
  9. package/dist/livekit-client.umd.js.map +1 -1
  10. package/dist/options.d.ts +1 -68
  11. package/dist/options.d.ts.map +1 -1
  12. package/dist/room/DeviceManager.d.ts.map +1 -1
  13. package/dist/room/RTCEngine.d.ts +3 -2
  14. package/dist/room/RTCEngine.d.ts.map +1 -1
  15. package/dist/room/Room.d.ts +11 -7
  16. package/dist/room/Room.d.ts.map +1 -1
  17. package/dist/room/events.d.ts +6 -12
  18. package/dist/room/events.d.ts.map +1 -1
  19. package/dist/room/participant/LocalParticipant.d.ts.map +1 -1
  20. package/dist/room/participant/Participant.d.ts +0 -4
  21. package/dist/room/participant/Participant.d.ts.map +1 -1
  22. package/dist/room/participant/RemoteParticipant.d.ts +3 -2
  23. package/dist/room/participant/RemoteParticipant.d.ts.map +1 -1
  24. package/dist/room/track/options.d.ts +0 -30
  25. package/dist/room/track/options.d.ts.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/dist/version.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/api/SignalClient.ts +32 -7
  30. package/src/index.ts +2 -2
  31. package/src/options.ts +0 -82
  32. package/src/room/DeviceManager.ts +4 -1
  33. package/src/room/RTCEngine.ts +16 -7
  34. package/src/room/Room.ts +65 -41
  35. package/src/room/events.ts +7 -14
  36. package/src/room/participant/LocalParticipant.ts +4 -0
  37. package/src/room/participant/Participant.ts +0 -5
  38. package/src/room/participant/RemoteParticipant.ts +16 -5
  39. package/src/room/participant/publishUtils.test.ts +2 -2
  40. package/src/room/track/create.ts +1 -1
  41. package/src/room/track/options.ts +0 -30
  42. package/src/room/track/utils.test.ts +6 -6
  43. package/src/version.ts +1 -1
  44. package/dist/connect.d.ts +0 -24
  45. package/dist/connect.d.ts.map +0 -1
  46. package/src/connect.ts +0 -98
package/src/connect.ts DELETED
@@ -1,98 +0,0 @@
1
- import log, { LogLevel, setLogLevel } from './logger';
2
- import { ConnectOptions } from './options';
3
- import { MediaDeviceFailure } from './room/errors';
4
- import { RoomEvent } from './room/events';
5
- import Room from './room/Room';
6
-
7
- export { version } from './version';
8
-
9
- /**
10
- * @deprecated Use room.connect() instead
11
- *
12
- * Connects to a LiveKit room, shorthand for `new Room()` and [[Room.connect]]
13
- *
14
- * ```typescript
15
- * connect('wss://myhost.livekit.io', token, {
16
- * // publish audio and video tracks on joining
17
- * audio: true,
18
- * video: true,
19
- * captureDefaults: {
20
- * facingMode: 'user',
21
- * },
22
- * })
23
- * ```
24
- * @param url URL to LiveKit server
25
- * @param token AccessToken, a JWT token that includes authentication and room details
26
- * @param options
27
- */
28
- export async function connect(url: string, token: string, options?: ConnectOptions): Promise<Room> {
29
- options ??= {};
30
- if (options.adaptiveStream === undefined) {
31
- options.adaptiveStream = options.autoManageVideo === true ? {} : undefined;
32
- }
33
- setLogLevel(options.logLevel ?? LogLevel.warn);
34
-
35
- const config: RTCConfiguration = options.rtcConfig ?? {};
36
- if (options.iceServers) {
37
- config.iceServers = options.iceServers;
38
- }
39
-
40
- const room = new Room(options);
41
-
42
- // connect to room
43
- await room.connect(url, token, options);
44
-
45
- const publishAudio: boolean = options.audio ?? false;
46
- const publishVideo: boolean = options.video ?? false;
47
-
48
- if (publishAudio || publishVideo) {
49
- setTimeout(async () => {
50
- // if publishing both
51
- let err: any;
52
- if (publishAudio && publishVideo) {
53
- try {
54
- await room.localParticipant.enableCameraAndMicrophone();
55
- } catch (e) {
56
- const errKind = MediaDeviceFailure.getFailure(e);
57
- log.warn('received error while creating media', { error: errKind });
58
- if (e instanceof Error) {
59
- log.warn(e.message);
60
- }
61
-
62
- // when it's a device issue, try to publish the other kind
63
- if (
64
- errKind === MediaDeviceFailure.NotFound ||
65
- errKind === MediaDeviceFailure.DeviceInUse
66
- ) {
67
- try {
68
- await room.localParticipant.setMicrophoneEnabled(true);
69
- } catch (audioErr) {
70
- err = audioErr;
71
- }
72
- } else {
73
- err = e;
74
- }
75
- }
76
- } else if (publishAudio) {
77
- try {
78
- await room.localParticipant.setMicrophoneEnabled(true);
79
- } catch (e) {
80
- err = e;
81
- }
82
- } else if (publishVideo) {
83
- try {
84
- await room.localParticipant.setCameraEnabled(true);
85
- } catch (e) {
86
- err = e;
87
- }
88
- }
89
-
90
- if (err) {
91
- room.emit(RoomEvent.MediaDevicesError, err);
92
- log.error('could not create media', err);
93
- }
94
- });
95
- }
96
-
97
- return room;
98
- }