@realsee/vreo 2.2.6 → 2.3.0
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/lib/PlayController/createHTMLAudioElement.js +11 -6
- package/lib/PlayController/index.js +80 -15
- package/lib/Player/App.js +28 -1
- package/lib/Player/Controller.js +100 -23
- package/lib/Player/custom/SpatialScenePanel/index.js +68 -42
- package/lib/Player/hooks.js +10 -0
- package/lib/Player/index.js +88 -24
- package/lib/Player/modules/Drawer/index.js +17 -0
- package/lib/Player/modules/PopUp/index.js +10 -0
- package/lib/Player/modules/ResizeObserver/index.js +8 -0
- package/lib/Player/modules/VideoAgent/VideoAgentMesh.js +108 -17
- package/lib/Player/modules/VideoAgent/VideoAgentScene.js +24 -2
- package/lib/Player/modules/VideoAgent/index.js +17 -0
- package/lib/Player/modules/Wave/index.d.ts +1 -0
- package/lib/Player/modules/Wave/index.js +46 -13
- package/lib/Player/modules/keyframes/BgMusic/index.js +25 -7
- package/lib/Player/modules/keyframes/CameraMovement/index.js +27 -3
- package/lib/Player/modules/keyframes/InfoPanel/index.js +29 -6
- package/lib/Player/modules/keyframes/ModelVideo/index.js +29 -3
- package/lib/Player/modules/keyframes/PanoEffect/index.js +43 -15
- package/lib/Player/modules/keyframes/PanoEffect/lineAnime.js +7 -0
- package/lib/Player/modules/keyframes/PanoTag/index.js +22 -4
- package/lib/Player/modules/keyframes/PanoTextLabel/index.js +47 -22
- package/lib/Player/modules/keyframes/Prompter/index.js +32 -10
- package/lib/Player/modules/keyframes/UpdateVRPanorama/index.js +25 -18
- package/lib/Player/modules/keyframes/VideoEffect/index.js +65 -16
- package/lib/Player/typings.d.ts +4 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/centerPoint.js +2 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/createResizeObserver.js +1 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/evenNumber.js +1 -0
- package/lib/fivePlugins/CSS3DRenderPlugin/index.js +60 -19
- package/lib/fivePlugins/CSS3DRenderPlugin/transformPositionToVector3.js +5 -2
- package/lib/fivePlugins/CameraMovementPlugin/index.js +72 -19
- package/lib/fivePlugins/CameraMovementPlugin/typings.js +4 -0
- package/lib/fivePlugins/ModelTVVideoPlugin/index.js +60 -11
- package/lib/index.js +1 -0
- package/lib/react/index.js +34 -7
- package/lib/shared-utils/Audio.js +69 -15
- package/lib/shared-utils/AudioLike.js +39 -5
- package/lib/shared-utils/Preloader.js +7 -0
- package/lib/shared-utils/addResizeListener.js +5 -0
- package/lib/shared-utils/animationFrame/BetterTween.js +38 -2
- package/lib/shared-utils/animationFrame/index.js +10 -2
- package/lib/shared-utils/animationFrame/tween.js +11 -2
- package/lib/shared-utils/createTransMatrix.js +17 -2
- package/lib/shared-utils/getFileExpandedName.js +1 -0
- package/lib/shared-utils/getMediaInfo.js +9 -0
- package/lib/shared-utils/setElementDataset.js +2 -0
- package/lib/typings/VreoUnit.js +15 -0
- package/package.json +4 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -8,58 +9,83 @@ exports.audioList = void 0;
|
|
|
8
9
|
exports.generateBlankAudio = generateBlankAudio;
|
|
9
10
|
exports.getAudio = getAudio;
|
|
10
11
|
exports.waitForBlankAudioGenerated = waitForBlankAudioGenerated;
|
|
11
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) 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 ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 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(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(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; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(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 ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
12
|
+
|
|
12
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
|
|
13
15
|
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); } }
|
|
16
|
+
|
|
14
17
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
+
|
|
15
19
|
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
20
|
+
|
|
16
21
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
22
|
+
|
|
17
23
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
+
|
|
18
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
+
|
|
19
27
|
function set(target, property, value, receiver) { if (typeof Reflect !== "undefined" && Reflect.set) { set = Reflect.set; } else { set = function set(target, property, value, receiver) { var base = _superPropBase(target, property); var desc; if (base) { desc = Object.getOwnPropertyDescriptor(base, property); if (desc.set) { desc.set.call(receiver, value); return true; } else if (!desc.writable) { return false; } } desc = Object.getOwnPropertyDescriptor(receiver, property); if (desc) { if (!desc.writable) { return false; } desc.value = value; Object.defineProperty(receiver, property, desc); } else { _defineProperty(receiver, property, value); } return true; }; } return set(target, property, value, receiver); }
|
|
28
|
+
|
|
20
29
|
function _set(target, property, value, receiver, isStrict) { var s = set(target, property, value, receiver || target); if (!s && isStrict) { throw new Error('failed to set property'); } return value; }
|
|
21
|
-
|
|
30
|
+
|
|
31
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
32
|
+
|
|
22
33
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
34
|
+
|
|
23
35
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
24
|
-
|
|
36
|
+
|
|
37
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
38
|
+
|
|
25
39
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
40
|
+
|
|
26
41
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
27
|
-
|
|
28
|
-
function
|
|
42
|
+
|
|
43
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
44
|
+
|
|
45
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
46
|
+
|
|
29
47
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
48
|
+
|
|
30
49
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
50
|
+
|
|
31
51
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
32
|
-
|
|
33
|
-
// 下面这段空音频居然在11pro和xr上播不出来
|
|
52
|
+
|
|
53
|
+
var blankAudioSrc = 'data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAADAAAGhgBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr///////////////////////////////////////////8AAAA5TEFNRTMuOThyAc0AAAAAAAAAABSAJAiqQgAAgAAABobxtI73AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQxAACFEII9ACZ/sJZwWEoEb8w/////N//////JcxjHjf+7/v/H2PzCCFAiDtGeyBCIx7bJJ1mmEEMy6g8mm2c8nrGABB4h2Mkmn//4z/73u773R5qHHu/j/w7Kxkzh5lWRWdsifCkNAnY9Zc1HvDAhjhSHdFkHFzLmabt/AQxSg2wwzLhHIJOBnAWwVY4zrhIYhhc2kvhYDfQ4hDi2Gmh5KyFn8EcGIrHAngNgIwVIEMf5bzbAiTRoAD///8z/KVhkkWEle6IX+d/z4fvH3BShK1e5kmjkCMoxVmXhd4ROlTKo3iipasvTilY21q19ta30/v/0/idPX1v8PNxJL6ramnOVsdvMv2akO0iSYIzdJFirtzWXCZicS9vHqvSKyqm5XJBdqBwPxyfJdykhWTZ0G0ZyTZGpLKxsNwwoRhsx3tZfhwmeOBVISm3impAC/IT/8hP/EKEM1KMdVdVKM2rHV4x7HVXZvbVVKN/qq8CiV9VL9jjH/6l6qf7MBCjZmOqsAibjcP+qqqv0oxqpa/NVW286hPo1nz2L/h8+jXt//uSxCmDU2IK/ECN98KKtE5IYzNoCfbw+u9i5r8PoadUMFPKqWL4LK3T/LCraMSHGkW4bpLXR/E6LlHOVQxmslKVJ8IULktMN06N0FKCpHCoYsjC4F+Z0NVqdNFoGSTjSiyjzLdnZ2fNqTi2eHKONONKLMPMKLONKLMPQRJGlFxZRoKcJFAYEeIFiRQkUWUeYfef//Ko04soswso40UJAgMw8wosososy0EalnZyjQUGBRQGIFggOWUacWUeYmuadrZziQKKEgQsQLAhQkUJAgMQDghltLO1onp0cpkNInSFMqlYeSEJ5AHsqFdOwy1DA2sRmRJKxdKRfLhfLw5BzUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjk4LjJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7ksRRA8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVU='; // 下面这段空音频居然在11pro和xr上播不出来
|
|
34
54
|
// const blankAudioSrc = 'data:audio/mpeg;base64,//AAAAHGZ0eXBNNEEgAAAAAE00QSBpc29tbXA0MgAAAAFtZGF0AAAAAAAAABwA0AAHANAABwDQAAcAAAM+bW9vdgAAAGxtdmhkAAAAAN+jti7fo7YuAACsRAAADAAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAdB0cmFrAAAAXHRraGQAAAAB36O2Lt+jti4AAAABAAAAAAAADAAAAAAAAAAAAAAAAAABAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAFsbWRpYQAAACBtZGhkAAAAAN+jti7fo7YuAACsRAAADABVxAAAAAAAMWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABDb3JlIE1lZGlhIEF1ZGlvAAAAARNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAANdzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAAABICAgBRAFAAYAAAA+gAAAPoABYCAgAISCAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAAADAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAwAAAAEAAAAgc3RzegAAAAAAAAAAAAAAAwAAAAQAAAAEAAAABAAAABRzdGNvAAAAAAAAAAEAAAAsAAAA+nVkdGEAAADybWV0YQAAAAAAAAAiaGRscgAAAAAAAAAAbWRpcgAAAAAAAAAAAAAAAAAAAAAAxGlsc3QAAAC8LS0tLQAAABxtZWFuAAAAAGNvbS5hcHBsZS5pVHVuZXMAAAAUbmFtZQAAAABpVHVuU01QQgAAAIRkYXRhAAAAAQAAAAAgMDAwMDAwMDAgMDAwMDA4NDAgMDAwMDAzQzAgMDAwMDAwMDAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMCAwMDAwMDAwMA=='
|
|
35
55
|
|
|
36
56
|
var audioList = [];
|
|
37
57
|
exports.audioList = audioList;
|
|
58
|
+
|
|
38
59
|
function getAudio(src) {
|
|
39
60
|
var audio = audioList.find(function (audio) {
|
|
40
61
|
return !audio.realSrc || audio.realSrc === blankAudioSrc;
|
|
41
62
|
});
|
|
63
|
+
|
|
42
64
|
if (!audio) {
|
|
43
65
|
// console.warn('未找到缓存音频,已新建', audioList)
|
|
44
66
|
audio = new IAudio(blankAudioSrc);
|
|
45
67
|
audioList.push(audio);
|
|
46
68
|
}
|
|
69
|
+
|
|
47
70
|
if (src) {
|
|
48
71
|
audio.src = src;
|
|
49
72
|
}
|
|
73
|
+
|
|
50
74
|
return audio;
|
|
51
75
|
}
|
|
76
|
+
|
|
52
77
|
function waitForBlankAudioGenerated() {
|
|
53
78
|
return _waitForBlankAudioGenerated.apply(this, arguments);
|
|
54
79
|
}
|
|
80
|
+
|
|
55
81
|
function _waitForBlankAudioGenerated() {
|
|
56
|
-
_waitForBlankAudioGenerated = _asyncToGenerator( /*#__PURE__*/
|
|
82
|
+
_waitForBlankAudioGenerated = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
57
83
|
var checkInterval,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return
|
|
84
|
+
timeout,
|
|
85
|
+
startTime,
|
|
86
|
+
isTimedOut,
|
|
87
|
+
_args = arguments;
|
|
88
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
89
|
while (1) {
|
|
64
90
|
switch (_context.prev = _context.next) {
|
|
65
91
|
case 0:
|
|
@@ -67,10 +93,11 @@ function _waitForBlankAudioGenerated() {
|
|
|
67
93
|
timeout = _args.length > 1 && _args[1] !== undefined ? _args[1] : 2000;
|
|
68
94
|
console.log('waitForBlankAudioGenerated, needGenerate: ', audioList.some(function (audio) {
|
|
69
95
|
return !audio.ended && audio.src === blankAudioSrc;
|
|
70
|
-
}));
|
|
71
|
-
|
|
96
|
+
})); // while any audioList not ended
|
|
97
|
+
|
|
72
98
|
startTime = Date.now();
|
|
73
99
|
isTimedOut = false;
|
|
100
|
+
|
|
74
101
|
case 5:
|
|
75
102
|
if (!(audioList.some(function (audio) {
|
|
76
103
|
return !audio.ended && audio.src === blankAudioSrc;
|
|
@@ -78,20 +105,25 @@ function _waitForBlankAudioGenerated() {
|
|
|
78
105
|
_context.next = 13;
|
|
79
106
|
break;
|
|
80
107
|
}
|
|
108
|
+
|
|
81
109
|
if (!(Date.now() - startTime > timeout)) {
|
|
82
110
|
_context.next = 9;
|
|
83
111
|
break;
|
|
84
112
|
}
|
|
113
|
+
|
|
85
114
|
isTimedOut = true;
|
|
86
115
|
return _context.abrupt("return", Promise.resolve());
|
|
116
|
+
|
|
87
117
|
case 9:
|
|
88
118
|
_context.next = 11;
|
|
89
119
|
return new Promise(function (resolve) {
|
|
90
120
|
return setTimeout(resolve, checkInterval);
|
|
91
121
|
});
|
|
122
|
+
|
|
92
123
|
case 11:
|
|
93
124
|
_context.next = 5;
|
|
94
125
|
break;
|
|
126
|
+
|
|
95
127
|
case 13:
|
|
96
128
|
case "end":
|
|
97
129
|
return _context.stop();
|
|
@@ -101,49 +133,69 @@ function _waitForBlankAudioGenerated() {
|
|
|
101
133
|
}));
|
|
102
134
|
return _waitForBlankAudioGenerated.apply(this, arguments);
|
|
103
135
|
}
|
|
136
|
+
|
|
104
137
|
function generateBlankAudio(length) {
|
|
105
138
|
// 判断一下已经生成几个了,防止重复生成
|
|
106
139
|
var generateLength = length - audioList.length;
|
|
107
140
|
if (generateLength <= 0) return;
|
|
141
|
+
|
|
108
142
|
for (var i = 0; i < generateLength; i++) {
|
|
109
143
|
audioList.push(new IAudio(blankAudioSrc));
|
|
110
144
|
}
|
|
111
145
|
}
|
|
146
|
+
|
|
112
147
|
function initAudio(audio) {
|
|
113
148
|
if (audio.inited) return;
|
|
149
|
+
|
|
114
150
|
if (audio.src) {
|
|
115
151
|
audio.inited = true;
|
|
116
152
|
audio.removeDocumentEventListener();
|
|
117
153
|
}
|
|
154
|
+
|
|
118
155
|
if (audio.src === blankAudioSrc) {
|
|
119
156
|
audio.play();
|
|
120
157
|
}
|
|
121
158
|
}
|
|
159
|
+
|
|
122
160
|
var IAudio = /*#__PURE__*/function (_Audio) {
|
|
123
161
|
_inherits(IAudio, _Audio);
|
|
162
|
+
|
|
124
163
|
var _super = _createSuper(IAudio);
|
|
164
|
+
|
|
125
165
|
function IAudio(src) {
|
|
126
166
|
var _thisSuper, _this;
|
|
167
|
+
|
|
127
168
|
_classCallCheck(this, IAudio);
|
|
169
|
+
|
|
128
170
|
_this = _super.call(this, src);
|
|
171
|
+
|
|
129
172
|
_defineProperty(_assertThisInitialized(_this), "preload", 'auto');
|
|
173
|
+
|
|
130
174
|
_defineProperty(_assertThisInitialized(_this), "realSrc", '');
|
|
175
|
+
|
|
131
176
|
_defineProperty(_assertThisInitialized(_this), "inited", false);
|
|
177
|
+
|
|
132
178
|
_this.realSrc = src !== null && src !== void 0 ? src : '';
|
|
179
|
+
|
|
133
180
|
_get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(IAudio.prototype)), "addEventListener", _thisSuper).call(_thisSuper, 'ended', function () {
|
|
134
181
|
_this.src = '';
|
|
135
182
|
});
|
|
183
|
+
|
|
136
184
|
var init = function init() {
|
|
137
185
|
return initAudio(_assertThisInitialized(_this));
|
|
138
186
|
};
|
|
187
|
+
|
|
139
188
|
document.addEventListener('click', init);
|
|
140
189
|
document.addEventListener('touchend', init);
|
|
190
|
+
|
|
141
191
|
_this.removeDocumentEventListener = function () {
|
|
142
192
|
document.removeEventListener('click', init);
|
|
143
193
|
document.removeEventListener('touchend', init);
|
|
144
194
|
};
|
|
195
|
+
|
|
145
196
|
return _this;
|
|
146
197
|
}
|
|
198
|
+
|
|
147
199
|
_createClass(IAudio, [{
|
|
148
200
|
key: "src",
|
|
149
201
|
get: function get() {
|
|
@@ -151,8 +203,10 @@ var IAudio = /*#__PURE__*/function (_Audio) {
|
|
|
151
203
|
},
|
|
152
204
|
set: function set(paramsSrc) {
|
|
153
205
|
_set(_getPrototypeOf(IAudio.prototype), "src", paramsSrc, this, true);
|
|
206
|
+
|
|
154
207
|
this.realSrc = paramsSrc;
|
|
155
208
|
}
|
|
156
209
|
}]);
|
|
210
|
+
|
|
157
211
|
return IAudio;
|
|
158
212
|
}( /*#__PURE__*/_wrapNativeSuper(Audio));
|
|
@@ -1,60 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = exports.AudioLike = void 0;
|
|
9
|
+
|
|
8
10
|
var _five = require("@realsee/five");
|
|
11
|
+
|
|
9
12
|
var _animationFrame = require("./animationFrame");
|
|
13
|
+
|
|
10
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
|
|
11
16
|
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); } }
|
|
17
|
+
|
|
12
18
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
+
|
|
13
20
|
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
-
|
|
21
|
+
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
+
|
|
15
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
25
|
+
|
|
16
26
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
27
|
+
|
|
17
28
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
29
|
+
|
|
18
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
-
|
|
31
|
+
|
|
32
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
+
|
|
20
34
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
|
|
21
36
|
/**
|
|
22
37
|
* 模拟 `<Audio>` 功能:没有音频,但执行逻辑跟 `<Audio>` 相似。
|
|
23
38
|
*/
|
|
24
39
|
var AudioLike = /*#__PURE__*/function (_Subscribe) {
|
|
25
40
|
_inherits(AudioLike, _Subscribe);
|
|
41
|
+
|
|
26
42
|
var _super = _createSuper(AudioLike);
|
|
43
|
+
|
|
27
44
|
function AudioLike() {
|
|
28
45
|
var _this;
|
|
46
|
+
|
|
29
47
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
30
|
-
|
|
48
|
+
duration = _ref.duration;
|
|
49
|
+
|
|
31
50
|
_classCallCheck(this, AudioLike);
|
|
51
|
+
|
|
32
52
|
_this = _super.call(this);
|
|
53
|
+
|
|
33
54
|
_defineProperty(_assertThisInitialized(_this), "$timestamp", null);
|
|
55
|
+
|
|
34
56
|
_defineProperty(_assertThisInitialized(_this), "$currentTime", 0);
|
|
57
|
+
|
|
35
58
|
_defineProperty(_assertThisInitialized(_this), "$duration", 0);
|
|
59
|
+
|
|
36
60
|
_defineProperty(_assertThisInitialized(_this), "muted", false);
|
|
61
|
+
|
|
37
62
|
_defineProperty(_assertThisInitialized(_this), "src", '');
|
|
63
|
+
|
|
38
64
|
if (duration) {
|
|
39
65
|
_this.$duration = duration;
|
|
40
66
|
}
|
|
67
|
+
|
|
41
68
|
return _this;
|
|
42
69
|
}
|
|
70
|
+
|
|
43
71
|
_createClass(AudioLike, [{
|
|
44
72
|
key: "setAttribute",
|
|
45
|
-
value: function setAttribute(name, value) {
|
|
46
|
-
// nothing todo
|
|
73
|
+
value: function setAttribute(name, value) {// nothing todo
|
|
47
74
|
}
|
|
48
75
|
}, {
|
|
49
76
|
key: "play",
|
|
50
77
|
value: function play() {
|
|
51
78
|
var _this2 = this;
|
|
79
|
+
|
|
52
80
|
if (this.$currentTime === this.$duration) {
|
|
53
81
|
this.$currentTime = 0;
|
|
54
82
|
}
|
|
83
|
+
|
|
55
84
|
if (this.$timestamp === null) {
|
|
56
85
|
this.$timestamp = performance.now();
|
|
57
86
|
}
|
|
87
|
+
|
|
58
88
|
this.stopInterval = (0, _animationFrame.requestAnimationFrameInterval)(function () {
|
|
59
89
|
return _this2.requestAnimationFrameLoop();
|
|
60
90
|
});
|
|
@@ -68,6 +98,7 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
|
|
|
68
98
|
this.emit('pause');
|
|
69
99
|
this.stopInterval = undefined;
|
|
70
100
|
}
|
|
101
|
+
|
|
71
102
|
this.$timestamp = null;
|
|
72
103
|
}
|
|
73
104
|
}, {
|
|
@@ -78,6 +109,7 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
|
|
|
78
109
|
this.$currentTime += now - this.$timestamp;
|
|
79
110
|
this.$timestamp = now;
|
|
80
111
|
this.emit('timeupdate');
|
|
112
|
+
|
|
81
113
|
if (this.$currentTime >= this.$duration - 10) {
|
|
82
114
|
this.$currentTime = this.$duration;
|
|
83
115
|
this.pause();
|
|
@@ -123,8 +155,10 @@ var AudioLike = /*#__PURE__*/function (_Subscribe) {
|
|
|
123
155
|
this.off(evtName, callback);
|
|
124
156
|
}
|
|
125
157
|
}]);
|
|
158
|
+
|
|
126
159
|
return AudioLike;
|
|
127
160
|
}(_five.Subscribe);
|
|
161
|
+
|
|
128
162
|
exports.AudioLike = AudioLike;
|
|
129
163
|
var _default = AudioLike;
|
|
130
164
|
exports["default"] = _default;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Preloader = void 0;
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* 预载器
|
|
9
10
|
*/
|
|
@@ -12,21 +13,26 @@ var Preloader = {
|
|
|
12
13
|
var noop = function noop() {
|
|
13
14
|
return null;
|
|
14
15
|
};
|
|
16
|
+
|
|
15
17
|
return new Promise(function (resolve, reject) {
|
|
16
18
|
var xhr = new XMLHttpRequest();
|
|
19
|
+
|
|
17
20
|
var clear = function clear() {
|
|
18
21
|
xhr.ontimeout = noop;
|
|
19
22
|
xhr.onreadystatechange = noop;
|
|
20
23
|
xhr.onprogress = noop;
|
|
21
24
|
xhr.onabort = noop;
|
|
22
25
|
};
|
|
26
|
+
|
|
23
27
|
xhr.ontimeout = function () {
|
|
24
28
|
reject(new Error('timeout'));
|
|
25
29
|
clear();
|
|
26
30
|
};
|
|
31
|
+
|
|
27
32
|
xhr.onreadystatechange = function () {
|
|
28
33
|
if (xhr.readyState !== 4) return;
|
|
29
34
|
if (xhr.status === 0 && !xhr.response) return;
|
|
35
|
+
|
|
30
36
|
if (xhr.status === 200 || xhr.status === 0) {
|
|
31
37
|
resolve(xhr.response);
|
|
32
38
|
clear();
|
|
@@ -35,6 +41,7 @@ var Preloader = {
|
|
|
35
41
|
clear();
|
|
36
42
|
}
|
|
37
43
|
};
|
|
44
|
+
|
|
38
45
|
xhr.open('GET', url, true);
|
|
39
46
|
xhr.responseType = 'blob';
|
|
40
47
|
xhr.send(null);
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.addResizeListener = addResizeListener;
|
|
7
7
|
exports.hasResizeListener = hasResizeListener;
|
|
8
8
|
var resizeObserverCache = new Map();
|
|
9
|
+
|
|
9
10
|
function addResizeListener(element, resizeHandler) {
|
|
10
11
|
var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
11
12
|
if (!element) return function () {};
|
|
12
13
|
if (immediate) resizeHandler(element.clientWidth, element.clientHeight);
|
|
14
|
+
|
|
13
15
|
if (typeof ResizeObserver !== 'undefined' && ResizeObserver) {
|
|
14
16
|
var resizeObserver = new ResizeObserver(function () {
|
|
15
17
|
return resizeHandler(element.clientWidth, element.clientHeight);
|
|
@@ -18,6 +20,7 @@ function addResizeListener(element, resizeHandler) {
|
|
|
18
20
|
resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
|
|
19
21
|
return function () {
|
|
20
22
|
if (element) resizeObserver.unobserve(element);
|
|
23
|
+
|
|
21
24
|
if (resizeObserverCache.get(element) === 1) {
|
|
22
25
|
resizeObserverCache["delete"](element);
|
|
23
26
|
}
|
|
@@ -34,12 +37,14 @@ function addResizeListener(element, resizeHandler) {
|
|
|
34
37
|
resizeObserverCache.set(element, resizeObserverCache.get(element) || 0 + 1);
|
|
35
38
|
return function () {
|
|
36
39
|
element.removeChild(iframe);
|
|
40
|
+
|
|
37
41
|
if (resizeObserverCache.get(element) === 1) {
|
|
38
42
|
resizeObserverCache["delete"](element);
|
|
39
43
|
}
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
}
|
|
47
|
+
|
|
43
48
|
function hasResizeListener(element) {
|
|
44
49
|
if (!element) return false;
|
|
45
50
|
return resizeObserverCache.get(element) || 0 > 0;
|
|
@@ -1,62 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.BetterTween = void 0;
|
|
8
9
|
exports.tweenProgress = tweenProgress;
|
|
10
|
+
|
|
9
11
|
var _tween = _interopRequireDefault(require("@tweenjs/tween.js"));
|
|
12
|
+
|
|
10
13
|
var _ = require(".");
|
|
14
|
+
|
|
11
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
|
|
12
17
|
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); } }
|
|
18
|
+
|
|
13
19
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
20
|
+
|
|
14
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
|
+
|
|
15
23
|
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 } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
-
|
|
24
|
+
|
|
25
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
26
|
+
|
|
17
27
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
28
|
+
|
|
18
29
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
30
|
+
|
|
19
31
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
|
+
|
|
20
33
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
|
|
34
|
+
|
|
35
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
36
|
+
|
|
22
37
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
38
|
+
|
|
23
39
|
var BetterTween = /*#__PURE__*/function (_TWEEN$Tween) {
|
|
24
40
|
_inherits(BetterTween, _TWEEN$Tween);
|
|
41
|
+
|
|
25
42
|
var _super = _createSuper(BetterTween);
|
|
43
|
+
|
|
26
44
|
function BetterTween() {
|
|
27
45
|
var _this;
|
|
46
|
+
|
|
28
47
|
_classCallCheck(this, BetterTween);
|
|
48
|
+
|
|
29
49
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
50
|
args[_key] = arguments[_key];
|
|
31
51
|
}
|
|
52
|
+
|
|
32
53
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
54
|
+
|
|
33
55
|
_defineProperty(_assertThisInitialized(_this), "disposeMethods", []);
|
|
56
|
+
|
|
34
57
|
_defineProperty(_assertThisInitialized(_this), "onDispose", function (callback) {
|
|
35
58
|
_this.disposeMethods.push(callback);
|
|
59
|
+
|
|
36
60
|
return _assertThisInitialized(_this);
|
|
37
61
|
});
|
|
62
|
+
|
|
38
63
|
_defineProperty(_assertThisInitialized(_this), "play", function () {
|
|
39
64
|
_this.start();
|
|
65
|
+
|
|
40
66
|
_this.animationFrameDisposer = (0, _.requestAnimationFrameInterval)(function () {
|
|
41
67
|
return _this.update();
|
|
42
68
|
});
|
|
43
69
|
return _assertThisInitialized(_this);
|
|
44
70
|
});
|
|
71
|
+
|
|
45
72
|
_defineProperty(_assertThisInitialized(_this), "dispose", function () {
|
|
46
73
|
var _this$animationFrameD, _this2;
|
|
74
|
+
|
|
47
75
|
_this.stop();
|
|
76
|
+
|
|
48
77
|
(_this$animationFrameD = (_this2 = _this).animationFrameDisposer) === null || _this$animationFrameD === void 0 ? void 0 : _this$animationFrameD.call(_this2);
|
|
78
|
+
|
|
49
79
|
_this.disposeMethods.forEach(function (fn) {
|
|
50
80
|
return fn();
|
|
51
81
|
});
|
|
82
|
+
|
|
52
83
|
_this.disposeMethods = [];
|
|
84
|
+
|
|
53
85
|
_tween["default"].remove(_assertThisInitialized(_this));
|
|
54
86
|
});
|
|
87
|
+
|
|
55
88
|
return _this;
|
|
56
89
|
}
|
|
90
|
+
|
|
57
91
|
return _createClass(BetterTween);
|
|
58
92
|
}(_tween["default"].Tween);
|
|
93
|
+
|
|
59
94
|
exports.BetterTween = BetterTween;
|
|
95
|
+
|
|
60
96
|
function tweenProgress(duration) {
|
|
61
97
|
var easing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _tween["default"].Easing.Linear.None;
|
|
62
98
|
var tween = new BetterTween({
|
|
@@ -7,33 +7,39 @@ exports["default"] = void 0;
|
|
|
7
7
|
exports.getFrameTime = getFrameTime;
|
|
8
8
|
exports.nextFrame = nextFrame;
|
|
9
9
|
exports.requestAnimationFrameInterval = requestAnimationFrameInterval;
|
|
10
|
+
|
|
10
11
|
var _requestAnimationFrame = window.requestAnimationFrame || function (fn) {
|
|
11
12
|
return setTimeout(function () {
|
|
12
13
|
return fn(performance.now());
|
|
13
14
|
}, 16);
|
|
14
15
|
};
|
|
16
|
+
|
|
15
17
|
var _cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
|
18
|
+
|
|
16
19
|
var _default = _requestAnimationFrame;
|
|
17
20
|
exports["default"] = _default;
|
|
21
|
+
|
|
18
22
|
function nextFrame(fn) {
|
|
19
23
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
20
24
|
if (delay <= 0) _requestAnimationFrame(fn);else _requestAnimationFrame(function () {
|
|
21
25
|
return nextFrame(fn, delay - 1);
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
|
-
|
|
25
28
|
/**
|
|
26
29
|
* 在每个 AnimationFrame 中调用传入的函数
|
|
27
30
|
* @param callback 每次 AnimationFrame 中调用的函数
|
|
28
31
|
* @param frame 每秒运行多少次
|
|
29
32
|
* @returns 返回一个函数,调用可以停止 AnimationFrameLoop
|
|
30
33
|
*/
|
|
34
|
+
|
|
35
|
+
|
|
31
36
|
function requestAnimationFrameInterval(callback) {
|
|
32
37
|
var frame = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60;
|
|
33
38
|
var index = -1;
|
|
34
39
|
var oldTime = 0;
|
|
35
40
|
var startTime = -1;
|
|
36
41
|
var minDeltaTime = 1000 / frame;
|
|
42
|
+
|
|
37
43
|
function loop(time) {
|
|
38
44
|
startTime === -1 && (startTime = time);
|
|
39
45
|
index = _requestAnimationFrame(loop);
|
|
@@ -42,16 +48,18 @@ function requestAnimationFrameInterval(callback) {
|
|
|
42
48
|
oldTime = time;
|
|
43
49
|
callback && callback(time - startTime);
|
|
44
50
|
}
|
|
51
|
+
|
|
45
52
|
index = _requestAnimationFrame(loop);
|
|
46
53
|
return function stop() {
|
|
47
54
|
_cancelAnimationFrame(index);
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
|
-
|
|
51
57
|
/**
|
|
52
58
|
* 获取两个 AnimationFrame 间隔的时间
|
|
53
59
|
* @returns 返回一个 Promise,resolve 的结果是两个 AnimationFrame 间隔的时间
|
|
54
60
|
*/
|
|
61
|
+
|
|
62
|
+
|
|
55
63
|
function getFrameTime() {
|
|
56
64
|
var start = Date.now();
|
|
57
65
|
return new Promise(function (resolve) {
|