@dtelecom/livekit-client 1.12.1

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 (279) hide show
  1. package/LICENSE +175 -0
  2. package/README.md +315 -0
  3. package/dist/@dtelecom/livekit-client.e2ee.worker.js +2 -0
  4. package/dist/@dtelecom/livekit-client.e2ee.worker.js.map +1 -0
  5. package/dist/@dtelecom/livekit-client.e2ee.worker.mjs +1633 -0
  6. package/dist/@dtelecom/livekit-client.e2ee.worker.mjs.map +1 -0
  7. package/dist/@dtelecom/livekit-client.esm.mjs +22545 -0
  8. package/dist/@dtelecom/livekit-client.esm.mjs.map +1 -0
  9. package/dist/@dtelecom/livekit-client.umd.js +2 -0
  10. package/dist/@dtelecom/livekit-client.umd.js.map +1 -0
  11. package/dist/@dtelecom/src/api/SignalClient.d.ts +102 -0
  12. package/dist/@dtelecom/src/api/SignalClient.d.ts.map +1 -0
  13. package/dist/@dtelecom/src/connectionHelper/ConnectionCheck.d.ts +26 -0
  14. package/dist/@dtelecom/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
  15. package/dist/@dtelecom/src/connectionHelper/checks/Checker.d.ts +59 -0
  16. package/dist/@dtelecom/src/connectionHelper/checks/Checker.d.ts.map +1 -0
  17. package/dist/@dtelecom/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  18. package/dist/@dtelecom/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
  19. package/dist/@dtelecom/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  20. package/dist/@dtelecom/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
  21. package/dist/@dtelecom/src/connectionHelper/checks/reconnect.d.ts +6 -0
  22. package/dist/@dtelecom/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
  23. package/dist/@dtelecom/src/connectionHelper/checks/turn.d.ts +6 -0
  24. package/dist/@dtelecom/src/connectionHelper/checks/turn.d.ts.map +1 -0
  25. package/dist/@dtelecom/src/connectionHelper/checks/webrtc.d.ts +6 -0
  26. package/dist/@dtelecom/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
  27. package/dist/@dtelecom/src/connectionHelper/checks/websocket.d.ts +6 -0
  28. package/dist/@dtelecom/src/connectionHelper/checks/websocket.d.ts.map +1 -0
  29. package/dist/@dtelecom/src/e2ee/E2eeManager.d.ts +47 -0
  30. package/dist/@dtelecom/src/e2ee/E2eeManager.d.ts.map +1 -0
  31. package/dist/@dtelecom/src/e2ee/KeyProvider.d.ts +44 -0
  32. package/dist/@dtelecom/src/e2ee/KeyProvider.d.ts.map +1 -0
  33. package/dist/@dtelecom/src/e2ee/constants.d.ts +15 -0
  34. package/dist/@dtelecom/src/e2ee/constants.d.ts.map +1 -0
  35. package/dist/@dtelecom/src/e2ee/errors.d.ts +11 -0
  36. package/dist/@dtelecom/src/e2ee/errors.d.ts.map +1 -0
  37. package/dist/@dtelecom/src/e2ee/index.d.ts +4 -0
  38. package/dist/@dtelecom/src/e2ee/index.d.ts.map +1 -0
  39. package/dist/@dtelecom/src/e2ee/types.d.ts +130 -0
  40. package/dist/@dtelecom/src/e2ee/types.d.ts.map +1 -0
  41. package/dist/@dtelecom/src/e2ee/utils.d.ts +24 -0
  42. package/dist/@dtelecom/src/e2ee/utils.d.ts.map +1 -0
  43. package/dist/@dtelecom/src/e2ee/worker/FrameCryptor.d.ts +176 -0
  44. package/dist/@dtelecom/src/e2ee/worker/FrameCryptor.d.ts.map +1 -0
  45. package/dist/@dtelecom/src/e2ee/worker/ParticipantKeyHandler.d.ts +65 -0
  46. package/dist/@dtelecom/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -0
  47. package/dist/@dtelecom/src/e2ee/worker/e2ee.worker.d.ts +2 -0
  48. package/dist/@dtelecom/src/e2ee/worker/e2ee.worker.d.ts.map +1 -0
  49. package/dist/@dtelecom/src/index.d.ts +38 -0
  50. package/dist/@dtelecom/src/index.d.ts.map +1 -0
  51. package/dist/@dtelecom/src/logger.d.ts +29 -0
  52. package/dist/@dtelecom/src/logger.d.ts.map +1 -0
  53. package/dist/@dtelecom/src/options.d.ts +104 -0
  54. package/dist/@dtelecom/src/options.d.ts.map +1 -0
  55. package/dist/@dtelecom/src/proto/livekit_models_pb.d.ts +1264 -0
  56. package/dist/@dtelecom/src/proto/livekit_models_pb.d.ts.map +1 -0
  57. package/dist/@dtelecom/src/proto/livekit_rtc_pb.d.ts +1373 -0
  58. package/dist/@dtelecom/src/proto/livekit_rtc_pb.d.ts.map +1 -0
  59. package/dist/@dtelecom/src/room/DefaultReconnectPolicy.d.ts +8 -0
  60. package/dist/@dtelecom/src/room/DefaultReconnectPolicy.d.ts.map +1 -0
  61. package/dist/@dtelecom/src/room/DeviceManager.d.ts +9 -0
  62. package/dist/@dtelecom/src/room/DeviceManager.d.ts.map +1 -0
  63. package/dist/@dtelecom/src/room/PCTransport.d.ts +41 -0
  64. package/dist/@dtelecom/src/room/PCTransport.d.ts.map +1 -0
  65. package/dist/@dtelecom/src/room/RTCEngine.d.ts +143 -0
  66. package/dist/@dtelecom/src/room/RTCEngine.d.ts.map +1 -0
  67. package/dist/@dtelecom/src/room/ReconnectPolicy.d.ts +24 -0
  68. package/dist/@dtelecom/src/room/ReconnectPolicy.d.ts.map +1 -0
  69. package/dist/@dtelecom/src/room/RegionUrlProvider.d.ts +17 -0
  70. package/dist/@dtelecom/src/room/RegionUrlProvider.d.ts.map +1 -0
  71. package/dist/@dtelecom/src/room/Room.d.ts +248 -0
  72. package/dist/@dtelecom/src/room/Room.d.ts.map +1 -0
  73. package/dist/@dtelecom/src/room/defaults.d.ts +8 -0
  74. package/dist/@dtelecom/src/room/defaults.d.ts.map +1 -0
  75. package/dist/@dtelecom/src/room/errors.d.ts +43 -0
  76. package/dist/@dtelecom/src/room/errors.d.ts.map +1 -0
  77. package/dist/@dtelecom/src/room/events.d.ts +477 -0
  78. package/dist/@dtelecom/src/room/events.d.ts.map +1 -0
  79. package/dist/@dtelecom/src/room/participant/LocalParticipant.d.ts +177 -0
  80. package/dist/@dtelecom/src/room/participant/LocalParticipant.d.ts.map +1 -0
  81. package/dist/@dtelecom/src/room/participant/Participant.d.ts +95 -0
  82. package/dist/@dtelecom/src/room/participant/Participant.d.ts.map +1 -0
  83. package/dist/@dtelecom/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  84. package/dist/@dtelecom/src/room/participant/ParticipantTrackPermission.d.ts.map +1 -0
  85. package/dist/@dtelecom/src/room/participant/RemoteParticipant.d.ts +55 -0
  86. package/dist/@dtelecom/src/room/participant/RemoteParticipant.d.ts.map +1 -0
  87. package/dist/@dtelecom/src/room/participant/publishUtils.d.ts +28 -0
  88. package/dist/@dtelecom/src/room/participant/publishUtils.d.ts.map +1 -0
  89. package/dist/@dtelecom/src/room/stats.d.ts +67 -0
  90. package/dist/@dtelecom/src/room/stats.d.ts.map +1 -0
  91. package/dist/@dtelecom/src/room/timers.d.ts +13 -0
  92. package/dist/@dtelecom/src/room/timers.d.ts.map +1 -0
  93. package/dist/@dtelecom/src/room/track/LocalAudioTrack.d.ts +25 -0
  94. package/dist/@dtelecom/src/room/track/LocalAudioTrack.d.ts.map +1 -0
  95. package/dist/@dtelecom/src/room/track/LocalTrack.d.ts +78 -0
  96. package/dist/@dtelecom/src/room/track/LocalTrack.d.ts.map +1 -0
  97. package/dist/@dtelecom/src/room/track/LocalTrackPublication.d.ts +38 -0
  98. package/dist/@dtelecom/src/room/track/LocalTrackPublication.d.ts.map +1 -0
  99. package/dist/@dtelecom/src/room/track/LocalVideoTrack.d.ts +54 -0
  100. package/dist/@dtelecom/src/room/track/LocalVideoTrack.d.ts.map +1 -0
  101. package/dist/@dtelecom/src/room/track/RemoteAudioTrack.d.ts +53 -0
  102. package/dist/@dtelecom/src/room/track/RemoteAudioTrack.d.ts.map +1 -0
  103. package/dist/@dtelecom/src/room/track/RemoteTrack.d.ts +15 -0
  104. package/dist/@dtelecom/src/room/track/RemoteTrack.d.ts.map +1 -0
  105. package/dist/@dtelecom/src/room/track/RemoteTrackPublication.d.ts +64 -0
  106. package/dist/@dtelecom/src/room/track/RemoteTrackPublication.d.ts.map +1 -0
  107. package/dist/@dtelecom/src/room/track/RemoteVideoTrack.d.ts +56 -0
  108. package/dist/@dtelecom/src/room/track/RemoteVideoTrack.d.ts.map +1 -0
  109. package/dist/@dtelecom/src/room/track/Track.d.ts +125 -0
  110. package/dist/@dtelecom/src/room/track/Track.d.ts.map +1 -0
  111. package/dist/@dtelecom/src/room/track/TrackPublication.d.ts +72 -0
  112. package/dist/@dtelecom/src/room/track/TrackPublication.d.ts.map +1 -0
  113. package/dist/@dtelecom/src/room/track/create.d.ts +24 -0
  114. package/dist/@dtelecom/src/room/track/create.d.ts.map +1 -0
  115. package/dist/@dtelecom/src/room/track/facingMode.d.ts +41 -0
  116. package/dist/@dtelecom/src/room/track/facingMode.d.ts.map +1 -0
  117. package/dist/@dtelecom/src/room/track/options.d.ts +272 -0
  118. package/dist/@dtelecom/src/room/track/options.d.ts.map +1 -0
  119. package/dist/@dtelecom/src/room/track/processor/types.d.ts +19 -0
  120. package/dist/@dtelecom/src/room/track/processor/types.d.ts.map +1 -0
  121. package/dist/@dtelecom/src/room/track/types.d.ts +24 -0
  122. package/dist/@dtelecom/src/room/track/types.d.ts.map +1 -0
  123. package/dist/@dtelecom/src/room/track/utils.d.ts +27 -0
  124. package/dist/@dtelecom/src/room/track/utils.d.ts.map +1 -0
  125. package/dist/@dtelecom/src/room/types.d.ts +26 -0
  126. package/dist/@dtelecom/src/room/types.d.ts.map +1 -0
  127. package/dist/@dtelecom/src/room/utils.d.ts +92 -0
  128. package/dist/@dtelecom/src/room/utils.d.ts.map +1 -0
  129. package/dist/@dtelecom/src/test/MockMediaStreamTrack.d.ts +26 -0
  130. package/dist/@dtelecom/src/test/MockMediaStreamTrack.d.ts.map +1 -0
  131. package/dist/@dtelecom/src/test/mocks.d.ts +12 -0
  132. package/dist/@dtelecom/src/test/mocks.d.ts.map +1 -0
  133. package/dist/@dtelecom/src/utils/AsyncQueue.d.ts +23 -0
  134. package/dist/@dtelecom/src/utils/AsyncQueue.d.ts.map +1 -0
  135. package/dist/@dtelecom/src/utils/browserParser.d.ts +12 -0
  136. package/dist/@dtelecom/src/utils/browserParser.d.ts.map +1 -0
  137. package/dist/@dtelecom/src/version.d.ts +3 -0
  138. package/dist/@dtelecom/src/version.d.ts.map +1 -0
  139. package/dist/ts4.2/@dtelecom/src/api/SignalClient.d.ts +105 -0
  140. package/dist/ts4.2/@dtelecom/src/connectionHelper/ConnectionCheck.d.ts +26 -0
  141. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/Checker.d.ts +59 -0
  142. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  143. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  144. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/reconnect.d.ts +6 -0
  145. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/turn.d.ts +6 -0
  146. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/webrtc.d.ts +6 -0
  147. package/dist/ts4.2/@dtelecom/src/connectionHelper/checks/websocket.d.ts +6 -0
  148. package/dist/ts4.2/@dtelecom/src/e2ee/E2eeManager.d.ts +47 -0
  149. package/dist/ts4.2/@dtelecom/src/e2ee/KeyProvider.d.ts +44 -0
  150. package/dist/ts4.2/@dtelecom/src/e2ee/constants.d.ts +15 -0
  151. package/dist/ts4.2/@dtelecom/src/e2ee/errors.d.ts +11 -0
  152. package/dist/ts4.2/@dtelecom/src/e2ee/index.d.ts +4 -0
  153. package/dist/ts4.2/@dtelecom/src/e2ee/types.d.ts +130 -0
  154. package/dist/ts4.2/@dtelecom/src/e2ee/utils.d.ts +24 -0
  155. package/dist/ts4.2/@dtelecom/src/e2ee/worker/FrameCryptor.d.ts +176 -0
  156. package/dist/ts4.2/@dtelecom/src/e2ee/worker/ParticipantKeyHandler.d.ts +65 -0
  157. package/dist/ts4.2/@dtelecom/src/e2ee/worker/e2ee.worker.d.ts +2 -0
  158. package/dist/ts4.2/@dtelecom/src/index.d.ts +38 -0
  159. package/dist/ts4.2/@dtelecom/src/logger.d.ts +29 -0
  160. package/dist/ts4.2/@dtelecom/src/options.d.ts +104 -0
  161. package/dist/ts4.2/@dtelecom/src/proto/livekit_models_pb.d.ts +1264 -0
  162. package/dist/ts4.2/@dtelecom/src/proto/livekit_rtc_pb.d.ts +1373 -0
  163. package/dist/ts4.2/@dtelecom/src/room/DefaultReconnectPolicy.d.ts +8 -0
  164. package/dist/ts4.2/@dtelecom/src/room/DeviceManager.d.ts +9 -0
  165. package/dist/ts4.2/@dtelecom/src/room/PCTransport.d.ts +43 -0
  166. package/dist/ts4.2/@dtelecom/src/room/RTCEngine.d.ts +143 -0
  167. package/dist/ts4.2/@dtelecom/src/room/ReconnectPolicy.d.ts +24 -0
  168. package/dist/ts4.2/@dtelecom/src/room/RegionUrlProvider.d.ts +17 -0
  169. package/dist/ts4.2/@dtelecom/src/room/Room.d.ts +248 -0
  170. package/dist/ts4.2/@dtelecom/src/room/defaults.d.ts +8 -0
  171. package/dist/ts4.2/@dtelecom/src/room/errors.d.ts +43 -0
  172. package/dist/ts4.2/@dtelecom/src/room/events.d.ts +477 -0
  173. package/dist/ts4.2/@dtelecom/src/room/participant/LocalParticipant.d.ts +177 -0
  174. package/dist/ts4.2/@dtelecom/src/room/participant/Participant.d.ts +95 -0
  175. package/dist/ts4.2/@dtelecom/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  176. package/dist/ts4.2/@dtelecom/src/room/participant/RemoteParticipant.d.ts +55 -0
  177. package/dist/ts4.2/@dtelecom/src/room/participant/publishUtils.d.ts +28 -0
  178. package/dist/ts4.2/@dtelecom/src/room/stats.d.ts +67 -0
  179. package/dist/ts4.2/@dtelecom/src/room/timers.d.ts +13 -0
  180. package/dist/ts4.2/@dtelecom/src/room/track/LocalAudioTrack.d.ts +25 -0
  181. package/dist/ts4.2/@dtelecom/src/room/track/LocalTrack.d.ts +78 -0
  182. package/dist/ts4.2/@dtelecom/src/room/track/LocalTrackPublication.d.ts +38 -0
  183. package/dist/ts4.2/@dtelecom/src/room/track/LocalVideoTrack.d.ts +54 -0
  184. package/dist/ts4.2/@dtelecom/src/room/track/RemoteAudioTrack.d.ts +53 -0
  185. package/dist/ts4.2/@dtelecom/src/room/track/RemoteTrack.d.ts +15 -0
  186. package/dist/ts4.2/@dtelecom/src/room/track/RemoteTrackPublication.d.ts +64 -0
  187. package/dist/ts4.2/@dtelecom/src/room/track/RemoteVideoTrack.d.ts +56 -0
  188. package/dist/ts4.2/@dtelecom/src/room/track/Track.d.ts +125 -0
  189. package/dist/ts4.2/@dtelecom/src/room/track/TrackPublication.d.ts +72 -0
  190. package/dist/ts4.2/@dtelecom/src/room/track/create.d.ts +24 -0
  191. package/dist/ts4.2/@dtelecom/src/room/track/facingMode.d.ts +41 -0
  192. package/dist/ts4.2/@dtelecom/src/room/track/options.d.ts +280 -0
  193. package/dist/ts4.2/@dtelecom/src/room/track/processor/types.d.ts +19 -0
  194. package/dist/ts4.2/@dtelecom/src/room/track/types.d.ts +24 -0
  195. package/dist/ts4.2/@dtelecom/src/room/track/utils.d.ts +27 -0
  196. package/dist/ts4.2/@dtelecom/src/room/types.d.ts +26 -0
  197. package/dist/ts4.2/@dtelecom/src/room/utils.d.ts +92 -0
  198. package/dist/ts4.2/@dtelecom/src/test/MockMediaStreamTrack.d.ts +26 -0
  199. package/dist/ts4.2/@dtelecom/src/test/mocks.d.ts +12 -0
  200. package/dist/ts4.2/@dtelecom/src/utils/AsyncQueue.d.ts +23 -0
  201. package/dist/ts4.2/@dtelecom/src/utils/browserParser.d.ts +12 -0
  202. package/dist/ts4.2/@dtelecom/src/version.d.ts +3 -0
  203. package/package.json +102 -0
  204. package/src/api/SignalClient.ts +790 -0
  205. package/src/connectionHelper/ConnectionCheck.ts +90 -0
  206. package/src/connectionHelper/checks/Checker.ts +163 -0
  207. package/src/connectionHelper/checks/publishAudio.ts +33 -0
  208. package/src/connectionHelper/checks/publishVideo.ts +33 -0
  209. package/src/connectionHelper/checks/reconnect.ts +45 -0
  210. package/src/connectionHelper/checks/turn.ts +54 -0
  211. package/src/connectionHelper/checks/webrtc.ts +82 -0
  212. package/src/connectionHelper/checks/websocket.ts +27 -0
  213. package/src/e2ee/E2eeManager.ts +375 -0
  214. package/src/e2ee/KeyProvider.ts +78 -0
  215. package/src/e2ee/constants.ts +44 -0
  216. package/src/e2ee/errors.ts +16 -0
  217. package/src/e2ee/index.ts +3 -0
  218. package/src/e2ee/types.ts +161 -0
  219. package/src/e2ee/utils.ts +127 -0
  220. package/src/e2ee/worker/FrameCryptor.test.ts +19 -0
  221. package/src/e2ee/worker/FrameCryptor.ts +612 -0
  222. package/src/e2ee/worker/ParticipantKeyHandler.ts +175 -0
  223. package/src/e2ee/worker/e2ee.worker.ts +223 -0
  224. package/src/e2ee/worker/tsconfig.json +6 -0
  225. package/src/index.ts +85 -0
  226. package/src/logger.ts +64 -0
  227. package/src/options.ts +127 -0
  228. package/src/proto/livekit_models_pb.ts +2096 -0
  229. package/src/proto/livekit_rtc_pb.ts +2332 -0
  230. package/src/room/DefaultReconnectPolicy.ts +35 -0
  231. package/src/room/DeviceManager.ts +88 -0
  232. package/src/room/PCTransport.ts +452 -0
  233. package/src/room/RTCEngine.ts +1421 -0
  234. package/src/room/ReconnectPolicy.ts +27 -0
  235. package/src/room/RegionUrlProvider.ts +82 -0
  236. package/src/room/Room.test.ts +30 -0
  237. package/src/room/Room.ts +1907 -0
  238. package/src/room/defaults.ts +49 -0
  239. package/src/room/errors.ts +90 -0
  240. package/src/room/events.ts +535 -0
  241. package/src/room/participant/LocalParticipant.ts +1350 -0
  242. package/src/room/participant/Participant.ts +299 -0
  243. package/src/room/participant/ParticipantTrackPermission.ts +42 -0
  244. package/src/room/participant/RemoteParticipant.ts +359 -0
  245. package/src/room/participant/publishUtils.test.ts +189 -0
  246. package/src/room/participant/publishUtils.ts +399 -0
  247. package/src/room/stats.ts +136 -0
  248. package/src/room/timers.ts +16 -0
  249. package/src/room/track/LocalAudioTrack.ts +171 -0
  250. package/src/room/track/LocalTrack.ts +430 -0
  251. package/src/room/track/LocalTrackPublication.ts +87 -0
  252. package/src/room/track/LocalVideoTrack.test.ts +73 -0
  253. package/src/room/track/LocalVideoTrack.ts +513 -0
  254. package/src/room/track/RemoteAudioTrack.ts +248 -0
  255. package/src/room/track/RemoteTrack.ts +62 -0
  256. package/src/room/track/RemoteTrackPublication.ts +311 -0
  257. package/src/room/track/RemoteVideoTrack.test.ts +152 -0
  258. package/src/room/track/RemoteVideoTrack.ts +410 -0
  259. package/src/room/track/Track.ts +452 -0
  260. package/src/room/track/TrackPublication.ts +158 -0
  261. package/src/room/track/create.ts +143 -0
  262. package/src/room/track/facingMode.test.ts +31 -0
  263. package/src/room/track/facingMode.ts +103 -0
  264. package/src/room/track/options.ts +362 -0
  265. package/src/room/track/processor/types.ts +20 -0
  266. package/src/room/track/types.ts +25 -0
  267. package/src/room/track/utils.test.ts +111 -0
  268. package/src/room/track/utils.ts +183 -0
  269. package/src/room/types.ts +39 -0
  270. package/src/room/utils.test.ts +16 -0
  271. package/src/room/utils.ts +501 -0
  272. package/src/room/worker.d.ts +4 -0
  273. package/src/test/MockMediaStreamTrack.ts +84 -0
  274. package/src/test/mocks.ts +19 -0
  275. package/src/utils/AsyncQueue.test.ts +100 -0
  276. package/src/utils/AsyncQueue.ts +57 -0
  277. package/src/utils/browserParser.test.ts +88 -0
  278. package/src/utils/browserParser.ts +74 -0
  279. package/src/version.ts +4 -0
