1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383 |
- /**
- * Name: Metaverse
- * Date: 2022/4/8
- * 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;
- }
- };
- 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(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 Reporter = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Reporter, _EventEmitter);
- var _super = _createSuper(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 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 e, 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:
- e = "https://static.xverse.cn/console/config/".concat(this.appId, "/config.json");
- this.releaseId && (e = "https://static.xverse.cn/console/config/".concat(this.appId, "/").concat(this.releaseId, "/config.json"));
- t = Xverse$1.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
- _context6.prev = 5;
- _context6.next = 8;
- return http$1.get({
- url: "".concat(t, "?t=").concat(Date.now()),
- key: "config",
- timeout: 6e3,
- retry: 2
- });
- case 8:
- r = _context6.sent;
- _ref = r.data.data || {};
- n = _ref.config;
- o = _ref.preload;
- if (n) {
- _context6.next = 14;
- break;
- }
- throw new Error("config data parse error" + r.data);
- case 14:
- return _context6.abrupt("return", (this.config = {
- config: n,
- preload: o
- }, logger.debug("get config success", this.config), this.config));
- case 17:
- _context6.prev = 17;
- _context6.t0 = _context6["catch"](5);
- return _context6.abrupt("return", Promise.reject(_context6.t0));
- case 20:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this, [[5, 17]]);
- }));
- 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;
- return _context2.abrupt("return", (this.allKeys = e, e));
- case 9:
- _context2.prev = 9;
- _context2.t0 = _context2["catch"](2);
- t = "preload getAllKeys error";
- return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
- case 13:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[2, 9]]);
- }));
- 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) {
- http$1.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", 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()) : http$1.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$1(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;
- }();
- new Xverse({
- env: "DEV",
- appId: 10016,
- releaseId: '2203120033_29769e'
- });
- }));
- //# sourceMappingURL=index.js.map
|