/** * Name: Metaverse * Date: 2022/4/9 * Author: https://www.4dkankan.com * Copyright © 2022 4DAGE Co., Ltd. All rights reserved. * Licensed under the GLP license */ (function (factory) { typeof define === 'function' && define.amd ? define(factory) : factory(); })((function () { 'use strict'; 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); } } 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); }); }; } function createCommonjsModule(fn) { var module = { exports: {} }; return fn(module, module.exports), module.exports; } /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var runtime_1 = createCommonjsModule(function (module) { var runtime = (function (exports) { var Op = Object.prototype; var hasOwn = Op.hasOwnProperty; var undefined$1; // More compressible than void 0. var $Symbol = typeof Symbol === "function" ? Symbol : {}; var iteratorSymbol = $Symbol.iterator || "@@iterator"; var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); return obj[key]; } try { // IE 8 has a broken Object.defineProperty that only works on DOM objects. define({}, ""); } catch (err) { define = function(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; var generator = Object.create(protoGenerator.prototype); var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, // .throw, and .return methods. generator._invoke = makeInvokeMethod(innerFn, self, context); return generator; } exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion // record like context.tryEntries[i].completion. This interface could // have been (and was previously) designed to take a closure to be // invoked without arguments, but in all the cases we care about we // already have an existing method we want to call, so there's no need // to create a new function object. We can even get away with assuming // the method takes exactly one argument, since that happens to be true // in every case, so we don't have to touch the arguments object. The // only additional allocation required is the completion record, which // has a stable shape and so hopefully should be cheap to allocate. 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"; // Returning this object from the innerFn has the same effect as // breaking out of the dispatch switch statement. var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and // .constructor.prototype properties for functions that return Generator // objects. For full spec compliance, you may wish to configure your // minifier not to mangle the names of these two functions. function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that // don't natively support it. var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf; var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { // This environment has a native %IteratorPrototype%; use it instead // of the polyfill. IteratorPrototype = NativeIteratorPrototype; } var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); GeneratorFunction.prototype = GeneratorFunctionPrototype; define(Gp, "constructor", GeneratorFunctionPrototype); define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); GeneratorFunction.displayName = define( GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction" ); // Helper for defining the .next, .throw, and .return methods of the // Iterator interface in terms of a single ._invoke method. function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function(method) { define(prototype, method, function(arg) { return this._invoke(method, arg); }); }); } exports.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; }; exports.mark = function(genFun) { if (Object.setPrototypeOf) { Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); } else { genFun.__proto__ = GeneratorFunctionPrototype; define(genFun, toStringTagSymbol, "GeneratorFunction"); } genFun.prototype = Object.create(Gp); return genFun; }; // Within the body of any async function, `await x` is transformed to // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test // `hasOwn.call(value, "__await")` to determine if the yielded value is // meant to be awaited. exports.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(value) { invoke("next", value, resolve, reject); }, function(err) { invoke("throw", err, resolve, reject); }); } return PromiseImpl.resolve(value).then(function(unwrapped) { // When a yielded Promise is resolved, its final value becomes // the .value of the Promise<{value,done}> result for the // current iteration. result.value = unwrapped; resolve(result); }, function(error) { // If a rejected Promise was yielded, throw the rejection back // into the async generator function so it can be handled there. 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(); } // Define the unified helper method that is used to implement .next, // .throw, and .return (see defineIteratorMethods). this._invoke = enqueue; } defineIteratorMethods(AsyncIterator.prototype); define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }); exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of // AsyncIterator objects; they just return a Promise for the value of // the final result produced by the iterator. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { if (PromiseImpl === void 0) PromiseImpl = Promise; var iter = new AsyncIterator( wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl ); return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. : iter.next().then(function(result) { return result.done ? result.value : iter.next(); }); }; function makeInvokeMethod(innerFn, self, 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; } // Be forgiving, per 25.3.3.3.3 of the spec: // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume 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") { // Setting context._sent for legacy support of Babel's // function.sent implementation. 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, self, context); if (record.type === "normal") { // If an exception is thrown from innerFn, we leave state === // GenStateExecuting and loop back for another invocation. state = context.done ? GenStateCompleted : GenStateSuspendedYield; if (record.arg === ContinueSentinel) { continue; } return { value: record.arg, done: context.done }; } else if (record.type === "throw") { state = GenStateCompleted; // Dispatch the exception by looping back around to the // context.dispatchException(context.arg) call above. context.method = "throw"; context.arg = record.arg; } } }; } // Call delegate.iterator[context.method](context.arg) and handle the // result, either by returning a { value, done } result from the // delegate iterator, or by modifying context.method and context.arg, // setting context.delegate to null, and returning the ContinueSentinel. function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (method === undefined$1) { // A .throw or .return when the delegate iterator has no .throw // method always terminates the yield* loop. context.delegate = null; if (context.method === "throw") { // Note: ["return"] must be used for ES3 parsing compatibility. if (delegate.iterator["return"]) { // If the delegate iterator has a return method, give it a // chance to clean up. context.method = "return"; context.arg = undefined$1; maybeInvokeDelegate(delegate, context); if (context.method === "throw") { // If maybeInvokeDelegate(context) changed context.method from // "return" to "throw", let that override the TypeError below. 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) { // Assign the result of the finished delegate to the temporary // variable specified by delegate.resultName (see delegateYield). context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the // exception, let the outer generator proceed normally. If // context.method was "next", forget context.arg since it has been // "consumed" by the delegate iterator. If context.method was // "return", allow the original .return call to continue in the // outer generator. if (context.method !== "return") { context.method = "next"; context.arg = undefined$1; } } else { // Re-yield the result returned by the delegate method. return info; } // The delegate iterator is finished, so forget it and continue with // the outer generator. context.delegate = null; return ContinueSentinel; } // Define Generator.prototype.{next,throw,return} in terms of the // unified ._invoke helper method. defineIteratorMethods(Gp); define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the // @@iterator function is called on it. Some browsers' implementations of the // iterator prototype chain incorrectly implement this, causing the Generator // object to not be returned from this call. This ensures that doesn't happen. // See https://github.com/facebook/regenerator/issues/274 for more details. define(Gp, iteratorSymbol, function() { return this; }); define(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) { // The root entry object (effectively a try statement without a catch // or a finally block) gives us a place to store values thrown from // locations where there is no enclosing try statement. this.tryEntries = [{ tryLoc: "root" }]; tryLocsList.forEach(pushTryEntry, this); this.reset(true); } exports.keys = function(object) { var keys = []; for (var key in object) { keys.push(key); } keys.reverse(); // Rather than returning an object with a next method, we keep // things simple and return the next function itself. return function next() { while (keys.length) { var key = keys.pop(); if (key in object) { next.value = key; next.done = false; return next; } } // To avoid creating an additional object, we just hang the .value // and .done properties off the next function object itself. This // also ensures that the minifier will not anonymize the function. 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 next() { while (++i < iterable.length) { if (hasOwn.call(iterable, i)) { next.value = iterable[i]; next.done = false; return next; } } next.value = undefined$1; next.done = true; return next; }; return next.next = next; } } // Return an iterator with no values. return { next: doneResult }; } exports.values = values; function doneResult() { return { value: undefined$1, done: true }; } Context.prototype = { constructor: Context, reset: function(skipTempReset) { this.prev = 0; this.next = 0; // Resetting context._sent for legacy support of Babel's // function.sent implementation. 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) { // Not sure about the optimal order of these conditions: 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) { // If the dispatched exception was caught by a catch block, // then let that catch block handle the exception normally. 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") { // Exception thrown outside of any try block that could handle // it, so set the completion value of the entire function to // throw the exception. 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) { // Ignore the finally entry if control is not jumping to a // location outside the try/catch block. 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; } } // The context.catch method must only be called with a location // argument that corresponds to a known catch block. throw new Error("illegal catch attempt"); }, delegateYield: function(iterable, resultName, nextLoc) { this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }; if (this.method === "next") { // Deliberately forget the last sent value so that we don't // accidentally pass it on to the delegate. this.arg = undefined$1; } return ContinueSentinel; } }; // Regardless of whether this script is executing as a CommonJS module // or not, return the runtime object so that we can declare the variable // regeneratorRuntime in the outer scope, which allows this module to be // injected easily by `bin/regenerator --include-runtime script.js`. return exports; }( // 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. module.exports )); try { regeneratorRuntime = runtime; } catch (accidentalStrictMode) { // This module should not be running in strict mode, so the above // assignment should always work unless something is misconfigured. Just // in case runtime.js accidentally runs in strict mode, in modern engines // we can explicitly access globalThis. In older engines we can escape // strict mode using a global Function call. This could conceivably fail // if a Content Security Policy forbids using Function, but in that case // the proper solution is to fix the accidental strict mode problem. If // you've misconfigured your bundler to force strict mode and applied a // CSP to forbid Function, and you're not willing to fix either of those // problems, please detail your unique predicament in a GitHub issue. if (typeof globalThis === "object") { globalThis.regeneratorRuntime = runtime; } else { Function("r", "regeneratorRuntime = r")(runtime); } } }); var regenerator = runtime_1; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } var util = { uuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) { var e = Math.random() * 16 | 0; return (i === "x" ? e : e & 3 | 8).toString(16); }); }, getFormattedDate(i) { var e = i.getMonth() + 1, t = i.getDate(), r = i.getHours(), n = i.getMinutes(), o = i.getSeconds(), a = i.getMilliseconds(), s = (e < 10 ? "0" : "") + e, l = (t < 10 ? "0" : "") + t, u = (r < 10 ? "0" : "") + r, c = (n < 10 ? "0" : "") + n, h = (o < 10 ? "0" : "") + o; return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a; }, createInstance(i) { var e = new Axios(i), t = bind(Axios.prototype.request, e); return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) { return createInstance(mergeConfig(i, n)); }, t; }, mapLimit(i, e, t) { return new Promise(function (r, n) { var o = i.length; var a = e - 1, s = 0; var l = function l(u) { u.forEach(function (c) { t(c).then(function () { if (s++, s === o) { r(); return; } a++; var h = i[a]; h && l([h]); }, function (h) { n(h); }); }); }; l(i.slice(0, e)); }); } }; function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 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); } 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); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 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); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); 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); }; } function _isNativeReflectConstruct$2() { 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; } } var Reporter = /*#__PURE__*/function (_EventEmitter) { _inherits(Reporter, _EventEmitter); var _super = _createSuper$2(Reporter); function Reporter() { var _this; _classCallCheck(this, Reporter); _this = _super.call(this); _this._header = {}; _this._body = {}; _this._queue = []; _this._disabled = !1; _this._interval = null; _this._reportUrl = null; _this.isDocumentLoaded = function () { return document.readyState === "complete"; }; _this._header.logModuleId = REPORT_MODULE_TYPE, _this._header.url = location.href, _this._header.enviroment = ENV, _this._header.networkType = window.navigator.connection ? window.navigator.connection.type : "unknown", _this._interval = window.setInterval(function () { _this._flushReport(); }, 10 * 1e3); return _this; } _createClass(Reporter, [{ key: "disable", value: function disable() { this._disabled = !0, this._interval && window.clearInterval(this._interval); } }, { key: "updateHeader", value: function updateHeader(e) { Object.assign(this._header, e); } }, { key: "updateBody", value: function updateBody(e) { Object.assign(this._body, e); } }, { key: "updateReportUrl", value: function updateReportUrl(e) { this._reportUrl = e; } }, { key: "report", value: function report(e, t, r) { var _this2 = this; if (this._disabled) return; r || (r = {}); var _r = r, n = _r.immediate, o = _r.sampleRate; if (o && o > Math.random()) return; this.updateBody({ logTime: util.getFormattedDate(new Date()), logTimestamp: Date.now() }); var a = function a(s) { var l = oe(le(oe({}, _this2._body), { type: e }), s); _this2._queue.push(l), e === "measurement" && _this2.emit("report", s); }; Array.isArray(t) ? t.forEach(function (s) { return a(s); }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport(); } }, { key: "_flushReport", value: function _flushReport() { if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return; var e = { header: this._header, body: this._queue.splice(0, REPORT_NUM_PER_REQUEST) }; this._post(e); } }, { key: "_post", value: function _post(e) { var t = this._reportUrl || REPORT_URL.DEV; return new Promise(function (r, n) { var o = new XMLHttpRequest(); o.open("POST", t), o.setRequestHeader("Content-Type", "application/json"); try { o.send(JSON.stringify(e)); } catch (a) { console.error(a); } o.addEventListener("readystatechange", function () { if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log"); }); }); } }]); return Reporter; }(EventEmitter); var reporter = new Reporter(); 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; } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } 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); } 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."); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } var Codes = { Success: 0, Param: 1001, Internal: 1002, Timeout: 1003, Authentication: 1004, TokenExpired: 1005, Unsupported: 1006, InitNetworkTimeout: 1007, InitDecoderTimeout: 1008, InitConfigTimeout: 1009, InitEngineTimeout: 1010, InitEngine: 1011, ActionBlocked: 1012, PreloadCanceled: 1013, FrequencyLimit: 1014, UsersUpperLimit: 2e3, RoomsUpperLimit: 2001, ServerParam: 2002, LackOfToken: 2003, LoginFailed: 2004, VerifyServiceDown: 2005, CreateSessionFailed: 2006, RtcConnection: 2008, DoActionFailed: 2009, StateSyncFailed: 2010, BroadcastFailed: 2011, DataAbnormal: 2012, GetOnVehicle: 2015, RepeatLogin: 2017, RoomDoseNotExist: 2018, TicketExpire: 2019, ServerRateLimit: 2020, DoActionBlocked: 2333, ActionMaybeDelay: 2334, ActionResponseTimeout: 2999 }; var Logger$1 = /*#__PURE__*/function () { function Logger(e) { _classCallCheck(this, Logger); this.level = 3; this.module = e; } _createClass(Logger, [{ key: "setLevel", value: function setLevel(e) { this.level = e; } }, { key: "atleast", value: function atleast(e) { return e >= this.level && e >= this.level; } }, { key: "print", value: function print(e, t) { for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { r[_key - 2] = arguments[_key]; } if (this.atleast(t)) { var _console$n; var n = e == "debug" ? "info" : e, o = this.prefix(e); (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r)); } if (e !== "debug" && e !== "info") { var _n = r.map(function (o) { if (o instanceof Object) try { return JSON.stringify(o); } catch (_unused) { return o; } else return o; }).join(","); reporter.report("log", { message: _n, level: e, module: this.module }); } } }, { key: "debug", value: function debug() { for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { e[_key2] = arguments[_key2]; } return this.print.apply(this, ["debug", 1].concat(e)); } }, { key: "info", value: function info() { for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { e[_key3] = arguments[_key3]; } return this.print.apply(this, ["info", 2].concat(e)); } }, { key: "infoAndReportLog", value: function infoAndReportLog(e) { for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { t[_key4 - 1] = arguments[_key4]; } var r = e.reportOptions; delete e.reportOptions, reporter.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t)); } }, { key: "infoAndReportMeasurement", value: function infoAndReportMeasurement(e) { for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { t[_key5 - 1] = arguments[_key5]; } var n; var r = e.reportOptions; if (e.startTime) { var o = Date.now(); e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime); } if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes.Internal : e.code = Codes.Success, reporter.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) { this.error.apply(this, _toConsumableArray(t)); return; } this.warn.apply(this, _toConsumableArray(t)); } }, { key: "warn", value: function warn() { for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { e[_key6] = arguments[_key6]; } return this.print.apply(this, ["warn", 3].concat(e)); } }, { key: "error", value: function error() { for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { e[_key7] = arguments[_key7]; } return this.print.apply(this, ["error", 4].concat(e)); } }, { key: "prefix", value: function prefix(e) { return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":"); } }], [{ key: "setLevel", value: function setLevel(e) { this.level = e; } }]); return Logger; }(); var logger = new Logger$1(); var BaseTable = /*#__PURE__*/function () { function BaseTable(e, t) { _classCallCheck(this, BaseTable); this.db = null; this.isCreatingTable = !1; this.hasCleared = !1; this.dbName = e, this.dbVersion = t; } _createClass(BaseTable, [{ key: "clearDataBase", value: function () { var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) { var _this = this; return regenerator.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) { var n = window.indexedDB.deleteDatabase(_this.dbName); n.onsuccess = function () { t(); }, n.onerror = r; })); case 1: case "end": return _context.stop(); } } }, _callee, this); })); function clearDataBase(_x) { return _clearDataBase.apply(this, arguments); } return clearDataBase; }() }, { key: "tableName", value: function tableName() { throw new Error("Derived class have to override 'tableName', and set a proper table name!"); } }, { key: "keyPath", value: function keyPath() { throw new Error("Derived class have to override 'keyPath', and set a proper index name!"); } }, { key: "index", value: function index() { throw new Error("Derived class have to override 'index', and set a proper index name!"); } }, { key: "checkAndOpenDatabase", value: function () { var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() { var _this2 = this; return regenerator.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) { var n = setTimeout(function () { logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n); }, 200); _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () { _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n); }, function () { t(new Error("Failed to open database!")), clearTimeout(n); }, function () { _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)); }); })); case 1: case "end": return _context2.stop(); } } }, _callee2, this); })); function checkAndOpenDatabase() { return _checkAndOpenDatabase.apply(this, arguments); } return checkAndOpenDatabase; }() }, { key: "openDatabase", value: function openDatabase(e, t, r, n, o) { var _this3 = this; if (this.isCreatingTable) return; this.isCreatingTable = !0, logger.info(e, t); var a = window.indexedDB.open(e, t), s = this.tableName(); a.onsuccess = function (l) { _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l); }, a.onerror = function (l) { var u; logger.error("Failed to open database", (u = l == null ? void 0 : l.srcElement) == null ? void 0 : u.error), _this3.isCreatingTable = !1, n && n(l), _this3.clearDataBase(!0); }, a.onupgradeneeded = function (l) { var u = l.target.result, c = _this3.index(); logger.info("Creating table ".concat(s, ".")); var h = u.objectStoreNames.contains(s); if (h) h = u.transaction([s], "readwrite").objectStore(s);else { var f = _this3.keyPath(); h = u.createObjectStore(s, { keyPath: f }); } c.map(function (f) { h.createIndex(f, f, { unique: !1 }); }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l); }; } }, { key: "add", value: function () { var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) { var t, o; return regenerator.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: t = this.tableName(); _context3.next = 3; return this.checkAndOpenDatabase(); case 3: o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e); return _context3.abrupt("return", new Promise(function (a, s) { o.onsuccess = function (l) { a(l); }, o.onerror = function (l) { var u; logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l); }; })); case 5: case "end": return _context3.stop(); } } }, _callee3, this); })); function add(_x2) { return _add.apply(this, arguments); } return add; }() }, { key: "put", value: function () { var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) { var t, o; return regenerator.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: t = this.tableName(); _context4.next = 3; return this.checkAndOpenDatabase(); case 3: o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e); return _context4.abrupt("return", new Promise(function (a, s) { o.onsuccess = function (l) { a(l); }, o.onerror = function (l) { var u; logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l); }; })); case 5: case "end": return _context4.stop(); } } }, _callee4, this); })); function put(_x3) { return _put.apply(this, arguments); } return put; }() }, { key: "delete", value: function _delete(e, t, r) { var n = this.tableName(); this.checkAndOpenDatabase().then(function (o) { var s = o.transaction([n], "readwrite").objectStore(n).delete(e); s.onsuccess = t, s.onerror = r; }); } }, { key: "update", value: function update() { this.checkAndOpenDatabase().then(function (e) {}); } }, { key: "getAllKeys", value: function () { var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() { var e, t; return regenerator.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: e = this.tableName(); _context5.next = 3; return this.checkAndOpenDatabase(); case 3: t = _context5.sent; return _context5.abrupt("return", new Promise(function (r, n) { var a = t.transaction([e], "readonly").objectStore(e).getAllKeys(); a.onsuccess = function (s) { r(s.target.result); }, a.onerror = function (s) { logger.error("db getAllKeys error", s), n(s); }; })); case 5: case "end": return _context5.stop(); } } }, _callee5, this); })); function getAllKeys() { return _getAllKeys.apply(this, arguments); } return getAllKeys; }() }, { key: "query", value: function () { var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) { var r, n; return regenerator.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: r = this.tableName(); _context6.next = 3; return this.checkAndOpenDatabase(); case 3: n = _context6.sent; return _context6.abrupt("return", new Promise(function (o, a) { var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t); u.onsuccess = function (c) { var f; var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result; o && o(h); }, u.onerror = function (c) { logger.error("db query error", c), a(c); }; })); case 5: case "end": return _context6.stop(); } } }, _callee6, this); })); function query(_x4, _x5) { return _query.apply(this, arguments); } return query; }() }, { key: "sleep", value: function () { var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) { return regenerator.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: return _context7.abrupt("return", new Promise(function (t) { setTimeout(function () { t(""); }, e); })); case 1: case "end": return _context7.stop(); } } }, _callee7); })); function sleep(_x6) { return _sleep.apply(this, arguments); } return sleep; }() }]); return BaseTable; }(); function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); 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); }; } function _isNativeReflectConstruct$1() { 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; } } var ModelTable = /*#__PURE__*/function (_BaseTable) { _inherits(ModelTable, _BaseTable); var _super = _createSuper$1(ModelTable); function ModelTable() { _classCallCheck(this, ModelTable); return _super.call(this, "XverseDatabase", 1); } _createClass(ModelTable, [{ key: "tableName", value: function tableName() { return "models"; } }, { key: "index", value: function index() { return ["url"]; } }, { key: "keyPath", value: function keyPath() { return "url"; } }]); return ModelTable; }(BaseTable); var modelTable = new ModelTable(); var AxiosCanceler = /*#__PURE__*/function () { function AxiosCanceler() { _classCallCheck(this, AxiosCanceler); this.pendingMap = new Map(); } _createClass(AxiosCanceler, [{ key: "addPending", value: function addPending(e) { var _this = this; return new axios.CancelToken(function (t) { _this.pendingMap.has(e) || _this.pendingMap.set(e, t); }); } }, { key: "removeAllPending", value: function removeAllPending() { this.pendingMap.forEach(function (e) { e && isFunction(e) && e(); }), this.pendingMap.clear(); } }, { key: "removePending", value: function removePending(e) { if (this.pendingMap.has(e)) { var t = this.pendingMap.get(e); t && t(e), this.pendingMap.delete(e); } } }, { key: "removeCancelToken", value: function removeCancelToken(e) { this.pendingMap.has(e) && this.pendingMap.delete(e); } }, { key: "reset", value: function reset() { this.pendingMap = new Map(); } }]); return AxiosCanceler; }(); 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); }; } 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; } } var Http1 = /*#__PURE__*/function (_EventEmitter) { _inherits(Http1, _EventEmitter); var _super = _createSuper(Http1); function Http1() { var _this; _classCallCheck(this, Http1); _this = _super.call(this); _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler(); return _this; } _createClass(Http1, [{ key: "requestConstant", value: function requestConstant() { return { x_nounce: this.randomString(), x_timestamp: new Date().getTime(), x_os: "web" }; } }, { key: "requestParams", value: function requestParams(e) { return oe({}, e.params); } }, { key: "get", value: function get(e) { return this.request(le(oe({}, e), { method: "GET" })); } }, { key: "post", value: function post(e) { return this.request(le(oe({}, e), { method: "POST" })); } }, { key: "request", value: function request(e) { var _this2 = this; var t = e.url, _e$timeout = e.timeout, r = _e$timeout === void 0 ? 1e4 : _e$timeout, n = e.method, o = e.key, a = e.beforeRequest, s = e.responseType, l = e.data; var _e$retry = e.retry, u = _e$retry === void 0 ? 0 : _e$retry; var c = this.patchUrl(t), h = this.canceler.addPending(t); a && isFunction(a) && a(e); var f = this.requestParams(e); var d = { url: c, method: n, timeout: r, cancelToken: h, responseType: s, params: f }; n === "POST" && (d = oe({ data: l }, d)); var _ = Date.now(), g = function g() { return _this2.instatnce.request(d).then(function (m) { return o && logger.infoAndReportMeasurement({ metric: "http", startTime: _, extra: t, group: "http", tag: o }), _this2.canceler.removeCancelToken(t), m; }).catch(function (m) { var v = axios.isCancel(m); return u > 0 && !v ? (u--, logger.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger.infoAndReportMeasurement({ metric: "http", startTime: _, error: m, extra: { url: t, isCanceled: v }, tag: o, group: "http" }), _this2.canceler.removeCancelToken(t), Promise.reject(m)); }); }; return g(); } }, { key: "patchUrl", value: function patchUrl(e) { return e; } }, { key: "randomString", value: function randomString() { var e = ""; var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", r = t.length; for (var n = 0; n < 8; n++) { e += t.charAt(Math.floor(Math.random() * r)); } return e; } }]); return Http1; }(EventEmitter); var http1 = new Http1(); var ModelManager = /*#__PURE__*/function () { function ModelManager(e, t) { _classCallCheck(this, ModelManager); this.avatarModelList = []; this.skinList = []; this.applicationConfig = null; this.config = null; this.appId = e, this.releaseId = t; } _createClass(ModelManager, [{ key: "findSkinConfig", value: function () { var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) { var t, n; return regenerator.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: t = null; _context.next = 3; return this.getSkinsList(); case 3: t = (this.skinList = _context.sent).find(function (n) { return n.id === e; }); if (!t) { _context.next = 6; break; } return _context.abrupt("return", t); case 6: n = "skin is invalid: skinId: ".concat(e); return _context.abrupt("return", Promise.reject(new ParamError(n))); case 8: case "end": return _context.stop(); } } }, _callee, this); })); function findSkinConfig(_x) { return _findSkinConfig.apply(this, arguments); } return findSkinConfig; }() }, { key: "findRoute", value: function () { var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) { var n, o; return regenerator.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _context2.next = 2; return this.findSkinConfig(e); case 2: n = _context2.sent.routeList.find(function (o) { return o.pathName === t; }); if (n) { _context2.next = 6; break; } o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t); return _context2.abrupt("return", Promise.reject(new ParamError(o))); case 6: return _context2.abrupt("return", (logger.debug("find route success", n), n)); case 7: case "end": return _context2.stop(); } } }, _callee2, this); })); function findRoute(_x2, _x3) { return _findRoute.apply(this, arguments); } return findRoute; }() }, { key: "findAssetList", value: function () { var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) { var r, n; return regenerator.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return this.findSkinConfig(e); case 2: r = _context3.sent.assetList; if (r) { _context3.next = 6; break; } n = "find path failed: skinId: ".concat(e); return _context3.abrupt("return", Promise.reject(new ParamError(n))); case 6: return _context3.abrupt("return", (logger.debug("find route success", r), r)); case 7: case "end": return _context3.stop(); } } }, _callee3, this); })); function findAssetList(_x4) { return _findAssetList.apply(this, arguments); } return findAssetList; }() }, { key: "findAsset", value: function () { var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) { var r, n, o, a, _args4 = arguments; return regenerator.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id"; _context4.next = 3; return this.findSkinConfig(e); case 3: n = _context4.sent; if (!Array.isArray(t)) { _context4.next = 6; break; } return _context4.abrupt("return", t.map(function (a) { return n.models.find(function (s) { return s[r] === a; }); }).filter(Boolean)); case 6: o = n.models.find(function (a) { return a[r] === t; }); if (o) { _context4.next = 10; break; } a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t); return _context4.abrupt("return", Promise.reject(new ParamError(a))); case 10: return _context4.abrupt("return", (logger.debug("find asset success", o), o)); case 11: case "end": return _context4.stop(); } } }, _callee4, this); })); function findAsset(_x5, _x6) { return _findAsset.apply(this, arguments); } return findAsset; }() }, { key: "findPoint", value: function () { var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) { var n, o; return regenerator.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _context5.next = 2; return this.findSkinConfig(e); case 2: n = _context5.sent.pointList.find(function (o) { return o.id === t; }); if (n) { _context5.next = 6; break; } o = "find point failed: skinId: ".concat(e, ", id: ").concat(t); return _context5.abrupt("return", Promise.reject(new ParamError(o))); case 6: return _context5.abrupt("return", (logger.debug("find point success", n), n)); case 7: case "end": return _context5.stop(); } } }, _callee5, this); })); function findPoint(_x7, _x8) { return _findPoint.apply(this, arguments); } return findPoint; }() }, { key: "requestConfig", value: function () { var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() { var t, r, _ref, n, o; return regenerator.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: if (!this.config) { _context6.next = 2; break; } return _context6.abrupt("return", this.config); case 2: // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`; // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`); // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e; t = './assets/config.json'; _context6.prev = 3; _context6.next = 6; return http1.get({ url: "".concat(t, "?t=").concat(Date.now()), key: "config", timeout: 6e3, retry: 2 }); case 6: r = _context6.sent; _ref = r.data.data || {}, n = _ref.config, o = _ref.preload; if (n) { _context6.next = 10; break; } throw new Error("config data parse error" + r.data); case 10: return _context6.abrupt("return", (this.config = { config: n, preload: o }, logger.debug("get config success", this.config), this.config)); case 13: _context6.prev = 13; _context6.t0 = _context6["catch"](3); return _context6.abrupt("return", Promise.reject(_context6.t0)); case 16: case "end": return _context6.stop(); } } }, _callee6, this, [[3, 13]]); })); function requestConfig() { return _requestConfig.apply(this, arguments); } return requestConfig; }() }, { key: "getApplicationConfig", value: function () { var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() { var e; return regenerator.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: if (!this.applicationConfig) { _context7.next = 2; break; } return _context7.abrupt("return", this.applicationConfig); case 2: _context7.prev = 2; _context7.next = 5; return this.requestConfig(); case 5: e = _context7.sent; return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig)); case 9: _context7.prev = 9; _context7.t0 = _context7["catch"](2); return _context7.abrupt("return", Promise.reject(_context7.t0)); case 12: case "end": return _context7.stop(); } } }, _callee7, this, [[2, 9]]); })); function getApplicationConfig() { return _getApplicationConfig.apply(this, arguments); } return getApplicationConfig; }() }, { key: "getAvatarModelList", value: function () { var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() { var _yield$this$getApplic, e; return regenerator.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: if (!this.avatarModelList.length) { _context8.next = 2; break; } return _context8.abrupt("return", this.avatarModelList); case 2: _context8.prev = 2; _context8.next = 5; return this.getApplicationConfig(); case 5: _yield$this$getApplic = _context8.sent; e = _yield$this$getApplic.avatars; return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) { return { name: t.name, id: t.id, modelUrl: t.url, gender: t.gender, components: t.components }; }), this.avatarModelList)); case 10: _context8.prev = 10; _context8.t0 = _context8["catch"](2); return _context8.abrupt("return", (logger.error(_context8.t0), [])); case 13: case "end": return _context8.stop(); } } }, _callee8, this, [[2, 10]]); })); function getAvatarModelList() { return _getAvatarModelList.apply(this, arguments); } return getAvatarModelList; }() }, { key: "getSkinsList", value: function () { var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() { var _yield$this$getApplic2, e; return regenerator.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: if (!this.skinList.length) { _context9.next = 2; break; } return _context9.abrupt("return", this.skinList); case 2: _context9.prev = 2; _context9.next = 5; return this.getApplicationConfig(); case 5: _yield$this$getApplic2 = _context9.sent; e = _yield$this$getApplic2.skins; return _context9.abrupt("return", (this.skinList = e.map(function (t) { var r; return { name: t.name, dataVersion: t.id + t.versionId, id: t.id, fov: parseInt(t.fov || 90), models: t.assetList.map(function (n) { var o = n.assetId, a = n.url, s = n.thumbnailUrl, l = n.typeName, u = n.className; return { id: o, modelUrl: a, name: n.name, thumbnailUrl: s, typeName: l, className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u }; }), routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) { var o = n.areaName, a = n.attitude, s = n.id, l = n.pathName, u = n.step, c = n.birthPointList; return { areaName: o, attitude: a, id: s, pathName: l, step: u, birthPointList: c.map(function (h) { return { camera: h.camera && { position: objectParseFloat(h.camera.position), angle: objectParseFloat(h.camera.rotation) }, player: h.player && { position: objectParseFloat(h.player.position), angle: objectParseFloat(h.player.rotation) } }; }) }; }), pointList: t.pointList.map(function (n) { return le(oe({}, n), { position: objectParseFloat(n.position), rotation: objectParseFloat(n.rotation) }); }), versionId: t.versionId, isEnable: t.isEnable, assetList: t.assetList, visibleRules: t.visibleRules, animationList: t.animationList }; }), this.skinList)); case 10: _context9.prev = 10; _context9.t0 = _context9["catch"](2); return _context9.abrupt("return", (logger.error(_context9.t0), [])); case 13: case "end": return _context9.stop(); } } }, _callee9, this, [[2, 10]]); })); function getSkinsList() { return _getSkinsList.apply(this, arguments); } return getSkinsList; }() }, { key: "getBreathPointTextrueList", value: function () { var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { return regenerator.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: return _context10.abrupt("return", [{ url: TEXTURE_URL }]); case 1: case "end": return _context10.stop(); } } }, _callee10); })); function getBreathPointTextrueList() { return _getBreathPointTextrueList.apply(this, arguments); } return getBreathPointTextrueList; }() }], [{ key: "getInstance", value: function getInstance(e, t) { //getInstance(e, t) { return this.instance || (this.instance = new ModelManager(e, t)), this.instance; } }, { key: "findModels", value: function findModels(e, t, r) { //findModels(e, t, r) { return e.filter(function (o) { return o.typeName === t && o.className === r; }); } }, { key: "findModel", value: function findModel(e, t, r) { //findModel(e, t, r) { var n = e.filter(function (o) { return o.typeName === t && o.className === r; })[0]; return n || null; } }]); return ModelManager; }(); // export { modelManager }; var Preload = /*#__PURE__*/function () { function Preload(e) { _classCallCheck(this, Preload); this.config = null; this.allKeys = []; this.oldResourcesDeleted = !1; this.requests = { simple: { stopped: !0, requests: {} }, observer: { stopped: !0, requests: {} }, full: { stopped: !0, requests: {} } }; this.modelManager = e, this.init(e.appId); } _createClass(Preload, [{ key: "init", value: function init(e) { reporter.updateBody({ appId: e }); } }, { key: "getConfig", value: function () { var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) { var _yield$this$modelMana, t; return regenerator.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: if (!this.config) { _context.next = 2; break; } return _context.abrupt("return", this.config); case 2: _context.next = 4; return this.modelManager.requestConfig(); case 4: _yield$this$modelMana = _context.sent; t = _yield$this$modelMana.preload; return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config")); case 7: case "end": return _context.stop(); } } }, _callee, this); })); function getConfig(_x) { return _getConfig.apply(this, arguments); } return getConfig; }() }, { key: "getAllKeys", value: function () { var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() { var e, t; return regenerator.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!this.allKeys.length) { _context2.next = 2; break; } return _context2.abrupt("return", this.allKeys); case 2: _context2.prev = 2; _context2.next = 5; return modelTable.getAllKeys(); case 5: e = _context2.sent; this.allKeys = e; return _context2.abrupt("return", e); case 10: _context2.prev = 10; _context2.t0 = _context2["catch"](2); t = "preload getAllKeys error"; return _context2.abrupt("return", (logger.error(t), Promise.reject(t))); case 14: case "end": return _context2.stop(); } } }, _callee2, this, [[2, 10]]); })); function getAllKeys() { return _getAllKeys.apply(this, arguments); } return getAllKeys; }() }, { key: "stop", value: function stop(e) { e === "serverless" && (e = "observer"), this.requests[e].stopped = !0; var t = this.requests[e].requests; Object.keys(t).forEach(function (r) { http1.canceler.removePending(r), delete t[r]; }); } }, { key: "clearPreload", value: function clearPreload(e) { this.requests[e].stopped = !1, this.allKeys = []; } }, { key: "start", value: function () { var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) { var n, o, a, s, l, u, h, f, _s; return regenerator.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: n = Date.now(), o = 0; _context3.prev = 1; if (!(e === "serverless" && (e = "observer"), !this.requests[e])) { _context3.next = 4; break; } return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e))); case 4: this.clearPreload(e); _context3.next = 7; return this.getConfig(e); case 7: a = _context3.sent; _context3.next = 10; return this.getAllKeys(); case 10: s = _context3.sent; _context3.prev = 11; _context3.next = 14; return this.deleteOldResources(a.assetUrls.map(function (d) { return d.url; }), s); case 14: _context3.next = 19; break; case 16: _context3.prev = 16; _context3.t0 = _context3["catch"](11); logger.error(_context3.t0); case 19: l = a.baseUrls, u = a.assetUrls; _context3.t1 = e; _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29; break; case 23: h = l; return _context3.abrupt("break", 30); case 25: h = u; return _context3.abrupt("break", 30); case 27: h = u; return _context3.abrupt("break", 30); case 29: h = u; case 30: f = h.filter(function (d) { return !s.includes(d.url); }); r && isFunction(r) && (f = f.filter(r)); o = f.length; logger.debug("keysNeedToPreload", f); f.length || t && t(h.length, h.length); n = Date.now(); _context3.next = 38; return this._preload(e, f, t); case 38: logger.infoAndReportMeasurement({ tag: e, startTime: n, metric: "assetsPreload", extra: { total: o } }); return _context3.abrupt("return"); case 42: _context3.prev = 42; _context3.t2 = _context3["catch"](1); _s = _context3.t2; return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({ tag: e, startTime: n, metric: "assetsPreload", extra: { total: o }, error: _s, reportOptions: { immediate: !0 } }), Promise.reject(_s))); case 46: case "end": return _context3.stop(); } } }, _callee3, this, [[1, 42], [11, 16]]); })); function start(_x2, _x3, _x4) { return _start.apply(this, arguments); } return start; }() }, { key: "deleteOldResources", value: function deleteOldResources(e, t) { if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve(); var r = t.filter(function (n) { return !e.includes(n); }); return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) { return modelTable.delete(n); })); } }, { key: "_preload", value: function () { var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) { var _this = this; var n, o, a; return regenerator.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: n = t.length; if (n) { _context6.next = 3; break; } return _context6.abrupt("return", Promise.resolve()); case 3: o = 0; a = window.setInterval(function () { r && r(o, n), o >= n && window.clearInterval(a); }, 1e3); return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) { var l, u; return regenerator.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: l = s.size, u = s.url; return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({ url: u, timeout: Preload.getTimeoutBySize(l), responseType: "blob", retry: 2, beforeRequest: function beforeRequest() { _this.requests[e].requests[u] = !0; } }).then( /*#__PURE__*/function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) { var h, f; return regenerator.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: h = c.data; if (h instanceof Blob) { _context4.next = 3; break; } return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u))); case 3: _context4.next = 5; return blobToDataURI(h); case 5: f = _context4.sent; _context4.prev = 6; _context4.next = 9; return modelTable.put({ url: u, model: f }); case 9: return _context4.abrupt("return"); case 12: _context4.prev = 12; _context4.t0 = _context4["catch"](6); return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error")))); case 15: case "end": return _context4.stop(); } } }, _callee4, null, [[6, 12]]); })); return function (_x9) { return _ref2.apply(this, arguments); }; }()).then(function () { o++, delete _this.requests[e].requests[u]; }, function (c) { return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c); })); case 2: case "end": return _context5.stop(); } } }, _callee5); })); return function (_x8) { return _ref.apply(this, arguments); }; }())); case 6: case "end": return _context6.stop(); } } }, _callee6); })); function _preload(_x5, _x6, _x7) { return _preload2.apply(this, arguments); } return _preload; }() }], [{ key: "getTimeoutBySize", value: function getTimeoutBySize(e) { return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3; } }]); return Preload; }(); var Xverse = /*#__PURE__*/function () { function Xverse(e) { _classCallCheck(this, Xverse); e || (e = {}); var _e = e, t = _e.onLog, r = _e.env, n = _e.appId, o = _e.releaseId, a = _e.subPackageVersion; this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && Logger.setLevel(LoggerLevels.Debug); var s = this.pageSession = util.uuid(); reporter.updateHeader({ pageSession: s }); reporter.updateReportUrl(REPORT_URL[this.env]); a && reporter.updateBody({ sdkVersion: a }); logger.infoAndReportMeasurement({ metric: "sdkInit", startTime: Date.now(), extra: { version: a, enviroment: r, pageSession: s } }); logger.debug("debug mode:", this.debug); reporter.on("report", function (l) { t && t(l); }); if (n) { this.appId = n, this.releaseId = o; var l = ModelManager.getInstance(n, o); this.preload = new Preload(l); } } _createClass(Xverse, [{ key: "isSupported", get: function get() { return isSupported(); } }, { key: "disableLogUpload", value: function disableLogUpload() { reporter.disable(), logger.debug("logger upload has been disabled"); } }, { key: "getSkinList", value: function () { var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() { return regenerator.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", []); case 1: case "end": return _context.stop(); } } }, _callee); })); function getSkinList() { return _getSkinList.apply(this, arguments); } return getSkinList; }() }, { key: "getAvatarList", value: function () { var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() { return regenerator.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", []); case 1: case "end": return _context2.stop(); } } }, _callee2); })); function getAvatarList() { return _getAvatarList.apply(this, arguments); } return getAvatarList; }() }, { key: "getGiftList", value: function () { var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() { return regenerator.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: return _context3.abrupt("return", [{ id: "hack " }]); case 1: case "end": return _context3.stop(); } } }, _callee3); })); function getGiftList() { return _getGiftList.apply(this, arguments); } return getGiftList; }() }, { key: "joinRoom", value: function () { var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) { var t, r, n, o; return regenerator.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), { appId: e.appId || this.appId, releaseId: e.releaseId || this.releaseId, pageSession: this.pageSession, isAllSync: !0, rotationRenderType: r, syncByEvent: !0, pathName: t, person: n, role: e.role || "audience" })); return _context4.abrupt("return", o.initRoom().then(function () { return o; })); case 2: case "end": return _context4.stop(); } } }, _callee4, this); })); function joinRoom(_x) { return _joinRoom.apply(this, arguments); } return joinRoom; }() }]); return Xverse; }(); var xverse = new Xverse({ env: "DEV", appId: 10016, releaseId: '2203120033_29769e' }); var l = /*#__PURE__*/function () { var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() { var R; return regenerator.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.prev = 0; _context.next = 3; return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) { }); case 3: _context.next = 12; break; case 5: _context.prev = 5; _context.t0 = _context["catch"](0); if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) { _context.next = 10; break; } toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88"); return _context.abrupt("return"); case 10: toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5"); return _context.abrupt("return"); case 12: _context.prev = 12; _context.next = 15; return xverse.joinRoom({ canvas: document.getElementById('canvas'), skinId: 10092, avatarId: 'KGe_Boy', roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb', userId: '1f7acca1db9d5', wsServerUrl: 'wss://uat-eks.xverse.cn/ws', appId: 10016, token: " ", nickname: '1f7acca1db9d5', firends: ["user1"], viewMode: "full", resolution: { width: 1728, height: 720 }, pathName: 'thirdwalk', objectFit: null, hasAvatar: !0, syncToOthers: !0 }); case 15: room = _context.sent; u(), c(), window.room = room, e(!1); _context.next = 23; break; case 19: _context.prev = 19; _context.t1 = _context["catch"](12); console.error(_context.t1), alert(_context.t1); return _context.abrupt("return"); case 23: case "end": return _context.stop(); } } }, _callee, null, [[0, 5], [12, 19]]); })); return function l() { return _ref.apply(this, arguments); }; }(); var u = function u() { room.on("_coreClick", function (_ref2) { var f = _ref2.point; room._userAvatar.moveTo({ point: f }); }); }; var c = function c() { room.on("repeatLogin", function () { toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", { duration: 1e4 }); }), room.on("reconnecting", function (_ref3) { var f = _ref3.count; toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE")); }), room.on("reconnected", function () { toast("\u91CD\u8FDE\u6210\u529F"); }), room.on("disconnected", function () { var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", { duration: 1e5, onClick() { f.hideToast(), room.reconnect(); } }); }); }; l(); })); //# sourceMappingURL=index.js.map