mediasoup-client 3.15.5 → 3.15.7
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/README.md +1 -1
- package/lib/Device.d.ts +7 -7
- package/lib/Device.d.ts.map +1 -1
- package/lib/Device.js +56 -61
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/test/uaTestCases.d.ts.map +1 -1
- package/lib/test/uaTestCases.js +15 -0
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ const dataProducer = await sendTransport.produceData({
|
|
|
138
138
|
|
|
139
139
|
## Social
|
|
140
140
|
|
|
141
|
-
-
|
|
141
|
+
- Bluesky: [@mediasoup-sfu.bsky.social](https://bsky.app/profile/mediasoup-sfu.bsky.social)
|
|
142
142
|
|
|
143
143
|
## Sponsor
|
|
144
144
|
|
package/lib/Device.d.ts
CHANGED
|
@@ -16,17 +16,17 @@ export type DeviceOptions = {
|
|
|
16
16
|
handlerFactory?: HandlerFactory;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* `detectDevice()`.
|
|
19
|
+
* Sync mediasoup-client Handler detection.
|
|
21
20
|
*/
|
|
22
|
-
export declare function
|
|
21
|
+
export declare function detectDevice(userAgent?: string): BuiltinHandlerName | undefined;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* Async mediasoup-client Handler detection.
|
|
25
24
|
*
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* - Currently it runs same logic than `detectDevice()`.
|
|
27
|
+
* - In the future this function could give better results than `detectDevice()`.
|
|
28
28
|
*/
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function detectDeviceAsync(userAgent?: string): Promise<BuiltinHandlerName | undefined>;
|
|
30
30
|
export type DeviceObserver = EnhancedEventEmitter<DeviceObserverEvents>;
|
|
31
31
|
export type DeviceObserverEvents = {
|
|
32
32
|
newtransport: [Transport];
|
package/lib/Device.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../src/Device.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAIxD,OAAO,EACN,SAAS,EACT,KAAK,gBAAgB,EAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAMlE,OAAO,KAAK,EACX,eAAe,EACf,SAAS,EAET,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIvC,MAAM,MAAM,kBAAkB,GAC3B,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,gBAAgB,CAAC;AAEpB,MAAM,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAC3B,SAAS,CAAC,EAAE,MAAM,GAChB,kBAAkB,GAAG,SAAS,CAUhC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACtC,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAUzC;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG;IAClC,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC;CAC1B,CAAC;AAEF,qBAAa,MAAM;IAElB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;IA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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,OAAO,GACP,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAAC,gBAAgB,CAAC;IAiBnE,OAAO,CAAC,eAAe;CAqDvB"}
|
package/lib/Device.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = void 0;
|
|
4
|
-
exports.detectDeviceAsync = detectDeviceAsync;
|
|
5
4
|
exports.detectDevice = detectDevice;
|
|
6
|
-
|
|
5
|
+
exports.detectDeviceAsync = detectDeviceAsync;
|
|
6
|
+
const browser_dtector_1 = require("browser-dtector");
|
|
7
7
|
const Logger_1 = require("./Logger");
|
|
8
8
|
const enhancedEvents_1 = require("./enhancedEvents");
|
|
9
9
|
const errors_1 = require("./errors");
|
|
@@ -17,30 +17,30 @@ const Safari12_1 = require("./handlers/Safari12");
|
|
|
17
17
|
const ReactNative106_1 = require("./handlers/ReactNative106");
|
|
18
18
|
const logger = new Logger_1.Logger('Device');
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* `detectDevice()`.
|
|
20
|
+
* Sync mediasoup-client Handler detection.
|
|
22
21
|
*/
|
|
23
|
-
|
|
24
|
-
logger.debug('
|
|
22
|
+
function detectDevice(userAgent) {
|
|
23
|
+
logger.debug('detectDevice() [userAgent:%s]', userAgent);
|
|
25
24
|
if (!userAgent && typeof navigator === 'object') {
|
|
26
25
|
userAgent = navigator.userAgent;
|
|
27
26
|
}
|
|
28
|
-
const
|
|
29
|
-
return detectDeviceImpl(
|
|
27
|
+
const browserDetector = new browser_dtector_1.default(userAgent);
|
|
28
|
+
return detectDeviceImpl(browserDetector);
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
31
|
+
* Async mediasoup-client Handler detection.
|
|
33
32
|
*
|
|
34
|
-
* @
|
|
35
|
-
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - Currently it runs same logic than `detectDevice()`.
|
|
35
|
+
* - In the future this function could give better results than `detectDevice()`.
|
|
36
36
|
*/
|
|
37
|
-
function
|
|
38
|
-
logger.debug('
|
|
37
|
+
async function detectDeviceAsync(userAgent) {
|
|
38
|
+
logger.debug('detectDeviceAsync() [userAgent:%s]', userAgent);
|
|
39
39
|
if (!userAgent && typeof navigator === 'object') {
|
|
40
40
|
userAgent = navigator.userAgent;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
return detectDeviceImpl(
|
|
42
|
+
const browserDetector = new browser_dtector_1.default(userAgent);
|
|
43
|
+
return detectDeviceImpl(browserDetector);
|
|
44
44
|
}
|
|
45
45
|
class Device {
|
|
46
46
|
// RTC handler factory.
|
|
@@ -313,7 +313,7 @@ class Device {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
exports.Device = Device;
|
|
316
|
-
function detectDeviceImpl(
|
|
316
|
+
function detectDeviceImpl(browserDetector) {
|
|
317
317
|
// React-Native.
|
|
318
318
|
if (typeof navigator === 'object' && navigator.product === 'ReactNative') {
|
|
319
319
|
logger.debug('detectDeviceImpl() | React-Native detected');
|
|
@@ -326,64 +326,62 @@ function detectDeviceImpl(uaParserResult) {
|
|
|
326
326
|
}
|
|
327
327
|
// Browser.
|
|
328
328
|
else {
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
const
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
329
|
+
const parsed = browserDetector.parseUserAgent();
|
|
330
|
+
const browserMajorVersionMatch = /^\d+/.exec(parsed?.shortVersion ?? '0');
|
|
331
|
+
const browserMajorVersion = parseInt(browserMajorVersionMatch?.[0] ?? '0', 10);
|
|
332
|
+
const isIOS = parsed.platform === browser_dtector_1.KnownPlatforms.iphone ||
|
|
333
|
+
parsed.platform === browser_dtector_1.KnownPlatforms.ipad ||
|
|
334
|
+
(parsed.platform === browser_dtector_1.KnownPlatforms.mac &&
|
|
335
|
+
(parsed.isMobile ||
|
|
336
|
+
parsed.isTablet ||
|
|
337
|
+
(typeof navigator === 'object' && navigator?.maxTouchPoints >= 2)));
|
|
338
|
+
const isChrome = parsed.isChrome;
|
|
339
|
+
const isFirefox = parsed.isFireFox;
|
|
340
|
+
const isSafari = parsed.isSafari;
|
|
341
|
+
const isEdge = parsed.isEdge;
|
|
342
|
+
const isElectron = parsed.isDesktop && parsed.name === browser_dtector_1.KnownBrowsers.electron;
|
|
343
|
+
// For logging purposes.
|
|
344
|
+
const result = {
|
|
345
|
+
browserMajorVersion,
|
|
346
|
+
isIOS,
|
|
347
|
+
isChrome,
|
|
348
|
+
isFirefox,
|
|
349
|
+
isSafari,
|
|
350
|
+
isElectron,
|
|
351
|
+
};
|
|
352
|
+
logger.debug('detectDeviceImpl() | detected browser [userAgent:%s, parsed:%o, result:%o]', parsed.userAgent, parsed, result);
|
|
353
353
|
// Chrome, Chromium, and Edge.
|
|
354
|
-
if ((isChrome || isEdge) && !isIOS &&
|
|
354
|
+
if ((isChrome || isEdge) && !isIOS && browserMajorVersion >= 111) {
|
|
355
355
|
return 'Chrome111';
|
|
356
356
|
}
|
|
357
|
-
else if ((isChrome && !isIOS &&
|
|
358
|
-
(isEdge && !isIOS &&
|
|
357
|
+
else if ((isChrome && !isIOS && browserMajorVersion >= 74) ||
|
|
358
|
+
(isEdge && !isIOS && browserMajorVersion >= 88)) {
|
|
359
359
|
return 'Chrome74';
|
|
360
360
|
}
|
|
361
|
+
// Electron.
|
|
362
|
+
else if (isElectron) {
|
|
363
|
+
return 'Chrome111';
|
|
364
|
+
}
|
|
361
365
|
// Firefox.
|
|
362
|
-
else if (isFirefox && !isIOS &&
|
|
366
|
+
else if (isFirefox && !isIOS && browserMajorVersion >= 120) {
|
|
363
367
|
return 'Firefox120';
|
|
364
368
|
}
|
|
365
|
-
//
|
|
366
|
-
else if (isFirefox && isIOS && osVersion >= 14.3) {
|
|
367
|
-
return 'Safari12';
|
|
368
|
-
}
|
|
369
|
-
// Safari with Unified-Plan support enabled.
|
|
369
|
+
// Safari.
|
|
370
370
|
else if (isSafari &&
|
|
371
|
-
|
|
371
|
+
browserMajorVersion >= 12 &&
|
|
372
372
|
typeof RTCRtpTransceiver !== 'undefined' &&
|
|
373
373
|
RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
|
|
374
374
|
return 'Safari12';
|
|
375
375
|
}
|
|
376
376
|
// Best effort for WebKit based browsers in iOS.
|
|
377
|
-
else if (
|
|
378
|
-
isIOS &&
|
|
377
|
+
else if (isIOS &&
|
|
379
378
|
typeof RTCRtpTransceiver !== 'undefined' &&
|
|
380
379
|
RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
|
|
381
380
|
return 'Safari12';
|
|
382
381
|
}
|
|
383
382
|
// Best effort for Chromium based browsers.
|
|
384
|
-
else
|
|
385
|
-
|
|
386
|
-
const match = uaParserResult.ua.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
|
|
383
|
+
else {
|
|
384
|
+
const match = browserDetector.userAgent?.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
|
|
387
385
|
if (match) {
|
|
388
386
|
const version = Number(match[1]);
|
|
389
387
|
if (version >= 111) {
|
|
@@ -393,14 +391,11 @@ function detectDeviceImpl(uaParserResult) {
|
|
|
393
391
|
return 'Chrome74';
|
|
394
392
|
}
|
|
395
393
|
}
|
|
394
|
+
// Unsupported browser.
|
|
396
395
|
else {
|
|
397
|
-
|
|
396
|
+
logger.warn('detectDeviceImpl() | browser not supported [userAgent:%s, parsed:%o, result:%o]', parsed.userAgent, parsed, result);
|
|
397
|
+
return undefined;
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
// Unsupported browser.
|
|
401
|
-
else {
|
|
402
|
-
logger.warn('detectDeviceImpl() | browser not supported [name:%s, version:%s]', browserName, browserVersion);
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
400
|
}
|
|
406
401
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uaTestCases.d.ts","sourceRoot":"","sources":["../../src/test/uaTestCases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,KAAK,UAAU,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"uaTestCases.d.ts","sourceRoot":"","sources":["../../src/test/uaTestCases.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,KAAK,UAAU,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,UAAU,EAuFnC,CAAC"}
|
package/lib/test/uaTestCases.js
CHANGED
|
@@ -57,6 +57,11 @@ exports.uaTestCases = [
|
|
|
57
57
|
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.37(0x1800252f) NetType/WIFI Language/zh_CN',
|
|
58
58
|
expect: 'Safari12',
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
desc: 'Custom Webview in iPad',
|
|
62
|
+
ua: 'Mozilla/5.0 (iPad; CPU iPadOS 16_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1 MyApp/1.0',
|
|
63
|
+
expect: 'Safari12',
|
|
64
|
+
},
|
|
60
65
|
{
|
|
61
66
|
desc: 'Chrome Mobile (iOS)',
|
|
62
67
|
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/114.0.5735.124 Mobile/15E148 Safari/604.1',
|
|
@@ -73,4 +78,14 @@ exports.uaTestCases = [
|
|
|
73
78
|
ua: 'Mozilla/5.0 ZoomWebKit/537.36 (KHTML, like Gecko) ZoomApps/1.0',
|
|
74
79
|
expect: undefined,
|
|
75
80
|
},
|
|
81
|
+
{
|
|
82
|
+
desc: 'Electron in Windows',
|
|
83
|
+
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Electron/37.4.0 Chrome/138.0.7204.243 Safari/537.36',
|
|
84
|
+
expect: 'Chrome111',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
desc: 'Samsung Browser (Android)',
|
|
88
|
+
ua: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/28.0 Chrome/130.0.0.0 Mobile Safari/537.36',
|
|
89
|
+
expect: 'Chrome111',
|
|
90
|
+
},
|
|
76
91
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup-client",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.7",
|
|
4
4
|
"description": "mediasoup client side TypeScript library",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -74,30 +74,30 @@
|
|
|
74
74
|
"@types/debug": "^4.1.12",
|
|
75
75
|
"@types/events-alias": "npm:@types/events@^3.0.3",
|
|
76
76
|
"awaitqueue": "^3.2.4",
|
|
77
|
-
"
|
|
77
|
+
"browser-dtector": "^4.1.0",
|
|
78
|
+
"debug": "^4.4.3",
|
|
78
79
|
"events-alias": "npm:events@^3.3.0",
|
|
79
80
|
"fake-mediastreamtrack": "^2.1.4",
|
|
80
81
|
"h264-profile-level-id": "^2.2.3",
|
|
81
82
|
"sdp-transform": "^2.15.0",
|
|
82
|
-
"supports-color": "^10.2.
|
|
83
|
-
"ua-parser-js": "^2.0.4"
|
|
83
|
+
"supports-color": "^10.2.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@eslint/js": "^9.
|
|
86
|
+
"@eslint/js": "^9.35.0",
|
|
87
87
|
"@types/jest": "^30.0.0",
|
|
88
|
-
"@types/node": "^24.
|
|
88
|
+
"@types/node": "^24.4.0",
|
|
89
89
|
"@types/sdp-transform": "^2.15.0",
|
|
90
90
|
"@types/ua-parser-js": "^0.7.39",
|
|
91
|
-
"eslint": "^9.
|
|
91
|
+
"eslint": "^9.35.0",
|
|
92
92
|
"eslint-config-prettier": "^10.1.8",
|
|
93
93
|
"eslint-plugin-jest": "^29.0.1",
|
|
94
94
|
"eslint-plugin-prettier": "^5.5.4",
|
|
95
|
-
"globals": "^16.
|
|
96
|
-
"jest": "^30.1.
|
|
95
|
+
"globals": "^16.4.0",
|
|
96
|
+
"jest": "^30.1.3",
|
|
97
97
|
"open-cli": "^8.0.0",
|
|
98
98
|
"prettier": "^3.6.2",
|
|
99
99
|
"ts-jest": "^29.4.1",
|
|
100
100
|
"typescript": "^5.9.2",
|
|
101
|
-
"typescript-eslint": "^8.
|
|
101
|
+
"typescript-eslint": "^8.43.0"
|
|
102
102
|
}
|
|
103
103
|
}
|