livekit-client 0.15.3 → 0.15.4

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 (74) hide show
  1. package/dist/api/SignalClient.d.ts +3 -1
  2. package/dist/api/SignalClient.js +59 -25
  3. package/dist/api/SignalClient.js.map +1 -1
  4. package/dist/options.d.ts +5 -0
  5. package/dist/proto/livekit_models.d.ts +30 -0
  6. package/dist/proto/livekit_models.js +219 -1
  7. package/dist/proto/livekit_models.js.map +1 -1
  8. package/dist/room/RTCEngine.d.ts +2 -0
  9. package/dist/room/RTCEngine.js +45 -2
  10. package/dist/room/RTCEngine.js.map +1 -1
  11. package/dist/room/Room.js +4 -0
  12. package/dist/room/Room.js.map +1 -1
  13. package/dist/room/participant/LocalParticipant.js +2 -1
  14. package/dist/room/participant/LocalParticipant.js.map +1 -1
  15. package/dist/room/participant/publishUtils.js +1 -1
  16. package/dist/room/participant/publishUtils.js.map +1 -1
  17. package/dist/room/participant/publishUtils.test.js +9 -0
  18. package/dist/room/participant/publishUtils.test.js.map +1 -1
  19. package/dist/room/track/RemoteTrackPublication.d.ts +1 -0
  20. package/dist/room/track/RemoteTrackPublication.js +15 -7
  21. package/dist/room/track/RemoteTrackPublication.js.map +1 -1
  22. package/dist/room/track/create.js +5 -0
  23. package/dist/room/track/create.js.map +1 -1
  24. package/dist/room/utils.d.ts +2 -0
  25. package/dist/room/utils.js +32 -1
  26. package/dist/room/utils.js.map +1 -1
  27. package/dist/version.d.ts +1 -1
  28. package/dist/version.js +1 -1
  29. package/package.json +4 -2
  30. package/src/api/SignalClient.ts +434 -0
  31. package/src/connect.ts +100 -0
  32. package/src/index.ts +47 -0
  33. package/src/logger.ts +22 -0
  34. package/src/options.ts +152 -0
  35. package/src/proto/livekit_models.ts +1863 -0
  36. package/src/proto/livekit_rtc.ts +3401 -0
  37. package/src/room/DeviceManager.ts +57 -0
  38. package/src/room/PCTransport.ts +86 -0
  39. package/src/room/RTCEngine.ts +484 -0
  40. package/src/room/Room.ts +785 -0
  41. package/src/room/errors.ts +65 -0
  42. package/src/room/events.ts +396 -0
  43. package/src/room/participant/LocalParticipant.ts +685 -0
  44. package/src/room/participant/Participant.ts +214 -0
  45. package/src/room/participant/ParticipantTrackPermission.ts +32 -0
  46. package/src/room/participant/RemoteParticipant.ts +238 -0
  47. package/src/room/participant/publishUtils.test.ts +105 -0
  48. package/src/room/participant/publishUtils.ts +180 -0
  49. package/src/room/stats.ts +130 -0
  50. package/src/room/track/LocalAudioTrack.ts +112 -0
  51. package/src/room/track/LocalTrack.ts +124 -0
  52. package/src/room/track/LocalTrackPublication.ts +63 -0
  53. package/src/room/track/LocalVideoTrack.test.ts +70 -0
  54. package/src/room/track/LocalVideoTrack.ts +416 -0
  55. package/src/room/track/RemoteAudioTrack.ts +58 -0
  56. package/src/room/track/RemoteTrack.ts +59 -0
  57. package/src/room/track/RemoteTrackPublication.ts +192 -0
  58. package/src/room/track/RemoteVideoTrack.ts +213 -0
  59. package/src/room/track/Track.ts +301 -0
  60. package/src/room/track/TrackPublication.ts +120 -0
  61. package/src/room/track/create.ts +120 -0
  62. package/src/room/track/defaults.ts +23 -0
  63. package/src/room/track/options.ts +229 -0
  64. package/src/room/track/types.ts +8 -0
  65. package/src/room/track/utils.test.ts +93 -0
  66. package/src/room/track/utils.ts +76 -0
  67. package/src/room/utils.ts +74 -0
  68. package/src/version.ts +2 -0
  69. package/.github/workflows/publish.yaml +0 -55
  70. package/.github/workflows/test.yaml +0 -36
  71. package/example/index.html +0 -247
  72. package/example/sample.ts +0 -632
  73. package/example/styles.css +0 -144
  74. package/example/webpack.config.js +0 -33
