livekit-client 1.15.12 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/README.md +27 -15
  2. package/dist/livekit-client.esm.mjs +1750 -1581
  3. package/dist/livekit-client.esm.mjs.map +1 -1
  4. package/dist/livekit-client.umd.js +1 -1
  5. package/dist/livekit-client.umd.js.map +1 -1
  6. package/dist/src/api/SignalClient.d.ts +0 -2
  7. package/dist/src/api/SignalClient.d.ts.map +1 -1
  8. package/dist/src/index.d.ts +3 -3
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/options.d.ts +3 -9
  11. package/dist/src/options.d.ts.map +1 -1
  12. package/dist/src/proto/livekit_models_pb.d.ts +56 -1
  13. package/dist/src/proto/livekit_models_pb.d.ts.map +1 -1
  14. package/dist/src/proto/livekit_rtc_pb.d.ts +38 -0
  15. package/dist/src/proto/livekit_rtc_pb.d.ts.map +1 -1
  16. package/dist/src/room/PCTransport.d.ts +1 -2
  17. package/dist/src/room/PCTransport.d.ts.map +1 -1
  18. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  19. package/dist/src/room/RTCEngine.d.ts +1 -0
  20. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  21. package/dist/src/room/Room.d.ts +12 -15
  22. package/dist/src/room/Room.d.ts.map +1 -1
  23. package/dist/src/room/defaults.d.ts.map +1 -1
  24. package/dist/src/room/events.d.ts +8 -5
  25. package/dist/src/room/events.d.ts.map +1 -1
  26. package/dist/src/room/participant/LocalParticipant.d.ts +8 -25
  27. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  28. package/dist/src/room/participant/Participant.d.ts +6 -10
  29. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  30. package/dist/src/room/participant/RemoteParticipant.d.ts +9 -6
  31. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  32. package/dist/src/room/timers.d.ts +4 -5
  33. package/dist/src/room/timers.d.ts.map +1 -1
  34. package/dist/src/room/track/LocalVideoTrack.d.ts +3 -3
  35. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  36. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -2
  37. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  38. package/dist/src/room/track/Track.d.ts +5 -0
  39. package/dist/src/room/track/Track.d.ts.map +1 -1
  40. package/dist/src/room/track/options.d.ts +0 -5
  41. package/dist/src/room/track/options.d.ts.map +1 -1
  42. package/dist/src/room/types.d.ts +11 -3
  43. package/dist/src/room/types.d.ts.map +1 -1
  44. package/dist/src/version.d.ts +1 -1
  45. package/dist/ts4.2/src/api/SignalClient.d.ts +0 -2
  46. package/dist/ts4.2/src/index.d.ts +3 -3
  47. package/dist/ts4.2/src/options.d.ts +3 -9
  48. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +56 -1
  49. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +38 -0
  50. package/dist/ts4.2/src/room/PCTransport.d.ts +1 -2
  51. package/dist/ts4.2/src/room/RTCEngine.d.ts +1 -0
  52. package/dist/ts4.2/src/room/Room.d.ts +12 -15
  53. package/dist/ts4.2/src/room/events.d.ts +8 -5
  54. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +8 -25
  55. package/dist/ts4.2/src/room/participant/Participant.d.ts +6 -10
  56. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +9 -6
  57. package/dist/ts4.2/src/room/timers.d.ts +4 -5
  58. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +3 -3
  59. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +2 -2
  60. package/dist/ts4.2/src/room/track/Track.d.ts +5 -0
  61. package/dist/ts4.2/src/room/track/options.d.ts +0 -5
  62. package/dist/ts4.2/src/room/types.d.ts +11 -3
  63. package/dist/ts4.2/src/version.d.ts +1 -1
  64. package/package.json +10 -9
  65. package/src/api/SignalClient.ts +2 -6
  66. package/src/e2ee/E2eeManager.ts +2 -2
  67. package/src/index.ts +2 -4
  68. package/src/options.ts +3 -10
  69. package/src/proto/livekit_models_pb.ts +78 -0
  70. package/src/proto/livekit_rtc_pb.ts +53 -0
  71. package/src/room/PCTransport.ts +3 -13
  72. package/src/room/PCTransportManager.ts +2 -3
  73. package/src/room/RTCEngine.ts +11 -1
  74. package/src/room/Room.ts +145 -114
  75. package/src/room/defaults.ts +1 -5
  76. package/src/room/events.ts +8 -6
  77. package/src/room/participant/LocalParticipant.ts +36 -77
  78. package/src/room/participant/Participant.ts +23 -24
  79. package/src/room/participant/RemoteParticipant.ts +27 -24
  80. package/src/room/track/LocalVideoTrack.test.ts +1 -1
  81. package/src/room/track/LocalVideoTrack.ts +11 -7
  82. package/src/room/track/RemoteTrackPublication.ts +2 -7
  83. package/src/room/track/Track.ts +10 -1
  84. package/src/room/track/options.ts +0 -6
  85. package/src/room/types.ts +11 -4
  86. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -1,14 +1,20 @@
