native-fn 1.1.9 → 1.2.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.
- package/README.md +488 -146
- package/dist/index.d.ts +138 -119
- package/dist/native.cjs +661 -565
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +661 -565
- package/dist/native.umd.js +661 -565
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/appearance/index.cjs +8 -3
- package/dist/plugin/appearance/index.mjs +8 -3
- package/dist/plugin/appearance/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/appearance/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/appearance/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/appearance/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/appearance/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/appearance/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/appearance/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/appearance/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/appearance/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/appearance/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/appearance/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/appearance/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/badge/index.cjs +2 -2
- package/dist/plugin/badge/index.d.ts +1 -1
- package/dist/plugin/badge/index.mjs +2 -2
- package/dist/plugin/badge/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/badge/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/badge/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/badge/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/badge/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/badge/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/badge/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/badge/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/badge/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/battery/index.cjs +3 -3
- package/dist/plugin/battery/index.d.ts +1 -1
- package/dist/plugin/battery/index.mjs +3 -3
- package/dist/plugin/battery/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/battery/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/battery/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/battery/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/battery/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/battery/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/battery/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/battery/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/battery/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/clipboard/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/clipboard/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/clipboard/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/clipboard/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/clipboard/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/clipboard/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/clipboard/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/clipboard/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/clipboard/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/dimension/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/dimension/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/dimension/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/dimension/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/dimension/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/dimension/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/dimension/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/dimension/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/dimension/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/fullscreen/index.cjs +539 -266
- package/dist/plugin/fullscreen/index.d.ts +20 -10
- package/dist/plugin/fullscreen/index.mjs +539 -266
- package/dist/plugin/fullscreen/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/fullscreen/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/fullscreen/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/fullscreen/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/fullscreen/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/fullscreen/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/fullscreen/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/fullscreen/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/fullscreen/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/fullscreen/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/fullscreen/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/fullscreen/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/geolocation/index.cjs +6 -0
- package/dist/plugin/geolocation/index.d.ts +1 -1
- package/dist/plugin/geolocation/index.mjs +6 -0
- package/dist/plugin/geolocation/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/geolocation/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/geolocation/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/geolocation/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/geolocation/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/geolocation/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/geolocation/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/geolocation/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/geolocation/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/notification/index.cjs +6 -0
- package/dist/plugin/notification/index.mjs +6 -0
- package/dist/plugin/notification/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/notification/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/notification/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/notification/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/notification/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/notification/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/notification/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/notification/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/notification/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/open/index.cjs +128 -123
- package/dist/plugin/open/index.d.ts +35 -35
- package/dist/plugin/open/index.mjs +128 -123
- package/dist/plugin/open/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/open/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/open/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/open/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/open/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/open/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/open/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/open/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/open/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/open/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/open/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/open/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/permission/index.cjs +6 -0
- package/dist/plugin/permission/index.d.ts +1 -0
- package/dist/plugin/permission/index.mjs +6 -0
- package/dist/plugin/permission/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/permission/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/permission/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/permission/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/permission/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/permission/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/permission/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/permission/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/permission/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/pip/index.cjs +651 -268
- package/dist/plugin/pip/index.d.ts +22 -12
- package/dist/plugin/pip/index.mjs +651 -268
- package/dist/plugin/pip/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/pip/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/pip/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/pip/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/pip/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/pip/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/pip/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/pip/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/pip/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/pip/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/pip/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/pip/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/platform/index.cjs +8 -3
- package/dist/plugin/platform/index.d.ts +5 -5
- package/dist/plugin/platform/index.mjs +8 -3
- package/dist/plugin/platform/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/platform/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/platform/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/platform/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/platform/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/platform/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/platform/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/platform/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/platform/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/platform/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/platform/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/platform/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/theme/index.cjs +8 -3
- package/dist/plugin/theme/index.mjs +8 -3
- package/dist/plugin/theme/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/theme/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/theme/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/theme/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/theme/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/theme/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/theme/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/theme/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/theme/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/theme/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/theme/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/theme/src/types/subscription-manager.d.ts +1 -1
- package/dist/plugin/vibration/index.cjs +5 -5
- package/dist/plugin/vibration/index.d.ts +1 -1
- package/dist/plugin/vibration/index.mjs +5 -5
- package/dist/plugin/vibration/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/plugin/vibration/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/plugin/vibration/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/plugin/vibration/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/open/types/open.d.ts +1 -1
- package/dist/plugin/vibration/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/plugin/vibration/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/plugin/vibration/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/plugin/vibration/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/plugin/vibration/src/types/subscription-manager.d.ts +1 -1
- package/dist/src/errors/invalid-state-error.d.ts +2 -0
- package/dist/src/plugin/badge/types/badge.d.ts +1 -1
- package/dist/src/plugin/battery/types/battery.d.ts +1 -1
- package/dist/src/plugin/fullscreen/cores/index.d.ts +3 -3
- package/dist/src/plugin/fullscreen/types/fullscreen.d.ts +15 -6
- package/dist/src/plugin/geolocation/types/geolocation.d.ts +1 -1
- package/dist/src/plugin/open/types/open.d.ts +1 -1
- package/dist/src/plugin/permission/types/permission.d.ts +1 -0
- package/dist/src/plugin/pip/cores/index.d.ts +6 -6
- package/dist/src/plugin/pip/types/pip.d.ts +14 -5
- package/dist/src/plugin/vibration/types/vibration.d.ts +1 -1
- package/dist/src/types/subscription-manager.d.ts +1 -1
- package/package.json +21 -13
|
@@ -348,301 +348,684 @@ function createCustomError(name, Base) {
|
|
|
348
348
|
|
|
349
349
|
var NotSupportedError = createCustomError('NotSupportedError');
|
|
350
350
|
|
|
351
|
-
var
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
var InvalidStateError = createCustomError('InvalidStateError');
|
|
352
|
+
|
|
353
|
+
function compareVersion(lhs, rhs) {
|
|
354
|
+
var pa = lhs.split('.');
|
|
355
|
+
var pb = rhs.split('.');
|
|
356
|
+
var length = Math.max(pa.length, pb.length);
|
|
357
|
+
for (var i = 0; i < length; i++) {
|
|
358
|
+
var a = void 0;
|
|
359
|
+
var b = void 0;
|
|
360
|
+
if (i < pa.length)
|
|
361
|
+
a = parseInt(pa[i], 10);
|
|
362
|
+
else
|
|
363
|
+
a = 0;
|
|
364
|
+
if (i < pb.length)
|
|
365
|
+
b = parseInt(pb[i], 10);
|
|
366
|
+
else
|
|
367
|
+
b = 0;
|
|
368
|
+
if (a > b)
|
|
369
|
+
return 1;
|
|
370
|
+
if (a < b)
|
|
371
|
+
return -1;
|
|
372
|
+
}
|
|
373
|
+
return 0;
|
|
356
374
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
375
|
+
|
|
376
|
+
function resolveWindowsVersion(string) {
|
|
377
|
+
if (typeof string === 'undefined')
|
|
378
|
+
return '';
|
|
379
|
+
var mapped = {
|
|
380
|
+
'4.90': 'ME',
|
|
381
|
+
'NT3.51': 'NT 3.11',
|
|
382
|
+
'NT4.0': 'NT 4.0',
|
|
383
|
+
'NT 5.0': '2000',
|
|
384
|
+
'NT 5.1': 'XP',
|
|
385
|
+
'NT 5.2': 'XP',
|
|
386
|
+
'NT 6.0': 'Vista',
|
|
387
|
+
'NT 6.1': '7',
|
|
388
|
+
'NT 6.2': '8',
|
|
389
|
+
'NT 6.3': '8.1',
|
|
390
|
+
'NT 6.4': '10',
|
|
391
|
+
'NT 10.0': '10',
|
|
392
|
+
'ARM': 'RT'
|
|
393
|
+
}[string];
|
|
394
|
+
if (typeof mapped !== 'undefined')
|
|
395
|
+
return mapped;
|
|
396
|
+
return string;
|
|
397
|
+
}
|
|
398
|
+
function resolveUnderscoreVersion(string) {
|
|
399
|
+
if (typeof string === 'undefined')
|
|
400
|
+
return '';
|
|
401
|
+
return string.replace(/_/g, '.');
|
|
402
|
+
}
|
|
403
|
+
var OS;
|
|
404
|
+
(function (OS) {
|
|
405
|
+
OS["Unknown"] = "Unknown";
|
|
406
|
+
OS["Android"] = "Android";
|
|
407
|
+
OS["iOS"] = "iOS";
|
|
408
|
+
OS["Windows"] = "Windows";
|
|
409
|
+
OS["MacOS"] = "MacOS";
|
|
410
|
+
})(OS || (OS = {}));
|
|
411
|
+
var Devices;
|
|
412
|
+
(function (Devices) {
|
|
413
|
+
Devices["Unknown"] = "Unknown";
|
|
414
|
+
Devices["Mobile"] = "Mobile";
|
|
415
|
+
Devices["Desktop"] = "Desktop";
|
|
416
|
+
})(Devices || (Devices = {}));
|
|
417
|
+
var Engines;
|
|
418
|
+
(function (Engines) {
|
|
419
|
+
Engines["Unknown"] = "Unknown";
|
|
420
|
+
Engines["EdgeHTML"] = "EdgeHTML";
|
|
421
|
+
Engines["ArkWeb"] = "ArkWeb";
|
|
422
|
+
Engines["Blink"] = "Blink";
|
|
423
|
+
Engines["Presto"] = "Presto";
|
|
424
|
+
Engines["WebKit"] = "WebKit";
|
|
425
|
+
Engines["Trident"] = "Trident";
|
|
426
|
+
Engines["NetFront"] = "NetFront";
|
|
427
|
+
Engines["KHTML"] = "KHTML";
|
|
428
|
+
Engines["Tasman"] = "Tasman";
|
|
429
|
+
Engines["Gecko"] = "Gecko";
|
|
430
|
+
})(Engines || (Engines = {}));
|
|
431
|
+
var Browsers;
|
|
432
|
+
(function (Browsers) {
|
|
433
|
+
Browsers["Unknown"] = "Unknown";
|
|
434
|
+
Browsers["Chrome"] = "Chrome";
|
|
435
|
+
Browsers["Safari"] = "Safari";
|
|
436
|
+
Browsers["Edge"] = "Edge";
|
|
437
|
+
Browsers["Firefox"] = "Firefox";
|
|
438
|
+
Browsers["Opera"] = "Opera";
|
|
439
|
+
Browsers["IE"] = "IE";
|
|
440
|
+
Browsers["SamsungInternet"] = "SamsungInternet";
|
|
441
|
+
})(Browsers || (Browsers = {}));
|
|
442
|
+
var USER_AGENT = (function () {
|
|
443
|
+
if (typeof globalThis.navigator.userAgent !== 'undefined')
|
|
444
|
+
return globalThis.navigator.userAgent;
|
|
445
|
+
return '';
|
|
446
|
+
})();
|
|
447
|
+
var HIGH_ENTROPY_BRAND_NAME_MAP = {
|
|
448
|
+
'Google Chrome': 'Chrome',
|
|
449
|
+
'Microsoft Edge': 'Edge',
|
|
450
|
+
'Microsoft Edge WebView2': 'Edge WebView2',
|
|
451
|
+
'Android WebView': 'Chrome WebView',
|
|
452
|
+
'HeadlessChrome': 'Chrome Headless',
|
|
453
|
+
'OperaMobile': 'Opera Mobi',
|
|
454
|
+
};
|
|
455
|
+
var OS_RESOLVER_MAP = [
|
|
456
|
+
[/windows nt (6\.[23]); arm/i, OS.Windows, resolveWindowsVersion],
|
|
457
|
+
[/windows (?:phone|mobile|iot)(?: os)?[\/ ]?([\d.]*( se)?)/i, OS.Windows, resolveWindowsVersion],
|
|
458
|
+
[/windows[\/ ](1[01]|2000|3\.1|7|8(\.1)?|9[58]|me|server 20\d\d( r2)?|vista|xp)/i, OS.Windows, resolveWindowsVersion],
|
|
459
|
+
[/windows nt ?([\d.)]*)(?!.+xbox)/i, OS.Windows, resolveWindowsVersion],
|
|
460
|
+
[/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d.;]*)/i, OS.Windows, resolveWindowsVersion],
|
|
461
|
+
[/windows ce\/?([\d.]*)/i, OS.Windows, resolveWindowsVersion],
|
|
462
|
+
[/[adehimnop]{4,7}\b(?:.*os (\w+) like mac|; opera)/i, OS.iOS, resolveUnderscoreVersion],
|
|
463
|
+
[/(?:ios;fbsv|ios(?=.+ip(?:ad|hone))|ip(?:ad|hone)(?: |.+i(?:pad)?)os)[\/ ]([\w.]+)/i, OS.iOS, resolveUnderscoreVersion],
|
|
464
|
+
[/cfnetwork\/.+darwin/i, OS.iOS, resolveUnderscoreVersion],
|
|
465
|
+
[/mac os x ?([\w. ]*)/i, OS.MacOS, resolveUnderscoreVersion],
|
|
466
|
+
[/(?:macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i, OS.MacOS, resolveUnderscoreVersion],
|
|
467
|
+
[/droid ([\w.]+)\b.+(android[- ]x86)/i, OS.Android],
|
|
468
|
+
[/android\w*[-\/.; ]?([\d.]*)/i, OS.Android],
|
|
469
|
+
];
|
|
470
|
+
var ENGINE_RESOLVER_MAP = [
|
|
471
|
+
[/windows.+ edge\/([\w.]+)/i, Engines.EdgeHTML],
|
|
472
|
+
[/arkweb\/([\w.]+)/i, Engines.ArkWeb],
|
|
473
|
+
[/webkit\/537\.36.+chrome\/(?!27)([\w.]+)/i, Engines.Blink],
|
|
474
|
+
[/presto\/([\w.]+)/i, Engines.Presto],
|
|
475
|
+
[/webkit\/([\w.]+)/i, Engines.WebKit],
|
|
476
|
+
[/trident\/([\w.]+)/i, Engines.Trident],
|
|
477
|
+
[/netfront\/([\w.]+)/i, Engines.NetFront],
|
|
478
|
+
[/khtml[\/ ]\(?([\w.]+)/i, Engines.KHTML],
|
|
479
|
+
[/tasman[\/ ]\(?([\w.]+)/i, Engines.Tasman],
|
|
480
|
+
[/rv:([\w.]{1,9})\b.+gecko/i, Engines.Gecko]
|
|
481
|
+
];
|
|
482
|
+
var BROWSER_RESOLVER_MAP = [
|
|
483
|
+
[/\b(?:crmo|crios)\/([\w.]+)/i, Browsers.Chrome],
|
|
484
|
+
[/webview.+edge\/([\w.]+)/i, Browsers.Edge],
|
|
485
|
+
[/edg(?:e|ios|a)?\/([\w.]+)/i, Browsers.Edge],
|
|
486
|
+
[/opera mini\/([-\w.]+)/i, Browsers.Opera],
|
|
487
|
+
[/opera [mobileta]{3,6}\b.+version\/([-\w.]+)/i, Browsers.Opera],
|
|
488
|
+
[/opera(?:.+version\/|[\/ ]+)([\w.]+)/i, Browsers.Opera],
|
|
489
|
+
[/opios[\/ ]+([\w.]+)/i, Browsers.Opera],
|
|
490
|
+
[/\bop(?:rg)?x\/([\w.]+)/i, Browsers.Opera],
|
|
491
|
+
[/\bopr\/([\w.]+)/i, Browsers.Opera],
|
|
492
|
+
[/iemobile(?:browser|boat|jet)[\/ ]?([\d.]*)/i, Browsers.IE],
|
|
493
|
+
[/(?:ms|\()ie ([\w.]+)/i, Browsers.IE],
|
|
494
|
+
[/trident.+rv[: ]([\w.]{1,9})\b.+like gecko/i, Browsers.IE],
|
|
495
|
+
[/\bfocus\/([\w.]+)/i, Browsers.Firefox],
|
|
496
|
+
[/\bopt\/([\w.]+)/i, Browsers.Opera],
|
|
497
|
+
[/coast\/([\w.]+)/i, Browsers.Opera],
|
|
498
|
+
[/fxios\/([\w.-]+)/i, Browsers.Firefox],
|
|
499
|
+
[/samsungbrowser\/([\w.]+)/i, Browsers.SamsungInternet],
|
|
500
|
+
[/headlesschrome(?:\/([\w.]+)| )/i, Browsers.Chrome],
|
|
501
|
+
[/wv\).+chrome\/([\w.]+).+edgw\//i, Browsers.Edge],
|
|
502
|
+
[/ wv\).+(chrome)\/([\w.]+)/i, Browsers.Chrome],
|
|
503
|
+
[/chrome\/([\w.]+) mobile/i, Browsers.Chrome],
|
|
504
|
+
[/chrome\/v?([\w.]+)/i, Browsers.Chrome],
|
|
505
|
+
[/version\/([\w.,]+) .*mobile(?:\/\w+ | ?)safari/i, Browsers.Safari],
|
|
506
|
+
[/iphone .*mobile(?:\/\w+ | ?)safari/i, Browsers.Safari],
|
|
507
|
+
[/version\/([\w.,]+) .*safari/i, Browsers.Safari],
|
|
508
|
+
[/webkit.+?(?:mobile ?safari|safari)(\/[\w.]+)/i, Browsers.Safari, '1'],
|
|
509
|
+
[/(?:mobile|tablet);.*firefox\/([\w.-]+)/i, Browsers.Firefox],
|
|
510
|
+
[/mobile vr; rv:([\w.]+)\).+firefox/i, Browsers.Firefox],
|
|
511
|
+
[/firefox\/([\w.]+)/i, Browsers.Firefox],
|
|
512
|
+
];
|
|
513
|
+
|
|
514
|
+
var currentUserAgent = USER_AGENT;
|
|
515
|
+
var parsedCache = null;
|
|
516
|
+
var parsedFromHighEntropyValuesOS = {};
|
|
517
|
+
var parsedFromHighEntropyValuesBrowser = {};
|
|
518
|
+
var parsedFromHighEntropyValuesEngine = {};
|
|
519
|
+
var parsedFromHighEntropyValuesDevice = null;
|
|
520
|
+
function resolveVersion(string, resolver) {
|
|
521
|
+
if (typeof resolver === 'function')
|
|
522
|
+
return resolver(string);
|
|
523
|
+
if (typeof resolver === 'string')
|
|
524
|
+
return resolver;
|
|
525
|
+
if (typeof string === 'undefined')
|
|
526
|
+
return '';
|
|
527
|
+
return string;
|
|
528
|
+
}
|
|
529
|
+
function normalizeBrand(entry) {
|
|
530
|
+
if (entry === null || typeof entry === 'undefined')
|
|
531
|
+
return { brand: '', version: '' };
|
|
532
|
+
if (typeof entry === 'string')
|
|
533
|
+
return { brand: entry, version: '' };
|
|
534
|
+
return { brand: entry.brand, version: entry.version };
|
|
535
|
+
}
|
|
536
|
+
function getParsedCache() {
|
|
537
|
+
if (parsedCache !== null && parsedCache.userAgent === currentUserAgent)
|
|
538
|
+
return parsedCache;
|
|
539
|
+
parsedCache = {
|
|
540
|
+
userAgent: currentUserAgent,
|
|
541
|
+
os: parseOS(),
|
|
542
|
+
browser: parseBrowser(),
|
|
543
|
+
engine: parseEngine(),
|
|
544
|
+
};
|
|
545
|
+
return parsedCache;
|
|
546
|
+
}
|
|
547
|
+
function parseOS() {
|
|
548
|
+
var result = { name: OS.Unknown, version: '' };
|
|
549
|
+
for (var i = 0; i < OS_RESOLVER_MAP.length; i++) {
|
|
550
|
+
var map = OS_RESOLVER_MAP[i];
|
|
551
|
+
var matched = currentUserAgent.match(map[0]);
|
|
552
|
+
if (matched !== null) {
|
|
553
|
+
result.name = map[1];
|
|
554
|
+
result.version = resolveVersion(matched[1], map[2]);
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (result.name === OS.iOS && compareVersion(result.version, '18.6') === 0) {
|
|
559
|
+
var version = /\) Version\/([\d.]+)/.exec(currentUserAgent);
|
|
560
|
+
if (version !== null) {
|
|
561
|
+
var major = parseInt(version[1].split('.')[0], 10);
|
|
562
|
+
if (major >= 26)
|
|
563
|
+
result.version = version[1];
|
|
564
|
+
}
|
|
394
565
|
}
|
|
395
|
-
|
|
396
|
-
if (
|
|
397
|
-
|
|
566
|
+
if (currentUserAgent === USER_AGENT) {
|
|
567
|
+
if (typeof parsedFromHighEntropyValuesOS.name !== 'undefined')
|
|
568
|
+
result.name = parsedFromHighEntropyValuesOS.name;
|
|
569
|
+
if (typeof parsedFromHighEntropyValuesOS.version !== 'undefined')
|
|
570
|
+
result.version = parsedFromHighEntropyValuesOS.version;
|
|
571
|
+
if (result.name === OS.MacOS && typeof globalThis.navigator.standalone !== 'undefined' && globalThis.navigator.maxTouchPoints > 2)
|
|
572
|
+
result.name = OS.iOS;
|
|
398
573
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
childList: true,
|
|
411
|
-
subtree: true,
|
|
412
|
-
});
|
|
413
|
-
}
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
576
|
+
function parseBrowser() {
|
|
577
|
+
var result = { name: Browsers.Unknown, version: '' };
|
|
578
|
+
for (var i = 0; i < BROWSER_RESOLVER_MAP.length; i++) {
|
|
579
|
+
var map = BROWSER_RESOLVER_MAP[i];
|
|
580
|
+
var matched = currentUserAgent.match(map[0]);
|
|
581
|
+
if (matched !== null) {
|
|
582
|
+
result.name = map[1];
|
|
583
|
+
result.version = resolveVersion(matched[1], map[2]);
|
|
584
|
+
break;
|
|
414
585
|
}
|
|
415
586
|
}
|
|
416
|
-
|
|
417
|
-
if (typeof
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (video[PIP_BRIDGED_KEY] === true || !(typeof video.webkitSetPresentationMode !== 'undefined' || typeof video.onwebkitpresentationmodechanged !== 'undefined'))
|
|
422
|
-
return;
|
|
423
|
-
EventListener.add(video, {
|
|
424
|
-
type: 'webkitpresentationmodechanged',
|
|
425
|
-
callback: onWebkitPresentationModeChanged,
|
|
426
|
-
options: false,
|
|
427
|
-
});
|
|
428
|
-
video[PIP_BRIDGED_KEY] = true;
|
|
429
|
-
});
|
|
587
|
+
if (currentUserAgent === USER_AGENT) {
|
|
588
|
+
if (typeof parsedFromHighEntropyValuesBrowser.name !== 'undefined')
|
|
589
|
+
result.name = parsedFromHighEntropyValuesBrowser.name;
|
|
590
|
+
if (typeof parsedFromHighEntropyValuesBrowser.version !== 'undefined')
|
|
591
|
+
result.version = parsedFromHighEntropyValuesBrowser.version;
|
|
430
592
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
593
|
+
return result;
|
|
594
|
+
}
|
|
595
|
+
function parseEngine() {
|
|
596
|
+
var result = { name: Engines.Unknown, version: '' };
|
|
597
|
+
for (var i = 0; i < ENGINE_RESOLVER_MAP.length; i++) {
|
|
598
|
+
var map = ENGINE_RESOLVER_MAP[i];
|
|
599
|
+
var matched = currentUserAgent.match(map[0]);
|
|
600
|
+
if (matched !== null) {
|
|
601
|
+
result.name = map[1];
|
|
602
|
+
result.version = resolveVersion(matched[1], map[2]);
|
|
603
|
+
break;
|
|
442
604
|
}
|
|
443
|
-
bridgeWebkitVideoEvents();
|
|
444
605
|
}
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
606
|
+
if (currentUserAgent === USER_AGENT) {
|
|
607
|
+
if (typeof parsedFromHighEntropyValuesEngine.name !== 'undefined')
|
|
608
|
+
result.name = parsedFromHighEntropyValuesEngine.name;
|
|
609
|
+
if (typeof parsedFromHighEntropyValuesEngine.version !== 'undefined')
|
|
610
|
+
result.version = parsedFromHighEntropyValuesEngine.version;
|
|
611
|
+
}
|
|
612
|
+
return result;
|
|
613
|
+
}
|
|
614
|
+
function parseFromHighEntropyValues() {
|
|
615
|
+
if (typeof globalThis.navigator === 'undefined' || typeof globalThis.navigator.userAgentData === 'undefined' || typeof globalThis.navigator.userAgentData.getHighEntropyValues === 'undefined')
|
|
616
|
+
return Promise.resolve();
|
|
617
|
+
return globalThis.navigator.userAgentData
|
|
618
|
+
.getHighEntropyValues(['brands', 'fullVersionList', 'mobile', 'model', 'platform', 'platformVersion', 'architecture', 'formFactors', 'bitness', 'uaFullVersion', 'wow64'])
|
|
619
|
+
.then(function (result) {
|
|
620
|
+
try {
|
|
621
|
+
var brands = result.fullVersionList || result.brands || [];
|
|
622
|
+
var platformVersion = result.platformVersion;
|
|
623
|
+
var platform = result.platform;
|
|
624
|
+
var browserName = getParsedCache().browser.name;
|
|
625
|
+
var prevBrandName = null;
|
|
626
|
+
for (var i = 0; i < brands.length; i++) {
|
|
627
|
+
var brand = normalizeBrand(brands[i]);
|
|
628
|
+
var brandVersion = brand.version;
|
|
629
|
+
var brandName = brand.brand;
|
|
630
|
+
if (/not.a.brand/i.test(brandName))
|
|
631
|
+
continue;
|
|
632
|
+
if (prevBrandName === null || (/Chrom/.test(prevBrandName) && brandName !== 'Chromium') || (prevBrandName === 'Edge' && /WebView2/.test(brandName))) {
|
|
633
|
+
brandName = HIGH_ENTROPY_BRAND_NAME_MAP[brandName] || brandName;
|
|
634
|
+
prevBrandName = browserName;
|
|
635
|
+
if (prevBrandName === null || /Chrom/.test(prevBrandName) || !/Chrom/.test(brandName)) {
|
|
636
|
+
browserName = brandName;
|
|
637
|
+
if (browserName === 'Chrome' || browserName === 'Chrome WebView' || browserName === 'Chrome Headless')
|
|
638
|
+
parsedFromHighEntropyValuesBrowser.name = Browsers.Chrome;
|
|
639
|
+
else if (browserName === 'Edge' || browserName === 'Edge WebView2')
|
|
640
|
+
parsedFromHighEntropyValuesBrowser.name = Browsers.Edge;
|
|
641
|
+
else if (browserName === 'Opera Mobi')
|
|
642
|
+
parsedFromHighEntropyValuesBrowser.name = Browsers.Opera;
|
|
643
|
+
parsedFromHighEntropyValuesBrowser.version = brandVersion;
|
|
644
|
+
}
|
|
645
|
+
prevBrandName = brandName;
|
|
646
|
+
}
|
|
647
|
+
if (brandName === 'Chromium')
|
|
648
|
+
parsedFromHighEntropyValuesEngine.version = brandVersion;
|
|
454
649
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
delete video[PIP_BRIDGED_KEY];
|
|
650
|
+
if (typeof platformVersion === 'string') {
|
|
651
|
+
if (getParsedCache().os.name === OS.Windows) {
|
|
652
|
+
if (parseInt(platformVersion.split('.')[0], 10) >= 13)
|
|
653
|
+
parsedFromHighEntropyValuesOS.version = '11';
|
|
654
|
+
else
|
|
655
|
+
parsedFromHighEntropyValuesOS.version = '10';
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
parsedFromHighEntropyValuesOS.version = platformVersion;
|
|
659
|
+
}
|
|
466
660
|
}
|
|
467
|
-
|
|
468
|
-
|
|
661
|
+
if (typeof platform === 'string') {
|
|
662
|
+
if (/android/i.test(platform))
|
|
663
|
+
parsedFromHighEntropyValuesOS.name = OS.Android;
|
|
664
|
+
else if (/ios|iphone|ipad/i.test(platform))
|
|
665
|
+
parsedFromHighEntropyValuesOS.name = OS.iOS;
|
|
666
|
+
else if (/windows|win32/i.test(platform))
|
|
667
|
+
parsedFromHighEntropyValuesOS.name = OS.Windows;
|
|
668
|
+
else if (/macos|macintel/i.test(platform))
|
|
669
|
+
parsedFromHighEntropyValuesOS.name = OS.MacOS;
|
|
469
670
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
EventListener.add(globalThis.document, {
|
|
474
|
-
type: 'pictureinpictureerror',
|
|
475
|
-
callback: onErrorSubscriptionManager.emit,
|
|
476
|
-
options: false,
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
function detachOnError() {
|
|
480
|
-
EventListener.remove(globalThis.document, {
|
|
481
|
-
type: 'pictureinpictureerror',
|
|
482
|
-
callback: onErrorSubscriptionManager.emit,
|
|
483
|
-
options: false,
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
function drainPendingOperation() {
|
|
487
|
-
var entry = pendingQueue.shift();
|
|
488
|
-
if (typeof entry === 'undefined') {
|
|
489
|
-
activeOperation = null;
|
|
490
|
-
return;
|
|
671
|
+
if (result.mobile === true)
|
|
672
|
+
parsedFromHighEntropyValuesDevice = Devices.Mobile;
|
|
673
|
+
parsedCache = null;
|
|
491
674
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
675
|
+
catch (_) {
|
|
676
|
+
}
|
|
677
|
+
})
|
|
678
|
+
.catch(function () {
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function parseFromNavigatorGPU() {
|
|
682
|
+
if (typeof globalThis.navigator === 'undefined' || typeof globalThis.navigator.gpu === 'undefined')
|
|
683
|
+
return Promise.resolve();
|
|
684
|
+
return globalThis.navigator.gpu
|
|
685
|
+
.requestAdapter()
|
|
686
|
+
.then(function (adapter) {
|
|
687
|
+
if (adapter !== null) {
|
|
688
|
+
var info = adapter.info;
|
|
689
|
+
info.architecture;
|
|
690
|
+
info.description;
|
|
691
|
+
info.device;
|
|
692
|
+
info.vendor;
|
|
693
|
+
}
|
|
694
|
+
})
|
|
695
|
+
.catch(function () {
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
Promise.all([
|
|
699
|
+
parseFromHighEntropyValues(),
|
|
700
|
+
parseFromNavigatorGPU(),
|
|
701
|
+
]).then(function () {
|
|
702
|
+
});
|
|
703
|
+
EventListener.add(globalThis, {
|
|
704
|
+
type: 'languagechange', callback: function () {
|
|
506
705
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
706
|
+
});
|
|
707
|
+
var Platform = {
|
|
708
|
+
get os() {
|
|
709
|
+
return getParsedCache().os;
|
|
710
|
+
},
|
|
711
|
+
get browser() {
|
|
712
|
+
return getParsedCache().browser;
|
|
713
|
+
}};
|
|
714
|
+
|
|
715
|
+
var PIP_PRESENTATION_MODE = 'picture-in-picture';
|
|
716
|
+
var INLINE_PRESENTATION_MODE = 'inline';
|
|
717
|
+
var videoElement = null;
|
|
718
|
+
var lastFallbackVideoElement = null;
|
|
719
|
+
var eventsBridged = false;
|
|
720
|
+
var PIP_BRIDGE_KEY = (function () {
|
|
721
|
+
if (typeof Symbol === 'function') {
|
|
722
|
+
var existing = globalThis.__nativeFnPipBridgeKey__;
|
|
723
|
+
if (typeof existing === 'symbol')
|
|
724
|
+
return existing;
|
|
725
|
+
return globalThis.__nativeFnPipBridgeKey__ = Symbol('native.fn.pip.bridged');
|
|
524
726
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
return
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
727
|
+
return '__nativeFnPipBridged__';
|
|
728
|
+
}());
|
|
729
|
+
var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
|
|
730
|
+
var onErrorSubscriptionManager = createSubscriptionManager(attachOnError, detachOnError);
|
|
731
|
+
var Pip = {
|
|
732
|
+
get supported() {
|
|
733
|
+
return getSupported();
|
|
734
|
+
},
|
|
735
|
+
get element() {
|
|
736
|
+
return getElement();
|
|
737
|
+
},
|
|
738
|
+
get isActive() {
|
|
739
|
+
return getIsActive();
|
|
740
|
+
},
|
|
741
|
+
request: request,
|
|
742
|
+
exit: exit,
|
|
743
|
+
toggle: toggle,
|
|
744
|
+
onChange: onChange,
|
|
745
|
+
onError: onError,
|
|
746
|
+
Constants: {},
|
|
747
|
+
Errors: {
|
|
748
|
+
NotSupportedError: NotSupportedError,
|
|
749
|
+
InvalidStateError: InvalidStateError,
|
|
750
|
+
},
|
|
751
|
+
};
|
|
752
|
+
function getHTMLVideoElement() {
|
|
753
|
+
var selected = globalThis.document.querySelector('video');
|
|
754
|
+
if (selected !== null)
|
|
755
|
+
return selected;
|
|
756
|
+
if (videoElement === null)
|
|
757
|
+
return videoElement = globalThis.document.createElement('video');
|
|
758
|
+
return videoElement;
|
|
759
|
+
}
|
|
760
|
+
function hasStandardApi() {
|
|
761
|
+
return typeof globalThis.document.pictureInPictureEnabled !== 'undefined';
|
|
762
|
+
}
|
|
763
|
+
function hasWebkitApi() {
|
|
764
|
+
return typeof getHTMLVideoElement().webkitSetPresentationMode === 'function';
|
|
765
|
+
}
|
|
766
|
+
function getDefaultTarget() {
|
|
767
|
+
var video = globalThis.document.querySelector('video');
|
|
768
|
+
if (video !== null)
|
|
769
|
+
return video;
|
|
770
|
+
return undefined;
|
|
771
|
+
}
|
|
772
|
+
function createPipEventPayload(nativeEvent, element, isActive) {
|
|
773
|
+
return {
|
|
774
|
+
nativeEvent: nativeEvent,
|
|
775
|
+
element: element,
|
|
776
|
+
isActive: isActive
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
function emitChange(nativeEvent, element, isActive) {
|
|
780
|
+
onChangeSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
781
|
+
}
|
|
782
|
+
function emitError(nativeEvent, element, isActive) {
|
|
783
|
+
onErrorSubscriptionManager.emit(createPipEventPayload(nativeEvent, element, isActive));
|
|
784
|
+
}
|
|
785
|
+
function onEnterPictureInPicture(event) {
|
|
786
|
+
var target = event.target;
|
|
787
|
+
if (target instanceof globalThis.HTMLVideoElement)
|
|
788
|
+
emitChange(event, target, true);
|
|
789
|
+
}
|
|
790
|
+
function onLeavePictureInPicture(event) {
|
|
791
|
+
var target = event.target;
|
|
792
|
+
if (target instanceof globalThis.HTMLVideoElement)
|
|
793
|
+
emitChange(event, target, false);
|
|
794
|
+
}
|
|
795
|
+
function onPictureInPictureError(event) {
|
|
796
|
+
var target = event.target;
|
|
797
|
+
if (target instanceof globalThis.HTMLVideoElement)
|
|
798
|
+
emitError(event, target, getIsActive());
|
|
799
|
+
}
|
|
800
|
+
function onWebkitPresentationModeChanged(event) {
|
|
801
|
+
if (this.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
802
|
+
lastFallbackVideoElement = this;
|
|
803
|
+
emitChange(event, this, true);
|
|
804
|
+
return;
|
|
542
805
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
806
|
+
if (this.webkitPresentationMode === INLINE_PRESENTATION_MODE && lastFallbackVideoElement === this) {
|
|
807
|
+
lastFallbackVideoElement = null;
|
|
808
|
+
emitChange(event, this, false);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function bridgeSingleVideoNode(video) {
|
|
812
|
+
if (video[PIP_BRIDGE_KEY])
|
|
813
|
+
return;
|
|
814
|
+
if (typeof video.webkitSetPresentationMode === 'undefined' && typeof video.onwebkitpresentationmodechanged === 'undefined')
|
|
815
|
+
return;
|
|
816
|
+
EventListener.add(video, { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
|
|
817
|
+
video[PIP_BRIDGE_KEY] = true;
|
|
818
|
+
}
|
|
819
|
+
function bridgeWebkitVideoEvents() {
|
|
820
|
+
var videos = globalThis.document.querySelectorAll('video');
|
|
821
|
+
for (var i = 0; i < videos.length; i++)
|
|
822
|
+
bridgeSingleVideoNode(videos[i]);
|
|
823
|
+
}
|
|
824
|
+
function bridgeEvents() {
|
|
825
|
+
if (eventsBridged)
|
|
826
|
+
return;
|
|
827
|
+
eventsBridged = true;
|
|
828
|
+
if (hasStandardApi() && !hasWebkitApi())
|
|
829
|
+
return;
|
|
830
|
+
bridgeWebkitVideoEvents();
|
|
831
|
+
if (typeof globalThis.MutationObserver === 'undefined')
|
|
832
|
+
return;
|
|
833
|
+
var observer = new globalThis.MutationObserver(function (records) {
|
|
834
|
+
if (lastFallbackVideoElement !== null) {
|
|
835
|
+
var removed = false;
|
|
836
|
+
for (var i = 0; i < records.length; i++) {
|
|
837
|
+
var removedNodes = records[i].removedNodes;
|
|
838
|
+
for (var j = 0; j < removedNodes.length; j++) {
|
|
839
|
+
var node = removedNodes[j];
|
|
840
|
+
if (node === lastFallbackVideoElement || (node.nodeType === Node.ELEMENT_NODE && node.contains(lastFallbackVideoElement))) {
|
|
841
|
+
removed = true;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
560
844
|
}
|
|
561
|
-
|
|
845
|
+
if (removed)
|
|
846
|
+
break;
|
|
562
847
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
848
|
+
if (removed && !globalThis.document.contains(lastFallbackVideoElement))
|
|
849
|
+
lastFallbackVideoElement = null;
|
|
850
|
+
}
|
|
851
|
+
for (var i = 0; i < records.length; i++) {
|
|
852
|
+
var addedNodes = records[i].addedNodes;
|
|
853
|
+
for (var j = 0; j < addedNodes.length; j++) {
|
|
854
|
+
var node = addedNodes[j];
|
|
855
|
+
if (node.nodeType !== Node.ELEMENT_NODE)
|
|
856
|
+
continue;
|
|
857
|
+
var element = node;
|
|
858
|
+
if (element.tagName === 'VIDEO') {
|
|
859
|
+
bridgeSingleVideoNode(element);
|
|
860
|
+
continue;
|
|
575
861
|
}
|
|
576
|
-
|
|
862
|
+
var nested = element.querySelectorAll('video');
|
|
863
|
+
for (var k = 0; k < nested.length; k++)
|
|
864
|
+
bridgeSingleVideoNode(nested[k]);
|
|
577
865
|
}
|
|
578
|
-
|
|
579
|
-
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
observer.observe(globalThis.document.documentElement, { childList: true, subtree: true });
|
|
869
|
+
}
|
|
870
|
+
function attachOnChange() {
|
|
871
|
+
if (hasStandardApi()) {
|
|
872
|
+
EventListener.add(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
|
|
873
|
+
EventListener.add(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
bridgeWebkitVideoEvents();
|
|
877
|
+
}
|
|
878
|
+
function detachOnChange() {
|
|
879
|
+
if (hasStandardApi()) {
|
|
880
|
+
EventListener.remove(globalThis.document, { type: 'enterpictureinpicture', callback: onEnterPictureInPicture, options: false });
|
|
881
|
+
EventListener.remove(globalThis.document, { type: 'leavepictureinpicture', callback: onLeavePictureInPicture, options: false });
|
|
882
|
+
return;
|
|
580
883
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
884
|
+
var videos = globalThis.document.querySelectorAll('video');
|
|
885
|
+
for (var i = 0; i < videos.length; i++) {
|
|
886
|
+
EventListener.remove(videos[i], { type: 'webkitpresentationmodechanged', callback: onWebkitPresentationModeChanged, options: false });
|
|
887
|
+
videos[i][PIP_BRIDGE_KEY] = false;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function attachOnError() {
|
|
891
|
+
EventListener.add(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
|
|
892
|
+
}
|
|
893
|
+
function detachOnError() {
|
|
894
|
+
EventListener.remove(globalThis.document, { type: 'pictureinpictureerror', callback: onPictureInPictureError, options: false });
|
|
895
|
+
}
|
|
896
|
+
function getSupported() {
|
|
897
|
+
if (typeof globalThis.document.pictureInPictureEnabled === 'boolean')
|
|
898
|
+
return globalThis.document.pictureInPictureEnabled;
|
|
899
|
+
var video = getHTMLVideoElement();
|
|
900
|
+
return typeof video.webkitSupportsPresentationMode === 'function' && video.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE);
|
|
901
|
+
}
|
|
902
|
+
function getElement() {
|
|
903
|
+
var currentElement = globalThis.document.pictureInPictureElement;
|
|
904
|
+
if (currentElement !== null && typeof currentElement !== 'undefined')
|
|
905
|
+
return currentElement;
|
|
906
|
+
if (lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE)
|
|
907
|
+
return lastFallbackVideoElement;
|
|
908
|
+
return null;
|
|
909
|
+
}
|
|
910
|
+
function getIsActive() {
|
|
911
|
+
return getElement() !== null;
|
|
912
|
+
}
|
|
913
|
+
function request(target) {
|
|
914
|
+
return new Promise(function (resolve, reject) {
|
|
915
|
+
if (typeof target === 'undefined')
|
|
916
|
+
target = getDefaultTarget();
|
|
917
|
+
if (typeof target === 'undefined')
|
|
918
|
+
return reject(new NotSupportedError('Failed to enter Picture-in-Picture mode.'));
|
|
919
|
+
if (getIsActive() && getElement() !== target && Platform.browser.name === Browsers.Safari && Platform.os.name === OS.iOS)
|
|
920
|
+
return reject(new NotSupportedError('There is already a Picture-in-Picture element in this document.'));
|
|
921
|
+
var tagName = target.tagName.toLowerCase();
|
|
922
|
+
if (tagName !== 'video')
|
|
923
|
+
return reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
924
|
+
var method = target.requestPictureInPicture;
|
|
925
|
+
var isWebkitPipActive = lastFallbackVideoElement !== null && lastFallbackVideoElement.webkitPresentationMode === PIP_PRESENTATION_MODE;
|
|
926
|
+
if (typeof method === 'function' && !hasWebkitApi() && !isWebkitPipActive) {
|
|
927
|
+
var result = method.call(target);
|
|
928
|
+
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
929
|
+
result
|
|
930
|
+
.then(resolve)
|
|
931
|
+
.catch(function () {
|
|
932
|
+
try {
|
|
933
|
+
fallbackToWebkit();
|
|
934
|
+
}
|
|
935
|
+
catch (e) {
|
|
936
|
+
reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
return resolve();
|
|
942
|
+
}
|
|
943
|
+
function fallbackToWebkit() {
|
|
944
|
+
if (typeof target !== 'undefined' && typeof target.webkitSupportsPresentationMode === 'function' && target.webkitSupportsPresentationMode(PIP_PRESENTATION_MODE) && typeof target.webkitSetPresentationMode === 'function') {
|
|
945
|
+
if (target.disablePictureInPicture)
|
|
946
|
+
return reject(new NotSupportedError('Picture-in-Picture is disabled on this element.'));
|
|
947
|
+
bridgeSingleVideoNode(target);
|
|
948
|
+
target.webkitSetPresentationMode(PIP_PRESENTATION_MODE);
|
|
584
949
|
return resolve();
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
950
|
+
}
|
|
951
|
+
reject(new NotSupportedError('The "' + tagName + '" element does not support Picture-in-Picture requests.'));
|
|
952
|
+
}
|
|
953
|
+
fallbackToWebkit();
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
function exit() {
|
|
957
|
+
return new Promise(function (resolve, reject) {
|
|
958
|
+
var method = globalThis.document.exitPictureInPicture;
|
|
959
|
+
if (typeof method === 'function' && !hasWebkitApi()) {
|
|
960
|
+
var result = method.call(globalThis.document);
|
|
961
|
+
if (typeof result !== 'undefined' && typeof result.then === 'function') {
|
|
962
|
+
result
|
|
963
|
+
.then(resolve)
|
|
964
|
+
.catch(function () {
|
|
965
|
+
try {
|
|
966
|
+
fallbackToWebkit();
|
|
597
967
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
968
|
+
catch (e) {
|
|
969
|
+
reject(new NotSupportedError('Failed to exit Picture-in-Picture mode.'));
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
return;
|
|
602
973
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
.then(resolve)
|
|
609
|
-
.catch(function () {
|
|
610
|
-
fallbackToWebkitVideo();
|
|
611
|
-
});
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
974
|
+
return resolve();
|
|
975
|
+
}
|
|
976
|
+
function fallbackToWebkit() {
|
|
977
|
+
if (lastFallbackVideoElement !== null && typeof lastFallbackVideoElement.webkitSetPresentationMode === 'function') {
|
|
978
|
+
lastFallbackVideoElement.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
614
979
|
return resolve();
|
|
615
980
|
}
|
|
616
|
-
|
|
617
|
-
|
|
981
|
+
var videos = globalThis.document.querySelectorAll('video');
|
|
982
|
+
for (var i = 0; i < videos.length; i++) {
|
|
983
|
+
var video = videos[i];
|
|
984
|
+
if (typeof video.webkitSetPresentationMode === 'function' && video.webkitPresentationMode === PIP_PRESENTATION_MODE) {
|
|
985
|
+
video.webkitSetPresentationMode(INLINE_PRESENTATION_MODE);
|
|
986
|
+
return resolve();
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return resolve();
|
|
990
|
+
}
|
|
991
|
+
fallbackToWebkit();
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function toggle(target) {
|
|
995
|
+
var current = getElement();
|
|
996
|
+
if (typeof target !== 'undefined') {
|
|
997
|
+
if (current === target)
|
|
998
|
+
return this.exit();
|
|
999
|
+
else
|
|
1000
|
+
return this.request(target);
|
|
1001
|
+
}
|
|
1002
|
+
if (current !== null)
|
|
1003
|
+
return this.exit();
|
|
1004
|
+
else
|
|
1005
|
+
return this.request(target);
|
|
1006
|
+
}
|
|
1007
|
+
function onChange(targetOrListener, listenerOrOptions, options) {
|
|
1008
|
+
if (typeof targetOrListener === 'function')
|
|
1009
|
+
return onChangeSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
|
|
1010
|
+
var target = targetOrListener;
|
|
1011
|
+
var listener = listenerOrOptions;
|
|
1012
|
+
function wrappedListener(payload) {
|
|
1013
|
+
if (payload.element === target)
|
|
1014
|
+
listener(payload);
|
|
618
1015
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
1016
|
+
return onChangeSubscriptionManager.subscribe(wrappedListener, options);
|
|
1017
|
+
}
|
|
1018
|
+
function onError(targetOrListener, listenerOrOptions, options) {
|
|
1019
|
+
if (typeof targetOrListener === 'function')
|
|
1020
|
+
return onErrorSubscriptionManager.subscribe(targetOrListener, listenerOrOptions);
|
|
1021
|
+
var target = targetOrListener;
|
|
1022
|
+
var listener = listenerOrOptions;
|
|
1023
|
+
function wrappedListener(payload) {
|
|
1024
|
+
if (payload.element === target)
|
|
1025
|
+
listener(payload);
|
|
623
1026
|
}
|
|
624
|
-
|
|
625
|
-
return {
|
|
626
|
-
get supported() {
|
|
627
|
-
return getEnabled();
|
|
628
|
-
},
|
|
629
|
-
get element() {
|
|
630
|
-
return getElement();
|
|
631
|
-
},
|
|
632
|
-
get isPip() {
|
|
633
|
-
return getIsPip();
|
|
634
|
-
},
|
|
635
|
-
request: request,
|
|
636
|
-
exit: exit,
|
|
637
|
-
toggle: toggle,
|
|
638
|
-
onChange: onChangeSubscriptionManager.subscribe,
|
|
639
|
-
onError: onErrorSubscriptionManager.subscribe,
|
|
640
|
-
Constants: {},
|
|
641
|
-
Errors: {
|
|
642
|
-
NotSupportedError: NotSupportedError,
|
|
643
|
-
},
|
|
644
|
-
};
|
|
1027
|
+
return onErrorSubscriptionManager.subscribe(wrappedListener, options);
|
|
645
1028
|
}
|
|
646
|
-
|
|
1029
|
+
bridgeEvents();
|
|
647
1030
|
|
|
648
1031
|
module.exports = Pip;
|