@@ -0,0 +1,74 @@
1
+ import uaparser from 'ua-parser-js';
2
+ import { ClientInfo, ClientInfo_SDK } from '../proto/livekit_models';
3
+ import { protocolVersion, version } from '../version';
4
+
5
+ const separator = '|';
6
+
7
+ export function unpackStreamId(packed: string): string[] {
8
+ const parts = packed.split(separator);
9
+ if (parts.length > 1) {
10
+ return [parts[0], packed.substr(parts[0].length + 1)];
11
+ }
12
+ return [packed, ''];
13
+ }
14
+
15
+ export async function sleep(duration: number): Promise<void> {
16
+ return new Promise((resolve) => setTimeout(resolve, duration));
17
+ }
18
+
19
+ export function isFireFox(): boolean {
20
+ return navigator.userAgent.indexOf('Firefox') !== -1;
21
+ }
22
+
23
+ function roDispatchCallback(entries: ResizeObserverEntry[]) {
24
+ for (const entry of entries) {
25
+ (entry.target as ObservableMediaElement).handleResize(entry);
26
+ }
27
+ }
28
+
29
+ function ioDispatchCallback(entries: IntersectionObserverEntry[]) {
30
+ for (const entry of entries) {
31
+ (entry.target as ObservableMediaElement).handleVisibilityChanged(entry);
32
+ }
33
+ }
34
+
35
+ let resizeObserver: ResizeObserver | null = null;
36
+ export const getResizeObserver = () => {
37
+ if (!resizeObserver) resizeObserver = new ResizeObserver(roDispatchCallback);
38
+ return resizeObserver;
39
+ };
40
+
41
+ let intersectionObserver: IntersectionObserver | null = null;
42
+ export const getIntersectionObserver = () => {
43
+ if (!intersectionObserver) intersectionObserver = new IntersectionObserver(ioDispatchCallback);
44
+ return intersectionObserver;
45
+ };
46
+
47
+ export interface ObservableMediaElement extends HTMLMediaElement {
48
+ handleResize: (entry: ResizeObserverEntry) => void;
49
+ handleVisibilityChanged: (entry: IntersectionObserverEntry) => void;
50
+ }
51
+
52
+ export function getClientInfo(): ClientInfo {
53
+ const ua = uaparser(navigator.userAgent);
54
+ const info = ClientInfo.fromPartial({
55
+ sdk: ClientInfo_SDK.JS,
56
+ protocol: protocolVersion,
57
+ version,
58
+ os: ua.os.name,
59
+ osVersion: ua.os.version,
60
+ browser: ua.browser.name,
61
+ browserVersion: ua.browser.version,
62
+ });
63
+
64
+ let model = '';
65
+ if (ua.device.vendor) {
66
+ model += ua.device.vendor;
67
+ }
68
+ if (ua.device.model) {
69
+ if (model) model += ' ';
70
+ model += ua.device.model;
71
+ }
72
+ if (model) info.deviceModel = model;
73
+ return info;
74
+ }
package/src/version.ts ADDED
@@ -0,0 +1,2 @@
1
+ export const version = '0.15.4';
2
+ export const protocolVersion = 5;
@@ -1,55 +0,0 @@
1
- name: Publish
2
-
3
- # Controls when the action will run.
4
- on:
5
- push:
6
- # only publish on version tags
7
- tags:
8
- - v*
9
-
10
- # A workflow run is made up of one or more jobs that can run sequentially or in parallel
11
- jobs:
12
- docs:
13
- # The type of runner that the job will run on
14
- runs-on: ubuntu-latest
15
-
16
- # Steps represent a sequence of tasks that will be executed as part of the job
17
- steps:
18
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19
- - uses: actions/checkout@v2
20
- - uses: actions/setup-node@v2
21
- with:
22
- node-version: '16.x'
23
- - uses: actions/cache@v2
24
- with:
25
- path: |
26
- ~/.npm
27
- ~/.config/yarn/global
28
- key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
29
- restore-keys: |
30
- ${{ runner.os }}-node-
31
-
32
- - name: Install Yarn
33
- run: |
34
- npm install -g yarn
35
- yarn install
36
-
37
- - name: Build
38
- run: yarn build
39
-
40
- - name: Build Docs
41
- run: yarn build-docs
42
-
43
- - name: Publish to npm
44
- run: |
45
- npm config set '//registry.npmjs.org/:_authToken' $NPM_TOKEN
46
- npm publish
47
- env:
48
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49
-
50
- - name: S3 Upload
51
- run: aws s3 cp docs/ s3://livekit-docs/client-sdk-js --recursive
52
- env:
53
- AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
54
- AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
55
- AWS_DEFAULT_REGION: "us-east-1"
@@ -1,36 +0,0 @@
1
- name: Test
2
- on:
3
- push:
4
- branches: [ main ]
5
- pull_request:
6
- branches: [ main ]
7
-
8
- jobs:
9
- test:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v2
13
-
14
- - uses: actions/setup-node@v2
15
- with:
16
- node-version: '16.x'
17
-
18
- - uses: actions/cache@v2
19
- with:
20
- path: |
21
- ~/.npm
22
- ~/.config/yarn/global
23
- key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
24
- restore-keys: |
25
- ${{ runner.os }}-node-
26
-
27
- - name: Install Yarn
28
- run: |
29
- npm install -g yarn
30
- yarn install
31
-
32
- - name: ESLint
33
- run: yarn lint
34
-
35
- - name: Run Tests
36
- run: yarn test
@@ -1,247 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <title>Livekit test app</title>
5
- <meta charset="utf-8" />
6
- <meta
7
- name="viewport"
8
- content="width=device-width, initial-scale=1, shrink-to-fit=no"
9
- />
10
-
11
- <link
12
- rel="stylesheet"
13
- href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
14
- integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
15
- crossorigin="anonymous"
16
- />
17
-
18
- <link rel="stylesheet" href="styles.css">
19
- </head>
20
-
21
- <body>
22
- <div class="container">
23
- <div class="row">
24
- <div class="col-md-8">
25
- <h2>Livekit Sample App</h2>
26
- <br/>
27
- <div id="connect-area">
28
- <div>
29
- <b>LiveKit URL</b>
30
- </div>
31
- <div>
32
- <input
33
- type="text"
34
- class="form-control"
35
- id="url"
36
- value="ws://localhost:7880"
37
- />
38
- </div>
39
- <div>
40
- <b>Token</b>
41
- </div>
42
- <div>
43
- <input type="text" class="form-control" id="token" />
44
- </div>
45
- </div>
46
-
47
- <!-- connect options -->
48
- <div id="options-area">
49
- <div>
50
- <input
51
- type="checkbox"
52
- class="form-check-input"
53
- id="publish-option"
54
- checked
55
- />
56
- <label for="publish-option" class="form-check-label">
57
- Publish
58
- </label>
59
- </div>
60
- <div>
61
- <input
62
- type="checkbox"
63
- class="form-check-input"
64
- id="simulcast"
65
- checked
66
- />
67
- <label for="simulcast" class="form-check-label">
68
- Simulcast
69
- </label>
70
- </div>
71
- <div>
72
- <input
73
- type="checkbox"
74
- class="form-check-input"
75
- id="dynacast"
76
- checked
77
- />
78
- <label for="dynacast" class="form-check-label">
79
- Dynacast
80
- </label>
81
- </div>
82
- <div>
83
- <input
84
- type="checkbox"
85
- class="form-check-input"
86
- id="adaptive-stream"
87
- checked
88
- />
89
- <label for="adaptive-stream" class="form-check-label">
90
- AdaptiveStream
91
- </label>
92
- </div>
93
- <div>
94
- <input
95
- type="checkbox"
96
- class="form-check-input"
97
- id="force-turn"
98
- />
99
- <label for="force-turn" class="form-check-label">
100
- Force TURN
101
- </label>
102
- </div>
103
- </div>
104
-
105
- <!-- actions -->
106
- <div id="actions-area">
107
- <div>
108
- <button
109
- id="connect-button"
110
- class="btn btn-primary mt-1"
111
- type="button"
112
- onclick="appActions.connectWithFormInput()"
113
- >
114
- Connect
115
- </button>
116
- </div>
117
- <div>
118
- <button
119
- id="toggle-audio-button"
120
- class="btn btn-secondary mt-1"
121
- disabled
122
- type="button"
123
- onclick="appActions.toggleAudio()"
124
- >
125
- Enable Mic
126
- </button>
127
- <button
128
- id="toggle-video-button"
129
- class="btn btn-secondary mt-1"
130
- disabled
131
- type="button"
132
- onclick="appActions.toggleVideo()"
133
- >
134
- Enable Camera
135
- </button>
136
- <button
137
- id="flip-video-button"
138
- class="btn btn-secondary mt-1"
139
- disabled
140
- type="button"
141
- onclick="appActions.flipVideo()"
142
- >
143
- Flip Camera
144
- </button>
145
- <button
146
- id="share-screen-button"
147
- class="btn btn-secondary mt-1"
148
- disabled
149
- type="button"
150
- onclick="appActions.shareScreen()"
151
- >
152
- Share Screen
153
- </button>
154
- <select id="simulate-scenario" class="custom-select" style="width: auto;" onchange="appActions.handleScenario(event)">
155
- <option value="" selected>Simulate</option>
156
- <option value="signal-reconnect">Signal reconnect</option>
157
- <option value="speaker">Speaker update</option>
158
- <option value="node-failure">Node failure</option>
159
- <option value="server-leave">Server booted</option>
160
- <option value="migration">Migration</option>
161
- </select>
162
- <button
163
- id="disconnect-room-button"
164
- class="btn btn-danger mt-1"
165
- disabled
166
- type="button"
167
- onclick="appActions.disconnectRoom()"
168
- >
169
- Disconnect
170
- </button>
171
- <button
172
- id="start-audio-button"
173
- class="btn btn-secondary mt-1"
174
- disabled
175
- type="button"
176
- onclick="appActions.startAudio()"
177
- >
178
- Start Audio
179
- </button>
180
- </div>
181
- </div>
182
-
183
- <div id="inputs-area">
184
- <div>
185
- <select id="video-input" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
186
- <option selected>Video Input (default)</option>
187
- </select>
188
- </div>
189
- <div>
190
- <select id="audio-input" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
191
- <option selected>Audio Input (default)</option>
192
- </select>
193
- </div>
194
- <div>
195
- <select id="audio-output" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
196
- <option selected>Audio Output (default)</option>
197
- </select>
198
- </div>
199
- </div>
200
- </div>
201
- <div class="col-md-4">
202
- <h3>Chat</h3>
203
- <div id="chat-area">
204
- <textarea class="form-control" id="chat" rows="9"></textarea>
205
- <div id="chat-input-area">
206
- <div>
207
- <input type="text" class="form-control" id="entry"
208
- placeholder="Type your message here" />
209
- </div>
210
- <div>
211
- <button
212
- id="send-button"
213
- class="btn btn-primary"
214
- type="button"
215
- onclick="appActions.enterText()"
216
- disabled
217
- >
218
- Send
219
- </button>
220
- </div>
221
- </div>
222
- </div>
223
- </div>
224
- </div>
225
-
226
- <div id="screenshare-area">
227
- <div>
228
- <span id="screenshare-info">
229
- </span>
230
- <span id="screenshare-resolution">
231
- </span>
232
- </div>
233
- <video id="screenshare-video" autoplay playsinline></video>
234
- </div>
235
-
236
- <div id="participants-area">
237
- </div>
238
-
239
- <div id="log-area">
240
- <textarea id="log"></textarea>
241
- </div>
242
- </div>
243
- <script src="bundle.js"></script>
244
- <!-- for icons -->
245
- <script src="https://kit.fontawesome.com/7c1c4c7e9c.js" crossorigin="anonymous"></script>
246
- </body>
247
- </html>