index.js 338 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/11
  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$j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$k(); 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$k() { 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$j(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$1(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$1(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$1(o, minLen) {
  938. if (!o) return;
  939. if (typeof o === "string") return _arrayLikeToArray$1(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$1(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$1(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 = /*#__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();
  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$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$j(); 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$j() { 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$i(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$i() {
  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$i()) {
  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$h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); 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$h() { 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$h(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$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); 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$g() { 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$g(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$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$f(); 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$f() { 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$f(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$e(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$e(); 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$e() { 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$e(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$d(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$d(); 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$d() { 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$d(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. function _createSuper$c(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); }; }
  3151. 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; } }
  3152. var EventsManager = /*#__PURE__*/function (_EventEmitter) {
  3153. _inherits(EventsManager, _EventEmitter);
  3154. var _super = _createSuper$c(EventsManager);
  3155. function EventsManager() {
  3156. var _this;
  3157. _classCallCheck(this, EventsManager);
  3158. _this = _super.apply(this, arguments);
  3159. E(_assertThisInitialized(_this), "events", new Map());
  3160. E(_assertThisInitialized(_this), "specialEvents", new Map());
  3161. return _this;
  3162. }
  3163. _createClass(EventsManager, [{
  3164. key: "remove",
  3165. value: function remove(e, t, r, n) {
  3166. if (this.specialEvents.has(e) && !n && t === Codes$1.Success) return;
  3167. this.events.get(e) && (this.emit(e, {
  3168. code: t,
  3169. data: r
  3170. }), this.events.delete(e), this.specialEvents.delete(e));
  3171. }
  3172. }, {
  3173. key: "track",
  3174. value: function () {
  3175. var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  3176. var _this2 = this;
  3177. var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
  3178. return regenerator.wrap(function _callee$(_context) {
  3179. while (1) {
  3180. switch (_context.prev = _context.next) {
  3181. case 0:
  3182. r = e.traceId;
  3183. this.emitTraceIdToDecoder(e);
  3184. _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
  3185. if (!(n && Math.random() > n)) {
  3186. _context.next = 5;
  3187. break;
  3188. }
  3189. return _context.abrupt("return", Promise.resolve());
  3190. case 5:
  3191. s = Actions[e.event] + "Action", l = e.tag;
  3192. this.events.set(r, !0), a && this.specialEvents.set(r, !0);
  3193. u = Date.now();
  3194. c = null;
  3195. return _context.abrupt("return", new Promise(function (h, f) {
  3196. if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
  3197. _this2.on(r, function (_ref2) {
  3198. var _ = _ref2.code,
  3199. g = _ref2.data,
  3200. m = _ref2.msg;
  3201. if (_ === Codes$1.Success) h(g), _this2.off(r), logger.infoAndReportMeasurement({
  3202. metric: s,
  3203. tag: l,
  3204. extra: e.extra,
  3205. startTime: u,
  3206. traceId: r
  3207. });else {
  3208. if (_ === Codes$1.ActionMaybeDelay) return;
  3209. if (_ === Codes$1.DoActionBlocked && e.event === Actions.Rotation) {
  3210. logger.debug(s + " response code: " + _);
  3211. return;
  3212. }
  3213. var v = getErrorByCode(_),
  3214. y = new v(m);
  3215. _this2.off(r), f(y), _this2.emit("actionResponseError", {
  3216. error: y,
  3217. event: e,
  3218. tag: l
  3219. }), logger.infoAndReportMeasurement({
  3220. metric: s,
  3221. tag: l,
  3222. extra: e.extra,
  3223. error: y,
  3224. startTime: u,
  3225. traceId: r
  3226. });
  3227. }
  3228. });
  3229. var d = e.timeout || 2e3;
  3230. c = window.setTimeout(function () {
  3231. if (c && clearTimeout(c), !_this2.events.get(r)) return;
  3232. var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
  3233. _this2.emit("actionResponseTimeout", {
  3234. error: _,
  3235. event: e,
  3236. tag: l
  3237. }), f(_), _this2.events.delete(r), _this2.off(r), logger.infoAndReportMeasurement({
  3238. metric: s,
  3239. tag: l,
  3240. extra: e.extra,
  3241. error: _,
  3242. startTime: u,
  3243. traceId: r
  3244. });
  3245. }, d);
  3246. }));
  3247. case 10:
  3248. case "end":
  3249. return _context.stop();
  3250. }
  3251. }
  3252. }, _callee, this);
  3253. }));
  3254. function track(_x, _x2) {
  3255. return _track.apply(this, arguments);
  3256. }
  3257. return track;
  3258. }()
  3259. }, {
  3260. key: "emitTraceIdToDecoder",
  3261. value: function emitTraceIdToDecoder(e) {
  3262. if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
  3263. var t = {
  3264. [Actions.Rotation]: "Rotation",
  3265. [Actions.GetOnVehicle]: "GetOnVehicle",
  3266. [Actions.GetOffVehicle]: "GetOffVehicle",
  3267. [Actions.Clicking]: "MoveTo"
  3268. };
  3269. this.emit("traceId", {
  3270. traceId: e.traceId,
  3271. timestamp: Date.now(),
  3272. event: t[e.event]
  3273. });
  3274. }
  3275. }
  3276. }]);
  3277. return EventsManager;
  3278. }(EventEmitter);
  3279. var eventsManager = new EventsManager();
  3280. var ActionsHandler = /*#__PURE__*/function () {
  3281. function ActionsHandler(e) {
  3282. _classCallCheck(this, ActionsHandler);
  3283. this.currentActiveAction = null;
  3284. this.room = e;
  3285. }
  3286. _createClass(ActionsHandler, [{
  3287. key: "avatarComponentsSync",
  3288. value: function () {
  3289. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3290. var t;
  3291. return regenerator.wrap(function _callee$(_context) {
  3292. while (1) {
  3293. switch (_context.prev = _context.next) {
  3294. case 0:
  3295. t = {
  3296. action_type: Actions$1.SetPlayerState,
  3297. set_player_state_action: {
  3298. player_state: {
  3299. avatar_components: JSON.stringify(e)
  3300. }
  3301. }
  3302. };
  3303. this.sendData({
  3304. data: t
  3305. });
  3306. case 2:
  3307. case "end":
  3308. return _context.stop();
  3309. }
  3310. }
  3311. }, _callee, this);
  3312. }));
  3313. function avatarComponentsSync(_x) {
  3314. return _avatarComponentsSync.apply(this, arguments);
  3315. }
  3316. return avatarComponentsSync;
  3317. }()
  3318. }, {
  3319. key: "sendData",
  3320. value: function () {
  3321. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  3322. var _this = this;
  3323. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  3324. return regenerator.wrap(function _callee2$(_context2) {
  3325. while (1) {
  3326. switch (_context2.prev = _context2.next) {
  3327. case 0:
  3328. _context2.next = 2;
  3329. return this.beforeSend(e);
  3330. case 2:
  3331. t = uuid$1();
  3332. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  3333. trace_id: t,
  3334. user_id: this.room.options.userId
  3335. })), e.track === !1)) {
  3336. _context2.next = 5;
  3337. break;
  3338. }
  3339. return _context2.abrupt("return", Promise.resolve(null));
  3340. case 5:
  3341. _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;
  3342. return _context2.abrupt("return", eventsManager.track({
  3343. timeout: n,
  3344. traceId: t,
  3345. event: a.action_type,
  3346. tag: o,
  3347. extra: a
  3348. }, {
  3349. special: s,
  3350. sampleRate: r,
  3351. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  3352. }).finally(function () {
  3353. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  3354. }));
  3355. case 7:
  3356. case "end":
  3357. return _context2.stop();
  3358. }
  3359. }
  3360. }, _callee2, this);
  3361. }));
  3362. function sendData(_x2) {
  3363. return _sendData.apply(this, arguments);
  3364. }
  3365. return sendData;
  3366. }()
  3367. }, {
  3368. key: "beforeSend",
  3369. value: function () {
  3370. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3371. var o, t, r;
  3372. return regenerator.wrap(function _callee3$(_context3) {
  3373. while (1) {
  3374. switch (_context3.prev = _context3.next) {
  3375. case 0:
  3376. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  3377. if (!QueueActions.includes(r)) {
  3378. _context3.next = 5;
  3379. break;
  3380. }
  3381. if (!this.currentActiveAction) {
  3382. _context3.next = 4;
  3383. break;
  3384. }
  3385. return _context3.abrupt("return", (logger.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")))));
  3386. case 4:
  3387. this.currentActiveAction = r;
  3388. case 5:
  3389. if (!(t && QueueActions.includes(e.data.action_type))) {
  3390. _context3.next = 14;
  3391. break;
  3392. }
  3393. _context3.prev = 6;
  3394. _context3.next = 9;
  3395. return this.stopMoving();
  3396. case 9:
  3397. _context3.next = 14;
  3398. break;
  3399. case 11:
  3400. _context3.prev = 11;
  3401. _context3.t0 = _context3["catch"](6);
  3402. this.currentActiveAction = void 0, logger.error("before action stopMoving failed", _context3.t0);
  3403. case 14:
  3404. case "end":
  3405. return _context3.stop();
  3406. }
  3407. }
  3408. }, _callee3, this, [[6, 11]]);
  3409. }));
  3410. function beforeSend(_x3) {
  3411. return _beforeSend.apply(this, arguments);
  3412. }
  3413. return beforeSend;
  3414. }()
  3415. }, {
  3416. key: "moveTo",
  3417. value: function () {
  3418. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3419. var t, _e$extra, r, n, o;
  3420. return regenerator.wrap(function _callee4$(_context4) {
  3421. while (1) {
  3422. switch (_context4.prev = _context4.next) {
  3423. case 0:
  3424. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  3425. action_type: Actions$1.Clicking,
  3426. clicking_action: {
  3427. clicking_point: t,
  3428. clicking_type: ClickType.IgnoreView,
  3429. extra: encodeURIComponent(r),
  3430. attitude: n
  3431. },
  3432. clicking_state: this.room._currentClickingState
  3433. };
  3434. return _context4.abrupt("return", this.sendData({
  3435. data: o
  3436. }));
  3437. case 2:
  3438. case "end":
  3439. return _context4.stop();
  3440. }
  3441. }
  3442. }, _callee4, this);
  3443. }));
  3444. function moveTo(_x4) {
  3445. return _moveTo.apply(this, arguments);
  3446. }
  3447. return moveTo;
  3448. }()
  3449. }, {
  3450. key: "transfer",
  3451. value: function transfer(e) {
  3452. var _this2 = this;
  3453. var t = e.renderType,
  3454. r = e.player,
  3455. n = e.camera,
  3456. o = e.areaName,
  3457. a = e.attitude,
  3458. s = e.pathName,
  3459. l = e.person,
  3460. u = e.noMedia,
  3461. c = e.timeout,
  3462. h = e.tag,
  3463. f = e.special,
  3464. d = {
  3465. data: {
  3466. action_type: Actions$1.Transfer,
  3467. transfer_action: {
  3468. render_type: t,
  3469. player: r,
  3470. camera: n,
  3471. areaName: o,
  3472. attitude: a,
  3473. pathName: s,
  3474. person: {
  3475. type: l
  3476. },
  3477. noMedia: u,
  3478. tiles: [0, 1, 2, 4]
  3479. }
  3480. },
  3481. special: f,
  3482. timeout: c || 4e3,
  3483. tag: h
  3484. };
  3485. return this.sendData(d).then(function (_) {
  3486. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  3487. person: l,
  3488. rotationRenderType: t
  3489. }), _;
  3490. });
  3491. }
  3492. }, {
  3493. key: "changeRotationRenderType",
  3494. value: function changeRotationRenderType(e) {
  3495. var t = e.renderType,
  3496. r = e.player,
  3497. n = e.camera,
  3498. o = e.areaName,
  3499. a = e.attitude,
  3500. s = e.pathName;
  3501. return this.transfer({
  3502. renderType: t,
  3503. player: r,
  3504. camera: n,
  3505. areaName: o,
  3506. attitude: a,
  3507. pathName: s,
  3508. tag: "changeToRotationVideo"
  3509. });
  3510. }
  3511. }, {
  3512. key: "requestPanorama",
  3513. value: function requestPanorama(e, t, r) {
  3514. var n = e.camera,
  3515. o = e.player,
  3516. a = e.areaName,
  3517. s = e.attitude,
  3518. l = e.pathName,
  3519. u = e.tag;
  3520. return this.transfer({
  3521. renderType: RenderType.ClientRotationPano,
  3522. player: o,
  3523. camera: n,
  3524. person: Person.First,
  3525. areaName: a,
  3526. attitude: s,
  3527. pathName: l,
  3528. noMedia: t,
  3529. timeout: r,
  3530. tag: u || "requestPanorama",
  3531. special: !t
  3532. });
  3533. }
  3534. }, {
  3535. key: "setMotionType",
  3536. value: function setMotionType(e) {
  3537. return this.transfer({
  3538. attitude: e,
  3539. tag: "setMotionType"
  3540. });
  3541. }
  3542. }, {
  3543. key: "setNickName",
  3544. value: function setNickName(e) {
  3545. var t = {
  3546. action_type: Actions$1.ChangeNickname,
  3547. change_nickname_action: {
  3548. nickname: e
  3549. }
  3550. };
  3551. return this.sendData({
  3552. data: t
  3553. });
  3554. }
  3555. }, {
  3556. key: "getReserveSeat",
  3557. value: function getReserveSeat(_ref) {
  3558. var e = _ref.routeId,
  3559. t = _ref.name;
  3560. var r = {
  3561. action_type: Actions$1.ReserveSeat,
  3562. reserve_seat_action: {
  3563. route_id: e,
  3564. name: t
  3565. }
  3566. };
  3567. return this.sendData({
  3568. data: r
  3569. });
  3570. }
  3571. }, {
  3572. key: "getReserveStatus",
  3573. value: function getReserveStatus(_ref2) {
  3574. var e = _ref2.routeId,
  3575. t = _ref2.name,
  3576. r = _ref2.need_detail;
  3577. var n = {
  3578. action_type: Actions$1.GetReserveStatus,
  3579. get_reserve_status_action: {
  3580. route_id: e,
  3581. name: t,
  3582. need_detail: r
  3583. }
  3584. };
  3585. return this.sendData({
  3586. data: n,
  3587. timeout: 2e3
  3588. }).then(function (o) {
  3589. return o.reserveDetail;
  3590. });
  3591. }
  3592. }, {
  3593. key: "stopMoving",
  3594. value: function stopMoving() {
  3595. var e = {
  3596. action_type: Actions$1.StopMoving,
  3597. stop_move_action: {}
  3598. };
  3599. return this.sendData({
  3600. data: e
  3601. });
  3602. }
  3603. }, {
  3604. key: "getOnVehicle",
  3605. value: function getOnVehicle(_ref3) {
  3606. var e = _ref3.routeId,
  3607. t = _ref3.name,
  3608. r = _ref3.camera;
  3609. var n = {
  3610. action_type: Actions$1.GetOnVehicle,
  3611. get_on_vehicle_action: {
  3612. route_id: e,
  3613. name: t,
  3614. camera: r
  3615. }
  3616. };
  3617. return this.sendData({
  3618. data: n
  3619. });
  3620. }
  3621. }, {
  3622. key: "getOffVehicle",
  3623. value: function getOffVehicle(_ref4) {
  3624. var e = _ref4.renderType,
  3625. t = _ref4.player,
  3626. r = _ref4.camera;
  3627. var n = {
  3628. action_type: Actions$1.GetOffVehicle,
  3629. get_off_vehicle_action: {
  3630. render_type: e,
  3631. player: t,
  3632. camera: r
  3633. }
  3634. };
  3635. return this.sendData({
  3636. data: n
  3637. });
  3638. }
  3639. }, {
  3640. key: "confirmEvent",
  3641. value: function confirmEvent(e) {
  3642. var t = {
  3643. action_type: Actions$1.ConfirmEvent,
  3644. confirm_event_action: {
  3645. id: e
  3646. }
  3647. };
  3648. return this.sendData({
  3649. data: t,
  3650. track: !1
  3651. });
  3652. }
  3653. }, {
  3654. key: "echo",
  3655. value: function echo(e) {
  3656. var t = {
  3657. action_type: Actions$1.Echo,
  3658. echo_msg: {
  3659. echoMsg: e
  3660. }
  3661. };
  3662. return this.sendData({
  3663. data: t,
  3664. track: !1
  3665. });
  3666. }
  3667. }, {
  3668. key: "changeSkin",
  3669. value: function () {
  3670. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3671. var _this3 = this;
  3672. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  3673. return regenerator.wrap(function _callee6$(_context6) {
  3674. while (1) {
  3675. switch (_context6.prev = _context6.next) {
  3676. case 0:
  3677. 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) {
  3678. return y.id === r;
  3679. })[0];
  3680. if (m) {
  3681. _context6.next = 4;
  3682. break;
  3683. }
  3684. y = "skin ".concat(r, " is invalid");
  3685. return _context6.abrupt("return", (logger.error(y), Promise.reject(new ParamError(y))));
  3686. case 4:
  3687. v = {
  3688. action_type: Actions$1.ChangeSkin,
  3689. change_skin_action: {
  3690. skinID: r,
  3691. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  3692. skin_data_version: r + m.versionId,
  3693. landing_type: o,
  3694. landing_point: a,
  3695. landing_camera: s,
  3696. render_wrapper: {
  3697. render_type: l
  3698. },
  3699. areaName: u,
  3700. attitude: c,
  3701. noMedia: d,
  3702. person: f,
  3703. pathName: h,
  3704. roomTypeId: g
  3705. }
  3706. };
  3707. return _context6.abrupt("return", this.sendData({
  3708. data: v,
  3709. timeout: _ || 6e3,
  3710. special: t
  3711. }).then( /*#__PURE__*/function () {
  3712. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  3713. var b, _ref6, T;
  3714. return regenerator.wrap(function _callee5$(_context5) {
  3715. while (1) {
  3716. switch (_context5.prev = _context5.next) {
  3717. case 0:
  3718. if (!(l === RenderType.ClientRotationPano && y)) {
  3719. _context5.next = 8;
  3720. break;
  3721. }
  3722. _context5.next = 3;
  3723. return _this3.room.modelManager.findRoute(r, h);
  3724. case 3:
  3725. b = _context5.sent;
  3726. _ref6 = getRandomItem(b.birthPointList) || {};
  3727. T = _ref6.camera;
  3728. _context5.next = 8;
  3729. return _this3.room.panorama.handleReceivePanorama(y, T);
  3730. case 8:
  3731. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  3732. case 9:
  3733. case "end":
  3734. return _context5.stop();
  3735. }
  3736. }
  3737. }, _callee5);
  3738. }));
  3739. return function (_x6) {
  3740. return _ref5.apply(this, arguments);
  3741. };
  3742. }()).catch(function (y) {
  3743. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  3744. }));
  3745. case 6:
  3746. case "end":
  3747. return _context6.stop();
  3748. }
  3749. }
  3750. }, _callee6, this);
  3751. }));
  3752. function changeSkin(_x5) {
  3753. return _changeSkin.apply(this, arguments);
  3754. }
  3755. return changeSkin;
  3756. }()
  3757. }, {
  3758. key: "handleChangeSkin",
  3759. value: function handleChangeSkin(e) {
  3760. var _this4 = this;
  3761. var t = e.skinId,
  3762. r = e.mode,
  3763. n = e.renderType,
  3764. o = e.areaName,
  3765. a = e.attitude,
  3766. s = e.pathName;
  3767. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  3768. _this4.room.sceneManager.staticmeshComponent.getCgMesh().hide(), _this4.room.sceneManager.cameraComponent.switchToMainCamera(), _this4.room.pathManager.currentArea = o, logger.info("changeSkin _updateSkinAssets susccss"), _this4.room.updateCurrentNetworkOptions({
  3769. pathName: s,
  3770. attitude: a,
  3771. areaName: o
  3772. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  3773. skin: {
  3774. id: t
  3775. },
  3776. mode: r
  3777. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  3778. });
  3779. }
  3780. }, {
  3781. key: "rotate",
  3782. value: function rotate(_ref7) {
  3783. var e = _ref7.pitch,
  3784. t = _ref7.yaw;
  3785. var n;
  3786. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  3787. var r = {
  3788. action_type: Actions$1.Rotation,
  3789. rotation_action: {
  3790. vertical_move: e,
  3791. horizontal_move: -t
  3792. }
  3793. };
  3794. this.sendData({
  3795. data: r,
  3796. sampleRate: .02
  3797. });
  3798. }
  3799. }, {
  3800. key: "turnTo",
  3801. value: function turnTo(e) {
  3802. var _ref8 = e || {},
  3803. t = _ref8.point,
  3804. _ref8$timeout = _ref8.timeout,
  3805. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  3806. _ref8$offset = _ref8.offset,
  3807. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  3808. o = {
  3809. action_type: Actions$1.TurnTo,
  3810. turn_to_action: {
  3811. turn_to_point: t,
  3812. offset: n
  3813. }
  3814. };
  3815. return this.sendData({
  3816. data: o,
  3817. timeout: r
  3818. });
  3819. }
  3820. }, {
  3821. key: "rotateTo",
  3822. value: function rotateTo(e) {
  3823. var _ref9 = e || {},
  3824. t = _ref9.point,
  3825. _ref9$offset = _ref9.offset,
  3826. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  3827. _ref9$speed = _ref9.speed,
  3828. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  3829. o = {
  3830. action_type: Actions$1.RotateTo,
  3831. rotate_to_action: {
  3832. rotate_to_point: t,
  3833. offset: r,
  3834. speed: n
  3835. }
  3836. };
  3837. return this.sendData({
  3838. data: o
  3839. });
  3840. }
  3841. }, {
  3842. key: "broadcast",
  3843. value: function broadcast(e) {
  3844. var t = e.data,
  3845. _e$msgType = e.msgType,
  3846. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  3847. n = e.targetUserIds;
  3848. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  3849. var o = {
  3850. action_type: Actions$1.Broadcast,
  3851. broadcast_action: {
  3852. data: JSON.stringify(t),
  3853. user_id: this.room.options.userId,
  3854. msgType: r
  3855. }
  3856. };
  3857. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  3858. data: o,
  3859. tag: t.broadcastType
  3860. });
  3861. }
  3862. }, {
  3863. key: "getNeighborPoints",
  3864. value: function getNeighborPoints(e) {
  3865. var t = e.point,
  3866. _e$containSelf = e.containSelf,
  3867. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  3868. _e$searchRange = e.searchRange,
  3869. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  3870. o = {
  3871. action_type: Actions$1.GetNeighborPoints,
  3872. get_neighbor_points_action: {
  3873. point: t,
  3874. level: 1,
  3875. containSelf: r,
  3876. searchRange: n
  3877. }
  3878. };
  3879. return this.sendData({
  3880. data: o
  3881. }).then(function (a) {
  3882. return a.nps;
  3883. });
  3884. }
  3885. }, {
  3886. key: "playCG",
  3887. value: function playCG(e) {
  3888. var t = {
  3889. action_type: Actions$1.PlayCG,
  3890. play_cg_action: {
  3891. cg_name: e
  3892. }
  3893. };
  3894. return this.sendData({
  3895. data: t
  3896. });
  3897. }
  3898. }, {
  3899. key: "audienceToVisitor",
  3900. value: function audienceToVisitor(e) {
  3901. var t = e.avatarId,
  3902. r = e.avatarComponents,
  3903. n = e.player,
  3904. o = e.camera,
  3905. a = {
  3906. action_type: Actions$1.AudienceChangeToVisitor,
  3907. audienceChangeToVisitorAction: {
  3908. avatarID: t,
  3909. avatarComponents: r,
  3910. player: n,
  3911. camera: o
  3912. }
  3913. };
  3914. return logger.debug("send data: audience to visitor"), this.sendData({
  3915. data: a
  3916. });
  3917. }
  3918. }, {
  3919. key: "visitorToAudience",
  3920. value: function visitorToAudience(e) {
  3921. var t = e.renderType,
  3922. r = e.player,
  3923. n = e.camera,
  3924. o = e.areaName,
  3925. a = e.attitude,
  3926. s = e.pathName,
  3927. l = e.person,
  3928. u = e.noMedia,
  3929. c = {
  3930. action_type: Actions$1.VisitorChangeToAudience,
  3931. visitorChangeToAudienceAction: {
  3932. transferAction: {
  3933. render_type: t,
  3934. player: r,
  3935. camera: n,
  3936. areaName: o,
  3937. attitude: a,
  3938. pathName: s,
  3939. person: {
  3940. type: l
  3941. },
  3942. noMedia: u,
  3943. tiles: [0, 1, 2, 4]
  3944. }
  3945. }
  3946. };
  3947. return logger.debug("send data: visitor to audience"), this.sendData({
  3948. data: c
  3949. });
  3950. }
  3951. }, {
  3952. key: "removeVisitor",
  3953. value: function removeVisitor(e) {
  3954. var t = e.removeType,
  3955. r = e.userIDList,
  3956. _e$extraInfo = e.extraInfo,
  3957. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  3958. o = {
  3959. action_type: Actions$1.RemoveVisitor,
  3960. removeVisitorAction: {
  3961. removeVisitorEvent: t,
  3962. userIDList: r,
  3963. extraInfo: encodeURIComponent(n)
  3964. }
  3965. };
  3966. return logger.debug("send data: remove visitor"), this.sendData({
  3967. data: o
  3968. });
  3969. }
  3970. }, {
  3971. key: "getUserWithAvatar",
  3972. value: function getUserWithAvatar(e, t) {
  3973. var r = {
  3974. action_type: Actions$1.GetUserWithAvatar,
  3975. getUserWithAvatarAction: {
  3976. userType: e,
  3977. roomID: t
  3978. }
  3979. };
  3980. return logger.debug("send data: get user with avatar"), this.sendData({
  3981. data: r
  3982. }).then(function (n) {
  3983. return n.userWithAvatarList;
  3984. });
  3985. }
  3986. }, {
  3987. key: "joystick",
  3988. value: function joystick(e) {
  3989. var t = e.degree,
  3990. _e$level = e.level,
  3991. r = _e$level === void 0 ? 1 : _e$level,
  3992. n = uuid$1();
  3993. var o = -t + 90 + 360;
  3994. o >= 360 && (o -= 360);
  3995. var a = {
  3996. action_type: Actions$1.Joystick,
  3997. dir_action: {
  3998. move_angle: o,
  3999. speed_level: r
  4000. },
  4001. trace_id: n,
  4002. user_id: this.room.options.userId,
  4003. packet_id: n
  4004. };
  4005. return this.sendData({
  4006. data: a,
  4007. track: !1
  4008. });
  4009. }
  4010. }]);
  4011. return ActionsHandler;
  4012. }();
  4013. var Signal = /*#__PURE__*/function () {
  4014. function Signal(e) {
  4015. _classCallCheck(this, Signal);
  4016. this.signalHandleActived = !0;
  4017. this.isUpdatedYUV = !0;
  4018. this._room = e;
  4019. }
  4020. _createClass(Signal, [{
  4021. key: "handleSignal",
  4022. value: function handleSignal(e) {
  4023. var _this = this;
  4024. var a, s, l;
  4025. if (!this.signalHandleActived) return;
  4026. var t = e.signal,
  4027. r = e.alreadyUpdateYUV;
  4028. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  4029. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  4030. return c.userId === _this._room.userId;
  4031. });
  4032. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  4033. logger.debug("stream stoped, make avatar to stop");
  4034. var _u$renderInfo = u.renderInfo,
  4035. c = _u$renderInfo.isMoving,
  4036. h = _u$renderInfo.isRotating;
  4037. this._room.avatarManager._updateAvatarMovingStatus({
  4038. id: u.userId,
  4039. isMoving: !!c,
  4040. isRotating: !!h
  4041. });
  4042. }
  4043. return;
  4044. }
  4045. this.isUpdatedYUV = r;
  4046. var n = t;
  4047. if (!t) {
  4048. logger.warn("metadata signal is empty");
  4049. return;
  4050. }
  4051. if (n.code === Codes.RepeatLogin) {
  4052. this._room.handleRepetLogin();
  4053. return;
  4054. }
  4055. 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));
  4056. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  4057. return u.userId === _this._room.userId;
  4058. });
  4059. if (n.broadcastAction) try {
  4060. var _u = JSON.parse(n.broadcastAction.data);
  4061. Broadcast.handlers.forEach(function (c) {
  4062. return c(_u);
  4063. });
  4064. } catch (u) {
  4065. logger.error(u);
  4066. }
  4067. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  4068. this._room._currentClickingState = o.playerState;
  4069. var _o$playerState = o.playerState,
  4070. _u2 = _o$playerState.pathName,
  4071. _c = _o$playerState.attitude,
  4072. _h = _o$playerState.areaName,
  4073. f = _o$playerState.skinId;
  4074. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  4075. pathName: _u2
  4076. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  4077. areaName: _h
  4078. }), _c) {
  4079. var d = this._room.skin.routeList.find(function (g) {
  4080. return g.areaName === _this._room.currentState.areaName;
  4081. }),
  4082. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  4083. this._room.updateCurrentState({
  4084. speed: _,
  4085. attitude: _c
  4086. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  4087. }
  4088. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  4089. }
  4090. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  4091. var _u3 = n.actionType,
  4092. _c2 = n.code,
  4093. _h2 = n.echoMsg,
  4094. _f = n.traceId;
  4095. _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);
  4096. }
  4097. }
  4098. }, {
  4099. key: "handleActionResponses",
  4100. value: function handleActionResponses(e) {
  4101. var _this2 = this;
  4102. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  4103. if (t.actionType == null) return;
  4104. var r = t.pointType,
  4105. n = t.extra,
  4106. o = t.actionType,
  4107. a = t.traceId,
  4108. s = t.code,
  4109. l = t.msg;
  4110. 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));
  4111. });
  4112. }
  4113. }, {
  4114. key: "udpateSkinInfo",
  4115. value: function () {
  4116. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4117. var t;
  4118. return regenerator.wrap(function _callee$(_context) {
  4119. while (1) {
  4120. switch (_context.prev = _context.next) {
  4121. case 0:
  4122. this._room.updateCurrentState({
  4123. skinId: e
  4124. });
  4125. _context.next = 3;
  4126. return this._room.skinList.find(function (r) {
  4127. return r.id === e;
  4128. });
  4129. case 3:
  4130. t = _context.sent;
  4131. t && this._room.updateCurrentState({
  4132. skin: t
  4133. });
  4134. case 5:
  4135. case "end":
  4136. return _context.stop();
  4137. }
  4138. }
  4139. }, _callee, this);
  4140. }));
  4141. function udpateSkinInfo(_x) {
  4142. return _udpateSkinInfo.apply(this, arguments);
  4143. }
  4144. return udpateSkinInfo;
  4145. }()
  4146. }]);
  4147. return Signal;
  4148. }();
  4149. function _createSuper$b(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); }; }
  4150. 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; } }
  4151. var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
  4152. _inherits(XverseEffectManager, _EventEmitter);
  4153. var _super = _createSuper$b(XverseEffectManager);
  4154. function XverseEffectManager(e) {
  4155. var _this;
  4156. _classCallCheck(this, XverseEffectManager);
  4157. _this = _super.call(this);
  4158. E(_assertThisInitialized(_this), "effects", new Map());
  4159. E(_assertThisInitialized(_this), "room");
  4160. _this.room = e;
  4161. return _this;
  4162. }
  4163. _createClass(XverseEffectManager, [{
  4164. key: "addEffect",
  4165. value: function () {
  4166. var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4167. var o, t, r, _e$type, n, a;
  4168. return regenerator.wrap(function _callee$(_context) {
  4169. while (1) {
  4170. switch (_context.prev = _context.next) {
  4171. case 0:
  4172. t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
  4173. _context.prev = 1;
  4174. this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
  4175. a = new Ae.subEffect({
  4176. id: r,
  4177. jsonPath: t,
  4178. type: n,
  4179. room: this.room
  4180. });
  4181. this.effects.set(r, a);
  4182. _context.next = 7;
  4183. return a.init();
  4184. case 7:
  4185. return _context.abrupt("return", a);
  4186. case 10:
  4187. _context.prev = 10;
  4188. _context.t0 = _context["catch"](1);
  4189. return _context.abrupt("return", (this.effects.delete(r), logger.error(_context.t0), Promise.reject(_context.t0)));
  4190. case 13:
  4191. case "end":
  4192. return _context.stop();
  4193. }
  4194. }
  4195. }, _callee, this, [[1, 10]]);
  4196. }));
  4197. function addEffect(_x) {
  4198. return _addEffect.apply(this, arguments);
  4199. }
  4200. return addEffect;
  4201. }()
  4202. }, {
  4203. key: "clearEffects",
  4204. value: function clearEffects() {
  4205. var _this2 = this;
  4206. this.effects.forEach(function (e) {
  4207. e.dispose(), _this2.effects.delete(e.id);
  4208. });
  4209. }
  4210. }, {
  4211. key: "removeEffect",
  4212. value: function removeEffect(e) {
  4213. var t = this.effects.get(e);
  4214. t == null || t.dispose(), t && this.effects.delete(t.id);
  4215. }
  4216. }]);
  4217. return XverseEffectManager;
  4218. }(EventEmitter);
  4219. function _createSuper$a(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$a(); 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); }; }
  4220. function _isNativeReflectConstruct$a() { 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; } }
  4221. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  4222. _inherits(ParamError, _XverseError);
  4223. var _super = _createSuper$a(ParamError);
  4224. function ParamError(e) {
  4225. _classCallCheck(this, ParamError);
  4226. return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
  4227. }
  4228. return _createClass(ParamError);
  4229. }(XverseError);
  4230. var MotionType$1 = {
  4231. Walk: 'walk',
  4232. Run: 'run',
  4233. Fly: 'fly'
  4234. };
  4235. var Heartbeat = /*#__PURE__*/function () {
  4236. function Heartbeat(e) {
  4237. var _this = this;
  4238. _classCallCheck(this, Heartbeat);
  4239. E(this, "_interval", null);
  4240. E(this, "ping", function () {
  4241. var e = Date.now().toString();
  4242. _this.handler.ping(e);
  4243. });
  4244. this.handler = e;
  4245. }
  4246. _createClass(Heartbeat, [{
  4247. key: "ping",
  4248. value: function ping() {
  4249. var e = Date.now().toString();
  4250. this.handler.ping(e);
  4251. }
  4252. }, {
  4253. key: "start",
  4254. value: function start() {
  4255. this.stop(), logger.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
  4256. }
  4257. }, {
  4258. key: "stop",
  4259. value: function stop() {
  4260. logger.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
  4261. }
  4262. }, {
  4263. key: "pong",
  4264. value: function pong(e, t) {
  4265. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
  4266. }
  4267. }]);
  4268. return Heartbeat;
  4269. }();
  4270. var Timeout$1 = /*#__PURE__*/function () {
  4271. function Timeout(e, t) {
  4272. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  4273. _classCallCheck(this, Timeout);
  4274. this._timeout = null;
  4275. this._fn = e, this._delay = t, r && this.start();
  4276. }
  4277. _createClass(Timeout, [{
  4278. key: "delay",
  4279. get: function get() {
  4280. return this._delay;
  4281. }
  4282. }, {
  4283. key: "isSet",
  4284. get: function get() {
  4285. return !!this._timeout;
  4286. }
  4287. }, {
  4288. key: "setDelay",
  4289. value: function setDelay(e) {
  4290. this._delay = e;
  4291. }
  4292. }, {
  4293. key: "start",
  4294. value: function start() {
  4295. var _this = this;
  4296. this.isSet || (this._timeout = window.setTimeout(function () {
  4297. var e = _this._fn;
  4298. _this.clear(), e();
  4299. }, this._delay));
  4300. }
  4301. }, {
  4302. key: "clear",
  4303. value: function clear() {
  4304. window.clearTimeout(this._timeout), this._timeout = void 0;
  4305. }
  4306. }, {
  4307. key: "reset",
  4308. value: function reset() {
  4309. this.clear(), this.start();
  4310. }
  4311. }]);
  4312. return Timeout;
  4313. }();
  4314. 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); }; }
  4315. 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; } }
  4316. var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
  4317. _inherits(InitNetworkTimeoutError, _XverseError);
  4318. var _super = _createSuper$9(InitNetworkTimeoutError);
  4319. function InitNetworkTimeoutError(e) {
  4320. _classCallCheck(this, InitNetworkTimeoutError);
  4321. return _super.call(this, 1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6");
  4322. }
  4323. return _createClass(InitNetworkTimeoutError);
  4324. }(XverseError);
  4325. 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); }; }
  4326. 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; } }
  4327. var Socket = /*#__PURE__*/function (_EventEmitter) {
  4328. _inherits(Socket, _EventEmitter);
  4329. var _super = _createSuper$8(Socket);
  4330. function Socket(e) {
  4331. var _this;
  4332. _classCallCheck(this, Socket);
  4333. _this = _super.call(this);
  4334. E(_assertThisInitialized(_this), "_ws");
  4335. E(_assertThisInitialized(_this), "_openTimer");
  4336. E(_assertThisInitialized(_this), "connected", !1);
  4337. E(_assertThisInitialized(_this), "_hasTimeout", !1);
  4338. E(_assertThisInitialized(_this), "heartbeat");
  4339. E(_assertThisInitialized(_this), "latency", function (e, t) {
  4340. return _this.send({
  4341. id: "checkLatency",
  4342. data: JSON.stringify(e),
  4343. packet_id: t
  4344. });
  4345. });
  4346. E(_assertThisInitialized(_this), "send", function (e) {
  4347. if (_this.wsNoReady()) return;
  4348. var t = JSON.stringify(e);
  4349. e.id !== "heartbeat" && logger.info("send ws frame", t), _this._ws.send(t);
  4350. });
  4351. E(_assertThisInitialized(_this), "startGame", function () {
  4352. var _this$network$room$cu = _this.network.room.currentNetworkOptions,
  4353. e = _this$network$room$cu.roomId,
  4354. t = _this$network$room$cu.userId,
  4355. r = _this$network$room$cu.avatarId,
  4356. n = _this$network$room$cu.skinId,
  4357. o = _this$network$room$cu.role,
  4358. a = _this$network$room$cu.avatarComponents,
  4359. s = _this$network$room$cu.versionId,
  4360. l = _this$network$room$cu.rotationRenderType,
  4361. u = _this$network$room$cu.isAllSync,
  4362. c = _this$network$room$cu.nickname,
  4363. h = _this$network$room$cu.avatarScale,
  4364. f = _this$network$room$cu.appId,
  4365. d = _this$network$room$cu.camera,
  4366. _ = _this$network$room$cu.player,
  4367. g = _this$network$room$cu.firends,
  4368. m = _this$network$room$cu.syncByEvent,
  4369. v = _this$network$room$cu.areaName,
  4370. y = _this$network$room$cu.attitude,
  4371. b = _this$network$room$cu.pathName,
  4372. T = _this$network$room$cu.person,
  4373. _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
  4374. C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
  4375. A = _this$network$room$cu.syncToOthers,
  4376. S = _this$network$room$cu.hasAvatar,
  4377. P = _this$network$room$cu.prioritySync,
  4378. _this$network$room$cu3 = _this$network$room$cu.extra,
  4379. R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
  4380. M = _this$network$room$cu.removeWhenDisconnected;
  4381. R.removeWhenDisconnected = M;
  4382. var x = {
  4383. id: "start",
  4384. room_id: e,
  4385. user_id: t,
  4386. trace_id: uuid$1(),
  4387. data: JSON.stringify({
  4388. avatar_components: JSON.stringify(a),
  4389. avatar_id: r,
  4390. skin_id: n,
  4391. is_host: o ? o == "host" : !0,
  4392. skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
  4393. rotation_render_type: l,
  4394. is_all_sync: u,
  4395. nick_name: encodeURIComponent(c || ""),
  4396. app_id: f,
  4397. camera: d,
  4398. player: _,
  4399. person: T,
  4400. firends: JSON.stringify(g),
  4401. sync_by_event: m,
  4402. area_name: v,
  4403. path_name: b,
  4404. attitude: y,
  4405. room_type_id: C,
  4406. syncToOthers: A,
  4407. hasAvatar: S,
  4408. avatarSize: h,
  4409. prioritySync: P,
  4410. extra: JSON.stringify(R)
  4411. })
  4412. };
  4413. _this.send(x), logger.warn("startGame", le(oe({}, x), {
  4414. data: JSON.parse(x.data)
  4415. }));
  4416. });
  4417. _this.network = e, _this.heartbeat = new Heartbeat({
  4418. ping: function ping(t) {
  4419. var r;
  4420. if (!_this.connected) {
  4421. _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
  4422. rtt: 0
  4423. });
  4424. return;
  4425. }
  4426. _this.send({
  4427. id: "heartbeat",
  4428. data: t
  4429. });
  4430. },
  4431. pong(t) {
  4432. var r;
  4433. (r = e.room.stats) == null || r.assign({
  4434. rtt: t
  4435. });
  4436. }
  4437. });
  4438. return _this;
  4439. }
  4440. _createClass(Socket, [{
  4441. key: "connection",
  4442. get: function get() {
  4443. return this._ws;
  4444. }
  4445. }, {
  4446. key: "start",
  4447. value: function start() {
  4448. var _this2 = this;
  4449. this._hasTimeout = !1;
  4450. var e = this.getAddress();
  4451. logger.info("connecting to ".concat(e));
  4452. var t = Date.now();
  4453. this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
  4454. var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
  4455. _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
  4456. }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
  4457. var r;
  4458. (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger.infoAndReportMeasurement({
  4459. metric: "wsOpenedAt",
  4460. group: "joinRoom",
  4461. startTime: _this2.network.room._startTime
  4462. }), logger.infoAndReportMeasurement({
  4463. metric: "wsOpenedCost",
  4464. group: "joinRoom",
  4465. startTime: t
  4466. }));
  4467. }, this.handleWSEvent();
  4468. }
  4469. }, {
  4470. key: "getAddress",
  4471. value: function getAddress() {
  4472. var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
  4473. e = _this$network$room$cu4.wsServerUrl,
  4474. t = _this$network$room$cu4.reconnect,
  4475. r = _this$network$room$cu4.sessionId,
  4476. n = _this$network$room$cu4.token,
  4477. o = _this$network$room$cu4.roomId,
  4478. a = _this$network$room$cu4.userId,
  4479. s = _this$network$room$cu4.pageSession,
  4480. l = this.network.room.skinId;
  4481. var u = e;
  4482. t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
  4483. var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
  4484. return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
  4485. }
  4486. }, {
  4487. key: "handleWSEvent",
  4488. value: function handleWSEvent() {
  4489. var _this3 = this;
  4490. var e = this._ws;
  4491. e.addEventListener("error", function (t) {
  4492. _this3.connected = !1, logger.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
  4493. }), e.addEventListener("close", function (t) {
  4494. _this3.connected = !1, _this3._onClose(t);
  4495. }), e.addEventListener("message", function (t) {
  4496. if (!t || _this3._hasTimeout || !_this3.connected) return;
  4497. var r = null;
  4498. try {
  4499. r = JSON.parse(t.data);
  4500. } catch (o) {
  4501. logger.error(o);
  4502. return;
  4503. }
  4504. if (!r) return;
  4505. var n = r.id;
  4506. if (!!n) switch (n !== "heartbeat" && logger.info("receive ws frame: ".concat(t.data)), n) {
  4507. case "fail":
  4508. break;
  4509. case "init":
  4510. try {
  4511. var o = r.data.slice(-37, -1);
  4512. reporter$1.updateBody({
  4513. serverSession: o
  4514. });
  4515. } catch (o) {
  4516. console.error(o);
  4517. }
  4518. _this3.network.rtcp.start();
  4519. break;
  4520. case "heartbeat":
  4521. _this3.heartbeat.pong(r.data);
  4522. break;
  4523. case "offer":
  4524. _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
  4525. break;
  4526. case "ice_candidate":
  4527. _this3.network.rtcp.addCandidate(r.data);
  4528. break;
  4529. case "start":
  4530. _this3.emit("gameRoomAvailable", r);
  4531. break;
  4532. case "error":
  4533. try {
  4534. var _JSON$parse = JSON.parse(r.data),
  4535. _o = _JSON$parse.Code,
  4536. a = _JSON$parse.Msg;
  4537. if (_o) {
  4538. if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
  4539. if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
  4540. {
  4541. var s = getErrorByCode(_o);
  4542. _this3.emit("socketClosed", new s(a));
  4543. }
  4544. }
  4545. } catch (o) {
  4546. logger.error(o), _this3.emit("socketClosed", new InternalError(r.data));
  4547. }
  4548. break;
  4549. case "checkLatency":
  4550. {
  4551. var _o2 = r.packet_id,
  4552. _a = r.data.split(",");
  4553. _this3.onLatencyCheck({
  4554. packetId: _o2,
  4555. addresses: _a
  4556. });
  4557. break;
  4558. }
  4559. default:
  4560. logger.warn("unkown ws message type", n, r);
  4561. }
  4562. });
  4563. }
  4564. }, {
  4565. key: "onLatencyCheck",
  4566. value: function onLatencyCheck(e) {
  4567. var _this4 = this;
  4568. var t = _toConsumableArray(new Set(e.addresses || []));
  4569. Promise.all(t.map(function (r) {
  4570. return {
  4571. [r]: 9999
  4572. };
  4573. })).then(function (r) {
  4574. var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
  4575. _this4.latency(n, e.packetId);
  4576. });
  4577. }
  4578. }, {
  4579. key: "wsNoReady",
  4580. value: function wsNoReady() {
  4581. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
  4582. }
  4583. }, {
  4584. key: "prepareReconnect",
  4585. value: function prepareReconnect() {
  4586. this._close({
  4587. code: WS_CLOSE_RECONNECT,
  4588. reason: "reconnect"
  4589. });
  4590. }
  4591. }, {
  4592. key: "_onClose",
  4593. value: function _onClose(_ref) {
  4594. var e = _ref.code,
  4595. t = _ref.reason;
  4596. this._openTimer && this._openTimer.clear(), logger.warn("ws closed: ".concat(e, " ") + t), [WS_CLOSE_RECONNECT, WS_CLOSE_NORMAL].includes(e) || this.emit("socketClosed", new InternalError("Websocket error"));
  4597. }
  4598. }, {
  4599. key: "_close",
  4600. value: function _close(_ref2) {
  4601. var e = _ref2.code,
  4602. t = _ref2.reason;
  4603. var r;
  4604. (r = this._ws) == null || r.close(e, t);
  4605. }
  4606. }, {
  4607. key: "quit",
  4608. value: function quit() {
  4609. this._close({
  4610. code: WS_CLOSE_NORMAL,
  4611. reason: "quit"
  4612. });
  4613. }
  4614. }]);
  4615. return Socket;
  4616. }(EventEmitter);
  4617. function add(i, e) {
  4618. return e == -1 && (e = 0), i + e;
  4619. }
  4620. function max(i, e) {
  4621. return Math.max(i, e);
  4622. }
  4623. function count_sd(i, e) {
  4624. function t(r, n) {
  4625. var o = 0;
  4626. return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
  4627. }
  4628. return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
  4629. }
  4630. function count_valid(i, e) {
  4631. var t = 0;
  4632. return e != -1 && (t = 1), i + t;
  4633. }
  4634. function count_less(i, e) {
  4635. function t(r, n) {
  4636. var o = 0;
  4637. return n != -1 && n < e && (o = 1), r + o;
  4638. }
  4639. return i.reduce(t, 0);
  4640. }
  4641. var CircularArray = /*#__PURE__*/function () {
  4642. function CircularArray(e, t, r) {
  4643. _classCallCheck(this, CircularArray);
  4644. this.sum = 0, this.incomingSum = 0, this.count = 0, this.incomingCount = 0, this.max = 0, this.incomingMax = 0, this.goodLess = 0, this.wellLess = 0, this.fairLess = 0, this.badLess = 0, this.countLess = !1, this.lessThreshes = [], this.incomingData = [], this.circularData = Array(e).fill(-1), this.circularPtr = 0, this.circularLength = e, t && (this.countLess = !0, this.lessThreshes = r);
  4645. }
  4646. _createClass(CircularArray, [{
  4647. key: "add",
  4648. value: function add(e) {
  4649. this.circularData[this.circularPtr] != -1 ? (this.sum -= this.circularData[this.circularPtr], Math.abs(this.circularData[this.circularPtr] - this.max) < .01 && (this.circularData[this.circularPtr] = -1, this.max = this.getMax(!1))) : this.count += 1, this.sum += e, this.incomingSum += e, this.incomingCount += 1, this.max < e && (this.max = e), this.incomingMax < e && (this.incomingMax = e), this.circularData[this.circularPtr] = e, this.circularPtr = (this.circularPtr + 1) % this.circularLength, this.incomingData.push(e), this.incomingData.length > this.circularLength && (this.clearIncoming(), this.incomingCount = 0, this.incomingSum = 0);
  4650. }
  4651. }, {
  4652. key: "computeAvg",
  4653. value: function computeAvg(e) {
  4654. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
  4655. }
  4656. }, {
  4657. key: "computeMax",
  4658. value: function computeMax(e) {
  4659. return e.reduce(max, 0) || 0;
  4660. }
  4661. }, {
  4662. key: "computeThreshPercent",
  4663. value: function computeThreshPercent(e) {
  4664. if (this.countLess) {
  4665. var t = count_less(e, this.lessThreshes[0]) || 0,
  4666. r = count_less(e, this.lessThreshes[1]) || 0,
  4667. n = count_less(e, this.lessThreshes[2]) || 0,
  4668. o = count_less(e, this.lessThreshes[3]) || 0,
  4669. a = e.reduce(count_valid, 0);
  4670. return [t, r, n, o, a];
  4671. } else return [0, 0, 0, 0, 0];
  4672. }
  4673. }, {
  4674. key: "getAvg",
  4675. value: function getAvg() {
  4676. var e = this.sum / this.count || 0,
  4677. t = this.computeAvg(this.circularData) || 0;
  4678. return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
  4679. }
  4680. }, {
  4681. key: "getMax",
  4682. value: function getMax() {
  4683. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  4684. var t = this.computeMax(this.circularData) || 0;
  4685. return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
  4686. }
  4687. }, {
  4688. key: "getStandardDeviation",
  4689. value: function getStandardDeviation() {
  4690. return count_sd(this.circularData, this.getAvg());
  4691. }
  4692. }, {
  4693. key: "getThreshPercent",
  4694. value: function getThreshPercent() {
  4695. return this.computeThreshPercent(this.circularData);
  4696. }
  4697. }, {
  4698. key: "getIncomingMax",
  4699. value: function getIncomingMax() {
  4700. return this.computeMax(this.incomingData) || 0;
  4701. }
  4702. }, {
  4703. key: "getIncomingAvg",
  4704. value: function getIncomingAvg() {
  4705. return this.computeAvg(this.incomingData) || 0;
  4706. }
  4707. }, {
  4708. key: "getIncomingStandardDeviation",
  4709. value: function getIncomingStandardDeviation() {
  4710. return count_sd(this.incomingData, this.getIncomingAvg());
  4711. }
  4712. }, {
  4713. key: "getIncomingThreshPercent",
  4714. value: function getIncomingThreshPercent() {
  4715. return this.computeThreshPercent(this.incomingData);
  4716. }
  4717. }, {
  4718. key: "clearFastComputeItem",
  4719. value: function clearFastComputeItem() {
  4720. this.sum = 0, this.incomingSum = 0, this.count = 0, this.incomingCount = 0, this.max = 0, this.incomingMax = 0, this.goodLess = 0, this.wellLess = 0, this.fairLess = 0, this.badLess = 0;
  4721. }
  4722. }, {
  4723. key: "clearIncoming",
  4724. value: function clearIncoming() {
  4725. for (; this.incomingData.length > 0;) {
  4726. this.incomingData.pop();
  4727. }
  4728. }
  4729. }, {
  4730. key: "clear",
  4731. value: function clear() {
  4732. this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
  4733. }
  4734. }]);
  4735. return CircularArray;
  4736. }();
  4737. function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  4738. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4739. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  4740. var defaultLogger = {
  4741. info: console.log,
  4742. debug: console.log,
  4743. error: console.error,
  4744. infoAndReportMeasurement: function infoAndReportMeasurement() {}
  4745. };
  4746. var USER_ID = "987412365",
  4747. PAGE_SESSION = "aaabbbccc",
  4748. SERVER_SESSION = "cccbbbaaa",
  4749. COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
  4750. FRAME_COMPOSE_LENGTH = 5;
  4751. var Workers = /*#__PURE__*/function () {
  4752. function Workers(e, t) {
  4753. var _this = this;
  4754. _classCallCheck(this, Workers);
  4755. this.rtcp = e, this.cacheSize = 0, this.cacheBuffer = new Uint8Array(262144), this.cacheFrameCnt = 0, this.startReceiveTime = 0, this.cacheFrameComposes = new Array(0), this.cacheSizes = new Array(5).fill(0), this.cacheFrameCnts = new Array(5).fill(-1), this.cacheStartReceiveTimes = new Array(5).fill(0), this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)], this.panoCacheSize = 0, this.panoCacheBuffer = new Uint8Array(2097152), this.cachePanoTileID = 0, this.receivedMedia = 0, this.receivedMedia_worker = 0, this.receivedYUV = 0, this.receivedEmit = 0, this.returnFrames = 0, this.lastReturnFrames = 0, this.lastReceivedEmit = 0, this.mediaBytesReceived = 0, this.metaBytesReceived = 0, this.noWasmBytesReceived = 0, this.rtcBytesReceived = 0, this.rtcMessageReceived = 0, this.packetsDrop = 0, this.framesAwait = 0, this.sendOutBuffer = 0, this.decodeTimePerFrame = 0, this.decodeTimeMaxFrame = 0, this.lastRenderTs = 0, this.JankTimes = 0, this.bigJankTimes = 0, this.DecodeJankTimes = 0, this.bigDecodeJankTimes = 0, this.saveframe = !1, this.SaveMediaStream = !1, this.packetsLost = 0, this.showAllReceivedMetadata = !1, this.firstMediaArraval = 0, this.firstMediaReceived = !1, this.firstYUVDecoded = 0, this.firstRender = 0, this.firstYUVReceived = !1, this.reconnectSignal = !1, this.serverFrameSlow = 0, this.serverFrameFast = 0, this.clientFrameSlow = 0, this.clientFrameFast = 0, this.lastServerTS = 0, this.lastClientTS = 0, this.lastSeq = 0, this.lastIsPureMeta = !1, this.lastHBPacketTs = 0, this.HBPacketInterval = 0, this.lastHBPacketSrvSentTs = 0, this.HBPacketIntervalSrvSent = 0, this.cachedLength = 2, this.cachedStreams = new Array(this.cachedLength), this.cachedMetas = new Array(this.cachedLength), this.cachedPtss = new Array(this.cachedLength), this.cachedRender = Array(this.cachedLength).fill(!1), this.cachedResolution = new Array(this.cachedLength), this.getPtr = 0, this.setPtr = 0, this.receiveIframes = 0, this.decodeIframes = 0, this.prevSenderTs = -1, this.serverSendTimeArray = new CircularArray(120, !1, []), this.inPanoMode = !1, this.PanoStatus = {
  4756. x: 0,
  4757. y: 0,
  4758. z: 0,
  4759. tiles: []
  4760. }, this.DynamicPanoTest = !1, this.PanoMask = new ArrayBuffer(8), this.PanoView = new DataView(this.PanoMask), this.userId_test = "", this.PendingMasks = [], this.traceIdMap = new Map(), this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [], this.responseMiss = 0, this.processMiss = 0, this.displayMiss = 0, this.updateYUVCircular = new CircularArray(120, !1, []), this.updateDropFrame = 0, this.metaParseAraay = [], this.responseMoveMiss = 0, this.processMoveMiss = 0, this.displayMoveMiss = 0, this.MovingTraceId = "", this.PendingMovingTraceId = "", this.inMovingMode = !1, this.StartMovingTs = 0, this.PendingStartMovingTs = 0, this.moveEvent = "", this.MoveToFrameCnt = 0, this.lastIsMoving = 0, this.MoveResponseDelay = 0, this.MoveProcessDelay = 0, this.MoveDisplayDelay = 0, this.lastMoveResponseTime = 0, this.lastMoveProcessTime = 0, this.lastMoveDisplayTime = 0, this.moveResponseCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveProcessCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveDisplayCircular = new CircularArray(120, !0, [STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]), this.moveStartPts = -1, this.frameServerCircular = new CircularArray(120, !1, []), this.srvMetaIntervalCircular = new CircularArray(120, !1, []), this.srvMediaIntervalCircular = new CircularArray(120, !1, []), this.srvHBMetaIntervalCircular = new CircularArray(120, !1, []), this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120, !1, []), this.frameClientCircular = new CircularArray(120, !1, []), this.firstUpdateYUV = !0, this.functionMap = new Map(), this.WASM_VERSION = "WASM-1.1", this.frameHistory = [], this.getVersion = function () {
  4761. return DECODER_VERSION;
  4762. }, this.downloadBlob = function (r, n, o) {
  4763. var a = new Blob([r], {
  4764. type: o
  4765. }),
  4766. s = window.URL.createObjectURL(a);
  4767. _this.downloadURL(s, n), setTimeout(function () {
  4768. return window.URL.revokeObjectURL(s);
  4769. }, 1e3);
  4770. }, this.downloadURL = function (r, n) {
  4771. var o = document.createElement("a");
  4772. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  4773. }, this.Stringify = function (r) {
  4774. var n = "";
  4775. for (var a = 0; a < r.length / 8192; a++) {
  4776. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  4777. }
  4778. return n;
  4779. }, this._rtcp = e;
  4780. }
  4781. _createClass(Workers, [{
  4782. key: "registerLogger",
  4783. value: function registerLogger(e) {//defaultLogger = e
  4784. }
  4785. }, {
  4786. key: "registerFunction",
  4787. value: function registerFunction(e, t) {
  4788. this.functionMap.set(e, t);
  4789. }
  4790. }, {
  4791. key: "hasFrmCntInCache",
  4792. value: function hasFrmCntInCache(e) {
  4793. var t = -1;
  4794. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  4795. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  4796. }
  4797. return t;
  4798. }
  4799. }, {
  4800. key: "requestPanoramaTest",
  4801. value: function requestPanoramaTest(e, t, r, n, o) {
  4802. var a = o,
  4803. s = {
  4804. action_type: 16,
  4805. change_rotation_render_type_action: {
  4806. render_type: 5,
  4807. player: {
  4808. position: {
  4809. x: 0,
  4810. y: 0,
  4811. z: 0
  4812. },
  4813. angle: {
  4814. yaw: 0,
  4815. pitch: 0,
  4816. roll: 0
  4817. }
  4818. },
  4819. camera: {
  4820. position: {
  4821. x: e,
  4822. y: t,
  4823. z: r
  4824. },
  4825. angle: {
  4826. yaw: 0,
  4827. pitch: 0,
  4828. roll: 0
  4829. }
  4830. },
  4831. client_pano_titles_bitmap: n
  4832. },
  4833. trace_id: a,
  4834. user_id: this.userId_test,
  4835. packet_id: a
  4836. };
  4837. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  4838. }
  4839. }, {
  4840. key: "onRotateInPanoMode",
  4841. value: function onRotateInPanoMode(e) {
  4842. var t = e.traceId,
  4843. r = {};
  4844. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  4845. yaw: 100,
  4846. pitch: 30
  4847. };
  4848. var n = new ArrayBuffer(8),
  4849. o = new DataView(n);
  4850. getTilesInView(r, n);
  4851. var a = n.slice(0);
  4852. this.PendingMasks.unshift({
  4853. buffer: a,
  4854. angle: r.angle
  4855. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  4856. return s ^ s & l;
  4857. }), this.requestPanoramaTest(0, 0, 0, [o.getUint8(0), o.getUint8(1), o.getUint8(2), o.getUint8(3), o.getUint8(4), o.getUint8(5), o.getUint8(6), o.getUint8(7)], t);
  4858. }
  4859. }, {
  4860. key: "processMetaWithTraceId",
  4861. value: function processMetaWithTraceId(e) {
  4862. var _iterator = _createForOfIteratorHelper(e.traceIds),
  4863. _step;
  4864. try {
  4865. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4866. var t = _step.value;
  4867. if (this.traceIdMap.has(t)) {
  4868. var r = this.traceIdMap.get(t);
  4869. r != null && (r.receiveTime = Date.now(), r.status = 1);
  4870. }
  4871. if (t == this.PendingMovingTraceId) {
  4872. this.inMovingMode = !0, this.MovingTraceId = this.PendingMovingTraceId, this.StartMovingTs = this.PendingStartMovingTs, this.PendingMovingTraceId = "", this.PendingStartMovingTs = 0, defaultLogger.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
  4873. var _r = Date.now();
  4874. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  4875. }
  4876. }
  4877. } catch (err) {
  4878. _iterator.e(err);
  4879. } finally {
  4880. _iterator.f();
  4881. }
  4882. }
  4883. }, {
  4884. key: "onTraceId",
  4885. value: function onTraceId(e) {
  4886. var _this2 = this;
  4887. var r = e.traceId,
  4888. n = e.timestamp,
  4889. o = e.event;
  4890. if (o === "Rotation") {
  4891. var a = {
  4892. traceId: r,
  4893. pts: 0,
  4894. startTime: n,
  4895. receiveTime: 0,
  4896. readyTime: 0,
  4897. displayTime: 0,
  4898. status: 0
  4899. };
  4900. this.traceIdMap.set(r, a);
  4901. var s = setTimeout(function () {
  4902. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  4903. var l = _this2.traceIdMap.get(r);
  4904. switch (l == null ? void 0 : l.status) {
  4905. case 0:
  4906. {
  4907. _this2.responseMiss += 1;
  4908. break;
  4909. }
  4910. case 1:
  4911. {
  4912. _this2.processMiss += 1;
  4913. var u = l.receiveTime - l.startTime;
  4914. _this2.responseTimeArray.push(u);
  4915. break;
  4916. }
  4917. case 2:
  4918. {
  4919. _this2.displayMiss += 1;
  4920. var _u = l.receiveTime - l.startTime,
  4921. c = l.readyTime - l.receiveTime;
  4922. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  4923. break;
  4924. }
  4925. case 3:
  4926. defaultLogger.debug("status is 3");
  4927. }
  4928. }
  4929. }, 1e3);
  4930. } else o === "MoveTo" ? (defaultLogger.info("receive moveto traceId ", r, " at timestamp", n), this.PendingMovingTraceId = r, this.PendingStartMovingTs = n, this.moveEvent = o, this.frameServerCircular.clear()) : o === "GetOnAirship" || o === "GetOnVehicle" ? (defaultLogger.info("receive airship traceId ", r, " at timestamp ", n), this.PendingMovingTraceId = r, this.PendingStartMovingTs = n, this.moveEvent = o, this.frameServerCircular.clear()) : (o === "GetOffAirship" || o === "GetOffVehicle") && this.clearMoveArray();
  4931. }
  4932. }, {
  4933. key: "executeFunction",
  4934. value: function executeFunction(e, t) {
  4935. if (this.functionMap.has(e)) {
  4936. var r = this.functionMap.get(e);
  4937. r != null && r(t);
  4938. }
  4939. }
  4940. }, {
  4941. key: "UpdateStats",
  4942. value: function UpdateStats(e) {
  4943. var _this3 = this;
  4944. var t;
  4945. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  4946. r.forEach(function (n) {
  4947. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  4948. });
  4949. }), this.receivedMedia_worker = e.data.framesReceived, this.receivedYUV = e.data.framesDecoded, this.receivedEmit = e.data.framesRendered, this.mediaBytesReceived = e.data.mediaBytesReceived, this.metaBytesReceived = e.data.metaBytesReceived, this.packetsLost = e.data.packetsLost, this.packetsDrop = e.data.packetsDrop, this.framesAwait = e.data.framesAwait, this.decodeTimePerFrame = e.data.decodeTimePerFrame, this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame, this.returnFrames = e.data.framesReturned, this.sendOutBuffer = e.data.sendOutBuffer, this.DecodeJankTimes = e.data.JankTimes, this.bigDecodeJankTimes = e.data.bigJankTimes, this.receiveIframes = e.data.receivedIframe, this.decodeIframes = e.data.decodedIframe;
  4950. }
  4951. }, {
  4952. key: "ReceiveDecodeMessage",
  4953. value: function ReceiveDecodeMessage(e) {
  4954. var n;
  4955. if (!this.firstYUVReceived) {
  4956. this.firstYUVDecoded = e.data.yuv_ts;
  4957. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  4958. defaultLogger.infoAndReportMeasurement({
  4959. metric: "firstYUVDecodedAt",
  4960. value: o,
  4961. group: "joinRoom"
  4962. }), this.firstRender = Date.now();
  4963. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  4964. defaultLogger.infoAndReportMeasurement({
  4965. metric: "firstRenderAt",
  4966. value: a,
  4967. group: "joinRoom"
  4968. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  4969. }
  4970. !this.cachedRender[this.setPtr] && this.cachedMetas[this.setPtr] != null && (this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0 && (e.data.data == null ? (this.executeFunction("stream", {
  4971. stream: this.cachedStreams[this.setPtr],
  4972. width: this.cachedResolution[this.setPtr].width,
  4973. height: this.cachedResolution[this.setPtr].height,
  4974. pts: this.cachedPtss[this.setPtr]
  4975. }), this.executeFunction("signal", {
  4976. signal: this.cachedMetas[this.setPtr],
  4977. pts: this.cachedPtss[this.setPtr],
  4978. alreadyUpdateYUV: !0
  4979. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  4980. t: 2,
  4981. frameCnt: this.cachedPtss[this.setPtr],
  4982. buffer: this.cachedStreams[this.setPtr]
  4983. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  4984. var t = e.data.metadata;
  4985. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  4986. var _iterator2 = _createForOfIteratorHelper(t.traceIds),
  4987. _step2;
  4988. try {
  4989. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  4990. var _o = _step2.value;
  4991. if (this.traceIdMap.has(_o)) {
  4992. var _a = this.traceIdMap.get(_o);
  4993. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  4994. }
  4995. }
  4996. } catch (err) {
  4997. _iterator2.e(err);
  4998. } finally {
  4999. _iterator2.f();
  5000. }
  5001. }
  5002. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  5003. var _o2 = Date.now(),
  5004. _a2 = _o2 - this.lastMoveProcessTime;
  5005. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  5006. }
  5007. var r = this.setPtr;
  5008. this.cachedStreams[r] = e.data.data, this.cachedMetas[r] = e.data.metadata, this.cachedPtss[r] = e.data.pts, this.cachedRender[r] = !1, this.cachedResolution[r] = {
  5009. width: e.data.width,
  5010. height: e.data.height
  5011. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  5012. }
  5013. }, {
  5014. key: "SendCacheFrameInfo",
  5015. value: function SendCacheFrameInfo(e) {
  5016. var _this4 = this;
  5017. var h, f, d, _, g, m, v;
  5018. var t = e.data.cachedKey,
  5019. r = e.data.metadata,
  5020. n = t,
  5021. o = r,
  5022. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  5023. return y.userId === _this4.rtcp.network.room.userId;
  5024. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  5025. s = this.rtcp.network.room.skinId,
  5026. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  5027. return y.userId === _this4._rtcp.network.room.userId;
  5028. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  5029. u = {
  5030. MsgType: 1,
  5031. FrameCacheMsg: {
  5032. FrameIndex: n,
  5033. RoomTypeId: a,
  5034. SkinID: s,
  5035. Position: l
  5036. }
  5037. };
  5038. var c = "";
  5039. try {
  5040. c = JSON.stringify(u);
  5041. } catch (y) {
  5042. defaultLogger.error(y);
  5043. return;
  5044. }
  5045. }
  5046. }, {
  5047. key: "ReceivePanoramaDecodeMessage",
  5048. value: function ReceivePanoramaDecodeMessage(e) {
  5049. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  5050. var t = 0,
  5051. r;
  5052. var n = this.PendingMasks.length;
  5053. for (t = 0; t < n; t++) {
  5054. var o = this.PendingMasks[t].buffer,
  5055. a = new DataView(o),
  5056. s = new ArrayBuffer(8),
  5057. l = new DataView(s);
  5058. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  5059. return c ^ u & c;
  5060. }), IsAll0(l)) {
  5061. r = this.PendingMasks[t].angle;
  5062. break;
  5063. }
  5064. }
  5065. for (var _o3 = t; _o3 < n; _o3++) {
  5066. this.PendingMasks.pop();
  5067. }
  5068. this.executeFunction("panorama", {
  5069. data: e.data.data,
  5070. tileId: e.data.tileId,
  5071. pos: {
  5072. x: e.data.x,
  5073. y: e.data.y,
  5074. z: e.data.z
  5075. },
  5076. uuid: e.data.uuid,
  5077. finished: !0,
  5078. matchAngle: r
  5079. });
  5080. }
  5081. }, {
  5082. key: "enable_decoder_queue_logging",
  5083. value: function enable_decoder_queue_logging() {
  5084. this.decoderWorker.postMessage({
  5085. t: 100,
  5086. status: !0
  5087. });
  5088. }
  5089. }, {
  5090. key: "disable_decoder_queue_logging",
  5091. value: function disable_decoder_queue_logging() {
  5092. this.decoderWorker.postMessage({
  5093. t: 100,
  5094. status: !1
  5095. });
  5096. }
  5097. }, {
  5098. key: "init",
  5099. value: function () {
  5100. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5101. var _this5 = this;
  5102. var e,
  5103. r,
  5104. n,
  5105. t,
  5106. _args = arguments;
  5107. return regenerator.wrap(function _callee$(_context) {
  5108. while (1) {
  5109. switch (_context.prev = _context.next) {
  5110. case 0:
  5111. e = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
  5112. width: 1280,
  5113. height: 720
  5114. };
  5115. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  5116. n = {
  5117. buffer: new Uint8Array(2621440),
  5118. size: 0,
  5119. startReceiveTime: 0,
  5120. serverTime: 0,
  5121. frameCnt: -1
  5122. };
  5123. this.cacheFrameComposes.push(n);
  5124. }
  5125. t = new Blob([decoder], {
  5126. type: "application/javascript"
  5127. });
  5128. return _context.abrupt("return", (this.decoderWorker = new Worker(URL.createObjectURL(t)), this.decoderWorker.postMessage({
  5129. t: 9,
  5130. url: WASM_URLS[WASM_Version],
  5131. jitterLength: DECODER_PASSIVE_JITTER
  5132. }), this.decoderWorker.postMessage({
  5133. t: 1,
  5134. config: e
  5135. }), new Promise(function (r) {
  5136. _this5.decoderWorker.onmessage = function (n) {
  5137. switch (n.data.t) {
  5138. case 0:
  5139. _this5.ReceiveDecodeMessage(n);
  5140. break;
  5141. case 1:
  5142. _this5.UpdateStats(n);
  5143. break;
  5144. case 2:
  5145. r();
  5146. break;
  5147. case 3:
  5148. _this5.SendCacheFrameInfo(n);
  5149. break;
  5150. case 4:
  5151. {
  5152. var o = new Date().toISOString(),
  5153. a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  5154. uploadStream(COS_PREFIX + a, n.data.fileObj);
  5155. break;
  5156. }
  5157. case 5:
  5158. _this5.executeFunction("signal", {
  5159. signal: n.data.metadata,
  5160. pts: -1,
  5161. alreadyUpdateYUV: !1
  5162. });
  5163. break;
  5164. case 6:
  5165. defaultLogger.infoAndReportMeasurement(n.data), defaultLogger.debug("WASM Ready Cost");
  5166. break;
  5167. case 7:
  5168. _this5.ReceivePanoramaDecodeMessage(n);
  5169. break;
  5170. case 8:
  5171. {
  5172. var _o4 = {
  5173. MstType: 0
  5174. };
  5175. var _a3 = "";
  5176. try {
  5177. _a3 = JSON.stringify(_o4);
  5178. } catch (l) {
  5179. defaultLogger.error(l);
  5180. return;
  5181. }
  5182. var s = "wasm:" + _a3;
  5183. _this5._rtcp.sendStringData(s);
  5184. break;
  5185. }
  5186. case 9:
  5187. {
  5188. defaultLogger.info(n.data.printMsg);
  5189. break;
  5190. }
  5191. case 10:
  5192. {
  5193. defaultLogger.error(n.data.printMsg), _this5.executeFunction("error", {
  5194. code: n.data.code,
  5195. message: n.data.printMsg
  5196. });
  5197. break;
  5198. }
  5199. default:
  5200. defaultLogger.error("Receive unknown message event from decoder"), defaultLogger.debug(n.data);
  5201. break;
  5202. }
  5203. };
  5204. })));
  5205. case 4:
  5206. case "end":
  5207. return _context.stop();
  5208. }
  5209. }
  5210. }, _callee, this);
  5211. }));
  5212. function init() {
  5213. return _init.apply(this, arguments);
  5214. }
  5215. return init;
  5216. }()
  5217. }, {
  5218. key: "UpdateYUV",
  5219. value: function UpdateYUV() {
  5220. var t, r;
  5221. var e = this.getPtr;
  5222. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  5223. var n = Date.now();
  5224. if (this.firstUpdateYUV) {
  5225. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  5226. defaultLogger.infoAndReportMeasurement({
  5227. metric: "firstUpdateStreamLength",
  5228. value: h,
  5229. group: "joinRoom"
  5230. }), this.firstUpdateYUV = !1;
  5231. }
  5232. this.cachedStreams[e] != null && this.executeFunction("stream", {
  5233. stream: this.cachedStreams[e],
  5234. width: this.cachedResolution[e].width,
  5235. height: this.cachedResolution[e].height,
  5236. pts: this.cachedPtss[e]
  5237. });
  5238. var o = Date.now();
  5239. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  5240. t: 2,
  5241. frameCnt: this.cachedPtss[e],
  5242. buffer: this.cachedStreams[e]
  5243. }, [this.cachedStreams[e].buffer]);
  5244. var a = Date.now(),
  5245. s = o - n,
  5246. l = a - o;
  5247. (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]), o - this.lastRenderTs > 84 && this.JankTimes++, o - this.lastRenderTs > 125 && this.bigJankTimes++, this.lastRenderTs = o;
  5248. var u = o - n;
  5249. this.updateYUVCircular.add(u);
  5250. var c = this.cachedMetas[e];
  5251. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  5252. var _iterator3 = _createForOfIteratorHelper(c.traceIds),
  5253. _step3;
  5254. try {
  5255. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5256. var _h = _step3.value;
  5257. if (this.traceIdMap.has(_h)) {
  5258. var f = this.traceIdMap.get(_h);
  5259. if (f != null) {
  5260. f.displayTime = Date.now(), f.status = 3;
  5261. var d = f.receiveTime - f.startTime,
  5262. _ = f.readyTime - f.receiveTime,
  5263. g = f.displayTime - f.readyTime,
  5264. m = f.displayTime - f.startTime;
  5265. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  5266. }
  5267. }
  5268. }
  5269. } catch (err) {
  5270. _iterator3.e(err);
  5271. } finally {
  5272. _iterator3.f();
  5273. }
  5274. }
  5275. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  5276. var _h2 = Date.now(),
  5277. _f = _h2 - this.lastMoveDisplayTime;
  5278. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  5279. }
  5280. this.executeFunction("signal", {
  5281. signal: this.cachedMetas[e],
  5282. pts: this.cachedPtss[e],
  5283. alreadyUpdateYUV: !0
  5284. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  5285. }
  5286. }
  5287. }, {
  5288. key: "unmarshalPano",
  5289. value: function unmarshalPano(e) {
  5290. var t = new DataView(e);
  5291. if (t.getUint32(0) != 1723558763) return !1;
  5292. console.log("Receive Pano Message"), t.getUint16(4);
  5293. var n = t.getUint16(6),
  5294. o = t.getUint32(8),
  5295. a = t.getUint32(12) - (1 << 30) * 2,
  5296. s = t.getUint32(16) - (1 << 30) * 2,
  5297. l = t.getUint32(20) - (1 << 30) * 2,
  5298. u = t.getUint32(24),
  5299. c = new Uint8Array(e).subarray(28, 64),
  5300. h = String.fromCharCode.apply(null, c),
  5301. f = t.getUint32(64),
  5302. d = e.byteLength - n;
  5303. if (d == u) {
  5304. var g = {
  5305. data: new Uint8Array(e).subarray(n),
  5306. mediaLen: u,
  5307. tileId: o,
  5308. uuid: h,
  5309. x: a,
  5310. y: s,
  5311. z: l
  5312. };
  5313. this.decoderWorker.postMessage({
  5314. t: 8,
  5315. data: g
  5316. });
  5317. } else {
  5318. var _ = new Uint8Array(e, n, d);
  5319. if (this.cachePanoTileID == o) {
  5320. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  5321. var m = {
  5322. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  5323. mediaLen: u,
  5324. tileId: o,
  5325. uuid: h,
  5326. x: a,
  5327. y: s,
  5328. z: l
  5329. };
  5330. this.decoderWorker.postMessage({
  5331. t: 8,
  5332. data: m
  5333. }), this.panoCacheSize = 0;
  5334. }
  5335. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  5336. }
  5337. return !0;
  5338. }
  5339. }, {
  5340. key: "clearMoveArray",
  5341. value: function clearMoveArray() {
  5342. this.MovingTraceId = "", this.inMovingMode = !1, this.StartMovingTs = 0, this.MoveToFrameCnt = 0, this.MoveResponseDelay = 0, this.MoveProcessDelay = 0, this.MoveDisplayDelay = 0, this.moveStartPts = -1, this.moveResponseCircular.clear(), this.moveProcessCircular.clear(), this.moveDisplayCircular.clear(), this.moveEvent = "";
  5343. }
  5344. }, {
  5345. key: "getIsMoving",
  5346. value: function getIsMoving(e) {
  5347. var t;
  5348. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  5349. var n = e.newUserStates[r];
  5350. if (n.userId == this.rtcp.network.room.userId) {
  5351. t = n.renderInfo.isMoving;
  5352. break;
  5353. }
  5354. }
  5355. return t;
  5356. }
  5357. }, {
  5358. key: "isHeartBeatPacket",
  5359. value: function isHeartBeatPacket(e, t) {
  5360. return new DataView(e).getUint32(0) == 2009889916;
  5361. }
  5362. }, {
  5363. key: "resetSendTimeDiff",
  5364. value: function resetSendTimeDiff() {
  5365. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  5366. }
  5367. }, {
  5368. key: "calcSendTimeDiff",
  5369. value: function calcSendTimeDiff(e) {
  5370. if (this.prevSenderTs == -1) {
  5371. this.prevSenderTs = e;
  5372. return;
  5373. }
  5374. var t = e - this.prevSenderTs;
  5375. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  5376. }
  5377. }, {
  5378. key: "unmarshalStream",
  5379. value: function unmarshalStream(e) {
  5380. var _this6 = this;
  5381. var T, C, A, S, P, R, M, x, I, w;
  5382. var t = new DataView(e);
  5383. if (t.getUint32(0) != 1437227610) return !1;
  5384. t.getUint16(4);
  5385. var n = t.getUint16(6),
  5386. o = t.getUint16(8),
  5387. a = o,
  5388. s = t.getUint16(10);
  5389. var l = !1;
  5390. s == 1 && (l = !0);
  5391. var u = t.getUint32(12),
  5392. c = t.getUint32(16),
  5393. h = t.getUint32(20),
  5394. f = t.getUint16(24),
  5395. d = t.getUint16(26),
  5396. _ = t.getUint32(28),
  5397. g = t.getUint32(n - 4),
  5398. m = u + c,
  5399. v = e.byteLength - n,
  5400. y = new Uint8Array(e, n, v);
  5401. this.calcSendTimeDiff(h);
  5402. var b;
  5403. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  5404. if (v === m) {
  5405. this.receivedMedia++;
  5406. var O = new Uint8Array(e).subarray(n);
  5407. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  5408. var D = Date.now();
  5409. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  5410. var F = c === 0,
  5411. V = h - this.lastServerTS;
  5412. this.lastServerTS != 0 && ((o + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == F && (F ? this.srvMetaIntervalCircular.add(V) : this.srvMediaIntervalCircular.add(V)), this.frameServerCircular.add(V), this.frameClientCircular.add(D - this.lastClientTS)), this.lastSeq = o, this.lastIsPureMeta = F, this.lastServerTS = h, this.lastClientTS = D;
  5413. var N = O.subarray(0, u),
  5414. L = Date.now(),
  5415. k = JSON.parse(this.Stringify(N)),
  5416. U = Date.now();
  5417. this.showAllReceivedMetadata && console.log(h, D, k), this.metaParseAraay.push(U - L), (T = k.traceIds) != null && T.length && this.processMetaWithTraceId(k), c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o), this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs, console.log("move response delay: ", o, this.moveStartPts, this.MoveResponseDelay));
  5418. var z = this.getIsMoving(k);
  5419. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  5420. var G = Date.now(),
  5421. W = G - this.lastMoveResponseTime;
  5422. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  5423. }
  5424. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  5425. return G.userId === _this6._rtcp.network.room.userId;
  5426. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  5427. var H = {
  5428. t: 0,
  5429. data: O,
  5430. mediaLen: c,
  5431. metaLen: u,
  5432. metadata: k,
  5433. frameCnt: a,
  5434. server_ts: h,
  5435. isIDR: l,
  5436. cacheRequest: d,
  5437. cached: f,
  5438. cachedKey: _,
  5439. position: b
  5440. };
  5441. if (this.inPanoMode) return this.executeFunction("signal", {
  5442. signal: k,
  5443. pts: -1,
  5444. alreadyUpdateYUV: !0
  5445. }), !0;
  5446. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  5447. this.firstMediaArraval = Date.now();
  5448. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  5449. defaultLogger.infoAndReportMeasurement({
  5450. metric: "firstMediaArravalAt",
  5451. value: _G,
  5452. group: "joinRoom"
  5453. }), this.firstMediaReceived = !0;
  5454. }
  5455. } else {
  5456. var _O = this.hasFrmCntInCache(a);
  5457. if (_O != -1) {
  5458. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  5459. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  5460. this.cacheFrameComposes[_O].frameCnt = -1, this.cacheFrameComposes[_O].size = 0, this.cacheFrameComposes[_O].startReceiveTime = 0, this.cacheFrameComposes[_O].serverTime = 0, this.receivedMedia++, h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  5461. var _F = Date.now();
  5462. _F - this.lastClientTS > 60 ? this.clientFrameSlow++ : _F - this.lastClientTS < 16 && this.clientFrameFast++, this.lastServerTS != 0 && (this.frameServerCircular.add(h - this.lastServerTS), this.frameClientCircular.add(_F - this.lastClientTS)), this.lastServerTS = h, this.lastClientTS = _F;
  5463. var _V = _D.subarray(0, u),
  5464. _N = Date.now(),
  5465. _L = JSON.parse(this.Stringify(_V)),
  5466. _k = Date.now();
  5467. this.showAllReceivedMetadata && console.log(h, _F, _L), this.metaParseAraay.push(_k - _N), (R = _L.traceIds) != null && R.length && this.processMetaWithTraceId(_L), c != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = o), this.moveStartPts == o && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
  5468. var _U = this.getIsMoving(_L);
  5469. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  5470. var _H = Date.now(),
  5471. _G2 = _H - this.lastMoveResponseTime;
  5472. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  5473. }
  5474. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  5475. return H.userId === _this6._rtcp.network.room.userId;
  5476. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  5477. var _z = {
  5478. t: 0,
  5479. data: _D,
  5480. mediaLen: c,
  5481. metaLen: u,
  5482. metadata: _L,
  5483. frameCnt: a,
  5484. server_ts: h,
  5485. isIDR: l,
  5486. cacheRequest: d,
  5487. cached: f,
  5488. cachedKey: _,
  5489. position: b
  5490. };
  5491. if (this.inPanoMode) return this.executeFunction("signal", {
  5492. signal: _L,
  5493. pts: -1,
  5494. alreadyUpdateYUV: !0
  5495. }), !0;
  5496. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  5497. this.firstMediaArraval = Date.now();
  5498. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  5499. defaultLogger.infoAndReportMeasurement({
  5500. metric: "firstMediaArravalAt",
  5501. value: _H2,
  5502. group: "joinRoom"
  5503. }), this.firstMediaReceived = !0;
  5504. }
  5505. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  5506. } else if (_O == -1) {
  5507. var _D2 = this.hasFrmCntInCache(-1);
  5508. if (_D2 == -1) {
  5509. var _F2 = Date.now() + 1e18,
  5510. _V2 = -1;
  5511. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  5512. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  5513. }
  5514. _D2 = _V2;
  5515. }
  5516. this.cacheFrameComposes[_D2].buffer.set(y, g), this.cacheFrameComposes[_D2].size = v, this.cacheFrameComposes[_D2].frameCnt = a, this.cacheFrameComposes[_D2].startReceiveTime = Date.now(), this.cacheFrameComposes[_D2].serverTime = h;
  5517. }
  5518. }
  5519. return !0;
  5520. }
  5521. }, {
  5522. key: "reset",
  5523. value: function reset() {
  5524. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  5525. t: 4
  5526. });
  5527. }
  5528. }, {
  5529. key: "dataHandleOff",
  5530. value: function dataHandleOff(e) {
  5531. defaultLogger.debug("hhh");
  5532. }
  5533. }, {
  5534. key: "dataHandle",
  5535. value: function dataHandle(e) {
  5536. this.saveframe && (this.decoderWorker.postMessage({
  5537. t: 6
  5538. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  5539. t: 7
  5540. }), this.SaveMediaStream = !1);
  5541. var t = new Uint8Array(e);
  5542. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  5543. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  5544. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  5545. return;
  5546. }
  5547. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  5548. this.noWasmBytesReceived += e.byteLength;
  5549. var r = JSON.parse(this.Stringify(t));
  5550. this.executeFunction("signal", {
  5551. signal: r,
  5552. pts: -1,
  5553. alreadyUpdateYUV: !0
  5554. });
  5555. }
  5556. }, {
  5557. key: "changePanoMode",
  5558. value: function changePanoMode(e) {
  5559. this.inPanoMode = e;
  5560. }
  5561. }, {
  5562. key: "uploadDataToServer",
  5563. value: function uploadDataToServer() {
  5564. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  5565. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  5566. }), this.DynamicPanoTest = !1);
  5567. function e(ie, ee) {
  5568. return ee == -1 && (ee = 0), ie + ee;
  5569. }
  5570. function t(ie, ee) {
  5571. return Math.max(ie, ee);
  5572. }
  5573. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  5574. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  5575. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  5576. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  5577. s = this.overallTimeArray.length;
  5578. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  5579. var l = this.moveResponseCircular.getThreshPercent(),
  5580. u = l[0],
  5581. c = l[1],
  5582. h = l[2],
  5583. f = l[3],
  5584. d = l[4],
  5585. _ = d - f,
  5586. g = 1 - c / d || 0,
  5587. m = [u, c - u, h - c, f - h, _],
  5588. v = this.moveProcessCircular.getThreshPercent(),
  5589. y = v[0],
  5590. b = v[1],
  5591. T = v[2],
  5592. C = v[3],
  5593. A = v[4],
  5594. S = A - C,
  5595. P = 1 - b / A || 0,
  5596. R = [y, b - y, T - b, C - T, S],
  5597. M = this.moveDisplayCircular.getThreshPercent(),
  5598. x = M[0],
  5599. I = M[1],
  5600. w = M[2],
  5601. O = M[3],
  5602. D = M[4],
  5603. F = D - O,
  5604. V = 1 - I / D || 0,
  5605. N = [x, I - x, w - I, O - w, F],
  5606. L = x,
  5607. k = I - x,
  5608. U = w - I,
  5609. z = O - w,
  5610. H = F,
  5611. G = this.moveResponseCircular.getAvg(),
  5612. W = this.moveProcessCircular.getAvg(),
  5613. j = this.moveDisplayCircular.getAvg(),
  5614. B = this.moveResponseCircular.getMax(),
  5615. X = this.moveProcessCircular.getMax(),
  5616. $ = this.moveDisplayCircular.getMax(),
  5617. Y = this.moveResponseCircular.getStandardDeviation(),
  5618. K = this.moveProcessCircular.getStandardDeviation(),
  5619. Z = this.moveDisplayCircular.getStandardDeviation();
  5620. this.moveResponseCircular.getIncomingAvg(), this.moveProcessCircular.getIncomingAvg(), this.moveDisplayCircular.getIncomingAvg(), this.moveResponseCircular.getIncomingMax(), this.moveProcessCircular.getIncomingMax(), this.moveDisplayCircular.getIncomingMax(), this.moveResponseCircular.clearIncoming(), this.moveProcessCircular.clearIncoming(), this.moveDisplayCircular.clearIncoming();
  5621. var q = this.frameServerCircular.getAvg(),
  5622. J = this.frameServerCircular.getMax();
  5623. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  5624. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  5625. te = this.metaParseAraay.reduce(t, 0);
  5626. this.metaParseAraay = [];
  5627. var re = {
  5628. mediaBytesReceived: this.mediaBytesReceived,
  5629. metaBytesReceived: this.metaBytesReceived,
  5630. packetsLost: this.packetsLost,
  5631. timestamp: Date.now(),
  5632. frameHeight: 1280,
  5633. frameWidth: 720,
  5634. framesReceived: this.receivedMedia,
  5635. framesReceivedWorker: this.receivedMedia_worker,
  5636. framesDecoded: this.receivedYUV,
  5637. framesEmited: this.receivedEmit,
  5638. decodeTimePerFrame: this.decodeTimePerFrame,
  5639. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  5640. packetsDrop: this.packetsDrop,
  5641. framesAwait: this.framesAwait,
  5642. firstMediaArraval: this.firstMediaArraval,
  5643. firstYUVDecoded: this.firstYUVDecoded,
  5644. firstRender: this.firstRender,
  5645. returnFrames: this.returnFrames,
  5646. sendOutBuffer: this.sendOutBuffer,
  5647. maxGraphicTime: this.updateYUVCircular.getMax(),
  5648. averageGraphicTime: this.updateYUVCircular.getAvg(),
  5649. jankTimes: this.JankTimes,
  5650. bigJankTimes: this.bigJankTimes,
  5651. decodeJankTimes: this.DecodeJankTimes,
  5652. bigDecodeJankTimes: this.bigDecodeJankTimes,
  5653. serverFrameSlow: this.serverFrameSlow,
  5654. serverFrameFast: this.serverFrameFast,
  5655. clientFrameSlow: this.clientFrameSlow,
  5656. clientFrameFast: this.clientFrameFast,
  5657. rtcMessageReceived: this.rtcMessageReceived,
  5658. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  5659. receiveIframes: this.receiveIframes,
  5660. decodeIframes: this.decodeIframes,
  5661. avgResponseTime: r,
  5662. avgProcessTime: n,
  5663. avgDisplayTime: o,
  5664. avgOverallTime: a,
  5665. overallTimeCount: s,
  5666. responseMiss: this.responseMiss,
  5667. processMiss: this.processMiss,
  5668. displayMiss: this.displayMiss,
  5669. updateDropFrame: this.updateDropFrame,
  5670. moveEvent: this.moveEvent,
  5671. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  5672. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  5673. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  5674. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  5675. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  5676. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  5677. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  5678. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  5679. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  5680. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  5681. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  5682. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  5683. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  5684. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  5685. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  5686. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  5687. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  5688. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  5689. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  5690. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  5691. sdMoveResponseLongTime: Y,
  5692. sdMoveProcessLongTime: K,
  5693. sdMoveDisplayLongTime: Z,
  5694. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  5695. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  5696. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  5697. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  5698. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  5699. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  5700. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  5701. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  5702. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  5703. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  5704. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  5705. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  5706. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  5707. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  5708. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  5709. avgMetaParseTime: Q,
  5710. maxMetaParseTime: te,
  5711. avgServerDiff: q,
  5712. maxServerDiff: J,
  5713. streamType: WASM_Version
  5714. };
  5715. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  5716. }
  5717. }]);
  5718. return Workers;
  5719. }();
  5720. 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); }; }
  5721. 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; } }
  5722. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  5723. _inherits(Rtcp, _EventEmitter);
  5724. var _super = _createSuper$7(Rtcp);
  5725. function Rtcp(e) {
  5726. var _this;
  5727. _classCallCheck(this, Rtcp);
  5728. _this = _super.call(this);
  5729. E(_assertThisInitialized(_this), "connection", null);
  5730. E(_assertThisInitialized(_this), "inputChannel", null);
  5731. E(_assertThisInitialized(_this), "mediaStream");
  5732. E(_assertThisInitialized(_this), "socket");
  5733. E(_assertThisInitialized(_this), "connected", !1);
  5734. E(_assertThisInitialized(_this), "candidates", []);
  5735. E(_assertThisInitialized(_this), "isAnswered", !1);
  5736. E(_assertThisInitialized(_this), "isFlushing", !1);
  5737. E(_assertThisInitialized(_this), "inputReady", !1);
  5738. E(_assertThisInitialized(_this), "workers");
  5739. E(_assertThisInitialized(_this), "actived", !0);
  5740. E(_assertThisInitialized(_this), "heartbeat");
  5741. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  5742. if (e.candidate != null) {
  5743. var t = JSON.stringify(e.candidate);
  5744. logger.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  5745. id: "ice_candidate",
  5746. data: btoa(t)
  5747. });
  5748. }
  5749. });
  5750. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  5751. logger.error("onicecandidateerror", e.errorCode, e.errorText, e);
  5752. });
  5753. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  5754. switch (e.target.iceGatheringState) {
  5755. case "gathering":
  5756. logger.info("ice gathering");
  5757. break;
  5758. case "complete":
  5759. logger.info("Ice gathering completed");
  5760. }
  5761. });
  5762. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  5763. if (!!_this.connection) switch (logger.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  5764. case "connected":
  5765. {
  5766. _this.connected = !0;
  5767. break;
  5768. }
  5769. case "disconnected":
  5770. {
  5771. _this.connected = !1, _this.emit("rtcDisconnected");
  5772. break;
  5773. }
  5774. case "failed":
  5775. {
  5776. _this.emit("rtcDisconnected"), _this.connected = !1;
  5777. break;
  5778. }
  5779. }
  5780. });
  5781. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  5782. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  5783. var a, s, l, r, n, o, u;
  5784. return regenerator.wrap(function _callee$(_context) {
  5785. while (1) {
  5786. switch (_context.prev = _context.next) {
  5787. case 0:
  5788. if (_this.connection) {
  5789. _context.next = 2;
  5790. break;
  5791. }
  5792. return _context.abrupt("return");
  5793. case 2:
  5794. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  5795. _context.next = 5;
  5796. return _this.connection.setRemoteDescription(n);
  5797. case 5:
  5798. _context.next = 7;
  5799. return _this.connection.createAnswer();
  5800. case 7:
  5801. o = _context.sent;
  5802. if (o.sdp = (a = o.sdp) == null ? void 0 : a.replace(/(a=fmtp:111 .*)/g, "$1;stereo=1;sprop-stereo=1"), ((l = (s = o.sdp) == null ? void 0 : s.match(/a=mid:1/g)) == null ? void 0 : l.length) == 2) {
  5803. u = o.sdp.lastIndexOf("a=mid:1");
  5804. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  5805. }
  5806. _context.prev = 9;
  5807. _context.next = 12;
  5808. return _this.connection.setLocalDescription(o);
  5809. case 12:
  5810. _context.next = 17;
  5811. break;
  5812. case 14:
  5813. _context.prev = 14;
  5814. _context.t0 = _context["catch"](9);
  5815. logger.error("error", _context.t0);
  5816. case 17:
  5817. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  5818. id: "answer",
  5819. data: btoa(JSON.stringify(o))
  5820. }), t.srcObject = _this.mediaStream;
  5821. case 18:
  5822. case "end":
  5823. return _context.stop();
  5824. }
  5825. }
  5826. }, _callee, null, [[9, 14]]);
  5827. }));
  5828. return function (_x, _x2) {
  5829. return _ref.apply(this, arguments);
  5830. };
  5831. }());
  5832. E(_assertThisInitialized(_this), "flushCandidate", function () {
  5833. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  5834. var t = atob(e),
  5835. r = JSON.parse(t);
  5836. if (/172\./.test(r.candidate)) return;
  5837. var n = new RTCIceCandidate(r);
  5838. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  5839. logger.info("add candidate failed", o);
  5840. });
  5841. }), _this.isFlushing = !1);
  5842. });
  5843. E(_assertThisInitialized(_this), "input", function (e) {
  5844. var t;
  5845. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  5846. });
  5847. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger), _this.workers.registerLogger(logger), _this.workers.registerFunction("data", function (t) {
  5848. _this.emit("data", t);
  5849. }), _this.heartbeat = new Heartbeat({
  5850. ping: function ping(t) {
  5851. e.room.actionsHandler.echo(t);
  5852. },
  5853. pong(t, r) {
  5854. var n;
  5855. r && t > 500 && logger.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  5856. hb: t
  5857. });
  5858. }
  5859. });
  5860. return _this;
  5861. }
  5862. _createClass(Rtcp, [{
  5863. key: "start",
  5864. value: function start() {
  5865. var _this2 = this;
  5866. this.connection = new RTCPeerConnection();
  5867. var e = Date.now();
  5868. this.connection.ondatachannel = function (t) {
  5869. logger.info("ondatachannel: ".concat(t.channel.label));
  5870. _this2.inputChannel = t.channel;
  5871. _this2.inputChannel.onopen = function () {
  5872. var r;
  5873. logger.info("The input channel has opened, id:", (r = _this2.inputChannel) == null ? void 0 : r.id), _this2.inputReady = !0, _this2.emit("rtcConnected"), _this2.network.room.currentNetworkOptions.reconnect || (logger.infoAndReportMeasurement({
  5874. metric: "datachannelOpenedAt",
  5875. startTime: _this2.network.room._startTime,
  5876. group: "joinRoom"
  5877. }), logger.infoAndReportMeasurement({
  5878. metric: "datachannelOpenedCost",
  5879. startTime: e,
  5880. group: "joinRoom"
  5881. }));
  5882. }, _this2.inputChannel.onclose = function () {
  5883. var r;
  5884. return logger.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  5885. }, _this2.inputChannel.onmessage = function (r) {
  5886. _this2.workers.dataHandle(r.data);
  5887. };
  5888. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  5889. id: "init_webrtc",
  5890. data: JSON.stringify({
  5891. is_mobile: !0
  5892. })
  5893. });
  5894. }
  5895. }, {
  5896. key: "addCandidate",
  5897. value: function addCandidate(e) {
  5898. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  5899. }
  5900. }, {
  5901. key: "disconnect",
  5902. value: function disconnect() {
  5903. var e, t, r;
  5904. this.heartbeat.stop(), logger.info("ready to close datachannel, id", (e = this.inputChannel) == null ? void 0 : e.id), (t = this.inputChannel) == null || t.close(), (r = this.connection) == null || r.close(), this.connection = null, this.inputChannel = null;
  5905. }
  5906. }, {
  5907. key: "sendStringData",
  5908. value: function sendStringData(e) {
  5909. console.log('e', e);
  5910. this.input(e);
  5911. }
  5912. }, {
  5913. key: "sendData",
  5914. value: function sendData(e) {
  5915. var t = "";
  5916. try {
  5917. t = JSON.stringify(e);
  5918. } catch (r) {
  5919. logger.error(r);
  5920. return;
  5921. }
  5922. this.input(t);
  5923. }
  5924. }]);
  5925. return Rtcp;
  5926. }(EventEmitter);
  5927. var NetworkMonitor = /*#__PURE__*/function () {
  5928. function NetworkMonitor(e) {
  5929. _classCallCheck(this, NetworkMonitor);
  5930. this._listener = e;
  5931. }
  5932. _createClass(NetworkMonitor, [{
  5933. key: "isOnline",
  5934. get: function get() {
  5935. var e = window.navigator;
  5936. return typeof e.onLine == "boolean" ? e.onLine : !0;
  5937. }
  5938. }, {
  5939. key: "start",
  5940. value: function start() {
  5941. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  5942. }
  5943. }, {
  5944. key: "stop",
  5945. value: function stop() {
  5946. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  5947. }
  5948. }]);
  5949. return NetworkMonitor;
  5950. }();
  5951. var Stream = /*#__PURE__*/function () {
  5952. function Stream(e) {
  5953. _classCallCheck(this, Stream);
  5954. this.el = null;
  5955. this._streamPlayTimer = null;
  5956. if (!e) {
  5957. this.el = this.createVideoElement();
  5958. return;
  5959. }
  5960. this.el = e;
  5961. }
  5962. _createClass(Stream, [{
  5963. key: "play",
  5964. value: function play() {
  5965. var _this = this;
  5966. return new Promise(function (e, t) {
  5967. _this._streamPlayTimer = new Timeout(function () {
  5968. t(new InternalError("Stream play timeout"));
  5969. }, 5e3), _this.el && _this.el.play().then(function () {
  5970. var r;
  5971. e(), logger.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  5972. }).catch(function (r) {
  5973. var n;
  5974. logger.error("Media Failed to autoplay"), logger.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  5975. });
  5976. });
  5977. }
  5978. }, {
  5979. key: "createVideoElement",
  5980. value: function createVideoElement() {
  5981. var e = document.createElement("video");
  5982. return e.muted = !0, e.autoplay = !1, e.playsInline = !0, e.setAttribute("autostart", "false"), e.setAttribute("controls", "controls"), e.setAttribute("muted", "true"), e.setAttribute("preload", "auto"), e.setAttribute("hidden", "hidden"), document.body.appendChild(e), e;
  5983. }
  5984. }]);
  5985. return Stream;
  5986. }();
  5987. 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); }; }
  5988. 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; } }
  5989. var InternalError$1 = /*#__PURE__*/function (_XverseError) {
  5990. _inherits(InternalError, _XverseError);
  5991. var _super = _createSuper$6(InternalError);
  5992. function InternalError(e) {
  5993. _classCallCheck(this, InternalError);
  5994. return _super.call(this, 1002, e || "\u5185\u90E8\u9519\u8BEF");
  5995. }
  5996. return _createClass(InternalError);
  5997. }(XverseError);
  5998. 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); }; }
  5999. 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; } }
  6000. var workerSourceCode = "onmessage = function (event) {\n const data = event.data\n if (!data) return\n \n if (data.type === 'start') {\n const startTime = Date.now()\n const request = new XMLHttpRequest()\n request.open('GET', data.url)\n try {\n request.send()\n } catch (error) {\n console.error(error)\n }\n request.addEventListener('readystatechange', () => {\n if (request.readyState == 4) {\n if (request.status == 200) {\n postMessage(Date.now() - startTime)\n }\n }\n })\n }\n }\n ";
  6001. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  6002. _inherits(NetworkController, _EventEmitter);
  6003. var _super = _createSuper$5(NetworkController);
  6004. function NetworkController(e) {
  6005. var _this;
  6006. _classCallCheck(this, NetworkController);
  6007. _this = _super.call(this);
  6008. _this.socket = null;
  6009. _this.rtcp = null;
  6010. _this.stream = null;
  6011. _this._state = 'connecting';
  6012. _this._networkMonitor = null;
  6013. _this.blockedActions = [];
  6014. _this.reconnectCount = 0;
  6015. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  6016. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  6017. _this.stream = new Stream();
  6018. _this._networkMonitor = new NetworkMonitor(function () {
  6019. 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());
  6020. });
  6021. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  6022. _this._networkMonitor.start();
  6023. new VisibilityChangeHandler().subscribe(function (r) {
  6024. var n, o;
  6025. r ? ((o = _this.room.stats) == null || o.disable(), logger.infoAndReportMeasurement({
  6026. metric: "pageHide",
  6027. startTime: Date.now()
  6028. })) : ((n = _this.room.stats) == null || n.enable(), logger.infoAndReportMeasurement({
  6029. metric: "pageShow",
  6030. startTime: Date.now(),
  6031. extra: {
  6032. state: _this._state
  6033. }
  6034. }), _this._state === "disconnected" && _this.reconnect());
  6035. });
  6036. return _this;
  6037. }
  6038. _createClass(NetworkController, [{
  6039. key: "startGame",
  6040. value: function startGame() {
  6041. var _this2 = this;
  6042. return new Promise(function (e, t) {
  6043. if (!_this2.rtcp.connected) return t(new InternalError$1("Game cannot load. Please refresh"));
  6044. if (!_this2.rtcp.inputReady) return t(new InternalError$1("Game is not ready yet. Please wait"));
  6045. _this2.socket.on("gameRoomAvailable", function (r) {
  6046. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  6047. }), _this2.socket.on("socketClosed", function (r) {
  6048. t(r);
  6049. }), _this2.socket.startGame();
  6050. });
  6051. }
  6052. }, {
  6053. key: "addBlockedActions",
  6054. value: function addBlockedActions(e) {
  6055. var _this$blockedActions;
  6056. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  6057. }
  6058. }, {
  6059. key: "removeBlockedActions",
  6060. value: function removeBlockedActions(e) {
  6061. if (!e) {
  6062. this.blockedActions = [];
  6063. return;
  6064. }
  6065. var t = this.blockedActions.indexOf(e);
  6066. this.blockedActions.splice(t, 1);
  6067. }
  6068. }, {
  6069. key: "setState",
  6070. value: function setState(e) {
  6071. this._state !== e && (logger.info("Set network state to ", e), this._state = e);
  6072. }
  6073. }, {
  6074. key: "connectAndStart",
  6075. value: function () {
  6076. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6077. return regenerator.wrap(function _callee$(_context) {
  6078. while (1) {
  6079. switch (_context.prev = _context.next) {
  6080. case 0:
  6081. return _context.abrupt("return", this.connect(e).then(this.startGame));
  6082. case 1:
  6083. case "end":
  6084. return _context.stop();
  6085. }
  6086. }
  6087. }, _callee, this);
  6088. }));
  6089. function connectAndStart(_x) {
  6090. return _connectAndStart.apply(this, arguments);
  6091. }
  6092. return connectAndStart;
  6093. }()
  6094. }, {
  6095. key: "connect",
  6096. value: function () {
  6097. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6098. var _this3 = this;
  6099. var e,
  6100. _args2 = arguments;
  6101. return regenerator.wrap(function _callee2$(_context2) {
  6102. while (1) {
  6103. switch (_context2.prev = _context2.next) {
  6104. case 0:
  6105. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  6106. this.room.updateCurrentNetworkOptions({
  6107. reconnect: e
  6108. });
  6109. return _context2.abrupt("return", new Promise(function (t, r) {
  6110. _this3.rtcp.on("rtcConnected", function () {
  6111. _this3.setState("connected"), t();
  6112. }), _this3.rtcp.on("rtcDisconnected", function () {
  6113. logger.info("rtc disconnected"), _this3._state === "connecting" ? (_this3.setState("disconnected"), r(new InternalError$1("rtc connect failed"))) : (_this3.setState("disconnected"), logger.info("rtc disconnected, start to reconnect"), _this3.reconnect());
  6114. }), _this3.socket.on("socketQuit", function () {
  6115. logger.info("socket quit success"), _this3.setState("closed");
  6116. }), _this3.socket.on("socketClosed", function (n) {
  6117. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  6118. }), _this3.socket.start();
  6119. }));
  6120. case 3:
  6121. case "end":
  6122. return _context2.stop();
  6123. }
  6124. }
  6125. }, _callee2, this);
  6126. }));
  6127. function connect() {
  6128. return _connect.apply(this, arguments);
  6129. }
  6130. return connect;
  6131. }()
  6132. }, {
  6133. key: "reconnect",
  6134. value: function reconnect() {
  6135. var _this4 = this;
  6136. if (this.room.viewMode === "observer") return;
  6137. var e = Date.now();
  6138. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  6139. logger.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  6140. state: "disconnected"
  6141. });
  6142. return;
  6143. }
  6144. return logger.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  6145. logger.infoAndReportMeasurement({
  6146. startTime: e,
  6147. metric: "reconnect"
  6148. });
  6149. }).catch(function (t) {
  6150. if (logger.infoAndReportMeasurement({
  6151. startTime: e,
  6152. metric: "reconnect",
  6153. error: t
  6154. }), t.code === Codes.RepeatLogin) {
  6155. _this4.room.handleRepetLogin();
  6156. return;
  6157. }
  6158. var r = 1e3;
  6159. logger.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  6160. _this4.reconnect();
  6161. }, r);
  6162. });
  6163. }
  6164. }, {
  6165. key: "_reconnect",
  6166. value: function _reconnect() {
  6167. var _this5 = this;
  6168. 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", {
  6169. state: "reconnecting",
  6170. count: this.reconnectCount
  6171. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  6172. var e = _ref.session_id;
  6173. _this5.room.updateCurrentNetworkOptions({
  6174. sessionId: e
  6175. }), reporter.updateBody({
  6176. serverSession: e
  6177. }), logger.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  6178. state: "reconnected"
  6179. });
  6180. }));
  6181. }
  6182. }, {
  6183. key: "prepareReconnect",
  6184. value: function prepareReconnect() {
  6185. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  6186. }
  6187. }, {
  6188. key: "prepareReconnectOptions",
  6189. value: function prepareReconnectOptions() {
  6190. var _ref2 = this.room.currentClickingState || {},
  6191. e = _ref2.camera,
  6192. t = _ref2.player;
  6193. e && t && this.room.updateCurrentNetworkOptions({
  6194. camera: e,
  6195. player: t
  6196. });
  6197. }
  6198. }, {
  6199. key: "sendRtcData",
  6200. value: function sendRtcData(e) {
  6201. if (this.blockedActions.includes(e.action_type)) {
  6202. logger.info("action: ".concat(Actions[e.action_type], " was blocked"));
  6203. return;
  6204. }
  6205. this.rtcp.sendData(e);
  6206. }
  6207. }, {
  6208. key: "sendSocketData",
  6209. value: function sendSocketData(e) {
  6210. logger.debug("ws send ->", e), this.socket.send(e);
  6211. }
  6212. }, {
  6213. key: "quit",
  6214. value: function quit() {
  6215. var e = uuid$1(),
  6216. t = {
  6217. action_type: Actions.Exit,
  6218. trace_id: e,
  6219. exit_action: {},
  6220. user_id: this.room.options.userId,
  6221. packet_id: e
  6222. };
  6223. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  6224. }
  6225. }, {
  6226. key: "checkNetworkQuality",
  6227. value: function checkNetworkQuality(i) {
  6228. var worker = null;
  6229. if (!i) return;
  6230. var e = Date.now();
  6231. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  6232. logger.infoAndReportMeasurement({
  6233. metric: "baiduRtt",
  6234. group: "http",
  6235. value: r,
  6236. startTime: e
  6237. });
  6238. }), !worker) {
  6239. var t = new Blob([workerSourceCode], {
  6240. type: "application/javascript"
  6241. });
  6242. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  6243. logger.infoAndReportMeasurement({
  6244. metric: "workerRtt",
  6245. group: "http",
  6246. startTime: e,
  6247. value: r.data
  6248. });
  6249. };
  6250. }
  6251. }
  6252. }, {
  6253. key: "pingOthers",
  6254. value: function pingOthers(i, e) {
  6255. var t = !1;
  6256. var r = new Image();
  6257. r.onload = o, r.onerror = a;
  6258. var n = Date.now();
  6259. function o(l) {
  6260. t = !0, s();
  6261. }
  6262. function a(l) {}
  6263. function s() {
  6264. var l = Date.now() - n;
  6265. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  6266. }
  6267. r.src = i + "/favicon.ico?" + +new Date();
  6268. }
  6269. }]);
  6270. return NetworkController;
  6271. }(EventEmitter);
  6272. 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); }; }
  6273. 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; } }
  6274. var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
  6275. _inherits(InitConfigTimeoutError, _XverseError);
  6276. var _super = _createSuper$4(InitConfigTimeoutError);
  6277. function InitConfigTimeoutError(e) {
  6278. _classCallCheck(this, InitConfigTimeoutError);
  6279. return _super.call(this, 1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6");
  6280. }
  6281. return _createClass(InitConfigTimeoutError);
  6282. }(XverseError);
  6283. 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); }; }
  6284. 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; } }
  6285. var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
  6286. _inherits(InitDecoderTimeoutError, _XverseError);
  6287. var _super = _createSuper$3(InitDecoderTimeoutError);
  6288. function InitDecoderTimeoutError(e) {
  6289. _classCallCheck(this, InitDecoderTimeoutError);
  6290. return _super.call(this, 1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6");
  6291. }
  6292. return _createClass(InitDecoderTimeoutError);
  6293. }(XverseError);
  6294. 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); }; }
  6295. 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; } }
  6296. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  6297. _inherits(Xverse_Room, _EventEmitter);
  6298. var _super = _createSuper$2(Xverse_Room);
  6299. function Xverse_Room(e) {
  6300. var _this;
  6301. _classCallCheck(this, Xverse_Room);
  6302. _this = _super.call(this);
  6303. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  6304. E(_assertThisInitialized(_this), "options");
  6305. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  6306. E(_assertThisInitialized(_this), "lastSkinId");
  6307. E(_assertThisInitialized(_this), "debug");
  6308. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  6309. E(_assertThisInitialized(_this), "userId", null);
  6310. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  6311. E(_assertThisInitialized(_this), "networkController");
  6312. E(_assertThisInitialized(_this), "_startTime", Date.now());
  6313. E(_assertThisInitialized(_this), "canvas");
  6314. E(_assertThisInitialized(_this), "modelManager");
  6315. E(_assertThisInitialized(_this), "eventsController");
  6316. E(_assertThisInitialized(_this), "panorama");
  6317. E(_assertThisInitialized(_this), "engineProxy");
  6318. E(_assertThisInitialized(_this), "_id");
  6319. E(_assertThisInitialized(_this), "skinList", []);
  6320. E(_assertThisInitialized(_this), "isHost", !1);
  6321. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  6322. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  6323. E(_assertThisInitialized(_this), "sceneManager");
  6324. E(_assertThisInitialized(_this), "scene");
  6325. E(_assertThisInitialized(_this), "breathPointManager");
  6326. E(_assertThisInitialized(_this), "_currentState");
  6327. E(_assertThisInitialized(_this), "joined", !1);
  6328. E(_assertThisInitialized(_this), "disableRotate", !1);
  6329. E(_assertThisInitialized(_this), "isPano", !1);
  6330. E(_assertThisInitialized(_this), "movingByClick", !0);
  6331. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  6332. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  6333. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  6334. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  6335. E(_assertThisInitialized(_this), "_currentClickingState", null);
  6336. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  6337. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  6338. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  6339. var e, t, r, n;
  6340. return regenerator.wrap(function _callee$(_context) {
  6341. while (1) {
  6342. switch (_context.prev = _context.next) {
  6343. case 0:
  6344. logger.info("Invoke receiveRtcData");
  6345. e = !1, t = !1, r = !1, n = !1;
  6346. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  6347. return _assertThisInitialized(_this);
  6348. }, function () {
  6349. return _assertThisInitialized(_this);
  6350. })) : new Promise(function (o) {
  6351. var a = _this.networkController.rtcp.workers;
  6352. a.registerFunction("signal", function (s) {
  6353. _this.signal.handleSignal(s);
  6354. }), a.registerFunction("stream", function (s) {
  6355. var l;
  6356. if (_this.emit("streamTimestamp", {
  6357. timestamp: Date.now()
  6358. }), t || (t = !0, logger.info("Invoke stream event")), s.stream) {
  6359. r || (r = !0, logger.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  6360. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  6361. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  6362. }
  6363. e || (logger.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  6364. _this.engineProxy.frameRenderNumber >= 2 && (n || (n = !0, logger.info("Invoke registerAfterRender")), _this.isFirstDataUsed || (logger.info("Invoke isStreamAvailable"), _this.isFirstDataUsed = !0, _this.firstFrameTimestamp = Date.now(), o(_assertThisInitialized(_this)), _this.afterJoinRoom()));
  6365. }));
  6366. }), _this.panorama.bindListener(function () {
  6367. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  6368. }), a.registerFunction("reconnectedFrame", function () {}), logger.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  6369. t: 5
  6370. });
  6371. }));
  6372. case 3:
  6373. case "end":
  6374. return _context.stop();
  6375. }
  6376. }
  6377. }, _callee);
  6378. })));
  6379. E(_assertThisInitialized(_this), "moveToExtra", "");
  6380. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  6381. var n = e;
  6382. n.canvas;
  6383. var r = Oe(n, ["canvas"]);
  6384. logger.infoAndReportMeasurement({
  6385. metric: "startJoinRoomAt",
  6386. startTime: Date.now(),
  6387. group: "joinRoom",
  6388. extra: r,
  6389. value: 0
  6390. });
  6391. return _this;
  6392. }
  6393. _createClass(Xverse_Room, [{
  6394. key: "currentNetworkOptions",
  6395. get: function get() {
  6396. return this._currentNetworkOptions;
  6397. }
  6398. }, {
  6399. key: "viewMode",
  6400. get: function get() {
  6401. var e;
  6402. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  6403. }
  6404. }, {
  6405. key: "id",
  6406. get: function get() {
  6407. return this._id;
  6408. }
  6409. }, {
  6410. key: "skinId",
  6411. get: function get() {
  6412. return this._currentState.skinId;
  6413. }
  6414. }, {
  6415. key: "skin",
  6416. get: function get() {
  6417. return this._currentState.skin;
  6418. }
  6419. }, {
  6420. key: "sessionId",
  6421. get: function get() {
  6422. return this.currentNetworkOptions.sessionId;
  6423. }
  6424. }, {
  6425. key: "pictureQualityLevel",
  6426. get: function get() {
  6427. return this.currentState.pictureQualityLevel;
  6428. }
  6429. }, {
  6430. key: "avatars",
  6431. get: function get() {
  6432. return Array.from(this.avatarManager.avatars.values());
  6433. }
  6434. }, {
  6435. key: "currentState",
  6436. get: function get() {
  6437. var e;
  6438. return le(oe({}, this._currentState), {
  6439. state: (e = this.networkController) == null ? void 0 : e._state
  6440. });
  6441. }
  6442. }, {
  6443. key: "_userAvatar",
  6444. get: function get() {
  6445. var _this2 = this;
  6446. return this.avatars.find(function (e) {
  6447. return e.userId === _this2.userId;
  6448. });
  6449. }
  6450. }, {
  6451. key: "tvs",
  6452. get: function get() {
  6453. return this.engineProxy._tvs;
  6454. }
  6455. }, {
  6456. key: "tv",
  6457. get: function get() {
  6458. return this.tvs[0];
  6459. }
  6460. }, {
  6461. key: "currentClickingState",
  6462. get: function get() {
  6463. return this._currentClickingState;
  6464. }
  6465. }, {
  6466. key: "afterJoinRoomHook",
  6467. value: function afterJoinRoomHook() {}
  6468. }, {
  6469. key: "beforeJoinRoomResolveHook",
  6470. value: function beforeJoinRoomResolveHook() {}
  6471. }, {
  6472. key: "afterReconnectedHook",
  6473. value: function afterReconnectedHook() {}
  6474. }, {
  6475. key: "handleSignalHook",
  6476. value: function handleSignalHook(e) {}
  6477. }, {
  6478. key: "skinChangedHook",
  6479. value: function skinChangedHook() {}
  6480. }, {
  6481. key: "beforeStartGameHook",
  6482. value: function () {
  6483. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  6484. return regenerator.wrap(function _callee2$(_context2) {
  6485. while (1) {
  6486. switch (_context2.prev = _context2.next) {
  6487. case 0:
  6488. case "end":
  6489. return _context2.stop();
  6490. }
  6491. }
  6492. }, _callee2);
  6493. }));
  6494. function beforeStartGameHook(_x) {
  6495. return _beforeStartGameHook.apply(this, arguments);
  6496. }
  6497. return beforeStartGameHook;
  6498. }()
  6499. }, {
  6500. key: "loadAssetsHook",
  6501. value: function loadAssetsHook() {}
  6502. }, {
  6503. key: "afterUserAvatarLoadedHook",
  6504. value: function afterUserAvatarLoadedHook() {}
  6505. }, {
  6506. key: "audienceViewModeHook",
  6507. value: function audienceViewModeHook() {}
  6508. }, {
  6509. key: "setViewModeToObserver",
  6510. value: function setViewModeToObserver() {}
  6511. }, {
  6512. key: "handleVehicleHook",
  6513. value: function handleVehicleHook(e) {}
  6514. }, {
  6515. key: "updateReporter",
  6516. value: function updateReporter() {
  6517. var _this$options = this.options,
  6518. e = _this$options.avatarId,
  6519. t = _this$options.skinId,
  6520. r = _this$options.userId,
  6521. n = _this$options.roomId,
  6522. o = _this$options.role,
  6523. a = _this$options.appId,
  6524. s = _this$options.wsServerUrl;
  6525. reporter$1.updateHeader({
  6526. userId: r
  6527. }), reporter$1.updateBody({
  6528. roomId: n,
  6529. role: o,
  6530. skinId: t,
  6531. avatarId: e,
  6532. appId: a,
  6533. wsServerUrl: s
  6534. });
  6535. }
  6536. }, {
  6537. key: "initRoom",
  6538. value: function () {
  6539. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  6540. var _this$options$timeout, e;
  6541. return regenerator.wrap(function _callee3$(_context3) {
  6542. while (1) {
  6543. switch (_context3.prev = _context3.next) {
  6544. case 0:
  6545. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  6546. if (!util.isSupported()) {
  6547. _context3.next = 5;
  6548. break;
  6549. }
  6550. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  6551. case 5:
  6552. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  6553. case 6:
  6554. case "end":
  6555. return _context3.stop();
  6556. }
  6557. }
  6558. }, _callee3, this);
  6559. }));
  6560. function initRoom() {
  6561. return _initRoom2.apply(this, arguments);
  6562. }
  6563. return initRoom;
  6564. }()
  6565. }, {
  6566. key: "_initRoom",
  6567. value: function () {
  6568. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  6569. 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;
  6570. return regenerator.wrap(function _callee4$(_context4) {
  6571. while (1) {
  6572. switch (_context4.prev = _context4.next) {
  6573. case 0:
  6574. e = this.validateOptions(this.options);
  6575. if (!e) {
  6576. _context4.next = 3;
  6577. break;
  6578. }
  6579. return _context4.abrupt("return", (logger.error("initRoom param error", e), Promise.reject(e)));
  6580. case 3:
  6581. _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;
  6582. this.setCurrentNetworkOptions({
  6583. avatarId: r,
  6584. skinId: n,
  6585. roomId: R,
  6586. userId: o,
  6587. wsServerUrl: a,
  6588. role: s,
  6589. token: l,
  6590. pageSession: u,
  6591. rotationRenderType: c,
  6592. isAllSync: h,
  6593. appId: f,
  6594. camera: d,
  6595. player: _,
  6596. avatarComponents: g,
  6597. nickname: m,
  6598. avatarScale: v,
  6599. firends: y,
  6600. syncByEvent: b,
  6601. areaName: T,
  6602. attitude: C,
  6603. pathName: A,
  6604. person: P,
  6605. roomTypeId: M,
  6606. hasAvatar: x,
  6607. syncToOthers: I,
  6608. prioritySync: w,
  6609. extra: D,
  6610. removeWhenDisconnected: O
  6611. });
  6612. this.userId = o;
  6613. this.canvas = t;
  6614. T && (this.pathManager.currentArea = T);
  6615. this.networkController = new NetworkController(this);
  6616. this.setCurrentState({
  6617. areaName: T,
  6618. pathName: A,
  6619. attitude: C,
  6620. speed: 0,
  6621. viewMode: S,
  6622. state: this.networkController._state,
  6623. skinId: n
  6624. });
  6625. _context4.prev = 10;
  6626. _context4.next = 13;
  6627. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  6628. case 13:
  6629. logger.info("network config wasm all ready, start to create game");
  6630. _context4.next = 16;
  6631. return this.requestCreateRoom({
  6632. skinId: n
  6633. });
  6634. case 16:
  6635. F = _context4.sent;
  6636. V = F.routeList.find(function (L) {
  6637. return L.areaName === T;
  6638. });
  6639. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  6640. this.updateCurrentState({
  6641. skin: F,
  6642. skinId: F.id,
  6643. versionId: F.versionId,
  6644. speed: N
  6645. });
  6646. _context4.next = 22;
  6647. return this.initEngine(F);
  6648. case 22:
  6649. _context4.next = 27;
  6650. break;
  6651. case 24:
  6652. _context4.prev = 24;
  6653. _context4.t0 = _context4["catch"](10);
  6654. return _context4.abrupt("return", Promise.reject(_context4.t0));
  6655. case 27:
  6656. return _context4.abrupt("return", (this.beforeJoinRoomResolve(), this.receiveRtcData()));
  6657. case 28:
  6658. case "end":
  6659. return _context4.stop();
  6660. }
  6661. }
  6662. }, _callee4, this, [[10, 24]]);
  6663. }));
  6664. function _initRoom() {
  6665. return _initRoom3.apply(this, arguments);
  6666. }
  6667. return _initRoom;
  6668. }()
  6669. }, {
  6670. key: "beforeJoinRoomResolve",
  6671. value: function beforeJoinRoomResolve() {
  6672. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  6673. }
  6674. }, {
  6675. key: "afterJoinRoom",
  6676. value: function afterJoinRoom() {
  6677. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger.infoAndReportMeasurement({
  6678. tag: this.viewMode,
  6679. value: this.firstFrameTimestamp - this._startTime,
  6680. startTime: Date.now(),
  6681. metric: "joinRoom"
  6682. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  6683. var e = _ref2.stats;
  6684. reporter$1.report("stats", oe({}, e));
  6685. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  6686. }
  6687. }, {
  6688. key: "afterReconnected",
  6689. value: function afterReconnected() {
  6690. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  6691. }
  6692. }, {
  6693. key: "leave",
  6694. value: function leave() {
  6695. var e, t;
  6696. return logger.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  6697. }
  6698. }, {
  6699. key: "validateOptions",
  6700. value: function validateOptions(e) {
  6701. var _ref3 = e || {},
  6702. t = _ref3.canvas,
  6703. r = _ref3.avatarId,
  6704. n = _ref3.skinId,
  6705. o = _ref3.userId,
  6706. a = _ref3.role;
  6707. _ref3.roomId;
  6708. var l = _ref3.token,
  6709. u = _ref3.appId;
  6710. _ref3.avatarComponents;
  6711. var h = [];
  6712. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  6713. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  6714. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  6715. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  6716. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  6717. return h[0];
  6718. }
  6719. }, {
  6720. key: "initNetwork",
  6721. value: function () {
  6722. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  6723. var e;
  6724. return regenerator.wrap(function _callee5$(_context5) {
  6725. while (1) {
  6726. switch (_context5.prev = _context5.next) {
  6727. case 0:
  6728. if (!(this.viewMode === "serverless")) {
  6729. _context5.next = 2;
  6730. break;
  6731. }
  6732. return _context5.abrupt("return", Promise.resolve());
  6733. case 2:
  6734. e = Date.now();
  6735. _context5.prev = 3;
  6736. _context5.next = 6;
  6737. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  6738. case 6:
  6739. logger.infoAndReportMeasurement({
  6740. metric: "networkInitAt",
  6741. startTime: this._startTime,
  6742. group: "joinRoom"
  6743. });
  6744. logger.infoAndReportMeasurement({
  6745. metric: "networkInitCost",
  6746. startTime: e,
  6747. group: "joinRoom"
  6748. });
  6749. _context5.next = 13;
  6750. break;
  6751. case 10:
  6752. _context5.prev = 10;
  6753. _context5.t0 = _context5["catch"](3);
  6754. throw logger.infoAndReportMeasurement({
  6755. metric: "networkInitAt",
  6756. startTime: e,
  6757. group: "joinRoom",
  6758. error: _context5.t0
  6759. }), _context5.t0;
  6760. case 13:
  6761. case "end":
  6762. return _context5.stop();
  6763. }
  6764. }
  6765. }, _callee5, this, [[3, 10]]);
  6766. }));
  6767. function initNetwork() {
  6768. return _initNetwork.apply(this, arguments);
  6769. }
  6770. return initNetwork;
  6771. }()
  6772. }, {
  6773. key: "initConfig",
  6774. value: function () {
  6775. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  6776. var e;
  6777. return regenerator.wrap(function _callee6$(_context6) {
  6778. while (1) {
  6779. switch (_context6.prev = _context6.next) {
  6780. case 0:
  6781. e = Date.now();
  6782. _context6.prev = 1;
  6783. _context6.next = 4;
  6784. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  6785. case 4:
  6786. logger.infoAndReportMeasurement({
  6787. metric: "configInitAt",
  6788. startTime: this._startTime,
  6789. group: "joinRoom"
  6790. });
  6791. logger.infoAndReportMeasurement({
  6792. metric: "configInitCost",
  6793. startTime: e,
  6794. group: "joinRoom"
  6795. });
  6796. _context6.next = 11;
  6797. break;
  6798. case 8:
  6799. _context6.prev = 8;
  6800. _context6.t0 = _context6["catch"](1);
  6801. throw logger.infoAndReportMeasurement({
  6802. metric: "configInitAt",
  6803. startTime: e,
  6804. group: "joinRoom",
  6805. error: _context6.t0
  6806. }), _context6.t0;
  6807. case 11:
  6808. case "end":
  6809. return _context6.stop();
  6810. }
  6811. }
  6812. }, _callee6, this, [[1, 8]]);
  6813. }));
  6814. function initConfig() {
  6815. return _initConfig.apply(this, arguments);
  6816. }
  6817. return initConfig;
  6818. }()
  6819. }, {
  6820. key: "initEngine",
  6821. value: function () {
  6822. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  6823. var t, n;
  6824. return regenerator.wrap(function _callee7$(_context7) {
  6825. while (1) {
  6826. switch (_context7.prev = _context7.next) {
  6827. case 0:
  6828. t = Date.now();
  6829. _context7.prev = 1;
  6830. this.engineProxy = new EngineProxy(this);
  6831. _context7.next = 5;
  6832. return this.engineProxy.initEngine(e);
  6833. case 5:
  6834. logger.infoAndReportMeasurement({
  6835. metric: "webglInitAt",
  6836. startTime: this._startTime,
  6837. group: "joinRoom"
  6838. });
  6839. logger.infoAndReportMeasurement({
  6840. metric: "webglInitCost",
  6841. startTime: t,
  6842. group: "joinRoom"
  6843. });
  6844. return _context7.abrupt("return");
  6845. case 10:
  6846. _context7.prev = 10;
  6847. _context7.t0 = _context7["catch"](1);
  6848. n = _context7.t0;
  6849. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger.error(_context7.t0), logger.infoAndReportMeasurement({
  6850. metric: "webglInitAt",
  6851. startTime: t,
  6852. group: "joinRoom",
  6853. error: n
  6854. }), Promise.reject(n)));
  6855. case 14:
  6856. case "end":
  6857. return _context7.stop();
  6858. }
  6859. }
  6860. }, _callee7, this, [[1, 10]]);
  6861. }));
  6862. function initEngine(_x2) {
  6863. return _initEngine.apply(this, arguments);
  6864. }
  6865. return initEngine;
  6866. }()
  6867. }, {
  6868. key: "initWasm",
  6869. value: function () {
  6870. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  6871. var _this3 = this;
  6872. var e;
  6873. return regenerator.wrap(function _callee8$(_context8) {
  6874. while (1) {
  6875. switch (_context8.prev = _context8.next) {
  6876. case 0:
  6877. if (!(this.viewMode === "serverless")) {
  6878. _context8.next = 2;
  6879. break;
  6880. }
  6881. return _context8.abrupt("return", Promise.resolve());
  6882. case 2:
  6883. e = Date.now();
  6884. _context8.prev = 3;
  6885. _context8.next = 6;
  6886. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  6887. case 6:
  6888. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  6889. logger.error("decode error", t);
  6890. var r = t.code,
  6891. n = t.message;
  6892. _this3.emit("error", {
  6893. code: r,
  6894. msg: n
  6895. });
  6896. });
  6897. logger.infoAndReportMeasurement({
  6898. metric: "wasmInitAt",
  6899. group: "joinRoom",
  6900. startTime: this._startTime
  6901. });
  6902. logger.infoAndReportMeasurement({
  6903. metric: "wasmInitCost",
  6904. group: "joinRoom",
  6905. startTime: e
  6906. });
  6907. eventsManager.on("traceId", function (t) {
  6908. _this3.networkController.rtcp.workers.onTraceId(t);
  6909. });
  6910. _context8.next = 15;
  6911. break;
  6912. case 12:
  6913. _context8.prev = 12;
  6914. _context8.t0 = _context8["catch"](3);
  6915. throw logger.infoAndReportMeasurement({
  6916. metric: "wasmInitAt",
  6917. group: "joinRoom",
  6918. startTime: e,
  6919. error: _context8.t0
  6920. }), _context8.t0;
  6921. case 15:
  6922. case "end":
  6923. return _context8.stop();
  6924. }
  6925. }
  6926. }, _callee8, this, [[3, 12]]);
  6927. }));
  6928. function initWasm() {
  6929. return _initWasm.apply(this, arguments);
  6930. }
  6931. return initWasm;
  6932. }()
  6933. }, {
  6934. key: "requestCreateRoom",
  6935. value: function () {
  6936. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  6937. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  6938. return regenerator.wrap(function _callee9$(_context9) {
  6939. while (1) {
  6940. switch (_context9.prev = _context9.next) {
  6941. case 0:
  6942. e = _ref4.skinId;
  6943. if (!e) {
  6944. _context9.next = 11;
  6945. break;
  6946. }
  6947. _context9.next = 4;
  6948. return this.getSkin(e);
  6949. case 4:
  6950. t = _context9.sent;
  6951. _context9.next = 7;
  6952. return this.modelManager.findRoute(e, this.options.pathName);
  6953. case 7:
  6954. r = _context9.sent;
  6955. this.updateCurrentNetworkOptions({
  6956. areaName: r.areaName,
  6957. attitude: r.attitude,
  6958. versionId: t.versionId
  6959. });
  6960. _ref5 = getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  6961. this.options.camera || this.updateCurrentNetworkOptions({
  6962. camera: n
  6963. }), this.options.player || this.updateCurrentNetworkOptions({
  6964. player: o
  6965. });
  6966. case 11:
  6967. if (!(this.viewMode === "serverless")) {
  6968. _context9.next = 13;
  6969. break;
  6970. }
  6971. return _context9.abrupt("return", t);
  6972. case 13:
  6973. _context9.prev = 13;
  6974. _context9.next = 16;
  6975. return this.beforeStartGameHook(this.options);
  6976. case 16:
  6977. _context9.next = 18;
  6978. return this.networkController.startGame();
  6979. case 18:
  6980. _yield$this$networkCo = _context9.sent;
  6981. _r = _yield$this$networkCo.room_id;
  6982. _n = _yield$this$networkCo.data;
  6983. _o = _yield$this$networkCo.session_id;
  6984. this._id = _r;
  6985. a = JSON.parse(_n);
  6986. this.isHost = a.IsHost, e = a.SkinID || e;
  6987. _context9.next = 27;
  6988. return this.getSkin(e);
  6989. case 27:
  6990. s = _context9.sent;
  6991. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  6992. roomId: _r,
  6993. sessionId: _o
  6994. }), reporter$1.updateBody({
  6995. roomId: _r,
  6996. skinId: e,
  6997. serverSession: _o
  6998. }), s));
  6999. case 31:
  7000. _context9.prev = 31;
  7001. _context9.t0 = _context9["catch"](13);
  7002. throw logger.error("Request create room error", _context9.t0), _context9.t0;
  7003. case 34:
  7004. case "end":
  7005. return _context9.stop();
  7006. }
  7007. }
  7008. }, _callee9, this, [[13, 31]]);
  7009. }));
  7010. function requestCreateRoom(_x3) {
  7011. return _requestCreateRoom.apply(this, arguments);
  7012. }
  7013. return requestCreateRoom;
  7014. }()
  7015. }, {
  7016. key: "pause",
  7017. value: function pause() {
  7018. return this.engineProxy.pause();
  7019. }
  7020. }, {
  7021. key: "resume",
  7022. value: function resume() {
  7023. return this.engineProxy.resume();
  7024. }
  7025. }, {
  7026. key: "reconnect",
  7027. value: function reconnect() {
  7028. this.networkController.reconnect();
  7029. }
  7030. }, {
  7031. key: "setViewMode",
  7032. value: function () {
  7033. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  7034. return regenerator.wrap(function _callee10$(_context10) {
  7035. while (1) {
  7036. switch (_context10.prev = _context10.next) {
  7037. case 0:
  7038. case "end":
  7039. return _context10.stop();
  7040. }
  7041. }
  7042. }, _callee10);
  7043. }));
  7044. function setViewMode(_x4) {
  7045. return _setViewMode.apply(this, arguments);
  7046. }
  7047. return setViewMode;
  7048. }()
  7049. }, {
  7050. key: "handleRepetLogin",
  7051. value: function handleRepetLogin() {
  7052. logger.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  7053. }
  7054. }, {
  7055. key: "setPictureQualityLevel",
  7056. value: function setPictureQualityLevel(e) {
  7057. var t = {
  7058. high: EImageQuality.high,
  7059. low: EImageQuality.low,
  7060. average: EImageQuality.mid
  7061. };
  7062. return this.updateCurrentState({
  7063. pictureQualityLevel: e
  7064. }), this.sceneManager.setImageQuality(t[e]);
  7065. }
  7066. }, {
  7067. key: "getSkin",
  7068. value: function () {
  7069. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  7070. var t, n;
  7071. return regenerator.wrap(function _callee11$(_context11) {
  7072. while (1) {
  7073. switch (_context11.prev = _context11.next) {
  7074. case 0:
  7075. t = null;
  7076. _context11.next = 3;
  7077. return this.modelManager.getSkinsList();
  7078. case 3:
  7079. t = (this.skinList = _context11.sent).find(function (n) {
  7080. return n.id === e || n.id === e;
  7081. });
  7082. if (!t) {
  7083. _context11.next = 6;
  7084. break;
  7085. }
  7086. return _context11.abrupt("return", t);
  7087. case 6:
  7088. n = "skin is invalid: skinId: ".concat(e);
  7089. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  7090. case 8:
  7091. case "end":
  7092. return _context11.stop();
  7093. }
  7094. }
  7095. }, _callee11, this);
  7096. }));
  7097. function getSkin(_x5) {
  7098. return _getSkin.apply(this, arguments);
  7099. }
  7100. return getSkin;
  7101. }()
  7102. }, {
  7103. key: "setupStats",
  7104. value: function setupStats() {
  7105. this.stats.assign({
  7106. roomId: this.id,
  7107. userId: this.userId
  7108. }), setInterval(this.engineProxy.updateStats, 1e3);
  7109. }
  7110. }, {
  7111. key: "proxyEvents",
  7112. value: function proxyEvents(e, t) {
  7113. this.emit(e, t);
  7114. }
  7115. }, {
  7116. key: "setCurrentNetworkOptions",
  7117. value: function setCurrentNetworkOptions(e) {
  7118. this._currentNetworkOptions = e;
  7119. }
  7120. }, {
  7121. key: "updateCurrentNetworkOptions",
  7122. value: function updateCurrentNetworkOptions(e) {
  7123. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  7124. }
  7125. }, {
  7126. key: "setCurrentState",
  7127. value: function setCurrentState(e) {
  7128. this._currentState = e;
  7129. }
  7130. }, {
  7131. key: "updateCurrentState",
  7132. value: function updateCurrentState(e) {
  7133. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  7134. skinId: e.skinId
  7135. })), e.versionId && this.updateCurrentNetworkOptions({
  7136. versionId: e.versionId
  7137. }), Object.assign(this._currentState, e);
  7138. }
  7139. }]);
  7140. return Xverse_Room;
  7141. }(EventEmitter);
  7142. 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); }; }
  7143. 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; } }
  7144. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  7145. _inherits(XverseRoom, _Xverse_Room);
  7146. var _super = _createSuper$1(XverseRoom);
  7147. function XverseRoom(e) {
  7148. var _this;
  7149. _classCallCheck(this, XverseRoom);
  7150. _this = _super.call(this, e);
  7151. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  7152. return _this;
  7153. }
  7154. _createClass(XverseRoom, [{
  7155. key: "afterJoinRoomHook",
  7156. value: function afterJoinRoomHook() {
  7157. this.joyStick.init({});
  7158. }
  7159. }]);
  7160. return XverseRoom;
  7161. }(Xverse_Room);
  7162. var BaseTable = /*#__PURE__*/function () {
  7163. function BaseTable(e, t) {
  7164. _classCallCheck(this, BaseTable);
  7165. this.db = null;
  7166. this.isCreatingTable = !1;
  7167. this.hasCleared = !1;
  7168. this.dbName = e, this.dbVersion = t;
  7169. }
  7170. _createClass(BaseTable, [{
  7171. key: "clearDataBase",
  7172. value: function () {
  7173. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7174. var _this = this;
  7175. return regenerator.wrap(function _callee$(_context) {
  7176. while (1) {
  7177. switch (_context.prev = _context.next) {
  7178. case 0:
  7179. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  7180. var n = window.indexedDB.deleteDatabase(_this.dbName);
  7181. n.onsuccess = function () {
  7182. t();
  7183. }, n.onerror = r;
  7184. }));
  7185. case 1:
  7186. case "end":
  7187. return _context.stop();
  7188. }
  7189. }
  7190. }, _callee, this);
  7191. }));
  7192. function clearDataBase(_x) {
  7193. return _clearDataBase.apply(this, arguments);
  7194. }
  7195. return clearDataBase;
  7196. }()
  7197. }, {
  7198. key: "tableName",
  7199. value: function tableName() {
  7200. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  7201. }
  7202. }, {
  7203. key: "keyPath",
  7204. value: function keyPath() {
  7205. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  7206. }
  7207. }, {
  7208. key: "index",
  7209. value: function index() {
  7210. throw new Error("Derived class have to override 'index', and set a proper index name!");
  7211. }
  7212. }, {
  7213. key: "checkAndOpenDatabase",
  7214. value: function () {
  7215. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7216. var _this2 = this;
  7217. return regenerator.wrap(function _callee2$(_context2) {
  7218. while (1) {
  7219. switch (_context2.prev = _context2.next) {
  7220. case 0:
  7221. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  7222. var n = setTimeout(function () {
  7223. logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  7224. }, 200);
  7225. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  7226. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  7227. }, function () {
  7228. t(new Error("Failed to open database!")), clearTimeout(n);
  7229. }, function () {
  7230. _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  7231. });
  7232. }));
  7233. case 1:
  7234. case "end":
  7235. return _context2.stop();
  7236. }
  7237. }
  7238. }, _callee2, this);
  7239. }));
  7240. function checkAndOpenDatabase() {
  7241. return _checkAndOpenDatabase.apply(this, arguments);
  7242. }
  7243. return checkAndOpenDatabase;
  7244. }()
  7245. }, {
  7246. key: "openDatabase",
  7247. value: function openDatabase(e, t, r, n, o) {
  7248. var _this3 = this;
  7249. if (this.isCreatingTable) return;
  7250. this.isCreatingTable = !0, logger.info(e, t);
  7251. var a = window.indexedDB.open(e, t),
  7252. s = this.tableName();
  7253. a.onsuccess = function (l) {
  7254. _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  7255. }, a.onerror = function (l) {
  7256. var u;
  7257. 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);
  7258. }, a.onupgradeneeded = function (l) {
  7259. var u = l.target.result,
  7260. c = _this3.index();
  7261. logger.info("Creating table ".concat(s, "."));
  7262. var h = u.objectStoreNames.contains(s);
  7263. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  7264. var f = _this3.keyPath();
  7265. h = u.createObjectStore(s, {
  7266. keyPath: f
  7267. });
  7268. }
  7269. c.map(function (f) {
  7270. h.createIndex(f, f, {
  7271. unique: !1
  7272. });
  7273. }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
  7274. };
  7275. }
  7276. }, {
  7277. key: "add",
  7278. value: function () {
  7279. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  7280. var t, o;
  7281. return regenerator.wrap(function _callee3$(_context3) {
  7282. while (1) {
  7283. switch (_context3.prev = _context3.next) {
  7284. case 0:
  7285. t = this.tableName();
  7286. _context3.next = 3;
  7287. return this.checkAndOpenDatabase();
  7288. case 3:
  7289. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  7290. return _context3.abrupt("return", new Promise(function (a, s) {
  7291. o.onsuccess = function (l) {
  7292. a(l);
  7293. }, o.onerror = function (l) {
  7294. var u;
  7295. logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  7296. };
  7297. }));
  7298. case 5:
  7299. case "end":
  7300. return _context3.stop();
  7301. }
  7302. }
  7303. }, _callee3, this);
  7304. }));
  7305. function add(_x2) {
  7306. return _add.apply(this, arguments);
  7307. }
  7308. return add;
  7309. }()
  7310. }, {
  7311. key: "put",
  7312. value: function () {
  7313. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  7314. var t, o;
  7315. return regenerator.wrap(function _callee4$(_context4) {
  7316. while (1) {
  7317. switch (_context4.prev = _context4.next) {
  7318. case 0:
  7319. t = this.tableName();
  7320. _context4.next = 3;
  7321. return this.checkAndOpenDatabase();
  7322. case 3:
  7323. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  7324. return _context4.abrupt("return", new Promise(function (a, s) {
  7325. o.onsuccess = function (l) {
  7326. a(l);
  7327. }, o.onerror = function (l) {
  7328. var u;
  7329. logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  7330. };
  7331. }));
  7332. case 5:
  7333. case "end":
  7334. return _context4.stop();
  7335. }
  7336. }
  7337. }, _callee4, this);
  7338. }));
  7339. function put(_x3) {
  7340. return _put.apply(this, arguments);
  7341. }
  7342. return put;
  7343. }()
  7344. }, {
  7345. key: "delete",
  7346. value: function _delete(e, t, r) {
  7347. var n = this.tableName();
  7348. this.checkAndOpenDatabase().then(function (o) {
  7349. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  7350. s.onsuccess = t, s.onerror = r;
  7351. });
  7352. }
  7353. }, {
  7354. key: "update",
  7355. value: function update() {
  7356. this.checkAndOpenDatabase().then(function (e) {});
  7357. }
  7358. }, {
  7359. key: "getAllKeys",
  7360. value: function () {
  7361. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  7362. var e, t;
  7363. return regenerator.wrap(function _callee5$(_context5) {
  7364. while (1) {
  7365. switch (_context5.prev = _context5.next) {
  7366. case 0:
  7367. e = this.tableName();
  7368. _context5.next = 3;
  7369. return this.checkAndOpenDatabase();
  7370. case 3:
  7371. t = _context5.sent;
  7372. return _context5.abrupt("return", new Promise(function (r, n) {
  7373. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  7374. a.onsuccess = function (s) {
  7375. r(s.target.result);
  7376. }, a.onerror = function (s) {
  7377. logger.error("db getAllKeys error", s), n(s);
  7378. };
  7379. }));
  7380. case 5:
  7381. case "end":
  7382. return _context5.stop();
  7383. }
  7384. }
  7385. }, _callee5, this);
  7386. }));
  7387. function getAllKeys() {
  7388. return _getAllKeys.apply(this, arguments);
  7389. }
  7390. return getAllKeys;
  7391. }()
  7392. }, {
  7393. key: "query",
  7394. value: function () {
  7395. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  7396. var r, n;
  7397. return regenerator.wrap(function _callee6$(_context6) {
  7398. while (1) {
  7399. switch (_context6.prev = _context6.next) {
  7400. case 0:
  7401. r = this.tableName();
  7402. _context6.next = 3;
  7403. return this.checkAndOpenDatabase();
  7404. case 3:
  7405. n = _context6.sent;
  7406. return _context6.abrupt("return", new Promise(function (o, a) {
  7407. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  7408. u.onsuccess = function (c) {
  7409. var f;
  7410. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  7411. o && o(h);
  7412. }, u.onerror = function (c) {
  7413. logger.error("db query error", c), a(c);
  7414. };
  7415. }));
  7416. case 5:
  7417. case "end":
  7418. return _context6.stop();
  7419. }
  7420. }
  7421. }, _callee6, this);
  7422. }));
  7423. function query(_x4, _x5) {
  7424. return _query.apply(this, arguments);
  7425. }
  7426. return query;
  7427. }()
  7428. }, {
  7429. key: "sleep",
  7430. value: function () {
  7431. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  7432. return regenerator.wrap(function _callee7$(_context7) {
  7433. while (1) {
  7434. switch (_context7.prev = _context7.next) {
  7435. case 0:
  7436. return _context7.abrupt("return", new Promise(function (t) {
  7437. setTimeout(function () {
  7438. t("");
  7439. }, e);
  7440. }));
  7441. case 1:
  7442. case "end":
  7443. return _context7.stop();
  7444. }
  7445. }
  7446. }, _callee7);
  7447. }));
  7448. function sleep(_x6) {
  7449. return _sleep.apply(this, arguments);
  7450. }
  7451. return sleep;
  7452. }()
  7453. }]);
  7454. return BaseTable;
  7455. }();
  7456. 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); }; }
  7457. 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; } }
  7458. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  7459. _inherits(ModelTable, _BaseTable);
  7460. var _super = _createSuper(ModelTable);
  7461. function ModelTable() {
  7462. _classCallCheck(this, ModelTable);
  7463. return _super.call(this, "XverseDatabase", 1);
  7464. }
  7465. _createClass(ModelTable, [{
  7466. key: "tableName",
  7467. value: function tableName() {
  7468. return "models";
  7469. }
  7470. }, {
  7471. key: "index",
  7472. value: function index() {
  7473. return ["url"];
  7474. }
  7475. }, {
  7476. key: "keyPath",
  7477. value: function keyPath() {
  7478. return "url";
  7479. }
  7480. }]);
  7481. return ModelTable;
  7482. }(BaseTable);
  7483. var modelTable = new ModelTable();
  7484. var Preload = /*#__PURE__*/function () {
  7485. function Preload(e) {
  7486. _classCallCheck(this, Preload);
  7487. this.config = null;
  7488. this.allKeys = [];
  7489. this.oldResourcesDeleted = !1;
  7490. this.requests = {
  7491. simple: {
  7492. stopped: !0,
  7493. requests: {}
  7494. },
  7495. observer: {
  7496. stopped: !0,
  7497. requests: {}
  7498. },
  7499. full: {
  7500. stopped: !0,
  7501. requests: {}
  7502. }
  7503. };
  7504. this.modelManager = e, this.init(e.appId);
  7505. }
  7506. _createClass(Preload, [{
  7507. key: "init",
  7508. value: function init(e) {
  7509. reporter$1.updateBody({
  7510. appId: e
  7511. });
  7512. }
  7513. }, {
  7514. key: "getConfig",
  7515. value: function () {
  7516. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7517. var _yield$this$modelMana, t;
  7518. return regenerator.wrap(function _callee$(_context) {
  7519. while (1) {
  7520. switch (_context.prev = _context.next) {
  7521. case 0:
  7522. if (!this.config) {
  7523. _context.next = 2;
  7524. break;
  7525. }
  7526. return _context.abrupt("return", this.config);
  7527. case 2:
  7528. _context.next = 4;
  7529. return this.modelManager.requestConfig();
  7530. case 4:
  7531. _yield$this$modelMana = _context.sent;
  7532. t = _yield$this$modelMana.preload;
  7533. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  7534. case 7:
  7535. case "end":
  7536. return _context.stop();
  7537. }
  7538. }
  7539. }, _callee, this);
  7540. }));
  7541. function getConfig(_x) {
  7542. return _getConfig.apply(this, arguments);
  7543. }
  7544. return getConfig;
  7545. }()
  7546. }, {
  7547. key: "getAllKeys",
  7548. value: function () {
  7549. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7550. var e, t;
  7551. return regenerator.wrap(function _callee2$(_context2) {
  7552. while (1) {
  7553. switch (_context2.prev = _context2.next) {
  7554. case 0:
  7555. if (!this.allKeys.length) {
  7556. _context2.next = 2;
  7557. break;
  7558. }
  7559. return _context2.abrupt("return", this.allKeys);
  7560. case 2:
  7561. _context2.prev = 2;
  7562. _context2.next = 5;
  7563. return modelTable.getAllKeys();
  7564. case 5:
  7565. e = _context2.sent;
  7566. this.allKeys = e;
  7567. return _context2.abrupt("return", e);
  7568. case 10:
  7569. _context2.prev = 10;
  7570. _context2.t0 = _context2["catch"](2);
  7571. t = "preload getAllKeys error";
  7572. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  7573. case 14:
  7574. case "end":
  7575. return _context2.stop();
  7576. }
  7577. }
  7578. }, _callee2, this, [[2, 10]]);
  7579. }));
  7580. function getAllKeys() {
  7581. return _getAllKeys.apply(this, arguments);
  7582. }
  7583. return getAllKeys;
  7584. }()
  7585. }, {
  7586. key: "stop",
  7587. value: function stop(e) {
  7588. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  7589. var t = this.requests[e].requests;
  7590. Object.keys(t).forEach(function (r) {
  7591. http1.canceler.removePending(r), delete t[r];
  7592. });
  7593. }
  7594. }, {
  7595. key: "clearPreload",
  7596. value: function clearPreload(e) {
  7597. this.requests[e].stopped = !1, this.allKeys = [];
  7598. }
  7599. }, {
  7600. key: "start",
  7601. value: function () {
  7602. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  7603. var n, o, a, s, l, u, h, f, _s;
  7604. return regenerator.wrap(function _callee3$(_context3) {
  7605. while (1) {
  7606. switch (_context3.prev = _context3.next) {
  7607. case 0:
  7608. n = Date.now(), o = 0;
  7609. _context3.prev = 1;
  7610. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  7611. _context3.next = 4;
  7612. break;
  7613. }
  7614. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  7615. case 4:
  7616. this.clearPreload(e);
  7617. _context3.next = 7;
  7618. return this.getConfig(e);
  7619. case 7:
  7620. a = _context3.sent;
  7621. _context3.next = 10;
  7622. return this.getAllKeys();
  7623. case 10:
  7624. s = _context3.sent;
  7625. _context3.prev = 11;
  7626. _context3.next = 14;
  7627. return this.deleteOldResources(a.assetUrls.map(function (d) {
  7628. return d.url;
  7629. }), s);
  7630. case 14:
  7631. _context3.next = 19;
  7632. break;
  7633. case 16:
  7634. _context3.prev = 16;
  7635. _context3.t0 = _context3["catch"](11);
  7636. logger.error(_context3.t0);
  7637. case 19:
  7638. l = a.baseUrls, u = a.assetUrls;
  7639. _context3.t1 = e;
  7640. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  7641. break;
  7642. case 23:
  7643. h = l;
  7644. return _context3.abrupt("break", 30);
  7645. case 25:
  7646. h = u;
  7647. return _context3.abrupt("break", 30);
  7648. case 27:
  7649. h = u;
  7650. return _context3.abrupt("break", 30);
  7651. case 29:
  7652. h = u;
  7653. case 30:
  7654. f = h.filter(function (d) {
  7655. return !s.includes(d.url);
  7656. });
  7657. r && isFunction(r) && (f = f.filter(r));
  7658. o = f.length;
  7659. logger.debug("keysNeedToPreload", f);
  7660. f.length || t && t(h.length, h.length);
  7661. n = Date.now();
  7662. _context3.next = 38;
  7663. return this._preload(e, f, t);
  7664. case 38:
  7665. logger.infoAndReportMeasurement({
  7666. tag: e,
  7667. startTime: n,
  7668. metric: "assetsPreload",
  7669. extra: {
  7670. total: o
  7671. }
  7672. });
  7673. return _context3.abrupt("return");
  7674. case 42:
  7675. _context3.prev = 42;
  7676. _context3.t2 = _context3["catch"](1);
  7677. _s = _context3.t2;
  7678. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  7679. tag: e,
  7680. startTime: n,
  7681. metric: "assetsPreload",
  7682. extra: {
  7683. total: o
  7684. },
  7685. error: _s,
  7686. reportOptions: {
  7687. immediate: !0
  7688. }
  7689. }), Promise.reject(_s)));
  7690. case 46:
  7691. case "end":
  7692. return _context3.stop();
  7693. }
  7694. }
  7695. }, _callee3, this, [[1, 42], [11, 16]]);
  7696. }));
  7697. function start(_x2, _x3, _x4) {
  7698. return _start.apply(this, arguments);
  7699. }
  7700. return start;
  7701. }()
  7702. }, {
  7703. key: "deleteOldResources",
  7704. value: function deleteOldResources(e, t) {
  7705. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  7706. var r = t.filter(function (n) {
  7707. return !e.includes(n);
  7708. });
  7709. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  7710. return modelTable.delete(n);
  7711. }));
  7712. }
  7713. }, {
  7714. key: "_preload",
  7715. value: function () {
  7716. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  7717. var _this = this;
  7718. var n, o, a;
  7719. return regenerator.wrap(function _callee6$(_context6) {
  7720. while (1) {
  7721. switch (_context6.prev = _context6.next) {
  7722. case 0:
  7723. n = t.length;
  7724. if (n) {
  7725. _context6.next = 3;
  7726. break;
  7727. }
  7728. return _context6.abrupt("return", Promise.resolve());
  7729. case 3:
  7730. o = 0;
  7731. a = window.setInterval(function () {
  7732. r && r(o, n), o >= n && window.clearInterval(a);
  7733. }, 1e3);
  7734. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  7735. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  7736. var l, u;
  7737. return regenerator.wrap(function _callee5$(_context5) {
  7738. while (1) {
  7739. switch (_context5.prev = _context5.next) {
  7740. case 0:
  7741. l = s.size, u = s.url;
  7742. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  7743. url: u,
  7744. timeout: Preload.getTimeoutBySize(l),
  7745. responseType: "blob",
  7746. retry: 2,
  7747. beforeRequest: function beforeRequest() {
  7748. _this.requests[e].requests[u] = !0;
  7749. }
  7750. }).then( /*#__PURE__*/function () {
  7751. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  7752. var h, f;
  7753. return regenerator.wrap(function _callee4$(_context4) {
  7754. while (1) {
  7755. switch (_context4.prev = _context4.next) {
  7756. case 0:
  7757. h = c.data;
  7758. if (h instanceof Blob) {
  7759. _context4.next = 3;
  7760. break;
  7761. }
  7762. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  7763. case 3:
  7764. _context4.next = 5;
  7765. return blobToDataURI(h);
  7766. case 5:
  7767. f = _context4.sent;
  7768. _context4.prev = 6;
  7769. _context4.next = 9;
  7770. return modelTable.put({
  7771. url: u,
  7772. model: f
  7773. });
  7774. case 9:
  7775. return _context4.abrupt("return");
  7776. case 12:
  7777. _context4.prev = 12;
  7778. _context4.t0 = _context4["catch"](6);
  7779. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  7780. case 15:
  7781. case "end":
  7782. return _context4.stop();
  7783. }
  7784. }
  7785. }, _callee4, null, [[6, 12]]);
  7786. }));
  7787. return function (_x9) {
  7788. return _ref2.apply(this, arguments);
  7789. };
  7790. }()).then(function () {
  7791. o++, delete _this.requests[e].requests[u];
  7792. }, function (c) {
  7793. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  7794. }));
  7795. case 2:
  7796. case "end":
  7797. return _context5.stop();
  7798. }
  7799. }
  7800. }, _callee5);
  7801. }));
  7802. return function (_x8) {
  7803. return _ref.apply(this, arguments);
  7804. };
  7805. }()));
  7806. case 6:
  7807. case "end":
  7808. return _context6.stop();
  7809. }
  7810. }
  7811. }, _callee6);
  7812. }));
  7813. function _preload(_x5, _x6, _x7) {
  7814. return _preload2.apply(this, arguments);
  7815. }
  7816. return _preload;
  7817. }()
  7818. }], [{
  7819. key: "getTimeoutBySize",
  7820. value: function getTimeoutBySize(e) {
  7821. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  7822. }
  7823. }]);
  7824. return Preload;
  7825. }();
  7826. var RenderType$1 = {
  7827. PathVideo: 0,
  7828. RotationVideo: 1,
  7829. RotationImage: 2,
  7830. PanoramaImage: 3,
  7831. CGVideo: 4,
  7832. ClientRotationPano: 5,
  7833. CloudRotationPano: 6
  7834. };
  7835. var Xverse = /*#__PURE__*/function () {
  7836. function Xverse(e) {
  7837. _classCallCheck(this, Xverse);
  7838. e || (e = {});
  7839. var _e = e,
  7840. t = _e.onLog,
  7841. r = _e.env,
  7842. n = _e.appId,
  7843. o = _e.releaseId,
  7844. a = _e.subPackageVersion;
  7845. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger.setLevel(LoggerLevels.Debug);
  7846. var s = this.pageSession = util.uuid();
  7847. reporter$1.updateHeader({
  7848. pageSession: s
  7849. });
  7850. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  7851. a && reporter$1.updateBody({
  7852. sdkVersion: a
  7853. });
  7854. logger.infoAndReportMeasurement({
  7855. metric: "sdkInit",
  7856. startTime: Date.now(),
  7857. extra: {
  7858. version: a,
  7859. enviroment: r,
  7860. pageSession: s
  7861. }
  7862. });
  7863. logger.debug("debug mode:", this.debug);
  7864. reporter$1.on("report", function (l) {
  7865. t && t(l);
  7866. });
  7867. if (n) {
  7868. this.appId = n, this.releaseId = o;
  7869. var l = ModelManager.getInstance(n, o);
  7870. this.preload = new Preload(l);
  7871. }
  7872. }
  7873. _createClass(Xverse, [{
  7874. key: "isSupported",
  7875. get: function get() {
  7876. return isSupported();
  7877. }
  7878. }, {
  7879. key: "disableLogUpload",
  7880. value: function disableLogUpload() {
  7881. reporter$1.disable(), logger.debug("logger upload has been disabled");
  7882. }
  7883. }, {
  7884. key: "getSkinList",
  7885. value: function () {
  7886. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  7887. return regenerator.wrap(function _callee$(_context) {
  7888. while (1) {
  7889. switch (_context.prev = _context.next) {
  7890. case 0:
  7891. return _context.abrupt("return", []);
  7892. case 1:
  7893. case "end":
  7894. return _context.stop();
  7895. }
  7896. }
  7897. }, _callee);
  7898. }));
  7899. function getSkinList() {
  7900. return _getSkinList.apply(this, arguments);
  7901. }
  7902. return getSkinList;
  7903. }()
  7904. }, {
  7905. key: "getAvatarList",
  7906. value: function () {
  7907. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7908. return regenerator.wrap(function _callee2$(_context2) {
  7909. while (1) {
  7910. switch (_context2.prev = _context2.next) {
  7911. case 0:
  7912. return _context2.abrupt("return", []);
  7913. case 1:
  7914. case "end":
  7915. return _context2.stop();
  7916. }
  7917. }
  7918. }, _callee2);
  7919. }));
  7920. function getAvatarList() {
  7921. return _getAvatarList.apply(this, arguments);
  7922. }
  7923. return getAvatarList;
  7924. }()
  7925. }, {
  7926. key: "getGiftList",
  7927. value: function () {
  7928. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  7929. return regenerator.wrap(function _callee3$(_context3) {
  7930. while (1) {
  7931. switch (_context3.prev = _context3.next) {
  7932. case 0:
  7933. return _context3.abrupt("return", [{
  7934. id: "hack "
  7935. }]);
  7936. case 1:
  7937. case "end":
  7938. return _context3.stop();
  7939. }
  7940. }
  7941. }, _callee3);
  7942. }));
  7943. function getGiftList() {
  7944. return _getGiftList.apply(this, arguments);
  7945. }
  7946. return getGiftList;
  7947. }()
  7948. }, {
  7949. key: "joinRoom",
  7950. value: function () {
  7951. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  7952. var t, r, n, o;
  7953. return regenerator.wrap(function _callee4$(_context4) {
  7954. while (1) {
  7955. switch (_context4.prev = _context4.next) {
  7956. case 0:
  7957. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
  7958. appId: e.appId || this.appId,
  7959. releaseId: e.releaseId || this.releaseId,
  7960. pageSession: this.pageSession,
  7961. isAllSync: !0,
  7962. rotationRenderType: r,
  7963. syncByEvent: !0,
  7964. pathName: t,
  7965. person: n,
  7966. role: e.role || "audience"
  7967. }));
  7968. return _context4.abrupt("return", o.initRoom().then(function () {
  7969. return o;
  7970. }));
  7971. case 2:
  7972. case "end":
  7973. return _context4.stop();
  7974. }
  7975. }
  7976. }, _callee4, this);
  7977. }));
  7978. function joinRoom(_x) {
  7979. return _joinRoom.apply(this, arguments);
  7980. }
  7981. return joinRoom;
  7982. }()
  7983. }]);
  7984. return Xverse;
  7985. }();
  7986. var xverse = new Xverse({
  7987. env: "DEV",
  7988. appId: "10016",
  7989. releaseId: '2203120033_29769e'
  7990. });
  7991. var l = /*#__PURE__*/function () {
  7992. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  7993. var R;
  7994. return regenerator.wrap(function _callee$(_context) {
  7995. while (1) {
  7996. switch (_context.prev = _context.next) {
  7997. case 0:
  7998. _context.prev = 0;
  7999. _context.next = 3;
  8000. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  8001. });
  8002. case 3:
  8003. _context.next = 12;
  8004. break;
  8005. case 5:
  8006. _context.prev = 5;
  8007. _context.t0 = _context["catch"](0);
  8008. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  8009. _context.next = 10;
  8010. break;
  8011. }
  8012. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  8013. return _context.abrupt("return");
  8014. case 10:
  8015. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  8016. return _context.abrupt("return");
  8017. case 12:
  8018. _context.prev = 12;
  8019. _context.next = 15;
  8020. return xverse.joinRoom({
  8021. canvas: document.getElementById('canvas'),
  8022. skinId: 10092,
  8023. avatarId: 'KGe_Boy',
  8024. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  8025. userId: '1f7acca1db9d5',
  8026. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  8027. appId: "10016",
  8028. token: " ",
  8029. nickname: '1f7acca1db9d5',
  8030. firends: ["user1"],
  8031. viewMode: "full",
  8032. resolution: {
  8033. width: 1728,
  8034. height: 720
  8035. },
  8036. pathName: 'thirdwalk',
  8037. objectFit: null,
  8038. hasAvatar: !0,
  8039. syncToOthers: !0
  8040. });
  8041. case 15:
  8042. room = _context.sent;
  8043. debugger;
  8044. u();
  8045. c();
  8046. window.room = room;
  8047. e(!1);
  8048. _context.next = 28;
  8049. break;
  8050. case 23:
  8051. _context.prev = 23;
  8052. _context.t1 = _context["catch"](12);
  8053. console.error(_context.t1);
  8054. alert(_context.t1);
  8055. return _context.abrupt("return");
  8056. case 28:
  8057. case "end":
  8058. return _context.stop();
  8059. }
  8060. }
  8061. }, _callee, null, [[0, 5], [12, 23]]);
  8062. }));
  8063. return function l() {
  8064. return _ref.apply(this, arguments);
  8065. };
  8066. }();
  8067. var u = function u() {
  8068. room.on("_coreClick", function (_ref2) {
  8069. var f = _ref2.point;
  8070. room._userAvatar.moveTo({
  8071. point: f
  8072. });
  8073. });
  8074. };
  8075. var c = function c() {
  8076. room.on("repeatLogin", function () {
  8077. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  8078. duration: 1e4
  8079. });
  8080. }), room.on("reconnecting", function (_ref3) {
  8081. var f = _ref3.count;
  8082. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  8083. }), room.on("reconnected", function () {
  8084. toast("\u91CD\u8FDE\u6210\u529F");
  8085. }), room.on("disconnected", function () {
  8086. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  8087. duration: 1e5,
  8088. onClick() {
  8089. f.hideToast(), room.reconnect();
  8090. }
  8091. });
  8092. });
  8093. };
  8094. l();
  8095. }));
  8096. //# sourceMappingURL=index.js.map