index.js 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/9
  4. * Author: https://www.4dkankan.com
  5. * Copyright © 2022 4DAGE Co., Ltd. All rights reserved.
  6. * Licensed under the GLP license
  7. */
  8. (function (factory) {
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. factory();
  11. })((function () { 'use strict';
  12. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13. try {
  14. var info = gen[key](arg);
  15. var value = info.value;
  16. } catch (error) {
  17. reject(error);
  18. return;
  19. }
  20. if (info.done) {
  21. resolve(value);
  22. } else {
  23. Promise.resolve(value).then(_next, _throw);
  24. }
  25. }
  26. function _asyncToGenerator(fn) {
  27. return function () {
  28. var self = this,
  29. args = arguments;
  30. return new Promise(function (resolve, reject) {
  31. var gen = fn.apply(self, args);
  32. function _next(value) {
  33. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  34. }
  35. function _throw(err) {
  36. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  37. }
  38. _next(undefined);
  39. });
  40. };
  41. }
  42. function createCommonjsModule(fn) {
  43. var module = { exports: {} };
  44. return fn(module, module.exports), module.exports;
  45. }
  46. /**
  47. * Copyright (c) 2014-present, Facebook, Inc.
  48. *
  49. * This source code is licensed under the MIT license found in the
  50. * LICENSE file in the root directory of this source tree.
  51. */
  52. var runtime_1 = createCommonjsModule(function (module) {
  53. var runtime = (function (exports) {
  54. var Op = Object.prototype;
  55. var hasOwn = Op.hasOwnProperty;
  56. var undefined$1; // More compressible than void 0.
  57. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  58. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  59. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  60. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  61. function define(obj, key, value) {
  62. Object.defineProperty(obj, key, {
  63. value: value,
  64. enumerable: true,
  65. configurable: true,
  66. writable: true
  67. });
  68. return obj[key];
  69. }
  70. try {
  71. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  72. define({}, "");
  73. } catch (err) {
  74. define = function(obj, key, value) {
  75. return obj[key] = value;
  76. };
  77. }
  78. function wrap(innerFn, outerFn, self, tryLocsList) {
  79. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  80. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  81. var generator = Object.create(protoGenerator.prototype);
  82. var context = new Context(tryLocsList || []);
  83. // The ._invoke method unifies the implementations of the .next,
  84. // .throw, and .return methods.
  85. generator._invoke = makeInvokeMethod(innerFn, self, context);
  86. return generator;
  87. }
  88. exports.wrap = wrap;
  89. // Try/catch helper to minimize deoptimizations. Returns a completion
  90. // record like context.tryEntries[i].completion. This interface could
  91. // have been (and was previously) designed to take a closure to be
  92. // invoked without arguments, but in all the cases we care about we
  93. // already have an existing method we want to call, so there's no need
  94. // to create a new function object. We can even get away with assuming
  95. // the method takes exactly one argument, since that happens to be true
  96. // in every case, so we don't have to touch the arguments object. The
  97. // only additional allocation required is the completion record, which
  98. // has a stable shape and so hopefully should be cheap to allocate.
  99. function tryCatch(fn, obj, arg) {
  100. try {
  101. return { type: "normal", arg: fn.call(obj, arg) };
  102. } catch (err) {
  103. return { type: "throw", arg: err };
  104. }
  105. }
  106. var GenStateSuspendedStart = "suspendedStart";
  107. var GenStateSuspendedYield = "suspendedYield";
  108. var GenStateExecuting = "executing";
  109. var GenStateCompleted = "completed";
  110. // Returning this object from the innerFn has the same effect as
  111. // breaking out of the dispatch switch statement.
  112. var ContinueSentinel = {};
  113. // Dummy constructor functions that we use as the .constructor and
  114. // .constructor.prototype properties for functions that return Generator
  115. // objects. For full spec compliance, you may wish to configure your
  116. // minifier not to mangle the names of these two functions.
  117. function Generator() {}
  118. function GeneratorFunction() {}
  119. function GeneratorFunctionPrototype() {}
  120. // This is a polyfill for %IteratorPrototype% for environments that
  121. // don't natively support it.
  122. var IteratorPrototype = {};
  123. define(IteratorPrototype, iteratorSymbol, function () {
  124. return this;
  125. });
  126. var getProto = Object.getPrototypeOf;
  127. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  128. if (NativeIteratorPrototype &&
  129. NativeIteratorPrototype !== Op &&
  130. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  131. // This environment has a native %IteratorPrototype%; use it instead
  132. // of the polyfill.
  133. IteratorPrototype = NativeIteratorPrototype;
  134. }
  135. var Gp = GeneratorFunctionPrototype.prototype =
  136. Generator.prototype = Object.create(IteratorPrototype);
  137. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  138. define(Gp, "constructor", GeneratorFunctionPrototype);
  139. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  140. GeneratorFunction.displayName = define(
  141. GeneratorFunctionPrototype,
  142. toStringTagSymbol,
  143. "GeneratorFunction"
  144. );
  145. // Helper for defining the .next, .throw, and .return methods of the
  146. // Iterator interface in terms of a single ._invoke method.
  147. function defineIteratorMethods(prototype) {
  148. ["next", "throw", "return"].forEach(function(method) {
  149. define(prototype, method, function(arg) {
  150. return this._invoke(method, arg);
  151. });
  152. });
  153. }
  154. exports.isGeneratorFunction = function(genFun) {
  155. var ctor = typeof genFun === "function" && genFun.constructor;
  156. return ctor
  157. ? ctor === GeneratorFunction ||
  158. // For the native GeneratorFunction constructor, the best we can
  159. // do is to check its .name property.
  160. (ctor.displayName || ctor.name) === "GeneratorFunction"
  161. : false;
  162. };
  163. exports.mark = function(genFun) {
  164. if (Object.setPrototypeOf) {
  165. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  166. } else {
  167. genFun.__proto__ = GeneratorFunctionPrototype;
  168. define(genFun, toStringTagSymbol, "GeneratorFunction");
  169. }
  170. genFun.prototype = Object.create(Gp);
  171. return genFun;
  172. };
  173. // Within the body of any async function, `await x` is transformed to
  174. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  175. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  176. // meant to be awaited.
  177. exports.awrap = function(arg) {
  178. return { __await: arg };
  179. };
  180. function AsyncIterator(generator, PromiseImpl) {
  181. function invoke(method, arg, resolve, reject) {
  182. var record = tryCatch(generator[method], generator, arg);
  183. if (record.type === "throw") {
  184. reject(record.arg);
  185. } else {
  186. var result = record.arg;
  187. var value = result.value;
  188. if (value &&
  189. typeof value === "object" &&
  190. hasOwn.call(value, "__await")) {
  191. return PromiseImpl.resolve(value.__await).then(function(value) {
  192. invoke("next", value, resolve, reject);
  193. }, function(err) {
  194. invoke("throw", err, resolve, reject);
  195. });
  196. }
  197. return PromiseImpl.resolve(value).then(function(unwrapped) {
  198. // When a yielded Promise is resolved, its final value becomes
  199. // the .value of the Promise<{value,done}> result for the
  200. // current iteration.
  201. result.value = unwrapped;
  202. resolve(result);
  203. }, function(error) {
  204. // If a rejected Promise was yielded, throw the rejection back
  205. // into the async generator function so it can be handled there.
  206. return invoke("throw", error, resolve, reject);
  207. });
  208. }
  209. }
  210. var previousPromise;
  211. function enqueue(method, arg) {
  212. function callInvokeWithMethodAndArg() {
  213. return new PromiseImpl(function(resolve, reject) {
  214. invoke(method, arg, resolve, reject);
  215. });
  216. }
  217. return previousPromise =
  218. // If enqueue has been called before, then we want to wait until
  219. // all previous Promises have been resolved before calling invoke,
  220. // so that results are always delivered in the correct order. If
  221. // enqueue has not been called before, then it is important to
  222. // call invoke immediately, without waiting on a callback to fire,
  223. // so that the async generator function has the opportunity to do
  224. // any necessary setup in a predictable way. This predictability
  225. // is why the Promise constructor synchronously invokes its
  226. // executor callback, and why async functions synchronously
  227. // execute code before the first await. Since we implement simple
  228. // async functions in terms of async generators, it is especially
  229. // important to get this right, even though it requires care.
  230. previousPromise ? previousPromise.then(
  231. callInvokeWithMethodAndArg,
  232. // Avoid propagating failures to Promises returned by later
  233. // invocations of the iterator.
  234. callInvokeWithMethodAndArg
  235. ) : callInvokeWithMethodAndArg();
  236. }
  237. // Define the unified helper method that is used to implement .next,
  238. // .throw, and .return (see defineIteratorMethods).
  239. this._invoke = enqueue;
  240. }
  241. defineIteratorMethods(AsyncIterator.prototype);
  242. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  243. return this;
  244. });
  245. exports.AsyncIterator = AsyncIterator;
  246. // Note that simple async functions are implemented on top of
  247. // AsyncIterator objects; they just return a Promise for the value of
  248. // the final result produced by the iterator.
  249. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  250. if (PromiseImpl === void 0) PromiseImpl = Promise;
  251. var iter = new AsyncIterator(
  252. wrap(innerFn, outerFn, self, tryLocsList),
  253. PromiseImpl
  254. );
  255. return exports.isGeneratorFunction(outerFn)
  256. ? iter // If outerFn is a generator, return the full iterator.
  257. : iter.next().then(function(result) {
  258. return result.done ? result.value : iter.next();
  259. });
  260. };
  261. function makeInvokeMethod(innerFn, self, context) {
  262. var state = GenStateSuspendedStart;
  263. return function invoke(method, arg) {
  264. if (state === GenStateExecuting) {
  265. throw new Error("Generator is already running");
  266. }
  267. if (state === GenStateCompleted) {
  268. if (method === "throw") {
  269. throw arg;
  270. }
  271. // Be forgiving, per 25.3.3.3.3 of the spec:
  272. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  273. return doneResult();
  274. }
  275. context.method = method;
  276. context.arg = arg;
  277. while (true) {
  278. var delegate = context.delegate;
  279. if (delegate) {
  280. var delegateResult = maybeInvokeDelegate(delegate, context);
  281. if (delegateResult) {
  282. if (delegateResult === ContinueSentinel) continue;
  283. return delegateResult;
  284. }
  285. }
  286. if (context.method === "next") {
  287. // Setting context._sent for legacy support of Babel's
  288. // function.sent implementation.
  289. context.sent = context._sent = context.arg;
  290. } else if (context.method === "throw") {
  291. if (state === GenStateSuspendedStart) {
  292. state = GenStateCompleted;
  293. throw context.arg;
  294. }
  295. context.dispatchException(context.arg);
  296. } else if (context.method === "return") {
  297. context.abrupt("return", context.arg);
  298. }
  299. state = GenStateExecuting;
  300. var record = tryCatch(innerFn, self, context);
  301. if (record.type === "normal") {
  302. // If an exception is thrown from innerFn, we leave state ===
  303. // GenStateExecuting and loop back for another invocation.
  304. state = context.done
  305. ? GenStateCompleted
  306. : GenStateSuspendedYield;
  307. if (record.arg === ContinueSentinel) {
  308. continue;
  309. }
  310. return {
  311. value: record.arg,
  312. done: context.done
  313. };
  314. } else if (record.type === "throw") {
  315. state = GenStateCompleted;
  316. // Dispatch the exception by looping back around to the
  317. // context.dispatchException(context.arg) call above.
  318. context.method = "throw";
  319. context.arg = record.arg;
  320. }
  321. }
  322. };
  323. }
  324. // Call delegate.iterator[context.method](context.arg) and handle the
  325. // result, either by returning a { value, done } result from the
  326. // delegate iterator, or by modifying context.method and context.arg,
  327. // setting context.delegate to null, and returning the ContinueSentinel.
  328. function maybeInvokeDelegate(delegate, context) {
  329. var method = delegate.iterator[context.method];
  330. if (method === undefined$1) {
  331. // A .throw or .return when the delegate iterator has no .throw
  332. // method always terminates the yield* loop.
  333. context.delegate = null;
  334. if (context.method === "throw") {
  335. // Note: ["return"] must be used for ES3 parsing compatibility.
  336. if (delegate.iterator["return"]) {
  337. // If the delegate iterator has a return method, give it a
  338. // chance to clean up.
  339. context.method = "return";
  340. context.arg = undefined$1;
  341. maybeInvokeDelegate(delegate, context);
  342. if (context.method === "throw") {
  343. // If maybeInvokeDelegate(context) changed context.method from
  344. // "return" to "throw", let that override the TypeError below.
  345. return ContinueSentinel;
  346. }
  347. }
  348. context.method = "throw";
  349. context.arg = new TypeError(
  350. "The iterator does not provide a 'throw' method");
  351. }
  352. return ContinueSentinel;
  353. }
  354. var record = tryCatch(method, delegate.iterator, context.arg);
  355. if (record.type === "throw") {
  356. context.method = "throw";
  357. context.arg = record.arg;
  358. context.delegate = null;
  359. return ContinueSentinel;
  360. }
  361. var info = record.arg;
  362. if (! info) {
  363. context.method = "throw";
  364. context.arg = new TypeError("iterator result is not an object");
  365. context.delegate = null;
  366. return ContinueSentinel;
  367. }
  368. if (info.done) {
  369. // Assign the result of the finished delegate to the temporary
  370. // variable specified by delegate.resultName (see delegateYield).
  371. context[delegate.resultName] = info.value;
  372. // Resume execution at the desired location (see delegateYield).
  373. context.next = delegate.nextLoc;
  374. // If context.method was "throw" but the delegate handled the
  375. // exception, let the outer generator proceed normally. If
  376. // context.method was "next", forget context.arg since it has been
  377. // "consumed" by the delegate iterator. If context.method was
  378. // "return", allow the original .return call to continue in the
  379. // outer generator.
  380. if (context.method !== "return") {
  381. context.method = "next";
  382. context.arg = undefined$1;
  383. }
  384. } else {
  385. // Re-yield the result returned by the delegate method.
  386. return info;
  387. }
  388. // The delegate iterator is finished, so forget it and continue with
  389. // the outer generator.
  390. context.delegate = null;
  391. return ContinueSentinel;
  392. }
  393. // Define Generator.prototype.{next,throw,return} in terms of the
  394. // unified ._invoke helper method.
  395. defineIteratorMethods(Gp);
  396. define(Gp, toStringTagSymbol, "Generator");
  397. // A Generator should always return itself as the iterator object when the
  398. // @@iterator function is called on it. Some browsers' implementations of the
  399. // iterator prototype chain incorrectly implement this, causing the Generator
  400. // object to not be returned from this call. This ensures that doesn't happen.
  401. // See https://github.com/facebook/regenerator/issues/274 for more details.
  402. define(Gp, iteratorSymbol, function() {
  403. return this;
  404. });
  405. define(Gp, "toString", function() {
  406. return "[object Generator]";
  407. });
  408. function pushTryEntry(locs) {
  409. var entry = { tryLoc: locs[0] };
  410. if (1 in locs) {
  411. entry.catchLoc = locs[1];
  412. }
  413. if (2 in locs) {
  414. entry.finallyLoc = locs[2];
  415. entry.afterLoc = locs[3];
  416. }
  417. this.tryEntries.push(entry);
  418. }
  419. function resetTryEntry(entry) {
  420. var record = entry.completion || {};
  421. record.type = "normal";
  422. delete record.arg;
  423. entry.completion = record;
  424. }
  425. function Context(tryLocsList) {
  426. // The root entry object (effectively a try statement without a catch
  427. // or a finally block) gives us a place to store values thrown from
  428. // locations where there is no enclosing try statement.
  429. this.tryEntries = [{ tryLoc: "root" }];
  430. tryLocsList.forEach(pushTryEntry, this);
  431. this.reset(true);
  432. }
  433. exports.keys = function(object) {
  434. var keys = [];
  435. for (var key in object) {
  436. keys.push(key);
  437. }
  438. keys.reverse();
  439. // Rather than returning an object with a next method, we keep
  440. // things simple and return the next function itself.
  441. return function next() {
  442. while (keys.length) {
  443. var key = keys.pop();
  444. if (key in object) {
  445. next.value = key;
  446. next.done = false;
  447. return next;
  448. }
  449. }
  450. // To avoid creating an additional object, we just hang the .value
  451. // and .done properties off the next function object itself. This
  452. // also ensures that the minifier will not anonymize the function.
  453. next.done = true;
  454. return next;
  455. };
  456. };
  457. function values(iterable) {
  458. if (iterable) {
  459. var iteratorMethod = iterable[iteratorSymbol];
  460. if (iteratorMethod) {
  461. return iteratorMethod.call(iterable);
  462. }
  463. if (typeof iterable.next === "function") {
  464. return iterable;
  465. }
  466. if (!isNaN(iterable.length)) {
  467. var i = -1, next = function next() {
  468. while (++i < iterable.length) {
  469. if (hasOwn.call(iterable, i)) {
  470. next.value = iterable[i];
  471. next.done = false;
  472. return next;
  473. }
  474. }
  475. next.value = undefined$1;
  476. next.done = true;
  477. return next;
  478. };
  479. return next.next = next;
  480. }
  481. }
  482. // Return an iterator with no values.
  483. return { next: doneResult };
  484. }
  485. exports.values = values;
  486. function doneResult() {
  487. return { value: undefined$1, done: true };
  488. }
  489. Context.prototype = {
  490. constructor: Context,
  491. reset: function(skipTempReset) {
  492. this.prev = 0;
  493. this.next = 0;
  494. // Resetting context._sent for legacy support of Babel's
  495. // function.sent implementation.
  496. this.sent = this._sent = undefined$1;
  497. this.done = false;
  498. this.delegate = null;
  499. this.method = "next";
  500. this.arg = undefined$1;
  501. this.tryEntries.forEach(resetTryEntry);
  502. if (!skipTempReset) {
  503. for (var name in this) {
  504. // Not sure about the optimal order of these conditions:
  505. if (name.charAt(0) === "t" &&
  506. hasOwn.call(this, name) &&
  507. !isNaN(+name.slice(1))) {
  508. this[name] = undefined$1;
  509. }
  510. }
  511. }
  512. },
  513. stop: function() {
  514. this.done = true;
  515. var rootEntry = this.tryEntries[0];
  516. var rootRecord = rootEntry.completion;
  517. if (rootRecord.type === "throw") {
  518. throw rootRecord.arg;
  519. }
  520. return this.rval;
  521. },
  522. dispatchException: function(exception) {
  523. if (this.done) {
  524. throw exception;
  525. }
  526. var context = this;
  527. function handle(loc, caught) {
  528. record.type = "throw";
  529. record.arg = exception;
  530. context.next = loc;
  531. if (caught) {
  532. // If the dispatched exception was caught by a catch block,
  533. // then let that catch block handle the exception normally.
  534. context.method = "next";
  535. context.arg = undefined$1;
  536. }
  537. return !! caught;
  538. }
  539. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  540. var entry = this.tryEntries[i];
  541. var record = entry.completion;
  542. if (entry.tryLoc === "root") {
  543. // Exception thrown outside of any try block that could handle
  544. // it, so set the completion value of the entire function to
  545. // throw the exception.
  546. return handle("end");
  547. }
  548. if (entry.tryLoc <= this.prev) {
  549. var hasCatch = hasOwn.call(entry, "catchLoc");
  550. var hasFinally = hasOwn.call(entry, "finallyLoc");
  551. if (hasCatch && hasFinally) {
  552. if (this.prev < entry.catchLoc) {
  553. return handle(entry.catchLoc, true);
  554. } else if (this.prev < entry.finallyLoc) {
  555. return handle(entry.finallyLoc);
  556. }
  557. } else if (hasCatch) {
  558. if (this.prev < entry.catchLoc) {
  559. return handle(entry.catchLoc, true);
  560. }
  561. } else if (hasFinally) {
  562. if (this.prev < entry.finallyLoc) {
  563. return handle(entry.finallyLoc);
  564. }
  565. } else {
  566. throw new Error("try statement without catch or finally");
  567. }
  568. }
  569. }
  570. },
  571. abrupt: function(type, arg) {
  572. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  573. var entry = this.tryEntries[i];
  574. if (entry.tryLoc <= this.prev &&
  575. hasOwn.call(entry, "finallyLoc") &&
  576. this.prev < entry.finallyLoc) {
  577. var finallyEntry = entry;
  578. break;
  579. }
  580. }
  581. if (finallyEntry &&
  582. (type === "break" ||
  583. type === "continue") &&
  584. finallyEntry.tryLoc <= arg &&
  585. arg <= finallyEntry.finallyLoc) {
  586. // Ignore the finally entry if control is not jumping to a
  587. // location outside the try/catch block.
  588. finallyEntry = null;
  589. }
  590. var record = finallyEntry ? finallyEntry.completion : {};
  591. record.type = type;
  592. record.arg = arg;
  593. if (finallyEntry) {
  594. this.method = "next";
  595. this.next = finallyEntry.finallyLoc;
  596. return ContinueSentinel;
  597. }
  598. return this.complete(record);
  599. },
  600. complete: function(record, afterLoc) {
  601. if (record.type === "throw") {
  602. throw record.arg;
  603. }
  604. if (record.type === "break" ||
  605. record.type === "continue") {
  606. this.next = record.arg;
  607. } else if (record.type === "return") {
  608. this.rval = this.arg = record.arg;
  609. this.method = "return";
  610. this.next = "end";
  611. } else if (record.type === "normal" && afterLoc) {
  612. this.next = afterLoc;
  613. }
  614. return ContinueSentinel;
  615. },
  616. finish: function(finallyLoc) {
  617. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  618. var entry = this.tryEntries[i];
  619. if (entry.finallyLoc === finallyLoc) {
  620. this.complete(entry.completion, entry.afterLoc);
  621. resetTryEntry(entry);
  622. return ContinueSentinel;
  623. }
  624. }
  625. },
  626. "catch": function(tryLoc) {
  627. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  628. var entry = this.tryEntries[i];
  629. if (entry.tryLoc === tryLoc) {
  630. var record = entry.completion;
  631. if (record.type === "throw") {
  632. var thrown = record.arg;
  633. resetTryEntry(entry);
  634. }
  635. return thrown;
  636. }
  637. }
  638. // The context.catch method must only be called with a location
  639. // argument that corresponds to a known catch block.
  640. throw new Error("illegal catch attempt");
  641. },
  642. delegateYield: function(iterable, resultName, nextLoc) {
  643. this.delegate = {
  644. iterator: values(iterable),
  645. resultName: resultName,
  646. nextLoc: nextLoc
  647. };
  648. if (this.method === "next") {
  649. // Deliberately forget the last sent value so that we don't
  650. // accidentally pass it on to the delegate.
  651. this.arg = undefined$1;
  652. }
  653. return ContinueSentinel;
  654. }
  655. };
  656. // Regardless of whether this script is executing as a CommonJS module
  657. // or not, return the runtime object so that we can declare the variable
  658. // regeneratorRuntime in the outer scope, which allows this module to be
  659. // injected easily by `bin/regenerator --include-runtime script.js`.
  660. return exports;
  661. }(
  662. // If this script is executing as a CommonJS module, use module.exports
  663. // as the regeneratorRuntime namespace. Otherwise create a new empty
  664. // object. Either way, the resulting object will be used to initialize
  665. // the regeneratorRuntime variable at the top of this file.
  666. module.exports
  667. ));
  668. try {
  669. regeneratorRuntime = runtime;
  670. } catch (accidentalStrictMode) {
  671. // This module should not be running in strict mode, so the above
  672. // assignment should always work unless something is misconfigured. Just
  673. // in case runtime.js accidentally runs in strict mode, in modern engines
  674. // we can explicitly access globalThis. In older engines we can escape
  675. // strict mode using a global Function call. This could conceivably fail
  676. // if a Content Security Policy forbids using Function, but in that case
  677. // the proper solution is to fix the accidental strict mode problem. If
  678. // you've misconfigured your bundler to force strict mode and applied a
  679. // CSP to forbid Function, and you're not willing to fix either of those
  680. // problems, please detail your unique predicament in a GitHub issue.
  681. if (typeof globalThis === "object") {
  682. globalThis.regeneratorRuntime = runtime;
  683. } else {
  684. Function("r", "regeneratorRuntime = r")(runtime);
  685. }
  686. }
  687. });
  688. var regenerator = runtime_1;
  689. function _classCallCheck(instance, Constructor) {
  690. if (!(instance instanceof Constructor)) {
  691. throw new TypeError("Cannot call a class as a function");
  692. }
  693. }
  694. function _defineProperties(target, props) {
  695. for (var i = 0; i < props.length; i++) {
  696. var descriptor = props[i];
  697. descriptor.enumerable = descriptor.enumerable || false;
  698. descriptor.configurable = true;
  699. if ("value" in descriptor) descriptor.writable = true;
  700. Object.defineProperty(target, descriptor.key, descriptor);
  701. }
  702. }
  703. function _createClass(Constructor, protoProps, staticProps) {
  704. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  705. if (staticProps) _defineProperties(Constructor, staticProps);
  706. Object.defineProperty(Constructor, "prototype", {
  707. writable: false
  708. });
  709. return Constructor;
  710. }
  711. var util = {
  712. uuid() {
  713. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
  714. var e = Math.random() * 16 | 0;
  715. return (i === "x" ? e : e & 3 | 8).toString(16);
  716. });
  717. },
  718. getFormattedDate(i) {
  719. var e = i.getMonth() + 1,
  720. t = i.getDate(),
  721. r = i.getHours(),
  722. n = i.getMinutes(),
  723. o = i.getSeconds(),
  724. a = i.getMilliseconds(),
  725. s = (e < 10 ? "0" : "") + e,
  726. l = (t < 10 ? "0" : "") + t,
  727. u = (r < 10 ? "0" : "") + r,
  728. c = (n < 10 ? "0" : "") + n,
  729. h = (o < 10 ? "0" : "") + o;
  730. return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
  731. },
  732. createInstance(i) {
  733. var e = new Axios(i),
  734. t = bind(Axios.prototype.request, e);
  735. return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
  736. return createInstance(mergeConfig(i, n));
  737. }, t;
  738. },
  739. mapLimit(i, e, t) {
  740. return new Promise(function (r, n) {
  741. var o = i.length;
  742. var a = e - 1,
  743. s = 0;
  744. var l = function l(u) {
  745. u.forEach(function (c) {
  746. t(c).then(function () {
  747. if (s++, s === o) {
  748. r();
  749. return;
  750. }
  751. a++;
  752. var h = i[a];
  753. h && l([h]);
  754. }, function (h) {
  755. n(h);
  756. });
  757. });
  758. };
  759. l(i.slice(0, e));
  760. });
  761. }
  762. };
  763. function _setPrototypeOf(o, p) {
  764. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  765. o.__proto__ = p;
  766. return o;
  767. };
  768. return _setPrototypeOf(o, p);
  769. }
  770. function _inherits(subClass, superClass) {
  771. if (typeof superClass !== "function" && superClass !== null) {
  772. throw new TypeError("Super expression must either be null or a function");
  773. }
  774. subClass.prototype = Object.create(superClass && superClass.prototype, {
  775. constructor: {
  776. value: subClass,
  777. writable: true,
  778. configurable: true
  779. }
  780. });
  781. Object.defineProperty(subClass, "prototype", {
  782. writable: false
  783. });
  784. if (superClass) _setPrototypeOf(subClass, superClass);
  785. }
  786. function _typeof(obj) {
  787. "@babel/helpers - typeof";
  788. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  789. return typeof obj;
  790. } : function (obj) {
  791. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  792. }, _typeof(obj);
  793. }
  794. function _assertThisInitialized(self) {
  795. if (self === void 0) {
  796. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  797. }
  798. return self;
  799. }
  800. function _possibleConstructorReturn(self, call) {
  801. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  802. return call;
  803. } else if (call !== void 0) {
  804. throw new TypeError("Derived constructors may only return object or undefined");
  805. }
  806. return _assertThisInitialized(self);
  807. }
  808. function _getPrototypeOf(o) {
  809. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  810. return o.__proto__ || Object.getPrototypeOf(o);
  811. };
  812. return _getPrototypeOf(o);
  813. }
  814. 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); }; }
  815. 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; } }
  816. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  817. _inherits(Reporter, _EventEmitter);
  818. var _super = _createSuper$2(Reporter);
  819. function Reporter() {
  820. var _this;
  821. _classCallCheck(this, Reporter);
  822. _this = _super.call(this);
  823. _this._header = {};
  824. _this._body = {};
  825. _this._queue = [];
  826. _this._disabled = !1;
  827. _this._interval = null;
  828. _this._reportUrl = null;
  829. _this.isDocumentLoaded = function () {
  830. return document.readyState === "complete";
  831. };
  832. _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 () {
  833. _this._flushReport();
  834. }, 10 * 1e3);
  835. return _this;
  836. }
  837. _createClass(Reporter, [{
  838. key: "disable",
  839. value: function disable() {
  840. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  841. }
  842. }, {
  843. key: "updateHeader",
  844. value: function updateHeader(e) {
  845. Object.assign(this._header, e);
  846. }
  847. }, {
  848. key: "updateBody",
  849. value: function updateBody(e) {
  850. Object.assign(this._body, e);
  851. }
  852. }, {
  853. key: "updateReportUrl",
  854. value: function updateReportUrl(e) {
  855. this._reportUrl = e;
  856. }
  857. }, {
  858. key: "report",
  859. value: function report(e, t, r) {
  860. var _this2 = this;
  861. if (this._disabled) return;
  862. r || (r = {});
  863. var _r = r,
  864. n = _r.immediate,
  865. o = _r.sampleRate;
  866. if (o && o > Math.random()) return;
  867. this.updateBody({
  868. logTime: util.getFormattedDate(new Date()),
  869. logTimestamp: Date.now()
  870. });
  871. var a = function a(s) {
  872. var l = oe(le(oe({}, _this2._body), {
  873. type: e
  874. }), s);
  875. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  876. };
  877. Array.isArray(t) ? t.forEach(function (s) {
  878. return a(s);
  879. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  880. }
  881. }, {
  882. key: "_flushReport",
  883. value: function _flushReport() {
  884. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  885. var e = {
  886. header: this._header,
  887. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  888. };
  889. this._post(e);
  890. }
  891. }, {
  892. key: "_post",
  893. value: function _post(e) {
  894. var t = this._reportUrl || REPORT_URL.DEV;
  895. return new Promise(function (r, n) {
  896. var o = new XMLHttpRequest();
  897. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  898. try {
  899. o.send(JSON.stringify(e));
  900. } catch (a) {
  901. console.error(a);
  902. }
  903. o.addEventListener("readystatechange", function () {
  904. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  905. });
  906. });
  907. }
  908. }]);
  909. return Reporter;
  910. }(EventEmitter);
  911. var reporter = new Reporter();
  912. function _arrayLikeToArray(arr, len) {
  913. if (len == null || len > arr.length) len = arr.length;
  914. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  915. arr2[i] = arr[i];
  916. }
  917. return arr2;
  918. }
  919. function _arrayWithoutHoles(arr) {
  920. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  921. }
  922. function _iterableToArray(iter) {
  923. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  924. }
  925. function _unsupportedIterableToArray(o, minLen) {
  926. if (!o) return;
  927. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  928. var n = Object.prototype.toString.call(o).slice(8, -1);
  929. if (n === "Object" && o.constructor) n = o.constructor.name;
  930. if (n === "Map" || n === "Set") return Array.from(o);
  931. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  932. }
  933. function _nonIterableSpread() {
  934. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  935. }
  936. function _toConsumableArray(arr) {
  937. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  938. }
  939. var Codes = {
  940. Success: 0,
  941. Param: 1001,
  942. Internal: 1002,
  943. Timeout: 1003,
  944. Authentication: 1004,
  945. TokenExpired: 1005,
  946. Unsupported: 1006,
  947. InitNetworkTimeout: 1007,
  948. InitDecoderTimeout: 1008,
  949. InitConfigTimeout: 1009,
  950. InitEngineTimeout: 1010,
  951. InitEngine: 1011,
  952. ActionBlocked: 1012,
  953. PreloadCanceled: 1013,
  954. FrequencyLimit: 1014,
  955. UsersUpperLimit: 2e3,
  956. RoomsUpperLimit: 2001,
  957. ServerParam: 2002,
  958. LackOfToken: 2003,
  959. LoginFailed: 2004,
  960. VerifyServiceDown: 2005,
  961. CreateSessionFailed: 2006,
  962. RtcConnection: 2008,
  963. DoActionFailed: 2009,
  964. StateSyncFailed: 2010,
  965. BroadcastFailed: 2011,
  966. DataAbnormal: 2012,
  967. GetOnVehicle: 2015,
  968. RepeatLogin: 2017,
  969. RoomDoseNotExist: 2018,
  970. TicketExpire: 2019,
  971. ServerRateLimit: 2020,
  972. DoActionBlocked: 2333,
  973. ActionMaybeDelay: 2334,
  974. ActionResponseTimeout: 2999
  975. };
  976. var Logger$1 = /*#__PURE__*/function () {
  977. function Logger(e) {
  978. _classCallCheck(this, Logger);
  979. this.level = 3;
  980. this.module = e;
  981. }
  982. _createClass(Logger, [{
  983. key: "setLevel",
  984. value: function setLevel(e) {
  985. this.level = e;
  986. }
  987. }, {
  988. key: "atleast",
  989. value: function atleast(e) {
  990. return e >= this.level && e >= this.level;
  991. }
  992. }, {
  993. key: "print",
  994. value: function print(e, t) {
  995. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  996. r[_key - 2] = arguments[_key];
  997. }
  998. if (this.atleast(t)) {
  999. var _console$n;
  1000. var n = e == "debug" ? "info" : e,
  1001. o = this.prefix(e);
  1002. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1003. }
  1004. if (e !== "debug" && e !== "info") {
  1005. var _n = r.map(function (o) {
  1006. if (o instanceof Object) try {
  1007. return JSON.stringify(o);
  1008. } catch (_unused) {
  1009. return o;
  1010. } else return o;
  1011. }).join(",");
  1012. reporter.report("log", {
  1013. message: _n,
  1014. level: e,
  1015. module: this.module
  1016. });
  1017. }
  1018. }
  1019. }, {
  1020. key: "debug",
  1021. value: function debug() {
  1022. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1023. e[_key2] = arguments[_key2];
  1024. }
  1025. return this.print.apply(this, ["debug", 1].concat(e));
  1026. }
  1027. }, {
  1028. key: "info",
  1029. value: function info() {
  1030. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1031. e[_key3] = arguments[_key3];
  1032. }
  1033. return this.print.apply(this, ["info", 2].concat(e));
  1034. }
  1035. }, {
  1036. key: "infoAndReportLog",
  1037. value: function infoAndReportLog(e) {
  1038. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1039. t[_key4 - 1] = arguments[_key4];
  1040. }
  1041. var r = e.reportOptions;
  1042. delete e.reportOptions, reporter.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1043. }
  1044. }, {
  1045. key: "infoAndReportMeasurement",
  1046. value: function infoAndReportMeasurement(e) {
  1047. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1048. t[_key5 - 1] = arguments[_key5];
  1049. }
  1050. var n;
  1051. var r = e.reportOptions;
  1052. if (e.startTime) {
  1053. var o = Date.now();
  1054. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1055. }
  1056. 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) {
  1057. this.error.apply(this, _toConsumableArray(t));
  1058. return;
  1059. }
  1060. this.warn.apply(this, _toConsumableArray(t));
  1061. }
  1062. }, {
  1063. key: "warn",
  1064. value: function warn() {
  1065. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1066. e[_key6] = arguments[_key6];
  1067. }
  1068. return this.print.apply(this, ["warn", 3].concat(e));
  1069. }
  1070. }, {
  1071. key: "error",
  1072. value: function error() {
  1073. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1074. e[_key7] = arguments[_key7];
  1075. }
  1076. return this.print.apply(this, ["error", 4].concat(e));
  1077. }
  1078. }, {
  1079. key: "prefix",
  1080. value: function prefix(e) {
  1081. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1082. }
  1083. }], [{
  1084. key: "setLevel",
  1085. value: function setLevel(e) {
  1086. this.level = e;
  1087. }
  1088. }]);
  1089. return Logger;
  1090. }();
  1091. var logger = new Logger$1();
  1092. var BaseTable = /*#__PURE__*/function () {
  1093. function BaseTable(e, t) {
  1094. _classCallCheck(this, BaseTable);
  1095. this.db = null;
  1096. this.isCreatingTable = !1;
  1097. this.hasCleared = !1;
  1098. this.dbName = e, this.dbVersion = t;
  1099. }
  1100. _createClass(BaseTable, [{
  1101. key: "clearDataBase",
  1102. value: function () {
  1103. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1104. var _this = this;
  1105. return regenerator.wrap(function _callee$(_context) {
  1106. while (1) {
  1107. switch (_context.prev = _context.next) {
  1108. case 0:
  1109. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  1110. var n = window.indexedDB.deleteDatabase(_this.dbName);
  1111. n.onsuccess = function () {
  1112. t();
  1113. }, n.onerror = r;
  1114. }));
  1115. case 1:
  1116. case "end":
  1117. return _context.stop();
  1118. }
  1119. }
  1120. }, _callee, this);
  1121. }));
  1122. function clearDataBase(_x) {
  1123. return _clearDataBase.apply(this, arguments);
  1124. }
  1125. return clearDataBase;
  1126. }()
  1127. }, {
  1128. key: "tableName",
  1129. value: function tableName() {
  1130. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  1131. }
  1132. }, {
  1133. key: "keyPath",
  1134. value: function keyPath() {
  1135. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  1136. }
  1137. }, {
  1138. key: "index",
  1139. value: function index() {
  1140. throw new Error("Derived class have to override 'index', and set a proper index name!");
  1141. }
  1142. }, {
  1143. key: "checkAndOpenDatabase",
  1144. value: function () {
  1145. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  1146. var _this2 = this;
  1147. return regenerator.wrap(function _callee2$(_context2) {
  1148. while (1) {
  1149. switch (_context2.prev = _context2.next) {
  1150. case 0:
  1151. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  1152. var n = setTimeout(function () {
  1153. logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  1154. }, 200);
  1155. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  1156. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  1157. }, function () {
  1158. t(new Error("Failed to open database!")), clearTimeout(n);
  1159. }, function () {
  1160. _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  1161. });
  1162. }));
  1163. case 1:
  1164. case "end":
  1165. return _context2.stop();
  1166. }
  1167. }
  1168. }, _callee2, this);
  1169. }));
  1170. function checkAndOpenDatabase() {
  1171. return _checkAndOpenDatabase.apply(this, arguments);
  1172. }
  1173. return checkAndOpenDatabase;
  1174. }()
  1175. }, {
  1176. key: "openDatabase",
  1177. value: function openDatabase(e, t, r, n, o) {
  1178. var _this3 = this;
  1179. if (this.isCreatingTable) return;
  1180. this.isCreatingTable = !0, logger.info(e, t);
  1181. var a = window.indexedDB.open(e, t),
  1182. s = this.tableName();
  1183. a.onsuccess = function (l) {
  1184. _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  1185. }, a.onerror = function (l) {
  1186. var u;
  1187. 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);
  1188. }, a.onupgradeneeded = function (l) {
  1189. var u = l.target.result,
  1190. c = _this3.index();
  1191. logger.info("Creating table ".concat(s, "."));
  1192. var h = u.objectStoreNames.contains(s);
  1193. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  1194. var f = _this3.keyPath();
  1195. h = u.createObjectStore(s, {
  1196. keyPath: f
  1197. });
  1198. }
  1199. c.map(function (f) {
  1200. h.createIndex(f, f, {
  1201. unique: !1
  1202. });
  1203. }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
  1204. };
  1205. }
  1206. }, {
  1207. key: "add",
  1208. value: function () {
  1209. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1210. var t, o;
  1211. return regenerator.wrap(function _callee3$(_context3) {
  1212. while (1) {
  1213. switch (_context3.prev = _context3.next) {
  1214. case 0:
  1215. t = this.tableName();
  1216. _context3.next = 3;
  1217. return this.checkAndOpenDatabase();
  1218. case 3:
  1219. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  1220. return _context3.abrupt("return", new Promise(function (a, s) {
  1221. o.onsuccess = function (l) {
  1222. a(l);
  1223. }, o.onerror = function (l) {
  1224. var u;
  1225. logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  1226. };
  1227. }));
  1228. case 5:
  1229. case "end":
  1230. return _context3.stop();
  1231. }
  1232. }
  1233. }, _callee3, this);
  1234. }));
  1235. function add(_x2) {
  1236. return _add.apply(this, arguments);
  1237. }
  1238. return add;
  1239. }()
  1240. }, {
  1241. key: "put",
  1242. value: function () {
  1243. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  1244. var t, o;
  1245. return regenerator.wrap(function _callee4$(_context4) {
  1246. while (1) {
  1247. switch (_context4.prev = _context4.next) {
  1248. case 0:
  1249. t = this.tableName();
  1250. _context4.next = 3;
  1251. return this.checkAndOpenDatabase();
  1252. case 3:
  1253. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  1254. return _context4.abrupt("return", new Promise(function (a, s) {
  1255. o.onsuccess = function (l) {
  1256. a(l);
  1257. }, o.onerror = function (l) {
  1258. var u;
  1259. logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  1260. };
  1261. }));
  1262. case 5:
  1263. case "end":
  1264. return _context4.stop();
  1265. }
  1266. }
  1267. }, _callee4, this);
  1268. }));
  1269. function put(_x3) {
  1270. return _put.apply(this, arguments);
  1271. }
  1272. return put;
  1273. }()
  1274. }, {
  1275. key: "delete",
  1276. value: function _delete(e, t, r) {
  1277. var n = this.tableName();
  1278. this.checkAndOpenDatabase().then(function (o) {
  1279. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  1280. s.onsuccess = t, s.onerror = r;
  1281. });
  1282. }
  1283. }, {
  1284. key: "update",
  1285. value: function update() {
  1286. this.checkAndOpenDatabase().then(function (e) {});
  1287. }
  1288. }, {
  1289. key: "getAllKeys",
  1290. value: function () {
  1291. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  1292. var e, t;
  1293. return regenerator.wrap(function _callee5$(_context5) {
  1294. while (1) {
  1295. switch (_context5.prev = _context5.next) {
  1296. case 0:
  1297. e = this.tableName();
  1298. _context5.next = 3;
  1299. return this.checkAndOpenDatabase();
  1300. case 3:
  1301. t = _context5.sent;
  1302. return _context5.abrupt("return", new Promise(function (r, n) {
  1303. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  1304. a.onsuccess = function (s) {
  1305. r(s.target.result);
  1306. }, a.onerror = function (s) {
  1307. logger.error("db getAllKeys error", s), n(s);
  1308. };
  1309. }));
  1310. case 5:
  1311. case "end":
  1312. return _context5.stop();
  1313. }
  1314. }
  1315. }, _callee5, this);
  1316. }));
  1317. function getAllKeys() {
  1318. return _getAllKeys.apply(this, arguments);
  1319. }
  1320. return getAllKeys;
  1321. }()
  1322. }, {
  1323. key: "query",
  1324. value: function () {
  1325. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  1326. var r, n;
  1327. return regenerator.wrap(function _callee6$(_context6) {
  1328. while (1) {
  1329. switch (_context6.prev = _context6.next) {
  1330. case 0:
  1331. r = this.tableName();
  1332. _context6.next = 3;
  1333. return this.checkAndOpenDatabase();
  1334. case 3:
  1335. n = _context6.sent;
  1336. return _context6.abrupt("return", new Promise(function (o, a) {
  1337. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  1338. u.onsuccess = function (c) {
  1339. var f;
  1340. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  1341. o && o(h);
  1342. }, u.onerror = function (c) {
  1343. logger.error("db query error", c), a(c);
  1344. };
  1345. }));
  1346. case 5:
  1347. case "end":
  1348. return _context6.stop();
  1349. }
  1350. }
  1351. }, _callee6, this);
  1352. }));
  1353. function query(_x4, _x5) {
  1354. return _query.apply(this, arguments);
  1355. }
  1356. return query;
  1357. }()
  1358. }, {
  1359. key: "sleep",
  1360. value: function () {
  1361. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  1362. return regenerator.wrap(function _callee7$(_context7) {
  1363. while (1) {
  1364. switch (_context7.prev = _context7.next) {
  1365. case 0:
  1366. return _context7.abrupt("return", new Promise(function (t) {
  1367. setTimeout(function () {
  1368. t("");
  1369. }, e);
  1370. }));
  1371. case 1:
  1372. case "end":
  1373. return _context7.stop();
  1374. }
  1375. }
  1376. }, _callee7);
  1377. }));
  1378. function sleep(_x6) {
  1379. return _sleep.apply(this, arguments);
  1380. }
  1381. return sleep;
  1382. }()
  1383. }]);
  1384. return BaseTable;
  1385. }();
  1386. 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); }; }
  1387. 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; } }
  1388. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  1389. _inherits(ModelTable, _BaseTable);
  1390. var _super = _createSuper$1(ModelTable);
  1391. function ModelTable() {
  1392. _classCallCheck(this, ModelTable);
  1393. return _super.call(this, "XverseDatabase", 1);
  1394. }
  1395. _createClass(ModelTable, [{
  1396. key: "tableName",
  1397. value: function tableName() {
  1398. return "models";
  1399. }
  1400. }, {
  1401. key: "index",
  1402. value: function index() {
  1403. return ["url"];
  1404. }
  1405. }, {
  1406. key: "keyPath",
  1407. value: function keyPath() {
  1408. return "url";
  1409. }
  1410. }]);
  1411. return ModelTable;
  1412. }(BaseTable);
  1413. var modelTable = new ModelTable();
  1414. var AxiosCanceler = /*#__PURE__*/function () {
  1415. function AxiosCanceler() {
  1416. _classCallCheck(this, AxiosCanceler);
  1417. this.pendingMap = new Map();
  1418. }
  1419. _createClass(AxiosCanceler, [{
  1420. key: "addPending",
  1421. value: function addPending(e) {
  1422. var _this = this;
  1423. return new axios.CancelToken(function (t) {
  1424. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1425. });
  1426. }
  1427. }, {
  1428. key: "removeAllPending",
  1429. value: function removeAllPending() {
  1430. this.pendingMap.forEach(function (e) {
  1431. e && isFunction(e) && e();
  1432. }), this.pendingMap.clear();
  1433. }
  1434. }, {
  1435. key: "removePending",
  1436. value: function removePending(e) {
  1437. if (this.pendingMap.has(e)) {
  1438. var t = this.pendingMap.get(e);
  1439. t && t(e), this.pendingMap.delete(e);
  1440. }
  1441. }
  1442. }, {
  1443. key: "removeCancelToken",
  1444. value: function removeCancelToken(e) {
  1445. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1446. }
  1447. }, {
  1448. key: "reset",
  1449. value: function reset() {
  1450. this.pendingMap = new Map();
  1451. }
  1452. }]);
  1453. return AxiosCanceler;
  1454. }();
  1455. 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); }; }
  1456. 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; } }
  1457. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1458. _inherits(Http1, _EventEmitter);
  1459. var _super = _createSuper(Http1);
  1460. function Http1() {
  1461. var _this;
  1462. _classCallCheck(this, Http1);
  1463. _this = _super.call(this);
  1464. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1465. return _this;
  1466. }
  1467. _createClass(Http1, [{
  1468. key: "requestConstant",
  1469. value: function requestConstant() {
  1470. return {
  1471. x_nounce: this.randomString(),
  1472. x_timestamp: new Date().getTime(),
  1473. x_os: "web"
  1474. };
  1475. }
  1476. }, {
  1477. key: "requestParams",
  1478. value: function requestParams(e) {
  1479. return oe({}, e.params);
  1480. }
  1481. }, {
  1482. key: "get",
  1483. value: function get(e) {
  1484. return this.request(le(oe({}, e), {
  1485. method: "GET"
  1486. }));
  1487. }
  1488. }, {
  1489. key: "post",
  1490. value: function post(e) {
  1491. return this.request(le(oe({}, e), {
  1492. method: "POST"
  1493. }));
  1494. }
  1495. }, {
  1496. key: "request",
  1497. value: function request(e) {
  1498. var _this2 = this;
  1499. var t = e.url,
  1500. _e$timeout = e.timeout,
  1501. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1502. n = e.method,
  1503. o = e.key,
  1504. a = e.beforeRequest,
  1505. s = e.responseType,
  1506. l = e.data;
  1507. var _e$retry = e.retry,
  1508. u = _e$retry === void 0 ? 0 : _e$retry;
  1509. var c = this.patchUrl(t),
  1510. h = this.canceler.addPending(t);
  1511. a && isFunction(a) && a(e);
  1512. var f = this.requestParams(e);
  1513. var d = {
  1514. url: c,
  1515. method: n,
  1516. timeout: r,
  1517. cancelToken: h,
  1518. responseType: s,
  1519. params: f
  1520. };
  1521. n === "POST" && (d = oe({
  1522. data: l
  1523. }, d));
  1524. var _ = Date.now(),
  1525. g = function g() {
  1526. return _this2.instatnce.request(d).then(function (m) {
  1527. return o && logger.infoAndReportMeasurement({
  1528. metric: "http",
  1529. startTime: _,
  1530. extra: t,
  1531. group: "http",
  1532. tag: o
  1533. }), _this2.canceler.removeCancelToken(t), m;
  1534. }).catch(function (m) {
  1535. var v = axios.isCancel(m);
  1536. return u > 0 && !v ? (u--, logger.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger.infoAndReportMeasurement({
  1537. metric: "http",
  1538. startTime: _,
  1539. error: m,
  1540. extra: {
  1541. url: t,
  1542. isCanceled: v
  1543. },
  1544. tag: o,
  1545. group: "http"
  1546. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1547. });
  1548. };
  1549. return g();
  1550. }
  1551. }, {
  1552. key: "patchUrl",
  1553. value: function patchUrl(e) {
  1554. return e;
  1555. }
  1556. }, {
  1557. key: "randomString",
  1558. value: function randomString() {
  1559. var e = "";
  1560. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1561. r = t.length;
  1562. for (var n = 0; n < 8; n++) {
  1563. e += t.charAt(Math.floor(Math.random() * r));
  1564. }
  1565. return e;
  1566. }
  1567. }]);
  1568. return Http1;
  1569. }(EventEmitter);
  1570. var http1 = new Http1();
  1571. var ModelManager = /*#__PURE__*/function () {
  1572. function ModelManager(e, t) {
  1573. _classCallCheck(this, ModelManager);
  1574. this.avatarModelList = [];
  1575. this.skinList = [];
  1576. this.applicationConfig = null;
  1577. this.config = null;
  1578. this.appId = e, this.releaseId = t;
  1579. }
  1580. _createClass(ModelManager, [{
  1581. key: "findSkinConfig",
  1582. value: function () {
  1583. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1584. var t, n;
  1585. return regenerator.wrap(function _callee$(_context) {
  1586. while (1) {
  1587. switch (_context.prev = _context.next) {
  1588. case 0:
  1589. t = null;
  1590. _context.next = 3;
  1591. return this.getSkinsList();
  1592. case 3:
  1593. t = (this.skinList = _context.sent).find(function (n) {
  1594. return n.id === e;
  1595. });
  1596. if (!t) {
  1597. _context.next = 6;
  1598. break;
  1599. }
  1600. return _context.abrupt("return", t);
  1601. case 6:
  1602. n = "skin is invalid: skinId: ".concat(e);
  1603. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1604. case 8:
  1605. case "end":
  1606. return _context.stop();
  1607. }
  1608. }
  1609. }, _callee, this);
  1610. }));
  1611. function findSkinConfig(_x) {
  1612. return _findSkinConfig.apply(this, arguments);
  1613. }
  1614. return findSkinConfig;
  1615. }()
  1616. }, {
  1617. key: "findRoute",
  1618. value: function () {
  1619. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1620. var n, o;
  1621. return regenerator.wrap(function _callee2$(_context2) {
  1622. while (1) {
  1623. switch (_context2.prev = _context2.next) {
  1624. case 0:
  1625. _context2.next = 2;
  1626. return this.findSkinConfig(e);
  1627. case 2:
  1628. n = _context2.sent.routeList.find(function (o) {
  1629. return o.pathName === t;
  1630. });
  1631. if (n) {
  1632. _context2.next = 6;
  1633. break;
  1634. }
  1635. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1636. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1637. case 6:
  1638. return _context2.abrupt("return", (logger.debug("find route success", n), n));
  1639. case 7:
  1640. case "end":
  1641. return _context2.stop();
  1642. }
  1643. }
  1644. }, _callee2, this);
  1645. }));
  1646. function findRoute(_x2, _x3) {
  1647. return _findRoute.apply(this, arguments);
  1648. }
  1649. return findRoute;
  1650. }()
  1651. }, {
  1652. key: "findAssetList",
  1653. value: function () {
  1654. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1655. var r, n;
  1656. return regenerator.wrap(function _callee3$(_context3) {
  1657. while (1) {
  1658. switch (_context3.prev = _context3.next) {
  1659. case 0:
  1660. _context3.next = 2;
  1661. return this.findSkinConfig(e);
  1662. case 2:
  1663. r = _context3.sent.assetList;
  1664. if (r) {
  1665. _context3.next = 6;
  1666. break;
  1667. }
  1668. n = "find path failed: skinId: ".concat(e);
  1669. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1670. case 6:
  1671. return _context3.abrupt("return", (logger.debug("find route success", r), r));
  1672. case 7:
  1673. case "end":
  1674. return _context3.stop();
  1675. }
  1676. }
  1677. }, _callee3, this);
  1678. }));
  1679. function findAssetList(_x4) {
  1680. return _findAssetList.apply(this, arguments);
  1681. }
  1682. return findAssetList;
  1683. }()
  1684. }, {
  1685. key: "findAsset",
  1686. value: function () {
  1687. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1688. var r,
  1689. n,
  1690. o,
  1691. a,
  1692. _args4 = arguments;
  1693. return regenerator.wrap(function _callee4$(_context4) {
  1694. while (1) {
  1695. switch (_context4.prev = _context4.next) {
  1696. case 0:
  1697. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1698. _context4.next = 3;
  1699. return this.findSkinConfig(e);
  1700. case 3:
  1701. n = _context4.sent;
  1702. if (!Array.isArray(t)) {
  1703. _context4.next = 6;
  1704. break;
  1705. }
  1706. return _context4.abrupt("return", t.map(function (a) {
  1707. return n.models.find(function (s) {
  1708. return s[r] === a;
  1709. });
  1710. }).filter(Boolean));
  1711. case 6:
  1712. o = n.models.find(function (a) {
  1713. return a[r] === t;
  1714. });
  1715. if (o) {
  1716. _context4.next = 10;
  1717. break;
  1718. }
  1719. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1720. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1721. case 10:
  1722. return _context4.abrupt("return", (logger.debug("find asset success", o), o));
  1723. case 11:
  1724. case "end":
  1725. return _context4.stop();
  1726. }
  1727. }
  1728. }, _callee4, this);
  1729. }));
  1730. function findAsset(_x5, _x6) {
  1731. return _findAsset.apply(this, arguments);
  1732. }
  1733. return findAsset;
  1734. }()
  1735. }, {
  1736. key: "findPoint",
  1737. value: function () {
  1738. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1739. var n, o;
  1740. return regenerator.wrap(function _callee5$(_context5) {
  1741. while (1) {
  1742. switch (_context5.prev = _context5.next) {
  1743. case 0:
  1744. _context5.next = 2;
  1745. return this.findSkinConfig(e);
  1746. case 2:
  1747. n = _context5.sent.pointList.find(function (o) {
  1748. return o.id === t;
  1749. });
  1750. if (n) {
  1751. _context5.next = 6;
  1752. break;
  1753. }
  1754. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1755. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1756. case 6:
  1757. return _context5.abrupt("return", (logger.debug("find point success", n), n));
  1758. case 7:
  1759. case "end":
  1760. return _context5.stop();
  1761. }
  1762. }
  1763. }, _callee5, this);
  1764. }));
  1765. function findPoint(_x7, _x8) {
  1766. return _findPoint.apply(this, arguments);
  1767. }
  1768. return findPoint;
  1769. }()
  1770. }, {
  1771. key: "requestConfig",
  1772. value: function () {
  1773. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1774. var t, r, _ref, n, o;
  1775. return regenerator.wrap(function _callee6$(_context6) {
  1776. while (1) {
  1777. switch (_context6.prev = _context6.next) {
  1778. case 0:
  1779. if (!this.config) {
  1780. _context6.next = 2;
  1781. break;
  1782. }
  1783. return _context6.abrupt("return", this.config);
  1784. case 2:
  1785. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1786. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1787. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1788. t = './assets/config.json';
  1789. _context6.prev = 3;
  1790. _context6.next = 6;
  1791. return http1.get({
  1792. url: "".concat(t, "?t=").concat(Date.now()),
  1793. key: "config",
  1794. timeout: 6e3,
  1795. retry: 2
  1796. });
  1797. case 6:
  1798. r = _context6.sent;
  1799. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  1800. if (n) {
  1801. _context6.next = 10;
  1802. break;
  1803. }
  1804. throw new Error("config data parse error" + r.data);
  1805. case 10:
  1806. return _context6.abrupt("return", (this.config = {
  1807. config: n,
  1808. preload: o
  1809. }, logger.debug("get config success", this.config), this.config));
  1810. case 13:
  1811. _context6.prev = 13;
  1812. _context6.t0 = _context6["catch"](3);
  1813. return _context6.abrupt("return", Promise.reject(_context6.t0));
  1814. case 16:
  1815. case "end":
  1816. return _context6.stop();
  1817. }
  1818. }
  1819. }, _callee6, this, [[3, 13]]);
  1820. }));
  1821. function requestConfig() {
  1822. return _requestConfig.apply(this, arguments);
  1823. }
  1824. return requestConfig;
  1825. }()
  1826. }, {
  1827. key: "getApplicationConfig",
  1828. value: function () {
  1829. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  1830. var e;
  1831. return regenerator.wrap(function _callee7$(_context7) {
  1832. while (1) {
  1833. switch (_context7.prev = _context7.next) {
  1834. case 0:
  1835. if (!this.applicationConfig) {
  1836. _context7.next = 2;
  1837. break;
  1838. }
  1839. return _context7.abrupt("return", this.applicationConfig);
  1840. case 2:
  1841. _context7.prev = 2;
  1842. _context7.next = 5;
  1843. return this.requestConfig();
  1844. case 5:
  1845. e = _context7.sent;
  1846. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  1847. case 9:
  1848. _context7.prev = 9;
  1849. _context7.t0 = _context7["catch"](2);
  1850. return _context7.abrupt("return", Promise.reject(_context7.t0));
  1851. case 12:
  1852. case "end":
  1853. return _context7.stop();
  1854. }
  1855. }
  1856. }, _callee7, this, [[2, 9]]);
  1857. }));
  1858. function getApplicationConfig() {
  1859. return _getApplicationConfig.apply(this, arguments);
  1860. }
  1861. return getApplicationConfig;
  1862. }()
  1863. }, {
  1864. key: "getAvatarModelList",
  1865. value: function () {
  1866. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  1867. var _yield$this$getApplic, e;
  1868. return regenerator.wrap(function _callee8$(_context8) {
  1869. while (1) {
  1870. switch (_context8.prev = _context8.next) {
  1871. case 0:
  1872. if (!this.avatarModelList.length) {
  1873. _context8.next = 2;
  1874. break;
  1875. }
  1876. return _context8.abrupt("return", this.avatarModelList);
  1877. case 2:
  1878. _context8.prev = 2;
  1879. _context8.next = 5;
  1880. return this.getApplicationConfig();
  1881. case 5:
  1882. _yield$this$getApplic = _context8.sent;
  1883. e = _yield$this$getApplic.avatars;
  1884. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  1885. return {
  1886. name: t.name,
  1887. id: t.id,
  1888. modelUrl: t.url,
  1889. gender: t.gender,
  1890. components: t.components
  1891. };
  1892. }), this.avatarModelList));
  1893. case 10:
  1894. _context8.prev = 10;
  1895. _context8.t0 = _context8["catch"](2);
  1896. return _context8.abrupt("return", (logger.error(_context8.t0), []));
  1897. case 13:
  1898. case "end":
  1899. return _context8.stop();
  1900. }
  1901. }
  1902. }, _callee8, this, [[2, 10]]);
  1903. }));
  1904. function getAvatarModelList() {
  1905. return _getAvatarModelList.apply(this, arguments);
  1906. }
  1907. return getAvatarModelList;
  1908. }()
  1909. }, {
  1910. key: "getSkinsList",
  1911. value: function () {
  1912. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  1913. var _yield$this$getApplic2, e;
  1914. return regenerator.wrap(function _callee9$(_context9) {
  1915. while (1) {
  1916. switch (_context9.prev = _context9.next) {
  1917. case 0:
  1918. if (!this.skinList.length) {
  1919. _context9.next = 2;
  1920. break;
  1921. }
  1922. return _context9.abrupt("return", this.skinList);
  1923. case 2:
  1924. _context9.prev = 2;
  1925. _context9.next = 5;
  1926. return this.getApplicationConfig();
  1927. case 5:
  1928. _yield$this$getApplic2 = _context9.sent;
  1929. e = _yield$this$getApplic2.skins;
  1930. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  1931. var r;
  1932. return {
  1933. name: t.name,
  1934. dataVersion: t.id + t.versionId,
  1935. id: t.id,
  1936. fov: parseInt(t.fov || 90),
  1937. models: t.assetList.map(function (n) {
  1938. var o = n.assetId,
  1939. a = n.url,
  1940. s = n.thumbnailUrl,
  1941. l = n.typeName,
  1942. u = n.className;
  1943. return {
  1944. id: o,
  1945. modelUrl: a,
  1946. name: n.name,
  1947. thumbnailUrl: s,
  1948. typeName: l,
  1949. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  1950. };
  1951. }),
  1952. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  1953. var o = n.areaName,
  1954. a = n.attitude,
  1955. s = n.id,
  1956. l = n.pathName,
  1957. u = n.step,
  1958. c = n.birthPointList;
  1959. return {
  1960. areaName: o,
  1961. attitude: a,
  1962. id: s,
  1963. pathName: l,
  1964. step: u,
  1965. birthPointList: c.map(function (h) {
  1966. return {
  1967. camera: h.camera && {
  1968. position: objectParseFloat(h.camera.position),
  1969. angle: objectParseFloat(h.camera.rotation)
  1970. },
  1971. player: h.player && {
  1972. position: objectParseFloat(h.player.position),
  1973. angle: objectParseFloat(h.player.rotation)
  1974. }
  1975. };
  1976. })
  1977. };
  1978. }),
  1979. pointList: t.pointList.map(function (n) {
  1980. return le(oe({}, n), {
  1981. position: objectParseFloat(n.position),
  1982. rotation: objectParseFloat(n.rotation)
  1983. });
  1984. }),
  1985. versionId: t.versionId,
  1986. isEnable: t.isEnable,
  1987. assetList: t.assetList,
  1988. visibleRules: t.visibleRules,
  1989. animationList: t.animationList
  1990. };
  1991. }), this.skinList));
  1992. case 10:
  1993. _context9.prev = 10;
  1994. _context9.t0 = _context9["catch"](2);
  1995. return _context9.abrupt("return", (logger.error(_context9.t0), []));
  1996. case 13:
  1997. case "end":
  1998. return _context9.stop();
  1999. }
  2000. }
  2001. }, _callee9, this, [[2, 10]]);
  2002. }));
  2003. function getSkinsList() {
  2004. return _getSkinsList.apply(this, arguments);
  2005. }
  2006. return getSkinsList;
  2007. }()
  2008. }, {
  2009. key: "getBreathPointTextrueList",
  2010. value: function () {
  2011. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  2012. return regenerator.wrap(function _callee10$(_context10) {
  2013. while (1) {
  2014. switch (_context10.prev = _context10.next) {
  2015. case 0:
  2016. return _context10.abrupt("return", [{
  2017. url: TEXTURE_URL
  2018. }]);
  2019. case 1:
  2020. case "end":
  2021. return _context10.stop();
  2022. }
  2023. }
  2024. }, _callee10);
  2025. }));
  2026. function getBreathPointTextrueList() {
  2027. return _getBreathPointTextrueList.apply(this, arguments);
  2028. }
  2029. return getBreathPointTextrueList;
  2030. }()
  2031. }], [{
  2032. key: "getInstance",
  2033. value: function getInstance(e, t) {
  2034. //getInstance(e, t) {
  2035. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  2036. }
  2037. }, {
  2038. key: "findModels",
  2039. value: function findModels(e, t, r) {
  2040. //findModels(e, t, r) {
  2041. return e.filter(function (o) {
  2042. return o.typeName === t && o.className === r;
  2043. });
  2044. }
  2045. }, {
  2046. key: "findModel",
  2047. value: function findModel(e, t, r) {
  2048. //findModel(e, t, r) {
  2049. var n = e.filter(function (o) {
  2050. return o.typeName === t && o.className === r;
  2051. })[0];
  2052. return n || null;
  2053. }
  2054. }]);
  2055. return ModelManager;
  2056. }();
  2057. // export { modelManager };
  2058. var Preload = /*#__PURE__*/function () {
  2059. function Preload(e) {
  2060. _classCallCheck(this, Preload);
  2061. this.config = null;
  2062. this.allKeys = [];
  2063. this.oldResourcesDeleted = !1;
  2064. this.requests = {
  2065. simple: {
  2066. stopped: !0,
  2067. requests: {}
  2068. },
  2069. observer: {
  2070. stopped: !0,
  2071. requests: {}
  2072. },
  2073. full: {
  2074. stopped: !0,
  2075. requests: {}
  2076. }
  2077. };
  2078. this.modelManager = e, this.init(e.appId);
  2079. }
  2080. _createClass(Preload, [{
  2081. key: "init",
  2082. value: function init(e) {
  2083. reporter.updateBody({
  2084. appId: e
  2085. });
  2086. }
  2087. }, {
  2088. key: "getConfig",
  2089. value: function () {
  2090. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2091. var _yield$this$modelMana, t;
  2092. return regenerator.wrap(function _callee$(_context) {
  2093. while (1) {
  2094. switch (_context.prev = _context.next) {
  2095. case 0:
  2096. if (!this.config) {
  2097. _context.next = 2;
  2098. break;
  2099. }
  2100. return _context.abrupt("return", this.config);
  2101. case 2:
  2102. _context.next = 4;
  2103. return this.modelManager.requestConfig();
  2104. case 4:
  2105. _yield$this$modelMana = _context.sent;
  2106. t = _yield$this$modelMana.preload;
  2107. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  2108. case 7:
  2109. case "end":
  2110. return _context.stop();
  2111. }
  2112. }
  2113. }, _callee, this);
  2114. }));
  2115. function getConfig(_x) {
  2116. return _getConfig.apply(this, arguments);
  2117. }
  2118. return getConfig;
  2119. }()
  2120. }, {
  2121. key: "getAllKeys",
  2122. value: function () {
  2123. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2124. var e, t;
  2125. return regenerator.wrap(function _callee2$(_context2) {
  2126. while (1) {
  2127. switch (_context2.prev = _context2.next) {
  2128. case 0:
  2129. if (!this.allKeys.length) {
  2130. _context2.next = 2;
  2131. break;
  2132. }
  2133. return _context2.abrupt("return", this.allKeys);
  2134. case 2:
  2135. _context2.prev = 2;
  2136. _context2.next = 5;
  2137. return modelTable.getAllKeys();
  2138. case 5:
  2139. e = _context2.sent;
  2140. this.allKeys = e;
  2141. return _context2.abrupt("return", e);
  2142. case 10:
  2143. _context2.prev = 10;
  2144. _context2.t0 = _context2["catch"](2);
  2145. t = "preload getAllKeys error";
  2146. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  2147. case 14:
  2148. case "end":
  2149. return _context2.stop();
  2150. }
  2151. }
  2152. }, _callee2, this, [[2, 10]]);
  2153. }));
  2154. function getAllKeys() {
  2155. return _getAllKeys.apply(this, arguments);
  2156. }
  2157. return getAllKeys;
  2158. }()
  2159. }, {
  2160. key: "stop",
  2161. value: function stop(e) {
  2162. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  2163. var t = this.requests[e].requests;
  2164. Object.keys(t).forEach(function (r) {
  2165. http1.canceler.removePending(r), delete t[r];
  2166. });
  2167. }
  2168. }, {
  2169. key: "clearPreload",
  2170. value: function clearPreload(e) {
  2171. this.requests[e].stopped = !1, this.allKeys = [];
  2172. }
  2173. }, {
  2174. key: "start",
  2175. value: function () {
  2176. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  2177. var n, o, a, s, l, u, h, f, _s;
  2178. return regenerator.wrap(function _callee3$(_context3) {
  2179. while (1) {
  2180. switch (_context3.prev = _context3.next) {
  2181. case 0:
  2182. n = Date.now(), o = 0;
  2183. _context3.prev = 1;
  2184. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  2185. _context3.next = 4;
  2186. break;
  2187. }
  2188. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  2189. case 4:
  2190. this.clearPreload(e);
  2191. _context3.next = 7;
  2192. return this.getConfig(e);
  2193. case 7:
  2194. a = _context3.sent;
  2195. _context3.next = 10;
  2196. return this.getAllKeys();
  2197. case 10:
  2198. s = _context3.sent;
  2199. _context3.prev = 11;
  2200. _context3.next = 14;
  2201. return this.deleteOldResources(a.assetUrls.map(function (d) {
  2202. return d.url;
  2203. }), s);
  2204. case 14:
  2205. _context3.next = 19;
  2206. break;
  2207. case 16:
  2208. _context3.prev = 16;
  2209. _context3.t0 = _context3["catch"](11);
  2210. logger.error(_context3.t0);
  2211. case 19:
  2212. l = a.baseUrls, u = a.assetUrls;
  2213. _context3.t1 = e;
  2214. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  2215. break;
  2216. case 23:
  2217. h = l;
  2218. return _context3.abrupt("break", 30);
  2219. case 25:
  2220. h = u;
  2221. return _context3.abrupt("break", 30);
  2222. case 27:
  2223. h = u;
  2224. return _context3.abrupt("break", 30);
  2225. case 29:
  2226. h = u;
  2227. case 30:
  2228. f = h.filter(function (d) {
  2229. return !s.includes(d.url);
  2230. });
  2231. r && isFunction(r) && (f = f.filter(r));
  2232. o = f.length;
  2233. logger.debug("keysNeedToPreload", f);
  2234. f.length || t && t(h.length, h.length);
  2235. n = Date.now();
  2236. _context3.next = 38;
  2237. return this._preload(e, f, t);
  2238. case 38:
  2239. logger.infoAndReportMeasurement({
  2240. tag: e,
  2241. startTime: n,
  2242. metric: "assetsPreload",
  2243. extra: {
  2244. total: o
  2245. }
  2246. });
  2247. return _context3.abrupt("return");
  2248. case 42:
  2249. _context3.prev = 42;
  2250. _context3.t2 = _context3["catch"](1);
  2251. _s = _context3.t2;
  2252. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  2253. tag: e,
  2254. startTime: n,
  2255. metric: "assetsPreload",
  2256. extra: {
  2257. total: o
  2258. },
  2259. error: _s,
  2260. reportOptions: {
  2261. immediate: !0
  2262. }
  2263. }), Promise.reject(_s)));
  2264. case 46:
  2265. case "end":
  2266. return _context3.stop();
  2267. }
  2268. }
  2269. }, _callee3, this, [[1, 42], [11, 16]]);
  2270. }));
  2271. function start(_x2, _x3, _x4) {
  2272. return _start.apply(this, arguments);
  2273. }
  2274. return start;
  2275. }()
  2276. }, {
  2277. key: "deleteOldResources",
  2278. value: function deleteOldResources(e, t) {
  2279. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  2280. var r = t.filter(function (n) {
  2281. return !e.includes(n);
  2282. });
  2283. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  2284. return modelTable.delete(n);
  2285. }));
  2286. }
  2287. }, {
  2288. key: "_preload",
  2289. value: function () {
  2290. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  2291. var _this = this;
  2292. var n, o, a;
  2293. return regenerator.wrap(function _callee6$(_context6) {
  2294. while (1) {
  2295. switch (_context6.prev = _context6.next) {
  2296. case 0:
  2297. n = t.length;
  2298. if (n) {
  2299. _context6.next = 3;
  2300. break;
  2301. }
  2302. return _context6.abrupt("return", Promise.resolve());
  2303. case 3:
  2304. o = 0;
  2305. a = window.setInterval(function () {
  2306. r && r(o, n), o >= n && window.clearInterval(a);
  2307. }, 1e3);
  2308. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  2309. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  2310. var l, u;
  2311. return regenerator.wrap(function _callee5$(_context5) {
  2312. while (1) {
  2313. switch (_context5.prev = _context5.next) {
  2314. case 0:
  2315. l = s.size, u = s.url;
  2316. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  2317. url: u,
  2318. timeout: Preload.getTimeoutBySize(l),
  2319. responseType: "blob",
  2320. retry: 2,
  2321. beforeRequest: function beforeRequest() {
  2322. _this.requests[e].requests[u] = !0;
  2323. }
  2324. }).then( /*#__PURE__*/function () {
  2325. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  2326. var h, f;
  2327. return regenerator.wrap(function _callee4$(_context4) {
  2328. while (1) {
  2329. switch (_context4.prev = _context4.next) {
  2330. case 0:
  2331. h = c.data;
  2332. if (h instanceof Blob) {
  2333. _context4.next = 3;
  2334. break;
  2335. }
  2336. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  2337. case 3:
  2338. _context4.next = 5;
  2339. return blobToDataURI(h);
  2340. case 5:
  2341. f = _context4.sent;
  2342. _context4.prev = 6;
  2343. _context4.next = 9;
  2344. return modelTable.put({
  2345. url: u,
  2346. model: f
  2347. });
  2348. case 9:
  2349. return _context4.abrupt("return");
  2350. case 12:
  2351. _context4.prev = 12;
  2352. _context4.t0 = _context4["catch"](6);
  2353. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  2354. case 15:
  2355. case "end":
  2356. return _context4.stop();
  2357. }
  2358. }
  2359. }, _callee4, null, [[6, 12]]);
  2360. }));
  2361. return function (_x9) {
  2362. return _ref2.apply(this, arguments);
  2363. };
  2364. }()).then(function () {
  2365. o++, delete _this.requests[e].requests[u];
  2366. }, function (c) {
  2367. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  2368. }));
  2369. case 2:
  2370. case "end":
  2371. return _context5.stop();
  2372. }
  2373. }
  2374. }, _callee5);
  2375. }));
  2376. return function (_x8) {
  2377. return _ref.apply(this, arguments);
  2378. };
  2379. }()));
  2380. case 6:
  2381. case "end":
  2382. return _context6.stop();
  2383. }
  2384. }
  2385. }, _callee6);
  2386. }));
  2387. function _preload(_x5, _x6, _x7) {
  2388. return _preload2.apply(this, arguments);
  2389. }
  2390. return _preload;
  2391. }()
  2392. }], [{
  2393. key: "getTimeoutBySize",
  2394. value: function getTimeoutBySize(e) {
  2395. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  2396. }
  2397. }]);
  2398. return Preload;
  2399. }();
  2400. var Xverse = /*#__PURE__*/function () {
  2401. function Xverse(e) {
  2402. _classCallCheck(this, Xverse);
  2403. e || (e = {});
  2404. var _e = e,
  2405. t = _e.onLog,
  2406. r = _e.env,
  2407. n = _e.appId,
  2408. o = _e.releaseId,
  2409. a = _e.subPackageVersion;
  2410. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && Logger.setLevel(LoggerLevels.Debug);
  2411. var s = this.pageSession = util.uuid();
  2412. reporter.updateHeader({
  2413. pageSession: s
  2414. });
  2415. reporter.updateReportUrl(REPORT_URL[this.env]);
  2416. a && reporter.updateBody({
  2417. sdkVersion: a
  2418. });
  2419. logger.infoAndReportMeasurement({
  2420. metric: "sdkInit",
  2421. startTime: Date.now(),
  2422. extra: {
  2423. version: a,
  2424. enviroment: r,
  2425. pageSession: s
  2426. }
  2427. });
  2428. logger.debug("debug mode:", this.debug);
  2429. reporter.on("report", function (l) {
  2430. t && t(l);
  2431. });
  2432. if (n) {
  2433. this.appId = n, this.releaseId = o;
  2434. var l = ModelManager.getInstance(n, o);
  2435. this.preload = new Preload(l);
  2436. }
  2437. }
  2438. _createClass(Xverse, [{
  2439. key: "isSupported",
  2440. get: function get() {
  2441. return isSupported();
  2442. }
  2443. }, {
  2444. key: "disableLogUpload",
  2445. value: function disableLogUpload() {
  2446. reporter.disable(), logger.debug("logger upload has been disabled");
  2447. }
  2448. }, {
  2449. key: "getSkinList",
  2450. value: function () {
  2451. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  2452. return regenerator.wrap(function _callee$(_context) {
  2453. while (1) {
  2454. switch (_context.prev = _context.next) {
  2455. case 0:
  2456. return _context.abrupt("return", []);
  2457. case 1:
  2458. case "end":
  2459. return _context.stop();
  2460. }
  2461. }
  2462. }, _callee);
  2463. }));
  2464. function getSkinList() {
  2465. return _getSkinList.apply(this, arguments);
  2466. }
  2467. return getSkinList;
  2468. }()
  2469. }, {
  2470. key: "getAvatarList",
  2471. value: function () {
  2472. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2473. return regenerator.wrap(function _callee2$(_context2) {
  2474. while (1) {
  2475. switch (_context2.prev = _context2.next) {
  2476. case 0:
  2477. return _context2.abrupt("return", []);
  2478. case 1:
  2479. case "end":
  2480. return _context2.stop();
  2481. }
  2482. }
  2483. }, _callee2);
  2484. }));
  2485. function getAvatarList() {
  2486. return _getAvatarList.apply(this, arguments);
  2487. }
  2488. return getAvatarList;
  2489. }()
  2490. }, {
  2491. key: "getGiftList",
  2492. value: function () {
  2493. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  2494. return regenerator.wrap(function _callee3$(_context3) {
  2495. while (1) {
  2496. switch (_context3.prev = _context3.next) {
  2497. case 0:
  2498. return _context3.abrupt("return", [{
  2499. id: "hack "
  2500. }]);
  2501. case 1:
  2502. case "end":
  2503. return _context3.stop();
  2504. }
  2505. }
  2506. }, _callee3);
  2507. }));
  2508. function getGiftList() {
  2509. return _getGiftList.apply(this, arguments);
  2510. }
  2511. return getGiftList;
  2512. }()
  2513. }, {
  2514. key: "joinRoom",
  2515. value: function () {
  2516. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2517. var t, r, n, o;
  2518. return regenerator.wrap(function _callee4$(_context4) {
  2519. while (1) {
  2520. switch (_context4.prev = _context4.next) {
  2521. case 0:
  2522. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), {
  2523. appId: e.appId || this.appId,
  2524. releaseId: e.releaseId || this.releaseId,
  2525. pageSession: this.pageSession,
  2526. isAllSync: !0,
  2527. rotationRenderType: r,
  2528. syncByEvent: !0,
  2529. pathName: t,
  2530. person: n,
  2531. role: e.role || "audience"
  2532. }));
  2533. return _context4.abrupt("return", o.initRoom().then(function () {
  2534. return o;
  2535. }));
  2536. case 2:
  2537. case "end":
  2538. return _context4.stop();
  2539. }
  2540. }
  2541. }, _callee4, this);
  2542. }));
  2543. function joinRoom(_x) {
  2544. return _joinRoom.apply(this, arguments);
  2545. }
  2546. return joinRoom;
  2547. }()
  2548. }]);
  2549. return Xverse;
  2550. }();
  2551. var xverse = new Xverse({
  2552. env: "DEV",
  2553. appId: 10016,
  2554. releaseId: '2203120033_29769e'
  2555. });
  2556. var l = /*#__PURE__*/function () {
  2557. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  2558. var R;
  2559. return regenerator.wrap(function _callee$(_context) {
  2560. while (1) {
  2561. switch (_context.prev = _context.next) {
  2562. case 0:
  2563. _context.prev = 0;
  2564. _context.next = 3;
  2565. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  2566. });
  2567. case 3:
  2568. _context.next = 12;
  2569. break;
  2570. case 5:
  2571. _context.prev = 5;
  2572. _context.t0 = _context["catch"](0);
  2573. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  2574. _context.next = 10;
  2575. break;
  2576. }
  2577. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  2578. return _context.abrupt("return");
  2579. case 10:
  2580. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  2581. return _context.abrupt("return");
  2582. case 12:
  2583. _context.prev = 12;
  2584. _context.next = 15;
  2585. return xverse.joinRoom({
  2586. canvas: document.getElementById('canvas'),
  2587. skinId: 10092,
  2588. avatarId: 'KGe_Boy',
  2589. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  2590. userId: '1f7acca1db9d5',
  2591. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  2592. appId: 10016,
  2593. token: " ",
  2594. nickname: '1f7acca1db9d5',
  2595. firends: ["user1"],
  2596. viewMode: "full",
  2597. resolution: {
  2598. width: 1728,
  2599. height: 720
  2600. },
  2601. pathName: 'thirdwalk',
  2602. objectFit: null,
  2603. hasAvatar: !0,
  2604. syncToOthers: !0
  2605. });
  2606. case 15:
  2607. room = _context.sent;
  2608. u(), c(), window.room = room, e(!1);
  2609. _context.next = 23;
  2610. break;
  2611. case 19:
  2612. _context.prev = 19;
  2613. _context.t1 = _context["catch"](12);
  2614. console.error(_context.t1), alert(_context.t1);
  2615. return _context.abrupt("return");
  2616. case 23:
  2617. case "end":
  2618. return _context.stop();
  2619. }
  2620. }
  2621. }, _callee, null, [[0, 5], [12, 19]]);
  2622. }));
  2623. return function l() {
  2624. return _ref.apply(this, arguments);
  2625. };
  2626. }();
  2627. var u = function u() {
  2628. room.on("_coreClick", function (_ref2) {
  2629. var f = _ref2.point;
  2630. room._userAvatar.moveTo({
  2631. point: f
  2632. });
  2633. });
  2634. };
  2635. var c = function c() {
  2636. room.on("repeatLogin", function () {
  2637. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  2638. duration: 1e4
  2639. });
  2640. }), room.on("reconnecting", function (_ref3) {
  2641. var f = _ref3.count;
  2642. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  2643. }), room.on("reconnected", function () {
  2644. toast("\u91CD\u8FDE\u6210\u529F");
  2645. }), room.on("disconnected", function () {
  2646. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  2647. duration: 1e5,
  2648. onClick() {
  2649. f.hideToast(), room.reconnect();
  2650. }
  2651. });
  2652. });
  2653. };
  2654. l();
  2655. }));
  2656. //# sourceMappingURL=index.js.map