mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
get api libs from bower
This commit is contained in:
parent
def418714f
commit
f36e664503
97 changed files with 16860 additions and 197 deletions
43
dashboard-ui/bower_components/hls.js/src/utils/binary-search.js
vendored
Normal file
43
dashboard-ui/bower_components/hls.js/src/utils/binary-search.js
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
var BinarySearch = {
|
||||
/**
|
||||
* Searches for an item in an array which matches a certain condition.
|
||||
* This requires the condition to only match one item in the array,
|
||||
* and for the array to be ordered.
|
||||
*
|
||||
* @param {Array} list The array to search.
|
||||
* @param {Function} comparisonFunction
|
||||
* Called and provided a candidate item as the first argument.
|
||||
* Should return:
|
||||
* > -1 if the item should be located at a lower index than the provided item.
|
||||
* > 1 if the item should be located at a higher index than the provided item.
|
||||
* > 0 if the item is the item you're looking for.
|
||||
*
|
||||
* @return {*} The object if it is found or null otherwise.
|
||||
*/
|
||||
search: function(list, comparisonFunction) {
|
||||
var minIndex = 0;
|
||||
var maxIndex = list.length - 1;
|
||||
var currentIndex = null;
|
||||
var currentElement = null;
|
||||
|
||||
while (minIndex <= maxIndex) {
|
||||
currentIndex = (minIndex + maxIndex) / 2 | 0;
|
||||
currentElement = list[currentIndex];
|
||||
|
||||
var comparisonResult = comparisonFunction(currentElement);
|
||||
if (comparisonResult > 0) {
|
||||
minIndex = currentIndex + 1;
|
||||
}
|
||||
else if (comparisonResult < 0) {
|
||||
maxIndex = currentIndex - 1;
|
||||
}
|
||||
else {
|
||||
return currentElement;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = BinarySearch;
|
16
dashboard-ui/bower_components/hls.js/src/utils/hex.js
vendored
Normal file
16
dashboard-ui/bower_components/hls.js/src/utils/hex.js
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
class Hex {
|
||||
|
||||
static hexDump(array) {
|
||||
var i, str = '';
|
||||
for(i = 0; i < array.length; i++) {
|
||||
var h = array[i].toString(16);
|
||||
if (h.length < 2) {
|
||||
h = '0' + h;
|
||||
}
|
||||
str += h;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
export default Hex;
|
73
dashboard-ui/bower_components/hls.js/src/utils/logger.js
vendored
Normal file
73
dashboard-ui/bower_components/hls.js/src/utils/logger.js
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
function noop() {}
|
||||
|
||||
const fakeLogger = {
|
||||
trace: noop,
|
||||
debug: noop,
|
||||
log: noop,
|
||||
warn: noop,
|
||||
info: noop,
|
||||
error: noop
|
||||
};
|
||||
|
||||
let exportedLogger = fakeLogger;
|
||||
|
||||
//let lastCallTime;
|
||||
// function formatMsgWithTimeInfo(type, msg) {
|
||||
// const now = Date.now();
|
||||
// const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';
|
||||
// lastCallTime = now;
|
||||
// msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';
|
||||
// return msg;
|
||||
// }
|
||||
|
||||
function formatMsg(type, msg) {
|
||||
msg = '[' + type + '] > ' + msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
function consolePrintFn(type) {
|
||||
const func = window.console[type];
|
||||
if (func) {
|
||||
return function(...args) {
|
||||
if(args[0]) {
|
||||
args[0] = formatMsg(type, args[0]);
|
||||
}
|
||||
func.apply(window.console, args);
|
||||
};
|
||||
}
|
||||
return noop;
|
||||
}
|
||||
|
||||
function exportLoggerFunctions(debugConfig, ...functions) {
|
||||
functions.forEach(function(type) {
|
||||
exportedLogger[type] = debugConfig[type] ? debugConfig[type].bind(debugConfig) : consolePrintFn(type);
|
||||
});
|
||||
}
|
||||
|
||||
export var enableLogs = function(debugConfig) {
|
||||
if (debugConfig === true || typeof debugConfig === 'object') {
|
||||
exportLoggerFunctions(debugConfig,
|
||||
// Remove out from list here to hard-disable a log-level
|
||||
//'trace',
|
||||
'debug',
|
||||
'log',
|
||||
'info',
|
||||
'warn',
|
||||
'error'
|
||||
);
|
||||
// Some browsers don't allow to use bind on console object anyway
|
||||
// fallback to default if needed
|
||||
try {
|
||||
exportedLogger.log();
|
||||
} catch (e) {
|
||||
exportedLogger = fakeLogger;
|
||||
}
|
||||
}
|
||||
else {
|
||||
exportedLogger = fakeLogger;
|
||||
}
|
||||
};
|
||||
|
||||
export var logger = exportedLogger;
|
77
dashboard-ui/bower_components/hls.js/src/utils/url.js
vendored
Normal file
77
dashboard-ui/bower_components/hls.js/src/utils/url.js
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
var URLHelper = {
|
||||
|
||||
// build an absolute URL from a relative one using the provided baseURL
|
||||
// if relativeURL is an absolute URL it will be returned as is.
|
||||
buildAbsoluteURL: function(baseURL, relativeURL) {
|
||||
// remove any remaining space and CRLF
|
||||
relativeURL = relativeURL.trim();
|
||||
if (/^[a-z]+:/i.test(relativeURL)) {
|
||||
// complete url, not relative
|
||||
return relativeURL;
|
||||
}
|
||||
|
||||
var relativeURLQuery = null;
|
||||
var relativeURLHash = null;
|
||||
|
||||
var relativeURLHashSplit = /^([^#]*)(.*)$/.exec(relativeURL);
|
||||
if (relativeURLHashSplit) {
|
||||
relativeURLHash = relativeURLHashSplit[2];
|
||||
relativeURL = relativeURLHashSplit[1];
|
||||
}
|
||||
var relativeURLQuerySplit = /^([^\?]*)(.*)$/.exec(relativeURL);
|
||||
if (relativeURLQuerySplit) {
|
||||
relativeURLQuery = relativeURLQuerySplit[2];
|
||||
relativeURL = relativeURLQuerySplit[1];
|
||||
}
|
||||
|
||||
var baseURLHashSplit = /^([^#]*)(.*)$/.exec(baseURL);
|
||||
if (baseURLHashSplit) {
|
||||
baseURL = baseURLHashSplit[1];
|
||||
}
|
||||
var baseURLQuerySplit = /^([^\?]*)(.*)$/.exec(baseURL);
|
||||
if (baseURLQuerySplit) {
|
||||
baseURL = baseURLQuerySplit[1];
|
||||
}
|
||||
|
||||
var baseURLDomainSplit = /^((([a-z]+):)?\/\/[a-z0-9\.-]+(:[0-9]+)?\/)(.*)$/i.exec(baseURL);
|
||||
var baseURLProtocol = baseURLDomainSplit[3];
|
||||
var baseURLDomain = baseURLDomainSplit[1];
|
||||
var baseURLPath = baseURLDomainSplit[5];
|
||||
|
||||
var builtURL = null;
|
||||
if (/^\/\//.test(relativeURL)) {
|
||||
builtURL = baseURLProtocol+'://'+URLHelper.buildAbsolutePath('', relativeURL.substring(2));
|
||||
}
|
||||
else if (/^\//.test(relativeURL)) {
|
||||
builtURL = baseURLDomain+URLHelper.buildAbsolutePath('', relativeURL.substring(1));
|
||||
}
|
||||
else {
|
||||
var newPath = URLHelper.buildAbsolutePath(baseURLPath, relativeURL);
|
||||
builtURL = baseURLDomain + newPath;
|
||||
}
|
||||
|
||||
// put the query and hash parts back
|
||||
if (relativeURLQuery) {
|
||||
builtURL += relativeURLQuery;
|
||||
}
|
||||
if (relativeURLHash) {
|
||||
builtURL += relativeURLHash;
|
||||
}
|
||||
return builtURL;
|
||||
},
|
||||
|
||||
// build an absolute path using the provided basePath
|
||||
// adapted from https://developer.mozilla.org/en-US/docs/Web/API/document/cookie#Using_relative_URLs_in_the_path_parameter
|
||||
// this does not handle the case where relativePath is "/" or "//". These cases should be handled outside this.
|
||||
buildAbsolutePath: function(basePath, relativePath) {
|
||||
var sRelPath = relativePath;
|
||||
var nUpLn, sDir = '', sPath = basePath.replace(/[^\/]*$/, sRelPath.replace(/(\/|^)(?:\.?\/+)+/g, '$1'));
|
||||
for (var nEnd, nStart = 0; nEnd = sPath.indexOf('/../', nStart), nEnd > -1; nStart = nEnd + nUpLn) {
|
||||
nUpLn = /^\/(?:\.\.\/)*/.exec(sPath.slice(nEnd))[0].length;
|
||||
sDir = (sDir + sPath.substring(nStart, nEnd)).replace(new RegExp('(?:\\\/+[^\\\/]*){0,' + ((nUpLn - 1) / 3) + '}$'), '/');
|
||||
}
|
||||
return sDir + sPath.substr(nStart);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = URLHelper;
|
104
dashboard-ui/bower_components/hls.js/src/utils/xhr-loader.js
vendored
Normal file
104
dashboard-ui/bower_components/hls.js/src/utils/xhr-loader.js
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* XHR based logger
|
||||
*/
|
||||
|
||||
import {logger} from '../utils/logger';
|
||||
|
||||
class XhrLoader {
|
||||
|
||||
constructor(config) {
|
||||
if (config && config.xhrSetup) {
|
||||
this.xhrSetup = config.xhrSetup;
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.abort();
|
||||
this.loader = null;
|
||||
}
|
||||
|
||||
abort() {
|
||||
if (this.loader && this.loader.readyState !== 4) {
|
||||
this.stats.aborted = true;
|
||||
this.loader.abort();
|
||||
}
|
||||
if (this.timeoutHandle) {
|
||||
window.clearTimeout(this.timeoutHandle);
|
||||
}
|
||||
}
|
||||
|
||||
load(url, responseType, onSuccess, onError, onTimeout, timeout, maxRetry, retryDelay, onProgress = null, frag = null) {
|
||||
this.url = url;
|
||||
if (frag && !isNaN(frag.byteRangeStartOffset) && !isNaN(frag.byteRangeEndOffset)) {
|
||||
this.byteRange = frag.byteRangeStartOffset + '-' + frag.byteRangeEndOffset;
|
||||
}
|
||||
this.responseType = responseType;
|
||||
this.onSuccess = onSuccess;
|
||||
this.onProgress = onProgress;
|
||||
this.onTimeout = onTimeout;
|
||||
this.onError = onError;
|
||||
this.stats = {trequest: performance.now(), retry: 0};
|
||||
this.timeout = timeout;
|
||||
this.maxRetry = maxRetry;
|
||||
this.retryDelay = retryDelay;
|
||||
this.timeoutHandle = window.setTimeout(this.loadtimeout.bind(this), timeout);
|
||||
this.loadInternal();
|
||||
}
|
||||
|
||||
loadInternal() {
|
||||
var xhr = this.loader = new XMLHttpRequest();
|
||||
xhr.onload = this.loadsuccess.bind(this);
|
||||
xhr.onerror = this.loaderror.bind(this);
|
||||
xhr.onprogress = this.loadprogress.bind(this);
|
||||
xhr.open('GET', this.url, true);
|
||||
if (this.byteRange) {
|
||||
xhr.setRequestHeader('Range', 'bytes=' + this.byteRange);
|
||||
}
|
||||
xhr.responseType = this.responseType;
|
||||
this.stats.tfirst = null;
|
||||
this.stats.loaded = 0;
|
||||
if (this.xhrSetup) {
|
||||
this.xhrSetup(xhr, this.url);
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
loadsuccess(event) {
|
||||
window.clearTimeout(this.timeoutHandle);
|
||||
this.stats.tload = performance.now();
|
||||
this.onSuccess(event, this.stats);
|
||||
}
|
||||
|
||||
loaderror(event) {
|
||||
if (this.stats.retry < this.maxRetry) {
|
||||
logger.warn(`${event.type} while loading ${this.url}, retrying in ${this.retryDelay}...`);
|
||||
this.destroy();
|
||||
window.setTimeout(this.loadInternal.bind(this), this.retryDelay);
|
||||
// exponential backoff
|
||||
this.retryDelay = Math.min(2 * this.retryDelay, 64000);
|
||||
this.stats.retry++;
|
||||
} else {
|
||||
window.clearTimeout(this.timeoutHandle);
|
||||
logger.error(`${event.type} while loading ${this.url}` );
|
||||
this.onError(event);
|
||||
}
|
||||
}
|
||||
|
||||
loadtimeout(event) {
|
||||
logger.warn(`timeout while loading ${this.url}` );
|
||||
this.onTimeout(event, this.stats);
|
||||
}
|
||||
|
||||
loadprogress(event) {
|
||||
var stats = this.stats;
|
||||
if (stats.tfirst === null) {
|
||||
stats.tfirst = performance.now();
|
||||
}
|
||||
stats.loaded = event.loaded;
|
||||
if (this.onProgress) {
|
||||
this.onProgress(event, stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default XhrLoader;
|
Loading…
Add table
Add a link
Reference in a new issue