livekit-client 0.15.0 → 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 (136) hide show
  1. package/.gitmodules +3 -0
  2. package/README.md +21 -4
  3. package/dist/api/SignalClient.d.ts +11 -2
  4. package/dist/api/SignalClient.js +92 -25
  5. package/dist/api/SignalClient.js.map +1 -1
  6. package/dist/connect.js +3 -0
  7. package/dist/connect.js.map +1 -1
  8. package/dist/index.d.ts +5 -2
  9. package/dist/index.js +6 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/logger.js +1 -0
  12. package/dist/logger.js.map +1 -1
  13. package/dist/options.d.ts +28 -14
  14. package/dist/proto/livekit_models.d.ts +48 -0
  15. package/dist/proto/livekit_models.js +367 -5
  16. package/dist/proto/livekit_models.js.map +1 -1
  17. package/dist/proto/livekit_rtc.d.ts +100 -1
  18. package/dist/proto/livekit_rtc.js +745 -3
  19. package/dist/proto/livekit_rtc.js.map +1 -1
  20. package/dist/room/PCTransport.js +4 -0
  21. package/dist/room/PCTransport.js.map +1 -1
  22. package/dist/room/RTCEngine.d.ts +4 -0
  23. package/dist/room/RTCEngine.js +73 -34
  24. package/dist/room/RTCEngine.js.map +1 -1
  25. package/dist/room/Room.d.ts +15 -0
  26. package/dist/room/Room.js +172 -59
  27. package/dist/room/Room.js.map +1 -1
  28. package/dist/room/events.d.ts +60 -24
  29. package/dist/room/events.js +58 -22
  30. package/dist/room/events.js.map +1 -1
  31. package/dist/room/participant/LocalParticipant.d.ts +26 -2
  32. package/dist/room/participant/LocalParticipant.js +69 -21
  33. package/dist/room/participant/LocalParticipant.js.map +1 -1
  34. package/dist/room/participant/Participant.d.ts +3 -1
  35. package/dist/room/participant/Participant.js +1 -0
  36. package/dist/room/participant/Participant.js.map +1 -1
  37. package/dist/room/participant/ParticipantTrackPermission.d.ts +19 -0
  38. package/dist/room/participant/ParticipantTrackPermission.js +16 -0
  39. package/dist/room/participant/ParticipantTrackPermission.js.map +1 -0
  40. package/dist/room/participant/RemoteParticipant.d.ts +2 -2
  41. package/dist/room/participant/RemoteParticipant.js +9 -15
  42. package/dist/room/participant/RemoteParticipant.js.map +1 -1
  43. package/dist/room/participant/publishUtils.d.ts +1 -1
  44. package/dist/room/participant/publishUtils.js +4 -4
  45. package/dist/room/participant/publishUtils.js.map +1 -1
  46. package/dist/room/participant/publishUtils.test.js +10 -1
  47. package/dist/room/participant/publishUtils.test.js.map +1 -1
  48. package/dist/room/stats.d.ts +21 -6
  49. package/dist/room/stats.js +22 -1
  50. package/dist/room/stats.js.map +1 -1
  51. package/dist/room/track/LocalAudioTrack.d.ts +5 -1
  52. package/dist/room/track/LocalAudioTrack.js +45 -1
  53. package/dist/room/track/LocalAudioTrack.js.map +1 -1
  54. package/dist/room/track/LocalTrack.js +1 -1
  55. package/dist/room/track/LocalTrack.js.map +1 -1
  56. package/dist/room/track/LocalTrackPublication.d.ts +3 -1
  57. package/dist/room/track/LocalTrackPublication.js +15 -5
  58. package/dist/room/track/LocalTrackPublication.js.map +1 -1
  59. package/dist/room/track/LocalVideoTrack.d.ts +8 -1
  60. package/dist/room/track/LocalVideoTrack.js +117 -52
  61. package/dist/room/track/LocalVideoTrack.js.map +1 -1
  62. package/dist/room/track/RemoteAudioTrack.d.ts +6 -8
  63. package/dist/room/track/RemoteAudioTrack.js +55 -19
  64. package/dist/room/track/RemoteAudioTrack.js.map +1 -1
  65. package/dist/room/track/RemoteTrack.d.ts +14 -0
  66. package/dist/room/track/RemoteTrack.js +47 -0
  67. package/dist/room/track/RemoteTrack.js.map +1 -0
  68. package/dist/room/track/RemoteTrackPublication.d.ts +10 -2
  69. package/dist/room/track/RemoteTrackPublication.js +49 -16
  70. package/dist/room/track/RemoteTrackPublication.js.map +1 -1
  71. package/dist/room/track/RemoteVideoTrack.d.ts +7 -7
  72. package/dist/room/track/RemoteVideoTrack.js +66 -22
  73. package/dist/room/track/RemoteVideoTrack.js.map +1 -1
  74. package/dist/room/track/Track.d.ts +12 -0
  75. package/dist/room/track/Track.js +33 -0
  76. package/dist/room/track/Track.js.map +1 -1
  77. package/dist/room/track/TrackPublication.d.ts +14 -1
  78. package/dist/room/track/TrackPublication.js +24 -7
  79. package/dist/room/track/TrackPublication.js.map +1 -1
  80. package/dist/room/track/create.d.ts +23 -0
  81. package/dist/room/track/create.js +130 -0
  82. package/dist/room/track/create.js.map +1 -0
  83. package/dist/room/track/defaults.d.ts +4 -0
  84. package/dist/room/track/defaults.js +21 -0
  85. package/dist/room/track/defaults.js.map +1 -0
  86. package/dist/room/utils.d.ts +3 -1
  87. package/dist/room/utils.js +36 -6
  88. package/dist/room/utils.js.map +1 -1
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/package.json +5 -3
  92. package/src/api/SignalClient.ts +434 -0
  93. package/src/connect.ts +100 -0
  94. package/src/index.ts +47 -0
  95. package/src/logger.ts +22 -0
  96. package/src/options.ts +152 -0
  97. package/src/proto/livekit_models.ts +1863 -0
  98. package/src/proto/livekit_rtc.ts +3401 -0
  99. package/src/room/DeviceManager.ts +57 -0
  100. package/src/room/PCTransport.ts +86 -0
  101. package/src/room/RTCEngine.ts +484 -0
  102. package/src/room/Room.ts +785 -0
  103. package/src/room/errors.ts +65 -0
  104. package/src/room/events.ts +396 -0
  105. package/src/room/participant/LocalParticipant.ts +685 -0
  106. package/src/room/participant/Participant.ts +214 -0
  107. package/src/room/participant/ParticipantTrackPermission.ts +32 -0
  108. package/src/room/participant/RemoteParticipant.ts +238 -0
  109. package/src/room/participant/publishUtils.test.ts +105 -0
  110. package/src/room/participant/publishUtils.ts +180 -0
  111. package/src/room/stats.ts +130 -0
  112. package/src/room/track/LocalAudioTrack.ts +112 -0
  113. package/src/room/track/LocalTrack.ts +124 -0
  114. package/src/room/track/LocalTrackPublication.ts +63 -0
  115. package/src/room/track/LocalVideoTrack.test.ts +70 -0
  116. package/src/room/track/LocalVideoTrack.ts +416 -0
  117. package/src/room/track/RemoteAudioTrack.ts +58 -0
  118. package/src/room/track/RemoteTrack.ts +59 -0
  119. package/src/room/track/RemoteTrackPublication.ts +192 -0
  120. package/src/room/track/RemoteVideoTrack.ts +213 -0
  121. package/src/room/track/Track.ts +301 -0
  122. package/src/room/track/TrackPublication.ts +120 -0
  123. package/src/room/track/create.ts +120 -0
  124. package/src/room/track/defaults.ts +23 -0
  125. package/src/room/track/options.ts +229 -0
  126. package/src/room/track/types.ts +8 -0
  127. package/src/room/track/utils.test.ts +93 -0
  128. package/src/room/track/utils.ts +76 -0
  129. package/src/room/utils.ts +74 -0
  130. package/src/version.ts +2 -0
  131. package/.github/workflows/publish.yaml +0 -55
  132. package/.github/workflows/test.yaml +0 -36
  133. package/example/index.html +0 -237
  134. package/example/sample.ts +0 -575
  135. package/example/styles.css +0 -144
  136. 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,237 +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="adaptive-video"
