12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134 |
- /**
- * 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;
- },
- 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();
- 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 Http = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Http, _EventEmitter);
- var _super = _createSuper$1(Http);
- function Http() {
- _classCallCheck(this, Http);
- return _super.apply(this, arguments);
- }
- _createClass(Http, [{
- key: "get",
- value: function () {
- var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
- var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- e = _ref.url, _ref$useIndexedDb = _ref.useIndexedDb, t = _ref$useIndexedDb === void 0 ? !1 : _ref$useIndexedDb, _ref$timeout = _ref.timeout, r = _ref$timeout === void 0 ? 15e3 : _ref$timeout, n = _ref.key, _ref$isOutPutObjectUR = _ref.isOutPutObjectURL, o = _ref$isOutPutObjectUR === void 0 ? !0 : _ref$isOutPutObjectUR;
- if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
- _context2.next = 25;
- break;
- }
- if (!isIndexedDbSupported()) {
- _context2.next = 22;
- break;
- }
- window.performance.now();
- a = null;
- _context2.prev = 5;
- _context2.next = 8;
- return modelTable.query("url", e);
- case 8:
- a = _context2.sent;
- _context2.next = 14;
- break;
- case 11:
- _context2.prev = 11;
- _context2.t0 = _context2["catch"](5);
- return _context2.abrupt("return", (logger.debug(_context2.t0), logger.warn("cache query error", e), Promise.resolve(e)));
- case 14:
- if (!(a && a.model)) {
- _context2.next = 19;
- break;
- }
- s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
- return _context2.abrupt("return", (window.performance.now(), l));
- case 19:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- contentType: "blob",
- key: n
- }).then( /*#__PURE__*/function () {
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
- var l;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return blobToDataURI(s.response);
- case 2:
- l = _context.sent;
- _context.prev = 3;
- _context.next = 6;
- return modelTable.put({
- url: e,
- model: l
- });
- case 6:
- _context.next = 11;
- break;
- case 8:
- _context.prev = 8;
- _context.t0 = _context["catch"](3);
- logger.warn("unable to add data to indexedDB", _context.t0);
- case 11:
- return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
- case 12:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, null, [[3, 8]]);
- }));
- return function (_x2) {
- return _ref2.apply(this, arguments);
- };
- }()));
- case 20:
- _context2.next = 23;
- break;
- case 22:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- contentType: "blob",
- key: n
- }).then(function (a) {
- var s = a.response;
- return Promise.resolve(o ? URL.createObjectURL(s) : s);
- }).catch(function (a) {
- return Promise.reject(a);
- }));
- case 23:
- _context2.next = 26;
- break;
- case 25:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- key: n
- }).then(function (a) {
- return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
- }));
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[5, 11]]);
- }));
- function get(_x) {
- return _get.apply(this, arguments);
- }
- return get;
- }()
- }, {
- key: "request",
- value: function request(e) {
- var _this = this;
- var _e$timeout = e.timeout,
- t = _e$timeout === void 0 ? 3e4 : _e$timeout,
- r = e.contentType;
- e.key;
- var o = e.onRequestStart,
- a = e.url;
- return new Promise(function (s, l) {
- window.performance.now();
- var u = new XMLHttpRequest();
- r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
- if (u.readyState == 4) {
- if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
- message: "request ".concat(a, " load success")
- }), s(u);
- {
- var c = "Unable to load the request ".concat(a);
- return _this.emit("error", {
- message: c
- }), logger.error(c), l(c);
- }
- }
- }), o && o(u), u.open("GET", a), u.send();
- });
- }
- }]);
- return Http;
- }(EventEmitter);
- var http = new Http();
- // , isIndexedDbSupported = ()=>(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0
- // , blobToDataURI = async i=>new Promise((e,t)=>{
- // const r = new FileReader;
- // r.readAsDataURL(i),
- // r.onload = function(n) {
- // var o;
- // e((o = n.target) == null ? void 0 : o.result)
- // }
- // ,
- // r.onerror = function(n) {
- // t(n)
- // }
- // }
- // )
- // , dataURItoBlob = i=>{
- // let e;
- // i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
- // const t = i.split(",")[0].split(":")[1].split(";")[0]
- // , r = new Uint8Array(e.length);
- // for (let o = 0; o < e.length; o++)
- // r[o] = e.charCodeAt(o);
- // return new Blob([r],{
- // type: t
- // })
- // }
- // , urlMap = new Map
- // , urlTransformer = async(i,e=!1)=>typeof i != "string" ? (console.warn("url transformer error", i),
- // i) : i.startsWith("blob:") ? i : e ? http.get({
- // url: i,
- // useIndexedDb: !0,
- // key: "url",
- // isOutPutObjectURL: !1
- // }) : urlMap.has(i) ? urlMap.get(i) : http.get({
- // url: i,
- // useIndexedDb: !0,
- // key: "url"
- // }).then(t=>(urlMap.set(i, t),
- // t));
- 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 http.get({
- url: "".concat(t, "?t=").concat(Date.now()),
- key: "config",
- timeout: 6e3,
- retry: 2
- });
- case 6:
- r = _context6.sent;
- _ref = JSON.parse(r).data || {};
- n = _ref.config;
- o = _ref.preload;
- if (n) {
- _context6.next = 12;
- break;
- }
- throw new Error("config data parse error" + r.data);
- case 12:
- return _context6.abrupt("return", (this.config = {
- config: n,
- preload: o
- }, logger.debug("get config success", this.config), this.config));
- case 15:
- _context6.prev = 15;
- _context6.t0 = _context6["catch"](3);
- return _context6.abrupt("return", Promise.reject(_context6.t0));
- case 18:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this, [[3, 15]]);
- }));
- 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 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(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 ModelTable = /*#__PURE__*/function (_BaseTable) {
- _inherits(ModelTable, _BaseTable);
- var _super = _createSuper(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$1 = new ModelTable();
- 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$1.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) {
- http.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$1.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()) : http.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$1.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) {
- var I = "(".concat(M, "/").concat(x, ")");
- s(I);
- });
- 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
|