index.js 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498
  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. };
  733. function _setPrototypeOf(o, p) {
  734. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  735. o.__proto__ = p;
  736. return o;
  737. };
  738. return _setPrototypeOf(o, p);
  739. }
  740. function _inherits(subClass, superClass) {
  741. if (typeof superClass !== "function" && superClass !== null) {
  742. throw new TypeError("Super expression must either be null or a function");
  743. }
  744. subClass.prototype = Object.create(superClass && superClass.prototype, {
  745. constructor: {
  746. value: subClass,
  747. writable: true,
  748. configurable: true
  749. }
  750. });
  751. Object.defineProperty(subClass, "prototype", {
  752. writable: false
  753. });
  754. if (superClass) _setPrototypeOf(subClass, superClass);
  755. }
  756. function _typeof(obj) {
  757. "@babel/helpers - typeof";
  758. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  759. return typeof obj;
  760. } : function (obj) {
  761. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  762. }, _typeof(obj);
  763. }
  764. function _assertThisInitialized(self) {
  765. if (self === void 0) {
  766. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  767. }
  768. return self;
  769. }
  770. function _possibleConstructorReturn(self, call) {
  771. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  772. return call;
  773. } else if (call !== void 0) {
  774. throw new TypeError("Derived constructors may only return object or undefined");
  775. }
  776. return _assertThisInitialized(self);
  777. }
  778. function _getPrototypeOf(o) {
  779. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  780. return o.__proto__ || Object.getPrototypeOf(o);
  781. };
  782. return _getPrototypeOf(o);
  783. }
  784. 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); }; }
  785. 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; } }
  786. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  787. _inherits(Reporter, _EventEmitter);
  788. var _super = _createSuper(Reporter);
  789. function Reporter() {
  790. var _this;
  791. _classCallCheck(this, Reporter);
  792. _this = _super.call(this);
  793. _this._header = {};
  794. _this._body = {};
  795. _this._queue = [];
  796. _this._disabled = !1;
  797. _this._interval = null;
  798. _this._reportUrl = null;
  799. _this.isDocumentLoaded = function () {
  800. return document.readyState === "complete";
  801. };
  802. _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 () {
  803. _this._flushReport();
  804. }, 10 * 1e3);
  805. return _this;
  806. }
  807. _createClass(Reporter, [{
  808. key: "disable",
  809. value: function disable() {
  810. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  811. }
  812. }, {
  813. key: "updateHeader",
  814. value: function updateHeader(e) {
  815. Object.assign(this._header, e);
  816. }
  817. }, {
  818. key: "updateBody",
  819. value: function updateBody(e) {
  820. Object.assign(this._body, e);
  821. }
  822. }, {
  823. key: "updateReportUrl",
  824. value: function updateReportUrl(e) {
  825. this._reportUrl = e;
  826. }
  827. }, {
  828. key: "report",
  829. value: function report(e, t, r) {
  830. var _this2 = this;
  831. if (this._disabled) return;
  832. r || (r = {});
  833. var _r = r,
  834. n = _r.immediate,
  835. o = _r.sampleRate;
  836. if (o && o > Math.random()) return;
  837. this.updateBody({
  838. logTime: util.getFormattedDate(new Date()),
  839. logTimestamp: Date.now()
  840. });
  841. var a = function a(s) {
  842. var l = oe(le(oe({}, _this2._body), {
  843. type: e
  844. }), s);
  845. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  846. };
  847. Array.isArray(t) ? t.forEach(function (s) {
  848. return a(s);
  849. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  850. }
  851. }, {
  852. key: "_flushReport",
  853. value: function _flushReport() {
  854. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  855. var e = {
  856. header: this._header,
  857. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  858. };
  859. this._post(e);
  860. }
  861. }, {
  862. key: "_post",
  863. value: function _post(e) {
  864. var t = this._reportUrl || REPORT_URL.DEV;
  865. return new Promise(function (r, n) {
  866. var o = new XMLHttpRequest();
  867. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  868. try {
  869. o.send(JSON.stringify(e));
  870. } catch (a) {
  871. console.error(a);
  872. }
  873. o.addEventListener("readystatechange", function () {
  874. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  875. });
  876. });
  877. }
  878. }]);
  879. return Reporter;
  880. }(EventEmitter);
  881. var reporter = new Reporter();
  882. function _arrayLikeToArray(arr, len) {
  883. if (len == null || len > arr.length) len = arr.length;
  884. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  885. arr2[i] = arr[i];
  886. }
  887. return arr2;
  888. }
  889. function _arrayWithoutHoles(arr) {
  890. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  891. }
  892. function _iterableToArray(iter) {
  893. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  894. }
  895. function _unsupportedIterableToArray(o, minLen) {
  896. if (!o) return;
  897. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  898. var n = Object.prototype.toString.call(o).slice(8, -1);
  899. if (n === "Object" && o.constructor) n = o.constructor.name;
  900. if (n === "Map" || n === "Set") return Array.from(o);
  901. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  902. }
  903. function _nonIterableSpread() {
  904. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  905. }
  906. function _toConsumableArray(arr) {
  907. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  908. }
  909. var Codes$1 = {
  910. Success: 0,
  911. Param: 1001,
  912. Internal: 1002,
  913. Timeout: 1003,
  914. Authentication: 1004,
  915. TokenExpired: 1005,
  916. Unsupported: 1006,
  917. InitNetworkTimeout: 1007,
  918. InitDecoderTimeout: 1008,
  919. InitConfigTimeout: 1009,
  920. InitEngineTimeout: 1010,
  921. InitEngine: 1011,
  922. ActionBlocked: 1012,
  923. PreloadCanceled: 1013,
  924. FrequencyLimit: 1014,
  925. UsersUpperLimit: 2e3,
  926. RoomsUpperLimit: 2001,
  927. ServerParam: 2002,
  928. LackOfToken: 2003,
  929. LoginFailed: 2004,
  930. VerifyServiceDown: 2005,
  931. CreateSessionFailed: 2006,
  932. RtcConnection: 2008,
  933. DoActionFailed: 2009,
  934. StateSyncFailed: 2010,
  935. BroadcastFailed: 2011,
  936. DataAbnormal: 2012,
  937. GetOnVehicle: 2015,
  938. RepeatLogin: 2017,
  939. RoomDoseNotExist: 2018,
  940. TicketExpire: 2019,
  941. ServerRateLimit: 2020,
  942. DoActionBlocked: 2333,
  943. ActionMaybeDelay: 2334,
  944. ActionResponseTimeout: 2999
  945. };
  946. var Logger$1 = /*#__PURE__*/function () {
  947. function Logger(e) {
  948. _classCallCheck(this, Logger);
  949. this.level = 3;
  950. this.module = e;
  951. }
  952. _createClass(Logger, [{
  953. key: "setLevel",
  954. value: function setLevel(e) {
  955. this.level = e;
  956. }
  957. }, {
  958. key: "atleast",
  959. value: function atleast(e) {
  960. return e >= this.level && e >= this.level;
  961. }
  962. }, {
  963. key: "print",
  964. value: function print(e, t) {
  965. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  966. r[_key - 2] = arguments[_key];
  967. }
  968. if (this.atleast(t)) {
  969. var _console$n;
  970. var n = e == "debug" ? "info" : e,
  971. o = this.prefix(e);
  972. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  973. }
  974. if (e !== "debug" && e !== "info") {
  975. var _n = r.map(function (o) {
  976. if (o instanceof Object) try {
  977. return JSON.stringify(o);
  978. } catch (_unused) {
  979. return o;
  980. } else return o;
  981. }).join(",");
  982. reporter.report("log", {
  983. message: _n,
  984. level: e,
  985. module: this.module
  986. });
  987. }
  988. }
  989. }, {
  990. key: "debug",
  991. value: function debug() {
  992. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  993. e[_key2] = arguments[_key2];
  994. }
  995. return this.print.apply(this, ["debug", 1].concat(e));
  996. }
  997. }, {
  998. key: "info",
  999. value: function info() {
  1000. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1001. e[_key3] = arguments[_key3];
  1002. }
  1003. return this.print.apply(this, ["info", 2].concat(e));
  1004. }
  1005. }, {
  1006. key: "infoAndReportLog",
  1007. value: function infoAndReportLog(e) {
  1008. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1009. t[_key4 - 1] = arguments[_key4];
  1010. }
  1011. var r = e.reportOptions;
  1012. delete e.reportOptions, reporter.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1013. }
  1014. }, {
  1015. key: "infoAndReportMeasurement",
  1016. value: function infoAndReportMeasurement(e) {
  1017. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1018. t[_key5 - 1] = arguments[_key5];
  1019. }
  1020. var n;
  1021. var r = e.reportOptions;
  1022. if (e.startTime) {
  1023. var o = Date.now();
  1024. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1025. }
  1026. if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes$1.Internal : e.code = Codes$1.Success, reporter.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) {
  1027. this.error.apply(this, _toConsumableArray(t));
  1028. return;
  1029. }
  1030. this.warn.apply(this, _toConsumableArray(t));
  1031. }
  1032. }, {
  1033. key: "warn",
  1034. value: function warn() {
  1035. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1036. e[_key6] = arguments[_key6];
  1037. }
  1038. return this.print.apply(this, ["warn", 3].concat(e));
  1039. }
  1040. }, {
  1041. key: "error",
  1042. value: function error() {
  1043. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1044. e[_key7] = arguments[_key7];
  1045. }
  1046. return this.print.apply(this, ["error", 4].concat(e));
  1047. }
  1048. }, {
  1049. key: "prefix",
  1050. value: function prefix(e) {
  1051. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1052. }
  1053. }], [{
  1054. key: "setLevel",
  1055. value: function setLevel(e) {
  1056. this.level = e;
  1057. }
  1058. }]);
  1059. return Logger;
  1060. }();
  1061. var logger = new Logger$1();
  1062. var ModelManager = /*#__PURE__*/function () {
  1063. function ModelManager(e, t) {
  1064. _classCallCheck(this, ModelManager);
  1065. this.avatarModelList = [];
  1066. this.skinList = [];
  1067. this.applicationConfig = null;
  1068. this.config = null;
  1069. this.appId = e, this.releaseId = t;
  1070. }
  1071. _createClass(ModelManager, [{
  1072. key: "findSkinConfig",
  1073. value: function () {
  1074. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1075. var t, n;
  1076. return regenerator.wrap(function _callee$(_context) {
  1077. while (1) {
  1078. switch (_context.prev = _context.next) {
  1079. case 0:
  1080. t = null;
  1081. _context.next = 3;
  1082. return this.getSkinsList();
  1083. case 3:
  1084. t = (this.skinList = _context.sent).find(function (n) {
  1085. return n.id === e;
  1086. });
  1087. if (!t) {
  1088. _context.next = 6;
  1089. break;
  1090. }
  1091. return _context.abrupt("return", t);
  1092. case 6:
  1093. n = "skin is invalid: skinId: ".concat(e);
  1094. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1095. case 8:
  1096. case "end":
  1097. return _context.stop();
  1098. }
  1099. }
  1100. }, _callee, this);
  1101. }));
  1102. function findSkinConfig(_x) {
  1103. return _findSkinConfig.apply(this, arguments);
  1104. }
  1105. return findSkinConfig;
  1106. }()
  1107. }, {
  1108. key: "findRoute",
  1109. value: function () {
  1110. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1111. var n, o;
  1112. return regenerator.wrap(function _callee2$(_context2) {
  1113. while (1) {
  1114. switch (_context2.prev = _context2.next) {
  1115. case 0:
  1116. _context2.next = 2;
  1117. return this.findSkinConfig(e);
  1118. case 2:
  1119. n = _context2.sent.routeList.find(function (o) {
  1120. return o.pathName === t;
  1121. });
  1122. if (n) {
  1123. _context2.next = 6;
  1124. break;
  1125. }
  1126. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1127. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1128. case 6:
  1129. return _context2.abrupt("return", (logger.debug("find route success", n), n));
  1130. case 7:
  1131. case "end":
  1132. return _context2.stop();
  1133. }
  1134. }
  1135. }, _callee2, this);
  1136. }));
  1137. function findRoute(_x2, _x3) {
  1138. return _findRoute.apply(this, arguments);
  1139. }
  1140. return findRoute;
  1141. }()
  1142. }, {
  1143. key: "findAssetList",
  1144. value: function () {
  1145. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1146. var r, n;
  1147. return regenerator.wrap(function _callee3$(_context3) {
  1148. while (1) {
  1149. switch (_context3.prev = _context3.next) {
  1150. case 0:
  1151. _context3.next = 2;
  1152. return this.findSkinConfig(e);
  1153. case 2:
  1154. r = _context3.sent.assetList;
  1155. if (r) {
  1156. _context3.next = 6;
  1157. break;
  1158. }
  1159. n = "find path failed: skinId: ".concat(e);
  1160. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1161. case 6:
  1162. return _context3.abrupt("return", (logger.debug("find route success", r), r));
  1163. case 7:
  1164. case "end":
  1165. return _context3.stop();
  1166. }
  1167. }
  1168. }, _callee3, this);
  1169. }));
  1170. function findAssetList(_x4) {
  1171. return _findAssetList.apply(this, arguments);
  1172. }
  1173. return findAssetList;
  1174. }()
  1175. }, {
  1176. key: "findAsset",
  1177. value: function () {
  1178. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1179. var r,
  1180. n,
  1181. o,
  1182. a,
  1183. _args4 = arguments;
  1184. return regenerator.wrap(function _callee4$(_context4) {
  1185. while (1) {
  1186. switch (_context4.prev = _context4.next) {
  1187. case 0:
  1188. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1189. _context4.next = 3;
  1190. return this.findSkinConfig(e);
  1191. case 3:
  1192. n = _context4.sent;
  1193. if (!Array.isArray(t)) {
  1194. _context4.next = 6;
  1195. break;
  1196. }
  1197. return _context4.abrupt("return", t.map(function (a) {
  1198. return n.models.find(function (s) {
  1199. return s[r] === a;
  1200. });
  1201. }).filter(Boolean));
  1202. case 6:
  1203. o = n.models.find(function (a) {
  1204. return a[r] === t;
  1205. });
  1206. if (o) {
  1207. _context4.next = 10;
  1208. break;
  1209. }
  1210. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1211. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1212. case 10:
  1213. return _context4.abrupt("return", (logger.debug("find asset success", o), o));
  1214. case 11:
  1215. case "end":
  1216. return _context4.stop();
  1217. }
  1218. }
  1219. }, _callee4, this);
  1220. }));
  1221. function findAsset(_x5, _x6) {
  1222. return _findAsset.apply(this, arguments);
  1223. }
  1224. return findAsset;
  1225. }()
  1226. }, {
  1227. key: "findPoint",
  1228. value: function () {
  1229. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1230. var n, o;
  1231. return regenerator.wrap(function _callee5$(_context5) {
  1232. while (1) {
  1233. switch (_context5.prev = _context5.next) {
  1234. case 0:
  1235. _context5.next = 2;
  1236. return this.findSkinConfig(e);
  1237. case 2:
  1238. n = _context5.sent.pointList.find(function (o) {
  1239. return o.id === t;
  1240. });
  1241. if (n) {
  1242. _context5.next = 6;
  1243. break;
  1244. }
  1245. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1246. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1247. case 6:
  1248. return _context5.abrupt("return", (logger.debug("find point success", n), n));
  1249. case 7:
  1250. case "end":
  1251. return _context5.stop();
  1252. }
  1253. }
  1254. }, _callee5, this);
  1255. }));
  1256. function findPoint(_x7, _x8) {
  1257. return _findPoint.apply(this, arguments);
  1258. }
  1259. return findPoint;
  1260. }()
  1261. }, {
  1262. key: "requestConfig",
  1263. value: function () {
  1264. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1265. var e, t, r, _ref, n, o;
  1266. return regenerator.wrap(function _callee6$(_context6) {
  1267. while (1) {
  1268. switch (_context6.prev = _context6.next) {
  1269. case 0:
  1270. if (!this.config) {
  1271. _context6.next = 2;
  1272. break;
  1273. }
  1274. return _context6.abrupt("return", this.config);
  1275. case 2:
  1276. e = "https://static.xverse.cn/console/config/".concat(this.appId, "/config.json");
  1277. this.releaseId && (e = "https://static.xverse.cn/console/config/".concat(this.appId, "/").concat(this.releaseId, "/config.json"));
  1278. t = Xverse$1.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1279. _context6.prev = 5;
  1280. _context6.next = 8;
  1281. return http$1.get({
  1282. url: "".concat(t, "?t=").concat(Date.now()),
  1283. key: "config",
  1284. timeout: 6e3,
  1285. retry: 2
  1286. });
  1287. case 8:
  1288. r = _context6.sent;
  1289. _ref = r.data.data || {};
  1290. n = _ref.config;
  1291. o = _ref.preload;
  1292. if (n) {
  1293. _context6.next = 14;
  1294. break;
  1295. }
  1296. throw new Error("config data parse error" + r.data);
  1297. case 14:
  1298. return _context6.abrupt("return", (this.config = {
  1299. config: n,
  1300. preload: o
  1301. }, logger.debug("get config success", this.config), this.config));
  1302. case 17:
  1303. _context6.prev = 17;
  1304. _context6.t0 = _context6["catch"](5);
  1305. return _context6.abrupt("return", Promise.reject(_context6.t0));
  1306. case 20:
  1307. case "end":
  1308. return _context6.stop();
  1309. }
  1310. }
  1311. }, _callee6, this, [[5, 17]]);
  1312. }));
  1313. function requestConfig() {
  1314. return _requestConfig.apply(this, arguments);
  1315. }
  1316. return requestConfig;
  1317. }()
  1318. }, {
  1319. key: "getApplicationConfig",
  1320. value: function () {
  1321. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  1322. var e;
  1323. return regenerator.wrap(function _callee7$(_context7) {
  1324. while (1) {
  1325. switch (_context7.prev = _context7.next) {
  1326. case 0:
  1327. if (!this.applicationConfig) {
  1328. _context7.next = 2;
  1329. break;
  1330. }
  1331. return _context7.abrupt("return", this.applicationConfig);
  1332. case 2:
  1333. _context7.prev = 2;
  1334. _context7.next = 5;
  1335. return this.requestConfig();
  1336. case 5:
  1337. e = _context7.sent;
  1338. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  1339. case 9:
  1340. _context7.prev = 9;
  1341. _context7.t0 = _context7["catch"](2);
  1342. return _context7.abrupt("return", Promise.reject(_context7.t0));
  1343. case 12:
  1344. case "end":
  1345. return _context7.stop();
  1346. }
  1347. }
  1348. }, _callee7, this, [[2, 9]]);
  1349. }));
  1350. function getApplicationConfig() {
  1351. return _getApplicationConfig.apply(this, arguments);
  1352. }
  1353. return getApplicationConfig;
  1354. }()
  1355. }, {
  1356. key: "getAvatarModelList",
  1357. value: function () {
  1358. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  1359. var _yield$this$getApplic, e;
  1360. return regenerator.wrap(function _callee8$(_context8) {
  1361. while (1) {
  1362. switch (_context8.prev = _context8.next) {
  1363. case 0:
  1364. if (!this.avatarModelList.length) {
  1365. _context8.next = 2;
  1366. break;
  1367. }
  1368. return _context8.abrupt("return", this.avatarModelList);
  1369. case 2:
  1370. _context8.prev = 2;
  1371. _context8.next = 5;
  1372. return this.getApplicationConfig();
  1373. case 5:
  1374. _yield$this$getApplic = _context8.sent;
  1375. e = _yield$this$getApplic.avatars;
  1376. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  1377. return {
  1378. name: t.name,
  1379. id: t.id,
  1380. modelUrl: t.url,
  1381. gender: t.gender,
  1382. components: t.components
  1383. };
  1384. }), this.avatarModelList));
  1385. case 10:
  1386. _context8.prev = 10;
  1387. _context8.t0 = _context8["catch"](2);
  1388. return _context8.abrupt("return", (logger.error(_context8.t0), []));
  1389. case 13:
  1390. case "end":
  1391. return _context8.stop();
  1392. }
  1393. }
  1394. }, _callee8, this, [[2, 10]]);
  1395. }));
  1396. function getAvatarModelList() {
  1397. return _getAvatarModelList.apply(this, arguments);
  1398. }
  1399. return getAvatarModelList;
  1400. }()
  1401. }, {
  1402. key: "getSkinsList",
  1403. value: function () {
  1404. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  1405. var _yield$this$getApplic2, e;
  1406. return regenerator.wrap(function _callee9$(_context9) {
  1407. while (1) {
  1408. switch (_context9.prev = _context9.next) {
  1409. case 0:
  1410. if (!this.skinList.length) {
  1411. _context9.next = 2;
  1412. break;
  1413. }
  1414. return _context9.abrupt("return", this.skinList);
  1415. case 2:
  1416. _context9.prev = 2;
  1417. _context9.next = 5;
  1418. return this.getApplicationConfig();
  1419. case 5:
  1420. _yield$this$getApplic2 = _context9.sent;
  1421. e = _yield$this$getApplic2.skins;
  1422. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  1423. var r;
  1424. return {
  1425. name: t.name,
  1426. dataVersion: t.id + t.versionId,
  1427. id: t.id,
  1428. fov: parseInt(t.fov || 90),
  1429. models: t.assetList.map(function (n) {
  1430. var o = n.assetId,
  1431. a = n.url,
  1432. s = n.thumbnailUrl,
  1433. l = n.typeName,
  1434. u = n.className;
  1435. return {
  1436. id: o,
  1437. modelUrl: a,
  1438. name: n.name,
  1439. thumbnailUrl: s,
  1440. typeName: l,
  1441. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  1442. };
  1443. }),
  1444. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  1445. var o = n.areaName,
  1446. a = n.attitude,
  1447. s = n.id,
  1448. l = n.pathName,
  1449. u = n.step,
  1450. c = n.birthPointList;
  1451. return {
  1452. areaName: o,
  1453. attitude: a,
  1454. id: s,
  1455. pathName: l,
  1456. step: u,
  1457. birthPointList: c.map(function (h) {
  1458. return {
  1459. camera: h.camera && {
  1460. position: objectParseFloat(h.camera.position),
  1461. angle: objectParseFloat(h.camera.rotation)
  1462. },
  1463. player: h.player && {
  1464. position: objectParseFloat(h.player.position),
  1465. angle: objectParseFloat(h.player.rotation)
  1466. }
  1467. };
  1468. })
  1469. };
  1470. }),
  1471. pointList: t.pointList.map(function (n) {
  1472. return le(oe({}, n), {
  1473. position: objectParseFloat(n.position),
  1474. rotation: objectParseFloat(n.rotation)
  1475. });
  1476. }),
  1477. versionId: t.versionId,
  1478. isEnable: t.isEnable,
  1479. assetList: t.assetList,
  1480. visibleRules: t.visibleRules,
  1481. animationList: t.animationList
  1482. };
  1483. }), this.skinList));
  1484. case 10:
  1485. _context9.prev = 10;
  1486. _context9.t0 = _context9["catch"](2);
  1487. return _context9.abrupt("return", (logger.error(_context9.t0), []));
  1488. case 13:
  1489. case "end":
  1490. return _context9.stop();
  1491. }
  1492. }
  1493. }, _callee9, this, [[2, 10]]);
  1494. }));
  1495. function getSkinsList() {
  1496. return _getSkinsList.apply(this, arguments);
  1497. }
  1498. return getSkinsList;
  1499. }()
  1500. }, {
  1501. key: "getBreathPointTextrueList",
  1502. value: function () {
  1503. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  1504. return regenerator.wrap(function _callee10$(_context10) {
  1505. while (1) {
  1506. switch (_context10.prev = _context10.next) {
  1507. case 0:
  1508. return _context10.abrupt("return", [{
  1509. url: TEXTURE_URL
  1510. }]);
  1511. case 1:
  1512. case "end":
  1513. return _context10.stop();
  1514. }
  1515. }
  1516. }, _callee10);
  1517. }));
  1518. function getBreathPointTextrueList() {
  1519. return _getBreathPointTextrueList.apply(this, arguments);
  1520. }
  1521. return getBreathPointTextrueList;
  1522. }()
  1523. }], [{
  1524. key: "getInstance",
  1525. value: function getInstance(e, t) {
  1526. //getInstance(e, t) {
  1527. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  1528. }
  1529. }, {
  1530. key: "findModels",
  1531. value: function findModels(e, t, r) {
  1532. //findModels(e, t, r) {
  1533. return e.filter(function (o) {
  1534. return o.typeName === t && o.className === r;
  1535. });
  1536. }
  1537. }, {
  1538. key: "findModel",
  1539. value: function findModel(e, t, r) {
  1540. //findModel(e, t, r) {
  1541. var n = e.filter(function (o) {
  1542. return o.typeName === t && o.className === r;
  1543. })[0];
  1544. return n || null;
  1545. }
  1546. }]);
  1547. return ModelManager;
  1548. }();
  1549. // export { modelManager };
  1550. var Preload = /*#__PURE__*/function () {
  1551. function Preload(e) {
  1552. _classCallCheck(this, Preload);
  1553. this.config = null;
  1554. this.allKeys = [];
  1555. this.oldResourcesDeleted = !1;
  1556. this.requests = {
  1557. simple: {
  1558. stopped: !0,
  1559. requests: {}
  1560. },
  1561. observer: {
  1562. stopped: !0,
  1563. requests: {}
  1564. },
  1565. full: {
  1566. stopped: !0,
  1567. requests: {}
  1568. }
  1569. };
  1570. this.modelManager = e, this.init(e.appId);
  1571. }
  1572. _createClass(Preload, [{
  1573. key: "init",
  1574. value: function init(e) {
  1575. reporter.updateBody({
  1576. appId: e
  1577. });
  1578. }
  1579. }, {
  1580. key: "getConfig",
  1581. value: function () {
  1582. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1583. var _yield$this$modelMana, t;
  1584. return regenerator.wrap(function _callee$(_context) {
  1585. while (1) {
  1586. switch (_context.prev = _context.next) {
  1587. case 0:
  1588. if (!this.config) {
  1589. _context.next = 2;
  1590. break;
  1591. }
  1592. return _context.abrupt("return", this.config);
  1593. case 2:
  1594. _context.next = 4;
  1595. return this.modelManager.requestConfig();
  1596. case 4:
  1597. _yield$this$modelMana = _context.sent;
  1598. t = _yield$this$modelMana.preload;
  1599. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  1600. case 7:
  1601. case "end":
  1602. return _context.stop();
  1603. }
  1604. }
  1605. }, _callee, this);
  1606. }));
  1607. function getConfig(_x) {
  1608. return _getConfig.apply(this, arguments);
  1609. }
  1610. return getConfig;
  1611. }()
  1612. }, {
  1613. key: "getAllKeys",
  1614. value: function () {
  1615. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  1616. var e, t;
  1617. return regenerator.wrap(function _callee2$(_context2) {
  1618. while (1) {
  1619. switch (_context2.prev = _context2.next) {
  1620. case 0:
  1621. if (!this.allKeys.length) {
  1622. _context2.next = 2;
  1623. break;
  1624. }
  1625. return _context2.abrupt("return", this.allKeys);
  1626. case 2:
  1627. _context2.prev = 2;
  1628. _context2.next = 5;
  1629. return modelTable.getAllKeys();
  1630. case 5:
  1631. e = _context2.sent;
  1632. return _context2.abrupt("return", (this.allKeys = e, e));
  1633. case 9:
  1634. _context2.prev = 9;
  1635. _context2.t0 = _context2["catch"](2);
  1636. t = "preload getAllKeys error";
  1637. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  1638. case 13:
  1639. case "end":
  1640. return _context2.stop();
  1641. }
  1642. }
  1643. }, _callee2, this, [[2, 9]]);
  1644. }));
  1645. function getAllKeys() {
  1646. return _getAllKeys.apply(this, arguments);
  1647. }
  1648. return getAllKeys;
  1649. }()
  1650. }, {
  1651. key: "stop",
  1652. value: function stop(e) {
  1653. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  1654. var t = this.requests[e].requests;
  1655. Object.keys(t).forEach(function (r) {
  1656. http$1.canceler.removePending(r), delete t[r];
  1657. });
  1658. }
  1659. }, {
  1660. key: "clearPreload",
  1661. value: function clearPreload(e) {
  1662. this.requests[e].stopped = !1, this.allKeys = [];
  1663. }
  1664. }, {
  1665. key: "start",
  1666. value: function () {
  1667. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  1668. var n, o, a, s, l, u, h, f, _s;
  1669. return regenerator.wrap(function _callee3$(_context3) {
  1670. while (1) {
  1671. switch (_context3.prev = _context3.next) {
  1672. case 0:
  1673. n = Date.now(), o = 0;
  1674. _context3.prev = 1;
  1675. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  1676. _context3.next = 4;
  1677. break;
  1678. }
  1679. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  1680. case 4:
  1681. this.clearPreload(e);
  1682. _context3.next = 7;
  1683. return this.getConfig(e);
  1684. case 7:
  1685. a = _context3.sent;
  1686. _context3.next = 10;
  1687. return this.getAllKeys();
  1688. case 10:
  1689. s = _context3.sent;
  1690. _context3.prev = 11;
  1691. _context3.next = 14;
  1692. return this.deleteOldResources(a.assetUrls.map(function (d) {
  1693. return d.url;
  1694. }), s);
  1695. case 14:
  1696. _context3.next = 19;
  1697. break;
  1698. case 16:
  1699. _context3.prev = 16;
  1700. _context3.t0 = _context3["catch"](11);
  1701. logger.error(_context3.t0);
  1702. case 19:
  1703. l = a.baseUrls, u = a.assetUrls;
  1704. _context3.t1 = e;
  1705. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  1706. break;
  1707. case 23:
  1708. h = l;
  1709. return _context3.abrupt("break", 30);
  1710. case 25:
  1711. h = u;
  1712. return _context3.abrupt("break", 30);
  1713. case 27:
  1714. h = u;
  1715. return _context3.abrupt("break", 30);
  1716. case 29:
  1717. h = u;
  1718. case 30:
  1719. f = h.filter(function (d) {
  1720. return !s.includes(d.url);
  1721. });
  1722. r && isFunction(r) && (f = f.filter(r));
  1723. o = f.length;
  1724. logger.debug("keysNeedToPreload", f);
  1725. f.length || t && t(h.length, h.length);
  1726. n = Date.now();
  1727. _context3.next = 38;
  1728. return this._preload(e, f, t);
  1729. case 38:
  1730. logger.infoAndReportMeasurement({
  1731. tag: e,
  1732. startTime: n,
  1733. metric: "assetsPreload",
  1734. extra: {
  1735. total: o
  1736. }
  1737. });
  1738. return _context3.abrupt("return");
  1739. case 42:
  1740. _context3.prev = 42;
  1741. _context3.t2 = _context3["catch"](1);
  1742. _s = _context3.t2;
  1743. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  1744. tag: e,
  1745. startTime: n,
  1746. metric: "assetsPreload",
  1747. extra: {
  1748. total: o
  1749. },
  1750. error: _s,
  1751. reportOptions: {
  1752. immediate: !0
  1753. }
  1754. }), Promise.reject(_s)));
  1755. case 46:
  1756. case "end":
  1757. return _context3.stop();
  1758. }
  1759. }
  1760. }, _callee3, this, [[1, 42], [11, 16]]);
  1761. }));
  1762. function start(_x2, _x3, _x4) {
  1763. return _start.apply(this, arguments);
  1764. }
  1765. return start;
  1766. }()
  1767. }, {
  1768. key: "deleteOldResources",
  1769. value: function deleteOldResources(e, t) {
  1770. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  1771. var r = t.filter(function (n) {
  1772. return !e.includes(n);
  1773. });
  1774. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  1775. return modelTable.delete(n);
  1776. }));
  1777. }
  1778. }, {
  1779. key: "_preload",
  1780. value: function () {
  1781. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  1782. var _this = this;
  1783. var n, o, a;
  1784. return regenerator.wrap(function _callee6$(_context6) {
  1785. while (1) {
  1786. switch (_context6.prev = _context6.next) {
  1787. case 0:
  1788. n = t.length;
  1789. if (n) {
  1790. _context6.next = 3;
  1791. break;
  1792. }
  1793. return _context6.abrupt("return", Promise.resolve());
  1794. case 3:
  1795. o = 0;
  1796. a = window.setInterval(function () {
  1797. r && r(o, n), o >= n && window.clearInterval(a);
  1798. }, 1e3);
  1799. return _context6.abrupt("return", mapLimit(t, 10, /*#__PURE__*/function () {
  1800. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  1801. var l, u;
  1802. return regenerator.wrap(function _callee5$(_context5) {
  1803. while (1) {
  1804. switch (_context5.prev = _context5.next) {
  1805. case 0:
  1806. l = s.size, u = s.url;
  1807. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http$1.get({
  1808. url: u,
  1809. timeout: Preload.getTimeoutBySize(l),
  1810. responseType: "blob",
  1811. retry: 2,
  1812. beforeRequest: function beforeRequest() {
  1813. _this.requests[e].requests[u] = !0;
  1814. }
  1815. }).then( /*#__PURE__*/function () {
  1816. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  1817. var h, f;
  1818. return regenerator.wrap(function _callee4$(_context4) {
  1819. while (1) {
  1820. switch (_context4.prev = _context4.next) {
  1821. case 0:
  1822. h = c.data;
  1823. if (h instanceof Blob) {
  1824. _context4.next = 3;
  1825. break;
  1826. }
  1827. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  1828. case 3:
  1829. _context4.next = 5;
  1830. return blobToDataURI$1(h);
  1831. case 5:
  1832. f = _context4.sent;
  1833. _context4.prev = 6;
  1834. _context4.next = 9;
  1835. return modelTable.put({
  1836. url: u,
  1837. model: f
  1838. });
  1839. case 9:
  1840. return _context4.abrupt("return");
  1841. case 12:
  1842. _context4.prev = 12;
  1843. _context4.t0 = _context4["catch"](6);
  1844. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  1845. case 15:
  1846. case "end":
  1847. return _context4.stop();
  1848. }
  1849. }
  1850. }, _callee4, null, [[6, 12]]);
  1851. }));
  1852. return function (_x9) {
  1853. return _ref2.apply(this, arguments);
  1854. };
  1855. }()).then(function () {
  1856. o++, delete _this.requests[e].requests[u];
  1857. }, function (c) {
  1858. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  1859. }));
  1860. case 2:
  1861. case "end":
  1862. return _context5.stop();
  1863. }
  1864. }
  1865. }, _callee5);
  1866. }));
  1867. return function (_x8) {
  1868. return _ref.apply(this, arguments);
  1869. };
  1870. }()));
  1871. case 6:
  1872. case "end":
  1873. return _context6.stop();
  1874. }
  1875. }
  1876. }, _callee6);
  1877. }));
  1878. function _preload(_x5, _x6, _x7) {
  1879. return _preload2.apply(this, arguments);
  1880. }
  1881. return _preload;
  1882. }()
  1883. }], [{
  1884. key: "getTimeoutBySize",
  1885. value: function getTimeoutBySize(e) {
  1886. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  1887. }
  1888. }]);
  1889. return Preload;
  1890. }();
  1891. var Xverse = /*#__PURE__*/function () {
  1892. function Xverse(e) {
  1893. _classCallCheck(this, Xverse);
  1894. e || (e = {});
  1895. var _e = e,
  1896. t = _e.onLog,
  1897. r = _e.env,
  1898. n = _e.appId,
  1899. o = _e.releaseId,
  1900. a = _e.subPackageVersion;
  1901. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && Logger.setLevel(LoggerLevels.Debug);
  1902. var s = this.pageSession = util.uuid();
  1903. reporter.updateHeader({
  1904. pageSession: s
  1905. });
  1906. reporter.updateReportUrl(REPORT_URL[this.env]);
  1907. a && reporter.updateBody({
  1908. sdkVersion: a
  1909. });
  1910. logger.infoAndReportMeasurement({
  1911. metric: "sdkInit",
  1912. startTime: Date.now(),
  1913. extra: {
  1914. version: a,
  1915. enviroment: r,
  1916. pageSession: s
  1917. }
  1918. });
  1919. logger.debug("debug mode:", this.debug);
  1920. reporter.on("report", function (l) {
  1921. t && t(l);
  1922. });
  1923. if (n) {
  1924. this.appId = n, this.releaseId = o;
  1925. var l = ModelManager.getInstance(n, o);
  1926. this.preload = new Preload(l);
  1927. }
  1928. }
  1929. _createClass(Xverse, [{
  1930. key: "isSupported",
  1931. get: function get() {
  1932. return isSupported();
  1933. }
  1934. }, {
  1935. key: "disableLogUpload",
  1936. value: function disableLogUpload() {
  1937. reporter.disable(), logger.debug("logger upload has been disabled");
  1938. }
  1939. }, {
  1940. key: "getSkinList",
  1941. value: function () {
  1942. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  1943. return regenerator.wrap(function _callee$(_context) {
  1944. while (1) {
  1945. switch (_context.prev = _context.next) {
  1946. case 0:
  1947. return _context.abrupt("return", []);
  1948. case 1:
  1949. case "end":
  1950. return _context.stop();
  1951. }
  1952. }
  1953. }, _callee);
  1954. }));
  1955. function getSkinList() {
  1956. return _getSkinList.apply(this, arguments);
  1957. }
  1958. return getSkinList;
  1959. }()
  1960. }, {
  1961. key: "getAvatarList",
  1962. value: function () {
  1963. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  1964. return regenerator.wrap(function _callee2$(_context2) {
  1965. while (1) {
  1966. switch (_context2.prev = _context2.next) {
  1967. case 0:
  1968. return _context2.abrupt("return", []);
  1969. case 1:
  1970. case "end":
  1971. return _context2.stop();
  1972. }
  1973. }
  1974. }, _callee2);
  1975. }));
  1976. function getAvatarList() {
  1977. return _getAvatarList.apply(this, arguments);
  1978. }
  1979. return getAvatarList;
  1980. }()
  1981. }, {
  1982. key: "getGiftList",
  1983. value: function () {
  1984. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  1985. return regenerator.wrap(function _callee3$(_context3) {
  1986. while (1) {
  1987. switch (_context3.prev = _context3.next) {
  1988. case 0:
  1989. return _context3.abrupt("return", [{
  1990. id: "hack "
  1991. }]);
  1992. case 1:
  1993. case "end":
  1994. return _context3.stop();
  1995. }
  1996. }
  1997. }, _callee3);
  1998. }));
  1999. function getGiftList() {
  2000. return _getGiftList.apply(this, arguments);
  2001. }
  2002. return getGiftList;
  2003. }()
  2004. }, {
  2005. key: "joinRoom",
  2006. value: function () {
  2007. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2008. var t, r, n, o;
  2009. return regenerator.wrap(function _callee4$(_context4) {
  2010. while (1) {
  2011. switch (_context4.prev = _context4.next) {
  2012. case 0:
  2013. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), {
  2014. appId: e.appId || this.appId,
  2015. releaseId: e.releaseId || this.releaseId,
  2016. pageSession: this.pageSession,
  2017. isAllSync: !0,
  2018. rotationRenderType: r,
  2019. syncByEvent: !0,
  2020. pathName: t,
  2021. person: n,
  2022. role: e.role || "audience"
  2023. }));
  2024. return _context4.abrupt("return", o.initRoom().then(function () {
  2025. return o;
  2026. }));
  2027. case 2:
  2028. case "end":
  2029. return _context4.stop();
  2030. }
  2031. }
  2032. }, _callee4, this);
  2033. }));
  2034. function joinRoom(_x) {
  2035. return _joinRoom.apply(this, arguments);
  2036. }
  2037. return joinRoom;
  2038. }()
  2039. }]);
  2040. return Xverse;
  2041. }();
  2042. var xverse = new Xverse({
  2043. env: "DEV",
  2044. appId: 10016,
  2045. releaseId: '2203120033_29769e'
  2046. });
  2047. var l = /*#__PURE__*/function () {
  2048. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  2049. var R;
  2050. return regenerator.wrap(function _callee$(_context) {
  2051. while (1) {
  2052. switch (_context.prev = _context.next) {
  2053. case 0:
  2054. _context.prev = 0;
  2055. _context.next = 3;
  2056. return (R = xverse.preload) == null ? void 0 : R.start(P, function (M, x) {
  2057. var I = "(".concat(M, "/").concat(x, ")");
  2058. s(I);
  2059. });
  2060. case 3:
  2061. _context.next = 12;
  2062. break;
  2063. case 5:
  2064. _context.prev = 5;
  2065. _context.t0 = _context["catch"](0);
  2066. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  2067. _context.next = 10;
  2068. break;
  2069. }
  2070. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  2071. return _context.abrupt("return");
  2072. case 10:
  2073. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  2074. return _context.abrupt("return");
  2075. case 12:
  2076. _context.prev = 12;
  2077. _context.next = 15;
  2078. return xverse.joinRoom({
  2079. canvas: f,
  2080. skinId: v,
  2081. avatarId: g,
  2082. roomId: d,
  2083. userId: _,
  2084. wsServerUrl: C,
  2085. appId: m,
  2086. token: " ",
  2087. nickname: _,
  2088. firends: ["user1"],
  2089. viewMode: "full",
  2090. resolution: T,
  2091. pathName: y,
  2092. objectFit: b,
  2093. hasAvatar: !0,
  2094. syncToOthers: !0
  2095. });
  2096. case 15:
  2097. room = _context.sent;
  2098. u(), c(), window.room = room, e(!1);
  2099. _context.next = 23;
  2100. break;
  2101. case 19:
  2102. _context.prev = 19;
  2103. _context.t1 = _context["catch"](12);
  2104. console.error(_context.t1), alert(_context.t1);
  2105. return _context.abrupt("return");
  2106. case 23:
  2107. case "end":
  2108. return _context.stop();
  2109. }
  2110. }
  2111. }, _callee, null, [[0, 5], [12, 19]]);
  2112. }));
  2113. return function l() {
  2114. return _ref.apply(this, arguments);
  2115. };
  2116. }();
  2117. var u = function u() {
  2118. room.on("_coreClick", function (_ref2) {
  2119. var f = _ref2.point;
  2120. room._userAvatar.moveTo({
  2121. point: f
  2122. });
  2123. });
  2124. };
  2125. var c = function c() {
  2126. room.on("repeatLogin", function () {
  2127. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  2128. duration: 1e4
  2129. });
  2130. }), room.on("reconnecting", function (_ref3) {
  2131. var f = _ref3.count;
  2132. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  2133. }), room.on("reconnected", function () {
  2134. toast("\u91CD\u8FDE\u6210\u529F");
  2135. }), room.on("disconnected", function () {
  2136. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  2137. duration: 1e5,
  2138. onClick() {
  2139. f.hideToast(), room.reconnect();
  2140. }
  2141. });
  2142. });
  2143. };
  2144. l();
  2145. }));
  2146. //# sourceMappingURL=index.js.map