index.js 244 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/9
  4. * Author: https://www.4dkankan.com
  5. * Copyright © 2022 4DAGE Co., Ltd. All rights reserved.
  6. * Licensed under the GLP license
  7. */
  8. (function (factory) {
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. factory();
  11. })((function () { 'use strict';
  12. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  13. try {
  14. var info = gen[key](arg);
  15. var value = info.value;
  16. } catch (error) {
  17. reject(error);
  18. return;
  19. }
  20. if (info.done) {
  21. resolve(value);
  22. } else {
  23. Promise.resolve(value).then(_next, _throw);
  24. }
  25. }
  26. function _asyncToGenerator(fn) {
  27. return function () {
  28. var self = this,
  29. args = arguments;
  30. return new Promise(function (resolve, reject) {
  31. var gen = fn.apply(self, args);
  32. function _next(value) {
  33. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  34. }
  35. function _throw(err) {
  36. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  37. }
  38. _next(undefined);
  39. });
  40. };
  41. }
  42. function createCommonjsModule(fn) {
  43. var module = { exports: {} };
  44. return fn(module, module.exports), module.exports;
  45. }
  46. /**
  47. * Copyright (c) 2014-present, Facebook, Inc.
  48. *
  49. * This source code is licensed under the MIT license found in the
  50. * LICENSE file in the root directory of this source tree.
  51. */
  52. var runtime_1 = createCommonjsModule(function (module) {
  53. var runtime = (function (exports) {
  54. var Op = Object.prototype;
  55. var hasOwn = Op.hasOwnProperty;
  56. var undefined$1; // More compressible than void 0.
  57. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  58. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  59. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  60. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  61. function define(obj, key, value) {
  62. Object.defineProperty(obj, key, {
  63. value: value,
  64. enumerable: true,
  65. configurable: true,
  66. writable: true
  67. });
  68. return obj[key];
  69. }
  70. try {
  71. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  72. define({}, "");
  73. } catch (err) {
  74. define = function(obj, key, value) {
  75. return obj[key] = value;
  76. };
  77. }
  78. function wrap(innerFn, outerFn, self, tryLocsList) {
  79. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  80. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  81. var generator = Object.create(protoGenerator.prototype);
  82. var context = new Context(tryLocsList || []);
  83. // The ._invoke method unifies the implementations of the .next,
  84. // .throw, and .return methods.
  85. generator._invoke = makeInvokeMethod(innerFn, self, context);
  86. return generator;
  87. }
  88. exports.wrap = wrap;
  89. // Try/catch helper to minimize deoptimizations. Returns a completion
  90. // record like context.tryEntries[i].completion. This interface could
  91. // have been (and was previously) designed to take a closure to be
  92. // invoked without arguments, but in all the cases we care about we
  93. // already have an existing method we want to call, so there's no need
  94. // to create a new function object. We can even get away with assuming
  95. // the method takes exactly one argument, since that happens to be true
  96. // in every case, so we don't have to touch the arguments object. The
  97. // only additional allocation required is the completion record, which
  98. // has a stable shape and so hopefully should be cheap to allocate.
  99. function tryCatch(fn, obj, arg) {
  100. try {
  101. return { type: "normal", arg: fn.call(obj, arg) };
  102. } catch (err) {
  103. return { type: "throw", arg: err };
  104. }
  105. }
  106. var GenStateSuspendedStart = "suspendedStart";
  107. var GenStateSuspendedYield = "suspendedYield";
  108. var GenStateExecuting = "executing";
  109. var GenStateCompleted = "completed";
  110. // Returning this object from the innerFn has the same effect as
  111. // breaking out of the dispatch switch statement.
  112. var ContinueSentinel = {};
  113. // Dummy constructor functions that we use as the .constructor and
  114. // .constructor.prototype properties for functions that return Generator
  115. // objects. For full spec compliance, you may wish to configure your
  116. // minifier not to mangle the names of these two functions.
  117. function Generator() {}
  118. function GeneratorFunction() {}
  119. function GeneratorFunctionPrototype() {}
  120. // This is a polyfill for %IteratorPrototype% for environments that
  121. // don't natively support it.
  122. var IteratorPrototype = {};
  123. define(IteratorPrototype, iteratorSymbol, function () {
  124. return this;
  125. });
  126. var getProto = Object.getPrototypeOf;
  127. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  128. if (NativeIteratorPrototype &&
  129. NativeIteratorPrototype !== Op &&
  130. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  131. // This environment has a native %IteratorPrototype%; use it instead
  132. // of the polyfill.
  133. IteratorPrototype = NativeIteratorPrototype;
  134. }
  135. var Gp = GeneratorFunctionPrototype.prototype =
  136. Generator.prototype = Object.create(IteratorPrototype);
  137. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  138. define(Gp, "constructor", GeneratorFunctionPrototype);
  139. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  140. GeneratorFunction.displayName = define(
  141. GeneratorFunctionPrototype,
  142. toStringTagSymbol,
  143. "GeneratorFunction"
  144. );
  145. // Helper for defining the .next, .throw, and .return methods of the
  146. // Iterator interface in terms of a single ._invoke method.
  147. function defineIteratorMethods(prototype) {
  148. ["next", "throw", "return"].forEach(function(method) {
  149. define(prototype, method, function(arg) {
  150. return this._invoke(method, arg);
  151. });
  152. });
  153. }
  154. exports.isGeneratorFunction = function(genFun) {
  155. var ctor = typeof genFun === "function" && genFun.constructor;
  156. return ctor
  157. ? ctor === GeneratorFunction ||
  158. // For the native GeneratorFunction constructor, the best we can
  159. // do is to check its .name property.
  160. (ctor.displayName || ctor.name) === "GeneratorFunction"
  161. : false;
  162. };
  163. exports.mark = function(genFun) {
  164. if (Object.setPrototypeOf) {
  165. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  166. } else {
  167. genFun.__proto__ = GeneratorFunctionPrototype;
  168. define(genFun, toStringTagSymbol, "GeneratorFunction");
  169. }
  170. genFun.prototype = Object.create(Gp);
  171. return genFun;
  172. };
  173. // Within the body of any async function, `await x` is transformed to
  174. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  175. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  176. // meant to be awaited.
  177. exports.awrap = function(arg) {
  178. return { __await: arg };
  179. };
  180. function AsyncIterator(generator, PromiseImpl) {
  181. function invoke(method, arg, resolve, reject) {
  182. var record = tryCatch(generator[method], generator, arg);
  183. if (record.type === "throw") {
  184. reject(record.arg);
  185. } else {
  186. var result = record.arg;
  187. var value = result.value;
  188. if (value &&
  189. typeof value === "object" &&
  190. hasOwn.call(value, "__await")) {
  191. return PromiseImpl.resolve(value.__await).then(function(value) {
  192. invoke("next", value, resolve, reject);
  193. }, function(err) {
  194. invoke("throw", err, resolve, reject);
  195. });
  196. }
  197. return PromiseImpl.resolve(value).then(function(unwrapped) {
  198. // When a yielded Promise is resolved, its final value becomes
  199. // the .value of the Promise<{value,done}> result for the
  200. // current iteration.
  201. result.value = unwrapped;
  202. resolve(result);
  203. }, function(error) {
  204. // If a rejected Promise was yielded, throw the rejection back
  205. // into the async generator function so it can be handled there.
  206. return invoke("throw", error, resolve, reject);
  207. });
  208. }
  209. }
  210. var previousPromise;
  211. function enqueue(method, arg) {
  212. function callInvokeWithMethodAndArg() {
  213. return new PromiseImpl(function(resolve, reject) {
  214. invoke(method, arg, resolve, reject);
  215. });
  216. }
  217. return previousPromise =
  218. // If enqueue has been called before, then we want to wait until
  219. // all previous Promises have been resolved before calling invoke,
  220. // so that results are always delivered in the correct order. If
  221. // enqueue has not been called before, then it is important to
  222. // call invoke immediately, without waiting on a callback to fire,
  223. // so that the async generator function has the opportunity to do
  224. // any necessary setup in a predictable way. This predictability
  225. // is why the Promise constructor synchronously invokes its
  226. // executor callback, and why async functions synchronously
  227. // execute code before the first await. Since we implement simple
  228. // async functions in terms of async generators, it is especially
  229. // important to get this right, even though it requires care.
  230. previousPromise ? previousPromise.then(
  231. callInvokeWithMethodAndArg,
  232. // Avoid propagating failures to Promises returned by later
  233. // invocations of the iterator.
  234. callInvokeWithMethodAndArg
  235. ) : callInvokeWithMethodAndArg();
  236. }
  237. // Define the unified helper method that is used to implement .next,
  238. // .throw, and .return (see defineIteratorMethods).
  239. this._invoke = enqueue;
  240. }
  241. defineIteratorMethods(AsyncIterator.prototype);
  242. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  243. return this;
  244. });
  245. exports.AsyncIterator = AsyncIterator;
  246. // Note that simple async functions are implemented on top of
  247. // AsyncIterator objects; they just return a Promise for the value of
  248. // the final result produced by the iterator.
  249. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  250. if (PromiseImpl === void 0) PromiseImpl = Promise;
  251. var iter = new AsyncIterator(
  252. wrap(innerFn, outerFn, self, tryLocsList),
  253. PromiseImpl
  254. );
  255. return exports.isGeneratorFunction(outerFn)
  256. ? iter // If outerFn is a generator, return the full iterator.
  257. : iter.next().then(function(result) {
  258. return result.done ? result.value : iter.next();
  259. });
  260. };
  261. function makeInvokeMethod(innerFn, self, context) {
  262. var state = GenStateSuspendedStart;
  263. return function invoke(method, arg) {
  264. if (state === GenStateExecuting) {
  265. throw new Error("Generator is already running");
  266. }
  267. if (state === GenStateCompleted) {
  268. if (method === "throw") {
  269. throw arg;
  270. }
  271. // Be forgiving, per 25.3.3.3.3 of the spec:
  272. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  273. return doneResult();
  274. }
  275. context.method = method;
  276. context.arg = arg;
  277. while (true) {
  278. var delegate = context.delegate;
  279. if (delegate) {
  280. var delegateResult = maybeInvokeDelegate(delegate, context);
  281. if (delegateResult) {
  282. if (delegateResult === ContinueSentinel) continue;
  283. return delegateResult;
  284. }
  285. }
  286. if (context.method === "next") {
  287. // Setting context._sent for legacy support of Babel's
  288. // function.sent implementation.
  289. context.sent = context._sent = context.arg;
  290. } else if (context.method === "throw") {
  291. if (state === GenStateSuspendedStart) {
  292. state = GenStateCompleted;
  293. throw context.arg;
  294. }
  295. context.dispatchException(context.arg);
  296. } else if (context.method === "return") {
  297. context.abrupt("return", context.arg);
  298. }
  299. state = GenStateExecuting;
  300. var record = tryCatch(innerFn, self, context);
  301. if (record.type === "normal") {
  302. // If an exception is thrown from innerFn, we leave state ===
  303. // GenStateExecuting and loop back for another invocation.
  304. state = context.done
  305. ? GenStateCompleted
  306. : GenStateSuspendedYield;
  307. if (record.arg === ContinueSentinel) {
  308. continue;
  309. }
  310. return {
  311. value: record.arg,
  312. done: context.done
  313. };
  314. } else if (record.type === "throw") {
  315. state = GenStateCompleted;
  316. // Dispatch the exception by looping back around to the
  317. // context.dispatchException(context.arg) call above.
  318. context.method = "throw";
  319. context.arg = record.arg;
  320. }
  321. }
  322. };
  323. }
  324. // Call delegate.iterator[context.method](context.arg) and handle the
  325. // result, either by returning a { value, done } result from the
  326. // delegate iterator, or by modifying context.method and context.arg,
  327. // setting context.delegate to null, and returning the ContinueSentinel.
  328. function maybeInvokeDelegate(delegate, context) {
  329. var method = delegate.iterator[context.method];
  330. if (method === undefined$1) {
  331. // A .throw or .return when the delegate iterator has no .throw
  332. // method always terminates the yield* loop.
  333. context.delegate = null;
  334. if (context.method === "throw") {
  335. // Note: ["return"] must be used for ES3 parsing compatibility.
  336. if (delegate.iterator["return"]) {
  337. // If the delegate iterator has a return method, give it a
  338. // chance to clean up.
  339. context.method = "return";
  340. context.arg = undefined$1;
  341. maybeInvokeDelegate(delegate, context);
  342. if (context.method === "throw") {
  343. // If maybeInvokeDelegate(context) changed context.method from
  344. // "return" to "throw", let that override the TypeError below.
  345. return ContinueSentinel;
  346. }
  347. }
  348. context.method = "throw";
  349. context.arg = new TypeError(
  350. "The iterator does not provide a 'throw' method");
  351. }
  352. return ContinueSentinel;
  353. }
  354. var record = tryCatch(method, delegate.iterator, context.arg);
  355. if (record.type === "throw") {
  356. context.method = "throw";
  357. context.arg = record.arg;
  358. context.delegate = null;
  359. return ContinueSentinel;
  360. }
  361. var info = record.arg;
  362. if (! info) {
  363. context.method = "throw";
  364. context.arg = new TypeError("iterator result is not an object");
  365. context.delegate = null;
  366. return ContinueSentinel;
  367. }
  368. if (info.done) {
  369. // Assign the result of the finished delegate to the temporary
  370. // variable specified by delegate.resultName (see delegateYield).
  371. context[delegate.resultName] = info.value;
  372. // Resume execution at the desired location (see delegateYield).
  373. context.next = delegate.nextLoc;
  374. // If context.method was "throw" but the delegate handled the
  375. // exception, let the outer generator proceed normally. If
  376. // context.method was "next", forget context.arg since it has been
  377. // "consumed" by the delegate iterator. If context.method was
  378. // "return", allow the original .return call to continue in the
  379. // outer generator.
  380. if (context.method !== "return") {
  381. context.method = "next";
  382. context.arg = undefined$1;
  383. }
  384. } else {
  385. // Re-yield the result returned by the delegate method.
  386. return info;
  387. }
  388. // The delegate iterator is finished, so forget it and continue with
  389. // the outer generator.
  390. context.delegate = null;
  391. return ContinueSentinel;
  392. }
  393. // Define Generator.prototype.{next,throw,return} in terms of the
  394. // unified ._invoke helper method.
  395. defineIteratorMethods(Gp);
  396. define(Gp, toStringTagSymbol, "Generator");
  397. // A Generator should always return itself as the iterator object when the
  398. // @@iterator function is called on it. Some browsers' implementations of the
  399. // iterator prototype chain incorrectly implement this, causing the Generator
  400. // object to not be returned from this call. This ensures that doesn't happen.
  401. // See https://github.com/facebook/regenerator/issues/274 for more details.
  402. define(Gp, iteratorSymbol, function() {
  403. return this;
  404. });
  405. define(Gp, "toString", function() {
  406. return "[object Generator]";
  407. });
  408. function pushTryEntry(locs) {
  409. var entry = { tryLoc: locs[0] };
  410. if (1 in locs) {
  411. entry.catchLoc = locs[1];
  412. }
  413. if (2 in locs) {
  414. entry.finallyLoc = locs[2];
  415. entry.afterLoc = locs[3];
  416. }
  417. this.tryEntries.push(entry);
  418. }
  419. function resetTryEntry(entry) {
  420. var record = entry.completion || {};
  421. record.type = "normal";
  422. delete record.arg;
  423. entry.completion = record;
  424. }
  425. function Context(tryLocsList) {
  426. // The root entry object (effectively a try statement without a catch
  427. // or a finally block) gives us a place to store values thrown from
  428. // locations where there is no enclosing try statement.
  429. this.tryEntries = [{ tryLoc: "root" }];
  430. tryLocsList.forEach(pushTryEntry, this);
  431. this.reset(true);
  432. }
  433. exports.keys = function(object) {
  434. var keys = [];
  435. for (var key in object) {
  436. keys.push(key);
  437. }
  438. keys.reverse();
  439. // Rather than returning an object with a next method, we keep
  440. // things simple and return the next function itself.
  441. return function next() {
  442. while (keys.length) {
  443. var key = keys.pop();
  444. if (key in object) {
  445. next.value = key;
  446. next.done = false;
  447. return next;
  448. }
  449. }
  450. // To avoid creating an additional object, we just hang the .value
  451. // and .done properties off the next function object itself. This
  452. // also ensures that the minifier will not anonymize the function.
  453. next.done = true;
  454. return next;
  455. };
  456. };
  457. function values(iterable) {
  458. if (iterable) {
  459. var iteratorMethod = iterable[iteratorSymbol];
  460. if (iteratorMethod) {
  461. return iteratorMethod.call(iterable);
  462. }
  463. if (typeof iterable.next === "function") {
  464. return iterable;
  465. }
  466. if (!isNaN(iterable.length)) {
  467. var i = -1, next = function next() {
  468. while (++i < iterable.length) {
  469. if (hasOwn.call(iterable, i)) {
  470. next.value = iterable[i];
  471. next.done = false;
  472. return next;
  473. }
  474. }
  475. next.value = undefined$1;
  476. next.done = true;
  477. return next;
  478. };
  479. return next.next = next;
  480. }
  481. }
  482. // Return an iterator with no values.
  483. return { next: doneResult };
  484. }
  485. exports.values = values;
  486. function doneResult() {
  487. return { value: undefined$1, done: true };
  488. }
  489. Context.prototype = {
  490. constructor: Context,
  491. reset: function(skipTempReset) {
  492. this.prev = 0;
  493. this.next = 0;
  494. // Resetting context._sent for legacy support of Babel's
  495. // function.sent implementation.
  496. this.sent = this._sent = undefined$1;
  497. this.done = false;
  498. this.delegate = null;
  499. this.method = "next";
  500. this.arg = undefined$1;
  501. this.tryEntries.forEach(resetTryEntry);
  502. if (!skipTempReset) {
  503. for (var name in this) {
  504. // Not sure about the optimal order of these conditions:
  505. if (name.charAt(0) === "t" &&
  506. hasOwn.call(this, name) &&
  507. !isNaN(+name.slice(1))) {
  508. this[name] = undefined$1;
  509. }
  510. }
  511. }
  512. },
  513. stop: function() {
  514. this.done = true;
  515. var rootEntry = this.tryEntries[0];
  516. var rootRecord = rootEntry.completion;
  517. if (rootRecord.type === "throw") {
  518. throw rootRecord.arg;
  519. }
  520. return this.rval;
  521. },
  522. dispatchException: function(exception) {
  523. if (this.done) {
  524. throw exception;
  525. }
  526. var context = this;
  527. function handle(loc, caught) {
  528. record.type = "throw";
  529. record.arg = exception;
  530. context.next = loc;
  531. if (caught) {
  532. // If the dispatched exception was caught by a catch block,
  533. // then let that catch block handle the exception normally.
  534. context.method = "next";
  535. context.arg = undefined$1;
  536. }
  537. return !! caught;
  538. }
  539. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  540. var entry = this.tryEntries[i];
  541. var record = entry.completion;
  542. if (entry.tryLoc === "root") {
  543. // Exception thrown outside of any try block that could handle
  544. // it, so set the completion value of the entire function to
  545. // throw the exception.
  546. return handle("end");
  547. }
  548. if (entry.tryLoc <= this.prev) {
  549. var hasCatch = hasOwn.call(entry, "catchLoc");
  550. var hasFinally = hasOwn.call(entry, "finallyLoc");
  551. if (hasCatch && hasFinally) {
  552. if (this.prev < entry.catchLoc) {
  553. return handle(entry.catchLoc, true);
  554. } else if (this.prev < entry.finallyLoc) {
  555. return handle(entry.finallyLoc);
  556. }
  557. } else if (hasCatch) {
  558. if (this.prev < entry.catchLoc) {
  559. return handle(entry.catchLoc, true);
  560. }
  561. } else if (hasFinally) {
  562. if (this.prev < entry.finallyLoc) {
  563. return handle(entry.finallyLoc);
  564. }
  565. } else {
  566. throw new Error("try statement without catch or finally");
  567. }
  568. }
  569. }
  570. },
  571. abrupt: function(type, arg) {
  572. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  573. var entry = this.tryEntries[i];
  574. if (entry.tryLoc <= this.prev &&
  575. hasOwn.call(entry, "finallyLoc") &&
  576. this.prev < entry.finallyLoc) {
  577. var finallyEntry = entry;
  578. break;
  579. }
  580. }
  581. if (finallyEntry &&
  582. (type === "break" ||
  583. type === "continue") &&
  584. finallyEntry.tryLoc <= arg &&
  585. arg <= finallyEntry.finallyLoc) {
  586. // Ignore the finally entry if control is not jumping to a
  587. // location outside the try/catch block.
  588. finallyEntry = null;
  589. }
  590. var record = finallyEntry ? finallyEntry.completion : {};
  591. record.type = type;
  592. record.arg = arg;
  593. if (finallyEntry) {
  594. this.method = "next";
  595. this.next = finallyEntry.finallyLoc;
  596. return ContinueSentinel;
  597. }
  598. return this.complete(record);
  599. },
  600. complete: function(record, afterLoc) {
  601. if (record.type === "throw") {
  602. throw record.arg;
  603. }
  604. if (record.type === "break" ||
  605. record.type === "continue") {
  606. this.next = record.arg;
  607. } else if (record.type === "return") {
  608. this.rval = this.arg = record.arg;
  609. this.method = "return";
  610. this.next = "end";
  611. } else if (record.type === "normal" && afterLoc) {
  612. this.next = afterLoc;
  613. }
  614. return ContinueSentinel;
  615. },
  616. finish: function(finallyLoc) {
  617. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  618. var entry = this.tryEntries[i];
  619. if (entry.finallyLoc === finallyLoc) {
  620. this.complete(entry.completion, entry.afterLoc);
  621. resetTryEntry(entry);
  622. return ContinueSentinel;
  623. }
  624. }
  625. },
  626. "catch": function(tryLoc) {
  627. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  628. var entry = this.tryEntries[i];
  629. if (entry.tryLoc === tryLoc) {
  630. var record = entry.completion;
  631. if (record.type === "throw") {
  632. var thrown = record.arg;
  633. resetTryEntry(entry);
  634. }
  635. return thrown;
  636. }
  637. }
  638. // The context.catch method must only be called with a location
  639. // argument that corresponds to a known catch block.
  640. throw new Error("illegal catch attempt");
  641. },
  642. delegateYield: function(iterable, resultName, nextLoc) {
  643. this.delegate = {
  644. iterator: values(iterable),
  645. resultName: resultName,
  646. nextLoc: nextLoc
  647. };
  648. if (this.method === "next") {
  649. // Deliberately forget the last sent value so that we don't
  650. // accidentally pass it on to the delegate.
  651. this.arg = undefined$1;
  652. }
  653. return ContinueSentinel;
  654. }
  655. };
  656. // Regardless of whether this script is executing as a CommonJS module
  657. // or not, return the runtime object so that we can declare the variable
  658. // regeneratorRuntime in the outer scope, which allows this module to be
  659. // injected easily by `bin/regenerator --include-runtime script.js`.
  660. return exports;
  661. }(
  662. // If this script is executing as a CommonJS module, use module.exports
  663. // as the regeneratorRuntime namespace. Otherwise create a new empty
  664. // object. Either way, the resulting object will be used to initialize
  665. // the regeneratorRuntime variable at the top of this file.
  666. module.exports
  667. ));
  668. try {
  669. regeneratorRuntime = runtime;
  670. } catch (accidentalStrictMode) {
  671. // This module should not be running in strict mode, so the above
  672. // assignment should always work unless something is misconfigured. Just
  673. // in case runtime.js accidentally runs in strict mode, in modern engines
  674. // we can explicitly access globalThis. In older engines we can escape
  675. // strict mode using a global Function call. This could conceivably fail
  676. // if a Content Security Policy forbids using Function, but in that case
  677. // the proper solution is to fix the accidental strict mode problem. If
  678. // you've misconfigured your bundler to force strict mode and applied a
  679. // CSP to forbid Function, and you're not willing to fix either of those
  680. // problems, please detail your unique predicament in a GitHub issue.
  681. if (typeof globalThis === "object") {
  682. globalThis.regeneratorRuntime = runtime;
  683. } else {
  684. Function("r", "regeneratorRuntime = r")(runtime);
  685. }
  686. }
  687. });
  688. var regenerator = runtime_1;
  689. function _classCallCheck(instance, Constructor) {
  690. if (!(instance instanceof Constructor)) {
  691. throw new TypeError("Cannot call a class as a function");
  692. }
  693. }
  694. function _defineProperties(target, props) {
  695. for (var i = 0; i < props.length; i++) {
  696. var descriptor = props[i];
  697. descriptor.enumerable = descriptor.enumerable || false;
  698. descriptor.configurable = true;
  699. if ("value" in descriptor) descriptor.writable = true;
  700. Object.defineProperty(target, descriptor.key, descriptor);
  701. }
  702. }
  703. function _createClass(Constructor, protoProps, staticProps) {
  704. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  705. if (staticProps) _defineProperties(Constructor, staticProps);
  706. Object.defineProperty(Constructor, "prototype", {
  707. writable: false
  708. });
  709. return Constructor;
  710. }
  711. var util = {
  712. uuid() {
  713. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
  714. var e = Math.random() * 16 | 0;
  715. return (i === "x" ? e : e & 3 | 8).toString(16);
  716. });
  717. },
  718. getFormattedDate(i) {
  719. var e = i.getMonth() + 1,
  720. t = i.getDate(),
  721. r = i.getHours(),
  722. n = i.getMinutes(),
  723. o = i.getSeconds(),
  724. a = i.getMilliseconds(),
  725. s = (e < 10 ? "0" : "") + e,
  726. l = (t < 10 ? "0" : "") + t,
  727. u = (r < 10 ? "0" : "") + r,
  728. c = (n < 10 ? "0" : "") + n,
  729. h = (o < 10 ? "0" : "") + o;
  730. return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
  731. },
  732. createInstance(i) {
  733. var e = new Axios(i),
  734. t = bind(Axios.prototype.request, e);
  735. return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
  736. return createInstance(mergeConfig(i, n));
  737. }, t;
  738. },
  739. mapLimit(i, e, t) {
  740. return new Promise(function (r, n) {
  741. var o = i.length;
  742. var a = e - 1,
  743. s = 0;
  744. var l = function l(u) {
  745. u.forEach(function (c) {
  746. t(c).then(function () {
  747. if (s++, s === o) {
  748. r();
  749. return;
  750. }
  751. a++;
  752. var h = i[a];
  753. h && l([h]);
  754. }, function (h) {
  755. n(h);
  756. });
  757. });
  758. };
  759. l(i.slice(0, e));
  760. });
  761. },
  762. isWebAssemblySupported() {
  763. try {
  764. if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
  765. var i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
  766. if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
  767. }
  768. } catch (_unused) {}
  769. return console.log("wasm is not supported"), !1;
  770. },
  771. isSupported() {
  772. return typeof RTCPeerConnection == "function" && this.isWebAssemblySupported();
  773. }
  774. };
  775. function _setPrototypeOf(o, p) {
  776. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  777. o.__proto__ = p;
  778. return o;
  779. };
  780. return _setPrototypeOf(o, p);
  781. }
  782. function _inherits(subClass, superClass) {
  783. if (typeof superClass !== "function" && superClass !== null) {
  784. throw new TypeError("Super expression must either be null or a function");
  785. }
  786. subClass.prototype = Object.create(superClass && superClass.prototype, {
  787. constructor: {
  788. value: subClass,
  789. writable: true,
  790. configurable: true
  791. }
  792. });
  793. Object.defineProperty(subClass, "prototype", {
  794. writable: false
  795. });
  796. if (superClass) _setPrototypeOf(subClass, superClass);
  797. }
  798. function _typeof(obj) {
  799. "@babel/helpers - typeof";
  800. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  801. return typeof obj;
  802. } : function (obj) {
  803. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  804. }, _typeof(obj);
  805. }
  806. function _assertThisInitialized(self) {
  807. if (self === void 0) {
  808. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  809. }
  810. return self;
  811. }
  812. function _possibleConstructorReturn(self, call) {
  813. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  814. return call;
  815. } else if (call !== void 0) {
  816. throw new TypeError("Derived constructors may only return object or undefined");
  817. }
  818. return _assertThisInitialized(self);
  819. }
  820. function _getPrototypeOf(o) {
  821. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  822. return o.__proto__ || Object.getPrototypeOf(o);
  823. };
  824. return _getPrototypeOf(o);
  825. }
  826. function _createSuper$b(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$c(); 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); }; }
  827. function _isNativeReflectConstruct$c() { 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; } }
  828. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  829. _inherits(Reporter, _EventEmitter);
  830. var _super = _createSuper$b(Reporter);
  831. function Reporter() {
  832. var _this;
  833. _classCallCheck(this, Reporter);
  834. _this = _super.call(this);
  835. _this._header = {};
  836. _this._body = {};
  837. _this._queue = [];
  838. _this._disabled = !1;
  839. _this._interval = null;
  840. _this._reportUrl = null;
  841. _this.isDocumentLoaded = function () {
  842. return document.readyState === "complete";
  843. };
  844. _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 () {
  845. _this._flushReport();
  846. }, 10 * 1e3);
  847. return _this;
  848. }
  849. _createClass(Reporter, [{
  850. key: "disable",
  851. value: function disable() {
  852. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  853. }
  854. }, {
  855. key: "updateHeader",
  856. value: function updateHeader(e) {
  857. Object.assign(this._header, e);
  858. }
  859. }, {
  860. key: "updateBody",
  861. value: function updateBody(e) {
  862. Object.assign(this._body, e);
  863. }
  864. }, {
  865. key: "updateReportUrl",
  866. value: function updateReportUrl(e) {
  867. this._reportUrl = e;
  868. }
  869. }, {
  870. key: "report",
  871. value: function report(e, t, r) {
  872. var _this2 = this;
  873. if (this._disabled) return;
  874. r || (r = {});
  875. var _r = r,
  876. n = _r.immediate,
  877. o = _r.sampleRate;
  878. if (o && o > Math.random()) return;
  879. this.updateBody({
  880. logTime: util.getFormattedDate(new Date()),
  881. logTimestamp: Date.now()
  882. });
  883. var a = function a(s) {
  884. var l = oe(le(oe({}, _this2._body), {
  885. type: e
  886. }), s);
  887. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  888. };
  889. Array.isArray(t) ? t.forEach(function (s) {
  890. return a(s);
  891. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  892. }
  893. }, {
  894. key: "_flushReport",
  895. value: function _flushReport() {
  896. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  897. var e = {
  898. header: this._header,
  899. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  900. };
  901. this._post(e);
  902. }
  903. }, {
  904. key: "_post",
  905. value: function _post(e) {
  906. var t = this._reportUrl || REPORT_URL.DEV;
  907. return new Promise(function (r, n) {
  908. var o = new XMLHttpRequest();
  909. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  910. try {
  911. o.send(JSON.stringify(e));
  912. } catch (a) {
  913. console.error(a);
  914. }
  915. o.addEventListener("readystatechange", function () {
  916. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  917. });
  918. });
  919. }
  920. }]);
  921. return Reporter;
  922. }(EventEmitter);
  923. var reporter$1 = new Reporter();
  924. function _arrayLikeToArray(arr, len) {
  925. if (len == null || len > arr.length) len = arr.length;
  926. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  927. arr2[i] = arr[i];
  928. }
  929. return arr2;
  930. }
  931. function _arrayWithoutHoles(arr) {
  932. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  933. }
  934. function _iterableToArray(iter) {
  935. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  936. }
  937. function _unsupportedIterableToArray(o, minLen) {
  938. if (!o) return;
  939. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  940. var n = Object.prototype.toString.call(o).slice(8, -1);
  941. if (n === "Object" && o.constructor) n = o.constructor.name;
  942. if (n === "Map" || n === "Set") return Array.from(o);
  943. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  944. }
  945. function _nonIterableSpread() {
  946. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  947. }
  948. function _toConsumableArray(arr) {
  949. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  950. }
  951. var Codes = {
  952. Success: 0,
  953. Param: 1001,
  954. Internal: 1002,
  955. Timeout: 1003,
  956. Authentication: 1004,
  957. TokenExpired: 1005,
  958. Unsupported: 1006,
  959. InitNetworkTimeout: 1007,
  960. InitDecoderTimeout: 1008,
  961. InitConfigTimeout: 1009,
  962. InitEngineTimeout: 1010,
  963. InitEngine: 1011,
  964. ActionBlocked: 1012,
  965. PreloadCanceled: 1013,
  966. FrequencyLimit: 1014,
  967. UsersUpperLimit: 2e3,
  968. RoomsUpperLimit: 2001,
  969. ServerParam: 2002,
  970. LackOfToken: 2003,
  971. LoginFailed: 2004,
  972. VerifyServiceDown: 2005,
  973. CreateSessionFailed: 2006,
  974. RtcConnection: 2008,
  975. DoActionFailed: 2009,
  976. StateSyncFailed: 2010,
  977. BroadcastFailed: 2011,
  978. DataAbnormal: 2012,
  979. GetOnVehicle: 2015,
  980. RepeatLogin: 2017,
  981. RoomDoseNotExist: 2018,
  982. TicketExpire: 2019,
  983. ServerRateLimit: 2020,
  984. DoActionBlocked: 2333,
  985. ActionMaybeDelay: 2334,
  986. ActionResponseTimeout: 2999
  987. };
  988. var Logger$1 = /*#__PURE__*/function () {
  989. function Logger(e) {
  990. _classCallCheck(this, Logger);
  991. this.level = 3;
  992. this.module = e;
  993. }
  994. _createClass(Logger, [{
  995. key: "setLevel",
  996. value: function setLevel(e) {
  997. this.level = e;
  998. }
  999. }, {
  1000. key: "atleast",
  1001. value: function atleast(e) {
  1002. return e >= this.level && e >= this.level;
  1003. }
  1004. }, {
  1005. key: "print",
  1006. value: function print(e, t) {
  1007. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1008. r[_key - 2] = arguments[_key];
  1009. }
  1010. if (this.atleast(t)) {
  1011. var _console$n;
  1012. var n = e == "debug" ? "info" : e,
  1013. o = this.prefix(e);
  1014. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1015. }
  1016. if (e !== "debug" && e !== "info") {
  1017. var _n = r.map(function (o) {
  1018. if (o instanceof Object) try {
  1019. return JSON.stringify(o);
  1020. } catch (_unused) {
  1021. return o;
  1022. } else return o;
  1023. }).join(",");
  1024. reporter$1.report("log", {
  1025. message: _n,
  1026. level: e,
  1027. module: this.module
  1028. });
  1029. }
  1030. }
  1031. }, {
  1032. key: "debug",
  1033. value: function debug() {
  1034. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1035. e[_key2] = arguments[_key2];
  1036. }
  1037. return this.print.apply(this, ["debug", 1].concat(e));
  1038. }
  1039. }, {
  1040. key: "info",
  1041. value: function info() {
  1042. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1043. e[_key3] = arguments[_key3];
  1044. }
  1045. return this.print.apply(this, ["info", 2].concat(e));
  1046. }
  1047. }, {
  1048. key: "infoAndReportLog",
  1049. value: function infoAndReportLog(e) {
  1050. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1051. t[_key4 - 1] = arguments[_key4];
  1052. }
  1053. var r = e.reportOptions;
  1054. delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1055. }
  1056. }, {
  1057. key: "infoAndReportMeasurement",
  1058. value: function infoAndReportMeasurement(e) {
  1059. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1060. t[_key5 - 1] = arguments[_key5];
  1061. }
  1062. var n;
  1063. var r = e.reportOptions;
  1064. if (e.startTime) {
  1065. var o = Date.now();
  1066. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1067. }
  1068. if (e.error ? e.code = ((n = e.error) == null ? void 0 : n.code) || Codes.Internal : e.code = Codes.Success, reporter$1.report("measurement", e, r), t.length || (t = [e]), e.level === 4 || e.error) {
  1069. this.error.apply(this, _toConsumableArray(t));
  1070. return;
  1071. }
  1072. this.warn.apply(this, _toConsumableArray(t));
  1073. }
  1074. }, {
  1075. key: "warn",
  1076. value: function warn() {
  1077. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1078. e[_key6] = arguments[_key6];
  1079. }
  1080. return this.print.apply(this, ["warn", 3].concat(e));
  1081. }
  1082. }, {
  1083. key: "error",
  1084. value: function error() {
  1085. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1086. e[_key7] = arguments[_key7];
  1087. }
  1088. return this.print.apply(this, ["error", 4].concat(e));
  1089. }
  1090. }, {
  1091. key: "prefix",
  1092. value: function prefix(e) {
  1093. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1094. }
  1095. }], [{
  1096. key: "setLevel",
  1097. value: function setLevel(e) {
  1098. this.level = e;
  1099. }
  1100. }]);
  1101. return Logger;
  1102. }();
  1103. var logger = new Logger$1();
  1104. var AxiosCanceler = /*#__PURE__*/function () {
  1105. function AxiosCanceler() {
  1106. _classCallCheck(this, AxiosCanceler);
  1107. this.pendingMap = new Map();
  1108. }
  1109. _createClass(AxiosCanceler, [{
  1110. key: "addPending",
  1111. value: function addPending(e) {
  1112. var _this = this;
  1113. return new axios.CancelToken(function (t) {
  1114. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1115. });
  1116. }
  1117. }, {
  1118. key: "removeAllPending",
  1119. value: function removeAllPending() {
  1120. this.pendingMap.forEach(function (e) {
  1121. e && isFunction(e) && e();
  1122. }), this.pendingMap.clear();
  1123. }
  1124. }, {
  1125. key: "removePending",
  1126. value: function removePending(e) {
  1127. if (this.pendingMap.has(e)) {
  1128. var t = this.pendingMap.get(e);
  1129. t && t(e), this.pendingMap.delete(e);
  1130. }
  1131. }
  1132. }, {
  1133. key: "removeCancelToken",
  1134. value: function removeCancelToken(e) {
  1135. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1136. }
  1137. }, {
  1138. key: "reset",
  1139. value: function reset() {
  1140. this.pendingMap = new Map();
  1141. }
  1142. }]);
  1143. return AxiosCanceler;
  1144. }();
  1145. function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$b(); 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); }; }
  1146. function _isNativeReflectConstruct$b() { 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; } }
  1147. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1148. _inherits(Http1, _EventEmitter);
  1149. var _super = _createSuper$a(Http1);
  1150. function Http1() {
  1151. var _this;
  1152. _classCallCheck(this, Http1);
  1153. _this = _super.call(this);
  1154. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1155. return _this;
  1156. }
  1157. _createClass(Http1, [{
  1158. key: "requestConstant",
  1159. value: function requestConstant() {
  1160. return {
  1161. x_nounce: this.randomString(),
  1162. x_timestamp: new Date().getTime(),
  1163. x_os: "web"
  1164. };
  1165. }
  1166. }, {
  1167. key: "requestParams",
  1168. value: function requestParams(e) {
  1169. return oe({}, e.params);
  1170. }
  1171. }, {
  1172. key: "get",
  1173. value: function get(e) {
  1174. return this.request(le(oe({}, e), {
  1175. method: "GET"
  1176. }));
  1177. }
  1178. }, {
  1179. key: "post",
  1180. value: function post(e) {
  1181. return this.request(le(oe({}, e), {
  1182. method: "POST"
  1183. }));
  1184. }
  1185. }, {
  1186. key: "request",
  1187. value: function request(e) {
  1188. var _this2 = this;
  1189. var t = e.url,
  1190. _e$timeout = e.timeout,
  1191. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1192. n = e.method,
  1193. o = e.key,
  1194. a = e.beforeRequest,
  1195. s = e.responseType,
  1196. l = e.data;
  1197. var _e$retry = e.retry,
  1198. u = _e$retry === void 0 ? 0 : _e$retry;
  1199. var c = this.patchUrl(t),
  1200. h = this.canceler.addPending(t);
  1201. a && isFunction(a) && a(e);
  1202. var f = this.requestParams(e);
  1203. var d = {
  1204. url: c,
  1205. method: n,
  1206. timeout: r,
  1207. cancelToken: h,
  1208. responseType: s,
  1209. params: f
  1210. };
  1211. n === "POST" && (d = oe({
  1212. data: l
  1213. }, d));
  1214. var _ = Date.now(),
  1215. g = function g() {
  1216. return _this2.instatnce.request(d).then(function (m) {
  1217. return o && logger.infoAndReportMeasurement({
  1218. metric: "http",
  1219. startTime: _,
  1220. extra: t,
  1221. group: "http",
  1222. tag: o
  1223. }), _this2.canceler.removeCancelToken(t), m;
  1224. }).catch(function (m) {
  1225. var v = axios.isCancel(m);
  1226. return u > 0 && !v ? (u--, logger.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger.infoAndReportMeasurement({
  1227. metric: "http",
  1228. startTime: _,
  1229. error: m,
  1230. extra: {
  1231. url: t,
  1232. isCanceled: v
  1233. },
  1234. tag: o,
  1235. group: "http"
  1236. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1237. });
  1238. };
  1239. return g();
  1240. }
  1241. }, {
  1242. key: "patchUrl",
  1243. value: function patchUrl(e) {
  1244. return e;
  1245. }
  1246. }, {
  1247. key: "randomString",
  1248. value: function randomString() {
  1249. var e = "";
  1250. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1251. r = t.length;
  1252. for (var n = 0; n < 8; n++) {
  1253. e += t.charAt(Math.floor(Math.random() * r));
  1254. }
  1255. return e;
  1256. }
  1257. }]);
  1258. return Http1;
  1259. }(EventEmitter);
  1260. var http1 = new Http1();
  1261. var ModelManager = /*#__PURE__*/function () {
  1262. function ModelManager(e, t) {
  1263. _classCallCheck(this, ModelManager);
  1264. this.avatarModelList = [];
  1265. this.skinList = [];
  1266. this.applicationConfig = null;
  1267. this.config = null;
  1268. this.appId = e, this.releaseId = t;
  1269. }
  1270. _createClass(ModelManager, [{
  1271. key: "findSkinConfig",
  1272. value: function () {
  1273. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1274. var t, n;
  1275. return regenerator.wrap(function _callee$(_context) {
  1276. while (1) {
  1277. switch (_context.prev = _context.next) {
  1278. case 0:
  1279. t = null;
  1280. _context.next = 3;
  1281. return this.getSkinsList();
  1282. case 3:
  1283. t = (this.skinList = _context.sent).find(function (n) {
  1284. return n.id === e;
  1285. });
  1286. if (!t) {
  1287. _context.next = 6;
  1288. break;
  1289. }
  1290. return _context.abrupt("return", t);
  1291. case 6:
  1292. n = "skin is invalid: skinId: ".concat(e);
  1293. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1294. case 8:
  1295. case "end":
  1296. return _context.stop();
  1297. }
  1298. }
  1299. }, _callee, this);
  1300. }));
  1301. function findSkinConfig(_x) {
  1302. return _findSkinConfig.apply(this, arguments);
  1303. }
  1304. return findSkinConfig;
  1305. }()
  1306. }, {
  1307. key: "findRoute",
  1308. value: function () {
  1309. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1310. var n, o;
  1311. return regenerator.wrap(function _callee2$(_context2) {
  1312. while (1) {
  1313. switch (_context2.prev = _context2.next) {
  1314. case 0:
  1315. _context2.next = 2;
  1316. return this.findSkinConfig(e);
  1317. case 2:
  1318. n = _context2.sent.routeList.find(function (o) {
  1319. return o.pathName === t;
  1320. });
  1321. if (n) {
  1322. _context2.next = 6;
  1323. break;
  1324. }
  1325. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1326. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1327. case 6:
  1328. return _context2.abrupt("return", (logger.debug("find route success", n), n));
  1329. case 7:
  1330. case "end":
  1331. return _context2.stop();
  1332. }
  1333. }
  1334. }, _callee2, this);
  1335. }));
  1336. function findRoute(_x2, _x3) {
  1337. return _findRoute.apply(this, arguments);
  1338. }
  1339. return findRoute;
  1340. }()
  1341. }, {
  1342. key: "findAssetList",
  1343. value: function () {
  1344. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1345. var r, n;
  1346. return regenerator.wrap(function _callee3$(_context3) {
  1347. while (1) {
  1348. switch (_context3.prev = _context3.next) {
  1349. case 0:
  1350. _context3.next = 2;
  1351. return this.findSkinConfig(e);
  1352. case 2:
  1353. r = _context3.sent.assetList;
  1354. if (r) {
  1355. _context3.next = 6;
  1356. break;
  1357. }
  1358. n = "find path failed: skinId: ".concat(e);
  1359. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1360. case 6:
  1361. return _context3.abrupt("return", (logger.debug("find route success", r), r));
  1362. case 7:
  1363. case "end":
  1364. return _context3.stop();
  1365. }
  1366. }
  1367. }, _callee3, this);
  1368. }));
  1369. function findAssetList(_x4) {
  1370. return _findAssetList.apply(this, arguments);
  1371. }
  1372. return findAssetList;
  1373. }()
  1374. }, {
  1375. key: "findAsset",
  1376. value: function () {
  1377. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1378. var r,
  1379. n,
  1380. o,
  1381. a,
  1382. _args4 = arguments;
  1383. return regenerator.wrap(function _callee4$(_context4) {
  1384. while (1) {
  1385. switch (_context4.prev = _context4.next) {
  1386. case 0:
  1387. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1388. _context4.next = 3;
  1389. return this.findSkinConfig(e);
  1390. case 3:
  1391. n = _context4.sent;
  1392. if (!Array.isArray(t)) {
  1393. _context4.next = 6;
  1394. break;
  1395. }
  1396. return _context4.abrupt("return", t.map(function (a) {
  1397. return n.models.find(function (s) {
  1398. return s[r] === a;
  1399. });
  1400. }).filter(Boolean));
  1401. case 6:
  1402. o = n.models.find(function (a) {
  1403. return a[r] === t;
  1404. });
  1405. if (o) {
  1406. _context4.next = 10;
  1407. break;
  1408. }
  1409. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1410. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1411. case 10:
  1412. return _context4.abrupt("return", (logger.debug("find asset success", o), o));
  1413. case 11:
  1414. case "end":
  1415. return _context4.stop();
  1416. }
  1417. }
  1418. }, _callee4, this);
  1419. }));
  1420. function findAsset(_x5, _x6) {
  1421. return _findAsset.apply(this, arguments);
  1422. }
  1423. return findAsset;
  1424. }()
  1425. }, {
  1426. key: "findPoint",
  1427. value: function () {
  1428. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1429. var n, o;
  1430. return regenerator.wrap(function _callee5$(_context5) {
  1431. while (1) {
  1432. switch (_context5.prev = _context5.next) {
  1433. case 0:
  1434. _context5.next = 2;
  1435. return this.findSkinConfig(e);
  1436. case 2:
  1437. n = _context5.sent.pointList.find(function (o) {
  1438. return o.id === t;
  1439. });
  1440. if (n) {
  1441. _context5.next = 6;
  1442. break;
  1443. }
  1444. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1445. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1446. case 6:
  1447. return _context5.abrupt("return", (logger.debug("find point success", n), n));
  1448. case 7:
  1449. case "end":
  1450. return _context5.stop();
  1451. }
  1452. }
  1453. }, _callee5, this);
  1454. }));
  1455. function findPoint(_x7, _x8) {
  1456. return _findPoint.apply(this, arguments);
  1457. }
  1458. return findPoint;
  1459. }()
  1460. }, {
  1461. key: "requestConfig",
  1462. value: function () {
  1463. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1464. var t, r, _ref, n, o;
  1465. return regenerator.wrap(function _callee6$(_context6) {
  1466. while (1) {
  1467. switch (_context6.prev = _context6.next) {
  1468. case 0:
  1469. if (!this.config) {
  1470. _context6.next = 2;
  1471. break;
  1472. }
  1473. return _context6.abrupt("return", this.config);
  1474. case 2:
  1475. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1476. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1477. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1478. t = './assets/config.json';
  1479. _context6.prev = 3;
  1480. _context6.next = 6;
  1481. return http1.get({
  1482. url: "".concat(t, "?t=").concat(Date.now()),
  1483. key: "config",
  1484. timeout: 6e3,
  1485. retry: 2
  1486. });
  1487. case 6:
  1488. r = _context6.sent;
  1489. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  1490. if (n) {
  1491. _context6.next = 10;
  1492. break;
  1493. }
  1494. throw new Error("config data parse error" + r.data);
  1495. case 10:
  1496. return _context6.abrupt("return", (this.config = {
  1497. config: n,
  1498. preload: o
  1499. }, logger.debug("get config success", this.config), this.config));
  1500. case 13:
  1501. _context6.prev = 13;
  1502. _context6.t0 = _context6["catch"](3);
  1503. return _context6.abrupt("return", Promise.reject(_context6.t0));
  1504. case 16:
  1505. case "end":
  1506. return _context6.stop();
  1507. }
  1508. }
  1509. }, _callee6, this, [[3, 13]]);
  1510. }));
  1511. function requestConfig() {
  1512. return _requestConfig.apply(this, arguments);
  1513. }
  1514. return requestConfig;
  1515. }()
  1516. }, {
  1517. key: "getApplicationConfig",
  1518. value: function () {
  1519. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  1520. var e;
  1521. return regenerator.wrap(function _callee7$(_context7) {
  1522. while (1) {
  1523. switch (_context7.prev = _context7.next) {
  1524. case 0:
  1525. if (!this.applicationConfig) {
  1526. _context7.next = 2;
  1527. break;
  1528. }
  1529. return _context7.abrupt("return", this.applicationConfig);
  1530. case 2:
  1531. _context7.prev = 2;
  1532. _context7.next = 5;
  1533. return this.requestConfig();
  1534. case 5:
  1535. e = _context7.sent;
  1536. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  1537. case 9:
  1538. _context7.prev = 9;
  1539. _context7.t0 = _context7["catch"](2);
  1540. return _context7.abrupt("return", Promise.reject(_context7.t0));
  1541. case 12:
  1542. case "end":
  1543. return _context7.stop();
  1544. }
  1545. }
  1546. }, _callee7, this, [[2, 9]]);
  1547. }));
  1548. function getApplicationConfig() {
  1549. return _getApplicationConfig.apply(this, arguments);
  1550. }
  1551. return getApplicationConfig;
  1552. }()
  1553. }, {
  1554. key: "getAvatarModelList",
  1555. value: function () {
  1556. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  1557. var _yield$this$getApplic, e;
  1558. return regenerator.wrap(function _callee8$(_context8) {
  1559. while (1) {
  1560. switch (_context8.prev = _context8.next) {
  1561. case 0:
  1562. if (!this.avatarModelList.length) {
  1563. _context8.next = 2;
  1564. break;
  1565. }
  1566. return _context8.abrupt("return", this.avatarModelList);
  1567. case 2:
  1568. _context8.prev = 2;
  1569. _context8.next = 5;
  1570. return this.getApplicationConfig();
  1571. case 5:
  1572. _yield$this$getApplic = _context8.sent;
  1573. e = _yield$this$getApplic.avatars;
  1574. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  1575. return {
  1576. name: t.name,
  1577. id: t.id,
  1578. modelUrl: t.url,
  1579. gender: t.gender,
  1580. components: t.components
  1581. };
  1582. }), this.avatarModelList));
  1583. case 10:
  1584. _context8.prev = 10;
  1585. _context8.t0 = _context8["catch"](2);
  1586. return _context8.abrupt("return", (logger.error(_context8.t0), []));
  1587. case 13:
  1588. case "end":
  1589. return _context8.stop();
  1590. }
  1591. }
  1592. }, _callee8, this, [[2, 10]]);
  1593. }));
  1594. function getAvatarModelList() {
  1595. return _getAvatarModelList.apply(this, arguments);
  1596. }
  1597. return getAvatarModelList;
  1598. }()
  1599. }, {
  1600. key: "getSkinsList",
  1601. value: function () {
  1602. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  1603. var _yield$this$getApplic2, e;
  1604. return regenerator.wrap(function _callee9$(_context9) {
  1605. while (1) {
  1606. switch (_context9.prev = _context9.next) {
  1607. case 0:
  1608. if (!this.skinList.length) {
  1609. _context9.next = 2;
  1610. break;
  1611. }
  1612. return _context9.abrupt("return", this.skinList);
  1613. case 2:
  1614. _context9.prev = 2;
  1615. _context9.next = 5;
  1616. return this.getApplicationConfig();
  1617. case 5:
  1618. _yield$this$getApplic2 = _context9.sent;
  1619. e = _yield$this$getApplic2.skins;
  1620. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  1621. var r;
  1622. return {
  1623. name: t.name,
  1624. dataVersion: t.id + t.versionId,
  1625. id: t.id,
  1626. fov: parseInt(t.fov || 90),
  1627. models: t.assetList.map(function (n) {
  1628. var o = n.assetId,
  1629. a = n.url,
  1630. s = n.thumbnailUrl,
  1631. l = n.typeName,
  1632. u = n.className;
  1633. return {
  1634. id: o,
  1635. modelUrl: a,
  1636. name: n.name,
  1637. thumbnailUrl: s,
  1638. typeName: l,
  1639. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  1640. };
  1641. }),
  1642. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  1643. var o = n.areaName,
  1644. a = n.attitude,
  1645. s = n.id,
  1646. l = n.pathName,
  1647. u = n.step,
  1648. c = n.birthPointList;
  1649. return {
  1650. areaName: o,
  1651. attitude: a,
  1652. id: s,
  1653. pathName: l,
  1654. step: u,
  1655. birthPointList: c.map(function (h) {
  1656. return {
  1657. camera: h.camera && {
  1658. position: objectParseFloat(h.camera.position),
  1659. angle: objectParseFloat(h.camera.rotation)
  1660. },
  1661. player: h.player && {
  1662. position: objectParseFloat(h.player.position),
  1663. angle: objectParseFloat(h.player.rotation)
  1664. }
  1665. };
  1666. })
  1667. };
  1668. }),
  1669. pointList: t.pointList.map(function (n) {
  1670. return le(oe({}, n), {
  1671. position: objectParseFloat(n.position),
  1672. rotation: objectParseFloat(n.rotation)
  1673. });
  1674. }),
  1675. versionId: t.versionId,
  1676. isEnable: t.isEnable,
  1677. assetList: t.assetList,
  1678. visibleRules: t.visibleRules,
  1679. animationList: t.animationList
  1680. };
  1681. }), this.skinList));
  1682. case 10:
  1683. _context9.prev = 10;
  1684. _context9.t0 = _context9["catch"](2);
  1685. return _context9.abrupt("return", (logger.error(_context9.t0), []));
  1686. case 13:
  1687. case "end":
  1688. return _context9.stop();
  1689. }
  1690. }
  1691. }, _callee9, this, [[2, 10]]);
  1692. }));
  1693. function getSkinsList() {
  1694. return _getSkinsList.apply(this, arguments);
  1695. }
  1696. return getSkinsList;
  1697. }()
  1698. }, {
  1699. key: "getBreathPointTextrueList",
  1700. value: function () {
  1701. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  1702. return regenerator.wrap(function _callee10$(_context10) {
  1703. while (1) {
  1704. switch (_context10.prev = _context10.next) {
  1705. case 0:
  1706. return _context10.abrupt("return", [{
  1707. url: TEXTURE_URL
  1708. }]);
  1709. case 1:
  1710. case "end":
  1711. return _context10.stop();
  1712. }
  1713. }
  1714. }, _callee10);
  1715. }));
  1716. function getBreathPointTextrueList() {
  1717. return _getBreathPointTextrueList.apply(this, arguments);
  1718. }
  1719. return getBreathPointTextrueList;
  1720. }()
  1721. }], [{
  1722. key: "getInstance",
  1723. value: function getInstance(e, t) {
  1724. //getInstance(e, t) {
  1725. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  1726. }
  1727. }, {
  1728. key: "findModels",
  1729. value: function findModels(e, t, r) {
  1730. //findModels(e, t, r) {
  1731. return e.filter(function (o) {
  1732. return o.typeName === t && o.className === r;
  1733. });
  1734. }
  1735. }, {
  1736. key: "findModel",
  1737. value: function findModel(e, t, r) {
  1738. //findModel(e, t, r) {
  1739. var n = e.filter(function (o) {
  1740. return o.typeName === t && o.className === r;
  1741. })[0];
  1742. return n || null;
  1743. }
  1744. }]);
  1745. return ModelManager;
  1746. }();
  1747. // export { modelManager };
  1748. var JoyStick = /*#__PURE__*/function () {
  1749. function JoyStick(e) {
  1750. _classCallCheck(this, JoyStick);
  1751. this._zone = document.createElement("div");
  1752. this._joystick = null;
  1753. this._room = e;
  1754. }
  1755. _createClass(JoyStick, [{
  1756. key: "init",
  1757. value: function init(e) {
  1758. var _this = this;
  1759. var _e$interval = e.interval,
  1760. t = _e$interval === void 0 ? 33 : _e$interval,
  1761. _e$triggerDistance = e.triggerDistance,
  1762. r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
  1763. _e$style = e.style,
  1764. n = _e$style === void 0 ? {
  1765. left: 0,
  1766. bottom: 0
  1767. } : _e$style,
  1768. o = function o(u, c) {
  1769. _this._room.actionsHandler.joystick({
  1770. degree: Math.floor(u),
  1771. level: Math.floor(c / 5)
  1772. });
  1773. },
  1774. a = this._zone;
  1775. document.body.appendChild(a), a.style.position = "absolute", a.style.width = "200px", a.style.height = "200px", a.style.left = String(n.left), a.style.bottom = String(n.bottom), a.style.zIndex = "999", a.style.userSelect = "none", a.style.webkitUserSelect = "none", this._joystick = nipplejs.create({
  1776. zone: a,
  1777. mode: "static",
  1778. position: {
  1779. left: "50%",
  1780. top: "50%"
  1781. },
  1782. color: "white"
  1783. });
  1784. var s, l;
  1785. return this._joystick.on("move", function (u, c) {
  1786. s = c;
  1787. }), this._joystick.on("start", function () {
  1788. l = window.setInterval(function () {
  1789. s && s.distance > r && o && o(s.angle.degree, s.distance);
  1790. }, t);
  1791. }), this._joystick.on("end", function () {
  1792. l && window.clearInterval(l), l = void 0;
  1793. }), this._joystick;
  1794. }
  1795. }, {
  1796. key: "show",
  1797. value: function show() {
  1798. if (!this._joystick) throw new Error("joystick is not created");
  1799. this._zone.style.display = "block";
  1800. }
  1801. }, {
  1802. key: "hide",
  1803. value: function hide() {
  1804. if (!this._joystick) throw new Error("joystick is not created");
  1805. this._zone.style.display = "none";
  1806. }
  1807. }]);
  1808. return JoyStick;
  1809. }();
  1810. var CoreBroadcastType = {
  1811. PlayAnimation: 'PlayAnimation'
  1812. };
  1813. var AvatarGroup = {
  1814. Npc: 'npc',
  1815. User: 'user'
  1816. };
  1817. var MessageHandleType$1 = {
  1818. MHT_Undefined: 0,
  1819. MHT_RoomMulticast: 1,
  1820. MHT_FollowListMulticast: 2,
  1821. MHT_CustomTargetSync: 3
  1822. };
  1823. var Broadcast$1 = /*#__PURE__*/function () {
  1824. function Broadcast(e, t) {
  1825. _classCallCheck(this, Broadcast);
  1826. this.room = e;
  1827. this.handlers = [];
  1828. this.init(t);
  1829. }
  1830. _createClass(Broadcast, [{
  1831. key: "init",
  1832. value: function init(t) {
  1833. this.handlers.push(t);
  1834. }
  1835. }, {
  1836. key: "handleBroadcast",
  1837. value: function () {
  1838. var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1839. return regenerator.wrap(function _callee$(_context) {
  1840. while (1) {
  1841. switch (_context.prev = _context.next) {
  1842. case 0:
  1843. _context.prev = 1;
  1844. JSON.parse(e.broadcastAction.data);
  1845. _context.next = 9;
  1846. break;
  1847. case 5:
  1848. _context.prev = 5;
  1849. _context.t0 = _context["catch"](1);
  1850. logger.error(_context.t0);
  1851. return _context.abrupt("return");
  1852. case 9:
  1853. case "end":
  1854. return _context.stop();
  1855. }
  1856. }
  1857. }, _callee, null, [[1, 5]]);
  1858. }));
  1859. function handleBroadcast(_x) {
  1860. return _handleBroadcast.apply(this, arguments);
  1861. }
  1862. return handleBroadcast;
  1863. }()
  1864. }, {
  1865. key: "broadcast",
  1866. value: function broadcast(e) {
  1867. var t = e.data,
  1868. _e$msgType = e.msgType,
  1869. r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
  1870. n = e.targetUserIds;
  1871. return this.room.actionsHandler.broadcast({
  1872. data: t,
  1873. msgType: r,
  1874. targetUserIds: n
  1875. });
  1876. }
  1877. }]);
  1878. return Broadcast;
  1879. }();
  1880. function _isNativeFunction(fn) {
  1881. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  1882. }
  1883. function _isNativeReflectConstruct$a() {
  1884. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  1885. if (Reflect.construct.sham) return false;
  1886. if (typeof Proxy === "function") return true;
  1887. try {
  1888. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  1889. return true;
  1890. } catch (e) {
  1891. return false;
  1892. }
  1893. }
  1894. function _construct(Parent, args, Class) {
  1895. if (_isNativeReflectConstruct$a()) {
  1896. _construct = Reflect.construct;
  1897. } else {
  1898. _construct = function _construct(Parent, args, Class) {
  1899. var a = [null];
  1900. a.push.apply(a, args);
  1901. var Constructor = Function.bind.apply(Parent, a);
  1902. var instance = new Constructor();
  1903. if (Class) _setPrototypeOf(instance, Class.prototype);
  1904. return instance;
  1905. };
  1906. }
  1907. return _construct.apply(null, arguments);
  1908. }
  1909. function _wrapNativeSuper(Class) {
  1910. var _cache = typeof Map === "function" ? new Map() : undefined;
  1911. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  1912. if (Class === null || !_isNativeFunction(Class)) return Class;
  1913. if (typeof Class !== "function") {
  1914. throw new TypeError("Super expression must either be null or a function");
  1915. }
  1916. if (typeof _cache !== "undefined") {
  1917. if (_cache.has(Class)) return _cache.get(Class);
  1918. _cache.set(Class, Wrapper);
  1919. }
  1920. function Wrapper() {
  1921. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  1922. }
  1923. Wrapper.prototype = Object.create(Class.prototype, {
  1924. constructor: {
  1925. value: Wrapper,
  1926. enumerable: false,
  1927. writable: true,
  1928. configurable: true
  1929. }
  1930. });
  1931. return _setPrototypeOf(Wrapper, Class);
  1932. };
  1933. return _wrapNativeSuper(Class);
  1934. }
  1935. function _createSuper$9(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$9(); 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); }; }
  1936. function _isNativeReflectConstruct$9() { 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; } }
  1937. var XverseError = /*#__PURE__*/function (_Error) {
  1938. _inherits(XverseError, _Error);
  1939. var _super = _createSuper$9(XverseError);
  1940. function XverseError(e, t) {
  1941. var _this;
  1942. _classCallCheck(this, XverseError);
  1943. _this = _super.call(this, t);
  1944. _this.code = e;
  1945. return _this;
  1946. }
  1947. _createClass(XverseError, [{
  1948. key: "toJSON",
  1949. value: function toJSON() {
  1950. return {
  1951. code: this.code,
  1952. message: this.message
  1953. };
  1954. }
  1955. }, {
  1956. key: "toString",
  1957. value: function toString() {
  1958. if (Object(this) !== this) throw new TypeError();
  1959. var t = this.name;
  1960. t = t === void 0 ? "Error" : String(t);
  1961. var r = this.message;
  1962. r = r === void 0 ? "" : String(r);
  1963. var n = this.code;
  1964. return r = n === void 0 ? r : n + "," + r, t === "" ? r : r === "" ? t : t + ": " + r;
  1965. }
  1966. }]);
  1967. return XverseError;
  1968. }( /*#__PURE__*/_wrapNativeSuper(Error));
  1969. function _createSuper$8(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$8(); 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); }; }
  1970. function _isNativeReflectConstruct$8() { 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; } }
  1971. var TimeoutError = /*#__PURE__*/function (_XverseError) {
  1972. _inherits(TimeoutError, _XverseError);
  1973. var _super = _createSuper$8(TimeoutError);
  1974. function TimeoutError(e) {
  1975. _classCallCheck(this, TimeoutError);
  1976. return _super.call(this, 1003, e || "\u8D85\u65F6");
  1977. }
  1978. return _createClass(TimeoutError);
  1979. }(XverseError);
  1980. function _createSuper$7(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$7(); 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); }; }
  1981. function _isNativeReflectConstruct$7() { 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; } }
  1982. var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
  1983. _inherits(XverseAvatarManager, _EventEmitter);
  1984. var _super = _createSuper$7(XverseAvatarManager);
  1985. function XverseAvatarManager(e) {
  1986. var _this;
  1987. _classCallCheck(this, XverseAvatarManager);
  1988. _this = _super.call(this);
  1989. _this.xAvatarManager = null;
  1990. _this.avatars = new Map();
  1991. _this.syncAvatarsLength = 0;
  1992. _this._room = e;
  1993. _this._usersStatistics();
  1994. _this.broadcast = _this.setupBroadcast();
  1995. e.on("skinChanged", function () {
  1996. _this.avatars.forEach(function (t) {
  1997. t.disconnected && _this.removeAvatar(t.userId, !0);
  1998. });
  1999. });
  2000. return _this;
  2001. }
  2002. _createClass(XverseAvatarManager, [{
  2003. key: "setupBroadcast",
  2004. value: function setupBroadcast() {
  2005. var _this2 = this;
  2006. return new Broadcast$1(this._room, /*#__PURE__*/function () {
  2007. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2008. var t, r, n, o, a, _r$loop, s, l;
  2009. return regenerator.wrap(function _callee$(_context) {
  2010. while (1) {
  2011. switch (_context.prev = _context.next) {
  2012. case 0:
  2013. t = e.broadcastType, r = e.info;
  2014. if (!(t !== CoreBroadcastType.PlayAnimation)) {
  2015. _context.next = 3;
  2016. break;
  2017. }
  2018. return _context.abrupt("return");
  2019. case 3:
  2020. n = r.userId, o = r.animation, a = r.extra, _r$loop = r.loop, s = _r$loop === void 0 ? !1 : _r$loop, l = _this2.avatars.get(n);
  2021. _context.t0 = l && !l.isSelf;
  2022. if (!_context.t0) {
  2023. _context.next = 10;
  2024. break;
  2025. }
  2026. l.emit("animationStart", {
  2027. animationName: o,
  2028. extra: decodeURIComponent(a)
  2029. });
  2030. _context.next = 9;
  2031. return l == null ? void 0 : l._playAnimation(o, s);
  2032. case 9:
  2033. l.emit("animationEnd", {
  2034. animationName: o,
  2035. extra: decodeURIComponent(a)
  2036. });
  2037. case 10:
  2038. case "end":
  2039. return _context.stop();
  2040. }
  2041. }
  2042. }, _callee);
  2043. }));
  2044. return function (_x) {
  2045. return _ref.apply(this, arguments);
  2046. };
  2047. }());
  2048. }
  2049. }, {
  2050. key: "hideAll",
  2051. value: function hideAll() {
  2052. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2053. this.xAvatarManager.hideAll(e);
  2054. }
  2055. }, {
  2056. key: "showAll",
  2057. value: function showAll() {
  2058. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2059. this.xAvatarManager.showAll(e);
  2060. }
  2061. }, {
  2062. key: "init",
  2063. value: function () {
  2064. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2065. var e, t;
  2066. return regenerator.wrap(function _callee2$(_context2) {
  2067. while (1) {
  2068. switch (_context2.prev = _context2.next) {
  2069. case 0:
  2070. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  2071. _context2.prev = 1;
  2072. _context2.next = 4;
  2073. return this._room.modelManager.getApplicationConfig();
  2074. case 4:
  2075. e = _context2.sent;
  2076. t = e.avatars;
  2077. if (!t) {
  2078. _context2.next = 10;
  2079. break;
  2080. }
  2081. _context2.next = 9;
  2082. return avatarLoader.parse(this._room.sceneManager, t);
  2083. case 9:
  2084. return _context2.abrupt("return");
  2085. case 10:
  2086. return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
  2087. case 13:
  2088. _context2.prev = 13;
  2089. _context2.t0 = _context2["catch"](1);
  2090. return _context2.abrupt("return", (logger.error(_context2.t0), Promise.reject("avatar mananger init error!")));
  2091. case 16:
  2092. case "end":
  2093. return _context2.stop();
  2094. }
  2095. }
  2096. }, _callee2, this, [[1, 13]]);
  2097. }));
  2098. function init() {
  2099. return _init.apply(this, arguments);
  2100. }
  2101. return init;
  2102. }()
  2103. }, {
  2104. key: "handleAvatar",
  2105. value: function () {
  2106. var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  2107. var _this3 = this;
  2108. var r, t, n, o, _n, a;
  2109. return regenerator.wrap(function _callee3$(_context3) {
  2110. while (1) {
  2111. switch (_context3.prev = _context3.next) {
  2112. case 0:
  2113. if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
  2114. _context3.next = 2;
  2115. break;
  2116. }
  2117. return _context3.abrupt("return");
  2118. case 2:
  2119. t = e.newUserStates;
  2120. if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
  2121. n = t.filter(function (a) {
  2122. return a.userId === _this3._room.userId;
  2123. }), o = t.filter(function (a) {
  2124. return a.userId !== _this3._room.userId;
  2125. }).slice(0, 2);
  2126. t = n.concat(o);
  2127. }
  2128. if (e.getStateType === GetStateTypes.Event) {
  2129. this.syncAvatarsLength = (t || []).length;
  2130. _n = this._room.avatars.filter(function (s) {
  2131. return s.group == AvatarGroup.User;
  2132. });
  2133. _n.filter(function (s) {
  2134. return !(t != null && t.find(function (l) {
  2135. return l.userId == s.userId;
  2136. }));
  2137. }).forEach(function (s) {
  2138. _this3.removeAvatar(s.userId);
  2139. });
  2140. a = t.filter(function (s) {
  2141. return !_n.find(function (l) {
  2142. return l.userId == s.userId;
  2143. });
  2144. });
  2145. this._handleAvatar(a);
  2146. }
  2147. this._handleAvatar(t);
  2148. case 6:
  2149. case "end":
  2150. return _context3.stop();
  2151. }
  2152. }
  2153. }, _callee3, this);
  2154. }));
  2155. function handleAvatar(_x2) {
  2156. return _handleAvatar2.apply(this, arguments);
  2157. }
  2158. return handleAvatar;
  2159. }()
  2160. }, {
  2161. key: "_handleAvatar",
  2162. value: function () {
  2163. var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2164. var _this4 = this;
  2165. return regenerator.wrap(function _callee4$(_context4) {
  2166. while (1) {
  2167. switch (_context4.prev = _context4.next) {
  2168. case 0:
  2169. e == null || e.forEach(function (t) {
  2170. var n, o, a, s, l, u, c, h, f;
  2171. var r = _this4._room.userId === t.userId;
  2172. if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
  2173. var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
  2174. _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
  2175. g = _.code,
  2176. m = _.msg;
  2177. d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
  2178. code: g,
  2179. msg: m
  2180. });
  2181. }
  2182. if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
  2183. var _d = _this4.avatars.get(t.userId);
  2184. if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
  2185. if (_d.disconnected && _d.setConnectionStatus(!1), (u = t.event) != null && u.id && _this4._room.actionsHandler.confirmEvent(t.event.id), t.playerState.nickName && (_d == null || _d._setNickname(t.playerState.nickName)), t.playerState.avatarComponents && !_d.isSelf && _d.xAvatar) {
  2186. var _2 = safeParseComponents(t.playerState.avatarComponents);
  2187. _d._changeComponents({
  2188. avatarComponents: _2,
  2189. mode: ChangeComponentsMode.Preview
  2190. });
  2191. }
  2192. } else {
  2193. var _t$playerState$player = t.playerState.player,
  2194. _3 = _t$playerState$player.position,
  2195. _g = _t$playerState$player.angle,
  2196. _m = t.playerState.avatarId,
  2197. v = t.playerState.prioritySync,
  2198. y = safelyJsonParse(t.playerState.extra);
  2199. if (!_m) return;
  2200. var b = safeParseComponents(t.playerState.avatarComponents),
  2201. T = safeDecodeURIComponent(t.playerState.nickName),
  2202. C = _this4.calculatePriority(t.userId, y);
  2203. _this4.addAvatar({
  2204. userId: t.userId,
  2205. isHost: t.playerState.isHost,
  2206. nickname: T,
  2207. avatarPosition: _3,
  2208. avatarRotation: _g,
  2209. avatarScale: t.playerState.avatarSize,
  2210. avatarId: _m,
  2211. avatarComponents: t.playerState.person === Person.First ? [] : b,
  2212. priority: C,
  2213. group: AvatarGroup.User,
  2214. prioritySync: v,
  2215. extraInfo: y
  2216. }).then(function () {
  2217. var A;
  2218. (A = t.event) != null && A.id && _this4._room.actionsHandler.confirmEvent(t.event.id), _this4.updateAvatarPositionAndRotation(t), r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarLoaded"), logger.info("userAvatarLoaded"));
  2219. }).catch(function (A) {
  2220. r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
  2221. error: A
  2222. }), logger.error("userAvatarFailed", A));
  2223. });
  2224. }
  2225. }
  2226. if (t.event && SyncEventType.Disappear === t.event.type && ((c = t == null ? void 0 : t.event) != null && c.id && _this4._room.actionsHandler.confirmEvent(t.event.id), _this4.removeAvatar(t.userId)), t.event && [SyncEventType.Move, SyncEventType.ChangeRenderInfo].includes(t.event.type) || !t.event) {
  2227. (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
  2228. var _d2 = _this4.avatars.get(t.userId);
  2229. _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
  2230. }
  2231. if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
  2232. var _d3 = _this4.avatars.get(t.userId);
  2233. _d3.statusSyncQueue.append({
  2234. type: QueueType.Rotate,
  2235. action: function action() {
  2236. return _d3.statusSync(t);
  2237. }
  2238. });
  2239. }
  2240. });
  2241. case 1:
  2242. case "end":
  2243. return _context4.stop();
  2244. }
  2245. }
  2246. }, _callee4);
  2247. }));
  2248. function _handleAvatar(_x3) {
  2249. return _handleAvatar3.apply(this, arguments);
  2250. }
  2251. return _handleAvatar;
  2252. }()
  2253. }, {
  2254. key: "calculatePriority",
  2255. value: function calculatePriority(e, t) {
  2256. var n;
  2257. return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
  2258. }
  2259. }, {
  2260. key: "updateAvatarPositionAndRotation",
  2261. value: function updateAvatarPositionAndRotation(e) {
  2262. var t, r;
  2263. if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
  2264. var _e$playerState$player = e.playerState.player,
  2265. n = _e$playerState$player.position,
  2266. o = _e$playerState$player.angle;
  2267. var a = this.avatars.get(e.userId);
  2268. if (!a) return;
  2269. if (n = positionPrecisionProtect(n), o = rotationPrecisionProtect(o), a.isSelf && !this._room.networkController.rtcp.workers.inPanoMode && (a.setPosition(n), a.setRotation(o)), e.event && (((r = e.event) == null ? void 0 : r.points.length) || 0) > 1 && !a.isSelf && a.statusSyncQueue.append({
  2270. type: QueueType.Move,
  2271. action: function action() {
  2272. return a.statusSync(e);
  2273. }
  2274. }), e.renderInfo && a.isSelf) {
  2275. var _e$renderInfo = e.renderInfo,
  2276. s = _e$renderInfo.isMoving,
  2277. l = _e$renderInfo.isRotating;
  2278. this._updateAvatarMovingStatus({
  2279. id: e.userId,
  2280. isMoving: !!s,
  2281. isRotating: !!l
  2282. });
  2283. }
  2284. }
  2285. }
  2286. }, {
  2287. key: "addAvatar",
  2288. value: function () {
  2289. var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  2290. var t, r, n, o, a, s, _e$avatarComponents, l, u, _e$group, c, _e$avatarScale, h, f, d, _, g, v, y, b, T, C;
  2291. return regenerator.wrap(function _callee5$(_context5) {
  2292. while (1) {
  2293. switch (_context5.prev = _context5.next) {
  2294. case 0:
  2295. t = e.userId, r = e.isHost, n = e.avatarPosition, o = e.avatarId, a = e.avatarRotation, s = e.nickname, _e$avatarComponents = e.avatarComponents, l = _e$avatarComponents === void 0 ? [] : _e$avatarComponents, u = e.priority, _e$group = e.group, c = _e$group === void 0 ? AvatarGroup.Npc : _e$group, _e$avatarScale = e.avatarScale, h = _e$avatarScale === void 0 ? DEFAULT_AVATAR_SCALE : _e$avatarScale, f = e.extraInfo, d = e.prioritySync, _ = t === this._room.userId;
  2296. g = this.avatars.get(t);
  2297. if (!g) {
  2298. _context5.next = 4;
  2299. break;
  2300. }
  2301. return _context5.abrupt("return", Promise.resolve(g));
  2302. case 4:
  2303. if (!(g = new xe.subAvatar({
  2304. userId: t,
  2305. isHost: r,
  2306. isSelf: _,
  2307. room: this._room,
  2308. avatarComponents: l,
  2309. avatarId: o,
  2310. nickname: s,
  2311. group: c
  2312. }), this.avatars.set(t, g), !g.withModel)) {
  2313. _context5.next = 6;
  2314. break;
  2315. }
  2316. return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  2317. avatars: this._room.avatars
  2318. }), g));
  2319. case 6:
  2320. _context5.next = 8;
  2321. return this._room.modelManager.getAvatarModelList();
  2322. case 8:
  2323. v = _context5.sent.find(function (b) {
  2324. return b.id === o;
  2325. });
  2326. y = Date.now();
  2327. if (v) {
  2328. _context5.next = 12;
  2329. break;
  2330. }
  2331. return _context5.abrupt("return", (this._room.emit("avatarChanged", {
  2332. avatars: this._room.avatars
  2333. }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
  2334. case 12:
  2335. _context5.prev = 12;
  2336. _context5.next = 15;
  2337. return avatarComponentsModify(v, l);
  2338. case 15:
  2339. b = _context5.sent;
  2340. b = b.filter(function (A) {
  2341. return A.type != "pendant";
  2342. });
  2343. _context5.next = 19;
  2344. return avatarComponentsParser(v, b);
  2345. case 19:
  2346. T = _context5.sent;
  2347. _context5.next = 22;
  2348. return this.xAvatarManager.loadAvatar({
  2349. id: t,
  2350. avatarType: o,
  2351. priority: u,
  2352. avatarManager: this.xAvatarManager,
  2353. assets: T,
  2354. status: {
  2355. avatarPosition: n,
  2356. avatarRotation: a,
  2357. avatarScale: h
  2358. }
  2359. })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
  2360. case 22:
  2361. C = _context5.sent;
  2362. return _context5.abrupt("return", (C.setPickBoxScale(t === this._room.userId ? 0 : 1), g.xAvatar = C, g.setScale(h), g.extraInfo = f, g.priority = u, g.isLoading = !1, g.prioritySync = !!d, g._playAnimation("Idle", !0, !0), g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  2363. avatars: this._room.avatars
  2364. }), s && g._setNickname(s), t === this._room.userId && (logger.infoAndReportMeasurement({
  2365. metric: "avatarLoadDuration",
  2366. startTime: y,
  2367. group: "costs"
  2368. }), logger.infoAndReportMeasurement({
  2369. metric: "avatarLoadAt",
  2370. startTime: this._room._startTime,
  2371. group: "costs"
  2372. })), g));
  2373. case 26:
  2374. _context5.prev = 26;
  2375. _context5.t0 = _context5["catch"](12);
  2376. return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
  2377. avatars: this._room.avatars
  2378. }), logger.error(_context5.t0), Promise.reject(_context5.t0)));
  2379. case 29:
  2380. case "end":
  2381. return _context5.stop();
  2382. }
  2383. }
  2384. }, _callee5, this, [[12, 26]]);
  2385. }));
  2386. function addAvatar(_x4) {
  2387. return _addAvatar.apply(this, arguments);
  2388. }
  2389. return addAvatar;
  2390. }()
  2391. }, {
  2392. key: "removeAvatar",
  2393. value: function removeAvatar(e) {
  2394. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  2395. var r = this.avatars.get(e);
  2396. if (!!r) {
  2397. if (r.removeWhenDisconnected || t) {
  2398. r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
  2399. avatars: this._room.avatars
  2400. });
  2401. return;
  2402. }
  2403. r.setConnectionStatus(!0);
  2404. }
  2405. }
  2406. }, {
  2407. key: "clearOtherUsers",
  2408. value: function clearOtherUsers() {
  2409. var _this5 = this;
  2410. this.avatars.forEach(function (e) {
  2411. !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
  2412. });
  2413. }
  2414. }, {
  2415. key: "_updateAvatarMovingStatus",
  2416. value: function () {
  2417. var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  2418. var t, r, n, o, a, _a;
  2419. return regenerator.wrap(function _callee6$(_context6) {
  2420. while (1) {
  2421. switch (_context6.prev = _context6.next) {
  2422. case 0:
  2423. t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
  2424. if (!!o) {
  2425. if (o.isRotating !== n) {
  2426. o.isRotating = n;
  2427. a = "Idle";
  2428. n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger.infoAndReportMeasurement({
  2429. startTime: Date.now(),
  2430. value: 0,
  2431. metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
  2432. extra: {
  2433. motionType: o.motionType,
  2434. moveToExtra: this._room.moveToExtra
  2435. }
  2436. });
  2437. }
  2438. if (o.isMoving !== r) {
  2439. o.isMoving = r;
  2440. _a = "Idle";
  2441. r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
  2442. target: o,
  2443. extra: this._room.moveToExtra
  2444. })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
  2445. target: o,
  2446. extra: this._room.moveToExtra
  2447. })), o._playAnimation(_a, !0, !0), logger.infoAndReportMeasurement({
  2448. startTime: Date.now(),
  2449. value: 0,
  2450. metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
  2451. extra: {
  2452. motionType: o.motionType,
  2453. moveToExtra: this._room.moveToExtra
  2454. }
  2455. });
  2456. }
  2457. }
  2458. case 2:
  2459. case "end":
  2460. return _context6.stop();
  2461. }
  2462. }
  2463. }, _callee6, this);
  2464. }));
  2465. function _updateAvatarMovingStatus(_x5) {
  2466. return _updateAvatarMovingStatus2.apply(this, arguments);
  2467. }
  2468. return _updateAvatarMovingStatus;
  2469. }()
  2470. }, {
  2471. key: "_usersStatistics",
  2472. value: function _usersStatistics() {
  2473. var _this6 = this;
  2474. this.on("userAvatarLoaded", function () {
  2475. window.setInterval(function () {
  2476. var e = _this6._room.avatars.filter(function (r) {
  2477. return r.group === AvatarGroup.User;
  2478. }).length || 0,
  2479. t = _this6._room.avatars.filter(function (r) {
  2480. return r.group === AvatarGroup.User && r.isRender;
  2481. }).length || 0;
  2482. _this6._room.stats.assign({
  2483. userNum: e,
  2484. syncUserNum: _this6.syncAvatarsLength,
  2485. renderedUserNum: t
  2486. });
  2487. }, 3e3);
  2488. });
  2489. }
  2490. }]);
  2491. return XverseAvatarManager;
  2492. }(EventEmitter);
  2493. var PathManager = /*#__PURE__*/function () {
  2494. function PathManager() {
  2495. _classCallCheck(this, PathManager);
  2496. this.currentArea = '';
  2497. this.currentPathName = '';
  2498. this.currentAttitude = '';
  2499. this.speed = 0;
  2500. }
  2501. _createClass(PathManager, [{
  2502. key: "getSpeed",
  2503. value: function getSpeed(e) {
  2504. var t = {
  2505. guangchang: {
  2506. [MotionType.Walk]: 17,
  2507. [MotionType.Run]: 51
  2508. },
  2509. tower: {
  2510. [MotionType.Walk]: 12.5,
  2511. [MotionType.Run]: 25
  2512. },
  2513. zhiboting: {
  2514. [MotionType.Walk]: 12.5,
  2515. [MotionType.Run]: 25
  2516. },
  2517. youxiting: {
  2518. [MotionType.Walk]: 12.5,
  2519. [MotionType.Run]: 25
  2520. },
  2521. diqing: {
  2522. [MotionType.Walk]: 12.5,
  2523. [MotionType.Run]: 25
  2524. }
  2525. },
  2526. r = t[this.currentArea] || t.guangchang;
  2527. return this.speed = r[e] * 30, this.speed;
  2528. }
  2529. }]);
  2530. return PathManager;
  2531. }();
  2532. var CameraStates = {
  2533. Normal: 0,
  2534. ItemView: 1,
  2535. CGView: 2,
  2536. PathView: 3
  2537. };
  2538. var Person$1 = {
  2539. Third: 0,
  2540. First: 1
  2541. };
  2542. function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); 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); }; }
  2543. function _isNativeReflectConstruct$6() { 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; } }
  2544. var Camera = /*#__PURE__*/function (_EventEmitter) {
  2545. _inherits(Camera, _EventEmitter);
  2546. var _super = _createSuper$6(Camera);
  2547. function Camera(e) {
  2548. var _this;
  2549. _classCallCheck(this, Camera);
  2550. _this = _super.call(this);
  2551. _this.initialFov = 0;
  2552. _this._state = CameraStates.Normal;
  2553. _this._person = Person$1.Third;
  2554. _this._cameraFollowing = !0;
  2555. _this._room = e;
  2556. return _this;
  2557. }
  2558. _createClass(Camera, [{
  2559. key: "checkPointOnLeftOrRight",
  2560. value: function checkPointOnLeftOrRight(e) {
  2561. var t = ue4Position2Xverse(e);
  2562. if (!t || this.checkPointInView(e)) return;
  2563. var o = this._room.scene.activeCamera;
  2564. if (!o) return;
  2565. var a = [o.target.x, o.target.y, o.target.z],
  2566. s = [o.position.x, o.position.y, o.position.z],
  2567. l = t.x,
  2568. u = t.y,
  2569. c = t.z,
  2570. h = calNormVector(s, a),
  2571. f = calNormVector(s, [l, u, c]);
  2572. return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
  2573. }
  2574. }, {
  2575. key: "checkPointInView",
  2576. value: function checkPointInView(e, t, r) {
  2577. var n = ue4Position2Xverse({
  2578. x: e,
  2579. y: t,
  2580. z: r
  2581. });
  2582. if (!n) return !1;
  2583. for (var o = 0; o < 6; o++) {
  2584. if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  2585. }
  2586. return !0;
  2587. }
  2588. }, {
  2589. key: "person",
  2590. get: function get() {
  2591. return this._person;
  2592. }
  2593. }, {
  2594. key: "state",
  2595. get: function get() {
  2596. return this._state;
  2597. }
  2598. }, {
  2599. key: "pose",
  2600. get: function get() {
  2601. return this._room.currentClickingState.camera;
  2602. }
  2603. }, {
  2604. key: "cameraFollowing",
  2605. get: function get() {
  2606. return this._cameraFollowing;
  2607. },
  2608. set: function set(e) {
  2609. logger.info("cameraFollowing setter", e), this.setCameraFollowing({
  2610. isFollowHost: e
  2611. });
  2612. }
  2613. }, {
  2614. key: "setCameraFollowing",
  2615. value: function setCameraFollowing(_ref) {
  2616. _ref.isFollowHost;
  2617. }
  2618. }, {
  2619. key: "handleRenderInfo",
  2620. value: function handleRenderInfo(e) {
  2621. var t = e.renderInfo.cameraStateType,
  2622. r = this._room.sceneManager;
  2623. if (t !== this._state && (this._state = t, logger.debug("camera._state changed to", CameraStates[t]), t === CameraStates.CGView ? (r.cameraComponent.switchToCgCamera(), r.staticmeshComponent.getCgMesh().show()) : (r.cameraComponent.switchToMainCamera(), r.staticmeshComponent.getCgMesh().hide()), this.emit("stateChanged", {
  2624. state: t
  2625. })), this._room.isHost) return;
  2626. var n = e.playerState.isFollowHost;
  2627. !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
  2628. cameraFollowing: !!n
  2629. }));
  2630. }
  2631. }, {
  2632. key: "setCameraState",
  2633. value: function setCameraState(_ref2) {
  2634. var e = _ref2.state;
  2635. if (this._state === e) {
  2636. logger.warn("You are already in ".concat(CameraStates[e], " camera state"));
  2637. return;
  2638. }
  2639. e === CameraStates.Normal || this._state === CameraStates.ItemView && logger.warn("CloseUp camera state can only be triggerd by room internally");
  2640. }
  2641. }, {
  2642. key: "turnToFace",
  2643. value: function turnToFace(_ref3) {
  2644. var _ref3$extra = _ref3.extra,
  2645. e = _ref3$extra === void 0 ? "" : _ref3$extra,
  2646. _ref3$offset = _ref3.offset,
  2647. t = _ref3$offset === void 0 ? 0 : _ref3$offset;
  2648. var r = {
  2649. action_type: Actions.TurnToFace,
  2650. turn_to_face_action: {
  2651. offset: t
  2652. }
  2653. };
  2654. return this.emit("viewChanged", {
  2655. extra: e
  2656. }), this._room.actionsHandler.sendData({
  2657. data: r
  2658. });
  2659. }
  2660. }, {
  2661. key: "isInDefaultView",
  2662. value: function isInDefaultView() {
  2663. if (!this._room.isHost) {
  2664. logger.warn("It is recommended to call the function on the host side");
  2665. return;
  2666. }
  2667. if (!this._room._currentClickingState) return logger.error("CurrentState should not be empty"), !1;
  2668. var _this$_room$_currentC = this._room._currentClickingState,
  2669. e = _this$_room$_currentC.camera,
  2670. t = _this$_room$_currentC.player;
  2671. return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
  2672. }
  2673. }, {
  2674. key: "screenShot",
  2675. value: function () {
  2676. var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
  2677. var e, _ref4$autoSave, t, r, n, o;
  2678. return regenerator.wrap(function _callee$(_context) {
  2679. while (1) {
  2680. switch (_context.prev = _context.next) {
  2681. case 0:
  2682. e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
  2683. r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
  2684. _context.prev = 2;
  2685. this._room.sceneManager.setImageQuality(EImageQuality.high);
  2686. _context.next = 6;
  2687. return CreateScreenshotAsync(r, n, {
  2688. precision: 1
  2689. });
  2690. case 6:
  2691. o = _context.sent;
  2692. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
  2693. case 10:
  2694. _context.prev = 10;
  2695. _context.t0 = _context["catch"](2);
  2696. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
  2697. case 13:
  2698. case "end":
  2699. return _context.stop();
  2700. }
  2701. }
  2702. }, _callee, this, [[2, 10]]);
  2703. }));
  2704. function screenShot(_x) {
  2705. return _screenShot.apply(this, arguments);
  2706. }
  2707. return screenShot;
  2708. }()
  2709. }, {
  2710. key: "changeToFirstPerson",
  2711. value: function changeToFirstPerson(e, t, r) {
  2712. var _this2 = this;
  2713. var n = e.camera,
  2714. o = e.player,
  2715. a = e.attitude,
  2716. s = e.areaName,
  2717. l = e.pathName;
  2718. return this._room.actionsHandler.requestPanorama({
  2719. camera: n,
  2720. player: o,
  2721. attitude: a,
  2722. areaName: s,
  2723. pathName: l
  2724. }, t, r).then(function () {
  2725. _this2._room.networkController.rtcp.workers.changePanoMode(!0);
  2726. var _ref5 = o || {},
  2727. u = _ref5.position,
  2728. c = _ref5.angle;
  2729. _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
  2730. position: u,
  2731. rotation: c
  2732. });
  2733. });
  2734. }
  2735. }, {
  2736. key: "setPerson",
  2737. value: function setPerson(e) {
  2738. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  2739. camera: this._room._currentClickingState.camera,
  2740. player: this._room._currentClickingState.player
  2741. };
  2742. var r = Date.now();
  2743. return this._setPerson(e, t).then(function (n) {
  2744. return logger.infoAndReportMeasurement({
  2745. tag: Person$1[e],
  2746. startTime: r,
  2747. metric: "setPerson"
  2748. }), n;
  2749. }).catch(function (n) {
  2750. return logger.infoAndReportMeasurement({
  2751. tag: Person$1[e],
  2752. startTime: r,
  2753. metric: "setPerson",
  2754. error: n
  2755. }), Promise.reject(n);
  2756. });
  2757. }
  2758. }, {
  2759. key: "_setPerson",
  2760. value: function _setPerson(e) {
  2761. var _this3 = this;
  2762. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  2763. camera: this._room._currentClickingState.camera,
  2764. player: this._room._currentClickingState.player
  2765. };
  2766. return e !== Person$1.First && e !== Person$1.Third ? Promise.reject("invalid person " + e) : !t.camera || !t.player ? Promise.reject(new ParamError("wrong camera or player")) : e === Person$1.First ? this._room.panorama.access({
  2767. camera: t.camera,
  2768. player: t.player,
  2769. tag: "setPerson"
  2770. }).then(function () {
  2771. var o, a;
  2772. _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
  2773. var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
  2774. r = _ref6.position,
  2775. n = _ref6.angle;
  2776. !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
  2777. position: r,
  2778. rotation: n
  2779. });
  2780. }) : this._room.panorama.exit({
  2781. camera: t.camera,
  2782. player: t.player
  2783. }).then(function () {
  2784. var r, n;
  2785. _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
  2786. });
  2787. }
  2788. }, {
  2789. key: "setCameraPose",
  2790. value: function setCameraPose(e) {
  2791. this._room.sceneManager.cameraComponent.setCameraPose({
  2792. position: e.position,
  2793. rotation: e.angle
  2794. });
  2795. }
  2796. }, {
  2797. key: "setMainCameraRotationLimit",
  2798. value: function setMainCameraRotationLimit(e) {
  2799. var t = e.limitAxis,
  2800. r = e.limitRotation;
  2801. this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
  2802. }
  2803. }]);
  2804. return Camera;
  2805. }(EventEmitter);
  2806. function _createSuper$5(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$5(); 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); }; }
  2807. function _isNativeReflectConstruct$5() { 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; } }
  2808. var numberFormat = new Intl.NumberFormat(window.navigator.language, {
  2809. maximumFractionDigits: 0
  2810. });
  2811. var Stats = /*#__PURE__*/function (_EventEmitter) {
  2812. _inherits(Stats, _EventEmitter);
  2813. var _super = _createSuper$5(Stats);
  2814. function Stats(e) {
  2815. var _this;
  2816. _classCallCheck(this, Stats);
  2817. _this = _super.call(this);
  2818. _this._netInterval = null;
  2819. _this._disabled = !1;
  2820. _this._show = !1;
  2821. _this._aggregatedStats = {};
  2822. _this._displayElement = null;
  2823. _this._extraStats = {};
  2824. _this._networkSamples = [];
  2825. _this.externalStats = null;
  2826. _this.constructedTime = null;
  2827. _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
  2828. var t, r, n;
  2829. _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
  2830. }, 1e3), _this._netInterval = window.setInterval(function () {
  2831. _this.getIsWeakNet();
  2832. }, NET_INTERVAL * 1e3);
  2833. return _this;
  2834. }
  2835. _createClass(Stats, [{
  2836. key: "isShow",
  2837. get: function get() {
  2838. return this._show;
  2839. }
  2840. }, {
  2841. key: "assign",
  2842. value: function assign(e) {
  2843. Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
  2844. }
  2845. }, {
  2846. key: "appendExternalStats",
  2847. value: function appendExternalStats(e) {
  2848. var _this2 = this;
  2849. var t = {};
  2850. if (!e || typeof e != "object") {
  2851. console.warn("appendExternalStats should be plain object");
  2852. return;
  2853. }
  2854. Object.keys(e).forEach(function (r) {
  2855. Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
  2856. }), !(Object.keys(t).length > 10) && (this.externalStats = t);
  2857. }
  2858. }, {
  2859. key: "getRtt",
  2860. value: function getRtt() {
  2861. var e = this._extraStats.rtt;
  2862. return typeof e != "number" ? 0 : e > 999 ? 999 : e;
  2863. }
  2864. }, {
  2865. key: "enable",
  2866. value: function enable() {
  2867. this._disabled = !1;
  2868. }
  2869. }, {
  2870. key: "disable",
  2871. value: function disable() {
  2872. this._disabled = !0;
  2873. }
  2874. }, {
  2875. key: "disableNet",
  2876. value: function disableNet() {
  2877. this._netInterval && window.clearInterval(this._netInterval);
  2878. }
  2879. }, {
  2880. key: "show",
  2881. value: function show() {
  2882. this._show = !0, this._render();
  2883. }
  2884. }, {
  2885. key: "hide",
  2886. value: function hide() {
  2887. this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
  2888. }
  2889. }, {
  2890. key: "getIsWeakNet",
  2891. value: function getIsWeakNet() {
  2892. var _this3 = this;
  2893. var e = !1;
  2894. var t = this._networkSamples.length - 1;
  2895. if (t < 0) return;
  2896. var r = this._networkSamples[t].time,
  2897. n = this._networkSamples[0].time,
  2898. o = r - n,
  2899. a = 1e3 * (DURATION - 2);
  2900. if (o < a) return;
  2901. var s = this._networkSamples.map(function (g) {
  2902. return _this3.isNetDelay(g, "rtt");
  2903. }),
  2904. l = this._networkSamples.map(function (g) {
  2905. return _this3.isNetDelay(g, "hb");
  2906. }),
  2907. u = s.reduce(function (g, m) {
  2908. return g + m;
  2909. }, 0),
  2910. c = l.reduce(function (g, m) {
  2911. return g + m;
  2912. }, 0),
  2913. h = Math.floor(u / this._networkSamples.length) * 100,
  2914. f = Math.floor(c / this._networkSamples.length) * 100,
  2915. d = 70;
  2916. (h >= d || f >= d) && (e = !0);
  2917. var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
  2918. e && !_ && (logger.infoAndReportMeasurement({
  2919. metric: "weakNetwork",
  2920. startTime: Date.now(),
  2921. extra: {
  2922. msg: this._networkSamples.slice(20),
  2923. netDelayRTTValues: u,
  2924. netDelayHBValues: c
  2925. }
  2926. }), this.emit("weakNetwork"));
  2927. }
  2928. }, {
  2929. key: "startStatsNetSamples",
  2930. value: function startStatsNetSamples() {
  2931. var _this$_extraStats = this._extraStats,
  2932. e = _this$_extraStats.rtt,
  2933. t = _this$_extraStats.hb;
  2934. if (e || t) {
  2935. var r = {
  2936. rtt: e,
  2937. hb: t,
  2938. time: new Date().getTime()
  2939. };
  2940. this._networkSamples.push(r);
  2941. var n = this._networkSamples.length - 1;
  2942. if (n < 0) return;
  2943. var o = this._networkSamples[n].time,
  2944. a = 1e3 * DURATION;
  2945. this._networkSamples = this._networkSamples.filter(function (s) {
  2946. return s.time > o - a;
  2947. });
  2948. }
  2949. }
  2950. }, {
  2951. key: "isNetDelay",
  2952. value: function isNetDelay(e, t) {
  2953. return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
  2954. }
  2955. }, {
  2956. key: "getPreciesTimer",
  2957. value: function getPreciesTimer(e, t) {
  2958. var r = t * 1e3,
  2959. n = new Date().getTime();
  2960. var o = 0;
  2961. o++;
  2962. var a = new Date().getTime() - (n + o * 1e3),
  2963. s = r - a,
  2964. l = setTimeout(function () {
  2965. clearTimeout(l), e();
  2966. }, s);
  2967. }
  2968. }, {
  2969. key: "_render",
  2970. value: function _render() {
  2971. var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
  2972. if (!this._aggregatedStats) return;
  2973. this._displayElement || (this._displayElement = document.createElement("div"), this._displayElement.style.position = "absolute", this._displayElement.style.top = "10px", this._displayElement.style.left = "200px", this._displayElement.style.width = "200px", this._displayElement.style.backgroundColor = "rgba(0,0,0,.5)", this._displayElement.style.color = "white", this._displayElement.style.textAlign = "left", this._displayElement.style.fontSize = "8px", this._displayElement.style.lineHeight = "10px", document.body.appendChild(this._displayElement));
  2974. var e = [],
  2975. t = Date.now() - this.constructedTime,
  2976. r = Math.floor(t / 1e3 % 60),
  2977. n = Math.floor(t / (1e3 * 60) % 60),
  2978. o = Math.floor(t / (1e3 * 60 * 60) % 24),
  2979. a = o < 10 ? "0" + o.toString() : o.toString(),
  2980. s = n < 10 ? "0" + n : n,
  2981. l = r < 10 ? "0" + r : r;
  2982. e.push({
  2983. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  2984. value: a + ":" + s + ":" + l
  2985. }), e.push({
  2986. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  2987. value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
  2988. }), e.push({
  2989. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  2990. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  2991. }), e.push({
  2992. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  2993. value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
  2994. }), e.push({
  2995. key: "media/meta bitrate(kbps)",
  2996. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  2997. }), e.push({
  2998. key: ":----------------Decoding---------------",
  2999. value: ""
  3000. }), e.push({
  3001. key: "-max/avg decodeTime(ms)",
  3002. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  3003. }), e.push({
  3004. key: "-frmAwait/Lost/Drop",
  3005. value: numberFormat.format(this._aggregatedStats.framesAwait || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsLost || 0) + "/" + numberFormat.format(this._aggregatedStats.packetsDrop || 0) + "/" + numberFormat.format(this._aggregatedStats.updateDropFrame) || 0
  3006. }), e.push({
  3007. key: ":----------------FrameLoop-------------",
  3008. value: ""
  3009. }), e.push({
  3010. key: "interval(max/avg/>40)",
  3011. value: (((h = this._extraStats.maxFrameTime) == null ? void 0 : h.toFixed(1)) || 0) + "/" + (((f = this._extraStats.avgFrameTime) == null ? void 0 : f.toFixed(0)) || 0) + "/" + this._extraStats.engineSloppyCnt
  3012. }), e.push({
  3013. key: "systemStuck",
  3014. value: this._extraStats.systemStuckCnt
  3015. }), e.push({
  3016. key: "--update",
  3017. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
  3018. }), e.push({
  3019. key: "--timeout",
  3020. value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
  3021. }), e.push({
  3022. key: "--render",
  3023. value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
  3024. }), e.push({
  3025. key: "---anim/regBR/clip(avg ms)",
  3026. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  3027. }), e.push({
  3028. key: "---anim/regBR/clip(max ms)",
  3029. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  3030. }), e.push({
  3031. key: "---rTR/drC/regAF(avg ms)",
  3032. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  3033. }), e.push({
  3034. key: "---rTR/drC/regAF(max ms)",
  3035. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  3036. }), e.push({
  3037. key: "--tri/drC/pati/bones/anim(Num)",
  3038. value: (this._extraStats.triangle || 0) + " / " + (this._extraStats.drawcall.toFixed(0) || 0) + " / " + (this._extraStats.activeParticles.toFixed(0) || 0) + " / " + (this._extraStats.activeBones.toFixed(0) || 0) + " / " + (this._extraStats.activeAnimation.toFixed(0) || 0)
  3039. }), e.push({
  3040. key: "--rootN/mesh/geo/tex/mat(Num)",
  3041. value: (this._extraStats.totalRootNodes.toFixed(0) || 0) + " / " + (this._extraStats.totalMeshes.toFixed(0) || 0) + " / " + (this._extraStats.totalGeometries.toFixed(0) || 0) + " / " + (this._extraStats.totalTextures.toFixed(0) || 0) + " / " + (this._extraStats.totalMaterials.toFixed(0) || 0)
  3042. }), e.push({
  3043. key: "--registerBF/AF(Num)",
  3044. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  3045. }), e.push({
  3046. key: ":----------------Rotation-------------------",
  3047. value: ""
  3048. }), e.push({
  3049. key: "Total(ms/miss)",
  3050. value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  3051. }), e.push({
  3052. key: "--rotateRsp",
  3053. value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  3054. }), e.push({
  3055. key: "--rotateProc",
  3056. value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  3057. }), e.push({
  3058. key: "--rotateShow",
  3059. value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  3060. }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
  3061. key: ":----------------Move----------------------",
  3062. value: ""
  3063. }), e.push({
  3064. key: "-startDelay",
  3065. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveResponseDelay || 0 : this._aggregatedStats.flyResponseDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveProcessDelay || 0 : this._aggregatedStats.flyProcessDelay || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.moveDisplayDelay || 0 : this._aggregatedStats.flyDisplayDelay || 0)
  3066. }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
  3067. key: "-srvInterFrm(max/avg)",
  3068. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  3069. }), e.push({
  3070. key: "-interFrameDelay",
  3071. value: "(max/avg/jank)"
  3072. }), e.push({
  3073. key: "--toDisplay",
  3074. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxDisplayMoveDiff || 0 : this._aggregatedStats.maxDisplayFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgDisplayMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgDisplayFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((P = this._aggregatedStats.moveDisplayJank) == null ? void 0 : P.toFixed(3)) || 0 : ((R = this._aggregatedStats.flyDisplayJank) == null ? void 0 : R.toFixed(3)) || 0)
  3075. }), e.push({
  3076. key: "--received",
  3077. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxResponseMoveDiff || 0 : this._aggregatedStats.maxResponseFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgResponseMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgResponseFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((M = this._aggregatedStats.moveResponseJank) == null ? void 0 : M.toFixed(3)) || 0 : ((x = this._aggregatedStats.flyResponseJank) == null ? void 0 : x.toFixed(3)) || 0)
  3078. }), e.push({
  3079. key: "--decoded",
  3080. value: (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.maxProcessMoveDiff || 0 : this._aggregatedStats.maxProcessFlyDiff || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? this._aggregatedStats.avgProcessMoveDiff.toFixed(1) || 0 : this._aggregatedStats.avgProcessFlyDiff.toFixed(1) || 0) + "/" + (this._aggregatedStats.moveEvent == "MoveTo" ? ((I = this._aggregatedStats.moveProcessJank) == null ? void 0 : I.toFixed(3)) || 0 : ((w = this._aggregatedStats.flyProcessJank) == null ? void 0 : w.toFixed(3)) || 0)
  3081. }), e.push({
  3082. key: ":----------------DevInfo-----------------",
  3083. value: ""
  3084. }), e.push({
  3085. key: "sd",
  3086. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  3087. }), e.push({
  3088. key: "----hardwareInfo",
  3089. value: this._extraStats.hardwareInfo
  3090. });
  3091. var u = "";
  3092. for (var _i = 0, _e = e; _i < _e.length; _i++) {
  3093. var O = _e[_i];
  3094. u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
  3095. }
  3096. this._displayElement.innerHTML = u;
  3097. }
  3098. }, {
  3099. key: "onStats",
  3100. value: function onStats(e) {
  3101. var _this4 = this;
  3102. var n;
  3103. if (!e) return;
  3104. var t = {},
  3105. r = this;
  3106. r._aggregatedStats || (r._aggregatedStats = {}), t.timestamp = e.timestamp, t.mediaBytesReceived = e.mediaBytesReceived, t.metaBytesReceived = e.metaBytesReceived, t.packetsLost = e.packetsLost, t.frameHeight = e.frameHeight, t.frameWidth = e.frameWidth, t.framesReceivedUI = e.framesReceived, t.framesReceived = e.framesReceivedWorker, t.framesDecoded = e.framesDecoded, t.framesEmited = e.framesEmited, t.decodeTimePerFrame = e.decodeTimePerFrame, t.decodeTimeMaxFrame = e.decodeTimeMaxFrame, t.packetsDrop = e.packetsDrop, t.framesAwait = e.framesAwait, t.updateDropFrame = e.updateDropFrame, t.firstMediaArraval = e.firstMediaArraval, t.firstYUVDecoded = e.firstYUVDecoded, t.firstRender = e.firstRender, t.returnFrames = e.returnFrames, t.sendOutBuffer = e.sendOutBuffer, t.averageGraphicTime = e.averageGraphicTime, t.maxGraphicTime = e.maxGraphicTime, t.jankTimes = e.jankTimes, t.bigJankTimes = e.bigJankTimes, t.decodeJankTimes = e.decodeJankTimes, t.bigDecodeJankTimes = e.bigDecodeJankTimes, t.serverFrameFast = e.serverFrameFast, t.serverFrameSlow = e.serverFrameSlow, t.clientFrameFast = e.clientFrameFast, t.clientFrameSlow = e.clientFrameSlow, t.rtcMessageReceived = e.rtcMessageReceived, t.rtcBytesReceived = e.rtcBytesReceived, t.receiveIframes = e.receiveIframes, t.decodeIframes = e.decodeIframes, t.avgResponseTime = e.avgResponseTime, t.avgProcessTime = e.avgProcessTime, t.avgDisplayTime = e.avgDisplayTime, t.avgOverallTime = e.avgOverallTime, t.overallTimeCount = e.overallTimeCount, t.responseMiss = e.responseMiss, t.processMiss = e.processMiss, t.displayMiss = e.displayMiss, t.avgResponseMoveDiff = e.avgResponseMoveDiff, t.avgProcessMoveDiff = e.avgProcessMoveDiff, t.avgDisplayMoveDiff = e.avgDisplayMoveDiff, t.maxResponseMoveDiff = e.maxResponseMoveDiff, t.maxProcessMoveDiff = e.maxProcessMoveDiff, t.maxDisplayMoveDiff = e.maxDisplayMoveDiff, t.moveResponseDelay = e.moveResponseDelay, t.moveProcessDelay = e.moveProcessDelay, t.moveDisplayDelay = e.moveDisplayDelay, t.moveResponseJank = e.moveResponseJank, t.moveProcessJank = e.moveProcessJank, t.moveDisplayJank = e.moveDisplayJank, t.avgMetaParseTime = e.avgMetaParseTime, t.maxMetaParseTime = e.maxMetaParseTime, t.moveResponseCounts = e.moveResponseCounts, t.moveProcessCounts = e.moveProcessCounts, t.moveDisplayCounts = e.moveDisplayCounts, t.MoveDisplayCountGood = e.MoveDisplayCountGood, t.MoveDisplayCountWell = e.MoveDisplayCountWell, t.MoveDisplayCountFair = e.MoveDisplayCountFair, t.MoveDisplayCountBad = e.MoveDisplayCountBad, t.MoveDisplayCountRest = e.MoveDisplayCountRest, t.avgServerDiff = e.avgServerDiff, t.maxServerDiff = e.maxServerDiff, t.avgResponseFlyDiff = e.avgResponseFlyDiff, t.avgProcessFlyDiff = e.avgProcessFlyDiff, t.avgDisplayFlyDiff = e.avgDisplayFlyDiff, t.maxResponseFlyDiff = e.maxResponseFlyDiff, t.maxProcessFlyDiff = e.maxProcessFlyDiff, t.maxDisplayFlyDiff = e.maxDisplayFlyDiff, t.flyResponseCounts = e.flyResponseCounts, t.flyProcessCounts = e.flyProcessCounts, t.flyDisplayCounts = e.flyDisplayCounts, t.flyResponseJank = e.flyResponseJank, t.flyProcessJank = e.flyProcessJank, t.flyDisplayJank = e.flyDisplayJank, t.flyResponseDelay = e.flyResponseDelay, t.flyProcessDelay = e.flyProcessDelay, t.flyDisplayDelay = e.flyDisplayDelay, t.moveEvent = e.moveEvent, t.sdMoveResponseLongTime = e.sdMoveResponseLongTime, t.sdMoveProcessLongTime = e.sdMoveProcessLongTime, t.sdMoveDisplayLongTime = e.sdMoveDisplayLongTime, r._aggregatedStats && r._aggregatedStats.timestamp && (t.mediaBitrate = 8 * (t.mediaBytesReceived - r._aggregatedStats.mediaBytesReceived) / 1e3, t.mediaBitrate = Math.round(t.mediaBitrate || 0), t.metaBitrate = 8 * (t.metaBytesReceived - r._aggregatedStats.metaBytesReceived) / 1e3, t.metaBitrate = Math.round(t.metaBitrate || 0), t.rtcMessagePs = t.rtcMessageReceived - r._aggregatedStats.rtcMessageReceived, t.rtcBitrate = 8 * (t.rtcBytesReceived - r._aggregatedStats.rtcBytesReceived) / 1e3, t.rtcBitrate = Math.round(t.rtcBitrate || 0), t.framesEmitedPs = t.framesEmited - r._aggregatedStats.framesEmited, t.framesEmitedPs = Math.round(t.framesEmitedPs || 0), t.framesReceivedPs = t.framesReceived - r._aggregatedStats.framesReceived, t.framesReceivedPs = Math.round(t.framesReceivedPs || 0), t.framesDecodedPs = t.framesDecoded - r._aggregatedStats.framesDecoded, t.framesDecodedPs = Math.round(t.framesDecodedPs || 0), t.returnFramesPs = t.returnFrames - r._aggregatedStats.returnFrames, t.returnFramesPs = Math.round(t.returnFramesPs || 0), t.responseMissPs = t.responseMiss - r._aggregatedStats.responseMiss, t.processMissPs = t.processMiss - r._aggregatedStats.processMiss, t.displayMissPs = t.displayMiss - r._aggregatedStats.displayMiss, t.returnFrames = e.returnFrames), this._show && this._render(), t.registerBeforeRenderTime = this._extraStats.registerBeforeRenderTime, t.registerAfterRenderTime = this._extraStats.registerAfterRenderTime, t.renderTargetRenderTime = this._extraStats.renderTargetRenderTime, t.renderFrameTime = this._extraStats.renderFrameTime, t.maxRenderFrameTime = this._extraStats.maxRenderFrameTime, t.interFrameTime = this._extraStats.interFrameTime, t.animationTime = this._extraStats.animationTime, t.meshSelectTime = this._extraStats.meshSelectTime, t.drawcall = this._extraStats.drawcall, t.drawcallTime = this._extraStats.drawcallTime, t.triangle = this._extraStats.triangle, t.registerAfterCount = this._extraStats.registerAfterCount, t.registerBeforeCount = this._extraStats.registerBeforeCount, t.fps = this._extraStats.fps, t.rtt = this._extraStats.rtt, t.hb = this._extraStats.hb, t.avgFrameTime = this._extraStats.avgFrameTime, t.avgTimeoutTime = this._extraStats.avgTimeoutTime, t.engineSloppyCnt = this._extraStats.engineSloppyCnt, t.systemStuckCnt = this._extraStats.systemStuckCnt, t.avatarState = (n = this.room._userAvatar) == null ? void 0 : n.state, t.maxFrameTime = this._extraStats.maxFrameTime, t.maxTimeoutTime = this._extraStats.maxTimeoutTime, t.activeParticles = this._extraStats.activeParticles, t.activeBones = this._extraStats.activeBones, t.activeAnimation = this._extraStats.activeAnimation, t.totalRootNodes = this._extraStats.totalRootNodes, t.totalGeometries = this._extraStats.totalGeometries, t.totalMeshes = this._extraStats.totalMeshes, t.totalTextures = this._extraStats.totalTextures, t.totalMaterials = this._extraStats.totalMaterials, t.hardwareInfo = this._extraStats.hardwareInfo, t.maxInterFrameTime = this._extraStats.maxInterFrameTime, t.maxDrawcallTime = this._extraStats.maxDrawcallTime, t.maxMeshSelectTime = this._extraStats.maxMeshSelectTime, t.maxAnimationTime = this._extraStats.maxAnimationTime, t.maxRegisterBeforeRenderTime = this._extraStats.maxRegisterBeforeRenderTime, t.maxRegisterAfterRenderTime = this._extraStats.maxRegisterAfterRenderTime, t.maxRenderTargetRenderTime = this._extraStats.maxRenderTargetRenderTime, this.externalStats && Object.keys(this.externalStats || {}).forEach(function (o) {
  3107. t[o] = _this4.externalStats[o];
  3108. }), r._aggregatedStats = t, this.emit("stats", {
  3109. stats: t
  3110. });
  3111. }
  3112. }]);
  3113. return Stats;
  3114. }(EventEmitter);
  3115. var Actions$1 = {
  3116. Clicking: 1,
  3117. PlayCG: 6,
  3118. Back: 7,
  3119. ChangeRoom: 8,
  3120. ChangeSkin: 13,
  3121. Joystick: 15,
  3122. Transfer: 18,
  3123. GetOnVehicle: 22,
  3124. GetOffVehicle: 23,
  3125. StopMoving: 34,
  3126. UnaryActionLine: 1e3,
  3127. Init: 1001,
  3128. Exit: 1002,
  3129. SetIFrameInfo: 1003,
  3130. GetNeighborPoints: 1004,
  3131. ReserveSeat: 1005,
  3132. GetReserveStatus: 1006,
  3133. ChangeNickname: 1007,
  3134. ChangeBitRateInfo: 1008,
  3135. Echo: 1009,
  3136. SetPlayerState: 1010,
  3137. TurnTo: 1011,
  3138. TurnToFace: 1012,
  3139. RotateTo: 1013,
  3140. Rotation: 1014,
  3141. CameraTurnTo: 1015,
  3142. ConfirmEvent: 1016,
  3143. Broadcast: 1017,
  3144. NotifyActionLine: 2e4,
  3145. AudienceChangeToVisitor: 1020,
  3146. VisitorChangeToAudience: 1021,
  3147. RemoveVisitor: 1022,
  3148. GetUserWithAvatar: 1023
  3149. };
  3150. var ActionsHandler = /*#__PURE__*/function () {
  3151. function ActionsHandler(e) {
  3152. _classCallCheck(this, ActionsHandler);
  3153. this.currentActiveAction = null;
  3154. this.room = e;
  3155. }
  3156. _createClass(ActionsHandler, [{
  3157. key: "avatarComponentsSync",
  3158. value: function () {
  3159. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3160. var t;
  3161. return regenerator.wrap(function _callee$(_context) {
  3162. while (1) {
  3163. switch (_context.prev = _context.next) {
  3164. case 0:
  3165. t = {
  3166. action_type: Actions$1.SetPlayerState,
  3167. set_player_state_action: {
  3168. player_state: {
  3169. avatar_components: JSON.stringify(e)
  3170. }
  3171. }
  3172. };
  3173. this.sendData({
  3174. data: t
  3175. });
  3176. case 2:
  3177. case "end":
  3178. return _context.stop();
  3179. }
  3180. }
  3181. }, _callee, this);
  3182. }));
  3183. function avatarComponentsSync(_x) {
  3184. return _avatarComponentsSync.apply(this, arguments);
  3185. }
  3186. return avatarComponentsSync;
  3187. }()
  3188. }, {
  3189. key: "sendData",
  3190. value: function () {
  3191. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  3192. var _this = this;
  3193. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  3194. return regenerator.wrap(function _callee2$(_context2) {
  3195. while (1) {
  3196. switch (_context2.prev = _context2.next) {
  3197. case 0:
  3198. _context2.next = 2;
  3199. return this.beforeSend(e);
  3200. case 2:
  3201. t = uuid$1();
  3202. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  3203. trace_id: t,
  3204. user_id: this.room.options.userId
  3205. })), e.track === !1)) {
  3206. _context2.next = 5;
  3207. break;
  3208. }
  3209. return _context2.abrupt("return", Promise.resolve(null));
  3210. case 5:
  3211. _e$sampleRate = e.sampleRate, r = _e$sampleRate === void 0 ? 1 : _e$sampleRate, _e$timeout = e.timeout, n = _e$timeout === void 0 ? 2e3 : _e$timeout, o = e.tag, a = e.data, s = e.special;
  3212. return _context2.abrupt("return", eventsManager.track({
  3213. timeout: n,
  3214. traceId: t,
  3215. event: a.action_type,
  3216. tag: o,
  3217. extra: a
  3218. }, {
  3219. special: s,
  3220. sampleRate: r,
  3221. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  3222. }).finally(function () {
  3223. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  3224. }));
  3225. case 7:
  3226. case "end":
  3227. return _context2.stop();
  3228. }
  3229. }
  3230. }, _callee2, this);
  3231. }));
  3232. function sendData(_x2) {
  3233. return _sendData.apply(this, arguments);
  3234. }
  3235. return sendData;
  3236. }()
  3237. }, {
  3238. key: "beforeSend",
  3239. value: function () {
  3240. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3241. var o, t, r;
  3242. return regenerator.wrap(function _callee3$(_context3) {
  3243. while (1) {
  3244. switch (_context3.prev = _context3.next) {
  3245. case 0:
  3246. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  3247. if (!QueueActions.includes(r)) {
  3248. _context3.next = 5;
  3249. break;
  3250. }
  3251. if (!this.currentActiveAction) {
  3252. _context3.next = 4;
  3253. break;
  3254. }
  3255. return _context3.abrupt("return", (log$p.error("".concat(Actions$1[this.currentActiveAction], " still pending, reject ").concat(Actions$1[r])), Promise.reject(new FrequencyLimitError("".concat(Actions$1[r], " action request frequency limit")))));
  3256. case 4:
  3257. this.currentActiveAction = r;
  3258. case 5:
  3259. if (!(t && QueueActions.includes(e.data.action_type))) {
  3260. _context3.next = 14;
  3261. break;
  3262. }
  3263. _context3.prev = 6;
  3264. _context3.next = 9;
  3265. return this.stopMoving();
  3266. case 9:
  3267. _context3.next = 14;
  3268. break;
  3269. case 11:
  3270. _context3.prev = 11;
  3271. _context3.t0 = _context3["catch"](6);
  3272. this.currentActiveAction = void 0, log$p.error("before action stopMoving failed", _context3.t0);
  3273. case 14:
  3274. case "end":
  3275. return _context3.stop();
  3276. }
  3277. }
  3278. }, _callee3, this, [[6, 11]]);
  3279. }));
  3280. function beforeSend(_x3) {
  3281. return _beforeSend.apply(this, arguments);
  3282. }
  3283. return beforeSend;
  3284. }()
  3285. }, {
  3286. key: "moveTo",
  3287. value: function () {
  3288. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3289. var t, _e$extra, r, n, o;
  3290. return regenerator.wrap(function _callee4$(_context4) {
  3291. while (1) {
  3292. switch (_context4.prev = _context4.next) {
  3293. case 0:
  3294. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  3295. action_type: Actions$1.Clicking,
  3296. clicking_action: {
  3297. clicking_point: t,
  3298. clicking_type: ClickType.IgnoreView,
  3299. extra: encodeURIComponent(r),
  3300. attitude: n
  3301. },
  3302. clicking_state: this.room._currentClickingState
  3303. };
  3304. return _context4.abrupt("return", this.sendData({
  3305. data: o
  3306. }));
  3307. case 2:
  3308. case "end":
  3309. return _context4.stop();
  3310. }
  3311. }
  3312. }, _callee4, this);
  3313. }));
  3314. function moveTo(_x4) {
  3315. return _moveTo.apply(this, arguments);
  3316. }
  3317. return moveTo;
  3318. }()
  3319. }, {
  3320. key: "transfer",
  3321. value: function transfer(e) {
  3322. var _this2 = this;
  3323. var t = e.renderType,
  3324. r = e.player,
  3325. n = e.camera,
  3326. o = e.areaName,
  3327. a = e.attitude,
  3328. s = e.pathName,
  3329. l = e.person,
  3330. u = e.noMedia,
  3331. c = e.timeout,
  3332. h = e.tag,
  3333. f = e.special,
  3334. d = {
  3335. data: {
  3336. action_type: Actions$1.Transfer,
  3337. transfer_action: {
  3338. render_type: t,
  3339. player: r,
  3340. camera: n,
  3341. areaName: o,
  3342. attitude: a,
  3343. pathName: s,
  3344. person: {
  3345. type: l
  3346. },
  3347. noMedia: u,
  3348. tiles: [0, 1, 2, 4]
  3349. }
  3350. },
  3351. special: f,
  3352. timeout: c || 4e3,
  3353. tag: h
  3354. };
  3355. return this.sendData(d).then(function (_) {
  3356. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  3357. person: l,
  3358. rotationRenderType: t
  3359. }), _;
  3360. });
  3361. }
  3362. }, {
  3363. key: "changeRotationRenderType",
  3364. value: function changeRotationRenderType(e) {
  3365. var t = e.renderType,
  3366. r = e.player,
  3367. n = e.camera,
  3368. o = e.areaName,
  3369. a = e.attitude,
  3370. s = e.pathName;
  3371. return this.transfer({
  3372. renderType: t,
  3373. player: r,
  3374. camera: n,
  3375. areaName: o,
  3376. attitude: a,
  3377. pathName: s,
  3378. tag: "changeToRotationVideo"
  3379. });
  3380. }
  3381. }, {
  3382. key: "requestPanorama",
  3383. value: function requestPanorama(e, t, r) {
  3384. var n = e.camera,
  3385. o = e.player,
  3386. a = e.areaName,
  3387. s = e.attitude,
  3388. l = e.pathName,
  3389. u = e.tag;
  3390. return this.transfer({
  3391. renderType: RenderType.ClientRotationPano,
  3392. player: o,
  3393. camera: n,
  3394. person: Person.First,
  3395. areaName: a,
  3396. attitude: s,
  3397. pathName: l,
  3398. noMedia: t,
  3399. timeout: r,
  3400. tag: u || "requestPanorama",
  3401. special: !t
  3402. });
  3403. }
  3404. }, {
  3405. key: "setMotionType",
  3406. value: function setMotionType(e) {
  3407. return this.transfer({
  3408. attitude: e,
  3409. tag: "setMotionType"
  3410. });
  3411. }
  3412. }, {
  3413. key: "setNickName",
  3414. value: function setNickName(e) {
  3415. var t = {
  3416. action_type: Actions$1.ChangeNickname,
  3417. change_nickname_action: {
  3418. nickname: e
  3419. }
  3420. };
  3421. return this.sendData({
  3422. data: t
  3423. });
  3424. }
  3425. }, {
  3426. key: "getReserveSeat",
  3427. value: function getReserveSeat(_ref) {
  3428. var e = _ref.routeId,
  3429. t = _ref.name;
  3430. var r = {
  3431. action_type: Actions$1.ReserveSeat,
  3432. reserve_seat_action: {
  3433. route_id: e,
  3434. name: t
  3435. }
  3436. };
  3437. return this.sendData({
  3438. data: r
  3439. });
  3440. }
  3441. }, {
  3442. key: "getReserveStatus",
  3443. value: function getReserveStatus(_ref2) {
  3444. var e = _ref2.routeId,
  3445. t = _ref2.name,
  3446. r = _ref2.need_detail;
  3447. var n = {
  3448. action_type: Actions$1.GetReserveStatus,
  3449. get_reserve_status_action: {
  3450. route_id: e,
  3451. name: t,
  3452. need_detail: r
  3453. }
  3454. };
  3455. return this.sendData({
  3456. data: n,
  3457. timeout: 2e3
  3458. }).then(function (o) {
  3459. return o.reserveDetail;
  3460. });
  3461. }
  3462. }, {
  3463. key: "stopMoving",
  3464. value: function stopMoving() {
  3465. var e = {
  3466. action_type: Actions$1.StopMoving,
  3467. stop_move_action: {}
  3468. };
  3469. return this.sendData({
  3470. data: e
  3471. });
  3472. }
  3473. }, {
  3474. key: "getOnVehicle",
  3475. value: function getOnVehicle(_ref3) {
  3476. var e = _ref3.routeId,
  3477. t = _ref3.name,
  3478. r = _ref3.camera;
  3479. var n = {
  3480. action_type: Actions$1.GetOnVehicle,
  3481. get_on_vehicle_action: {
  3482. route_id: e,
  3483. name: t,
  3484. camera: r
  3485. }
  3486. };
  3487. return this.sendData({
  3488. data: n
  3489. });
  3490. }
  3491. }, {
  3492. key: "getOffVehicle",
  3493. value: function getOffVehicle(_ref4) {
  3494. var e = _ref4.renderType,
  3495. t = _ref4.player,
  3496. r = _ref4.camera;
  3497. var n = {
  3498. action_type: Actions$1.GetOffVehicle,
  3499. get_off_vehicle_action: {
  3500. render_type: e,
  3501. player: t,
  3502. camera: r
  3503. }
  3504. };
  3505. return this.sendData({
  3506. data: n
  3507. });
  3508. }
  3509. }, {
  3510. key: "confirmEvent",
  3511. value: function confirmEvent(e) {
  3512. var t = {
  3513. action_type: Actions$1.ConfirmEvent,
  3514. confirm_event_action: {
  3515. id: e
  3516. }
  3517. };
  3518. return this.sendData({
  3519. data: t,
  3520. track: !1
  3521. });
  3522. }
  3523. }, {
  3524. key: "echo",
  3525. value: function echo(e) {
  3526. var t = {
  3527. action_type: Actions$1.Echo,
  3528. echo_msg: {
  3529. echoMsg: e
  3530. }
  3531. };
  3532. return this.sendData({
  3533. data: t,
  3534. track: !1
  3535. });
  3536. }
  3537. }, {
  3538. key: "changeSkin",
  3539. value: function () {
  3540. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3541. var _this3 = this;
  3542. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  3543. return regenerator.wrap(function _callee6$(_context6) {
  3544. while (1) {
  3545. switch (_context6.prev = _context6.next) {
  3546. case 0:
  3547. t = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special, r = e.skinId, n = e.mode, _e$landingType = e.landingType, o = _e$landingType === void 0 ? LandingType.Stay : _e$landingType, a = e.landingPoint, s = e.landingCamera, l = e.renderType, u = e.areaName, c = e.attitude, h = e.pathName, f = e.person, d = e.noMedia, _ = e.timeout, _e$roomTypeId = e.roomTypeId, g = _e$roomTypeId === void 0 ? "" : _e$roomTypeId, m = this.room.skinList.filter(function (y) {
  3548. return y.id === r;
  3549. })[0];
  3550. if (m) {
  3551. _context6.next = 4;
  3552. break;
  3553. }
  3554. y = "skin ".concat(r, " is invalid");
  3555. return _context6.abrupt("return", (log$p.error(y), Promise.reject(new ParamError(y))));
  3556. case 4:
  3557. v = {
  3558. action_type: Actions$1.ChangeSkin,
  3559. change_skin_action: {
  3560. skinID: r,
  3561. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  3562. skin_data_version: r + m.versionId,
  3563. landing_type: o,
  3564. landing_point: a,
  3565. landing_camera: s,
  3566. render_wrapper: {
  3567. render_type: l
  3568. },
  3569. areaName: u,
  3570. attitude: c,
  3571. noMedia: d,
  3572. person: f,
  3573. pathName: h,
  3574. roomTypeId: g
  3575. }
  3576. };
  3577. return _context6.abrupt("return", this.sendData({
  3578. data: v,
  3579. timeout: _ || 6e3,
  3580. special: t
  3581. }).then( /*#__PURE__*/function () {
  3582. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  3583. var b, _ref6, T;
  3584. return regenerator.wrap(function _callee5$(_context5) {
  3585. while (1) {
  3586. switch (_context5.prev = _context5.next) {
  3587. case 0:
  3588. if (!(l === RenderType.ClientRotationPano && y)) {
  3589. _context5.next = 8;
  3590. break;
  3591. }
  3592. _context5.next = 3;
  3593. return _this3.room.modelManager.findRoute(r, h);
  3594. case 3:
  3595. b = _context5.sent;
  3596. _ref6 = getRandomItem(b.birthPointList) || {};
  3597. T = _ref6.camera;
  3598. _context5.next = 8;
  3599. return _this3.room.panorama.handleReceivePanorama(y, T);
  3600. case 8:
  3601. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  3602. case 9:
  3603. case "end":
  3604. return _context5.stop();
  3605. }
  3606. }
  3607. }, _callee5);
  3608. }));
  3609. return function (_x6) {
  3610. return _ref5.apply(this, arguments);
  3611. };
  3612. }()).catch(function (y) {
  3613. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  3614. }));
  3615. case 6:
  3616. case "end":
  3617. return _context6.stop();
  3618. }
  3619. }
  3620. }, _callee6, this);
  3621. }));
  3622. function changeSkin(_x5) {
  3623. return _changeSkin.apply(this, arguments);
  3624. }
  3625. return changeSkin;
  3626. }()
  3627. }, {
  3628. key: "handleChangeSkin",
  3629. value: function handleChangeSkin(e) {
  3630. var _this4 = this;
  3631. var t = e.skinId,
  3632. r = e.mode,
  3633. n = e.renderType,
  3634. o = e.areaName,
  3635. a = e.attitude,
  3636. s = e.pathName;
  3637. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  3638. _this4.room.sceneManager.staticmeshComponent.getCgMesh().hide(), _this4.room.sceneManager.cameraComponent.switchToMainCamera(), _this4.room.pathManager.currentArea = o, log$p.info("changeSkin _updateSkinAssets susccss"), _this4.room.updateCurrentNetworkOptions({
  3639. pathName: s,
  3640. attitude: a,
  3641. areaName: o
  3642. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  3643. skin: {
  3644. id: t
  3645. },
  3646. mode: r
  3647. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  3648. });
  3649. }
  3650. }, {
  3651. key: "rotate",
  3652. value: function rotate(_ref7) {
  3653. var e = _ref7.pitch,
  3654. t = _ref7.yaw;
  3655. var n;
  3656. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  3657. var r = {
  3658. action_type: Actions$1.Rotation,
  3659. rotation_action: {
  3660. vertical_move: e,
  3661. horizontal_move: -t
  3662. }
  3663. };
  3664. this.sendData({
  3665. data: r,
  3666. sampleRate: .02
  3667. });
  3668. }
  3669. }, {
  3670. key: "turnTo",
  3671. value: function turnTo(e) {
  3672. var _ref8 = e || {},
  3673. t = _ref8.point,
  3674. _ref8$timeout = _ref8.timeout,
  3675. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  3676. _ref8$offset = _ref8.offset,
  3677. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  3678. o = {
  3679. action_type: Actions$1.TurnTo,
  3680. turn_to_action: {
  3681. turn_to_point: t,
  3682. offset: n
  3683. }
  3684. };
  3685. return this.sendData({
  3686. data: o,
  3687. timeout: r
  3688. });
  3689. }
  3690. }, {
  3691. key: "rotateTo",
  3692. value: function rotateTo(e) {
  3693. var _ref9 = e || {},
  3694. t = _ref9.point,
  3695. _ref9$offset = _ref9.offset,
  3696. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  3697. _ref9$speed = _ref9.speed,
  3698. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  3699. o = {
  3700. action_type: Actions$1.RotateTo,
  3701. rotate_to_action: {
  3702. rotate_to_point: t,
  3703. offset: r,
  3704. speed: n
  3705. }
  3706. };
  3707. return this.sendData({
  3708. data: o
  3709. });
  3710. }
  3711. }, {
  3712. key: "broadcast",
  3713. value: function broadcast(e) {
  3714. var t = e.data,
  3715. _e$msgType = e.msgType,
  3716. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  3717. n = e.targetUserIds;
  3718. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  3719. var o = {
  3720. action_type: Actions$1.Broadcast,
  3721. broadcast_action: {
  3722. data: JSON.stringify(t),
  3723. user_id: this.room.options.userId,
  3724. msgType: r
  3725. }
  3726. };
  3727. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  3728. data: o,
  3729. tag: t.broadcastType
  3730. });
  3731. }
  3732. }, {
  3733. key: "getNeighborPoints",
  3734. value: function getNeighborPoints(e) {
  3735. var t = e.point,
  3736. _e$containSelf = e.containSelf,
  3737. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  3738. _e$searchRange = e.searchRange,
  3739. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  3740. o = {
  3741. action_type: Actions$1.GetNeighborPoints,
  3742. get_neighbor_points_action: {
  3743. point: t,
  3744. level: 1,
  3745. containSelf: r,
  3746. searchRange: n
  3747. }
  3748. };
  3749. return this.sendData({
  3750. data: o
  3751. }).then(function (a) {
  3752. return a.nps;
  3753. });
  3754. }
  3755. }, {
  3756. key: "playCG",
  3757. value: function playCG(e) {
  3758. var t = {
  3759. action_type: Actions$1.PlayCG,
  3760. play_cg_action: {
  3761. cg_name: e
  3762. }
  3763. };
  3764. return this.sendData({
  3765. data: t
  3766. });
  3767. }
  3768. }, {
  3769. key: "audienceToVisitor",
  3770. value: function audienceToVisitor(e) {
  3771. var t = e.avatarId,
  3772. r = e.avatarComponents,
  3773. n = e.player,
  3774. o = e.camera,
  3775. a = {
  3776. action_type: Actions$1.AudienceChangeToVisitor,
  3777. audienceChangeToVisitorAction: {
  3778. avatarID: t,
  3779. avatarComponents: r,
  3780. player: n,
  3781. camera: o
  3782. }
  3783. };
  3784. return log$p.debug("send data: audience to visitor"), this.sendData({
  3785. data: a
  3786. });
  3787. }
  3788. }, {
  3789. key: "visitorToAudience",
  3790. value: function visitorToAudience(e) {
  3791. var t = e.renderType,
  3792. r = e.player,
  3793. n = e.camera,
  3794. o = e.areaName,
  3795. a = e.attitude,
  3796. s = e.pathName,
  3797. l = e.person,
  3798. u = e.noMedia,
  3799. c = {
  3800. action_type: Actions$1.VisitorChangeToAudience,
  3801. visitorChangeToAudienceAction: {
  3802. transferAction: {
  3803. render_type: t,
  3804. player: r,
  3805. camera: n,
  3806. areaName: o,
  3807. attitude: a,
  3808. pathName: s,
  3809. person: {
  3810. type: l
  3811. },
  3812. noMedia: u,
  3813. tiles: [0, 1, 2, 4]
  3814. }
  3815. }
  3816. };
  3817. return log$p.debug("send data: visitor to audience"), this.sendData({
  3818. data: c
  3819. });
  3820. }
  3821. }, {
  3822. key: "removeVisitor",
  3823. value: function removeVisitor(e) {
  3824. var t = e.removeType,
  3825. r = e.userIDList,
  3826. _e$extraInfo = e.extraInfo,
  3827. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  3828. o = {
  3829. action_type: Actions$1.RemoveVisitor,
  3830. removeVisitorAction: {
  3831. removeVisitorEvent: t,
  3832. userIDList: r,
  3833. extraInfo: encodeURIComponent(n)
  3834. }
  3835. };
  3836. return log$p.debug("send data: remove visitor"), this.sendData({
  3837. data: o
  3838. });
  3839. }
  3840. }, {
  3841. key: "getUserWithAvatar",
  3842. value: function getUserWithAvatar(e, t) {
  3843. var r = {
  3844. action_type: Actions$1.GetUserWithAvatar,
  3845. getUserWithAvatarAction: {
  3846. userType: e,
  3847. roomID: t
  3848. }
  3849. };
  3850. return log$p.debug("send data: get user with avatar"), this.sendData({
  3851. data: r
  3852. }).then(function (n) {
  3853. return n.userWithAvatarList;
  3854. });
  3855. }
  3856. }, {
  3857. key: "joystick",
  3858. value: function joystick(e) {
  3859. var t = e.degree,
  3860. _e$level = e.level,
  3861. r = _e$level === void 0 ? 1 : _e$level,
  3862. n = uuid$1();
  3863. var o = -t + 90 + 360;
  3864. o >= 360 && (o -= 360);
  3865. var a = {
  3866. action_type: Actions$1.Joystick,
  3867. dir_action: {
  3868. move_angle: o,
  3869. speed_level: r
  3870. },
  3871. trace_id: n,
  3872. user_id: this.room.options.userId,
  3873. packet_id: n
  3874. };
  3875. return this.sendData({
  3876. data: a,
  3877. track: !1
  3878. });
  3879. }
  3880. }]);
  3881. return ActionsHandler;
  3882. }();
  3883. var Signal = /*#__PURE__*/function () {
  3884. function Signal(e) {
  3885. _classCallCheck(this, Signal);
  3886. this.signalHandleActived = !0;
  3887. this.isUpdatedYUV = !0;
  3888. this._room = e;
  3889. }
  3890. _createClass(Signal, [{
  3891. key: "handleSignal",
  3892. value: function handleSignal(e) {
  3893. var _this = this;
  3894. var a, s, l;
  3895. if (!this.signalHandleActived) return;
  3896. var t = e.signal,
  3897. r = e.alreadyUpdateYUV;
  3898. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  3899. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  3900. return c.userId === _this._room.userId;
  3901. });
  3902. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  3903. logger.debug("stream stoped, make avatar to stop");
  3904. var _u$renderInfo = u.renderInfo,
  3905. c = _u$renderInfo.isMoving,
  3906. h = _u$renderInfo.isRotating;
  3907. this._room.avatarManager._updateAvatarMovingStatus({
  3908. id: u.userId,
  3909. isMoving: !!c,
  3910. isRotating: !!h
  3911. });
  3912. }
  3913. return;
  3914. }
  3915. this.isUpdatedYUV = r;
  3916. var n = t;
  3917. if (!t) {
  3918. logger.warn("metadata signal is empty");
  3919. return;
  3920. }
  3921. if (n.code === Codes.RepeatLogin) {
  3922. this._room.handleRepetLogin();
  3923. return;
  3924. }
  3925. n.code !== void 0 && n.code !== Codes.Success && n.code !== Codes.ActionMaybeDelay && n.code !== Codes.DoActionBlocked && n.code !== Codes.GetOnVehicle && (logger.error("signal errcode: ", n), this._room.emit("error", n));
  3926. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  3927. return u.userId === _this._room.userId;
  3928. });
  3929. if (n.broadcastAction) try {
  3930. var _u = JSON.parse(n.broadcastAction.data);
  3931. Broadcast.handlers.forEach(function (c) {
  3932. return c(_u);
  3933. });
  3934. } catch (u) {
  3935. logger.error(u);
  3936. }
  3937. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  3938. this._room._currentClickingState = o.playerState;
  3939. var _o$playerState = o.playerState,
  3940. _u2 = _o$playerState.pathName,
  3941. _c = _o$playerState.attitude,
  3942. _h = _o$playerState.areaName,
  3943. f = _o$playerState.skinId;
  3944. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  3945. pathName: _u2
  3946. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  3947. areaName: _h
  3948. }), _c) {
  3949. var d = this._room.skin.routeList.find(function (g) {
  3950. return g.areaName === _this._room.currentState.areaName;
  3951. }),
  3952. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  3953. this._room.updateCurrentState({
  3954. speed: _,
  3955. attitude: _c
  3956. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  3957. }
  3958. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  3959. }
  3960. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  3961. var _u3 = n.actionType,
  3962. _c2 = n.code,
  3963. _h2 = n.echoMsg,
  3964. _f = n.traceId;
  3965. _u3 === Actions.Echo && _c2 === Codes.Success && this._room.networkController.rtcp.heartbeat.pong(_h2, _f), _c2 !== Codes.Success ? eventsManager.remove(_f, _c2) : [Actions.GetReserveStatus, Actions.Broadcast, Actions.ChangeNickname, Actions.ConfirmEvent, Actions.ReserveSeat, Actions.Rotation, Actions.TurnTo, Actions.RotateTo, Actions.SetPlayerState, Actions.GetNeighborPoints, Actions.TurnToFace, Actions.AudienceChangeToVisitor, Actions.RemoveVisitor, Actions.GetUserWithAvatar].includes(_u3) && eventsManager.remove(_f, _c2, n);
  3966. }
  3967. }
  3968. }, {
  3969. key: "handleActionResponses",
  3970. value: function handleActionResponses(e) {
  3971. var _this2 = this;
  3972. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  3973. if (t.actionType == null) return;
  3974. var r = t.pointType,
  3975. n = t.extra,
  3976. o = t.actionType,
  3977. a = t.traceId,
  3978. s = t.code,
  3979. l = t.msg;
  3980. o === Actions.GetNeighborPoints ? eventsManager.remove(a, s, t.nps) : o === Actions.GetUserWithAvatar ? eventsManager.remove(a, s, t.userWithAvatarList) : eventsManager.remove(a, s, l), r === PointType.Path && o === Actions.Clicking && (_this2._room.moveToExtra = decodeURIComponent(n));
  3981. });
  3982. }
  3983. }, {
  3984. key: "udpateSkinInfo",
  3985. value: function () {
  3986. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3987. var t;
  3988. return regenerator.wrap(function _callee$(_context) {
  3989. while (1) {
  3990. switch (_context.prev = _context.next) {
  3991. case 0:
  3992. this._room.updateCurrentState({
  3993. skinId: e
  3994. });
  3995. _context.next = 3;
  3996. return this._room.skinList.find(function (r) {
  3997. return r.id === e;
  3998. });
  3999. case 3:
  4000. t = _context.sent;
  4001. t && this._room.updateCurrentState({
  4002. skin: t
  4003. });
  4004. case 5:
  4005. case "end":
  4006. return _context.stop();
  4007. }
  4008. }
  4009. }, _callee, this);
  4010. }));
  4011. function udpateSkinInfo(_x) {
  4012. return _udpateSkinInfo.apply(this, arguments);
  4013. }
  4014. return udpateSkinInfo;
  4015. }()
  4016. }]);
  4017. return Signal;
  4018. }();
  4019. function _createSuper$4(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$4(); 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); }; }
  4020. function _isNativeReflectConstruct$4() { 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; } }
  4021. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  4022. _inherits(ParamError, _XverseError);
  4023. var _super = _createSuper$4(ParamError);
  4024. function ParamError(e) {
  4025. _classCallCheck(this, ParamError);
  4026. return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
  4027. }
  4028. return _createClass(ParamError);
  4029. }(XverseError);
  4030. var MotionType$1 = {
  4031. Walk: 'walk',
  4032. Run: 'run',
  4033. Fly: 'fly'
  4034. };
  4035. function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); 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); }; }
  4036. function _isNativeReflectConstruct$3() { 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; } }
  4037. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  4038. _inherits(NetworkController, _EventEmitter);
  4039. var _super = _createSuper$3(NetworkController);
  4040. function NetworkController(e) {
  4041. var _this;
  4042. _classCallCheck(this, NetworkController);
  4043. _this = _super.call(this);
  4044. _this.socket = null;
  4045. _this.rtcp = null;
  4046. _this.stream = null;
  4047. _this._state = 'connecting';
  4048. _this._networkMonitor = null;
  4049. _this.blockedActions = [];
  4050. _this.reconnectCount = 0;
  4051. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this)), _this.rtcp = new Rtcp(_assertThisInitialized(_this)), _this.stream = new Stream(), _this._networkMonitor = new NetworkMonitor(function () {
  4052. logger.info("network changed, online:", _this._networkMonitor.isOnline), _this._state === "disconnected" && _this._networkMonitor.isOnline && (logger.info("network back to online, try to reconnect"), _this.reconnect());
  4053. }), checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl), _this._networkMonitor.start(), new VisibilityChangeHandler().subscribe(function (r) {
  4054. var n, o;
  4055. r ? ((o = _this.room.stats) == null || o.disable(), logger.infoAndReportMeasurement({
  4056. metric: "pageHide",
  4057. startTime: Date.now()
  4058. })) : ((n = _this.room.stats) == null || n.enable(), logger.infoAndReportMeasurement({
  4059. metric: "pageShow",
  4060. startTime: Date.now(),
  4061. extra: {
  4062. state: _this._state
  4063. }
  4064. }), _this._state === "disconnected" && _this.reconnect());
  4065. });
  4066. return _this;
  4067. }
  4068. _createClass(NetworkController, [{
  4069. key: "startGame",
  4070. value: function startGame() {
  4071. var _this2 = this;
  4072. return new Promise(function (e, t) {
  4073. if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
  4074. if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
  4075. _this2.socket.on("gameRoomAvailable", function (r) {
  4076. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  4077. }), _this2.socket.on("socketClosed", function (r) {
  4078. t(r);
  4079. }), _this2.socket.startGame();
  4080. });
  4081. }
  4082. }, {
  4083. key: "addBlockedActions",
  4084. value: function addBlockedActions(e) {
  4085. var _this$blockedActions;
  4086. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  4087. }
  4088. }, {
  4089. key: "removeBlockedActions",
  4090. value: function removeBlockedActions(e) {
  4091. if (!e) {
  4092. this.blockedActions = [];
  4093. return;
  4094. }
  4095. var t = this.blockedActions.indexOf(e);
  4096. this.blockedActions.splice(t, 1);
  4097. }
  4098. }, {
  4099. key: "setState",
  4100. value: function setState(e) {
  4101. this._state !== e && (logger.info("Set network state to ", e), this._state = e);
  4102. }
  4103. }, {
  4104. key: "connectAndStart",
  4105. value: function () {
  4106. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4107. return regenerator.wrap(function _callee$(_context) {
  4108. while (1) {
  4109. switch (_context.prev = _context.next) {
  4110. case 0:
  4111. return _context.abrupt("return", this.connect(e).then(this.startGame));
  4112. case 1:
  4113. case "end":
  4114. return _context.stop();
  4115. }
  4116. }
  4117. }, _callee, this);
  4118. }));
  4119. function connectAndStart(_x) {
  4120. return _connectAndStart.apply(this, arguments);
  4121. }
  4122. return connectAndStart;
  4123. }()
  4124. }, {
  4125. key: "connect",
  4126. value: function () {
  4127. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  4128. var _this3 = this;
  4129. var e,
  4130. _args2 = arguments;
  4131. return regenerator.wrap(function _callee2$(_context2) {
  4132. while (1) {
  4133. switch (_context2.prev = _context2.next) {
  4134. case 0:
  4135. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  4136. return _context2.abrupt("return", (this.room.updateCurrentNetworkOptions({
  4137. reconnect: e
  4138. }), new Promise(function (t, r) {
  4139. _this3.rtcp.on("rtcConnected", function () {
  4140. _this3.setState("connected"), t();
  4141. }), _this3.rtcp.on("rtcDisconnected", function () {
  4142. logger.info("rtc disconnected"), _this3._state === "connecting" ? (_this3.setState("disconnected"), r(new InternalError("rtc connect failed"))) : (_this3.setState("disconnected"), logger.info("rtc disconnected, start to reconnect"), _this3.reconnect());
  4143. }), _this3.socket.on("socketQuit", function () {
  4144. logger.info("socket quit success"), _this3.setState("closed");
  4145. }), _this3.socket.on("socketClosed", function (n) {
  4146. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  4147. }), _this3.socket.start();
  4148. })));
  4149. case 2:
  4150. case "end":
  4151. return _context2.stop();
  4152. }
  4153. }
  4154. }, _callee2, this);
  4155. }));
  4156. function connect() {
  4157. return _connect.apply(this, arguments);
  4158. }
  4159. return connect;
  4160. }()
  4161. }, {
  4162. key: "reconnect",
  4163. value: function reconnect() {
  4164. var _this4 = this;
  4165. if (this.room.viewMode === "observer") return;
  4166. var e = Date.now();
  4167. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  4168. logger.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  4169. state: "disconnected"
  4170. });
  4171. return;
  4172. }
  4173. return logger.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  4174. logger.infoAndReportMeasurement({
  4175. startTime: e,
  4176. metric: "reconnect"
  4177. });
  4178. }).catch(function (t) {
  4179. if (logger.infoAndReportMeasurement({
  4180. startTime: e,
  4181. metric: "reconnect",
  4182. error: t
  4183. }), t.code === Codes.RepeatLogin) {
  4184. _this4.room.handleRepetLogin();
  4185. return;
  4186. }
  4187. var r = 1e3;
  4188. logger.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  4189. _this4.reconnect();
  4190. }, r);
  4191. });
  4192. }
  4193. }, {
  4194. key: "_reconnect",
  4195. value: function _reconnect() {
  4196. var _this5 = this;
  4197. return this._state === "closed" ? (logger.warn("connection closed already"), Promise.reject()) : this._state === "connecting" ? (logger.warn("connection is already in connecting state"), Promise.reject()) : this._state !== "disconnected" ? Promise.reject() : (this.prepareReconnect(), this._state = "connecting", this.emit("stateChanged", {
  4198. state: "reconnecting",
  4199. count: this.reconnectCount
  4200. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  4201. var e = _ref.session_id;
  4202. _this5.room.updateCurrentNetworkOptions({
  4203. sessionId: e
  4204. }), reporter.updateBody({
  4205. serverSession: e
  4206. }), logger.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  4207. state: "reconnected"
  4208. });
  4209. }));
  4210. }
  4211. }, {
  4212. key: "prepareReconnect",
  4213. value: function prepareReconnect() {
  4214. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  4215. }
  4216. }, {
  4217. key: "prepareReconnectOptions",
  4218. value: function prepareReconnectOptions() {
  4219. var _ref2 = this.room.currentClickingState || {},
  4220. e = _ref2.camera,
  4221. t = _ref2.player;
  4222. e && t && this.room.updateCurrentNetworkOptions({
  4223. camera: e,
  4224. player: t
  4225. });
  4226. }
  4227. }, {
  4228. key: "sendRtcData",
  4229. value: function sendRtcData(e) {
  4230. if (this.blockedActions.includes(e.action_type)) {
  4231. logger.info("action: ".concat(Actions[e.action_type], " was blocked"));
  4232. return;
  4233. }
  4234. this.rtcp.sendData(e);
  4235. }
  4236. }, {
  4237. key: "sendSocketData",
  4238. value: function sendSocketData(e) {
  4239. logger.debug("ws send ->", e), this.socket.send(e);
  4240. }
  4241. }, {
  4242. key: "quit",
  4243. value: function quit() {
  4244. var e = uuid$1(),
  4245. t = {
  4246. action_type: Actions.Exit,
  4247. trace_id: e,
  4248. exit_action: {},
  4249. user_id: this.room.options.userId,
  4250. packet_id: e
  4251. };
  4252. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  4253. }
  4254. }]);
  4255. return NetworkController;
  4256. }(EventEmitter);
  4257. 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); }; }
  4258. 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; } }
  4259. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  4260. _inherits(Xverse_Room, _EventEmitter);
  4261. var _super = _createSuper$2(Xverse_Room);
  4262. function Xverse_Room(e) {
  4263. var _this;
  4264. _classCallCheck(this, Xverse_Room);
  4265. _this = _super.call(this);
  4266. _this.disableAutoTurn = !1;
  4267. _this._currentNetworkOptions = null;
  4268. _this.lastSkinId = null;
  4269. _this.debug = null;
  4270. _this.isFirstDataUsed = !1;
  4271. _this.userId = null;
  4272. _this.pathManager = new PathManager();
  4273. _this.networkController = null;
  4274. _this._startTime = Date.now();
  4275. _this.canvas = null;
  4276. _this.eventsController = null;
  4277. _this.panorama = null;
  4278. _this.engineProxy = null;
  4279. _this._id = null;
  4280. _this.skinList = [];
  4281. _this.isHost = !1;
  4282. _this.avatarManager = new XverseAvatarManager(_assertThisInitialized(_this));
  4283. _this.effectManager = new XverseAvatarManager(_assertThisInitialized(_this));
  4284. _this.sceneManager = null;
  4285. _this.scene = null;
  4286. _this.breathPointManager = null;
  4287. _this._currentState = null;
  4288. _this.joined = !1;
  4289. _this.disableRotate = !1;
  4290. _this.isPano = !1;
  4291. _this.movingByClick = !0;
  4292. _this.camera = new Camera(_assertThisInitialized(_this));
  4293. _this.stats = new Stats(_assertThisInitialized(_this));
  4294. _this.isUpdatedRawYUVData = !1;
  4295. _this.actionsHandler = new ActionsHandler(_assertThisInitialized(_this));
  4296. _this._currentClickingState = null;
  4297. _this.signal = new Signal(_assertThisInitialized(_this));
  4298. _this.firstFrameTimestamp = null;
  4299. _this.moveToExtra = '';
  4300. _this.options = e;
  4301. _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV);
  4302. _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  4303. var n = e;
  4304. n.canvas;
  4305. var r = Oe(n, ["canvas"]);
  4306. logger.infoAndReportMeasurement({
  4307. metric: "startJoinRoomAt",
  4308. startTime: Date.now(),
  4309. group: "joinRoom",
  4310. extra: r,
  4311. value: 0
  4312. });
  4313. return _this;
  4314. }
  4315. _createClass(Xverse_Room, [{
  4316. key: "receiveRtcData",
  4317. value: function () {
  4318. var _receiveRtcData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  4319. var _this2 = this;
  4320. var e, t, r, n;
  4321. return regenerator.wrap(function _callee$(_context) {
  4322. while (1) {
  4323. switch (_context.prev = _context.next) {
  4324. case 0:
  4325. logger.info("Invoke receiveRtcData");
  4326. e = !1, t = !1, r = !1, n = !1;
  4327. return _context.abrupt("return", this.viewMode === "serverless" ? (logger.warn("set view mode to serverless"), this.setViewMode("observer").then(function () {
  4328. return _this2;
  4329. }, function () {
  4330. return _this2;
  4331. })) : new Promise(function (o) {
  4332. var a = _this2.networkController.rtcp.workers;
  4333. a.registerFunction("signal", function (s) {
  4334. _this2.signal.handleSignal(s);
  4335. }), a.registerFunction("stream", function (s) {
  4336. var l;
  4337. if (_this2.emit("streamTimestamp", {
  4338. timestamp: Date.now()
  4339. }), t || (t = !0, logger.info("Invoke stream event")), s.stream) {
  4340. r || (r = !0, logger.info("Invoke updateRawYUVData")), _this2.isUpdatedRawYUVData = !1;
  4341. var u = (l = _this2._currentState.skin) == null ? void 0 : l.fov;
  4342. _this2.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this2.isUpdatedRawYUVData = !0;
  4343. }
  4344. e || (logger.info("Invoke isAfterRenderRegistered"), e = !0, _this2.scene.registerAfterRender(function () {
  4345. _this2.engineProxy.frameRenderNumber >= 2 && (n || (n = !0, logger.info("Invoke registerAfterRender")), _this2.isFirstDataUsed || (logger.info("Invoke isStreamAvailable"), _this2.isFirstDataUsed = !0, _this2.firstFrameTimestamp = Date.now(), o(_this2), _this2.afterJoinRoom()));
  4346. }));
  4347. }), _this2.panorama.bindListener(function () {
  4348. o(_this2), _this2.afterJoinRoom();
  4349. }), a.registerFunction("reconnectedFrame", function () {}), logger.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  4350. t: 5
  4351. });
  4352. }));
  4353. case 3:
  4354. case "end":
  4355. return _context.stop();
  4356. }
  4357. }
  4358. }, _callee, this);
  4359. }));
  4360. function receiveRtcData() {
  4361. return _receiveRtcData.apply(this, arguments);
  4362. }
  4363. return receiveRtcData;
  4364. }()
  4365. }, {
  4366. key: "currentNetworkOptions",
  4367. get: function get() {
  4368. return this._currentNetworkOptions;
  4369. }
  4370. }, {
  4371. key: "viewMode",
  4372. get: function get() {
  4373. var e;
  4374. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  4375. }
  4376. }, {
  4377. key: "id",
  4378. get: function get() {
  4379. return this._id;
  4380. }
  4381. }, {
  4382. key: "skinId",
  4383. get: function get() {
  4384. return this._currentState.skinId;
  4385. }
  4386. }, {
  4387. key: "skin",
  4388. get: function get() {
  4389. return this._currentState.skin;
  4390. }
  4391. }, {
  4392. key: "sessionId",
  4393. get: function get() {
  4394. return this.currentNetworkOptions.sessionId;
  4395. }
  4396. }, {
  4397. key: "pictureQualityLevel",
  4398. get: function get() {
  4399. return this.currentState.pictureQualityLevel;
  4400. }
  4401. }, {
  4402. key: "avatars",
  4403. get: function get() {
  4404. return Array.from(this.avatarManager.avatars.values());
  4405. }
  4406. }, {
  4407. key: "currentState",
  4408. get: function get() {
  4409. var e;
  4410. return le(oe({}, this._currentState), {
  4411. state: (e = this.networkController) == null ? void 0 : e._state
  4412. });
  4413. }
  4414. }, {
  4415. key: "_userAvatar",
  4416. get: function get() {
  4417. var _this3 = this;
  4418. return this.avatars.find(function (e) {
  4419. return e.userId === _this3.userId;
  4420. });
  4421. }
  4422. }, {
  4423. key: "tvs",
  4424. get: function get() {
  4425. return this.engineProxy._tvs;
  4426. }
  4427. }, {
  4428. key: "tv",
  4429. get: function get() {
  4430. return this.tvs[0];
  4431. }
  4432. }, {
  4433. key: "currentClickingState",
  4434. get: function get() {
  4435. return this._currentClickingState;
  4436. }
  4437. }, {
  4438. key: "afterJoinRoomHook",
  4439. value: function afterJoinRoomHook() {}
  4440. }, {
  4441. key: "beforeJoinRoomResolveHook",
  4442. value: function beforeJoinRoomResolveHook() {}
  4443. }, {
  4444. key: "afterReconnectedHook",
  4445. value: function afterReconnectedHook() {}
  4446. }, {
  4447. key: "handleSignalHook",
  4448. value: function handleSignalHook(e) {}
  4449. }, {
  4450. key: "skinChangedHook",
  4451. value: function skinChangedHook() {}
  4452. }, {
  4453. key: "beforeStartGameHook",
  4454. value: function () {
  4455. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  4456. return regenerator.wrap(function _callee2$(_context2) {
  4457. while (1) {
  4458. switch (_context2.prev = _context2.next) {
  4459. case 0:
  4460. case "end":
  4461. return _context2.stop();
  4462. }
  4463. }
  4464. }, _callee2);
  4465. }));
  4466. function beforeStartGameHook(_x) {
  4467. return _beforeStartGameHook.apply(this, arguments);
  4468. }
  4469. return beforeStartGameHook;
  4470. }()
  4471. }, {
  4472. key: "loadAssetsHook",
  4473. value: function loadAssetsHook() {}
  4474. }, {
  4475. key: "afterUserAvatarLoadedHook",
  4476. value: function afterUserAvatarLoadedHook() {}
  4477. }, {
  4478. key: "audienceViewModeHook",
  4479. value: function audienceViewModeHook() {}
  4480. }, {
  4481. key: "setViewModeToObserver",
  4482. value: function setViewModeToObserver() {}
  4483. }, {
  4484. key: "handleVehicleHook",
  4485. value: function handleVehicleHook(e) {}
  4486. }, {
  4487. key: "updateReporter",
  4488. value: function updateReporter() {
  4489. var _this$options = this.options,
  4490. e = _this$options.avatarId,
  4491. t = _this$options.skinId,
  4492. r = _this$options.userId,
  4493. n = _this$options.roomId,
  4494. o = _this$options.role,
  4495. a = _this$options.appId,
  4496. s = _this$options.wsServerUrl;
  4497. reporter$1.updateHeader({
  4498. userId: r
  4499. }), reporter$1.updateBody({
  4500. roomId: n,
  4501. role: o,
  4502. skinId: t,
  4503. avatarId: e,
  4504. appId: a,
  4505. wsServerUrl: s
  4506. });
  4507. }
  4508. }, {
  4509. key: "initRoom",
  4510. value: function () {
  4511. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  4512. var _this$options$timeout, e;
  4513. return regenerator.wrap(function _callee3$(_context3) {
  4514. while (1) {
  4515. switch (_context3.prev = _context3.next) {
  4516. case 0:
  4517. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  4518. if (!util.isSupported()) {
  4519. _context3.next = 5;
  4520. break;
  4521. }
  4522. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  4523. case 5:
  4524. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  4525. case 6:
  4526. case "end":
  4527. return _context3.stop();
  4528. }
  4529. }
  4530. }, _callee3, this);
  4531. }));
  4532. function initRoom() {
  4533. return _initRoom2.apply(this, arguments);
  4534. }
  4535. return initRoom;
  4536. }()
  4537. }, {
  4538. key: "_initRoom",
  4539. value: function () {
  4540. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  4541. var e, _this$options2, t, r, n, o, a, s, l, u, c, _this$options2$isAllS, h, f, d, _, g, m, v, _this$options2$firend, y, _this$options2$syncBy, b, T, _this$options2$attitu, C, A, _this$options2$viewMo, S, P, R, M, _this$options2$hasAva, x, _this$options2$syncTo, I, _this$options2$priori, w, _this$options2$remove, O, D, F, V, N;
  4542. return regenerator.wrap(function _callee4$(_context4) {
  4543. while (1) {
  4544. switch (_context4.prev = _context4.next) {
  4545. case 0:
  4546. e = this.validateOptions(this.options);
  4547. if (!e) {
  4548. _context4.next = 3;
  4549. break;
  4550. }
  4551. return _context4.abrupt("return", (logger.error("initRoom param error", e), Promise.reject(e)));
  4552. case 3:
  4553. _this$options2 = this.options, t = _this$options2.canvas, r = _this$options2.avatarId, n = _this$options2.skinId, o = _this$options2.userId, a = _this$options2.wsServerUrl, s = _this$options2.role, l = _this$options2.token, u = _this$options2.pageSession, c = _this$options2.rotationRenderType, _this$options2$isAllS = _this$options2.isAllSync, h = _this$options2$isAllS === void 0 ? !1 : _this$options2$isAllS, f = _this$options2.appId, d = _this$options2.camera, _ = _this$options2.player, g = _this$options2.avatarComponents, m = _this$options2.nickname, v = _this$options2.avatarScale, _this$options2$firend = _this$options2.firends, y = _this$options2$firend === void 0 ? [] : _this$options2$firend, _this$options2$syncBy = _this$options2.syncByEvent, b = _this$options2$syncBy === void 0 ? !1 : _this$options2$syncBy, T = _this$options2.areaName, _this$options2$attitu = _this$options2.attitude, C = _this$options2$attitu === void 0 ? MotionType$1.Walk : _this$options2$attitu, A = _this$options2.pathName, _this$options2$viewMo = _this$options2.viewMode, S = _this$options2$viewMo === void 0 ? "full" : _this$options2$viewMo, P = _this$options2.person, R = _this$options2.roomId, M = _this$options2.roomTypeId, _this$options2$hasAva = _this$options2.hasAvatar, x = _this$options2$hasAva === void 0 ? !1 : _this$options2$hasAva, _this$options2$syncTo = _this$options2.syncToOthers, I = _this$options2$syncTo === void 0 ? !1 : _this$options2$syncTo, _this$options2$priori = _this$options2.prioritySync, w = _this$options2$priori === void 0 ? !1 : _this$options2$priori, _this$options2$remove = _this$options2.removeWhenDisconnected, O = _this$options2$remove === void 0 ? !0 : _this$options2$remove, D = _this$options2.extra;
  4554. this.setCurrentNetworkOptions({
  4555. avatarId: r,
  4556. skinId: n,
  4557. roomId: R,
  4558. userId: o,
  4559. wsServerUrl: a,
  4560. role: s,
  4561. token: l,
  4562. pageSession: u,
  4563. rotationRenderType: c,
  4564. isAllSync: h,
  4565. appId: f,
  4566. camera: d,
  4567. player: _,
  4568. avatarComponents: g,
  4569. nickname: m,
  4570. avatarScale: v,
  4571. firends: y,
  4572. syncByEvent: b,
  4573. areaName: T,
  4574. attitude: C,
  4575. pathName: A,
  4576. person: P,
  4577. roomTypeId: M,
  4578. hasAvatar: x,
  4579. syncToOthers: I,
  4580. prioritySync: w,
  4581. extra: D,
  4582. removeWhenDisconnected: O
  4583. });
  4584. this.userId = o;
  4585. this.canvas = t;
  4586. T && (this.pathManager.currentArea = T);
  4587. this.networkController = new NetworkController(this);
  4588. this.setCurrentState({
  4589. areaName: T,
  4590. pathName: A,
  4591. attitude: C,
  4592. speed: 0,
  4593. viewMode: S,
  4594. state: this.networkController._state,
  4595. skinId: n
  4596. });
  4597. _context4.prev = 10;
  4598. _context4.next = 13;
  4599. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  4600. case 13:
  4601. logger.info("network config wasm all ready, start to create game");
  4602. _context4.next = 16;
  4603. return this.requestCreateRoom({
  4604. skinId: n
  4605. });
  4606. case 16:
  4607. F = _context4.sent;
  4608. V = F.routeList.find(function (L) {
  4609. return L.areaName === T;
  4610. });
  4611. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  4612. this.updateCurrentState({
  4613. skin: F,
  4614. skinId: F.id,
  4615. versionId: F.versionId,
  4616. speed: N
  4617. });
  4618. _context4.next = 22;
  4619. return this.initEngine(F);
  4620. case 22:
  4621. _context4.next = 27;
  4622. break;
  4623. case 24:
  4624. _context4.prev = 24;
  4625. _context4.t0 = _context4["catch"](10);
  4626. return _context4.abrupt("return", Promise.reject(_context4.t0));
  4627. case 27:
  4628. return _context4.abrupt("return", (this.beforeJoinRoomResolve(), this.receiveRtcData()));
  4629. case 28:
  4630. case "end":
  4631. return _context4.stop();
  4632. }
  4633. }
  4634. }, _callee4, this, [[10, 24]]);
  4635. }));
  4636. function _initRoom() {
  4637. return _initRoom3.apply(this, arguments);
  4638. }
  4639. return _initRoom;
  4640. }()
  4641. }, {
  4642. key: "beforeJoinRoomResolve",
  4643. value: function beforeJoinRoomResolve() {
  4644. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  4645. }
  4646. }, {
  4647. key: "afterJoinRoom",
  4648. value: function afterJoinRoom() {
  4649. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger.infoAndReportMeasurement({
  4650. tag: this.viewMode,
  4651. value: this.firstFrameTimestamp - this._startTime,
  4652. startTime: Date.now(),
  4653. metric: "joinRoom"
  4654. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref) {
  4655. var e = _ref.stats;
  4656. reporter$1.report("stats", oe({}, e));
  4657. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  4658. }
  4659. }, {
  4660. key: "afterReconnected",
  4661. value: function afterReconnected() {
  4662. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  4663. }
  4664. }, {
  4665. key: "leave",
  4666. value: function leave() {
  4667. var e, t;
  4668. return logger.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  4669. }
  4670. }, {
  4671. key: "validateOptions",
  4672. value: function validateOptions(e) {
  4673. var _ref2 = e || {},
  4674. t = _ref2.canvas,
  4675. r = _ref2.avatarId,
  4676. n = _ref2.skinId,
  4677. o = _ref2.userId,
  4678. a = _ref2.role;
  4679. _ref2.roomId;
  4680. var l = _ref2.token,
  4681. u = _ref2.appId;
  4682. _ref2.avatarComponents;
  4683. var h = [];
  4684. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  4685. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  4686. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  4687. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  4688. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  4689. return h[0];
  4690. }
  4691. }, {
  4692. key: "initNetwork",
  4693. value: function () {
  4694. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  4695. var e;
  4696. return regenerator.wrap(function _callee5$(_context5) {
  4697. while (1) {
  4698. switch (_context5.prev = _context5.next) {
  4699. case 0:
  4700. if (!(this.viewMode === "serverless")) {
  4701. _context5.next = 2;
  4702. break;
  4703. }
  4704. return _context5.abrupt("return", Promise.resolve());
  4705. case 2:
  4706. e = Date.now();
  4707. _context5.prev = 3;
  4708. _context5.next = 6;
  4709. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  4710. case 6:
  4711. logger.infoAndReportMeasurement({
  4712. metric: "networkInitAt",
  4713. startTime: this._startTime,
  4714. group: "joinRoom"
  4715. });
  4716. logger.infoAndReportMeasurement({
  4717. metric: "networkInitCost",
  4718. startTime: e,
  4719. group: "joinRoom"
  4720. });
  4721. _context5.next = 13;
  4722. break;
  4723. case 10:
  4724. _context5.prev = 10;
  4725. _context5.t0 = _context5["catch"](3);
  4726. throw logger.infoAndReportMeasurement({
  4727. metric: "networkInitAt",
  4728. startTime: e,
  4729. group: "joinRoom",
  4730. error: _context5.t0
  4731. }), _context5.t0;
  4732. case 13:
  4733. case "end":
  4734. return _context5.stop();
  4735. }
  4736. }
  4737. }, _callee5, this, [[3, 10]]);
  4738. }));
  4739. function initNetwork() {
  4740. return _initNetwork.apply(this, arguments);
  4741. }
  4742. return initNetwork;
  4743. }()
  4744. }, {
  4745. key: "initConfig",
  4746. value: function () {
  4747. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  4748. var e;
  4749. return regenerator.wrap(function _callee6$(_context6) {
  4750. while (1) {
  4751. switch (_context6.prev = _context6.next) {
  4752. case 0:
  4753. e = Date.now();
  4754. _context6.prev = 1;
  4755. _context6.next = 4;
  4756. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  4757. case 4:
  4758. logger.infoAndReportMeasurement({
  4759. metric: "configInitAt",
  4760. startTime: this._startTime,
  4761. group: "joinRoom"
  4762. });
  4763. logger.infoAndReportMeasurement({
  4764. metric: "configInitCost",
  4765. startTime: e,
  4766. group: "joinRoom"
  4767. });
  4768. _context6.next = 11;
  4769. break;
  4770. case 8:
  4771. _context6.prev = 8;
  4772. _context6.t0 = _context6["catch"](1);
  4773. throw logger.infoAndReportMeasurement({
  4774. metric: "configInitAt",
  4775. startTime: e,
  4776. group: "joinRoom",
  4777. error: _context6.t0
  4778. }), _context6.t0;
  4779. case 11:
  4780. case "end":
  4781. return _context6.stop();
  4782. }
  4783. }
  4784. }, _callee6, this, [[1, 8]]);
  4785. }));
  4786. function initConfig() {
  4787. return _initConfig.apply(this, arguments);
  4788. }
  4789. return initConfig;
  4790. }()
  4791. }, {
  4792. key: "initEngine",
  4793. value: function () {
  4794. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  4795. var t, n;
  4796. return regenerator.wrap(function _callee7$(_context7) {
  4797. while (1) {
  4798. switch (_context7.prev = _context7.next) {
  4799. case 0:
  4800. t = Date.now();
  4801. _context7.prev = 1;
  4802. this.engineProxy = new EngineProxy(this);
  4803. _context7.next = 5;
  4804. return this.engineProxy.initEngine(e);
  4805. case 5:
  4806. logger.infoAndReportMeasurement({
  4807. metric: "webglInitAt",
  4808. startTime: this._startTime,
  4809. group: "joinRoom"
  4810. });
  4811. logger.infoAndReportMeasurement({
  4812. metric: "webglInitCost",
  4813. startTime: t,
  4814. group: "joinRoom"
  4815. });
  4816. return _context7.abrupt("return");
  4817. case 10:
  4818. _context7.prev = 10;
  4819. _context7.t0 = _context7["catch"](1);
  4820. n = _context7.t0;
  4821. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger.error(_context7.t0), logger.infoAndReportMeasurement({
  4822. metric: "webglInitAt",
  4823. startTime: t,
  4824. group: "joinRoom",
  4825. error: n
  4826. }), Promise.reject(n)));
  4827. case 14:
  4828. case "end":
  4829. return _context7.stop();
  4830. }
  4831. }
  4832. }, _callee7, this, [[1, 10]]);
  4833. }));
  4834. function initEngine(_x2) {
  4835. return _initEngine.apply(this, arguments);
  4836. }
  4837. return initEngine;
  4838. }()
  4839. }, {
  4840. key: "initWasm",
  4841. value: function () {
  4842. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  4843. var _this4 = this;
  4844. var e;
  4845. return regenerator.wrap(function _callee8$(_context8) {
  4846. while (1) {
  4847. switch (_context8.prev = _context8.next) {
  4848. case 0:
  4849. if (!(this.viewMode === "serverless")) {
  4850. _context8.next = 2;
  4851. break;
  4852. }
  4853. return _context8.abrupt("return", Promise.resolve());
  4854. case 2:
  4855. e = Date.now();
  4856. _context8.prev = 3;
  4857. _context8.next = 6;
  4858. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  4859. case 6:
  4860. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  4861. logger.error("decode error", t);
  4862. var r = t.code,
  4863. n = t.message;
  4864. _this4.emit("error", {
  4865. code: r,
  4866. msg: n
  4867. });
  4868. });
  4869. logger.infoAndReportMeasurement({
  4870. metric: "wasmInitAt",
  4871. group: "joinRoom",
  4872. startTime: this._startTime
  4873. });
  4874. logger.infoAndReportMeasurement({
  4875. metric: "wasmInitCost",
  4876. group: "joinRoom",
  4877. startTime: e
  4878. });
  4879. eventsManager.on("traceId", function (t) {
  4880. _this4.networkController.rtcp.workers.onTraceId(t);
  4881. });
  4882. _context8.next = 15;
  4883. break;
  4884. case 12:
  4885. _context8.prev = 12;
  4886. _context8.t0 = _context8["catch"](3);
  4887. throw logger.infoAndReportMeasurement({
  4888. metric: "wasmInitAt",
  4889. group: "joinRoom",
  4890. startTime: e,
  4891. error: _context8.t0
  4892. }), _context8.t0;
  4893. case 15:
  4894. case "end":
  4895. return _context8.stop();
  4896. }
  4897. }
  4898. }, _callee8, this, [[3, 12]]);
  4899. }));
  4900. function initWasm() {
  4901. return _initWasm.apply(this, arguments);
  4902. }
  4903. return initWasm;
  4904. }()
  4905. }, {
  4906. key: "requestCreateRoom",
  4907. value: function () {
  4908. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref3) {
  4909. var e, t, r, _ref4, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  4910. return regenerator.wrap(function _callee9$(_context9) {
  4911. while (1) {
  4912. switch (_context9.prev = _context9.next) {
  4913. case 0:
  4914. e = _ref3.skinId;
  4915. if (!e) {
  4916. _context9.next = 11;
  4917. break;
  4918. }
  4919. _context9.next = 4;
  4920. return this.getSkin(e);
  4921. case 4:
  4922. t = _context9.sent;
  4923. _context9.next = 7;
  4924. return this.modelManager.findRoute(e, this.options.pathName);
  4925. case 7:
  4926. r = _context9.sent;
  4927. this.updateCurrentNetworkOptions({
  4928. areaName: r.areaName,
  4929. attitude: r.attitude,
  4930. versionId: t.versionId
  4931. });
  4932. _ref4 = getRandomItem(r.birthPointList) || this.options, n = _ref4.camera, o = _ref4.player;
  4933. this.options.camera || this.updateCurrentNetworkOptions({
  4934. camera: n
  4935. }), this.options.player || this.updateCurrentNetworkOptions({
  4936. player: o
  4937. });
  4938. case 11:
  4939. if (!(this.viewMode === "serverless")) {
  4940. _context9.next = 13;
  4941. break;
  4942. }
  4943. return _context9.abrupt("return", t);
  4944. case 13:
  4945. _context9.prev = 13;
  4946. _context9.next = 16;
  4947. return this.beforeStartGameHook(this.options);
  4948. case 16:
  4949. _context9.next = 18;
  4950. return this.networkController.startGame();
  4951. case 18:
  4952. _yield$this$networkCo = _context9.sent;
  4953. _r = _yield$this$networkCo.room_id;
  4954. _n = _yield$this$networkCo.data;
  4955. _o = _yield$this$networkCo.session_id;
  4956. this._id = _r;
  4957. a = JSON.parse(_n);
  4958. this.isHost = a.IsHost, e = a.SkinID || e;
  4959. _context9.next = 27;
  4960. return this.getSkin(e);
  4961. case 27:
  4962. s = _context9.sent;
  4963. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  4964. roomId: _r,
  4965. sessionId: _o
  4966. }), reporter$1.updateBody({
  4967. roomId: _r,
  4968. skinId: e,
  4969. serverSession: _o
  4970. }), s));
  4971. case 31:
  4972. _context9.prev = 31;
  4973. _context9.t0 = _context9["catch"](13);
  4974. throw logger.error("Request create room error", _context9.t0), _context9.t0;
  4975. case 34:
  4976. case "end":
  4977. return _context9.stop();
  4978. }
  4979. }
  4980. }, _callee9, this, [[13, 31]]);
  4981. }));
  4982. function requestCreateRoom(_x3) {
  4983. return _requestCreateRoom.apply(this, arguments);
  4984. }
  4985. return requestCreateRoom;
  4986. }()
  4987. }, {
  4988. key: "pause",
  4989. value: function pause() {
  4990. return this.engineProxy.pause();
  4991. }
  4992. }, {
  4993. key: "resume",
  4994. value: function resume() {
  4995. return this.engineProxy.resume();
  4996. }
  4997. }, {
  4998. key: "reconnect",
  4999. value: function reconnect() {
  5000. this.networkController.reconnect();
  5001. }
  5002. }, {
  5003. key: "setViewMode",
  5004. value: function () {
  5005. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  5006. return regenerator.wrap(function _callee10$(_context10) {
  5007. while (1) {
  5008. switch (_context10.prev = _context10.next) {
  5009. case 0:
  5010. case "end":
  5011. return _context10.stop();
  5012. }
  5013. }
  5014. }, _callee10);
  5015. }));
  5016. function setViewMode(_x4) {
  5017. return _setViewMode.apply(this, arguments);
  5018. }
  5019. return setViewMode;
  5020. }()
  5021. }, {
  5022. key: "handleRepetLogin",
  5023. value: function handleRepetLogin() {
  5024. logger.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  5025. }
  5026. }, {
  5027. key: "setPictureQualityLevel",
  5028. value: function setPictureQualityLevel(e) {
  5029. var t = {
  5030. high: EImageQuality.high,
  5031. low: EImageQuality.low,
  5032. average: EImageQuality.mid
  5033. };
  5034. return this.updateCurrentState({
  5035. pictureQualityLevel: e
  5036. }), this.sceneManager.setImageQuality(t[e]);
  5037. }
  5038. }, {
  5039. key: "getSkin",
  5040. value: function () {
  5041. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  5042. var t, n;
  5043. return regenerator.wrap(function _callee11$(_context11) {
  5044. while (1) {
  5045. switch (_context11.prev = _context11.next) {
  5046. case 0:
  5047. t = null;
  5048. _context11.next = 3;
  5049. return this.modelManager.getSkinsList();
  5050. case 3:
  5051. t = (this.skinList = _context11.sent).find(function (n) {
  5052. return n.id === e || n.id === e;
  5053. });
  5054. if (!t) {
  5055. _context11.next = 6;
  5056. break;
  5057. }
  5058. return _context11.abrupt("return", t);
  5059. case 6:
  5060. n = "skin is invalid: skinId: ".concat(e);
  5061. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  5062. case 8:
  5063. case "end":
  5064. return _context11.stop();
  5065. }
  5066. }
  5067. }, _callee11, this);
  5068. }));
  5069. function getSkin(_x5) {
  5070. return _getSkin.apply(this, arguments);
  5071. }
  5072. return getSkin;
  5073. }()
  5074. }, {
  5075. key: "setupStats",
  5076. value: function setupStats() {
  5077. this.stats.assign({
  5078. roomId: this.id,
  5079. userId: this.userId
  5080. }), setInterval(this.engineProxy.updateStats, 1e3);
  5081. }
  5082. }, {
  5083. key: "proxyEvents",
  5084. value: function proxyEvents(e, t) {
  5085. this.emit(e, t);
  5086. }
  5087. }, {
  5088. key: "setCurrentNetworkOptions",
  5089. value: function setCurrentNetworkOptions(e) {
  5090. this._currentNetworkOptions = e;
  5091. }
  5092. }, {
  5093. key: "updateCurrentNetworkOptions",
  5094. value: function updateCurrentNetworkOptions(e) {
  5095. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  5096. }
  5097. }, {
  5098. key: "setCurrentState",
  5099. value: function setCurrentState(e) {
  5100. this._currentState = e;
  5101. }
  5102. }, {
  5103. key: "updateCurrentState",
  5104. value: function updateCurrentState(e) {
  5105. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  5106. skinId: e.skinId
  5107. })), e.versionId && this.updateCurrentNetworkOptions({
  5108. versionId: e.versionId
  5109. }), Object.assign(this._currentState, e);
  5110. }
  5111. }]);
  5112. return Xverse_Room;
  5113. }(EventEmitter);
  5114. 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); }; }
  5115. 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; } }
  5116. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  5117. _inherits(XverseRoom, _Xverse_Room);
  5118. var _super = _createSuper$1(XverseRoom);
  5119. function XverseRoom(e) {
  5120. var _this;
  5121. _classCallCheck(this, XverseRoom);
  5122. _this = _super.call(this, e);
  5123. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  5124. return _this;
  5125. }
  5126. _createClass(XverseRoom, [{
  5127. key: "afterJoinRoomHook",
  5128. value: function afterJoinRoomHook() {
  5129. this.joyStick.init({});
  5130. }
  5131. }]);
  5132. return XverseRoom;
  5133. }(Xverse_Room);
  5134. var BaseTable = /*#__PURE__*/function () {
  5135. function BaseTable(e, t) {
  5136. _classCallCheck(this, BaseTable);
  5137. this.db = null;
  5138. this.isCreatingTable = !1;
  5139. this.hasCleared = !1;
  5140. this.dbName = e, this.dbVersion = t;
  5141. }
  5142. _createClass(BaseTable, [{
  5143. key: "clearDataBase",
  5144. value: function () {
  5145. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5146. var _this = this;
  5147. return regenerator.wrap(function _callee$(_context) {
  5148. while (1) {
  5149. switch (_context.prev = _context.next) {
  5150. case 0:
  5151. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  5152. var n = window.indexedDB.deleteDatabase(_this.dbName);
  5153. n.onsuccess = function () {
  5154. t();
  5155. }, n.onerror = r;
  5156. }));
  5157. case 1:
  5158. case "end":
  5159. return _context.stop();
  5160. }
  5161. }
  5162. }, _callee, this);
  5163. }));
  5164. function clearDataBase(_x) {
  5165. return _clearDataBase.apply(this, arguments);
  5166. }
  5167. return clearDataBase;
  5168. }()
  5169. }, {
  5170. key: "tableName",
  5171. value: function tableName() {
  5172. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  5173. }
  5174. }, {
  5175. key: "keyPath",
  5176. value: function keyPath() {
  5177. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  5178. }
  5179. }, {
  5180. key: "index",
  5181. value: function index() {
  5182. throw new Error("Derived class have to override 'index', and set a proper index name!");
  5183. }
  5184. }, {
  5185. key: "checkAndOpenDatabase",
  5186. value: function () {
  5187. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  5188. var _this2 = this;
  5189. return regenerator.wrap(function _callee2$(_context2) {
  5190. while (1) {
  5191. switch (_context2.prev = _context2.next) {
  5192. case 0:
  5193. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  5194. var n = setTimeout(function () {
  5195. logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  5196. }, 200);
  5197. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  5198. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  5199. }, function () {
  5200. t(new Error("Failed to open database!")), clearTimeout(n);
  5201. }, function () {
  5202. _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  5203. });
  5204. }));
  5205. case 1:
  5206. case "end":
  5207. return _context2.stop();
  5208. }
  5209. }
  5210. }, _callee2, this);
  5211. }));
  5212. function checkAndOpenDatabase() {
  5213. return _checkAndOpenDatabase.apply(this, arguments);
  5214. }
  5215. return checkAndOpenDatabase;
  5216. }()
  5217. }, {
  5218. key: "openDatabase",
  5219. value: function openDatabase(e, t, r, n, o) {
  5220. var _this3 = this;
  5221. if (this.isCreatingTable) return;
  5222. this.isCreatingTable = !0, logger.info(e, t);
  5223. var a = window.indexedDB.open(e, t),
  5224. s = this.tableName();
  5225. a.onsuccess = function (l) {
  5226. _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  5227. }, a.onerror = function (l) {
  5228. var u;
  5229. 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);
  5230. }, a.onupgradeneeded = function (l) {
  5231. var u = l.target.result,
  5232. c = _this3.index();
  5233. logger.info("Creating table ".concat(s, "."));
  5234. var h = u.objectStoreNames.contains(s);
  5235. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  5236. var f = _this3.keyPath();
  5237. h = u.createObjectStore(s, {
  5238. keyPath: f
  5239. });
  5240. }
  5241. c.map(function (f) {
  5242. h.createIndex(f, f, {
  5243. unique: !1
  5244. });
  5245. }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
  5246. };
  5247. }
  5248. }, {
  5249. key: "add",
  5250. value: function () {
  5251. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  5252. var t, o;
  5253. return regenerator.wrap(function _callee3$(_context3) {
  5254. while (1) {
  5255. switch (_context3.prev = _context3.next) {
  5256. case 0:
  5257. t = this.tableName();
  5258. _context3.next = 3;
  5259. return this.checkAndOpenDatabase();
  5260. case 3:
  5261. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  5262. return _context3.abrupt("return", new Promise(function (a, s) {
  5263. o.onsuccess = function (l) {
  5264. a(l);
  5265. }, o.onerror = function (l) {
  5266. var u;
  5267. logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  5268. };
  5269. }));
  5270. case 5:
  5271. case "end":
  5272. return _context3.stop();
  5273. }
  5274. }
  5275. }, _callee3, this);
  5276. }));
  5277. function add(_x2) {
  5278. return _add.apply(this, arguments);
  5279. }
  5280. return add;
  5281. }()
  5282. }, {
  5283. key: "put",
  5284. value: function () {
  5285. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  5286. var t, o;
  5287. return regenerator.wrap(function _callee4$(_context4) {
  5288. while (1) {
  5289. switch (_context4.prev = _context4.next) {
  5290. case 0:
  5291. t = this.tableName();
  5292. _context4.next = 3;
  5293. return this.checkAndOpenDatabase();
  5294. case 3:
  5295. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  5296. return _context4.abrupt("return", new Promise(function (a, s) {
  5297. o.onsuccess = function (l) {
  5298. a(l);
  5299. }, o.onerror = function (l) {
  5300. var u;
  5301. logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  5302. };
  5303. }));
  5304. case 5:
  5305. case "end":
  5306. return _context4.stop();
  5307. }
  5308. }
  5309. }, _callee4, this);
  5310. }));
  5311. function put(_x3) {
  5312. return _put.apply(this, arguments);
  5313. }
  5314. return put;
  5315. }()
  5316. }, {
  5317. key: "delete",
  5318. value: function _delete(e, t, r) {
  5319. var n = this.tableName();
  5320. this.checkAndOpenDatabase().then(function (o) {
  5321. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  5322. s.onsuccess = t, s.onerror = r;
  5323. });
  5324. }
  5325. }, {
  5326. key: "update",
  5327. value: function update() {
  5328. this.checkAndOpenDatabase().then(function (e) {});
  5329. }
  5330. }, {
  5331. key: "getAllKeys",
  5332. value: function () {
  5333. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  5334. var e, t;
  5335. return regenerator.wrap(function _callee5$(_context5) {
  5336. while (1) {
  5337. switch (_context5.prev = _context5.next) {
  5338. case 0:
  5339. e = this.tableName();
  5340. _context5.next = 3;
  5341. return this.checkAndOpenDatabase();
  5342. case 3:
  5343. t = _context5.sent;
  5344. return _context5.abrupt("return", new Promise(function (r, n) {
  5345. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  5346. a.onsuccess = function (s) {
  5347. r(s.target.result);
  5348. }, a.onerror = function (s) {
  5349. logger.error("db getAllKeys error", s), n(s);
  5350. };
  5351. }));
  5352. case 5:
  5353. case "end":
  5354. return _context5.stop();
  5355. }
  5356. }
  5357. }, _callee5, this);
  5358. }));
  5359. function getAllKeys() {
  5360. return _getAllKeys.apply(this, arguments);
  5361. }
  5362. return getAllKeys;
  5363. }()
  5364. }, {
  5365. key: "query",
  5366. value: function () {
  5367. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  5368. var r, n;
  5369. return regenerator.wrap(function _callee6$(_context6) {
  5370. while (1) {
  5371. switch (_context6.prev = _context6.next) {
  5372. case 0:
  5373. r = this.tableName();
  5374. _context6.next = 3;
  5375. return this.checkAndOpenDatabase();
  5376. case 3:
  5377. n = _context6.sent;
  5378. return _context6.abrupt("return", new Promise(function (o, a) {
  5379. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  5380. u.onsuccess = function (c) {
  5381. var f;
  5382. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  5383. o && o(h);
  5384. }, u.onerror = function (c) {
  5385. logger.error("db query error", c), a(c);
  5386. };
  5387. }));
  5388. case 5:
  5389. case "end":
  5390. return _context6.stop();
  5391. }
  5392. }
  5393. }, _callee6, this);
  5394. }));
  5395. function query(_x4, _x5) {
  5396. return _query.apply(this, arguments);
  5397. }
  5398. return query;
  5399. }()
  5400. }, {
  5401. key: "sleep",
  5402. value: function () {
  5403. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  5404. return regenerator.wrap(function _callee7$(_context7) {
  5405. while (1) {
  5406. switch (_context7.prev = _context7.next) {
  5407. case 0:
  5408. return _context7.abrupt("return", new Promise(function (t) {
  5409. setTimeout(function () {
  5410. t("");
  5411. }, e);
  5412. }));
  5413. case 1:
  5414. case "end":
  5415. return _context7.stop();
  5416. }
  5417. }
  5418. }, _callee7);
  5419. }));
  5420. function sleep(_x6) {
  5421. return _sleep.apply(this, arguments);
  5422. }
  5423. return sleep;
  5424. }()
  5425. }]);
  5426. return BaseTable;
  5427. }();
  5428. 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); }; }
  5429. 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; } }
  5430. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  5431. _inherits(ModelTable, _BaseTable);
  5432. var _super = _createSuper(ModelTable);
  5433. function ModelTable() {
  5434. _classCallCheck(this, ModelTable);
  5435. return _super.call(this, "XverseDatabase", 1);
  5436. }
  5437. _createClass(ModelTable, [{
  5438. key: "tableName",
  5439. value: function tableName() {
  5440. return "models";
  5441. }
  5442. }, {
  5443. key: "index",
  5444. value: function index() {
  5445. return ["url"];
  5446. }
  5447. }, {
  5448. key: "keyPath",
  5449. value: function keyPath() {
  5450. return "url";
  5451. }
  5452. }]);
  5453. return ModelTable;
  5454. }(BaseTable);
  5455. var modelTable = new ModelTable();
  5456. var Preload = /*#__PURE__*/function () {
  5457. function Preload(e) {
  5458. _classCallCheck(this, Preload);
  5459. this.config = null;
  5460. this.allKeys = [];
  5461. this.oldResourcesDeleted = !1;
  5462. this.requests = {
  5463. simple: {
  5464. stopped: !0,
  5465. requests: {}
  5466. },
  5467. observer: {
  5468. stopped: !0,
  5469. requests: {}
  5470. },
  5471. full: {
  5472. stopped: !0,
  5473. requests: {}
  5474. }
  5475. };
  5476. this.modelManager = e, this.init(e.appId);
  5477. }
  5478. _createClass(Preload, [{
  5479. key: "init",
  5480. value: function init(e) {
  5481. reporter$1.updateBody({
  5482. appId: e
  5483. });
  5484. }
  5485. }, {
  5486. key: "getConfig",
  5487. value: function () {
  5488. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5489. var _yield$this$modelMana, t;
  5490. return regenerator.wrap(function _callee$(_context) {
  5491. while (1) {
  5492. switch (_context.prev = _context.next) {
  5493. case 0:
  5494. if (!this.config) {
  5495. _context.next = 2;
  5496. break;
  5497. }
  5498. return _context.abrupt("return", this.config);
  5499. case 2:
  5500. _context.next = 4;
  5501. return this.modelManager.requestConfig();
  5502. case 4:
  5503. _yield$this$modelMana = _context.sent;
  5504. t = _yield$this$modelMana.preload;
  5505. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  5506. case 7:
  5507. case "end":
  5508. return _context.stop();
  5509. }
  5510. }
  5511. }, _callee, this);
  5512. }));
  5513. function getConfig(_x) {
  5514. return _getConfig.apply(this, arguments);
  5515. }
  5516. return getConfig;
  5517. }()
  5518. }, {
  5519. key: "getAllKeys",
  5520. value: function () {
  5521. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  5522. var e, t;
  5523. return regenerator.wrap(function _callee2$(_context2) {
  5524. while (1) {
  5525. switch (_context2.prev = _context2.next) {
  5526. case 0:
  5527. if (!this.allKeys.length) {
  5528. _context2.next = 2;
  5529. break;
  5530. }
  5531. return _context2.abrupt("return", this.allKeys);
  5532. case 2:
  5533. _context2.prev = 2;
  5534. _context2.next = 5;
  5535. return modelTable.getAllKeys();
  5536. case 5:
  5537. e = _context2.sent;
  5538. this.allKeys = e;
  5539. return _context2.abrupt("return", e);
  5540. case 10:
  5541. _context2.prev = 10;
  5542. _context2.t0 = _context2["catch"](2);
  5543. t = "preload getAllKeys error";
  5544. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  5545. case 14:
  5546. case "end":
  5547. return _context2.stop();
  5548. }
  5549. }
  5550. }, _callee2, this, [[2, 10]]);
  5551. }));
  5552. function getAllKeys() {
  5553. return _getAllKeys.apply(this, arguments);
  5554. }
  5555. return getAllKeys;
  5556. }()
  5557. }, {
  5558. key: "stop",
  5559. value: function stop(e) {
  5560. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  5561. var t = this.requests[e].requests;
  5562. Object.keys(t).forEach(function (r) {
  5563. http1.canceler.removePending(r), delete t[r];
  5564. });
  5565. }
  5566. }, {
  5567. key: "clearPreload",
  5568. value: function clearPreload(e) {
  5569. this.requests[e].stopped = !1, this.allKeys = [];
  5570. }
  5571. }, {
  5572. key: "start",
  5573. value: function () {
  5574. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  5575. var n, o, a, s, l, u, h, f, _s;
  5576. return regenerator.wrap(function _callee3$(_context3) {
  5577. while (1) {
  5578. switch (_context3.prev = _context3.next) {
  5579. case 0:
  5580. n = Date.now(), o = 0;
  5581. _context3.prev = 1;
  5582. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  5583. _context3.next = 4;
  5584. break;
  5585. }
  5586. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  5587. case 4:
  5588. this.clearPreload(e);
  5589. _context3.next = 7;
  5590. return this.getConfig(e);
  5591. case 7:
  5592. a = _context3.sent;
  5593. _context3.next = 10;
  5594. return this.getAllKeys();
  5595. case 10:
  5596. s = _context3.sent;
  5597. _context3.prev = 11;
  5598. _context3.next = 14;
  5599. return this.deleteOldResources(a.assetUrls.map(function (d) {
  5600. return d.url;
  5601. }), s);
  5602. case 14:
  5603. _context3.next = 19;
  5604. break;
  5605. case 16:
  5606. _context3.prev = 16;
  5607. _context3.t0 = _context3["catch"](11);
  5608. logger.error(_context3.t0);
  5609. case 19:
  5610. l = a.baseUrls, u = a.assetUrls;
  5611. _context3.t1 = e;
  5612. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  5613. break;
  5614. case 23:
  5615. h = l;
  5616. return _context3.abrupt("break", 30);
  5617. case 25:
  5618. h = u;
  5619. return _context3.abrupt("break", 30);
  5620. case 27:
  5621. h = u;
  5622. return _context3.abrupt("break", 30);
  5623. case 29:
  5624. h = u;
  5625. case 30:
  5626. f = h.filter(function (d) {
  5627. return !s.includes(d.url);
  5628. });
  5629. r && isFunction(r) && (f = f.filter(r));
  5630. o = f.length;
  5631. logger.debug("keysNeedToPreload", f);
  5632. f.length || t && t(h.length, h.length);
  5633. n = Date.now();
  5634. _context3.next = 38;
  5635. return this._preload(e, f, t);
  5636. case 38:
  5637. logger.infoAndReportMeasurement({
  5638. tag: e,
  5639. startTime: n,
  5640. metric: "assetsPreload",
  5641. extra: {
  5642. total: o
  5643. }
  5644. });
  5645. return _context3.abrupt("return");
  5646. case 42:
  5647. _context3.prev = 42;
  5648. _context3.t2 = _context3["catch"](1);
  5649. _s = _context3.t2;
  5650. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  5651. tag: e,
  5652. startTime: n,
  5653. metric: "assetsPreload",
  5654. extra: {
  5655. total: o
  5656. },
  5657. error: _s,
  5658. reportOptions: {
  5659. immediate: !0
  5660. }
  5661. }), Promise.reject(_s)));
  5662. case 46:
  5663. case "end":
  5664. return _context3.stop();
  5665. }
  5666. }
  5667. }, _callee3, this, [[1, 42], [11, 16]]);
  5668. }));
  5669. function start(_x2, _x3, _x4) {
  5670. return _start.apply(this, arguments);
  5671. }
  5672. return start;
  5673. }()
  5674. }, {
  5675. key: "deleteOldResources",
  5676. value: function deleteOldResources(e, t) {
  5677. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  5678. var r = t.filter(function (n) {
  5679. return !e.includes(n);
  5680. });
  5681. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  5682. return modelTable.delete(n);
  5683. }));
  5684. }
  5685. }, {
  5686. key: "_preload",
  5687. value: function () {
  5688. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  5689. var _this = this;
  5690. var n, o, a;
  5691. return regenerator.wrap(function _callee6$(_context6) {
  5692. while (1) {
  5693. switch (_context6.prev = _context6.next) {
  5694. case 0:
  5695. n = t.length;
  5696. if (n) {
  5697. _context6.next = 3;
  5698. break;
  5699. }
  5700. return _context6.abrupt("return", Promise.resolve());
  5701. case 3:
  5702. o = 0;
  5703. a = window.setInterval(function () {
  5704. r && r(o, n), o >= n && window.clearInterval(a);
  5705. }, 1e3);
  5706. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  5707. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  5708. var l, u;
  5709. return regenerator.wrap(function _callee5$(_context5) {
  5710. while (1) {
  5711. switch (_context5.prev = _context5.next) {
  5712. case 0:
  5713. l = s.size, u = s.url;
  5714. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  5715. url: u,
  5716. timeout: Preload.getTimeoutBySize(l),
  5717. responseType: "blob",
  5718. retry: 2,
  5719. beforeRequest: function beforeRequest() {
  5720. _this.requests[e].requests[u] = !0;
  5721. }
  5722. }).then( /*#__PURE__*/function () {
  5723. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  5724. var h, f;
  5725. return regenerator.wrap(function _callee4$(_context4) {
  5726. while (1) {
  5727. switch (_context4.prev = _context4.next) {
  5728. case 0:
  5729. h = c.data;
  5730. if (h instanceof Blob) {
  5731. _context4.next = 3;
  5732. break;
  5733. }
  5734. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  5735. case 3:
  5736. _context4.next = 5;
  5737. return blobToDataURI(h);
  5738. case 5:
  5739. f = _context4.sent;
  5740. _context4.prev = 6;
  5741. _context4.next = 9;
  5742. return modelTable.put({
  5743. url: u,
  5744. model: f
  5745. });
  5746. case 9:
  5747. return _context4.abrupt("return");
  5748. case 12:
  5749. _context4.prev = 12;
  5750. _context4.t0 = _context4["catch"](6);
  5751. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  5752. case 15:
  5753. case "end":
  5754. return _context4.stop();
  5755. }
  5756. }
  5757. }, _callee4, null, [[6, 12]]);
  5758. }));
  5759. return function (_x9) {
  5760. return _ref2.apply(this, arguments);
  5761. };
  5762. }()).then(function () {
  5763. o++, delete _this.requests[e].requests[u];
  5764. }, function (c) {
  5765. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  5766. }));
  5767. case 2:
  5768. case "end":
  5769. return _context5.stop();
  5770. }
  5771. }
  5772. }, _callee5);
  5773. }));
  5774. return function (_x8) {
  5775. return _ref.apply(this, arguments);
  5776. };
  5777. }()));
  5778. case 6:
  5779. case "end":
  5780. return _context6.stop();
  5781. }
  5782. }
  5783. }, _callee6);
  5784. }));
  5785. function _preload(_x5, _x6, _x7) {
  5786. return _preload2.apply(this, arguments);
  5787. }
  5788. return _preload;
  5789. }()
  5790. }], [{
  5791. key: "getTimeoutBySize",
  5792. value: function getTimeoutBySize(e) {
  5793. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  5794. }
  5795. }]);
  5796. return Preload;
  5797. }();
  5798. var RenderType$1 = {
  5799. PathVideo: 0,
  5800. RotationVideo: 1,
  5801. RotationImage: 2,
  5802. PanoramaImage: 3,
  5803. CGVideo: 4,
  5804. ClientRotationPano: 5,
  5805. CloudRotationPano: 6
  5806. };
  5807. var Xverse = /*#__PURE__*/function () {
  5808. function Xverse(e) {
  5809. _classCallCheck(this, Xverse);
  5810. e || (e = {});
  5811. var _e = e,
  5812. t = _e.onLog,
  5813. r = _e.env,
  5814. n = _e.appId,
  5815. o = _e.releaseId,
  5816. a = _e.subPackageVersion;
  5817. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && Logger.setLevel(LoggerLevels.Debug);
  5818. var s = this.pageSession = util.uuid();
  5819. reporter$1.updateHeader({
  5820. pageSession: s
  5821. });
  5822. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  5823. a && reporter$1.updateBody({
  5824. sdkVersion: a
  5825. });
  5826. logger.infoAndReportMeasurement({
  5827. metric: "sdkInit",
  5828. startTime: Date.now(),
  5829. extra: {
  5830. version: a,
  5831. enviroment: r,
  5832. pageSession: s
  5833. }
  5834. });
  5835. logger.debug("debug mode:", this.debug);
  5836. reporter$1.on("report", function (l) {
  5837. t && t(l);
  5838. });
  5839. if (n) {
  5840. this.appId = n, this.releaseId = o;
  5841. var l = ModelManager.getInstance(n, o);
  5842. this.preload = new Preload(l);
  5843. }
  5844. }
  5845. _createClass(Xverse, [{
  5846. key: "isSupported",
  5847. get: function get() {
  5848. return isSupported();
  5849. }
  5850. }, {
  5851. key: "disableLogUpload",
  5852. value: function disableLogUpload() {
  5853. reporter$1.disable(), logger.debug("logger upload has been disabled");
  5854. }
  5855. }, {
  5856. key: "getSkinList",
  5857. value: function () {
  5858. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5859. return regenerator.wrap(function _callee$(_context) {
  5860. while (1) {
  5861. switch (_context.prev = _context.next) {
  5862. case 0:
  5863. return _context.abrupt("return", []);
  5864. case 1:
  5865. case "end":
  5866. return _context.stop();
  5867. }
  5868. }
  5869. }, _callee);
  5870. }));
  5871. function getSkinList() {
  5872. return _getSkinList.apply(this, arguments);
  5873. }
  5874. return getSkinList;
  5875. }()
  5876. }, {
  5877. key: "getAvatarList",
  5878. value: function () {
  5879. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  5880. return regenerator.wrap(function _callee2$(_context2) {
  5881. while (1) {
  5882. switch (_context2.prev = _context2.next) {
  5883. case 0:
  5884. return _context2.abrupt("return", []);
  5885. case 1:
  5886. case "end":
  5887. return _context2.stop();
  5888. }
  5889. }
  5890. }, _callee2);
  5891. }));
  5892. function getAvatarList() {
  5893. return _getAvatarList.apply(this, arguments);
  5894. }
  5895. return getAvatarList;
  5896. }()
  5897. }, {
  5898. key: "getGiftList",
  5899. value: function () {
  5900. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  5901. return regenerator.wrap(function _callee3$(_context3) {
  5902. while (1) {
  5903. switch (_context3.prev = _context3.next) {
  5904. case 0:
  5905. return _context3.abrupt("return", [{
  5906. id: "hack "
  5907. }]);
  5908. case 1:
  5909. case "end":
  5910. return _context3.stop();
  5911. }
  5912. }
  5913. }, _callee3);
  5914. }));
  5915. function getGiftList() {
  5916. return _getGiftList.apply(this, arguments);
  5917. }
  5918. return getGiftList;
  5919. }()
  5920. }, {
  5921. key: "joinRoom",
  5922. value: function () {
  5923. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  5924. var t, r, n, o;
  5925. return regenerator.wrap(function _callee4$(_context4) {
  5926. while (1) {
  5927. switch (_context4.prev = _context4.next) {
  5928. case 0:
  5929. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
  5930. appId: e.appId || this.appId,
  5931. releaseId: e.releaseId || this.releaseId,
  5932. pageSession: this.pageSession,
  5933. isAllSync: !0,
  5934. rotationRenderType: r,
  5935. syncByEvent: !0,
  5936. pathName: t,
  5937. person: n,
  5938. role: e.role || "audience"
  5939. }));
  5940. return _context4.abrupt("return", o.initRoom().then(function () {
  5941. return o;
  5942. }));
  5943. case 2:
  5944. case "end":
  5945. return _context4.stop();
  5946. }
  5947. }
  5948. }, _callee4, this);
  5949. }));
  5950. function joinRoom(_x) {
  5951. return _joinRoom.apply(this, arguments);
  5952. }
  5953. return joinRoom;
  5954. }()
  5955. }]);
  5956. return Xverse;
  5957. }();
  5958. var xverse = new Xverse({
  5959. env: "DEV",
  5960. appId: "10016",
  5961. releaseId: '2203120033_29769e'
  5962. });
  5963. var l = /*#__PURE__*/function () {
  5964. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5965. var R;
  5966. return regenerator.wrap(function _callee$(_context) {
  5967. while (1) {
  5968. switch (_context.prev = _context.next) {
  5969. case 0:
  5970. _context.prev = 0;
  5971. _context.next = 3;
  5972. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  5973. });
  5974. case 3:
  5975. _context.next = 12;
  5976. break;
  5977. case 5:
  5978. _context.prev = 5;
  5979. _context.t0 = _context["catch"](0);
  5980. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  5981. _context.next = 10;
  5982. break;
  5983. }
  5984. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  5985. return _context.abrupt("return");
  5986. case 10:
  5987. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  5988. return _context.abrupt("return");
  5989. case 12:
  5990. _context.prev = 12;
  5991. _context.next = 15;
  5992. return xverse.joinRoom({
  5993. canvas: document.getElementById('canvas'),
  5994. skinId: 10092,
  5995. avatarId: 'KGe_Boy',
  5996. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  5997. userId: '1f7acca1db9d5',
  5998. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  5999. appId: "10016",
  6000. token: " ",
  6001. nickname: '1f7acca1db9d5',
  6002. firends: ["user1"],
  6003. viewMode: "full",
  6004. resolution: {
  6005. width: 1728,
  6006. height: 720
  6007. },
  6008. pathName: 'thirdwalk',
  6009. objectFit: null,
  6010. hasAvatar: !0,
  6011. syncToOthers: !0
  6012. });
  6013. case 15:
  6014. room = _context.sent;
  6015. debugger;
  6016. u();
  6017. c();
  6018. window.room = room;
  6019. e(!1);
  6020. _context.next = 28;
  6021. break;
  6022. case 23:
  6023. _context.prev = 23;
  6024. _context.t1 = _context["catch"](12);
  6025. console.error(_context.t1);
  6026. alert(_context.t1);
  6027. return _context.abrupt("return");
  6028. case 28:
  6029. case "end":
  6030. return _context.stop();
  6031. }
  6032. }
  6033. }, _callee, null, [[0, 5], [12, 23]]);
  6034. }));
  6035. return function l() {
  6036. return _ref.apply(this, arguments);
  6037. };
  6038. }();
  6039. var u = function u() {
  6040. room.on("_coreClick", function (_ref2) {
  6041. var f = _ref2.point;
  6042. room._userAvatar.moveTo({
  6043. point: f
  6044. });
  6045. });
  6046. };
  6047. var c = function c() {
  6048. room.on("repeatLogin", function () {
  6049. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  6050. duration: 1e4
  6051. });
  6052. }), room.on("reconnecting", function (_ref3) {
  6053. var f = _ref3.count;
  6054. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  6055. }), room.on("reconnected", function () {
  6056. toast("\u91CD\u8FDE\u6210\u529F");
  6057. }), room.on("disconnected", function () {
  6058. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  6059. duration: 1e5,
  6060. onClick() {
  6061. f.hideToast(), room.reconnect();
  6062. }
  6063. });
  6064. });
  6065. };
  6066. l();
  6067. }));
  6068. //# sourceMappingURL=index.js.map