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