1
1
  <!--BEGIN_BANNER_IMAGE-->
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="/.github/banner_dark.png">
4
- <source media="(prefers-color-scheme: light)" srcset="/.github/banner_light.png">
5
- <img style="width:100%;" alt="The LiveKit icon, the name of the repository and some sample code in the background." src="/.github/banner_light.png">
6
- </picture>
7
- <!--END_BANNER_IMAGE-->
2
+
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="/.github/banner_dark.png">
5
+ <source media="(prefers-color-scheme: light)" srcset="/.github/banner_light.png">
6
+ <img style="width:100%;" alt="The LiveKit icon, the name of the repository and some sample code in the background." src="https://raw.githubusercontent.com/livekit/client-sdk-js/main/.github/banner_light.png">
7
+ </picture>
8
+
9
+ <!--END_BANNER_IMAGE-->
8
10
 
9
11
  # JavaScript/TypeScript client SDK for LiveKit
10
12
 
11
- <!--BEGIN_DESCRIPTION-->Use this SDK to add real-time video, audio and data features to your JavaScript/TypeScript app. By connecting to a self- or cloud-hosted <a href="https://livekit.io/">LiveKit</a> server, you can quickly build applications like interactive live streaming or video calls with just a few lines of code.<!--END_DESCRIPTION-->
13
+ <!--BEGIN_DESCRIPTION-->
14
+
15
+ Use this SDK to add real-time video, audio and data features to your JavaScript/TypeScript app. By connecting to a self- or cloud-hosted <a href="https://livekit.io/">LiveKit</a> server, you can quickly build applications like interactive live streaming or video calls with just a few lines of code.
16
+
17
+ <!--END_DESCRIPTION-->
12
18
 
13
19
  ## Docs
14
20
 
@@ -16,6 +22,10 @@ Docs and guides at [https://docs.livekit.io](https://docs.livekit.io)
16
22
 
17
23
  [SDK reference](https://docs.livekit.io/client-sdk-js/)
18
24
 
25
+ > [!NOTE]
26
+ > This is v2 of `livekit-client`. When migrating from v1.x to v2.x you might encounter a small set of breaking changes.
27
+ > Read the [migration guide](https://docs.livekit.io/guides/migrate-from-v1/) for a detailed overview of what has changed.
28
+
19
29
  ## Installation
20
30
 
21
31
  ### Yarn
@@ -51,6 +61,7 @@ const livekit = require('livekit-client');
51
61
 
52
62
  const room = new livekit.Room(...);
53
63
 
64
+ // call this some time before actually connecting to speed up the actual connection
54
65
  room.prepareConnection(url, token);
55
66
 
56
67
  await room.connect(...);
@@ -164,14 +175,14 @@ await p.setCameraEnabled(false);
164
175
  Similarly, you can access these common track types on the other participants' end.
165
176
 
166
177
  ```typescript
167
- // get a RemoteParticipant by their sid
168
- const p = room.participants.get('participant-sid');
178
+ // get a RemoteParticipant by their identity
179
+ const p = room.remoteParticipants.get('participant-identity');
169
180
  if (p) {
170
181
  // if the other user has enabled their camera, attach it to a new HTMLVideoElement
171
182
  if (p.isCameraEnabled) {
172
- const track = p.getTrack(Track.Source.Camera);
173
- if (track?.isSubscribed) {
174
- const videoElement = track.videoTrack?.attach();
183
+ const publication = p.getTrackPublication(Track.Source.Camera);
184
+ if (publication?.isSubscribed) {
185
+ const videoElement = publication.videoTrack?.attach();
175
186
  // do something with the element
176
187
  }
177
188
  }
@@ -323,9 +334,10 @@ Also when targeting legacy browsers, older than the ones specified in our browse
323
334
 
324
335
  <thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
325
336
  <tbody>
326
- <tr><td>Client SDKs</td><td><a href="https://github.com/livekit/components-js">Components</a> · <b>JavaScript</b> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
327
- <tr><td>Server SDKs</td><td><a href="https://github.com/livekit/server-sdk-js">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a> · <a href="https://github.com/tradablebits/livekit-server-sdk-python">Python (community)</a></td></tr><tr></tr>
328
- <tr><td>Services</td><td><a href="https://github.com/livekit/livekit">Livekit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a></td></tr><tr></tr>
337
+ <tr><td>Real-time SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <b>JavaScript</b> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
338
+ <tr><td>Server APIs</td><td><a href="https://github.com/livekit/server-sdk-js">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <a href="https://github.com/livekit/server-sdk-ruby">Ruby</a> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/livekit/client-sdk-python">Python</a> · <a href="https://github.com/livekit/client-sdk-rust">Rust</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a></td></tr><tr></tr>
339
+ <tr><td>Agents Frameworks</td><td><a href="https://github.com/livekit/agents">Python</a> · <a href="https://github.com/livekit/agent-playground">Playground</a></td></tr><tr></tr>
340
+ <tr><td>Services</td><td><a href="https://github.com/livekit/livekit">Livekit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a> · <a href="https://github.com/livekit/sip">SIP</a></td></tr><tr></tr>
329
341
  <tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/oss/deployment">Self-hosting</a> · <a href="https://github.com/livekit/livekit-cli">CLI</a></td></tr>
330
342
  </tbody>
331
343
  </table>