76
- checked
77
- />
78
- <label for="adaptive-video" class="form-check-label">
79
- Adaptive video
80
- </label>
81
- </div>
82
- <div>
83
- <input
84
- type="checkbox"
85
- class="form-check-input"
86
- id="force-turn"
87
- />
88
- <label for="force-turn" class="form-check-label">
89
- Force TURN
90
- </label>
91
- </div>
92
- </div>
93
-
94
- <!-- actions -->
95
- <div id="actions-area">
96
- <div>
97
- <button
98
- id="connect-button"
99
- class="btn btn-primary mt-1"
100
- type="button"
101
- onclick="appActions.connectWithFormInput()"
102
- >
103
- Connect
104
- </button>
105
- </div>
106
- <div>
107
- <button
108
- id="toggle-audio-button"
109
- class="btn btn-secondary mt-1"
110
- disabled
111
- type="button"
112
- onclick="appActions.toggleAudio()"
113
- >
114
- Enable Mic
115
- </button>
116
- <button
117
- id="toggle-video-button"
118
- class="btn btn-secondary mt-1"
119
- disabled
120
- type="button"
121
- onclick="appActions.toggleVideo()"
122
- >
123
- Enable Camera
124
- </button>
125
- <button
126
- id="flip-video-button"
127
- class="btn btn-secondary mt-1"
128
- disabled
129
- type="button"
130
- onclick="appActions.flipVideo()"
131
- >
132
- Flip Camera
133
- </button>
134
- <button
135
- id="share-screen-button"
136
- class="btn btn-secondary mt-1"
137
- disabled
138
- type="button"
139
- onclick="appActions.shareScreen()"
140
- >
141
- Share Screen
142
- </button>
143
- <button
144
- id="disconnect-ws-button"
145
- class="btn btn-warning mt-1"
146
- disabled
147
- type="button"
148
- onclick="appActions.disconnectSignal()"
149
- >
150
- Signal Reconnect
151
- </button>
152
- <button
153
- id="disconnect-room-button"
154
- class="btn btn-danger mt-1"
155
- disabled
156
- type="button"
157
- onclick="appActions.disconnectRoom()"
158
- >
159
- Disconnect
160
- </button>
161
- <button
162
- id="start-audio-button"
163
- class="btn btn-secondary mt-1"
164
- disabled
165
- type="button"
166
- onclick="appActions.startAudio()"
167
- >
168
- Start Audio
169
- </button>
170
- </div>
171
- </div>
172
-
173
- <div id="inputs-area">
174
- <div>
175
- <select id="video-input" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
176
- <option selected>Video Input (default)</option>
177
- </select>
178
- </div>
179
- <div>
180
- <select id="audio-input" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
181
- <option selected>Audio Input (default)</option>
182
- </select>
183
- </div>
184
- <div>
185
- <select id="audio-output" class="custom-select" onchange="appActions.handleDeviceSelected(event)">
186
- <option selected>Audio Output (default)</option>
187
- </select>
188
- </div>
189
- </div>
190
- </div>
191
- <div class="col-md-4">
192
- <h3>Chat</h3>
193
- <div id="chat-area">
194
- <textarea class="form-control" id="chat" rows="9"></textarea>
195
- <div id="chat-input-area">
196
- <div>
197
- <input type="text" class="form-control" id="entry"
198
- placeholder="Type your message here" />
199
- </div>
200
- <div>
201
- <button
202
- id="send-button"
203
- class="btn btn-primary"
204
- type="button"
205
- onclick="appActions.enterText()"
206
- disabled
207
- >
208
- Send
209
- </button>
210
- </div>
211
- </div>
212
- </div>
213
- </div>
214
- </div>
215
-
216
- <div id="screenshare-area">
217
- <div>
218
- <span id="screenshare-info">
219
- </span>
220
- <span id="screenshare-resolution">
221
- </span>
222
- </div>
223
- <video id="screenshare-video" autoplay playsinline></video>
224
- </div>
225
-
226
- <div id="participants-area">
227
- </div>
228
-
229
- <div id="log-area">
230
- <textarea id="log"></textarea>
231
- </div>
232
- </div>
233
- <script src="bundle.js"></script>
234
- <!-- for icons -->
235
- <script src="https://kit.fontawesome.com/7c1c4c7e9c.js" crossorigin="anonymous"></script>
236
- </body>
237
- </html>