@@ -0,0 +1,501 @@
1
+ import { ClientInfo, ClientInfo_SDK } from '../proto/livekit_models_pb';
2
+ import type { DetectableBrowser } from '../utils/browserParser';
3
+ import { getBrowser } from '../utils/browserParser';
4
+ import { protocolVersion, version } from '../version';
5
+ import type LocalAudioTrack from './track/LocalAudioTrack';
6
+ import type RemoteAudioTrack from './track/RemoteAudioTrack';
7
+ import { VideoCodec, videoCodecs } from './track/options';
8
+ import { getNewAudioContext } from './track/utils';
9
+ import type { LiveKitReactNativeInfo } from './types';
10
+
11
+ const separator = '|';
12
+ export const ddExtensionURI =
13
+ 'https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension';
14
+
15
+ export function unpackStreamId(packed: string): string[] {
16
+ const parts = packed.split(separator);
17
+ if (parts.length > 1) {
18
+ return [parts[0], packed.substr(parts[0].length + 1)];
19
+ }
20
+ return [packed, ''];
21
+ }
22
+
23
+ export async function sleep(duration: number): Promise<void> {
24
+ return new Promise((resolve) => setTimeout(resolve, duration));
25
+ }
26
+
27
+ /** @internal */
28
+ export function supportsTransceiver() {
29
+ return 'addTransceiver' in RTCPeerConnection.prototype;
30
+ }
31
+
32
+ /** @internal */
33
+ export function supportsAddTrack() {
34
+ return 'addTrack' in RTCPeerConnection.prototype;
35
+ }
36
+
37
+ export function supportsAdaptiveStream() {
38
+ return typeof ResizeObserver !== undefined && typeof IntersectionObserver !== undefined;
39
+ }
40
+
41
+ export function supportsDynacast() {
42
+ return supportsTransceiver();
43
+ }
44
+
45
+ export function supportsAV1(): boolean {
46
+ if (!('getCapabilities' in RTCRtpSender)) {
47
+ return false;
48
+ }
49
+ const capabilities = RTCRtpSender.getCapabilities('video');
50
+ let hasAV1 = false;
51
+ if (capabilities) {
52
+ for (const codec of capabilities.codecs) {
53
+ if (codec.mimeType === 'video/AV1') {
54
+ hasAV1 = true;
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ return hasAV1;
60
+ }
61
+
62
+ export function supportsVP9(): boolean {
63
+ if (!('getCapabilities' in RTCRtpSender)) {
64
+ // technically speaking FireFox supports VP9, but SVC publishing is broken
65
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
66
+ return false;
67
+ }
68
+ const capabilities = RTCRtpSender.getCapabilities('video');
69
+ let hasVP9 = false;
70
+ if (capabilities) {
71
+ for (const codec of capabilities.codecs) {
72
+ if (codec.mimeType === 'video/VP9') {
73
+ hasVP9 = true;
74
+ break;
75
+ }
76
+ }
77
+ }
78
+ return hasVP9;
79
+ }
80
+
81
+ export function isSVCCodec(codec?: string): boolean {
82
+ return codec === 'av1' || codec === 'vp9';
83
+ }
84
+
85
+ export function supportsSetSinkId(elm?: HTMLMediaElement): boolean {
86
+ if (!document) {
87
+ return false;
88
+ }
89
+ if (!elm) {
90
+ elm = document.createElement('audio');
91
+ }
92
+ return 'setSinkId' in elm;
93
+ }
94
+
95
+ const setCodecPreferencesVersions: Record<DetectableBrowser, string> = {
96
+ Chrome: '100',
97
+ Safari: '15',
98
+ Firefox: '100',
99
+ };
100
+
101
+ export function supportsSetCodecPreferences(transceiver: RTCRtpTransceiver): boolean {
102
+ if (!isWeb()) {
103
+ return false;
104
+ }
105
+ if (!('setCodecPreferences' in transceiver)) {
106
+ return false;
107
+ }
108
+ const browser = getBrowser();
109
+ if (!browser?.name || !browser.version) {
110
+ // version is required
111
+ return false;
112
+ }
113
+ const v = setCodecPreferencesVersions[browser.name];
114
+ if (v) {
115
+ return compareVersions(browser.version, v) >= 0;
116
+ }
117
+ return false;
118
+ }
119
+
120
+ export function isBrowserSupported() {
121
+ return supportsTransceiver() || supportsAddTrack();
122
+ }
123
+
124
+ export function isFireFox(): boolean {
125
+ return getBrowser()?.name === 'Firefox';
126
+ }
127
+
128
+ export function isChromiumBased(): boolean {
129
+ return getBrowser()?.name === 'Chrome';
130
+ }
131
+
132
+ export function isSafari(): boolean {
133
+ return getBrowser()?.name === 'Safari';
134
+ }
135
+
136
+ export function isMobile(): boolean {
137
+ if (!isWeb()) return false;
138
+ return /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent);
139
+ }
140
+
141
+ export function isWeb(): boolean {
142
+ return typeof document !== 'undefined';
143
+ }
144
+
145
+ export function isReactNative(): boolean {
146
+ // navigator.product is deprecated on browsers, but will be set appropriately for react-native.
147
+ return navigator.product == 'ReactNative';
148
+ }
149
+
150
+ export function isCloud(serverUrl: URL) {
151
+ return (
152
+ serverUrl.hostname.endsWith('.livekit.cloud') || serverUrl.hostname.endsWith('.livekit.run')
153
+ );
154
+ }
155
+
156
+ function getLKReactNativeInfo(): LiveKitReactNativeInfo | undefined {
157
+ // global defined only for ReactNative.
158
+ // @ts-ignore
159
+ if (global && global.LiveKitReactNativeGlobal) {
160
+ // @ts-ignore
161
+ return global.LiveKitReactNativeGlobal as LiveKitReactNativeInfo;
162
+ }
163
+
164
+ return undefined;
165
+ }
166
+
167
+ export function getReactNativeOs(): string | undefined {
168
+ if (!isReactNative()) {
169
+ return undefined;
170
+ }
171
+
172
+ let info = getLKReactNativeInfo();
173
+ if (info) {
174
+ return info.platform;
175
+ }
176
+
177
+ return undefined;
178
+ }
179
+
180
+ export function getDevicePixelRatio(): number {
181
+ if (isWeb()) {
182
+ return window.devicePixelRatio;
183
+ }
184
+
185
+ if (isReactNative()) {
186
+ let info = getLKReactNativeInfo();
187
+ if (info) {
188
+ return info.devicePixelRatio;
189
+ }
190
+ }
191
+
192
+ return 1;
193
+ }
194
+
195
+ export function compareVersions(v1: string, v2: string): number {
196
+ const parts1 = v1.split('.');
197
+ const parts2 = v2.split('.');
198
+ const k = Math.min(parts1.length, parts2.length);
199
+ for (let i = 0; i < k; ++i) {
200
+ const p1 = parseInt(parts1[i], 10);
201
+ const p2 = parseInt(parts2[i], 10);
202
+ if (p1 > p2) return 1;
203
+ if (p1 < p2) return -1;
204
+ if (i === k - 1 && p1 === p2) return 0;
205
+ }
206
+ if (v1 === '' && v2 !== '') {
207
+ return -1;
208
+ } else if (v2 === '') {
209
+ return 1;
210
+ }
211
+ return parts1.length == parts2.length ? 0 : parts1.length < parts2.length ? -1 : 1;
212
+ }
213
+
214
+ function roDispatchCallback(entries: ResizeObserverEntry[]) {
215
+ for (const entry of entries) {
216
+ (entry.target as ObservableMediaElement).handleResize(entry);
217
+ }
218
+ }
219
+
220
+ function ioDispatchCallback(entries: IntersectionObserverEntry[]) {
221
+ for (const entry of entries) {
222
+ (entry.target as ObservableMediaElement).handleVisibilityChanged(entry);
223
+ }
224
+ }
225
+
226
+ let resizeObserver: ResizeObserver | null = null;
227
+ export const getResizeObserver = () => {
228
+ if (!resizeObserver) resizeObserver = new ResizeObserver(roDispatchCallback);
229
+ return resizeObserver;
230
+ };
231
+
232
+ let intersectionObserver: IntersectionObserver | null = null;
233
+ export const getIntersectionObserver = () => {
234
+ if (!intersectionObserver) {
235
+ intersectionObserver = new IntersectionObserver(ioDispatchCallback, {
236
+ root: null,
237
+ rootMargin: '0px',
238
+ });
239
+ }
240
+ return intersectionObserver;
241
+ };
242
+
243
+ export interface ObservableMediaElement extends HTMLMediaElement {
244
+ handleResize: (entry: ResizeObserverEntry) => void;
245
+ handleVisibilityChanged: (entry: IntersectionObserverEntry) => void;
246
+ }
247
+
248
+ export function getClientInfo(): ClientInfo {
249
+ const info = new ClientInfo({
250
+ sdk: ClientInfo_SDK.JS,
251
+ protocol: protocolVersion,
252
+ version,
253
+ });
254
+
255
+ if (isReactNative()) {
256
+ info.os = getReactNativeOs() ?? '';
257
+ }
258
+ return info;
259
+ }
260
+
261
+ let emptyVideoStreamTrack: MediaStreamTrack | undefined;
262
+
263
+ export function getEmptyVideoStreamTrack() {
264
+ if (!emptyVideoStreamTrack) {
265
+ emptyVideoStreamTrack = createDummyVideoStreamTrack();
266
+ }
267
+ return emptyVideoStreamTrack.clone();
268
+ }
269
+
270
+ export function createDummyVideoStreamTrack(
271
+ width: number = 16,
272
+ height: number = 16,
273
+ enabled: boolean = false,
274
+ paintContent: boolean = false,
275
+ ) {
276
+ const canvas = document.createElement('canvas');
277
+ // the canvas size is set to 16 by default, because electron apps seem to fail with smaller values
278
+ canvas.width = width;
279
+ canvas.height = height;
280
+ const ctx = canvas.getContext('2d');
281
+ ctx?.fillRect(0, 0, canvas.width, canvas.height);
282
+ if (paintContent && ctx) {
283
+ ctx.beginPath();
284
+ ctx.arc(width / 2, height / 2, 50, 0, Math.PI * 2, true);
285
+ ctx.closePath();
286
+ ctx.fillStyle = 'grey';
287
+ ctx.fill();
288
+ }
289
+ // @ts-ignore
290
+ const dummyStream = canvas.captureStream();
291
+ const [dummyTrack] = dummyStream.getTracks();
292
+ if (!dummyTrack) {
293
+ throw Error('Could not get empty media stream video track');
294
+ }
295
+ dummyTrack.enabled = enabled;
296
+
297
+ return dummyTrack;
298
+ }
299
+
300
+ let emptyAudioStreamTrack: MediaStreamTrack | undefined;
301
+
302
+ export function getEmptyAudioStreamTrack() {
303
+ if (!emptyAudioStreamTrack) {
304
+ // implementation adapted from https://blog.mozilla.org/webrtc/warm-up-with-replacetrack/
305
+ const ctx = new AudioContext();
306
+ const oscillator = ctx.createOscillator();
307
+ const gain = ctx.createGain();
308
+ gain.gain.setValueAtTime(0, 0);
309
+ const dst = ctx.createMediaStreamDestination();
310
+ oscillator.connect(gain);
311
+ gain.connect(dst);
312
+ oscillator.start();
313
+ [emptyAudioStreamTrack] = dst.stream.getAudioTracks();
314
+ if (!emptyAudioStreamTrack) {
315
+ throw Error('Could not get empty media stream audio track');
316
+ }
317
+ emptyAudioStreamTrack.enabled = false;
318
+ }
319
+ return emptyAudioStreamTrack.clone();
320
+ }
321
+
322
+ export class Future<T> {
323
+ promise: Promise<T>;
324
+
325
+ resolve?: (arg: T) => void;
326
+
327
+ reject?: (e: any) => void;
328
+
329
+ onFinally?: () => void;
330
+
331
+ constructor(
332
+ futureBase?: (resolve: (arg: T) => void, reject: (e: any) => void) => void,
333
+ onFinally?: () => void,
334
+ ) {
335
+ this.onFinally = onFinally;
336
+ this.promise = new Promise<T>(async (resolve, reject) => {
337
+ this.resolve = resolve;
338
+ this.reject = reject;
339
+ if (futureBase) {
340
+ await futureBase(resolve, reject);
341
+ }
342
+ }).finally(() => this.onFinally?.());
343
+ }
344
+ }
345
+
346
+ export type AudioAnalyserOptions = {
347
+ /**
348
+ * If set to true, the analyser will use a cloned version of the underlying mediastreamtrack, which won't be impacted by muting the track.
349
+ * Useful for local tracks when implementing things like "seems like you're muted, but trying to speak".
350
+ * Defaults to false
351
+ */
352
+ cloneTrack?: boolean;
353
+ /**
354
+ * see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize
355
+ */
356
+ fftSize?: number;
357
+ /**
358
+ * see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/smoothingTimeConstant
359
+ */
360
+ smoothingTimeConstant?: number;
361
+ /**
362
+ * see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/minDecibels
363
+ */
364
+ minDecibels?: number;
365
+ /**
366
+ * see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/maxDecibels
367
+ */
368
+ maxDecibels?: number;
369
+ };
370
+
371
+ /**
372
+ * Creates and returns an analyser web audio node that is attached to the provided track.
373
+ * Additionally returns a convenience method `calculateVolume` to perform instant volume readings on that track.
374
+ * Call the returned `cleanup` function to close the audioContext that has been created for the instance of this helper
375
+ */
376
+ export function createAudioAnalyser(
377
+ track: LocalAudioTrack | RemoteAudioTrack,
378
+ options?: AudioAnalyserOptions,
379
+ ) {
380
+ const opts = {
381
+ cloneTrack: false,
382
+ fftSize: 2048,
383
+ smoothingTimeConstant: 0.8,
384
+ minDecibels: -100,
385
+ maxDecibels: -80,
386
+ ...options,
387
+ };
388
+ const audioContext = getNewAudioContext();
389
+
390
+ if (!audioContext) {
391
+ throw new Error('Audio Context not supported on this browser');
392
+ }
393
+ const streamTrack = opts.cloneTrack ? track.mediaStreamTrack.clone() : track.mediaStreamTrack;
394
+ const mediaStreamSource = audioContext.createMediaStreamSource(new MediaStream([streamTrack]));
395
+ const analyser = audioContext.createAnalyser();
396
+ analyser.minDecibels = opts.minDecibels;
397
+ analyser.maxDecibels = opts.maxDecibels;
398
+ analyser.fftSize = opts.fftSize;
399
+ analyser.smoothingTimeConstant = opts.smoothingTimeConstant;
400
+
401
+ mediaStreamSource.connect(analyser);
402
+ const dataArray = new Uint8Array(analyser.frequencyBinCount);
403
+
404
+ /**
405
+ * Calculates the current volume of the track in the range from 0 to 1
406
+ */
407
+ const calculateVolume = () => {
408
+ analyser.getByteFrequencyData(dataArray);
409
+ let sum = 0;
410
+ for (const amplitude of dataArray) {
411
+ sum += Math.pow(amplitude / 255, 2);
412
+ }
413
+ const volume = Math.sqrt(sum / dataArray.length);
414
+ return volume;
415
+ };
416
+
417
+ const cleanup = () => {
418
+ audioContext.close();
419
+ if (opts.cloneTrack) {
420
+ streamTrack.stop();
421
+ }
422
+ };
423
+
424
+ return { calculateVolume, analyser, cleanup };
425
+ }
426
+
427
+ export class Mutex {
428
+ private _locking: Promise<void>;
429
+
430
+ private _locks: number;
431
+
432
+ constructor() {
433
+ this._locking = Promise.resolve();
434
+ this._locks = 0;
435
+ }
436
+
437
+ isLocked() {
438
+ return this._locks > 0;
439
+ }
440
+
441
+ lock() {
442
+ this._locks += 1;
443
+
444
+ let unlockNext: () => void;
445
+
446
+ const willLock = new Promise<void>(
447
+ (resolve) =>
448
+ (unlockNext = () => {
449
+ this._locks -= 1;
450
+ resolve();
451
+ }),
452
+ );
453
+
454
+ const willUnlock = this._locking.then(() => unlockNext);
455
+
456
+ this._locking = this._locking.then(() => willLock);
457
+
458
+ return willUnlock;
459
+ }
460
+ }
461
+
462
+ export function isVideoCodec(maybeCodec: string): maybeCodec is VideoCodec {
463
+ return videoCodecs.includes(maybeCodec as VideoCodec);
464
+ }
465
+
466
+ export function unwrapConstraint(constraint: ConstrainDOMString): string {
467
+ if (typeof constraint === 'string') {
468
+ return constraint;
469
+ }
470
+
471
+ if (Array.isArray(constraint)) {
472
+ return constraint[0];
473
+ }
474
+ if (constraint.exact) {
475
+ if (Array.isArray(constraint.exact)) {
476
+ return constraint.exact[0];
477
+ }
478
+ return constraint.exact;
479
+ }
480
+ if (constraint.ideal) {
481
+ if (Array.isArray(constraint.ideal)) {
482
+ return constraint.ideal[0];
483
+ }
484
+ return constraint.ideal;
485
+ }
486
+ throw Error('could not unwrap constraint');
487
+ }
488
+
489
+ export function toWebsocketUrl(url: string): string {
490
+ if (url.startsWith('http')) {
491
+ return url.replace(/^(http)/, 'ws');
492
+ }
493
+ return url;
494
+ }
495
+
496
+ export function toHttpUrl(url: string): string {
497
+ if (url.startsWith('ws')) {
498
+ return url.replace(/^(ws)/, 'http');
499
+ }
500
+ return url;
501
+ }
@@ -0,0 +1,4 @@
1
+ declare module 'web-worker:*' {
2
+ const WorkerFactory: new () => Worker;
3
+ export default WorkerFactory;
4
+ }
@@ -0,0 +1,84 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ // @ts-ignore
3
+ export default class MockMediaStreamTrack implements MediaStreamTrack {
4
+ contentHint: string = '';
5
+
6
+ enabled: boolean = true;
7
+
8
+ id: string = 'id';
9
+
10
+ kind: string = 'video';
11
+
12
+ label: string = 'label';
13
+
14
+ muted: boolean = false;
15
+
16
+ onended: ((this: MediaStreamTrack, ev: Event) => any) | null = null;
17
+
18
+ onmute: ((this: MediaStreamTrack, ev: Event) => any) | null = null;
19
+
20
+ onunmute: ((this: MediaStreamTrack, ev: Event) => any) | null = null;
21
+
22
+ readyState: MediaStreamTrackState = 'live';
23
+
24
+ isolated: boolean = false;
25
+
26
+ onisolationchange: ((this: MediaStreamTrack, ev: Event) => any) | null = null;
27
+
28
+ // @ts-ignore
29
+ applyConstraints(constraints?: MediaTrackConstraints): Promise<void> {
30
+ throw new Error('Method not implemented.');
31
+ }
32
+
33
+ clone(): MediaStreamTrack {
34
+ throw new Error('Method not implemented.');
35
+ }
36
+
37
+ getCapabilities(): MediaTrackCapabilities {
38
+ throw new Error('Method not implemented.');
39
+ }
40
+
41
+ getConstraints(): MediaTrackConstraints {
42
+ throw new Error('Method not implemented.');
43
+ }
44
+
45
+ getSettings(): MediaTrackSettings {
46
+ throw new Error('Method not implemented.');
47
+ }
48
+
49
+ stop(): void {
50
+ throw new Error('Method not implemented.');
51
+ }
52
+
53
+ addEventListener<K extends keyof MediaStreamTrackEventMap>(
54
+ type: K,
55
+ listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any,
56
+ options?: boolean | AddEventListenerOptions,
57
+ ): void;
58
+ addEventListener(
59
+ type: string,
60
+ listener: EventListenerOrEventListenerObject,
61
+ options?: boolean | AddEventListenerOptions,
62
+ ): void;
63
+ addEventListener(type: any, listener: any, options?: any): void {
64
+ throw new Error('Method not implemented.');
65
+ }
66
+
67
+ removeEventListener<K extends keyof MediaStreamTrackEventMap>(
68
+ type: K,
69
+ listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any,
70
+ options?: boolean | EventListenerOptions,
71
+ ): void;
72
+ removeEventListener(
73
+ type: string,
74
+ listener: EventListenerOrEventListenerObject,
75
+ options?: boolean | EventListenerOptions,
76
+ ): void;
77
+ removeEventListener(type: any, listener: any, options?: any): void {
78
+ throw new Error('Method not implemented.');
79
+ }
80
+
81
+ dispatchEvent(event: Event): boolean {
82
+ throw new Error('Method not implemented.');
83
+ }
84
+ }
@@ -0,0 +1,19 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { MockedClass, vi } from 'vitest';
3
+ import { SignalClient } from '../api/SignalClient';
4
+ import RTCEngine from '../room/RTCEngine';
5
+
6
+ vi.mock('../api/SignalClient');
7
+ vi.mock('../room/RTCEngine');
8
+
9
+ // mock helpers for testing
10
+
11
+ const mocks = {
12
+ SignalClient: SignalClient as MockedClass<typeof SignalClient>,
13
+ RTCEngine: RTCEngine as MockedClass<typeof RTCEngine>,
14
+ MockLocalVideoTrack: {
15
+ stop: vi.fn(),
16
+ },
17
+ };
18
+
19
+ export default mocks;
@@ -0,0 +1,100 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { sleep } from '../room/utils';
3
+ import { AsyncQueue } from './AsyncQueue';
4
+
5
+ describe('asyncQueue', () => {
6
+ it('runs multiple tasks in order', async () => {
7
+ const queue = new AsyncQueue();
8
+ const tasksExecuted: number[] = [];
9
+
10
+ for (let i = 0; i < 5; i++) {
11
+ queue.run(async () => {
12
+ await sleep(50);
13
+ tasksExecuted.push(i);
14
+ });
15
+ }
16
+ await queue.flush();
17
+ expect(tasksExecuted).toMatchObject([0, 1, 2, 3, 4]);
18
+ });
19
+ it('runs tasks sequentially and not in parallel', async () => {
20
+ const queue = new AsyncQueue();
21
+ const results: number[] = [];
22
+ for (let i = 0; i < 5; i++) {
23
+ queue.run(async () => {
24
+ results.push(i);
25
+ await sleep(10);
26
+ results.push(i);
27
+ });
28
+ }
29
+ await queue.flush();
30
+ expect(results).toMatchObject([0, 0, 1, 1, 2, 2, 3, 3, 4, 4]);
31
+ });
32
+ it('continues executing tasks if one task throws an error', async () => {
33
+ const queue = new AsyncQueue();
34
+
35
+ let task1threw = false;
36
+ let task2Executed = false;
37
+
38
+ queue
39
+ .run(async () => {
40
+ await sleep(100);
41
+ throw Error('task 1 throws');
42
+ })
43
+ .catch(() => {
44
+ task1threw = true;
45
+ });
46
+
47
+ await queue
48
+ .run(async () => {
49
+ task2Executed = true;
50
+ })
51
+ .catch(() => {
52
+ fail('task 2 should not have thrown');
53
+ });
54
+
55
+ expect(task1threw).toBeTruthy();
56
+ expect(task2Executed).toBeTruthy();
57
+ });
58
+ it('returns the result of the task', async () => {
59
+ const queue = new AsyncQueue();
60
+
61
+ const result = await queue.run(async () => {
62
+ await sleep(10);
63
+ return 'result';
64
+ });
65
+
66
+ expect(result).toBe('result');
67
+ });
68
+ it('returns only when the enqueued task and all previous tasks have completed', async () => {
69
+ const queue = new AsyncQueue();
70
+ const tasksExecuted: number[] = [];
71
+ for (let i = 0; i < 10; i += 1) {
72
+ queue.run(async () => {
73
+ await sleep(10);
74
+ tasksExecuted.push(i);
75
+ return i;
76
+ });
77
+ }
78
+
79
+ const result = await queue.run(async () => {
80
+ await sleep(10);
81
+ tasksExecuted.push(999);
82
+ return 'result';
83
+ });
84
+
85
+ expect(result).toBe('result');
86
+ expect(tasksExecuted).toMatchObject([...new Array(10).fill(0).map((_, idx) => idx), 999]);
87
+ });
88
+ it('can handle queue sizes of up to 10_000 tasks', async () => {
89
+ const queue = new AsyncQueue();
90
+ const tasksExecuted: number[] = [];
91
+
92
+ for (let i = 0; i < 10_000; i++) {
93
+ queue.run(async () => {
94
+ tasksExecuted.push(i);
95
+ });
96
+ }
97
+ await queue.flush();
98
+ expect(tasksExecuted).toMatchObject(new Array(10_000).fill(0).map((_, idx) => idx));
99
+ });
100
+ });