188 lines
6.2 KiB
JavaScript
Executable File
188 lines
6.2 KiB
JavaScript
Executable File
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
// file that has been converted to a CommonJS file using a Babel-
|
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
mod
|
|
));
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
var utils_exports = {};
|
|
__export(utils_exports, {
|
|
callPlayer: () => callPlayer,
|
|
getConfig: () => getConfig,
|
|
getSDK: () => getSDK,
|
|
isBlobUrl: () => isBlobUrl,
|
|
isMediaStream: () => isMediaStream,
|
|
lazy: () => lazy,
|
|
omit: () => omit,
|
|
parseEndTime: () => parseEndTime,
|
|
parseStartTime: () => parseStartTime,
|
|
queryString: () => queryString,
|
|
randomString: () => randomString,
|
|
supportsWebKitPresentationMode: () => supportsWebKitPresentationMode
|
|
});
|
|
module.exports = __toCommonJS(utils_exports);
|
|
var import_react = __toESM(require("react"));
|
|
var import_load_script = __toESM(require("load-script"));
|
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
const lazy = (componentImportFn) => import_react.default.lazy(async () => {
|
|
const obj = await componentImportFn();
|
|
return typeof obj.default === "function" ? obj : obj.default;
|
|
});
|
|
const MATCH_START_QUERY = /[?&#](?:start|t)=([0-9hms]+)/;
|
|
const MATCH_END_QUERY = /[?&#]end=([0-9hms]+)/;
|
|
const MATCH_START_STAMP = /(\d+)(h|m|s)/g;
|
|
const MATCH_NUMERIC = /^\d+$/;
|
|
function parseTimeParam(url, pattern) {
|
|
if (url instanceof Array) {
|
|
return void 0;
|
|
}
|
|
const match = url.match(pattern);
|
|
if (match) {
|
|
const stamp = match[1];
|
|
if (stamp.match(MATCH_START_STAMP)) {
|
|
return parseTimeString(stamp);
|
|
}
|
|
if (MATCH_NUMERIC.test(stamp)) {
|
|
return parseInt(stamp);
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
function parseTimeString(stamp) {
|
|
let seconds = 0;
|
|
let array = MATCH_START_STAMP.exec(stamp);
|
|
while (array !== null) {
|
|
const [, count, period] = array;
|
|
if (period === "h")
|
|
seconds += parseInt(count, 10) * 60 * 60;
|
|
if (period === "m")
|
|
seconds += parseInt(count, 10) * 60;
|
|
if (period === "s")
|
|
seconds += parseInt(count, 10);
|
|
array = MATCH_START_STAMP.exec(stamp);
|
|
}
|
|
return seconds;
|
|
}
|
|
function parseStartTime(url) {
|
|
return parseTimeParam(url, MATCH_START_QUERY);
|
|
}
|
|
function parseEndTime(url) {
|
|
return parseTimeParam(url, MATCH_END_QUERY);
|
|
}
|
|
function randomString() {
|
|
return Math.random().toString(36).substr(2, 5);
|
|
}
|
|
function queryString(object) {
|
|
return Object.keys(object).map((key) => `${key}=${object[key]}`).join("&");
|
|
}
|
|
function getGlobal(key) {
|
|
if (window[key]) {
|
|
return window[key];
|
|
}
|
|
if (window.exports && window.exports[key]) {
|
|
return window.exports[key];
|
|
}
|
|
if (window.module && window.module.exports && window.module.exports[key]) {
|
|
return window.module.exports[key];
|
|
}
|
|
return null;
|
|
}
|
|
const requests = {};
|
|
const getSDK = enableStubOn(function getSDK2(url, sdkGlobal, sdkReady = null, isLoaded = () => true, fetchScript = import_load_script.default) {
|
|
const existingGlobal = getGlobal(sdkGlobal);
|
|
if (existingGlobal && isLoaded(existingGlobal)) {
|
|
return Promise.resolve(existingGlobal);
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
if (requests[url]) {
|
|
requests[url].push({ resolve, reject });
|
|
return;
|
|
}
|
|
requests[url] = [{ resolve, reject }];
|
|
const onLoaded = (sdk) => {
|
|
requests[url].forEach((request) => request.resolve(sdk));
|
|
};
|
|
if (sdkReady) {
|
|
const previousOnReady = window[sdkReady];
|
|
window[sdkReady] = function() {
|
|
if (previousOnReady)
|
|
previousOnReady();
|
|
onLoaded(getGlobal(sdkGlobal));
|
|
};
|
|
}
|
|
fetchScript(url, (err) => {
|
|
if (err) {
|
|
requests[url].forEach((request) => request.reject(err));
|
|
requests[url] = null;
|
|
} else if (!sdkReady) {
|
|
onLoaded(getGlobal(sdkGlobal));
|
|
}
|
|
});
|
|
});
|
|
});
|
|
function getConfig(props, defaultProps) {
|
|
return (0, import_deepmerge.default)(defaultProps.config, props.config);
|
|
}
|
|
function omit(object, ...arrays) {
|
|
const omitKeys = [].concat(...arrays);
|
|
const output = {};
|
|
const keys = Object.keys(object);
|
|
for (const key of keys) {
|
|
if (omitKeys.indexOf(key) === -1) {
|
|
output[key] = object[key];
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
function callPlayer(method, ...args) {
|
|
if (!this.player || !this.player[method]) {
|
|
let message = `ReactPlayer: ${this.constructor.displayName} player could not call %c${method}%c \u2013 `;
|
|
if (!this.player) {
|
|
message += "The player was not available";
|
|
} else if (!this.player[method]) {
|
|
message += "The method was not available";
|
|
}
|
|
console.warn(message, "font-weight: bold", "");
|
|
return null;
|
|
}
|
|
return this.player[method](...args);
|
|
}
|
|
function isMediaStream(url) {
|
|
return typeof window !== "undefined" && typeof window.MediaStream !== "undefined" && url instanceof window.MediaStream;
|
|
}
|
|
function isBlobUrl(url) {
|
|
return /^blob:/.test(url);
|
|
}
|
|
function supportsWebKitPresentationMode(video = document.createElement("video")) {
|
|
const notMobile = /iPhone|iPod/.test(navigator.userAgent) === false;
|
|
return video.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === "function" && notMobile;
|
|
}
|
|
function enableStubOn(fn) {
|
|
if (false) {
|
|
const wrap = (...args) => wrap.stub(...args);
|
|
wrap.stub = fn;
|
|
return wrap;
|
|
}
|
|
return fn;
|
|
}
|