@kkcompany/player 2.25.0-canary.0 → 2.25.0-canary.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/CHANGELOG.md +5 -14
- package/dist/core.mjs +22 -20
- package/dist/index.js +2085 -2379
- package/dist/index.mjs +105 -392
- package/dist/modules.mjs +29 -38
- package/dist/plugins.mjs +4 -3
- package/dist/react.mjs +172 -434
- package/package.json +2 -1
package/dist/modules.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
1
2
|
import mitt from 'mitt';
|
|
2
3
|
import UAParser from 'ua-parser-js';
|
|
3
4
|
|
|
4
5
|
/* eslint-disable no-param-reassign */
|
|
6
|
+
|
|
5
7
|
const waitMs$1 = time => new Promise(resolve => {
|
|
6
8
|
setTimeout(resolve, time);
|
|
7
9
|
});
|
|
8
10
|
|
|
9
|
-
const handleRequestError = (
|
|
11
|
+
const handleRequestError = (result, {
|
|
10
12
|
onError,
|
|
11
13
|
retryTimes = 0
|
|
12
|
-
}) =>
|
|
13
|
-
retry: () => handleRequestError(
|
|
14
|
+
}) => result.catch(error => onError(error, {
|
|
15
|
+
retry: () => handleRequestError(axios(error.config), {
|
|
14
16
|
onError,
|
|
15
17
|
retryTimes: retryTimes + 1
|
|
16
18
|
}),
|
|
@@ -65,26 +67,28 @@ const createApi = (config, {
|
|
|
65
67
|
|
|
66
68
|
const request = (url, {
|
|
67
69
|
method
|
|
68
|
-
} = {}) => handleRequestError((
|
|
70
|
+
} = {}) => handleRequestError(axios(url, {
|
|
69
71
|
method,
|
|
70
|
-
headers: getHeaders()
|
|
71
|
-
|
|
72
|
+
headers: getHeaders(),
|
|
73
|
+
params
|
|
74
|
+
}), {
|
|
72
75
|
onError
|
|
73
|
-
});
|
|
76
|
+
}).then(response => response.data);
|
|
74
77
|
|
|
75
78
|
const sessionRequest = (path, {
|
|
76
79
|
method = 'POST',
|
|
77
80
|
type,
|
|
78
81
|
id,
|
|
79
82
|
token
|
|
80
|
-
}) => handleRequestError((
|
|
81
|
-
playback_token: token
|
|
82
|
-
}).toString()}`, {
|
|
83
|
+
}) => handleRequestError(axios(`${host}/sessions/${type}/${id}/playback/${deviceId}/${path}`, {
|
|
83
84
|
method,
|
|
84
|
-
headers: getHeaders()
|
|
85
|
-
|
|
85
|
+
headers: getHeaders(),
|
|
86
|
+
params: { ...params,
|
|
87
|
+
playback_token: token
|
|
88
|
+
}
|
|
89
|
+
}), {
|
|
86
90
|
onError
|
|
87
|
-
});
|
|
91
|
+
}).then(response => response === null || response === void 0 ? void 0 : response.data);
|
|
88
92
|
|
|
89
93
|
return {
|
|
90
94
|
config,
|
|
@@ -265,15 +269,15 @@ function getDevice() {
|
|
|
265
269
|
function getBrowser() {
|
|
266
270
|
return parser.getBrowser();
|
|
267
271
|
}
|
|
272
|
+
|
|
273
|
+
const isSafari = () => /^((?!chrome|android|X11|Linux).)*(safari|iPad|iPhone|Version)/i.test(navigator.userAgent);
|
|
274
|
+
|
|
268
275
|
function needNativeHls() {
|
|
269
276
|
// Don't let Android phones play HLS, even if some of them report supported
|
|
270
277
|
// This covers Samsung & OPPO special cases
|
|
271
|
-
const isAndroid = /android|X11|Linux/i.test(navigator.userAgent);
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// none of our supported browsers other than Safari response to this
|
|
275
|
-
|
|
276
|
-
return isAndroid || /firefox/i.test(navigator.userAgent) ? '' : isSafari ? 'maybe' : document.createElement('video').canPlayType('application/vnd.apple.mpegURL');
|
|
278
|
+
const isAndroid = /android|X11|Linux/i.test(navigator.userAgent);
|
|
279
|
+
return isAndroid || /firefox/i.test(navigator.userAgent) ? '' : // canPlayType isn't reliable across all iOS verion / device combinations, so also check user agent
|
|
280
|
+
isSafari() ? 'maybe' : document.createElement('video').canPlayType('application/vnd.apple.mpegURL');
|
|
277
281
|
}
|
|
278
282
|
|
|
279
283
|
const isDesktop = () => !getDevice().type; // TODO solve lint error:
|
|
@@ -443,7 +447,7 @@ const getDrmOptions = fallbackDrm => {
|
|
|
443
447
|
* @typedef {{hls: string, dash: string}} SourceObjectAlt backward compatiable form
|
|
444
448
|
*
|
|
445
449
|
* @param {SourceObject[]|SourceObject|SourceObjectAlt|string} sourceOptions
|
|
446
|
-
* @param {{preferManifestType?: ('dash'|'hls')}} options
|
|
450
|
+
* @param {{preferManifestType?: ('dash'|'hls'|'platform')}} options
|
|
447
451
|
* @return {{src: string, type: string, drm: Object}}
|
|
448
452
|
*/
|
|
449
453
|
|
|
@@ -486,7 +490,8 @@ const getSource = (sourceOptions, {
|
|
|
486
490
|
});
|
|
487
491
|
}
|
|
488
492
|
|
|
489
|
-
const
|
|
493
|
+
const targetType = preferManifestType !== 'platform' ? preferManifestType : isSafari() ? 'hls' : 'dash';
|
|
494
|
+
const matched = sourceOptions.find(source => matchType(source, targetType));
|
|
490
495
|
const selected = matched || sourceOptions[0];
|
|
491
496
|
|
|
492
497
|
if (!selected) {
|
|
@@ -504,14 +509,12 @@ const getSource = (sourceOptions, {
|
|
|
504
509
|
function getVersion() {
|
|
505
510
|
try {
|
|
506
511
|
// eslint-disable-next-line no-undef
|
|
507
|
-
return "2.25.0-canary.
|
|
512
|
+
return "2.25.0-canary.1";
|
|
508
513
|
} catch (e) {
|
|
509
514
|
return undefined;
|
|
510
515
|
}
|
|
511
516
|
}
|
|
512
517
|
|
|
513
|
-
/* eslint-disable no-param-reassign */
|
|
514
|
-
|
|
515
518
|
const matchAll = (input, pattern) => {
|
|
516
519
|
const flags = [pattern.global && 'g', pattern.ignoreCase && 'i', pattern.multiline && 'm'].filter(Boolean).join('');
|
|
517
520
|
const clone = new RegExp(pattern, flags);
|
|
@@ -1391,12 +1394,6 @@ const retrieveModuleConfig = (modulesConfig, query) => {
|
|
|
1391
1394
|
|
|
1392
1395
|
/* eslint-disable camelcase */
|
|
1393
1396
|
const HEARTBEAT_INTERVAL_MS = 10000;
|
|
1394
|
-
//@ts-ignore
|
|
1395
|
-
const axios$1 = {
|
|
1396
|
-
post: (...args) => {
|
|
1397
|
-
console.log(args);
|
|
1398
|
-
}
|
|
1399
|
-
}; // TODO
|
|
1400
1397
|
|
|
1401
1398
|
const eventHeartbeat = ({
|
|
1402
1399
|
token,
|
|
@@ -1429,7 +1426,7 @@ const eventHeartbeat = ({
|
|
|
1429
1426
|
}; // Avoid template literals because the env variable would be replaced in the rollup
|
|
1430
1427
|
|
|
1431
1428
|
await retryWithBackoff$1({
|
|
1432
|
-
fn: () => axios
|
|
1429
|
+
fn: () => axios.post(endpoint, payload, {
|
|
1433
1430
|
headers: {
|
|
1434
1431
|
'Kks-Bv-Token': token
|
|
1435
1432
|
}
|
|
@@ -1442,12 +1439,6 @@ var eventHeartbeat$1 = eventHeartbeat;
|
|
|
1442
1439
|
|
|
1443
1440
|
/* eslint-disable camelcase */
|
|
1444
1441
|
|
|
1445
|
-
const axios = {
|
|
1446
|
-
post: (...args) => {
|
|
1447
|
-
console.log(args);
|
|
1448
|
-
}
|
|
1449
|
-
}; // TODO
|
|
1450
|
-
|
|
1451
1442
|
const getDeviceInfo = () => {
|
|
1452
1443
|
const browser = getBrowser();
|
|
1453
1444
|
return {
|
|
@@ -1502,7 +1493,7 @@ const createAnalytics = ({
|
|
|
1502
1493
|
const logTarget = mapLogEvents({
|
|
1503
1494
|
video,
|
|
1504
1495
|
playerName: 'shaka',
|
|
1505
|
-
version: "2.25.0-canary.
|
|
1496
|
+
version: "2.25.0-canary.1"
|
|
1506
1497
|
});
|
|
1507
1498
|
logTarget.all((type, data) => {
|
|
1508
1499
|
const payload = {
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import mitt from 'mitt';
|
|
2
|
+
import axios from 'axios';
|
|
2
3
|
import UAParser from 'ua-parser-js';
|
|
3
4
|
|
|
4
5
|
/** @param {string} m3u8Manifest */
|
|
@@ -486,13 +487,13 @@ const snapback = ({
|
|
|
486
487
|
}
|
|
487
488
|
};
|
|
488
489
|
|
|
489
|
-
const axios = () => {};
|
|
490
|
-
|
|
491
490
|
const addFetchPolyfill = () => {
|
|
492
491
|
window.fetch = async (url, {
|
|
493
492
|
method
|
|
494
493
|
} = {}) => {
|
|
495
|
-
const result = await axios(
|
|
494
|
+
const result = await axios(url, {
|
|
495
|
+
method
|
|
496
|
+
});
|
|
496
497
|
return Promise.resolve({
|
|
497
498
|
json: () => result.data
|
|
498
499
|
});
|