1653 lines
69 KiB
JavaScript
1653 lines
69 KiB
JavaScript
import {
|
||
__commonJS
|
||
} from "./chunk-P2LSHJDD.js";
|
||
|
||
// E:/语聊项目/秘地/fanyin-h5/node_modules/video-animation-player/dist/vap.js
|
||
var require_vap = __commonJS({
|
||
"E:/语聊项目/秘地/fanyin-h5/node_modules/video-animation-player/dist/vap.js"(exports, module) {
|
||
(function(global, factory) {
|
||
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Vap = {}));
|
||
})(exports, function(exports2) {
|
||
"use strict";
|
||
function _arrayLikeToArray(arr, len) {
|
||
if (len == null || len > arr.length)
|
||
len = arr.length;
|
||
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
||
arr2[i] = arr[i];
|
||
}
|
||
return arr2;
|
||
}
|
||
var arrayLikeToArray = _arrayLikeToArray;
|
||
function _arrayWithoutHoles(arr) {
|
||
if (Array.isArray(arr))
|
||
return arrayLikeToArray(arr);
|
||
}
|
||
var arrayWithoutHoles = _arrayWithoutHoles;
|
||
function _iterableToArray(iter) {
|
||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter))
|
||
return Array.from(iter);
|
||
}
|
||
var iterableToArray = _iterableToArray;
|
||
function _unsupportedIterableToArray(o, minLen) {
|
||
if (!o)
|
||
return;
|
||
if (typeof o === "string")
|
||
return arrayLikeToArray(o, minLen);
|
||
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||
if (n === "Object" && o.constructor)
|
||
n = o.constructor.name;
|
||
if (n === "Map" || n === "Set")
|
||
return Array.from(o);
|
||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
||
return arrayLikeToArray(o, minLen);
|
||
}
|
||
var unsupportedIterableToArray = _unsupportedIterableToArray;
|
||
function _nonIterableSpread() {
|
||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||
}
|
||
var nonIterableSpread = _nonIterableSpread;
|
||
function _toConsumableArray(arr) {
|
||
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
|
||
}
|
||
var toConsumableArray = _toConsumableArray;
|
||
function _arrayWithHoles(arr) {
|
||
if (Array.isArray(arr))
|
||
return arr;
|
||
}
|
||
var arrayWithHoles = _arrayWithHoles;
|
||
function _iterableToArrayLimit(arr, i) {
|
||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr)))
|
||
return;
|
||
var _arr = [];
|
||
var _n = true;
|
||
var _d = false;
|
||
var _e = void 0;
|
||
try {
|
||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||
_arr.push(_s.value);
|
||
if (i && _arr.length === i)
|
||
break;
|
||
}
|
||
} catch (err) {
|
||
_d = true;
|
||
_e = err;
|
||
} finally {
|
||
try {
|
||
if (!_n && _i["return"] != null)
|
||
_i["return"]();
|
||
} finally {
|
||
if (_d)
|
||
throw _e;
|
||
}
|
||
}
|
||
return _arr;
|
||
}
|
||
var iterableToArrayLimit = _iterableToArrayLimit;
|
||
function _nonIterableRest() {
|
||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||
}
|
||
var nonIterableRest = _nonIterableRest;
|
||
function _slicedToArray(arr, i) {
|
||
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
|
||
}
|
||
var slicedToArray = _slicedToArray;
|
||
function _classCallCheck(instance, Constructor) {
|
||
if (!(instance instanceof Constructor)) {
|
||
throw new TypeError("Cannot call a class as a function");
|
||
}
|
||
}
|
||
var classCallCheck = _classCallCheck;
|
||
function _defineProperties(target, props) {
|
||
for (var i = 0; i < props.length; i++) {
|
||
var descriptor = props[i];
|
||
descriptor.enumerable = descriptor.enumerable || false;
|
||
descriptor.configurable = true;
|
||
if ("value" in descriptor)
|
||
descriptor.writable = true;
|
||
Object.defineProperty(target, descriptor.key, descriptor);
|
||
}
|
||
}
|
||
function _createClass(Constructor, protoProps, staticProps) {
|
||
if (protoProps)
|
||
_defineProperties(Constructor.prototype, protoProps);
|
||
if (staticProps)
|
||
_defineProperties(Constructor, staticProps);
|
||
return Constructor;
|
||
}
|
||
var createClass = _createClass;
|
||
function createCommonjsModule(fn, module2) {
|
||
return module2 = { exports: {} }, fn(module2, module2.exports), module2.exports;
|
||
}
|
||
var getPrototypeOf = createCommonjsModule(function(module2) {
|
||
function _getPrototypeOf(o) {
|
||
module2.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
||
return o2.__proto__ || Object.getPrototypeOf(o2);
|
||
};
|
||
return _getPrototypeOf(o);
|
||
}
|
||
module2.exports = _getPrototypeOf;
|
||
});
|
||
function _superPropBase(object, property) {
|
||
while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
||
object = getPrototypeOf(object);
|
||
if (object === null)
|
||
break;
|
||
}
|
||
return object;
|
||
}
|
||
var superPropBase = _superPropBase;
|
||
var get = createCommonjsModule(function(module2) {
|
||
function _get(target, property, receiver) {
|
||
if (typeof Reflect !== "undefined" && Reflect.get) {
|
||
module2.exports = _get = Reflect.get;
|
||
} else {
|
||
module2.exports = _get = function _get2(target2, property2, receiver2) {
|
||
var base = superPropBase(target2, property2);
|
||
if (!base)
|
||
return;
|
||
var desc = Object.getOwnPropertyDescriptor(base, property2);
|
||
if (desc.get) {
|
||
return desc.get.call(receiver2);
|
||
}
|
||
return desc.value;
|
||
};
|
||
}
|
||
return _get(target, property, receiver || target);
|
||
}
|
||
module2.exports = _get;
|
||
});
|
||
var setPrototypeOf = createCommonjsModule(function(module2) {
|
||
function _setPrototypeOf(o, p) {
|
||
module2.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
||
o2.__proto__ = p2;
|
||
return o2;
|
||
};
|
||
return _setPrototypeOf(o, p);
|
||
}
|
||
module2.exports = _setPrototypeOf;
|
||
});
|
||
function _inherits(subClass, superClass) {
|
||
if (typeof superClass !== "function" && superClass !== null) {
|
||
throw new TypeError("Super expression must either be null or a function");
|
||
}
|
||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||
constructor: {
|
||
value: subClass,
|
||
writable: true,
|
||
configurable: true
|
||
}
|
||
});
|
||
if (superClass)
|
||
setPrototypeOf(subClass, superClass);
|
||
}
|
||
var inherits = _inherits;
|
||
var _typeof_1 = createCommonjsModule(function(module2) {
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||
module2.exports = _typeof = function _typeof2(obj2) {
|
||
return typeof obj2;
|
||
};
|
||
} else {
|
||
module2.exports = _typeof = function _typeof2(obj2) {
|
||
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
||
};
|
||
}
|
||
return _typeof(obj);
|
||
}
|
||
module2.exports = _typeof;
|
||
});
|
||
function _assertThisInitialized(self2) {
|
||
if (self2 === void 0) {
|
||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
}
|
||
return self2;
|
||
}
|
||
var assertThisInitialized = _assertThisInitialized;
|
||
function _possibleConstructorReturn(self2, call) {
|
||
if (call && (_typeof_1(call) === "object" || typeof call === "function")) {
|
||
return call;
|
||
}
|
||
return assertThisInitialized(self2);
|
||
}
|
||
var possibleConstructorReturn = _possibleConstructorReturn;
|
||
var getPrototypeOf$1 = createCommonjsModule(function(module2) {
|
||
function _getPrototypeOf(o) {
|
||
module2.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
|
||
return o2.__proto__ || Object.getPrototypeOf(o2);
|
||
};
|
||
return _getPrototypeOf(o);
|
||
}
|
||
module2.exports = _getPrototypeOf;
|
||
});
|
||
var _typeof_1$1 = createCommonjsModule(function(module2) {
|
||
function _typeof(obj) {
|
||
"@babel/helpers - typeof";
|
||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||
module2.exports = _typeof = function _typeof2(obj2) {
|
||
return typeof obj2;
|
||
};
|
||
} else {
|
||
module2.exports = _typeof = function _typeof2(obj2) {
|
||
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
||
};
|
||
}
|
||
return _typeof(obj);
|
||
}
|
||
module2.exports = _typeof;
|
||
});
|
||
var runtime_1 = createCommonjsModule(function(module2) {
|
||
var runtime = function(exports3) {
|
||
var Op = Object.prototype;
|
||
var hasOwn = Op.hasOwnProperty;
|
||
var undefined$1;
|
||
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
||
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
||
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
||
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
||
function define2(obj, key, value) {
|
||
Object.defineProperty(obj, key, {
|
||
value,
|
||
enumerable: true,
|
||
configurable: true,
|
||
writable: true
|
||
});
|
||
return obj[key];
|
||
}
|
||
try {
|
||
define2({}, "");
|
||
} catch (err) {
|
||
define2 = function(obj, key, value) {
|
||
return obj[key] = value;
|
||
};
|
||
}
|
||
function wrap(innerFn, outerFn, self2, tryLocsList) {
|
||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
||
var generator = Object.create(protoGenerator.prototype);
|
||
var context = new Context(tryLocsList || []);
|
||
generator._invoke = makeInvokeMethod(innerFn, self2, context);
|
||
return generator;
|
||
}
|
||
exports3.wrap = wrap;
|
||
function tryCatch(fn, obj, arg) {
|
||
try {
|
||
return { type: "normal", arg: fn.call(obj, arg) };
|
||
} catch (err) {
|
||
return { type: "throw", arg: err };
|
||
}
|
||
}
|
||
var GenStateSuspendedStart = "suspendedStart";
|
||
var GenStateSuspendedYield = "suspendedYield";
|
||
var GenStateExecuting = "executing";
|
||
var GenStateCompleted = "completed";
|
||
var ContinueSentinel = {};
|
||
function Generator() {
|
||
}
|
||
function GeneratorFunction() {
|
||
}
|
||
function GeneratorFunctionPrototype() {
|
||
}
|
||
var IteratorPrototype = {};
|
||
IteratorPrototype[iteratorSymbol] = function() {
|
||
return this;
|
||
};
|
||
var getProto = Object.getPrototypeOf;
|
||
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
||
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
||
IteratorPrototype = NativeIteratorPrototype;
|
||
}
|
||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
||
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
||
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
||
GeneratorFunction.displayName = define2(
|
||
GeneratorFunctionPrototype,
|
||
toStringTagSymbol,
|
||
"GeneratorFunction"
|
||
);
|
||
function defineIteratorMethods(prototype) {
|
||
["next", "throw", "return"].forEach(function(method) {
|
||
define2(prototype, method, function(arg) {
|
||
return this._invoke(method, arg);
|
||
});
|
||
});
|
||
}
|
||
exports3.isGeneratorFunction = function(genFun) {
|
||
var ctor = typeof genFun === "function" && genFun.constructor;
|
||
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
||
// do is to check its .name property.
|
||
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
||
};
|
||
exports3.mark = function(genFun) {
|
||
if (Object.setPrototypeOf) {
|
||
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
||
} else {
|
||
genFun.__proto__ = GeneratorFunctionPrototype;
|
||
define2(genFun, toStringTagSymbol, "GeneratorFunction");
|
||
}
|
||
genFun.prototype = Object.create(Gp);
|
||
return genFun;
|
||
};
|
||
exports3.awrap = function(arg) {
|
||
return { __await: arg };
|
||
};
|
||
function AsyncIterator(generator, PromiseImpl) {
|
||
function invoke(method, arg, resolve, reject) {
|
||
var record = tryCatch(generator[method], generator, arg);
|
||
if (record.type === "throw") {
|
||
reject(record.arg);
|
||
} else {
|
||
var result = record.arg;
|
||
var value = result.value;
|
||
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
||
return PromiseImpl.resolve(value.__await).then(function(value2) {
|
||
invoke("next", value2, resolve, reject);
|
||
}, function(err) {
|
||
invoke("throw", err, resolve, reject);
|
||
});
|
||
}
|
||
return PromiseImpl.resolve(value).then(function(unwrapped) {
|
||
result.value = unwrapped;
|
||
resolve(result);
|
||
}, function(error) {
|
||
return invoke("throw", error, resolve, reject);
|
||
});
|
||
}
|
||
}
|
||
var previousPromise;
|
||
function enqueue(method, arg) {
|
||
function callInvokeWithMethodAndArg() {
|
||
return new PromiseImpl(function(resolve, reject) {
|
||
invoke(method, arg, resolve, reject);
|
||
});
|
||
}
|
||
return previousPromise = // If enqueue has been called before, then we want to wait until
|
||
// all previous Promises have been resolved before calling invoke,
|
||
// so that results are always delivered in the correct order. If
|
||
// enqueue has not been called before, then it is important to
|
||
// call invoke immediately, without waiting on a callback to fire,
|
||
// so that the async generator function has the opportunity to do
|
||
// any necessary setup in a predictable way. This predictability
|
||
// is why the Promise constructor synchronously invokes its
|
||
// executor callback, and why async functions synchronously
|
||
// execute code before the first await. Since we implement simple
|
||
// async functions in terms of async generators, it is especially
|
||
// important to get this right, even though it requires care.
|
||
previousPromise ? previousPromise.then(
|
||
callInvokeWithMethodAndArg,
|
||
// Avoid propagating failures to Promises returned by later
|
||
// invocations of the iterator.
|
||
callInvokeWithMethodAndArg
|
||
) : callInvokeWithMethodAndArg();
|
||
}
|
||
this._invoke = enqueue;
|
||
}
|
||
defineIteratorMethods(AsyncIterator.prototype);
|
||
AsyncIterator.prototype[asyncIteratorSymbol] = function() {
|
||
return this;
|
||
};
|
||
exports3.AsyncIterator = AsyncIterator;
|
||
exports3.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
|
||
if (PromiseImpl === void 0)
|
||
PromiseImpl = Promise;
|
||
var iter = new AsyncIterator(
|
||
wrap(innerFn, outerFn, self2, tryLocsList),
|
||
PromiseImpl
|
||
);
|
||
return exports3.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
|
||
return result.done ? result.value : iter.next();
|
||
});
|
||
};
|
||
function makeInvokeMethod(innerFn, self2, context) {
|
||
var state = GenStateSuspendedStart;
|
||
return function invoke(method, arg) {
|
||
if (state === GenStateExecuting) {
|
||
throw new Error("Generator is already running");
|
||
}
|
||
if (state === GenStateCompleted) {
|
||
if (method === "throw") {
|
||
throw arg;
|
||
}
|
||
return doneResult();
|
||
}
|
||
context.method = method;
|
||
context.arg = arg;
|
||
while (true) {
|
||
var delegate = context.delegate;
|
||
if (delegate) {
|
||
var delegateResult = maybeInvokeDelegate(delegate, context);
|
||
if (delegateResult) {
|
||
if (delegateResult === ContinueSentinel)
|
||
continue;
|
||
return delegateResult;
|
||
}
|
||
}
|
||
if (context.method === "next") {
|
||
context.sent = context._sent = context.arg;
|
||
} else if (context.method === "throw") {
|
||
if (state === GenStateSuspendedStart) {
|
||
state = GenStateCompleted;
|
||
throw context.arg;
|
||
}
|
||
context.dispatchException(context.arg);
|
||
} else if (context.method === "return") {
|
||
context.abrupt("return", context.arg);
|
||
}
|
||
state = GenStateExecuting;
|
||
var record = tryCatch(innerFn, self2, context);
|
||
if (record.type === "normal") {
|
||
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
||
if (record.arg === ContinueSentinel) {
|
||
continue;
|
||
}
|
||
return {
|
||
value: record.arg,
|
||
done: context.done
|
||
};
|
||
} else if (record.type === "throw") {
|
||
state = GenStateCompleted;
|
||
context.method = "throw";
|
||
context.arg = record.arg;
|
||
}
|
||
}
|
||
};
|
||
}
|
||
function maybeInvokeDelegate(delegate, context) {
|
||
var method = delegate.iterator[context.method];
|
||
if (method === undefined$1) {
|
||
context.delegate = null;
|
||
if (context.method === "throw") {
|
||
if (delegate.iterator["return"]) {
|
||
context.method = "return";
|
||
context.arg = undefined$1;
|
||
maybeInvokeDelegate(delegate, context);
|
||
if (context.method === "throw") {
|
||
return ContinueSentinel;
|
||
}
|
||
}
|
||
context.method = "throw";
|
||
context.arg = new TypeError(
|
||
"The iterator does not provide a 'throw' method"
|
||
);
|
||
}
|
||
return ContinueSentinel;
|
||
}
|
||
var record = tryCatch(method, delegate.iterator, context.arg);
|
||
if (record.type === "throw") {
|
||
context.method = "throw";
|
||
context.arg = record.arg;
|
||
context.delegate = null;
|
||
return ContinueSentinel;
|
||
}
|
||
var info = record.arg;
|
||
if (!info) {
|
||
context.method = "throw";
|
||
context.arg = new TypeError("iterator result is not an object");
|
||
context.delegate = null;
|
||
return ContinueSentinel;
|
||
}
|
||
if (info.done) {
|
||
context[delegate.resultName] = info.value;
|
||
context.next = delegate.nextLoc;
|
||
if (context.method !== "return") {
|
||
context.method = "next";
|
||
context.arg = undefined$1;
|
||
}
|
||
} else {
|
||
return info;
|
||
}
|
||
context.delegate = null;
|
||
return ContinueSentinel;
|
||
}
|
||
defineIteratorMethods(Gp);
|
||
define2(Gp, toStringTagSymbol, "Generator");
|
||
Gp[iteratorSymbol] = function() {
|
||
return this;
|
||
};
|
||
Gp.toString = function() {
|
||
return "[object Generator]";
|
||
};
|
||
function pushTryEntry(locs) {
|
||
var entry = { tryLoc: locs[0] };
|
||
if (1 in locs) {
|
||
entry.catchLoc = locs[1];
|
||
}
|
||
if (2 in locs) {
|
||
entry.finallyLoc = locs[2];
|
||
entry.afterLoc = locs[3];
|
||
}
|
||
this.tryEntries.push(entry);
|
||
}
|
||
function resetTryEntry(entry) {
|
||
var record = entry.completion || {};
|
||
record.type = "normal";
|
||
delete record.arg;
|
||
entry.completion = record;
|
||
}
|
||
function Context(tryLocsList) {
|
||
this.tryEntries = [{ tryLoc: "root" }];
|
||
tryLocsList.forEach(pushTryEntry, this);
|
||
this.reset(true);
|
||
}
|
||
exports3.keys = function(object) {
|
||
var keys = [];
|
||
for (var key in object) {
|
||
keys.push(key);
|
||
}
|
||
keys.reverse();
|
||
return function next() {
|
||
while (keys.length) {
|
||
var key2 = keys.pop();
|
||
if (key2 in object) {
|
||
next.value = key2;
|
||
next.done = false;
|
||
return next;
|
||
}
|
||
}
|
||
next.done = true;
|
||
return next;
|
||
};
|
||
};
|
||
function values(iterable) {
|
||
if (iterable) {
|
||
var iteratorMethod = iterable[iteratorSymbol];
|
||
if (iteratorMethod) {
|
||
return iteratorMethod.call(iterable);
|
||
}
|
||
if (typeof iterable.next === "function") {
|
||
return iterable;
|
||
}
|
||
if (!isNaN(iterable.length)) {
|
||
var i = -1, next = function next2() {
|
||
while (++i < iterable.length) {
|
||
if (hasOwn.call(iterable, i)) {
|
||
next2.value = iterable[i];
|
||
next2.done = false;
|
||
return next2;
|
||
}
|
||
}
|
||
next2.value = undefined$1;
|
||
next2.done = true;
|
||
return next2;
|
||
};
|
||
return next.next = next;
|
||
}
|
||
}
|
||
return { next: doneResult };
|
||
}
|
||
exports3.values = values;
|
||
function doneResult() {
|
||
return { value: undefined$1, done: true };
|
||
}
|
||
Context.prototype = {
|
||
constructor: Context,
|
||
reset: function(skipTempReset) {
|
||
this.prev = 0;
|
||
this.next = 0;
|
||
this.sent = this._sent = undefined$1;
|
||
this.done = false;
|
||
this.delegate = null;
|
||
this.method = "next";
|
||
this.arg = undefined$1;
|
||
this.tryEntries.forEach(resetTryEntry);
|
||
if (!skipTempReset) {
|
||
for (var name in this) {
|
||
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
||
this[name] = undefined$1;
|
||
}
|
||
}
|
||
}
|
||
},
|
||
stop: function() {
|
||
this.done = true;
|
||
var rootEntry = this.tryEntries[0];
|
||
var rootRecord = rootEntry.completion;
|
||
if (rootRecord.type === "throw") {
|
||
throw rootRecord.arg;
|
||
}
|
||
return this.rval;
|
||
},
|
||
dispatchException: function(exception) {
|
||
if (this.done) {
|
||
throw exception;
|
||
}
|
||
var context = this;
|
||
function handle(loc, caught) {
|
||
record.type = "throw";
|
||
record.arg = exception;
|
||
context.next = loc;
|
||
if (caught) {
|
||
context.method = "next";
|
||
context.arg = undefined$1;
|
||
}
|
||
return !!caught;
|
||
}
|
||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||
var entry = this.tryEntries[i];
|
||
var record = entry.completion;
|
||
if (entry.tryLoc === "root") {
|
||
return handle("end");
|
||
}
|
||
if (entry.tryLoc <= this.prev) {
|
||
var hasCatch = hasOwn.call(entry, "catchLoc");
|
||
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
||
if (hasCatch && hasFinally) {
|
||
if (this.prev < entry.catchLoc) {
|
||
return handle(entry.catchLoc, true);
|
||
} else if (this.prev < entry.finallyLoc) {
|
||
return handle(entry.finallyLoc);
|
||
}
|
||
} else if (hasCatch) {
|
||
if (this.prev < entry.catchLoc) {
|
||
return handle(entry.catchLoc, true);
|
||
}
|
||
} else if (hasFinally) {
|
||
if (this.prev < entry.finallyLoc) {
|
||
return handle(entry.finallyLoc);
|
||
}
|
||
} else {
|
||
throw new Error("try statement without catch or finally");
|
||
}
|
||
}
|
||
}
|
||
},
|
||
abrupt: function(type, arg) {
|
||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||
var entry = this.tryEntries[i];
|
||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
||
var finallyEntry = entry;
|
||
break;
|
||
}
|
||
}
|
||
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
||
finallyEntry = null;
|
||
}
|
||
var record = finallyEntry ? finallyEntry.completion : {};
|
||
record.type = type;
|
||
record.arg = arg;
|
||
if (finallyEntry) {
|
||
this.method = "next";
|
||
this.next = finallyEntry.finallyLoc;
|
||
return ContinueSentinel;
|
||
}
|
||
return this.complete(record);
|
||
},
|
||
complete: function(record, afterLoc) {
|
||
if (record.type === "throw") {
|
||
throw record.arg;
|
||
}
|
||
if (record.type === "break" || record.type === "continue") {
|
||
this.next = record.arg;
|
||
} else if (record.type === "return") {
|
||
this.rval = this.arg = record.arg;
|
||
this.method = "return";
|
||
this.next = "end";
|
||
} else if (record.type === "normal" && afterLoc) {
|
||
this.next = afterLoc;
|
||
}
|
||
return ContinueSentinel;
|
||
},
|
||
finish: function(finallyLoc) {
|
||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||
var entry = this.tryEntries[i];
|
||
if (entry.finallyLoc === finallyLoc) {
|
||
this.complete(entry.completion, entry.afterLoc);
|
||
resetTryEntry(entry);
|
||
return ContinueSentinel;
|
||
}
|
||
}
|
||
},
|
||
"catch": function(tryLoc) {
|
||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||
var entry = this.tryEntries[i];
|
||
if (entry.tryLoc === tryLoc) {
|
||
var record = entry.completion;
|
||
if (record.type === "throw") {
|
||
var thrown = record.arg;
|
||
resetTryEntry(entry);
|
||
}
|
||
return thrown;
|
||
}
|
||
}
|
||
throw new Error("illegal catch attempt");
|
||
},
|
||
delegateYield: function(iterable, resultName, nextLoc) {
|
||
this.delegate = {
|
||
iterator: values(iterable),
|
||
resultName,
|
||
nextLoc
|
||
};
|
||
if (this.method === "next") {
|
||
this.arg = undefined$1;
|
||
}
|
||
return ContinueSentinel;
|
||
}
|
||
};
|
||
return exports3;
|
||
}(
|
||
// If this script is executing as a CommonJS module, use module.exports
|
||
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
||
// object. Either way, the resulting object will be used to initialize
|
||
// the regeneratorRuntime variable at the top of this file.
|
||
module2.exports
|
||
);
|
||
try {
|
||
regeneratorRuntime = runtime;
|
||
} catch (accidentalStrictMode) {
|
||
Function("r", "regeneratorRuntime = r")(runtime);
|
||
}
|
||
});
|
||
var D__project_vapSource_web_node_modules__babel_runtime_regenerator = runtime_1;
|
||
function __awaiter(thisArg, _arguments, P, generator) {
|
||
function adopt(value) {
|
||
return value instanceof P ? value : new P(function(resolve) {
|
||
resolve(value);
|
||
});
|
||
}
|
||
return new (P || (P = Promise))(function(resolve, reject) {
|
||
function fulfilled(value) {
|
||
try {
|
||
step(generator.next(value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
}
|
||
function rejected(value) {
|
||
try {
|
||
step(generator["throw"](value));
|
||
} catch (e) {
|
||
reject(e);
|
||
}
|
||
}
|
||
function step(result) {
|
||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
||
}
|
||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
});
|
||
}
|
||
var FrameParser = function() {
|
||
function FrameParser2(source, headData) {
|
||
classCallCheck(this, FrameParser2);
|
||
this.config = source || {};
|
||
this.headData = headData;
|
||
this.frame = [];
|
||
this.textureMap = {};
|
||
}
|
||
createClass(FrameParser2, [{
|
||
key: "init",
|
||
value: function init() {
|
||
return __awaiter(this, void 0, void 0, D__project_vapSource_web_node_modules__babel_runtime_regenerator.mark(function _callee() {
|
||
return D__project_vapSource_web_node_modules__babel_runtime_regenerator.wrap(function _callee$(_context) {
|
||
while (1) {
|
||
switch (_context.prev = _context.next) {
|
||
case 0:
|
||
if (!/\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]\.json/.test(this.config)) {
|
||
_context.next = 4;
|
||
break;
|
||
}
|
||
_context.next = 3;
|
||
return this.getConfigBySrc(this.config);
|
||
case 3:
|
||
this.config = _context.sent;
|
||
case 4:
|
||
_context.next = 6;
|
||
return this.parseSrc(this.config);
|
||
case 6:
|
||
this.frame = this.config.frame || [];
|
||
return _context.abrupt("return", this);
|
||
case 8:
|
||
case "end":
|
||
return _context.stop();
|
||
}
|
||
}
|
||
}, _callee, this);
|
||
}));
|
||
}
|
||
}, {
|
||
key: "initCanvas",
|
||
value: function initCanvas() {
|
||
if (!this.canvas) {
|
||
var canvas = document.createElement("canvas");
|
||
var ctx = canvas.getContext("2d");
|
||
canvas.style.display = "none";
|
||
document.body.appendChild(canvas);
|
||
this.ctx = ctx;
|
||
this.canvas = canvas;
|
||
}
|
||
}
|
||
}, {
|
||
key: "loadImg",
|
||
value: function loadImg(url) {
|
||
return new Promise(function(resolve, reject) {
|
||
var img = new Image();
|
||
img.crossOrigin = "anonymous";
|
||
img.onload = function() {
|
||
resolve(this);
|
||
};
|
||
img.onerror = function(e) {
|
||
console.error("frame 资源加载失败:" + url);
|
||
reject(new Error("frame 资源加载失败:" + url));
|
||
};
|
||
img.src = url;
|
||
});
|
||
}
|
||
}, {
|
||
key: "parseSrc",
|
||
value: function parseSrc(dataJson) {
|
||
var _this = this;
|
||
var src = this.srcData = {};
|
||
return Promise.all((dataJson.src || []).map(function(item) {
|
||
return __awaiter(_this, void 0, void 0, D__project_vapSource_web_node_modules__babel_runtime_regenerator.mark(function _callee2() {
|
||
var _this2 = this;
|
||
return D__project_vapSource_web_node_modules__babel_runtime_regenerator.wrap(function _callee2$(_context2) {
|
||
while (1) {
|
||
switch (_context2.prev = _context2.next) {
|
||
case 0:
|
||
item.img = null;
|
||
if (!(!this.headData[item.srcTag.slice(1, item.srcTag.length - 1)] && !this.headData[item.srcTag])) {
|
||
_context2.next = 5;
|
||
break;
|
||
}
|
||
console.warn("vap: 融合信息没有传入:".concat(item.srcTag));
|
||
_context2.next = 23;
|
||
break;
|
||
case 5:
|
||
if (!(item.srcType === "txt")) {
|
||
_context2.next = 12;
|
||
break;
|
||
}
|
||
if (this.headData["fontStyle"] && !item["fontStyle"]) {
|
||
item["fontStyle"] = this.headData["fontStyle"];
|
||
}
|
||
item.textStr = this.headData[item.srcTag] || item.srcTag.replace(/\[(.*)\]/, function($0, $1) {
|
||
return _this2.headData[$1];
|
||
});
|
||
this.initCanvas();
|
||
item.img = this.makeTextImg(item);
|
||
_context2.next = 22;
|
||
break;
|
||
case 12:
|
||
if (!(item.srcType === "img")) {
|
||
_context2.next = 22;
|
||
break;
|
||
}
|
||
item.imgUrl = this.headData[item.srcTag] || item.srcTag.replace(/\[(.*)\]/, function($0, $1) {
|
||
return _this2.headData[$1];
|
||
});
|
||
_context2.prev = 14;
|
||
_context2.next = 17;
|
||
return this.loadImg(item.imgUrl);
|
||
case 17:
|
||
item.img = _context2.sent;
|
||
_context2.next = 22;
|
||
break;
|
||
case 20:
|
||
_context2.prev = 20;
|
||
_context2.t0 = _context2["catch"](14);
|
||
case 22:
|
||
if (item.img) {
|
||
src[item.srcId] = item;
|
||
}
|
||
case 23:
|
||
case "end":
|
||
return _context2.stop();
|
||
}
|
||
}
|
||
}, _callee2, this, [[14, 20]]);
|
||
}));
|
||
})).then(function() {
|
||
if (_this.canvas) {
|
||
_this.canvas.parentNode.removeChild(_this.canvas);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* 下载json文件
|
||
* @param jsonUrl json外链
|
||
* @returns {Promise}
|
||
*/
|
||
}, {
|
||
key: "getConfigBySrc",
|
||
value: function getConfigBySrc(jsonUrl) {
|
||
return new Promise(function(resolve, reject) {
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open("GET", jsonUrl, true);
|
||
xhr.responseType = "json";
|
||
xhr.onload = function() {
|
||
if (xhr.status === 200 || xhr.status === 304 && xhr.response) {
|
||
var res = xhr.response;
|
||
resolve(res);
|
||
} else {
|
||
reject(new Error("http response invalid" + xhr.status));
|
||
}
|
||
};
|
||
xhr.send();
|
||
});
|
||
}
|
||
/**
|
||
* 文字转换图片
|
||
* @param item
|
||
*/
|
||
}, {
|
||
key: "makeTextImg",
|
||
value: function makeTextImg(item) {
|
||
var textStr = item.textStr, w = item.w, h = item.h, color = item.color, style = item.style, fontStyle = item.fontStyle;
|
||
var ctx = this.ctx;
|
||
ctx.canvas.width = w;
|
||
ctx.canvas.height = h;
|
||
ctx.textBaseline = "middle";
|
||
ctx.textAlign = "center";
|
||
var getFontStyle = function getFontStyle2() {
|
||
var fontSize = Math.min(w / textStr.length, h - 8);
|
||
var font = ["".concat(fontSize, "px"), "Arial"];
|
||
if (style === "b") {
|
||
font.unshift("bold");
|
||
}
|
||
return font.join(" ");
|
||
};
|
||
if (!fontStyle) {
|
||
ctx.font = getFontStyle();
|
||
ctx.fillStyle = color;
|
||
} else if (typeof fontStyle == "string") {
|
||
ctx.font = fontStyle;
|
||
ctx.fillStyle = color;
|
||
} else if (_typeof_1$1(fontStyle) == "object") {
|
||
ctx.font = fontStyle["font"] || getFontStyle();
|
||
ctx.fillStyle = fontStyle["color"] || color;
|
||
} else if (typeof fontStyle == "function") {
|
||
ctx.font = getFontStyle();
|
||
ctx.fillStyle = color;
|
||
fontStyle.call(null, ctx, item);
|
||
}
|
||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||
ctx.fillText(textStr, w / 2, h / 2);
|
||
return ctx.getImageData(0, 0, w, h);
|
||
}
|
||
}, {
|
||
key: "getFrame",
|
||
value: function getFrame(frame) {
|
||
return this.frame.find(function(item) {
|
||
return item.i === frame;
|
||
});
|
||
}
|
||
}]);
|
||
return FrameParser2;
|
||
}();
|
||
function createShader(gl, type, source) {
|
||
var shader = gl.createShader(type);
|
||
gl.shaderSource(shader, source);
|
||
gl.compileShader(shader);
|
||
return shader;
|
||
}
|
||
function createProgram(gl, vertexShader, fragmentShader) {
|
||
var program = gl.createProgram();
|
||
gl.attachShader(program, vertexShader);
|
||
gl.attachShader(program, fragmentShader);
|
||
gl.linkProgram(program);
|
||
gl.useProgram(program);
|
||
return program;
|
||
}
|
||
function createTexture(gl, index2, imgData) {
|
||
var texture = gl.createTexture();
|
||
var textrueIndex = gl.TEXTURE0 + index2;
|
||
gl.activeTexture(textrueIndex);
|
||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||
if (imgData) {
|
||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imgData);
|
||
}
|
||
return texture;
|
||
}
|
||
function cleanWebGL(gl, _ref) {
|
||
var _ref$shaders = _ref.shaders, shaders = _ref$shaders === void 0 ? [] : _ref$shaders, _ref$program = _ref.program, program = _ref$program === void 0 ? null : _ref$program, _ref$textures = _ref.textures, textures = _ref$textures === void 0 ? [] : _ref$textures, _ref$buffers = _ref.buffers, buffers = _ref$buffers === void 0 ? [] : _ref$buffers;
|
||
try {
|
||
textures.forEach(function(t) {
|
||
gl.deleteTexture(t);
|
||
});
|
||
buffers.forEach(function(b) {
|
||
gl.deleteBuffer(b);
|
||
});
|
||
if (program) {
|
||
shaders.forEach(function(shader) {
|
||
gl.detachShader(program, shader);
|
||
gl.deleteShader(shader);
|
||
});
|
||
gl.deleteProgram(program);
|
||
}
|
||
} catch (e) {
|
||
}
|
||
}
|
||
var VapVideo = function() {
|
||
function VapVideo2() {
|
||
classCallCheck(this, VapVideo2);
|
||
this.events = {};
|
||
this.firstPlaying = true;
|
||
this.customEvent = ["frame", "percentage", ""];
|
||
}
|
||
createClass(VapVideo2, [{
|
||
key: "setOptions",
|
||
value: function setOptions(options) {
|
||
if (!options.container || !options.src) {
|
||
console.warn("[Alpha video]: options container and src cannot be empty!");
|
||
}
|
||
this.options = Object.assign({
|
||
// 视频url
|
||
src: "",
|
||
// 循环播放
|
||
loop: false,
|
||
fps: 20,
|
||
// 容器
|
||
container: null,
|
||
// 是否预加载视频资源
|
||
precache: false,
|
||
// 是否静音播放
|
||
mute: false,
|
||
config: "",
|
||
accurate: false,
|
||
// 帧偏移, 一般没用, 预留支持问题素材
|
||
offset: 0
|
||
}, options);
|
||
this.setBegin = true;
|
||
this.useFrameCallback = false;
|
||
this.container = this.options.container;
|
||
if (!this.options.src || !this.options.config || !this.options.container) {
|
||
console.error("参数出错:src(视频地址)、config(配置文件地址)、container(dom容器)");
|
||
}
|
||
return this;
|
||
}
|
||
}, {
|
||
key: "precacheSource",
|
||
value: function precacheSource(source) {
|
||
var URL = window.webkitURL || window.URL;
|
||
return new Promise(function(resolve, reject) {
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open("GET", source, true);
|
||
xhr.responseType = "blob";
|
||
xhr.onload = function() {
|
||
if (xhr.status === 200 || xhr.status === 304) {
|
||
var res = xhr.response;
|
||
if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
|
||
var fileReader = new FileReader();
|
||
fileReader.onloadend = function() {
|
||
var resultStr = fileReader.result;
|
||
var raw = atob(resultStr.slice(resultStr.indexOf(",") + 1));
|
||
var buf = Array(raw.length);
|
||
for (var d = 0; d < raw.length; d++) {
|
||
buf[d] = raw.charCodeAt(d);
|
||
}
|
||
var arr = new Uint8Array(buf);
|
||
var blob = new Blob([arr], {
|
||
type: "video/mp4"
|
||
});
|
||
resolve(URL.createObjectURL(blob));
|
||
};
|
||
fileReader.readAsDataURL(xhr.response);
|
||
} else {
|
||
resolve(URL.createObjectURL(res));
|
||
}
|
||
} else {
|
||
reject(new Error("http response invalid" + xhr.status));
|
||
}
|
||
};
|
||
xhr.send();
|
||
});
|
||
}
|
||
}, {
|
||
key: "initVideo",
|
||
value: function initVideo() {
|
||
var _this = this;
|
||
var options = this.options;
|
||
var video = this.video;
|
||
if (!video) {
|
||
video = this.video = document.createElement("video");
|
||
}
|
||
video.crossOrigin = "anonymous";
|
||
video.autoplay = false;
|
||
video.preload = "auto";
|
||
video.setAttribute("playsinline", "");
|
||
video.setAttribute("webkit-playsinline", "");
|
||
if (options.mute) {
|
||
video.muted = true;
|
||
video.volume = 0;
|
||
}
|
||
video.style.display = "none";
|
||
video.loop = !!options.loop;
|
||
if (options.precache) {
|
||
this.precacheSource(options.src).then(function(blob) {
|
||
console.log("sample precached.");
|
||
video.src = blob;
|
||
document.body.appendChild(video);
|
||
})["catch"](function(e) {
|
||
console.error(e);
|
||
});
|
||
} else {
|
||
video.src = options.src;
|
||
document.body.appendChild(this.video);
|
||
video.load();
|
||
}
|
||
this.firstPlaying = true;
|
||
if ("requestVideoFrameCallback" in this.video) {
|
||
this.useFrameCallback = !!this.options.accurate;
|
||
}
|
||
this.cancelRequestAnimation();
|
||
this.offAll();
|
||
["playing", "error", "canplay"].forEach(function(item) {
|
||
_this.on(item, _this["on" + item].bind(_this));
|
||
});
|
||
}
|
||
}, {
|
||
key: "drawFrame",
|
||
value: function drawFrame(_, _info) {
|
||
this._drawFrame = this._drawFrame || this.drawFrame.bind(this);
|
||
if (this.useFrameCallback) {
|
||
this.animId = this.video.requestVideoFrameCallback(this._drawFrame);
|
||
} else {
|
||
this.animId = this.requestAnim(this._drawFrame);
|
||
}
|
||
}
|
||
}, {
|
||
key: "play",
|
||
value: function play() {
|
||
var _this2 = this;
|
||
if (this.useFrameCallback) {
|
||
this.animId = this.video.requestVideoFrameCallback(this.drawFrame.bind(this));
|
||
} else {
|
||
this.requestAnim = this.requestAnimFunc();
|
||
}
|
||
var prom = this.video && this.video.play();
|
||
if (prom && prom.then) {
|
||
prom["catch"](function(e) {
|
||
if (!_this2.video) {
|
||
return;
|
||
}
|
||
_this2.video.muted = true;
|
||
_this2.video.volume = 0;
|
||
_this2.video.play()["catch"](function(e2) {
|
||
_this2.trigger("error", e2);
|
||
});
|
||
});
|
||
}
|
||
}
|
||
}, {
|
||
key: "pause",
|
||
value: function pause() {
|
||
this.video && this.video.pause();
|
||
}
|
||
}, {
|
||
key: "setTime",
|
||
value: function setTime(t) {
|
||
if (this.video) {
|
||
this.video.currentTime = t;
|
||
}
|
||
}
|
||
}, {
|
||
key: "requestAnimFunc",
|
||
value: function requestAnimFunc() {
|
||
var _this3 = this;
|
||
var _this$options$fps = this.options.fps, fps = _this$options$fps === void 0 ? 30 : _this$options$fps;
|
||
if (window.requestAnimationFrame) {
|
||
var index2 = -1;
|
||
return function(cb) {
|
||
index2++;
|
||
return requestAnimationFrame(function() {
|
||
if (!(index2 % (60 / fps))) {
|
||
return cb();
|
||
}
|
||
_this3.animId = _this3.requestAnim(cb);
|
||
});
|
||
};
|
||
}
|
||
return function(cb) {
|
||
return window.setTimeout(cb, 1e3 / fps);
|
||
};
|
||
}
|
||
}, {
|
||
key: "cancelRequestAnimation",
|
||
value: function cancelRequestAnimation() {
|
||
if (!this.animId) {
|
||
return;
|
||
}
|
||
if (this.useFrameCallback) {
|
||
try {
|
||
this.video.cancelVideoFrameCallback(this.animId);
|
||
} catch (e) {
|
||
console.error(e);
|
||
}
|
||
} else if (window.cancelAnimationFrame) {
|
||
cancelAnimationFrame(this.animId);
|
||
} else {
|
||
clearTimeout(this.animId);
|
||
}
|
||
this.animId = 0;
|
||
}
|
||
}, {
|
||
key: "clear",
|
||
value: function clear() {
|
||
this.cancelRequestAnimation();
|
||
}
|
||
}, {
|
||
key: "destroy",
|
||
value: function destroy() {
|
||
this.cancelRequestAnimation();
|
||
if (this.video) {
|
||
this.offAll();
|
||
this.video.parentNode && this.video.parentNode.removeChild(this.video);
|
||
this.video = null;
|
||
}
|
||
this.options.onDestroy && this.options.onDestroy();
|
||
}
|
||
}, {
|
||
key: "on",
|
||
value: function on(event, callback) {
|
||
var cbs = this.events[event] || [];
|
||
cbs.push(callback);
|
||
this.events[event] = cbs;
|
||
if (this.customEvent.indexOf(event) === -1) {
|
||
this.video.addEventListener(event, callback);
|
||
}
|
||
return this;
|
||
}
|
||
}, {
|
||
key: "once",
|
||
value: function once(event, callback) {
|
||
var _this4 = this;
|
||
var once2 = function once3() {
|
||
var cbs = _this4.events[event];
|
||
cbs.splice(cbs.indexOf(once3), 1);
|
||
_this4.video.removeEventListener(event, once3);
|
||
callback.apply(void 0, arguments);
|
||
};
|
||
return this.on(event, once2);
|
||
}
|
||
}, {
|
||
key: "trigger",
|
||
value: function trigger(eventName) {
|
||
for (var _len = arguments.length, e = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||
e[_key - 1] = arguments[_key];
|
||
}
|
||
try {
|
||
(this.events[eventName] || []).forEach(function(item) {
|
||
item.apply(void 0, e);
|
||
});
|
||
} catch (e2) {
|
||
console.error(e2);
|
||
}
|
||
}
|
||
}, {
|
||
key: "offAll",
|
||
value: function offAll() {
|
||
var _this5 = this;
|
||
Object.keys(this.events).forEach(function(name) {
|
||
var cbs = _this5.events[name];
|
||
if (cbs && cbs.length) {
|
||
cbs.forEach(function(cb) {
|
||
_this5.video.removeEventListener(name, cb);
|
||
});
|
||
}
|
||
});
|
||
this.events = {};
|
||
return this;
|
||
}
|
||
}, {
|
||
key: "onplaying",
|
||
value: function onplaying() {
|
||
if (this.firstPlaying) {
|
||
this.firstPlaying = false;
|
||
if (!this.useFrameCallback) {
|
||
this.drawFrame(null, null);
|
||
}
|
||
}
|
||
}
|
||
}, {
|
||
key: "oncanplay",
|
||
value: function oncanplay() {
|
||
var begin = this.options.beginPoint;
|
||
if (begin && this.setBegin) {
|
||
this.setBegin = false;
|
||
this.video.currentTime = begin;
|
||
}
|
||
}
|
||
}, {
|
||
key: "onerror",
|
||
value: function onerror(err) {
|
||
console.error("[Alpha video]: play error: ", err);
|
||
this.destroy();
|
||
this.options.onLoadError && this.options.onLoadError(err);
|
||
}
|
||
}]);
|
||
return VapVideo2;
|
||
}();
|
||
function _createSuper(Derived) {
|
||
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
||
return function _createSuperInternal() {
|
||
var Super = getPrototypeOf$1(Derived), result;
|
||
if (hasNativeReflectConstruct) {
|
||
var NewTarget = getPrototypeOf$1(this).constructor;
|
||
result = Reflect.construct(Super, arguments, NewTarget);
|
||
} else {
|
||
result = Super.apply(this, arguments);
|
||
}
|
||
return possibleConstructorReturn(this, result);
|
||
};
|
||
}
|
||
function _isNativeReflectConstruct() {
|
||
if (typeof Reflect === "undefined" || !Reflect.construct)
|
||
return false;
|
||
if (Reflect.construct.sham)
|
||
return false;
|
||
if (typeof Proxy === "function")
|
||
return true;
|
||
try {
|
||
Date.prototype.toString.call(Reflect.construct(Date, [], function() {
|
||
}));
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
var PER_SIZE = 9;
|
||
function computeCoord(x, y, w, h, vw, vh) {
|
||
return [x / vw, (x + w) / vw, (vh - y - h) / vh, (vh - y) / vh];
|
||
}
|
||
var WebglRenderVap = function(_VapVideo) {
|
||
inherits(WebglRenderVap2, _VapVideo);
|
||
var _super = _createSuper(WebglRenderVap2);
|
||
function WebglRenderVap2(options) {
|
||
var _this;
|
||
classCallCheck(this, WebglRenderVap2);
|
||
_this = _super.call(this);
|
||
_this.textures = [];
|
||
if (options) {
|
||
_this.play(options);
|
||
}
|
||
return _this;
|
||
}
|
||
createClass(WebglRenderVap2, [{
|
||
key: "play",
|
||
value: function play(options) {
|
||
var _this2 = this;
|
||
var _a;
|
||
if (options) {
|
||
this.setOptions(options);
|
||
}
|
||
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.config)) {
|
||
console.error("options.config cannot be empty.");
|
||
return this;
|
||
}
|
||
if (options) {
|
||
this.initVideo();
|
||
this.vapFrameParser = new FrameParser(this.options.config, this.options);
|
||
this.vapFrameParser.init().then(function() {
|
||
_this2.initWebGL();
|
||
_this2.initTexture();
|
||
_this2.initVideoTexture();
|
||
_this2.options.fps = _this2.vapFrameParser.config.info.fps || 30;
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "play", _this2).call(_this2);
|
||
})["catch"](function(e) {
|
||
_this2.vapFrameParser = null;
|
||
console.error("[Alpha video] parse vap frame error.", e);
|
||
return _this2;
|
||
});
|
||
} else {
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "play", this).call(this);
|
||
}
|
||
return this;
|
||
}
|
||
}, {
|
||
key: "initWebGL",
|
||
value: function initWebGL() {
|
||
var canvas = this.canvas, gl = this.gl, vertexShader = this.vertexShader, fragmentShader = this.fragmentShader, program = this.program;
|
||
var _this$options = this.options, width = _this$options.width, height = _this$options.height;
|
||
if (!canvas) {
|
||
canvas = document.createElement("canvas");
|
||
}
|
||
var vapFrameParser = this.vapFrameParser;
|
||
var _vapFrameParser$confi = vapFrameParser.config.info, w = _vapFrameParser$confi.w, h = _vapFrameParser$confi.h;
|
||
canvas.width = width || w;
|
||
canvas.height = height || h;
|
||
this.container.appendChild(canvas);
|
||
if (!gl) {
|
||
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
||
gl.disable(gl.BLEND);
|
||
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
|
||
}
|
||
gl.viewport(0, 0, canvas.width, canvas.height);
|
||
if (!vertexShader) {
|
||
vertexShader = this.initVertexShader(gl);
|
||
}
|
||
if (fragmentShader && program) {
|
||
cleanWebGL(gl, {
|
||
program,
|
||
shaders: [fragmentShader]
|
||
});
|
||
}
|
||
var srcData = vapFrameParser.srcData;
|
||
fragmentShader = this.initFragmentShader(gl, Object.keys(srcData).length);
|
||
program = createProgram(gl, vertexShader, fragmentShader);
|
||
this.canvas = canvas;
|
||
this.gl = gl;
|
||
this.vertexShader = vertexShader;
|
||
this.fragmentShader = fragmentShader;
|
||
this.program = program;
|
||
this.imagePosLoc = null;
|
||
return gl;
|
||
}
|
||
/**
|
||
* 顶点着色器
|
||
*/
|
||
}, {
|
||
key: "initVertexShader",
|
||
value: function initVertexShader(gl) {
|
||
return createShader(gl, gl.VERTEX_SHADER, "attribute vec2 a_position; // 接受顶点坐标\n attribute vec2 a_texCoord; // 接受纹理坐标\n attribute vec2 a_alpha_texCoord; // 接受纹理坐标\n varying vec2 v_alpha_texCoord; // 接受纹理坐标\n varying vec2 v_texcoord; // 传递纹理坐标给片元着色器\n void main(void){\n gl_Position = vec4(a_position, 0.0, 1.0); // 设置坐标\n v_texcoord = a_texCoord; // 设置纹理坐标\n v_alpha_texCoord = a_alpha_texCoord; // 设置纹理坐标\n }");
|
||
}
|
||
/**
|
||
* 片元着色器
|
||
*/
|
||
}, {
|
||
key: "initFragmentShader",
|
||
value: function initFragmentShader(gl, textureSize) {
|
||
var bgColor = "vec4(texture2D(u_image_video, v_texcoord).rgb, texture2D(u_image_video,v_alpha_texCoord).r);";
|
||
var sourceTexure = "";
|
||
var sourceUniform = "";
|
||
if (textureSize > 0) {
|
||
var bufferSize = textureSize * PER_SIZE;
|
||
var imgColor = [];
|
||
var samplers = [];
|
||
for (var i = 0; i < textureSize; i++) {
|
||
imgColor.push("if(ndx == ".concat(i + 1, "){\n color = texture2D(u_image").concat(i + 1, ",uv);\n }"));
|
||
samplers.push("uniform sampler2D u_image".concat(i + 1, ";"));
|
||
}
|
||
sourceUniform = "\n ".concat(samplers.join("\n"), "\n uniform float image_pos[").concat(bufferSize, "];\n vec4 getSampleFromArray(int ndx, vec2 uv) {\n vec4 color;\n ").concat(imgColor.join(" else "), "\n return color;\n }\n ");
|
||
sourceTexure = "\n vec4 srcColor,maskColor;\n vec2 srcTexcoord,maskTexcoord;\n int srcIndex;\n float x1,x2,y1,y2,mx1,mx2,my1,my2; //显示的区域\n\n for(int i=0;i<".concat(bufferSize, ";i+= ").concat(PER_SIZE, "){\n if ((int(image_pos[i]) > 0)) {\n srcIndex = int(image_pos[i]);\n \n x1 = image_pos[i+1];\n x2 = image_pos[i+2];\n y1 = image_pos[i+3];\n y2 = image_pos[i+4];\n \n mx1 = image_pos[i+5];\n mx2 = image_pos[i+6];\n my1 = image_pos[i+7];\n my2 = image_pos[i+8];\n \n \n if (v_texcoord.s>x1 && v_texcoord.s<x2 && v_texcoord.t>y1 && v_texcoord.t<y2) {\n srcTexcoord = vec2((v_texcoord.s-x1)/(x2-x1),(v_texcoord.t-y1)/(y2-y1));\n maskTexcoord = vec2(mx1+srcTexcoord.s*(mx2-mx1),my1+srcTexcoord.t*(my2-my1));\n srcColor = getSampleFromArray(srcIndex,srcTexcoord);\n maskColor = texture2D(u_image_video, maskTexcoord);\n srcColor.a = srcColor.a*(maskColor.r);\n \n bgColor = vec4(srcColor.rgb*srcColor.a,srcColor.a) + (1.0-srcColor.a)*bgColor;\n \n } \n }\n }\n ");
|
||
}
|
||
var fragmentShader = "\n precision lowp float;\n varying vec2 v_texcoord;\n varying vec2 v_alpha_texCoord;\n uniform sampler2D u_image_video;\n ".concat(sourceUniform, "\n \n void main(void) {\n vec4 bgColor = ").concat(bgColor, "\n ").concat(sourceTexure, "\n gl_FragColor = bgColor;\n }\n ");
|
||
return createShader(gl, gl.FRAGMENT_SHADER, fragmentShader);
|
||
}
|
||
}, {
|
||
key: "initTexture",
|
||
value: function initTexture() {
|
||
var gl = this.gl, vapFrameParser = this.vapFrameParser, textures = this.textures;
|
||
if (!vapFrameParser || !vapFrameParser.srcData) {
|
||
return;
|
||
}
|
||
var resources = vapFrameParser.srcData;
|
||
var i = 1;
|
||
for (var key in resources) {
|
||
var resource = resources[key];
|
||
var texture = textures[i - 1];
|
||
if (texture) {
|
||
gl.activeTexture(gl.TEXTURE0 + i);
|
||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, resource.img);
|
||
} else {
|
||
this.textures.push(createTexture(gl, i, resource.img));
|
||
}
|
||
var sampler = gl.getUniformLocation(this.program, "u_image".concat(i));
|
||
gl.uniform1i(sampler, i);
|
||
this.vapFrameParser.textureMap[resource.srcId] = i++;
|
||
}
|
||
}
|
||
}, {
|
||
key: "initVideoTexture",
|
||
value: function initVideoTexture() {
|
||
var gl = this.gl, vapFrameParser = this.vapFrameParser, program = this.program;
|
||
if (!vapFrameParser || !vapFrameParser.config || !vapFrameParser.config.info) {
|
||
return;
|
||
}
|
||
if (!this.videoTexture) {
|
||
this.videoTexture = createTexture(gl, 0);
|
||
}
|
||
var sampler = gl.getUniformLocation(program, "u_image_video");
|
||
gl.uniform1i(sampler, 0);
|
||
gl.activeTexture(gl.TEXTURE0);
|
||
var info = vapFrameParser.config.info;
|
||
var vW = info.videoW, vH = info.videoH;
|
||
var _info$rgbFrame = slicedToArray(info.rgbFrame, 4), rgbX = _info$rgbFrame[0], rgbY = _info$rgbFrame[1], rgbW = _info$rgbFrame[2], rgbH = _info$rgbFrame[3];
|
||
var _info$aFrame = slicedToArray(info.aFrame, 4), aX = _info$aFrame[0], aY = _info$aFrame[1], aW = _info$aFrame[2], aH = _info$aFrame[3];
|
||
var rgbCoord = computeCoord(rgbX, rgbY, rgbW, rgbH, vW, vH);
|
||
var aCoord = computeCoord(aX, aY, aW, aH, vW, vH);
|
||
var view = new Float32Array([-1, 1, rgbCoord[0], rgbCoord[3], aCoord[0], aCoord[3]].concat([1, 1, rgbCoord[1], rgbCoord[3], aCoord[1], aCoord[3]], [-1, -1, rgbCoord[0], rgbCoord[2], aCoord[0], aCoord[2]], [1, -1, rgbCoord[1], rgbCoord[2], aCoord[1], aCoord[2]]));
|
||
if (!this.vertexBuffer) {
|
||
this.vertexBuffer = gl.createBuffer();
|
||
gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer);
|
||
}
|
||
gl.bufferData(gl.ARRAY_BUFFER, view, gl.STATIC_DRAW);
|
||
var size = view.BYTES_PER_ELEMENT;
|
||
var aPosition = gl.getAttribLocation(program, "a_position");
|
||
gl.enableVertexAttribArray(aPosition);
|
||
gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, size * 6, 0);
|
||
var aTexCoord = gl.getAttribLocation(program, "a_texCoord");
|
||
gl.enableVertexAttribArray(aTexCoord);
|
||
gl.vertexAttribPointer(aTexCoord, 2, gl.FLOAT, false, size * 6, size * 2);
|
||
var aAlphaTexCoord = gl.getAttribLocation(program, "a_alpha_texCoord");
|
||
gl.enableVertexAttribArray(aAlphaTexCoord);
|
||
gl.vertexAttribPointer(aAlphaTexCoord, 2, gl.FLOAT, false, size * 6, size * 4);
|
||
}
|
||
}, {
|
||
key: "drawFrame",
|
||
value: function drawFrame(_, info) {
|
||
var gl = this.gl, vapFrameParser = this.vapFrameParser, video = this.video, options = this.options;
|
||
if (!gl) {
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "drawFrame", this).call(this, _, info);
|
||
return;
|
||
}
|
||
var frame = !options.loop && (info === null || info === void 0 ? void 0 : info.presentedFrames) > 0 ? info.presentedFrames - 1 : Math.round(video.currentTime * options.fps) + options.offset;
|
||
var frameData = vapFrameParser.getFrame(frame);
|
||
if (frameData === null || frameData === void 0 ? void 0 : frameData.obj) {
|
||
var posArr = [];
|
||
var _vapFrameParser$confi2 = vapFrameParser.config.info, vW = _vapFrameParser$confi2.videoW, vH = _vapFrameParser$confi2.videoH, rgbFrame = _vapFrameParser$confi2.rgbFrame;
|
||
frameData.obj.forEach(function(frame2) {
|
||
var imgIndex = vapFrameParser.textureMap[frame2.srcId];
|
||
if (imgIndex > 0) {
|
||
posArr[posArr.length] = imgIndex;
|
||
var _rgbFrame = slicedToArray(rgbFrame, 2), rgbX = _rgbFrame[0], rgbY = _rgbFrame[1];
|
||
var _frame$frame = slicedToArray(frame2.frame, 4), x = _frame$frame[0], y = _frame$frame[1], w = _frame$frame[2], h = _frame$frame[3];
|
||
var _frame$mFrame = slicedToArray(frame2.mFrame, 4), mX = _frame$mFrame[0], mY = _frame$mFrame[1], mW = _frame$mFrame[2], mH = _frame$mFrame[3];
|
||
var coord = computeCoord(x + rgbX, y + rgbY, w, h, vW, vH);
|
||
var mCoord = computeCoord(mX, mY, mW, mH, vW, vH);
|
||
posArr = posArr.concat(coord).concat(mCoord);
|
||
}
|
||
});
|
||
if (posArr.length) {
|
||
this.imagePosLoc = this.imagePosLoc || gl.getUniformLocation(this.program, "image_pos");
|
||
gl.uniform1fv(this.imagePosLoc, new Float32Array(posArr));
|
||
}
|
||
}
|
||
this.trigger("frame", frame + 1, frameData, vapFrameParser.config);
|
||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, video);
|
||
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "drawFrame", this).call(this, _, info);
|
||
}
|
||
// 清理数据,为下一次播放做准备
|
||
}, {
|
||
key: "clear",
|
||
value: function clear() {
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "clear", this).call(this);
|
||
var gl = this.gl;
|
||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||
}
|
||
// 销毁,释放webgl资源,销毁后调用play,资源会重新初始化
|
||
}, {
|
||
key: "destroy",
|
||
value: function destroy() {
|
||
get(getPrototypeOf$1(WebglRenderVap2.prototype), "destroy", this).call(this);
|
||
var canvas = this.canvas, gl = this.gl, vertexShader = this.vertexShader, fragmentShader = this.fragmentShader, program = this.program, textures = this.textures, videoTexture = this.videoTexture, vertexBuffer = this.vertexBuffer;
|
||
if (canvas) {
|
||
canvas.parentNode && canvas.parentNode.removeChild(canvas);
|
||
this.canvas = null;
|
||
}
|
||
if (gl) {
|
||
cleanWebGL(gl, {
|
||
program,
|
||
shaders: [vertexShader, fragmentShader],
|
||
textures: [].concat(toConsumableArray(textures), [videoTexture]),
|
||
buffers: [vertexBuffer]
|
||
});
|
||
}
|
||
this.gl = null;
|
||
this.vertexShader = null;
|
||
this.fragmentShader = null;
|
||
this.program = null;
|
||
this.imagePosLoc = null;
|
||
this.vertexBuffer = null;
|
||
this.videoTexture = null;
|
||
this.textures = [];
|
||
}
|
||
}]);
|
||
return WebglRenderVap2;
|
||
}(VapVideo);
|
||
var isCanWebGL;
|
||
function index(options) {
|
||
if (canWebGL()) {
|
||
return new WebglRenderVap(options);
|
||
} else {
|
||
throw new Error("your browser not support webgl");
|
||
}
|
||
}
|
||
function canWebGL() {
|
||
if (typeof isCanWebGL !== "undefined") {
|
||
return isCanWebGL;
|
||
}
|
||
try {
|
||
if (!window.WebGLRenderingContext) {
|
||
return false;
|
||
}
|
||
var canvas = document.createElement("canvas");
|
||
var context = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
||
isCanWebGL = !!context;
|
||
context = null;
|
||
} catch (err) {
|
||
isCanWebGL = false;
|
||
}
|
||
return isCanWebGL;
|
||
}
|
||
exports2.canWebGL = canWebGL;
|
||
exports2.default = index;
|
||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||
});
|
||
}
|
||
});
|
||
export default require_vap();
|
||
/*! Bundled license information:
|
||
|
||
video-animation-player/dist/vap.js:
|
||
(*! *****************************************************************************
|
||
Copyright (c) Microsoft Corporation.
|
||
|
||
Permission to use, copy, modify, and/or distribute this software for any
|
||
purpose with or without fee is hereby granted.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
PERFORMANCE OF THIS SOFTWARE.
|
||
***************************************************************************** *)
|
||
*/
|
||
//# sourceMappingURL=video-animation-player.js.map
|