index.js 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/8
  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. 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); }; }
  1093. 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; } }
  1094. var Http = /*#__PURE__*/function (_EventEmitter) {
  1095. _inherits(Http, _EventEmitter);
  1096. var _super = _createSuper$1(Http);
  1097. function Http() {
  1098. _classCallCheck(this, Http);
  1099. return _super.apply(this, arguments);
  1100. }
  1101. _createClass(Http, [{
  1102. key: "get",
  1103. value: function () {
  1104. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  1105. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  1106. return regenerator.wrap(function _callee2$(_context2) {
  1107. while (1) {
  1108. switch (_context2.prev = _context2.next) {
  1109. case 0:
  1110. e = _ref.url, _ref$useIndexedDb = _ref.useIndexedDb, t = _ref$useIndexedDb === void 0 ? !1 : _ref$useIndexedDb, _ref$timeout = _ref.timeout, r = _ref$timeout === void 0 ? 15e3 : _ref$timeout, n = _ref.key, _ref$isOutPutObjectUR = _ref.isOutPutObjectURL, o = _ref$isOutPutObjectUR === void 0 ? !0 : _ref$isOutPutObjectUR;
  1111. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  1112. _context2.next = 25;
  1113. break;
  1114. }
  1115. if (!isIndexedDbSupported()) {
  1116. _context2.next = 22;
  1117. break;
  1118. }
  1119. window.performance.now();
  1120. a = null;
  1121. _context2.prev = 5;
  1122. _context2.next = 8;
  1123. return modelTable.query("url", e);
  1124. case 8:
  1125. a = _context2.sent;
  1126. _context2.next = 14;
  1127. break;
  1128. case 11:
  1129. _context2.prev = 11;
  1130. _context2.t0 = _context2["catch"](5);
  1131. return _context2.abrupt("return", (logger.debug(_context2.t0), logger.warn("cache query error", e), Promise.resolve(e)));
  1132. case 14:
  1133. if (!(a && a.model)) {
  1134. _context2.next = 19;
  1135. break;
  1136. }
  1137. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  1138. return _context2.abrupt("return", (window.performance.now(), l));
  1139. case 19:
  1140. return _context2.abrupt("return", this.request({
  1141. url: e,
  1142. timeout: r,
  1143. contentType: "blob",
  1144. key: n
  1145. }).then( /*#__PURE__*/function () {
  1146. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  1147. var l;
  1148. return regenerator.wrap(function _callee$(_context) {
  1149. while (1) {
  1150. switch (_context.prev = _context.next) {
  1151. case 0:
  1152. _context.next = 2;
  1153. return blobToDataURI(s.response);
  1154. case 2:
  1155. l = _context.sent;
  1156. _context.prev = 3;
  1157. _context.next = 6;
  1158. return modelTable.put({
  1159. url: e,
  1160. model: l
  1161. });
  1162. case 6:
  1163. _context.next = 11;
  1164. break;
  1165. case 8:
  1166. _context.prev = 8;
  1167. _context.t0 = _context["catch"](3);
  1168. logger.warn("unable to add data to indexedDB", _context.t0);
  1169. case 11:
  1170. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  1171. case 12:
  1172. case "end":
  1173. return _context.stop();
  1174. }
  1175. }
  1176. }, _callee, null, [[3, 8]]);
  1177. }));
  1178. return function (_x2) {
  1179. return _ref2.apply(this, arguments);
  1180. };
  1181. }()));
  1182. case 20:
  1183. _context2.next = 23;
  1184. break;
  1185. case 22:
  1186. return _context2.abrupt("return", this.request({
  1187. url: e,
  1188. timeout: r,
  1189. contentType: "blob",
  1190. key: n
  1191. }).then(function (a) {
  1192. var s = a.response;
  1193. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  1194. }).catch(function (a) {
  1195. return Promise.reject(a);
  1196. }));
  1197. case 23:
  1198. _context2.next = 26;
  1199. break;
  1200. case 25:
  1201. return _context2.abrupt("return", this.request({
  1202. url: e,
  1203. timeout: r,
  1204. key: n
  1205. }).then(function (a) {
  1206. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  1207. }));
  1208. case 26:
  1209. case "end":
  1210. return _context2.stop();
  1211. }
  1212. }
  1213. }, _callee2, this, [[5, 11]]);
  1214. }));
  1215. function get(_x) {
  1216. return _get.apply(this, arguments);
  1217. }
  1218. return get;
  1219. }()
  1220. }, {
  1221. key: "request",
  1222. value: function request(e) {
  1223. var _this = this;
  1224. var _e$timeout = e.timeout,
  1225. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  1226. r = e.contentType;
  1227. e.key;
  1228. var o = e.onRequestStart,
  1229. a = e.url;
  1230. return new Promise(function (s, l) {
  1231. window.performance.now();
  1232. var u = new XMLHttpRequest();
  1233. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  1234. if (u.readyState == 4) {
  1235. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  1236. message: "request ".concat(a, " load success")
  1237. }), s(u);
  1238. {
  1239. var c = "Unable to load the request ".concat(a);
  1240. return _this.emit("error", {
  1241. message: c
  1242. }), logger.error(c), l(c);
  1243. }
  1244. }
  1245. }), o && o(u), u.open("GET", a), u.send();
  1246. });
  1247. }
  1248. }]);
  1249. return Http;
  1250. }(EventEmitter);
  1251. var http = new Http();
  1252. // , isIndexedDbSupported = ()=>(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0
  1253. // , blobToDataURI = async i=>new Promise((e,t)=>{
  1254. // const r = new FileReader;
  1255. // r.readAsDataURL(i),
  1256. // r.onload = function(n) {
  1257. // var o;
  1258. // e((o = n.target) == null ? void 0 : o.result)
  1259. // }
  1260. // ,
  1261. // r.onerror = function(n) {
  1262. // t(n)
  1263. // }
  1264. // }
  1265. // )
  1266. // , dataURItoBlob = i=>{
  1267. // let e;
  1268. // i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
  1269. // const t = i.split(",")[0].split(":")[1].split(";")[0]
  1270. // , r = new Uint8Array(e.length);
  1271. // for (let o = 0; o < e.length; o++)
  1272. // r[o] = e.charCodeAt(o);
  1273. // return new Blob([r],{
  1274. // type: t
  1275. // })
  1276. // }
  1277. // , urlMap = new Map
  1278. // , urlTransformer = async(i,e=!1)=>typeof i != "string" ? (console.warn("url transformer error", i),
  1279. // i) : i.startsWith("blob:") ? i : e ? http.get({
  1280. // url: i,
  1281. // useIndexedDb: !0,
  1282. // key: "url",
  1283. // isOutPutObjectURL: !1
  1284. // }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  1285. // url: i,
  1286. // useIndexedDb: !0,
  1287. // key: "url"
  1288. // }).then(t=>(urlMap.set(i, t),
  1289. // t));
  1290. var ModelManager = /*#__PURE__*/function () {
  1291. function ModelManager(e, t) {
  1292. _classCallCheck(this, ModelManager);
  1293. this.avatarModelList = [];
  1294. this.skinList = [];
  1295. this.applicationConfig = null;
  1296. this.config = null;
  1297. this.appId = e, this.releaseId = t;
  1298. }
  1299. _createClass(ModelManager, [{
  1300. key: "findSkinConfig",
  1301. value: function () {
  1302. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1303. var t, n;
  1304. return regenerator.wrap(function _callee$(_context) {
  1305. while (1) {
  1306. switch (_context.prev = _context.next) {
  1307. case 0:
  1308. t = null;
  1309. _context.next = 3;
  1310. return this.getSkinsList();
  1311. case 3:
  1312. t = (this.skinList = _context.sent).find(function (n) {
  1313. return n.id === e;
  1314. });
  1315. if (!t) {
  1316. _context.next = 6;
  1317. break;
  1318. }
  1319. return _context.abrupt("return", t);
  1320. case 6:
  1321. n = "skin is invalid: skinId: ".concat(e);
  1322. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1323. case 8:
  1324. case "end":
  1325. return _context.stop();
  1326. }
  1327. }
  1328. }, _callee, this);
  1329. }));
  1330. function findSkinConfig(_x) {
  1331. return _findSkinConfig.apply(this, arguments);
  1332. }
  1333. return findSkinConfig;
  1334. }()
  1335. }, {
  1336. key: "findRoute",
  1337. value: function () {
  1338. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1339. var n, o;
  1340. return regenerator.wrap(function _callee2$(_context2) {
  1341. while (1) {
  1342. switch (_context2.prev = _context2.next) {
  1343. case 0:
  1344. _context2.next = 2;
  1345. return this.findSkinConfig(e);
  1346. case 2:
  1347. n = _context2.sent.routeList.find(function (o) {
  1348. return o.pathName === t;
  1349. });
  1350. if (n) {
  1351. _context2.next = 6;
  1352. break;
  1353. }
  1354. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1355. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1356. case 6:
  1357. return _context2.abrupt("return", (logger.debug("find route success", n), n));
  1358. case 7:
  1359. case "end":
  1360. return _context2.stop();
  1361. }
  1362. }
  1363. }, _callee2, this);
  1364. }));
  1365. function findRoute(_x2, _x3) {
  1366. return _findRoute.apply(this, arguments);
  1367. }
  1368. return findRoute;
  1369. }()
  1370. }, {
  1371. key: "findAssetList",
  1372. value: function () {
  1373. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1374. var r, n;
  1375. return regenerator.wrap(function _callee3$(_context3) {
  1376. while (1) {
  1377. switch (_context3.prev = _context3.next) {
  1378. case 0:
  1379. _context3.next = 2;
  1380. return this.findSkinConfig(e);
  1381. case 2:
  1382. r = _context3.sent.assetList;
  1383. if (r) {
  1384. _context3.next = 6;
  1385. break;
  1386. }
  1387. n = "find path failed: skinId: ".concat(e);
  1388. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1389. case 6:
  1390. return _context3.abrupt("return", (logger.debug("find route success", r), r));
  1391. case 7:
  1392. case "end":
  1393. return _context3.stop();
  1394. }
  1395. }
  1396. }, _callee3, this);
  1397. }));
  1398. function findAssetList(_x4) {
  1399. return _findAssetList.apply(this, arguments);
  1400. }
  1401. return findAssetList;
  1402. }()
  1403. }, {
  1404. key: "findAsset",
  1405. value: function () {
  1406. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1407. var r,
  1408. n,
  1409. o,
  1410. a,
  1411. _args4 = arguments;
  1412. return regenerator.wrap(function _callee4$(_context4) {
  1413. while (1) {
  1414. switch (_context4.prev = _context4.next) {
  1415. case 0:
  1416. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1417. _context4.next = 3;
  1418. return this.findSkinConfig(e);
  1419. case 3:
  1420. n = _context4.sent;
  1421. if (!Array.isArray(t)) {
  1422. _context4.next = 6;
  1423. break;
  1424. }
  1425. return _context4.abrupt("return", t.map(function (a) {
  1426. return n.models.find(function (s) {
  1427. return s[r] === a;
  1428. });
  1429. }).filter(Boolean));
  1430. case 6:
  1431. o = n.models.find(function (a) {
  1432. return a[r] === t;
  1433. });
  1434. if (o) {
  1435. _context4.next = 10;
  1436. break;
  1437. }
  1438. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1439. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1440. case 10:
  1441. return _context4.abrupt("return", (logger.debug("find asset success", o), o));
  1442. case 11:
  1443. case "end":
  1444. return _context4.stop();
  1445. }
  1446. }
  1447. }, _callee4, this);
  1448. }));
  1449. function findAsset(_x5, _x6) {
  1450. return _findAsset.apply(this, arguments);
  1451. }
  1452. return findAsset;
  1453. }()
  1454. }, {
  1455. key: "findPoint",
  1456. value: function () {
  1457. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1458. var n, o;
  1459. return regenerator.wrap(function _callee5$(_context5) {
  1460. while (1) {
  1461. switch (_context5.prev = _context5.next) {
  1462. case 0:
  1463. _context5.next = 2;
  1464. return this.findSkinConfig(e);
  1465. case 2:
  1466. n = _context5.sent.pointList.find(function (o) {
  1467. return o.id === t;
  1468. });
  1469. if (n) {
  1470. _context5.next = 6;
  1471. break;
  1472. }
  1473. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1474. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1475. case 6:
  1476. return _context5.abrupt("return", (logger.debug("find point success", n), n));
  1477. case 7:
  1478. case "end":
  1479. return _context5.stop();
  1480. }
  1481. }
  1482. }, _callee5, this);
  1483. }));
  1484. function findPoint(_x7, _x8) {
  1485. return _findPoint.apply(this, arguments);
  1486. }
  1487. return findPoint;
  1488. }()
  1489. }, {
  1490. key: "requestConfig",
  1491. value: function () {
  1492. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1493. var t, r, _ref, n, o;
  1494. return regenerator.wrap(function _callee6$(_context6) {
  1495. while (1) {
  1496. switch (_context6.prev = _context6.next) {
  1497. case 0:
  1498. if (!this.config) {
  1499. _context6.next = 2;
  1500. break;
  1501. }
  1502. return _context6.abrupt("return", this.config);
  1503. case 2:
  1504. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1505. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1506. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1507. t = './assets/config.json';
  1508. _context6.prev = 3;
  1509. _context6.next = 6;
  1510. return http.get({
  1511. url: "".concat(t, "?t=").concat(Date.now()),
  1512. key: "config",
  1513. timeout: 6e3,
  1514. retry: 2
  1515. });
  1516. case 6:
  1517. r = _context6.sent;
  1518. _ref = JSON.parse(r).data || {};
  1519. n = _ref.config;
  1520. o = _ref.preload;
  1521. if (n) {
  1522. _context6.next = 12;
  1523. break;
  1524. }
  1525. throw new Error("config data parse error" + r.data);
  1526. case 12:
  1527. return _context6.abrupt("return", (this.config = {
  1528. config: n,
  1529. preload: o
  1530. }, logger.debug("get config success", this.config), this.config));
  1531. case 15:
  1532. _context6.prev = 15;
  1533. _context6.t0 = _context6["catch"](3);
  1534. return _context6.abrupt("return", Promise.reject(_context6.t0));
  1535. case 18:
  1536. case "end":
  1537. return _context6.stop();
  1538. }
  1539. }
  1540. }, _callee6, this, [[3, 15]]);
  1541. }));
  1542. function requestConfig() {
  1543. return _requestConfig.apply(this, arguments);
  1544. }
  1545. return requestConfig;
  1546. }()
  1547. }, {
  1548. key: "getApplicationConfig",
  1549. value: function () {
  1550. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  1551. var e;
  1552. return regenerator.wrap(function _callee7$(_context7) {
  1553. while (1) {
  1554. switch (_context7.prev = _context7.next) {
  1555. case 0:
  1556. if (!this.applicationConfig) {
  1557. _context7.next = 2;
  1558. break;
  1559. }
  1560. return _context7.abrupt("return", this.applicationConfig);
  1561. case 2:
  1562. _context7.prev = 2;
  1563. _context7.next = 5;
  1564. return this.requestConfig();
  1565. case 5:
  1566. e = _context7.sent;
  1567. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  1568. case 9:
  1569. _context7.prev = 9;
  1570. _context7.t0 = _context7["catch"](2);
  1571. return _context7.abrupt("return", Promise.reject(_context7.t0));
  1572. case 12:
  1573. case "end":
  1574. return _context7.stop();
  1575. }
  1576. }
  1577. }, _callee7, this, [[2, 9]]);
  1578. }));
  1579. function getApplicationConfig() {
  1580. return _getApplicationConfig.apply(this, arguments);
  1581. }
  1582. return getApplicationConfig;
  1583. }()
  1584. }, {
  1585. key: "getAvatarModelList",
  1586. value: function () {
  1587. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  1588. var _yield$this$getApplic, e;
  1589. return regenerator.wrap(function _callee8$(_context8) {
  1590. while (1) {
  1591. switch (_context8.prev = _context8.next) {
  1592. case 0:
  1593. if (!this.avatarModelList.length) {
  1594. _context8.next = 2;
  1595. break;
  1596. }
  1597. return _context8.abrupt("return", this.avatarModelList);
  1598. case 2:
  1599. _context8.prev = 2;
  1600. _context8.next = 5;
  1601. return this.getApplicationConfig();
  1602. case 5:
  1603. _yield$this$getApplic = _context8.sent;
  1604. e = _yield$this$getApplic.avatars;
  1605. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  1606. return {
  1607. name: t.name,
  1608. id: t.id,
  1609. modelUrl: t.url,
  1610. gender: t.gender,
  1611. components: t.components
  1612. };
  1613. }), this.avatarModelList));
  1614. case 10:
  1615. _context8.prev = 10;
  1616. _context8.t0 = _context8["catch"](2);
  1617. return _context8.abrupt("return", (logger.error(_context8.t0), []));
  1618. case 13:
  1619. case "end":
  1620. return _context8.stop();
  1621. }
  1622. }
  1623. }, _callee8, this, [[2, 10]]);
  1624. }));
  1625. function getAvatarModelList() {
  1626. return _getAvatarModelList.apply(this, arguments);
  1627. }
  1628. return getAvatarModelList;
  1629. }()
  1630. }, {
  1631. key: "getSkinsList",
  1632. value: function () {
  1633. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  1634. var _yield$this$getApplic2, e;
  1635. return regenerator.wrap(function _callee9$(_context9) {
  1636. while (1) {
  1637. switch (_context9.prev = _context9.next) {
  1638. case 0:
  1639. if (!this.skinList.length) {
  1640. _context9.next = 2;
  1641. break;
  1642. }
  1643. return _context9.abrupt("return", this.skinList);
  1644. case 2:
  1645. _context9.prev = 2;
  1646. _context9.next = 5;
  1647. return this.getApplicationConfig();
  1648. case 5:
  1649. _yield$this$getApplic2 = _context9.sent;
  1650. e = _yield$this$getApplic2.skins;
  1651. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  1652. var r;
  1653. return {
  1654. name: t.name,
  1655. dataVersion: t.id + t.versionId,
  1656. id: t.id,
  1657. fov: parseInt(t.fov || 90),
  1658. models: t.assetList.map(function (n) {
  1659. var o = n.assetId,
  1660. a = n.url,
  1661. s = n.thumbnailUrl,
  1662. l = n.typeName,
  1663. u = n.className;
  1664. return {
  1665. id: o,
  1666. modelUrl: a,
  1667. name: n.name,
  1668. thumbnailUrl: s,
  1669. typeName: l,
  1670. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  1671. };
  1672. }),
  1673. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  1674. var o = n.areaName,
  1675. a = n.attitude,
  1676. s = n.id,
  1677. l = n.pathName,
  1678. u = n.step,
  1679. c = n.birthPointList;
  1680. return {
  1681. areaName: o,
  1682. attitude: a,
  1683. id: s,
  1684. pathName: l,
  1685. step: u,
  1686. birthPointList: c.map(function (h) {
  1687. return {
  1688. camera: h.camera && {
  1689. position: objectParseFloat(h.camera.position),
  1690. angle: objectParseFloat(h.camera.rotation)
  1691. },
  1692. player: h.player && {
  1693. position: objectParseFloat(h.player.position),
  1694. angle: objectParseFloat(h.player.rotation)
  1695. }
  1696. };
  1697. })
  1698. };
  1699. }),
  1700. pointList: t.pointList.map(function (n) {
  1701. return le(oe({}, n), {
  1702. position: objectParseFloat(n.position),
  1703. rotation: objectParseFloat(n.rotation)
  1704. });
  1705. }),
  1706. versionId: t.versionId,
  1707. isEnable: t.isEnable,
  1708. assetList: t.assetList,
  1709. visibleRules: t.visibleRules,
  1710. animationList: t.animationList
  1711. };
  1712. }), this.skinList));
  1713. case 10:
  1714. _context9.prev = 10;
  1715. _context9.t0 = _context9["catch"](2);
  1716. return _context9.abrupt("return", (logger.error(_context9.t0), []));
  1717. case 13:
  1718. case "end":
  1719. return _context9.stop();
  1720. }
  1721. }
  1722. }, _callee9, this, [[2, 10]]);
  1723. }));
  1724. function getSkinsList() {
  1725. return _getSkinsList.apply(this, arguments);
  1726. }
  1727. return getSkinsList;
  1728. }()
  1729. }, {
  1730. key: "getBreathPointTextrueList",
  1731. value: function () {
  1732. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  1733. return regenerator.wrap(function _callee10$(_context10) {
  1734. while (1) {
  1735. switch (_context10.prev = _context10.next) {
  1736. case 0:
  1737. return _context10.abrupt("return", [{
  1738. url: TEXTURE_URL
  1739. }]);
  1740. case 1:
  1741. case "end":
  1742. return _context10.stop();
  1743. }
  1744. }
  1745. }, _callee10);
  1746. }));
  1747. function getBreathPointTextrueList() {
  1748. return _getBreathPointTextrueList.apply(this, arguments);
  1749. }
  1750. return getBreathPointTextrueList;
  1751. }()
  1752. }], [{
  1753. key: "getInstance",
  1754. value: function getInstance(e, t) {
  1755. //getInstance(e, t) {
  1756. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  1757. }
  1758. }, {
  1759. key: "findModels",
  1760. value: function findModels(e, t, r) {
  1761. //findModels(e, t, r) {
  1762. return e.filter(function (o) {
  1763. return o.typeName === t && o.className === r;
  1764. });
  1765. }
  1766. }, {
  1767. key: "findModel",
  1768. value: function findModel(e, t, r) {
  1769. //findModel(e, t, r) {
  1770. var n = e.filter(function (o) {
  1771. return o.typeName === t && o.className === r;
  1772. })[0];
  1773. return n || null;
  1774. }
  1775. }]);
  1776. return ModelManager;
  1777. }();
  1778. // export { modelManager };
  1779. var BaseTable = /*#__PURE__*/function () {
  1780. function BaseTable(e, t) {
  1781. _classCallCheck(this, BaseTable);
  1782. this.db = null;
  1783. this.isCreatingTable = !1;
  1784. this.hasCleared = !1;
  1785. this.dbName = e, this.dbVersion = t;
  1786. }
  1787. _createClass(BaseTable, [{
  1788. key: "clearDataBase",
  1789. value: function () {
  1790. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1791. var _this = this;
  1792. return regenerator.wrap(function _callee$(_context) {
  1793. while (1) {
  1794. switch (_context.prev = _context.next) {
  1795. case 0:
  1796. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  1797. var n = window.indexedDB.deleteDatabase(_this.dbName);
  1798. n.onsuccess = function () {
  1799. t();
  1800. }, n.onerror = r;
  1801. }));
  1802. case 1:
  1803. case "end":
  1804. return _context.stop();
  1805. }
  1806. }
  1807. }, _callee, this);
  1808. }));
  1809. function clearDataBase(_x) {
  1810. return _clearDataBase.apply(this, arguments);
  1811. }
  1812. return clearDataBase;
  1813. }()
  1814. }, {
  1815. key: "tableName",
  1816. value: function tableName() {
  1817. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  1818. }
  1819. }, {
  1820. key: "keyPath",
  1821. value: function keyPath() {
  1822. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  1823. }
  1824. }, {
  1825. key: "index",
  1826. value: function index() {
  1827. throw new Error("Derived class have to override 'index', and set a proper index name!");
  1828. }
  1829. }, {
  1830. key: "checkAndOpenDatabase",
  1831. value: function () {
  1832. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  1833. var _this2 = this;
  1834. return regenerator.wrap(function _callee2$(_context2) {
  1835. while (1) {
  1836. switch (_context2.prev = _context2.next) {
  1837. case 0:
  1838. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  1839. var n = setTimeout(function () {
  1840. logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  1841. }, 200);
  1842. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  1843. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  1844. }, function () {
  1845. t(new Error("Failed to open database!")), clearTimeout(n);
  1846. }, function () {
  1847. _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  1848. });
  1849. }));
  1850. case 1:
  1851. case "end":
  1852. return _context2.stop();
  1853. }
  1854. }
  1855. }, _callee2, this);
  1856. }));
  1857. function checkAndOpenDatabase() {
  1858. return _checkAndOpenDatabase.apply(this, arguments);
  1859. }
  1860. return checkAndOpenDatabase;
  1861. }()
  1862. }, {
  1863. key: "openDatabase",
  1864. value: function openDatabase(e, t, r, n, o) {
  1865. var _this3 = this;
  1866. if (this.isCreatingTable) return;
  1867. this.isCreatingTable = !0, logger.info(e, t);
  1868. var a = window.indexedDB.open(e, t),
  1869. s = this.tableName();
  1870. a.onsuccess = function (l) {
  1871. _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  1872. }, a.onerror = function (l) {
  1873. var u;
  1874. 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);
  1875. }, a.onupgradeneeded = function (l) {
  1876. var u = l.target.result,
  1877. c = _this3.index();
  1878. logger.info("Creating table ".concat(s, "."));
  1879. var h = u.objectStoreNames.contains(s);
  1880. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  1881. var f = _this3.keyPath();
  1882. h = u.createObjectStore(s, {
  1883. keyPath: f
  1884. });
  1885. }
  1886. c.map(function (f) {
  1887. h.createIndex(f, f, {
  1888. unique: !1
  1889. });
  1890. }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
  1891. };
  1892. }
  1893. }, {
  1894. key: "add",
  1895. value: function () {
  1896. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1897. var t, o;
  1898. return regenerator.wrap(function _callee3$(_context3) {
  1899. while (1) {
  1900. switch (_context3.prev = _context3.next) {
  1901. case 0:
  1902. t = this.tableName();
  1903. _context3.next = 3;
  1904. return this.checkAndOpenDatabase();
  1905. case 3:
  1906. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  1907. return _context3.abrupt("return", new Promise(function (a, s) {
  1908. o.onsuccess = function (l) {
  1909. a(l);
  1910. }, o.onerror = function (l) {
  1911. var u;
  1912. logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  1913. };
  1914. }));
  1915. case 5:
  1916. case "end":
  1917. return _context3.stop();
  1918. }
  1919. }
  1920. }, _callee3, this);
  1921. }));
  1922. function add(_x2) {
  1923. return _add.apply(this, arguments);
  1924. }
  1925. return add;
  1926. }()
  1927. }, {
  1928. key: "put",
  1929. value: function () {
  1930. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  1931. var t, o;
  1932. return regenerator.wrap(function _callee4$(_context4) {
  1933. while (1) {
  1934. switch (_context4.prev = _context4.next) {
  1935. case 0:
  1936. t = this.tableName();
  1937. _context4.next = 3;
  1938. return this.checkAndOpenDatabase();
  1939. case 3:
  1940. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  1941. return _context4.abrupt("return", new Promise(function (a, s) {
  1942. o.onsuccess = function (l) {
  1943. a(l);
  1944. }, o.onerror = function (l) {
  1945. var u;
  1946. logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  1947. };
  1948. }));
  1949. case 5:
  1950. case "end":
  1951. return _context4.stop();
  1952. }
  1953. }
  1954. }, _callee4, this);
  1955. }));
  1956. function put(_x3) {
  1957. return _put.apply(this, arguments);
  1958. }
  1959. return put;
  1960. }()
  1961. }, {
  1962. key: "delete",
  1963. value: function _delete(e, t, r) {
  1964. var n = this.tableName();
  1965. this.checkAndOpenDatabase().then(function (o) {
  1966. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  1967. s.onsuccess = t, s.onerror = r;
  1968. });
  1969. }
  1970. }, {
  1971. key: "update",
  1972. value: function update() {
  1973. this.checkAndOpenDatabase().then(function (e) {});
  1974. }
  1975. }, {
  1976. key: "getAllKeys",
  1977. value: function () {
  1978. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  1979. var e, t;
  1980. return regenerator.wrap(function _callee5$(_context5) {
  1981. while (1) {
  1982. switch (_context5.prev = _context5.next) {
  1983. case 0:
  1984. e = this.tableName();
  1985. _context5.next = 3;
  1986. return this.checkAndOpenDatabase();
  1987. case 3:
  1988. t = _context5.sent;
  1989. return _context5.abrupt("return", new Promise(function (r, n) {
  1990. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  1991. a.onsuccess = function (s) {
  1992. r(s.target.result);
  1993. }, a.onerror = function (s) {
  1994. logger.error("db getAllKeys error", s), n(s);
  1995. };
  1996. }));
  1997. case 5:
  1998. case "end":
  1999. return _context5.stop();
  2000. }
  2001. }
  2002. }, _callee5, this);
  2003. }));
  2004. function getAllKeys() {
  2005. return _getAllKeys.apply(this, arguments);
  2006. }
  2007. return getAllKeys;
  2008. }()
  2009. }, {
  2010. key: "query",
  2011. value: function () {
  2012. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  2013. var r, n;
  2014. return regenerator.wrap(function _callee6$(_context6) {
  2015. while (1) {
  2016. switch (_context6.prev = _context6.next) {
  2017. case 0:
  2018. r = this.tableName();
  2019. _context6.next = 3;
  2020. return this.checkAndOpenDatabase();
  2021. case 3:
  2022. n = _context6.sent;
  2023. return _context6.abrupt("return", new Promise(function (o, a) {
  2024. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  2025. u.onsuccess = function (c) {
  2026. var f;
  2027. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  2028. o && o(h);
  2029. }, u.onerror = function (c) {
  2030. logger.error("db query error", c), a(c);
  2031. };
  2032. }));
  2033. case 5:
  2034. case "end":
  2035. return _context6.stop();
  2036. }
  2037. }
  2038. }, _callee6, this);
  2039. }));
  2040. function query(_x4, _x5) {
  2041. return _query.apply(this, arguments);
  2042. }
  2043. return query;
  2044. }()
  2045. }, {
  2046. key: "sleep",
  2047. value: function () {
  2048. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  2049. return regenerator.wrap(function _callee7$(_context7) {
  2050. while (1) {
  2051. switch (_context7.prev = _context7.next) {
  2052. case 0:
  2053. return _context7.abrupt("return", new Promise(function (t) {
  2054. setTimeout(function () {
  2055. t("");
  2056. }, e);
  2057. }));
  2058. case 1:
  2059. case "end":
  2060. return _context7.stop();
  2061. }
  2062. }
  2063. }, _callee7);
  2064. }));
  2065. function sleep(_x6) {
  2066. return _sleep.apply(this, arguments);
  2067. }
  2068. return sleep;
  2069. }()
  2070. }]);
  2071. return BaseTable;
  2072. }();
  2073. 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); }; }
  2074. 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; } }
  2075. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  2076. _inherits(ModelTable, _BaseTable);
  2077. var _super = _createSuper(ModelTable);
  2078. function ModelTable() {
  2079. _classCallCheck(this, ModelTable);
  2080. return _super.call(this, "XverseDatabase", 1);
  2081. }
  2082. _createClass(ModelTable, [{
  2083. key: "tableName",
  2084. value: function tableName() {
  2085. return "models";
  2086. }
  2087. }, {
  2088. key: "index",
  2089. value: function index() {
  2090. return ["url"];
  2091. }
  2092. }, {
  2093. key: "keyPath",
  2094. value: function keyPath() {
  2095. return "url";
  2096. }
  2097. }]);
  2098. return ModelTable;
  2099. }(BaseTable);
  2100. var modelTable$1 = new ModelTable();
  2101. var Preload = /*#__PURE__*/function () {
  2102. function Preload(e) {
  2103. _classCallCheck(this, Preload);
  2104. this.config = null;
  2105. this.allKeys = [];
  2106. this.oldResourcesDeleted = !1;
  2107. this.requests = {
  2108. simple: {
  2109. stopped: !0,
  2110. requests: {}
  2111. },
  2112. observer: {
  2113. stopped: !0,
  2114. requests: {}
  2115. },
  2116. full: {
  2117. stopped: !0,
  2118. requests: {}
  2119. }
  2120. };
  2121. this.modelManager = e, this.init(e.appId);
  2122. }
  2123. _createClass(Preload, [{
  2124. key: "init",
  2125. value: function init(e) {
  2126. reporter.updateBody({
  2127. appId: e
  2128. });
  2129. }
  2130. }, {
  2131. key: "getConfig",
  2132. value: function () {
  2133. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2134. var _yield$this$modelMana, t;
  2135. return regenerator.wrap(function _callee$(_context) {
  2136. while (1) {
  2137. switch (_context.prev = _context.next) {
  2138. case 0:
  2139. if (!this.config) {
  2140. _context.next = 2;
  2141. break;
  2142. }
  2143. return _context.abrupt("return", this.config);
  2144. case 2:
  2145. _context.next = 4;
  2146. return this.modelManager.requestConfig();
  2147. case 4:
  2148. _yield$this$modelMana = _context.sent;
  2149. t = _yield$this$modelMana.preload;
  2150. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  2151. case 7:
  2152. case "end":
  2153. return _context.stop();
  2154. }
  2155. }
  2156. }, _callee, this);
  2157. }));
  2158. function getConfig(_x) {
  2159. return _getConfig.apply(this, arguments);
  2160. }
  2161. return getConfig;
  2162. }()
  2163. }, {
  2164. key: "getAllKeys",
  2165. value: function () {
  2166. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2167. var e, t;
  2168. return regenerator.wrap(function _callee2$(_context2) {
  2169. while (1) {
  2170. switch (_context2.prev = _context2.next) {
  2171. case 0:
  2172. if (!this.allKeys.length) {
  2173. _context2.next = 2;
  2174. break;
  2175. }
  2176. return _context2.abrupt("return", this.allKeys);
  2177. case 2:
  2178. _context2.prev = 2;
  2179. _context2.next = 5;
  2180. return modelTable$1.getAllKeys();
  2181. case 5:
  2182. e = _context2.sent;
  2183. this.allKeys = e;
  2184. return _context2.abrupt("return", e);
  2185. case 10:
  2186. _context2.prev = 10;
  2187. _context2.t0 = _context2["catch"](2);
  2188. t = "preload getAllKeys error";
  2189. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  2190. case 14:
  2191. case "end":
  2192. return _context2.stop();
  2193. }
  2194. }
  2195. }, _callee2, this, [[2, 10]]);
  2196. }));
  2197. function getAllKeys() {
  2198. return _getAllKeys.apply(this, arguments);
  2199. }
  2200. return getAllKeys;
  2201. }()
  2202. }, {
  2203. key: "stop",
  2204. value: function stop(e) {
  2205. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  2206. var t = this.requests[e].requests;
  2207. Object.keys(t).forEach(function (r) {
  2208. http.canceler.removePending(r), delete t[r];
  2209. });
  2210. }
  2211. }, {
  2212. key: "clearPreload",
  2213. value: function clearPreload(e) {
  2214. this.requests[e].stopped = !1, this.allKeys = [];
  2215. }
  2216. }, {
  2217. key: "start",
  2218. value: function () {
  2219. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  2220. var n, o, a, s, l, u, h, f, _s;
  2221. return regenerator.wrap(function _callee3$(_context3) {
  2222. while (1) {
  2223. switch (_context3.prev = _context3.next) {
  2224. case 0:
  2225. n = Date.now(), o = 0;
  2226. _context3.prev = 1;
  2227. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  2228. _context3.next = 4;
  2229. break;
  2230. }
  2231. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  2232. case 4:
  2233. this.clearPreload(e);
  2234. _context3.next = 7;
  2235. return this.getConfig(e);
  2236. case 7:
  2237. a = _context3.sent;
  2238. _context3.next = 10;
  2239. return this.getAllKeys();
  2240. case 10:
  2241. s = _context3.sent;
  2242. _context3.prev = 11;
  2243. _context3.next = 14;
  2244. return this.deleteOldResources(a.assetUrls.map(function (d) {
  2245. return d.url;
  2246. }), s);
  2247. case 14:
  2248. _context3.next = 19;
  2249. break;
  2250. case 16:
  2251. _context3.prev = 16;
  2252. _context3.t0 = _context3["catch"](11);
  2253. logger.error(_context3.t0);
  2254. case 19:
  2255. l = a.baseUrls, u = a.assetUrls;
  2256. _context3.t1 = e;
  2257. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  2258. break;
  2259. case 23:
  2260. h = l;
  2261. return _context3.abrupt("break", 30);
  2262. case 25:
  2263. h = u;
  2264. return _context3.abrupt("break", 30);
  2265. case 27:
  2266. h = u;
  2267. return _context3.abrupt("break", 30);
  2268. case 29:
  2269. h = u;
  2270. case 30:
  2271. f = h.filter(function (d) {
  2272. return !s.includes(d.url);
  2273. });
  2274. r && isFunction(r) && (f = f.filter(r));
  2275. o = f.length;
  2276. logger.debug("keysNeedToPreload", f);
  2277. f.length || t && t(h.length, h.length);
  2278. n = Date.now();
  2279. _context3.next = 38;
  2280. return this._preload(e, f, t);
  2281. case 38:
  2282. logger.infoAndReportMeasurement({
  2283. tag: e,
  2284. startTime: n,
  2285. metric: "assetsPreload",
  2286. extra: {
  2287. total: o
  2288. }
  2289. });
  2290. return _context3.abrupt("return");
  2291. case 42:
  2292. _context3.prev = 42;
  2293. _context3.t2 = _context3["catch"](1);
  2294. _s = _context3.t2;
  2295. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  2296. tag: e,
  2297. startTime: n,
  2298. metric: "assetsPreload",
  2299. extra: {
  2300. total: o
  2301. },
  2302. error: _s,
  2303. reportOptions: {
  2304. immediate: !0
  2305. }
  2306. }), Promise.reject(_s)));
  2307. case 46:
  2308. case "end":
  2309. return _context3.stop();
  2310. }
  2311. }
  2312. }, _callee3, this, [[1, 42], [11, 16]]);
  2313. }));
  2314. function start(_x2, _x3, _x4) {
  2315. return _start.apply(this, arguments);
  2316. }
  2317. return start;
  2318. }()
  2319. }, {
  2320. key: "deleteOldResources",
  2321. value: function deleteOldResources(e, t) {
  2322. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  2323. var r = t.filter(function (n) {
  2324. return !e.includes(n);
  2325. });
  2326. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  2327. return modelTable$1.delete(n);
  2328. }));
  2329. }
  2330. }, {
  2331. key: "_preload",
  2332. value: function () {
  2333. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  2334. var _this = this;
  2335. var n, o, a;
  2336. return regenerator.wrap(function _callee6$(_context6) {
  2337. while (1) {
  2338. switch (_context6.prev = _context6.next) {
  2339. case 0:
  2340. n = t.length;
  2341. if (n) {
  2342. _context6.next = 3;
  2343. break;
  2344. }
  2345. return _context6.abrupt("return", Promise.resolve());
  2346. case 3:
  2347. o = 0;
  2348. a = window.setInterval(function () {
  2349. r && r(o, n), o >= n && window.clearInterval(a);
  2350. }, 1e3);
  2351. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  2352. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  2353. var l, u;
  2354. return regenerator.wrap(function _callee5$(_context5) {
  2355. while (1) {
  2356. switch (_context5.prev = _context5.next) {
  2357. case 0:
  2358. l = s.size, u = s.url;
  2359. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http.get({
  2360. url: u,
  2361. timeout: Preload.getTimeoutBySize(l),
  2362. responseType: "blob",
  2363. retry: 2,
  2364. beforeRequest: function beforeRequest() {
  2365. _this.requests[e].requests[u] = !0;
  2366. }
  2367. }).then( /*#__PURE__*/function () {
  2368. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  2369. var h, f;
  2370. return regenerator.wrap(function _callee4$(_context4) {
  2371. while (1) {
  2372. switch (_context4.prev = _context4.next) {
  2373. case 0:
  2374. h = c.data;
  2375. if (h instanceof Blob) {
  2376. _context4.next = 3;
  2377. break;
  2378. }
  2379. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  2380. case 3:
  2381. _context4.next = 5;
  2382. return blobToDataURI$1(h);
  2383. case 5:
  2384. f = _context4.sent;
  2385. _context4.prev = 6;
  2386. _context4.next = 9;
  2387. return modelTable$1.put({
  2388. url: u,
  2389. model: f
  2390. });
  2391. case 9:
  2392. return _context4.abrupt("return");
  2393. case 12:
  2394. _context4.prev = 12;
  2395. _context4.t0 = _context4["catch"](6);
  2396. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  2397. case 15:
  2398. case "end":
  2399. return _context4.stop();
  2400. }
  2401. }
  2402. }, _callee4, null, [[6, 12]]);
  2403. }));
  2404. return function (_x9) {
  2405. return _ref2.apply(this, arguments);
  2406. };
  2407. }()).then(function () {
  2408. o++, delete _this.requests[e].requests[u];
  2409. }, function (c) {
  2410. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  2411. }));
  2412. case 2:
  2413. case "end":
  2414. return _context5.stop();
  2415. }
  2416. }
  2417. }, _callee5);
  2418. }));
  2419. return function (_x8) {
  2420. return _ref.apply(this, arguments);
  2421. };
  2422. }()));
  2423. case 6:
  2424. case "end":
  2425. return _context6.stop();
  2426. }
  2427. }
  2428. }, _callee6);
  2429. }));
  2430. function _preload(_x5, _x6, _x7) {
  2431. return _preload2.apply(this, arguments);
  2432. }
  2433. return _preload;
  2434. }()
  2435. }], [{
  2436. key: "getTimeoutBySize",
  2437. value: function getTimeoutBySize(e) {
  2438. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  2439. }
  2440. }]);
  2441. return Preload;
  2442. }();
  2443. var Xverse = /*#__PURE__*/function () {
  2444. function Xverse(e) {
  2445. _classCallCheck(this, Xverse);
  2446. e || (e = {});
  2447. var _e = e,
  2448. t = _e.onLog,
  2449. r = _e.env,
  2450. n = _e.appId,
  2451. o = _e.releaseId,
  2452. a = _e.subPackageVersion;
  2453. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && Logger.setLevel(LoggerLevels.Debug);
  2454. var s = this.pageSession = util.uuid();
  2455. reporter.updateHeader({
  2456. pageSession: s
  2457. });
  2458. reporter.updateReportUrl(REPORT_URL[this.env]);
  2459. a && reporter.updateBody({
  2460. sdkVersion: a
  2461. });
  2462. logger.infoAndReportMeasurement({
  2463. metric: "sdkInit",
  2464. startTime: Date.now(),
  2465. extra: {
  2466. version: a,
  2467. enviroment: r,
  2468. pageSession: s
  2469. }
  2470. });
  2471. logger.debug("debug mode:", this.debug);
  2472. reporter.on("report", function (l) {
  2473. t && t(l);
  2474. });
  2475. if (n) {
  2476. this.appId = n, this.releaseId = o;
  2477. var l = ModelManager.getInstance(n, o);
  2478. this.preload = new Preload(l);
  2479. }
  2480. }
  2481. _createClass(Xverse, [{
  2482. key: "isSupported",
  2483. get: function get() {
  2484. return isSupported();
  2485. }
  2486. }, {
  2487. key: "disableLogUpload",
  2488. value: function disableLogUpload() {
  2489. reporter.disable(), logger.debug("logger upload has been disabled");
  2490. }
  2491. }, {
  2492. key: "getSkinList",
  2493. value: function () {
  2494. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  2495. return regenerator.wrap(function _callee$(_context) {
  2496. while (1) {
  2497. switch (_context.prev = _context.next) {
  2498. case 0:
  2499. return _context.abrupt("return", []);
  2500. case 1:
  2501. case "end":
  2502. return _context.stop();
  2503. }
  2504. }
  2505. }, _callee);
  2506. }));
  2507. function getSkinList() {
  2508. return _getSkinList.apply(this, arguments);
  2509. }
  2510. return getSkinList;
  2511. }()
  2512. }, {
  2513. key: "getAvatarList",
  2514. value: function () {
  2515. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2516. return regenerator.wrap(function _callee2$(_context2) {
  2517. while (1) {
  2518. switch (_context2.prev = _context2.next) {
  2519. case 0:
  2520. return _context2.abrupt("return", []);
  2521. case 1:
  2522. case "end":
  2523. return _context2.stop();
  2524. }
  2525. }
  2526. }, _callee2);
  2527. }));
  2528. function getAvatarList() {
  2529. return _getAvatarList.apply(this, arguments);
  2530. }
  2531. return getAvatarList;
  2532. }()
  2533. }, {
  2534. key: "getGiftList",
  2535. value: function () {
  2536. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  2537. return regenerator.wrap(function _callee3$(_context3) {
  2538. while (1) {
  2539. switch (_context3.prev = _context3.next) {
  2540. case 0:
  2541. return _context3.abrupt("return", [{
  2542. id: "hack "
  2543. }]);
  2544. case 1:
  2545. case "end":
  2546. return _context3.stop();
  2547. }
  2548. }
  2549. }, _callee3);
  2550. }));
  2551. function getGiftList() {
  2552. return _getGiftList.apply(this, arguments);
  2553. }
  2554. return getGiftList;
  2555. }()
  2556. }, {
  2557. key: "joinRoom",
  2558. value: function () {
  2559. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2560. var t, r, n, o;
  2561. return regenerator.wrap(function _callee4$(_context4) {
  2562. while (1) {
  2563. switch (_context4.prev = _context4.next) {
  2564. case 0:
  2565. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), {
  2566. appId: e.appId || this.appId,
  2567. releaseId: e.releaseId || this.releaseId,
  2568. pageSession: this.pageSession,
  2569. isAllSync: !0,
  2570. rotationRenderType: r,
  2571. syncByEvent: !0,
  2572. pathName: t,
  2573. person: n,
  2574. role: e.role || "audience"
  2575. }));
  2576. return _context4.abrupt("return", o.initRoom().then(function () {
  2577. return o;
  2578. }));
  2579. case 2:
  2580. case "end":
  2581. return _context4.stop();
  2582. }
  2583. }
  2584. }, _callee4, this);
  2585. }));
  2586. function joinRoom(_x) {
  2587. return _joinRoom.apply(this, arguments);
  2588. }
  2589. return joinRoom;
  2590. }()
  2591. }]);
  2592. return Xverse;
  2593. }();
  2594. var xverse = new Xverse({
  2595. env: "DEV",
  2596. appId: 10016,
  2597. releaseId: '2203120033_29769e'
  2598. });
  2599. var l = /*#__PURE__*/function () {
  2600. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  2601. var R;
  2602. return regenerator.wrap(function _callee$(_context) {
  2603. while (1) {
  2604. switch (_context.prev = _context.next) {
  2605. case 0:
  2606. _context.prev = 0;
  2607. _context.next = 3;
  2608. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  2609. var I = "(".concat(M, "/").concat(x, ")");
  2610. s(I);
  2611. });
  2612. case 3:
  2613. _context.next = 12;
  2614. break;
  2615. case 5:
  2616. _context.prev = 5;
  2617. _context.t0 = _context["catch"](0);
  2618. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  2619. _context.next = 10;
  2620. break;
  2621. }
  2622. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  2623. return _context.abrupt("return");
  2624. case 10:
  2625. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  2626. return _context.abrupt("return");
  2627. case 12:
  2628. _context.prev = 12;
  2629. _context.next = 15;
  2630. return xverse.joinRoom({
  2631. canvas: document.getElementById('canvas'),
  2632. skinId: 10092,
  2633. avatarId: 'KGe_Boy',
  2634. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  2635. userId: '1f7acca1db9d5',
  2636. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  2637. appId: 10016,
  2638. token: " ",
  2639. nickname: '1f7acca1db9d5',
  2640. firends: ["user1"],
  2641. viewMode: "full",
  2642. resolution: {
  2643. width: 1728,
  2644. height: 720
  2645. },
  2646. pathName: 'thirdwalk',
  2647. objectFit: null,
  2648. hasAvatar: !0,
  2649. syncToOthers: !0
  2650. });
  2651. case 15:
  2652. room = _context.sent;
  2653. u(), c(), window.room = room, e(!1);
  2654. _context.next = 23;
  2655. break;
  2656. case 19:
  2657. _context.prev = 19;
  2658. _context.t1 = _context["catch"](12);
  2659. console.error(_context.t1), alert(_context.t1);
  2660. return _context.abrupt("return");
  2661. case 23:
  2662. case "end":
  2663. return _context.stop();
  2664. }
  2665. }
  2666. }, _callee, null, [[0, 5], [12, 19]]);
  2667. }));
  2668. return function l() {
  2669. return _ref.apply(this, arguments);
  2670. };
  2671. }();
  2672. var u = function u() {
  2673. room.on("_coreClick", function (_ref2) {
  2674. var f = _ref2.point;
  2675. room._userAvatar.moveTo({
  2676. point: f
  2677. });
  2678. });
  2679. };
  2680. var c = function c() {
  2681. room.on("repeatLogin", function () {
  2682. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  2683. duration: 1e4
  2684. });
  2685. }), room.on("reconnecting", function (_ref3) {
  2686. var f = _ref3.count;
  2687. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  2688. }), room.on("reconnected", function () {
  2689. toast("\u91CD\u8FDE\u6210\u529F");
  2690. }), room.on("disconnected", function () {
  2691. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  2692. duration: 1e5,
  2693. onClick() {
  2694. f.hideToast(), room.reconnect();
  2695. }
  2696. });
  2697. });
  2698. };
  2699. l();
  2700. }));
  2701. //# sourceMappingURL=index.js.map