mediasoup-client 3.9.7 → 3.10.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.
package/lib/Device.d.ts CHANGED
@@ -15,6 +15,17 @@ export type DeviceOptions = {
15
15
  */
16
16
  handlerFactory?: HandlerFactory;
17
17
  };
18
+ /**
19
+ * Async mediasoup-client Handler detection. More powerful than
20
+ * `detectDevice()`.
21
+ */
22
+ export declare function detectDeviceAsync(userAgent?: string): Promise<BuiltinHandlerName | undefined>;
23
+ /**
24
+ * Sync mediasoup-client Handler detection.
25
+ *
26
+ * @deprecated It only relies on navigator.userAgent. Use `detectDeviceAsync()`
27
+ * instead.
28
+ */
18
29
  export declare function detectDevice(userAgent?: string): BuiltinHandlerName | undefined;
19
30
  export type DeviceObserver = EnhancedEventEmitter<DeviceObserverEvents>;
20
31
  export type DeviceObserverEvents = {
@@ -29,6 +40,13 @@ export declare class Device {
29
40
  private readonly _canProduceByKind;
30
41
  private _sctpCapabilities?;
31
42
  protected readonly _observer: DeviceObserver;
43
+ /**
44
+ * Create a new Device to connect to mediasoup server. It uses a more advanced
45
+ * device detection.
46
+ *
47
+ * @throws {UnsupportedError} if device is not supported.
48
+ */
49
+ static factory({ handlerName, handlerFactory, }?: DeviceOptions): Promise<Device>;
32
50
  /**
33
51
  * Create a new Device to connect to mediasoup server.
34
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,OAAO,EACN,SAAS,EACT,KAAK,gBAAgB,EAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,cAAc,EAEnB,MAAM,6BAA6B,CAAC;AAarC,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAk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AuH/D;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;OAIG;IACH,IAAI,eAAe,IAAI,eAAe,CAMrC;IAED;;;;OAIG;IACH,IAAI,gBAAgB,IAAI,gBAAgB,CAMvC;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;OAEG;IACG,IAAI,CAAC,EACV,qBAAqB,GACrB,EAAE;QACF,qBAAqB,EAAE,eAAe,CAAC;KACvC,GAAG,OAAO,CAAC,IAAI,CAAC;IA+FjB;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAUpC;;;;;OAKG;IACH,mBAAmB,CAAC,gBAAgB,SAAS,OAAO,GAAG,OAAO,EAAE,EAC/D,EAAE,EACF,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,GACP,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAkBnE;;;;;OAKG;IACH,mBAAmB,CAAC,gBAAgB,SAAS,OAAO,GAAG,OAAO,EAAE,EAC/D,EAAE,EACF,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,OAAO,GACP,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAkBnE,OAAO,CAAC,eAAe;CAsDvB"}
package/lib/Device.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
+ exports.detectDeviceAsync = detectDeviceAsync;
4
5
  exports.detectDevice = detectDevice;
5
6
  const ua_parser_js_1 = require("ua-parser-js");
6
7
  const Logger_1 = require("./Logger");
@@ -22,144 +23,31 @@ const Edge11_1 = require("./handlers/Edge11");
22
23
  const ReactNativeUnifiedPlan_1 = require("./handlers/ReactNativeUnifiedPlan");
23
24
  const ReactNative_1 = require("./handlers/ReactNative");
24
25
  const logger = new Logger_1.Logger('Device');
25
- function detectDevice(userAgent) {
26
- // React-Native.
27
- // NOTE: react-native-webrtc >= 1.75.0 is required.
28
- // NOTE: For Unified-Plan support, react-native-webrtc version >= 106.0.0 is
29
- // required.
30
- if (!userAgent &&
31
- typeof navigator === 'object' &&
32
- navigator.product === 'ReactNative') {
33
- logger.debug('detectDevice() | React-Native detected');
34
- if (typeof RTCPeerConnection === 'undefined') {
35
- logger.warn('detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?');
36
- return undefined;
37
- }
38
- if (typeof RTCRtpTransceiver !== 'undefined') {
39
- logger.debug('detectDevice() | ReactNative UnifiedPlan handler chosen');
40
- return 'ReactNativeUnifiedPlan';
41
- }
42
- else {
43
- logger.debug('detectDevice() | ReactNative PlanB handler chosen');
44
- return 'ReactNative';
45
- }
46
- }
47
- // Browser.
48
- else if (userAgent ||
49
- (typeof navigator === 'object' && typeof navigator.userAgent === 'string')) {
50
- userAgent ??= navigator.userAgent;
51
- const uaParser = new ua_parser_js_1.UAParser(userAgent);
52
- logger.debug('detectDevice() | browser detected [userAgent:%s, parsed:%o]', userAgent, uaParser.getResult());
53
- const browser = uaParser.getBrowser();
54
- const browserName = browser.name?.toLowerCase();
55
- const browserVersion = parseInt(browser.major ?? '0');
56
- const engine = uaParser.getEngine();
57
- const engineName = engine.name?.toLowerCase();
58
- const os = uaParser.getOS();
59
- const osName = os.name?.toLowerCase();
60
- const osVersion = parseFloat(os.version ?? '0');
61
- const device = uaParser.getDevice();
62
- const deviceModel = device.model?.toLowerCase();
63
- const isIOS = osName === 'ios' || deviceModel === 'ipad';
64
- const isChrome = browserName &&
65
- [
66
- 'chrome',
67
- 'chromium',
68
- 'mobile chrome',
69
- 'chrome webview',
70
- 'chrome headless',
71
- ].includes(browserName);
72
- const isFirefox = browserName &&
73
- ['firefox', 'mobile firefox', 'mobile focus'].includes(browserName);
74
- const isSafari = browserName && ['safari', 'mobile safari'].includes(browserName);
75
- const isEdge = browserName && ['edge'].includes(browserName);
76
- // Chrome, Chromium, and Edge.
77
- if ((isChrome || isEdge) && !isIOS && browserVersion >= 111) {
78
- return 'Chrome111';
79
- }
80
- else if ((isChrome && !isIOS && browserVersion >= 74) ||
81
- (isEdge && !isIOS && browserVersion >= 88)) {
82
- return 'Chrome74';
83
- }
84
- else if (isChrome && !isIOS && browserVersion >= 70) {
85
- return 'Chrome70';
86
- }
87
- else if (isChrome && !isIOS && browserVersion >= 67) {
88
- return 'Chrome67';
89
- }
90
- else if (isChrome && !isIOS && browserVersion >= 55) {
91
- return 'Chrome55';
92
- }
93
- // Firefox.
94
- else if (isFirefox && !isIOS && browserVersion >= 120) {
95
- return 'Firefox120';
96
- }
97
- else if (isFirefox && !isIOS && browserVersion >= 60) {
98
- return 'Firefox60';
99
- }
100
- // Firefox on iOS (so Safari).
101
- else if (isFirefox && isIOS && osVersion >= 14.3) {
102
- return 'Safari12';
103
- }
104
- // Safari with Unified-Plan support enabled.
105
- else if (isSafari &&
106
- browserVersion >= 12 &&
107
- typeof RTCRtpTransceiver !== 'undefined' &&
108
- RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
109
- return 'Safari12';
110
- }
111
- // Safari with Plab-B support.
112
- else if (isSafari && browserVersion >= 11) {
113
- return 'Safari11';
114
- }
115
- // Old Edge with ORTC support.
116
- else if (isEdge && !isIOS && browserVersion >= 11 && browserVersion <= 18) {
117
- return 'Edge11';
118
- }
119
- // Best effort for WebKit based browsers in iOS.
120
- else if (engineName === 'webkit' &&
121
- isIOS &&
122
- typeof RTCRtpTransceiver !== 'undefined' &&
123
- RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
124
- return 'Safari12';
125
- }
126
- // Best effort for Chromium based browsers.
127
- else if (engineName === 'blink') {
128
- // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
129
- const match = userAgent.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
130
- if (match) {
131
- const version = Number(match[1]);
132
- if (version >= 111) {
133
- return 'Chrome111';
134
- }
135
- else if (version >= 74) {
136
- return 'Chrome74';
137
- }
138
- else if (version >= 70) {
139
- return 'Chrome70';
140
- }
141
- else if (version >= 67) {
142
- return 'Chrome67';
143
- }
144
- else {
145
- return 'Chrome55';
146
- }
147
- }
148
- else {
149
- return 'Chrome111';
150
- }
151
- }
152
- // Unsupported browser.
153
- else {
154
- logger.warn('detectDevice() | browser not supported [name:%s, version:%s]', browserName, browserVersion);
155
- return undefined;
156
- }
26
+ /**
27
+ * Async mediasoup-client Handler detection. More powerful than
28
+ * `detectDevice()`.
29
+ */
30
+ async function detectDeviceAsync(userAgent) {
31
+ logger.debug('detectDeviceAsync() [userAgent:%s]', userAgent);
32
+ if (!userAgent && typeof navigator === 'object') {
33
+ userAgent = navigator.userAgent;
157
34
  }
158
- // Unknown device.
159
- else {
160
- logger.warn('detectDevice() | unknown device');
161
- return undefined;
35
+ const uaParserResult = await (0, ua_parser_js_1.UAParser)(userAgent).withFeatureCheck();
36
+ return detectDeviceImpl(uaParserResult);
37
+ }
38
+ /**
39
+ * Sync mediasoup-client Handler detection.
40
+ *
41
+ * @deprecated It only relies on navigator.userAgent. Use `detectDeviceAsync()`
42
+ * instead.
43
+ */
44
+ function detectDevice(userAgent) {
45
+ logger.debug('detectDevice() [userAgent:%s]', userAgent);
46
+ if (!userAgent && typeof navigator === 'object') {
47
+ userAgent = navigator.userAgent;
162
48
  }
49
+ const uaParserResult = (0, ua_parser_js_1.UAParser)(userAgent);
50
+ return detectDeviceImpl(uaParserResult);
163
51
  }
164
52
  class Device {
165
53
  // RTC handler factory.
@@ -179,6 +67,25 @@ class Device {
179
67
  _sctpCapabilities;
180
68
  // Observer instance.
181
69
  _observer = new enhancedEvents_1.EnhancedEventEmitter();
70
+ /**
71
+ * Create a new Device to connect to mediasoup server. It uses a more advanced
72
+ * device detection.
73
+ *
74
+ * @throws {UnsupportedError} if device is not supported.
75
+ */
76
+ static async factory({ handlerName, handlerFactory, } = {}) {
77
+ logger.debug('factory()');
78
+ if (handlerName && handlerFactory) {
79
+ throw new TypeError('just one of handlerName or handlerInterface can be given');
80
+ }
81
+ if (!handlerName && !handlerFactory) {
82
+ handlerName = await detectDeviceAsync();
83
+ if (!handlerName) {
84
+ throw new errors_1.UnsupportedError('device not supported');
85
+ }
86
+ }
87
+ return new Device({ handlerName, handlerFactory });
88
+ }
182
89
  /**
183
90
  * Create a new Device to connect to mediasoup server.
184
91
  *
@@ -461,3 +368,132 @@ class Device {
461
368
  }
462
369
  }
463
370
  exports.Device = Device;
371
+ function detectDeviceImpl(uaParserResult) {
372
+ // React-Native.
373
+ // NOTE: react-native-webrtc >= 1.75.0 is required.
374
+ // NOTE: For Unified-Plan support, react-native-webrtc version >= 106.0.0 is
375
+ // required.
376
+ if (typeof navigator === 'object' && navigator.product === 'ReactNative') {
377
+ logger.debug('detectDeviceImpl() | React-Native detected');
378
+ if (typeof RTCPeerConnection === 'undefined') {
379
+ logger.warn('detectDeviceImpl() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?');
380
+ return undefined;
381
+ }
382
+ if (typeof RTCRtpTransceiver !== 'undefined') {
383
+ logger.debug('detectDeviceImpl() | ReactNative UnifiedPlan handler chosen');
384
+ return 'ReactNativeUnifiedPlan';
385
+ }
386
+ else {
387
+ logger.debug('detectDeviceImpl() | ReactNative PlanB handler chosen');
388
+ return 'ReactNative';
389
+ }
390
+ }
391
+ // Browser.
392
+ else {
393
+ logger.debug('detectDeviceImpl() | browser detected [userAgent:%s, parsed:%o]', uaParserResult.ua, uaParserResult);
394
+ const browser = uaParserResult.browser;
395
+ const browserName = browser.name?.toLowerCase();
396
+ const browserVersion = parseInt(browser.major ?? '0');
397
+ const engine = uaParserResult.engine;
398
+ const engineName = engine.name?.toLowerCase();
399
+ const os = uaParserResult.os;
400
+ const osName = os.name?.toLowerCase();
401
+ const osVersion = parseFloat(os.version ?? '0');
402
+ const device = uaParserResult.device;
403
+ const deviceModel = device.model?.toLowerCase();
404
+ const isIOS = osName === 'ios' || deviceModel === 'ipad';
405
+ const isChrome = browserName &&
406
+ [
407
+ 'chrome',
408
+ 'chromium',
409
+ 'mobile chrome',
410
+ 'chrome webview',
411
+ 'chrome headless',
412
+ ].includes(browserName);
413
+ const isFirefox = browserName &&
414
+ ['firefox', 'mobile firefox', 'mobile focus'].includes(browserName);
415
+ const isSafari = browserName && ['safari', 'mobile safari'].includes(browserName);
416
+ const isEdge = browserName && ['edge'].includes(browserName);
417
+ // Chrome, Chromium, and Edge.
418
+ if ((isChrome || isEdge) && !isIOS && browserVersion >= 111) {
419
+ return 'Chrome111';
420
+ }
421
+ else if ((isChrome && !isIOS && browserVersion >= 74) ||
422
+ (isEdge && !isIOS && browserVersion >= 88)) {
423
+ return 'Chrome74';
424
+ }
425
+ else if (isChrome && !isIOS && browserVersion >= 70) {
426
+ return 'Chrome70';
427
+ }
428
+ else if (isChrome && !isIOS && browserVersion >= 67) {
429
+ return 'Chrome67';
430
+ }
431
+ else if (isChrome && !isIOS && browserVersion >= 55) {
432
+ return 'Chrome55';
433
+ }
434
+ // Firefox.
435
+ else if (isFirefox && !isIOS && browserVersion >= 120) {
436
+ return 'Firefox120';
437
+ }
438
+ else if (isFirefox && !isIOS && browserVersion >= 60) {
439
+ return 'Firefox60';
440
+ }
441
+ // Firefox on iOS (so Safari).
442
+ else if (isFirefox && isIOS && osVersion >= 14.3) {
443
+ return 'Safari12';
444
+ }
445
+ // Safari with Unified-Plan support enabled.
446
+ else if (isSafari &&
447
+ browserVersion >= 12 &&
448
+ typeof RTCRtpTransceiver !== 'undefined' &&
449
+ RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
450
+ return 'Safari12';
451
+ }
452
+ // Safari with Plab-B support.
453
+ else if (isSafari && browserVersion >= 11) {
454
+ return 'Safari11';
455
+ }
456
+ // Old Edge with ORTC support.
457
+ else if (isEdge && !isIOS && browserVersion >= 11 && browserVersion <= 18) {
458
+ return 'Edge11';
459
+ }
460
+ // Best effort for WebKit based browsers in iOS.
461
+ else if (engineName === 'webkit' &&
462
+ isIOS &&
463
+ typeof RTCRtpTransceiver !== 'undefined' &&
464
+ RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
465
+ return 'Safari12';
466
+ }
467
+ // Best effort for Chromium based browsers.
468
+ else if (engineName === 'blink') {
469
+ // eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
470
+ const match = uaParserResult.ua.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
471
+ if (match) {
472
+ const version = Number(match[1]);
473
+ if (version >= 111) {
474
+ return 'Chrome111';
475
+ }
476
+ else if (version >= 74) {
477
+ return 'Chrome74';
478
+ }
479
+ else if (version >= 70) {
480
+ return 'Chrome70';
481
+ }
482
+ else if (version >= 67) {
483
+ return 'Chrome67';
484
+ }
485
+ else {
486
+ return 'Chrome55';
487
+ }
488
+ }
489
+ else {
490
+ return 'Chrome111';
491
+ }
492
+ }
493
+ // Unsupported browser.
494
+ else {
495
+ logger.warn('detectDeviceImpl() | browser not supported [name:%s, version:%s]', browserName, browserVersion);
496
+ return undefined;
497
+ }
498
+ }
499
+ }
package/lib/index.d.ts CHANGED
@@ -6,11 +6,11 @@ export * as types from './types';
6
6
  /**
7
7
  * Expose mediasoup-client version.
8
8
  */
9
- export declare const version = "__MEDIASOUP_CLIENT_VERSION__";
9
+ export declare const version = "3.10.0";
10
10
  /**
11
- * Expose Device class and detectDevice() helper.
11
+ * Expose Device class and device detector helpers.
12
12
  */
13
- export { Device, detectDevice } from './Device';
13
+ export { Device, detectDevice, detectDeviceAsync } from './Device';
14
14
  /**
15
15
  * Expose parseScalabilityMode() function.
16
16
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AAEtD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD;;GAEG;AACH,OAAO,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;GAEG;AACH,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AAEtD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnE;;GAEG;AACH,OAAO,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEnE;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;GAEG;AACH,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debug = exports.testFakeParameters = exports.FakeHandler = exports.ortc = exports.parseScalabilityMode = exports.detectDevice = exports.Device = exports.version = exports.types = void 0;
3
+ exports.debug = exports.testFakeParameters = exports.FakeHandler = exports.ortc = exports.parseScalabilityMode = exports.detectDeviceAsync = exports.detectDevice = exports.Device = exports.version = exports.types = void 0;
4
4
  const debug_1 = require("debug");
5
5
  exports.debug = debug_1.default;
6
6
  /**
@@ -10,13 +10,14 @@ exports.types = require("./types");
10
10
  /**
11
11
  * Expose mediasoup-client version.
12
12
  */
13
- exports.version = '__MEDIASOUP_CLIENT_VERSION__';
13
+ exports.version = '3.10.0';
14
14
  /**
15
- * Expose Device class and detectDevice() helper.
15
+ * Expose Device class and device detector helpers.
16
16
  */
17
17
  var Device_1 = require("./Device");
18
18
  Object.defineProperty(exports, "Device", { enumerable: true, get: function () { return Device_1.Device; } });
19
19
  Object.defineProperty(exports, "detectDevice", { enumerable: true, get: function () { return Device_1.detectDevice; } });
20
+ Object.defineProperty(exports, "detectDeviceAsync", { enumerable: true, get: function () { return Device_1.detectDeviceAsync; } });
20
21
  /**
21
22
  * Expose parseScalabilityMode() function.
22
23
  */
package/lib/test/test.js CHANGED
@@ -13,7 +13,7 @@ const RemoteSdp_1 = require("../handlers/sdp/RemoteSdp");
13
13
  const FakeHandler_1 = require("../handlers/FakeHandler");
14
14
  const fakeParameters = require("./fakeParameters");
15
15
  const uaTestCases_1 = require("./uaTestCases");
16
- const { Device, detectDevice, parseScalabilityMode, debug } = mediasoupClient;
16
+ const { Device, detectDevice, detectDeviceAsync, parseScalabilityMode, debug } = mediasoupClient;
17
17
  const ctx = {};
18
18
  beforeEach(async () => {
19
19
  ctx.device = new Device({
@@ -1268,11 +1268,11 @@ test('parseScalabilityMode() works', () => {
1268
1268
  temporalLayers: 1,
1269
1269
  });
1270
1270
  });
1271
- describe('detectDevice() assigns proper handler based on UserAgent', () => {
1271
+ describe('detectDevice() and detectDeviceAsync() assign proper handler based on UserAgent', () => {
1272
1272
  for (const uaTestCase of uaTestCases_1.uaTestCases) {
1273
1273
  test(
1274
1274
  // eslint-disable-next-line jest/valid-title --- Jest is not that smart.
1275
- uaTestCase.desc, () => {
1275
+ uaTestCase.desc, async () => {
1276
1276
  const originalRTCRtpTransceiver = global.RTCRtpTransceiver;
1277
1277
  // We need to force presence of RTCRtpTransceiver to test Safari 12.
1278
1278
  if (uaTestCase.expect === 'Safari12') {
@@ -1283,6 +1283,7 @@ describe('detectDevice() assigns proper handler based on UserAgent', () => {
1283
1283
  };
1284
1284
  }
1285
1285
  expect(detectDevice(uaTestCase.ua)).toBe(uaTestCase.expect);
1286
+ await expect(detectDeviceAsync(uaTestCase.ua)).resolves.toBe(uaTestCase.expect);
1286
1287
  // Cleanup.
1287
1288
  global.RTCRtpTransceiver = originalRTCRtpTransceiver;
1288
1289
  }, 100);
package/npm-scripts.mjs CHANGED
@@ -53,6 +53,7 @@ async function run() {
53
53
  // So here we compile TypeScript to JavaScript.
54
54
  case 'prepare': {
55
55
  buildTypescript({ force: false });
56
+ replaceVersion();
56
57
 
57
58
  break;
58
59
  }
@@ -155,7 +156,7 @@ function deleteLib() {
155
156
  }
156
157
 
157
158
  function buildTypescript({ force }) {
158
- if (!force && fs.existsSync('node/lib')) {
159
+ if (!force && fs.existsSync('lib')) {
159
160
  return;
160
161
  }
161
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasoup-client",
3
- "version": "3.9.7",
3
+ "version": "3.10.0",
4
4
  "description": "mediasoup client side TypeScript library",
5
5
  "contributors": [
6
6
  "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
@@ -81,11 +81,11 @@
81
81
  "devDependencies": {
82
82
  "@eslint/js": "^9.25.1",
83
83
  "@types/jest": "^29.5.14",
84
- "@types/node": "^22.14.1",
84
+ "@types/node": "^22.15.3",
85
85
  "@types/sdp-transform": "^2.4.9",
86
86
  "@types/ua-parser-js": "^0.7.39",
87
- "@typescript-eslint/eslint-plugin": "^8.31.0",
88
- "@typescript-eslint/parser": "^8.31.0",
87
+ "@typescript-eslint/eslint-plugin": "^8.31.1",
88
+ "@typescript-eslint/parser": "^8.31.1",
89
89
  "eslint": "^9.25.1",
90
90
  "eslint-config-prettier": "^10.1.2",
91
91
  "eslint-plugin-jest": "^28.11.0",
@@ -96,6 +96,6 @@
96
96
  "prettier": "^3.5.3",
97
97
  "ts-jest": "^29.3.2",
98
98
  "typescript": "^5.8.3",
99
- "typescript-eslint": "^8.31.0"
99
+ "typescript-eslint": "^8.31.1"
100
100
  }
101
101
  }