mediasoup-client 3.15.5 → 3.15.6
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 +7 -7
- package/lib/Device.d.ts.map +1 -1
- package/lib/Device.js +56 -56
- 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 +10 -0
- package/package.json +5 -5
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,CAA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AAe;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,64 @@ 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
|
+
const isWebkit = parsed.isWebkit;
|
|
344
|
+
// For logging purposes.
|
|
345
|
+
const result = {
|
|
346
|
+
browserMajorVersion,
|
|
347
|
+
isIOS,
|
|
348
|
+
isChrome,
|
|
349
|
+
isFirefox,
|
|
350
|
+
isSafari,
|
|
351
|
+
isElectron,
|
|
352
|
+
isWebkit,
|
|
353
|
+
};
|
|
354
|
+
logger.debug('detectDeviceImpl() | detected browser [userAgent:%s, parsed:%o, result:%o]', parsed.userAgent, parsed, result);
|
|
353
355
|
// Chrome, Chromium, and Edge.
|
|
354
|
-
if ((isChrome || isEdge) && !isIOS &&
|
|
356
|
+
if ((isChrome || isEdge) && !isIOS && browserMajorVersion >= 111) {
|
|
355
357
|
return 'Chrome111';
|
|
356
358
|
}
|
|
357
|
-
else if ((isChrome && !isIOS &&
|
|
358
|
-
(isEdge && !isIOS &&
|
|
359
|
+
else if ((isChrome && !isIOS && browserMajorVersion >= 74) ||
|
|
360
|
+
(isEdge && !isIOS && browserMajorVersion >= 88)) {
|
|
359
361
|
return 'Chrome74';
|
|
360
362
|
}
|
|
363
|
+
// Electron.
|
|
364
|
+
else if (isElectron) {
|
|
365
|
+
return 'Chrome111';
|
|
366
|
+
}
|
|
361
367
|
// Firefox.
|
|
362
|
-
else if (isFirefox && !isIOS &&
|
|
368
|
+
else if (isFirefox && !isIOS && browserMajorVersion >= 120) {
|
|
363
369
|
return 'Firefox120';
|
|
364
370
|
}
|
|
365
|
-
//
|
|
366
|
-
else if (isFirefox && isIOS && osVersion >= 14.3) {
|
|
367
|
-
return 'Safari12';
|
|
368
|
-
}
|
|
369
|
-
// Safari with Unified-Plan support enabled.
|
|
371
|
+
// Safari.
|
|
370
372
|
else if (isSafari &&
|
|
371
|
-
|
|
373
|
+
browserMajorVersion >= 12 &&
|
|
372
374
|
typeof RTCRtpTransceiver !== 'undefined' &&
|
|
373
375
|
RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
|
|
374
376
|
return 'Safari12';
|
|
375
377
|
}
|
|
376
378
|
// Best effort for WebKit based browsers in iOS.
|
|
377
|
-
else if (
|
|
378
|
-
isIOS &&
|
|
379
|
+
else if (isIOS &&
|
|
379
380
|
typeof RTCRtpTransceiver !== 'undefined' &&
|
|
380
381
|
RTCRtpTransceiver.prototype.hasOwnProperty('currentDirection')) {
|
|
381
382
|
return 'Safari12';
|
|
382
383
|
}
|
|
383
384
|
// Best effort for Chromium based browsers.
|
|
384
|
-
else if (
|
|
385
|
-
|
|
386
|
-
const match = uaParserResult.ua.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
|
|
385
|
+
else if (isWebkit) {
|
|
386
|
+
const match = browserDetector.userAgent?.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);
|
|
387
387
|
if (match) {
|
|
388
388
|
const version = Number(match[1]);
|
|
389
389
|
if (version >= 111) {
|
|
@@ -399,7 +399,7 @@ function detectDeviceImpl(uaParserResult) {
|
|
|
399
399
|
}
|
|
400
400
|
// Unsupported browser.
|
|
401
401
|
else {
|
|
402
|
-
logger.warn('detectDeviceImpl() | browser not supported [
|
|
402
|
+
logger.warn('detectDeviceImpl() | browser not supported [userAgent:%s, parsed:%o, result:%o]', parsed.userAgent, parsed, result);
|
|
403
403
|
return undefined;
|
|
404
404
|
}
|
|
405
405
|
}
|
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,EAkFnC,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,9 @@ 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
|
+
},
|
|
76
86
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup-client",
|
|
3
|
-
"version": "3.15.
|
|
3
|
+
"version": "3.15.6",
|
|
4
4
|
"description": "mediasoup client side TypeScript library",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -74,13 +74,13 @@
|
|
|
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
|
+
"browser-dtector": "^4.1.0",
|
|
77
78
|
"debug": "^4.4.1",
|
|
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.0"
|
|
83
|
-
"ua-parser-js": "^2.0.4"
|
|
83
|
+
"supports-color": "^10.2.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@eslint/js": "^9.34.0",
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
"eslint-plugin-jest": "^29.0.1",
|
|
94
94
|
"eslint-plugin-prettier": "^5.5.4",
|
|
95
95
|
"globals": "^16.3.0",
|
|
96
|
-
"jest": "^30.1.
|
|
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.42.0"
|
|
102
102
|
}
|
|
103
103
|
}
|