index.js 408 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977
  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. objectParseFloat(i) {
  775. var e = {};
  776. return i && Object.keys(i).forEach(function (t) {
  777. e[t] = parseFloat(i[t]);
  778. }), e;
  779. },
  780. getRandomItem(i) {
  781. i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
  782. }
  783. };
  784. function _setPrototypeOf(o, p) {
  785. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  786. o.__proto__ = p;
  787. return o;
  788. };
  789. return _setPrototypeOf(o, p);
  790. }
  791. function _inherits(subClass, superClass) {
  792. if (typeof superClass !== "function" && superClass !== null) {
  793. throw new TypeError("Super expression must either be null or a function");
  794. }
  795. subClass.prototype = Object.create(superClass && superClass.prototype, {
  796. constructor: {
  797. value: subClass,
  798. writable: true,
  799. configurable: true
  800. }
  801. });
  802. Object.defineProperty(subClass, "prototype", {
  803. writable: false
  804. });
  805. if (superClass) _setPrototypeOf(subClass, superClass);
  806. }
  807. function _typeof(obj) {
  808. "@babel/helpers - typeof";
  809. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  810. return typeof obj;
  811. } : function (obj) {
  812. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  813. }, _typeof(obj);
  814. }
  815. function _assertThisInitialized(self) {
  816. if (self === void 0) {
  817. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  818. }
  819. return self;
  820. }
  821. function _possibleConstructorReturn(self, call) {
  822. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  823. return call;
  824. } else if (call !== void 0) {
  825. throw new TypeError("Derived constructors may only return object or undefined");
  826. }
  827. return _assertThisInitialized(self);
  828. }
  829. function _getPrototypeOf(o) {
  830. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  831. return o.__proto__ || Object.getPrototypeOf(o);
  832. };
  833. return _getPrototypeOf(o);
  834. }
  835. function _createSuper$l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); 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); }; }
  836. function _isNativeReflectConstruct$m() { 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; } }
  837. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  838. _inherits(Reporter, _EventEmitter);
  839. var _super = _createSuper$l(Reporter);
  840. function Reporter() {
  841. var _this;
  842. _classCallCheck(this, Reporter);
  843. _this = _super.call(this);
  844. _this._header = {};
  845. _this._body = {};
  846. _this._queue = [];
  847. _this._disabled = !1;
  848. _this._interval = null;
  849. _this._reportUrl = null;
  850. _this.isDocumentLoaded = function () {
  851. return document.readyState === "complete";
  852. };
  853. _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 () {
  854. _this._flushReport();
  855. }, 10 * 1e3);
  856. return _this;
  857. }
  858. _createClass(Reporter, [{
  859. key: "disable",
  860. value: function disable() {
  861. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  862. }
  863. }, {
  864. key: "updateHeader",
  865. value: function updateHeader(e) {
  866. Object.assign(this._header, e);
  867. }
  868. }, {
  869. key: "updateBody",
  870. value: function updateBody(e) {
  871. Object.assign(this._body, e);
  872. }
  873. }, {
  874. key: "updateReportUrl",
  875. value: function updateReportUrl(e) {
  876. this._reportUrl = e;
  877. }
  878. }, {
  879. key: "report",
  880. value: function report(e, t, r) {
  881. var _this2 = this;
  882. if (this._disabled) return;
  883. r || (r = {});
  884. var _r = r,
  885. n = _r.immediate,
  886. o = _r.sampleRate;
  887. if (o && o > Math.random()) return;
  888. this.updateBody({
  889. logTime: util.getFormattedDate(new Date()),
  890. logTimestamp: Date.now()
  891. });
  892. var a = function a(s) {
  893. var l = oe(le(oe({}, _this2._body), {
  894. type: e
  895. }), s);
  896. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  897. };
  898. Array.isArray(t) ? t.forEach(function (s) {
  899. return a(s);
  900. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  901. }
  902. }, {
  903. key: "_flushReport",
  904. value: function _flushReport() {
  905. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  906. var e = {
  907. header: this._header,
  908. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  909. };
  910. this._post(e);
  911. }
  912. }, {
  913. key: "_post",
  914. value: function _post(e) {
  915. var t = this._reportUrl || REPORT_URL.DEV;
  916. return new Promise(function (r, n) {
  917. var o = new XMLHttpRequest();
  918. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  919. try {
  920. o.send(JSON.stringify(e));
  921. } catch (a) {
  922. console.error(a);
  923. }
  924. o.addEventListener("readystatechange", function () {
  925. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  926. });
  927. });
  928. }
  929. }]);
  930. return Reporter;
  931. }(EventEmitter);
  932. var reporter$1 = new Reporter();
  933. function _arrayLikeToArray$2(arr, len) {
  934. if (len == null || len > arr.length) len = arr.length;
  935. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  936. arr2[i] = arr[i];
  937. }
  938. return arr2;
  939. }
  940. function _arrayWithoutHoles(arr) {
  941. if (Array.isArray(arr)) return _arrayLikeToArray$2(arr);
  942. }
  943. function _iterableToArray(iter) {
  944. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  945. }
  946. function _unsupportedIterableToArray$2(o, minLen) {
  947. if (!o) return;
  948. if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
  949. var n = Object.prototype.toString.call(o).slice(8, -1);
  950. if (n === "Object" && o.constructor) n = o.constructor.name;
  951. if (n === "Map" || n === "Set") return Array.from(o);
  952. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
  953. }
  954. function _nonIterableSpread() {
  955. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  956. }
  957. function _toConsumableArray(arr) {
  958. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$2(arr) || _nonIterableSpread();
  959. }
  960. var Codes = {
  961. Success: 0,
  962. Param: 1001,
  963. Internal: 1002,
  964. Timeout: 1003,
  965. Authentication: 1004,
  966. TokenExpired: 1005,
  967. Unsupported: 1006,
  968. InitNetworkTimeout: 1007,
  969. InitDecoderTimeout: 1008,
  970. InitConfigTimeout: 1009,
  971. InitEngineTimeout: 1010,
  972. InitEngine: 1011,
  973. ActionBlocked: 1012,
  974. PreloadCanceled: 1013,
  975. FrequencyLimit: 1014,
  976. UsersUpperLimit: 2e3,
  977. RoomsUpperLimit: 2001,
  978. ServerParam: 2002,
  979. LackOfToken: 2003,
  980. LoginFailed: 2004,
  981. VerifyServiceDown: 2005,
  982. CreateSessionFailed: 2006,
  983. RtcConnection: 2008,
  984. DoActionFailed: 2009,
  985. StateSyncFailed: 2010,
  986. BroadcastFailed: 2011,
  987. DataAbnormal: 2012,
  988. GetOnVehicle: 2015,
  989. RepeatLogin: 2017,
  990. RoomDoseNotExist: 2018,
  991. TicketExpire: 2019,
  992. ServerRateLimit: 2020,
  993. DoActionBlocked: 2333,
  994. ActionMaybeDelay: 2334,
  995. ActionResponseTimeout: 2999
  996. };
  997. var Logger = /*#__PURE__*/function () {
  998. function Logger(e) {
  999. _classCallCheck(this, Logger);
  1000. this.level = 3;
  1001. this.module = e;
  1002. }
  1003. _createClass(Logger, [{
  1004. key: "setLevel",
  1005. value: function setLevel(e) {
  1006. this.level = e;
  1007. }
  1008. }, {
  1009. key: "atleast",
  1010. value: function atleast(e) {
  1011. return e >= this.level && e >= this.level;
  1012. }
  1013. }, {
  1014. key: "print",
  1015. value: function print(e, t) {
  1016. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1017. r[_key - 2] = arguments[_key];
  1018. }
  1019. if (this.atleast(t)) {
  1020. var _console$n;
  1021. var n = e == "debug" ? "info" : e,
  1022. o = this.prefix(e);
  1023. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1024. }
  1025. if (e !== "debug" && e !== "info") {
  1026. var _n = r.map(function (o) {
  1027. if (o instanceof Object) try {
  1028. return JSON.stringify(o);
  1029. } catch (_unused) {
  1030. return o;
  1031. } else return o;
  1032. }).join(",");
  1033. reporter$1.report("log", {
  1034. message: _n,
  1035. level: e,
  1036. module: this.module
  1037. });
  1038. }
  1039. }
  1040. }, {
  1041. key: "debug",
  1042. value: function debug() {
  1043. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1044. e[_key2] = arguments[_key2];
  1045. }
  1046. return this.print.apply(this, ["debug", 1].concat(e));
  1047. }
  1048. }, {
  1049. key: "info",
  1050. value: function info() {
  1051. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1052. e[_key3] = arguments[_key3];
  1053. }
  1054. return this.print.apply(this, ["info", 2].concat(e));
  1055. }
  1056. }, {
  1057. key: "infoAndReportLog",
  1058. value: function infoAndReportLog(e) {
  1059. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1060. t[_key4 - 1] = arguments[_key4];
  1061. }
  1062. var r = e.reportOptions;
  1063. delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1064. }
  1065. }, {
  1066. key: "infoAndReportMeasurement",
  1067. value: function infoAndReportMeasurement(e) {
  1068. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1069. t[_key5 - 1] = arguments[_key5];
  1070. }
  1071. var n;
  1072. var r = e.reportOptions;
  1073. if (e.startTime) {
  1074. var o = Date.now();
  1075. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1076. }
  1077. 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) {
  1078. this.error.apply(this, _toConsumableArray(t));
  1079. return;
  1080. }
  1081. this.warn.apply(this, _toConsumableArray(t));
  1082. }
  1083. }, {
  1084. key: "warn",
  1085. value: function warn() {
  1086. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1087. e[_key6] = arguments[_key6];
  1088. }
  1089. return this.print.apply(this, ["warn", 3].concat(e));
  1090. }
  1091. }, {
  1092. key: "error",
  1093. value: function error() {
  1094. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1095. e[_key7] = arguments[_key7];
  1096. }
  1097. return this.print.apply(this, ["error", 4].concat(e));
  1098. }
  1099. }, {
  1100. key: "prefix",
  1101. value: function prefix(e) {
  1102. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1103. }
  1104. }], [{
  1105. key: "setLevel",
  1106. value: function setLevel(e) {
  1107. this.level = e;
  1108. }
  1109. }]);
  1110. return Logger;
  1111. }();
  1112. var logger = new Logger();
  1113. var AxiosCanceler = /*#__PURE__*/function () {
  1114. function AxiosCanceler() {
  1115. _classCallCheck(this, AxiosCanceler);
  1116. this.pendingMap = new Map();
  1117. }
  1118. _createClass(AxiosCanceler, [{
  1119. key: "addPending",
  1120. value: function addPending(e) {
  1121. var _this = this;
  1122. return new axios.CancelToken(function (t) {
  1123. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1124. });
  1125. }
  1126. }, {
  1127. key: "removeAllPending",
  1128. value: function removeAllPending() {
  1129. this.pendingMap.forEach(function (e) {
  1130. e && isFunction(e) && e();
  1131. }), this.pendingMap.clear();
  1132. }
  1133. }, {
  1134. key: "removePending",
  1135. value: function removePending(e) {
  1136. if (this.pendingMap.has(e)) {
  1137. var t = this.pendingMap.get(e);
  1138. t && t(e), this.pendingMap.delete(e);
  1139. }
  1140. }
  1141. }, {
  1142. key: "removeCancelToken",
  1143. value: function removeCancelToken(e) {
  1144. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1145. }
  1146. }, {
  1147. key: "reset",
  1148. value: function reset() {
  1149. this.pendingMap = new Map();
  1150. }
  1151. }]);
  1152. return AxiosCanceler;
  1153. }();
  1154. function _createSuper$k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$l(); 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); }; }
  1155. function _isNativeReflectConstruct$l() { 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; } }
  1156. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1157. _inherits(Http1, _EventEmitter);
  1158. var _super = _createSuper$k(Http1);
  1159. function Http1() {
  1160. var _this;
  1161. _classCallCheck(this, Http1);
  1162. _this = _super.call(this);
  1163. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1164. return _this;
  1165. }
  1166. _createClass(Http1, [{
  1167. key: "requestConstant",
  1168. value: function requestConstant() {
  1169. return {
  1170. x_nounce: this.randomString(),
  1171. x_timestamp: new Date().getTime(),
  1172. x_os: "web"
  1173. };
  1174. }
  1175. }, {
  1176. key: "requestParams",
  1177. value: function requestParams(e) {
  1178. return oe({}, e.params);
  1179. }
  1180. }, {
  1181. key: "get",
  1182. value: function get(e) {
  1183. return this.request(le(oe({}, e), {
  1184. method: "GET"
  1185. }));
  1186. }
  1187. }, {
  1188. key: "post",
  1189. value: function post(e) {
  1190. return this.request(le(oe({}, e), {
  1191. method: "POST"
  1192. }));
  1193. }
  1194. }, {
  1195. key: "request",
  1196. value: function request(e) {
  1197. var _this2 = this;
  1198. var t = e.url,
  1199. _e$timeout = e.timeout,
  1200. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1201. n = e.method,
  1202. o = e.key,
  1203. a = e.beforeRequest,
  1204. s = e.responseType,
  1205. l = e.data;
  1206. var _e$retry = e.retry,
  1207. u = _e$retry === void 0 ? 0 : _e$retry;
  1208. var c = this.patchUrl(t),
  1209. h = this.canceler.addPending(t);
  1210. a && isFunction(a) && a(e);
  1211. var f = this.requestParams(e);
  1212. var d = {
  1213. url: c,
  1214. method: n,
  1215. timeout: r,
  1216. cancelToken: h,
  1217. responseType: s,
  1218. params: f
  1219. };
  1220. n === "POST" && (d = oe({
  1221. data: l
  1222. }, d));
  1223. var _ = Date.now(),
  1224. g = function g() {
  1225. return _this2.instatnce.request(d).then(function (m) {
  1226. return o && logger.infoAndReportMeasurement({
  1227. metric: "http",
  1228. startTime: _,
  1229. extra: t,
  1230. group: "http",
  1231. tag: o
  1232. }), _this2.canceler.removeCancelToken(t), m;
  1233. }).catch(function (m) {
  1234. var v = axios.isCancel(m);
  1235. return u > 0 && !v ? (u--, logger.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger.infoAndReportMeasurement({
  1236. metric: "http",
  1237. startTime: _,
  1238. error: m,
  1239. extra: {
  1240. url: t,
  1241. isCanceled: v
  1242. },
  1243. tag: o,
  1244. group: "http"
  1245. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1246. });
  1247. };
  1248. return g();
  1249. }
  1250. }, {
  1251. key: "patchUrl",
  1252. value: function patchUrl(e) {
  1253. return e;
  1254. }
  1255. }, {
  1256. key: "randomString",
  1257. value: function randomString() {
  1258. var e = "";
  1259. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1260. r = t.length;
  1261. for (var n = 0; n < 8; n++) {
  1262. e += t.charAt(Math.floor(Math.random() * r));
  1263. }
  1264. return e;
  1265. }
  1266. }]);
  1267. return Http1;
  1268. }(EventEmitter);
  1269. var http1 = new Http1();
  1270. var ModelManager$1 = /*#__PURE__*/function () {
  1271. function ModelManager(e, t) {
  1272. _classCallCheck(this, ModelManager);
  1273. this.avatarModelList = [];
  1274. this.skinList = [];
  1275. this.applicationConfig = null;
  1276. this.config = null;
  1277. this.appId = e, this.releaseId = t;
  1278. }
  1279. _createClass(ModelManager, [{
  1280. key: "findSkinConfig",
  1281. value: function () {
  1282. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1283. var t, n;
  1284. return regenerator.wrap(function _callee$(_context) {
  1285. while (1) {
  1286. switch (_context.prev = _context.next) {
  1287. case 0:
  1288. t = null;
  1289. _context.next = 3;
  1290. return this.getSkinsList();
  1291. case 3:
  1292. t = (this.skinList = _context.sent).find(function (n) {
  1293. return n.id === e;
  1294. });
  1295. if (!t) {
  1296. _context.next = 6;
  1297. break;
  1298. }
  1299. return _context.abrupt("return", t);
  1300. case 6:
  1301. n = "skin is invalid: skinId: ".concat(e);
  1302. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1303. case 8:
  1304. case "end":
  1305. return _context.stop();
  1306. }
  1307. }
  1308. }, _callee, this);
  1309. }));
  1310. function findSkinConfig(_x) {
  1311. return _findSkinConfig.apply(this, arguments);
  1312. }
  1313. return findSkinConfig;
  1314. }()
  1315. }, {
  1316. key: "findRoute",
  1317. value: function () {
  1318. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1319. var n, o;
  1320. return regenerator.wrap(function _callee2$(_context2) {
  1321. while (1) {
  1322. switch (_context2.prev = _context2.next) {
  1323. case 0:
  1324. _context2.next = 2;
  1325. return this.findSkinConfig(e);
  1326. case 2:
  1327. n = _context2.sent.routeList.find(function (o) {
  1328. return o.pathName === t;
  1329. });
  1330. if (n) {
  1331. _context2.next = 6;
  1332. break;
  1333. }
  1334. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1335. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1336. case 6:
  1337. return _context2.abrupt("return", (logger.debug("find route success", n), n));
  1338. case 7:
  1339. case "end":
  1340. return _context2.stop();
  1341. }
  1342. }
  1343. }, _callee2, this);
  1344. }));
  1345. function findRoute(_x2, _x3) {
  1346. return _findRoute.apply(this, arguments);
  1347. }
  1348. return findRoute;
  1349. }()
  1350. }, {
  1351. key: "findAssetList",
  1352. value: function () {
  1353. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1354. var r, n;
  1355. return regenerator.wrap(function _callee3$(_context3) {
  1356. while (1) {
  1357. switch (_context3.prev = _context3.next) {
  1358. case 0:
  1359. _context3.next = 2;
  1360. return this.findSkinConfig(e);
  1361. case 2:
  1362. r = _context3.sent.assetList;
  1363. if (r) {
  1364. _context3.next = 6;
  1365. break;
  1366. }
  1367. n = "find path failed: skinId: ".concat(e);
  1368. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1369. case 6:
  1370. return _context3.abrupt("return", (logger.debug("find route success", r), r));
  1371. case 7:
  1372. case "end":
  1373. return _context3.stop();
  1374. }
  1375. }
  1376. }, _callee3, this);
  1377. }));
  1378. function findAssetList(_x4) {
  1379. return _findAssetList.apply(this, arguments);
  1380. }
  1381. return findAssetList;
  1382. }()
  1383. }, {
  1384. key: "findAsset",
  1385. value: function () {
  1386. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1387. var r,
  1388. n,
  1389. o,
  1390. a,
  1391. _args4 = arguments;
  1392. return regenerator.wrap(function _callee4$(_context4) {
  1393. while (1) {
  1394. switch (_context4.prev = _context4.next) {
  1395. case 0:
  1396. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1397. _context4.next = 3;
  1398. return this.findSkinConfig(e);
  1399. case 3:
  1400. n = _context4.sent;
  1401. if (!Array.isArray(t)) {
  1402. _context4.next = 6;
  1403. break;
  1404. }
  1405. return _context4.abrupt("return", t.map(function (a) {
  1406. return n.models.find(function (s) {
  1407. return s[r] === a;
  1408. });
  1409. }).filter(Boolean));
  1410. case 6:
  1411. o = n.models.find(function (a) {
  1412. return a[r] === t;
  1413. });
  1414. if (o) {
  1415. _context4.next = 10;
  1416. break;
  1417. }
  1418. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1419. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1420. case 10:
  1421. return _context4.abrupt("return", (logger.debug("find asset success", o), o));
  1422. case 11:
  1423. case "end":
  1424. return _context4.stop();
  1425. }
  1426. }
  1427. }, _callee4, this);
  1428. }));
  1429. function findAsset(_x5, _x6) {
  1430. return _findAsset.apply(this, arguments);
  1431. }
  1432. return findAsset;
  1433. }()
  1434. }, {
  1435. key: "findPoint",
  1436. value: function () {
  1437. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1438. var n, o;
  1439. return regenerator.wrap(function _callee5$(_context5) {
  1440. while (1) {
  1441. switch (_context5.prev = _context5.next) {
  1442. case 0:
  1443. _context5.next = 2;
  1444. return this.findSkinConfig(e);
  1445. case 2:
  1446. n = _context5.sent.pointList.find(function (o) {
  1447. return o.id === t;
  1448. });
  1449. if (n) {
  1450. _context5.next = 6;
  1451. break;
  1452. }
  1453. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1454. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1455. case 6:
  1456. return _context5.abrupt("return", (logger.debug("find point success", n), n));
  1457. case 7:
  1458. case "end":
  1459. return _context5.stop();
  1460. }
  1461. }
  1462. }, _callee5, this);
  1463. }));
  1464. function findPoint(_x7, _x8) {
  1465. return _findPoint.apply(this, arguments);
  1466. }
  1467. return findPoint;
  1468. }()
  1469. }, {
  1470. key: "requestConfig",
  1471. value: function () {
  1472. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1473. var t, r, _ref, n, o;
  1474. return regenerator.wrap(function _callee6$(_context6) {
  1475. while (1) {
  1476. switch (_context6.prev = _context6.next) {
  1477. case 0:
  1478. if (!this.config) {
  1479. _context6.next = 2;
  1480. break;
  1481. }
  1482. return _context6.abrupt("return", this.config);
  1483. case 2:
  1484. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1485. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1486. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  1487. t = './assets/config.json';
  1488. _context6.prev = 3;
  1489. _context6.next = 6;
  1490. return http1.get({
  1491. url: "".concat(t, "?t=").concat(Date.now()),
  1492. key: "config",
  1493. timeout: 6e3,
  1494. retry: 2
  1495. });
  1496. case 6:
  1497. r = _context6.sent;
  1498. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  1499. if (n) {
  1500. _context6.next = 10;
  1501. break;
  1502. }
  1503. throw new Error("config data parse error" + r.data);
  1504. case 10:
  1505. return _context6.abrupt("return", (this.config = {
  1506. config: n,
  1507. preload: o
  1508. }, logger.debug("get config success", this.config), this.config));
  1509. case 13:
  1510. _context6.prev = 13;
  1511. _context6.t0 = _context6["catch"](3);
  1512. return _context6.abrupt("return", Promise.reject(_context6.t0));
  1513. case 16:
  1514. case "end":
  1515. return _context6.stop();
  1516. }
  1517. }
  1518. }, _callee6, this, [[3, 13]]);
  1519. }));
  1520. function requestConfig() {
  1521. return _requestConfig.apply(this, arguments);
  1522. }
  1523. return requestConfig;
  1524. }()
  1525. }, {
  1526. key: "getApplicationConfig",
  1527. value: function () {
  1528. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  1529. var e;
  1530. return regenerator.wrap(function _callee7$(_context7) {
  1531. while (1) {
  1532. switch (_context7.prev = _context7.next) {
  1533. case 0:
  1534. if (!this.applicationConfig) {
  1535. _context7.next = 2;
  1536. break;
  1537. }
  1538. return _context7.abrupt("return", this.applicationConfig);
  1539. case 2:
  1540. _context7.prev = 2;
  1541. _context7.next = 5;
  1542. return this.requestConfig();
  1543. case 5:
  1544. e = _context7.sent;
  1545. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  1546. case 9:
  1547. _context7.prev = 9;
  1548. _context7.t0 = _context7["catch"](2);
  1549. return _context7.abrupt("return", Promise.reject(_context7.t0));
  1550. case 12:
  1551. case "end":
  1552. return _context7.stop();
  1553. }
  1554. }
  1555. }, _callee7, this, [[2, 9]]);
  1556. }));
  1557. function getApplicationConfig() {
  1558. return _getApplicationConfig.apply(this, arguments);
  1559. }
  1560. return getApplicationConfig;
  1561. }()
  1562. }, {
  1563. key: "getAvatarModelList",
  1564. value: function () {
  1565. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  1566. var _yield$this$getApplic, e;
  1567. return regenerator.wrap(function _callee8$(_context8) {
  1568. while (1) {
  1569. switch (_context8.prev = _context8.next) {
  1570. case 0:
  1571. if (!this.avatarModelList.length) {
  1572. _context8.next = 2;
  1573. break;
  1574. }
  1575. return _context8.abrupt("return", this.avatarModelList);
  1576. case 2:
  1577. _context8.prev = 2;
  1578. _context8.next = 5;
  1579. return this.getApplicationConfig();
  1580. case 5:
  1581. _yield$this$getApplic = _context8.sent;
  1582. e = _yield$this$getApplic.avatars;
  1583. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  1584. return {
  1585. name: t.name,
  1586. id: t.id,
  1587. modelUrl: t.url,
  1588. gender: t.gender,
  1589. components: t.components
  1590. };
  1591. }), this.avatarModelList));
  1592. case 10:
  1593. _context8.prev = 10;
  1594. _context8.t0 = _context8["catch"](2);
  1595. return _context8.abrupt("return", (logger.error(_context8.t0), []));
  1596. case 13:
  1597. case "end":
  1598. return _context8.stop();
  1599. }
  1600. }
  1601. }, _callee8, this, [[2, 10]]);
  1602. }));
  1603. function getAvatarModelList() {
  1604. return _getAvatarModelList.apply(this, arguments);
  1605. }
  1606. return getAvatarModelList;
  1607. }()
  1608. }, {
  1609. key: "getSkinsList",
  1610. value: function () {
  1611. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  1612. var _yield$this$getApplic2, e;
  1613. return regenerator.wrap(function _callee9$(_context9) {
  1614. while (1) {
  1615. switch (_context9.prev = _context9.next) {
  1616. case 0:
  1617. if (!this.skinList.length) {
  1618. _context9.next = 2;
  1619. break;
  1620. }
  1621. return _context9.abrupt("return", this.skinList);
  1622. case 2:
  1623. _context9.prev = 2;
  1624. _context9.next = 5;
  1625. return this.getApplicationConfig();
  1626. case 5:
  1627. _yield$this$getApplic2 = _context9.sent;
  1628. e = _yield$this$getApplic2.skins;
  1629. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  1630. var r;
  1631. return {
  1632. name: t.name,
  1633. dataVersion: t.id + t.versionId,
  1634. id: t.id,
  1635. fov: parseInt(t.fov || 90),
  1636. models: t.assetList.map(function (n) {
  1637. var o = n.assetId,
  1638. a = n.url,
  1639. s = n.thumbnailUrl,
  1640. l = n.typeName,
  1641. u = n.className;
  1642. return {
  1643. id: o,
  1644. modelUrl: a,
  1645. name: n.name,
  1646. thumbnailUrl: s,
  1647. typeName: l,
  1648. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  1649. };
  1650. }),
  1651. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  1652. var o = n.areaName,
  1653. a = n.attitude,
  1654. s = n.id,
  1655. l = n.pathName,
  1656. u = n.step,
  1657. c = n.birthPointList;
  1658. return {
  1659. areaName: o,
  1660. attitude: a,
  1661. id: s,
  1662. pathName: l,
  1663. step: u,
  1664. birthPointList: c.map(function (h) {
  1665. return {
  1666. camera: h.camera && {
  1667. position: util.objectParseFloat(h.camera.position),
  1668. angle: util.objectParseFloat(h.camera.rotation)
  1669. },
  1670. player: h.player && {
  1671. position: util.objectParseFloat(h.player.position),
  1672. angle: util.objectParseFloat(h.player.rotation)
  1673. }
  1674. };
  1675. })
  1676. };
  1677. }),
  1678. pointList: t.pointList.map(function (n) {
  1679. return le(oe({}, n), {
  1680. position: util.objectParseFloat(n.position),
  1681. rotation: util.objectParseFloat(n.rotation)
  1682. });
  1683. }),
  1684. versionId: t.versionId,
  1685. isEnable: t.isEnable,
  1686. assetList: t.assetList,
  1687. visibleRules: t.visibleRules,
  1688. animationList: t.animationList
  1689. };
  1690. }), this.skinList));
  1691. case 10:
  1692. _context9.prev = 10;
  1693. _context9.t0 = _context9["catch"](2);
  1694. return _context9.abrupt("return", (logger.error(_context9.t0), []));
  1695. case 13:
  1696. case "end":
  1697. return _context9.stop();
  1698. }
  1699. }
  1700. }, _callee9, this, [[2, 10]]);
  1701. }));
  1702. function getSkinsList() {
  1703. return _getSkinsList.apply(this, arguments);
  1704. }
  1705. return getSkinsList;
  1706. }()
  1707. }, {
  1708. key: "getBreathPointTextrueList",
  1709. value: function () {
  1710. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  1711. return regenerator.wrap(function _callee10$(_context10) {
  1712. while (1) {
  1713. switch (_context10.prev = _context10.next) {
  1714. case 0:
  1715. return _context10.abrupt("return", [{
  1716. url: TEXTURE_URL
  1717. }]);
  1718. case 1:
  1719. case "end":
  1720. return _context10.stop();
  1721. }
  1722. }
  1723. }, _callee10);
  1724. }));
  1725. function getBreathPointTextrueList() {
  1726. return _getBreathPointTextrueList.apply(this, arguments);
  1727. }
  1728. return getBreathPointTextrueList;
  1729. }()
  1730. }], [{
  1731. key: "getInstance",
  1732. value: function getInstance(e, t) {
  1733. //getInstance(e, t) {
  1734. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  1735. }
  1736. }, {
  1737. key: "findModels",
  1738. value: function findModels(e, t, r) {
  1739. //findModels(e, t, r) {
  1740. return e.filter(function (o) {
  1741. return o.typeName === t && o.className === r;
  1742. });
  1743. }
  1744. }, {
  1745. key: "findModel",
  1746. value: function findModel(e, t, r) {
  1747. //findModel(e, t, r) {
  1748. var n = e.filter(function (o) {
  1749. return o.typeName === t && o.className === r;
  1750. })[0];
  1751. return n || null;
  1752. }
  1753. }]);
  1754. return ModelManager;
  1755. }();
  1756. // export { modelManager };
  1757. var JoyStick = /*#__PURE__*/function () {
  1758. function JoyStick(e) {
  1759. _classCallCheck(this, JoyStick);
  1760. this._zone = document.createElement("div");
  1761. this._joystick = null;
  1762. this._room = e;
  1763. }
  1764. _createClass(JoyStick, [{
  1765. key: "init",
  1766. value: function init(e) {
  1767. var _this = this;
  1768. var _e$interval = e.interval,
  1769. t = _e$interval === void 0 ? 33 : _e$interval,
  1770. _e$triggerDistance = e.triggerDistance,
  1771. r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
  1772. _e$style = e.style,
  1773. n = _e$style === void 0 ? {
  1774. left: 0,
  1775. bottom: 0
  1776. } : _e$style,
  1777. o = function o(u, c) {
  1778. _this._room.actionsHandler.joystick({
  1779. degree: Math.floor(u),
  1780. level: Math.floor(c / 5)
  1781. });
  1782. },
  1783. a = this._zone;
  1784. 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({
  1785. zone: a,
  1786. mode: "static",
  1787. position: {
  1788. left: "50%",
  1789. top: "50%"
  1790. },
  1791. color: "white"
  1792. });
  1793. var s, l;
  1794. return this._joystick.on("move", function (u, c) {
  1795. s = c;
  1796. }), this._joystick.on("start", function () {
  1797. l = window.setInterval(function () {
  1798. s && s.distance > r && o && o(s.angle.degree, s.distance);
  1799. }, t);
  1800. }), this._joystick.on("end", function () {
  1801. l && window.clearInterval(l), l = void 0;
  1802. }), this._joystick;
  1803. }
  1804. }, {
  1805. key: "show",
  1806. value: function show() {
  1807. if (!this._joystick) throw new Error("joystick is not created");
  1808. this._zone.style.display = "block";
  1809. }
  1810. }, {
  1811. key: "hide",
  1812. value: function hide() {
  1813. if (!this._joystick) throw new Error("joystick is not created");
  1814. this._zone.style.display = "none";
  1815. }
  1816. }]);
  1817. return JoyStick;
  1818. }();
  1819. var CoreBroadcastType = {
  1820. PlayAnimation: 'PlayAnimation'
  1821. };
  1822. var AvatarGroup = {
  1823. Npc: 'npc',
  1824. User: 'user'
  1825. };
  1826. var MessageHandleType$1 = {
  1827. MHT_Undefined: 0,
  1828. MHT_RoomMulticast: 1,
  1829. MHT_FollowListMulticast: 2,
  1830. MHT_CustomTargetSync: 3
  1831. };
  1832. var Broadcast$1 = /*#__PURE__*/function () {
  1833. function Broadcast(e, t) {
  1834. _classCallCheck(this, Broadcast);
  1835. this.room = e;
  1836. this.handlers = [];
  1837. this.init(t);
  1838. }
  1839. _createClass(Broadcast, [{
  1840. key: "init",
  1841. value: function init(t) {
  1842. this.handlers.push(t);
  1843. }
  1844. }, {
  1845. key: "handleBroadcast",
  1846. value: function () {
  1847. var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1848. return regenerator.wrap(function _callee$(_context) {
  1849. while (1) {
  1850. switch (_context.prev = _context.next) {
  1851. case 0:
  1852. _context.prev = 1;
  1853. JSON.parse(e.broadcastAction.data);
  1854. _context.next = 9;
  1855. break;
  1856. case 5:
  1857. _context.prev = 5;
  1858. _context.t0 = _context["catch"](1);
  1859. logger.error(_context.t0);
  1860. return _context.abrupt("return");
  1861. case 9:
  1862. case "end":
  1863. return _context.stop();
  1864. }
  1865. }
  1866. }, _callee, null, [[1, 5]]);
  1867. }));
  1868. function handleBroadcast(_x) {
  1869. return _handleBroadcast.apply(this, arguments);
  1870. }
  1871. return handleBroadcast;
  1872. }()
  1873. }, {
  1874. key: "broadcast",
  1875. value: function broadcast(e) {
  1876. var t = e.data,
  1877. _e$msgType = e.msgType,
  1878. r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
  1879. n = e.targetUserIds;
  1880. return this.room.actionsHandler.broadcast({
  1881. data: t,
  1882. msgType: r,
  1883. targetUserIds: n
  1884. });
  1885. }
  1886. }]);
  1887. return Broadcast;
  1888. }();
  1889. function _isNativeFunction(fn) {
  1890. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  1891. }
  1892. function _isNativeReflectConstruct$k() {
  1893. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  1894. if (Reflect.construct.sham) return false;
  1895. if (typeof Proxy === "function") return true;
  1896. try {
  1897. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  1898. return true;
  1899. } catch (e) {
  1900. return false;
  1901. }
  1902. }
  1903. function _construct(Parent, args, Class) {
  1904. if (_isNativeReflectConstruct$k()) {
  1905. _construct = Reflect.construct;
  1906. } else {
  1907. _construct = function _construct(Parent, args, Class) {
  1908. var a = [null];
  1909. a.push.apply(a, args);
  1910. var Constructor = Function.bind.apply(Parent, a);
  1911. var instance = new Constructor();
  1912. if (Class) _setPrototypeOf(instance, Class.prototype);
  1913. return instance;
  1914. };
  1915. }
  1916. return _construct.apply(null, arguments);
  1917. }
  1918. function _wrapNativeSuper(Class) {
  1919. var _cache = typeof Map === "function" ? new Map() : undefined;
  1920. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  1921. if (Class === null || !_isNativeFunction(Class)) return Class;
  1922. if (typeof Class !== "function") {
  1923. throw new TypeError("Super expression must either be null or a function");
  1924. }
  1925. if (typeof _cache !== "undefined") {
  1926. if (_cache.has(Class)) return _cache.get(Class);
  1927. _cache.set(Class, Wrapper);
  1928. }
  1929. function Wrapper() {
  1930. return _construct(Class, arguments, _getPrototypeOf(this).constructor);
  1931. }
  1932. Wrapper.prototype = Object.create(Class.prototype, {
  1933. constructor: {
  1934. value: Wrapper,
  1935. enumerable: false,
  1936. writable: true,
  1937. configurable: true
  1938. }
  1939. });
  1940. return _setPrototypeOf(Wrapper, Class);
  1941. };
  1942. return _wrapNativeSuper(Class);
  1943. }
  1944. function _createSuper$j(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); }; }
  1945. 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; } }
  1946. var XverseError = /*#__PURE__*/function (_Error) {
  1947. _inherits(XverseError, _Error);
  1948. var _super = _createSuper$j(XverseError);
  1949. function XverseError(e, t) {
  1950. var _this;
  1951. _classCallCheck(this, XverseError);
  1952. _this = _super.call(this, t);
  1953. _this.code = e;
  1954. return _this;
  1955. }
  1956. _createClass(XverseError, [{
  1957. key: "toJSON",
  1958. value: function toJSON() {
  1959. return {
  1960. code: this.code,
  1961. message: this.message
  1962. };
  1963. }
  1964. }, {
  1965. key: "toString",
  1966. value: function toString() {
  1967. if (Object(this) !== this) throw new TypeError();
  1968. var t = this.name;
  1969. t = t === void 0 ? "Error" : String(t);
  1970. var r = this.message;
  1971. r = r === void 0 ? "" : String(r);
  1972. var n = this.code;
  1973. return r = n === void 0 ? r : n + "," + r, t === "" ? r : r === "" ? t : t + ": " + r;
  1974. }
  1975. }]);
  1976. return XverseError;
  1977. }( /*#__PURE__*/_wrapNativeSuper(Error));
  1978. function _createSuper$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$i(); 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); }; }
  1979. function _isNativeReflectConstruct$i() { 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; } }
  1980. var TimeoutError = /*#__PURE__*/function (_XverseError) {
  1981. _inherits(TimeoutError, _XverseError);
  1982. var _super = _createSuper$i(TimeoutError);
  1983. function TimeoutError(e) {
  1984. _classCallCheck(this, TimeoutError);
  1985. return _super.call(this, 1003, e || "\u8D85\u65F6");
  1986. }
  1987. return _createClass(TimeoutError);
  1988. }(XverseError);
  1989. 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); }; }
  1990. 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; } }
  1991. var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
  1992. _inherits(XverseAvatarManager, _EventEmitter);
  1993. var _super = _createSuper$h(XverseAvatarManager);
  1994. function XverseAvatarManager(e) {
  1995. var _this;
  1996. _classCallCheck(this, XverseAvatarManager);
  1997. _this = _super.call(this);
  1998. _this.xAvatarManager = null;
  1999. _this.avatars = new Map();
  2000. _this.syncAvatarsLength = 0;
  2001. _this._room = e;
  2002. _this._usersStatistics();
  2003. _this.broadcast = _this.setupBroadcast();
  2004. e.on("skinChanged", function () {
  2005. _this.avatars.forEach(function (t) {
  2006. t.disconnected && _this.removeAvatar(t.userId, !0);
  2007. });
  2008. });
  2009. return _this;
  2010. }
  2011. _createClass(XverseAvatarManager, [{
  2012. key: "setupBroadcast",
  2013. value: function setupBroadcast() {
  2014. var _this2 = this;
  2015. return new Broadcast$1(this._room, /*#__PURE__*/function () {
  2016. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2017. var t, r, n, o, a, _r$loop, s, l;
  2018. return regenerator.wrap(function _callee$(_context) {
  2019. while (1) {
  2020. switch (_context.prev = _context.next) {
  2021. case 0:
  2022. t = e.broadcastType, r = e.info;
  2023. if (!(t !== CoreBroadcastType.PlayAnimation)) {
  2024. _context.next = 3;
  2025. break;
  2026. }
  2027. return _context.abrupt("return");
  2028. case 3:
  2029. 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);
  2030. _context.t0 = l && !l.isSelf;
  2031. if (!_context.t0) {
  2032. _context.next = 10;
  2033. break;
  2034. }
  2035. l.emit("animationStart", {
  2036. animationName: o,
  2037. extra: decodeURIComponent(a)
  2038. });
  2039. _context.next = 9;
  2040. return l == null ? void 0 : l._playAnimation(o, s);
  2041. case 9:
  2042. l.emit("animationEnd", {
  2043. animationName: o,
  2044. extra: decodeURIComponent(a)
  2045. });
  2046. case 10:
  2047. case "end":
  2048. return _context.stop();
  2049. }
  2050. }
  2051. }, _callee);
  2052. }));
  2053. return function (_x) {
  2054. return _ref.apply(this, arguments);
  2055. };
  2056. }());
  2057. }
  2058. }, {
  2059. key: "hideAll",
  2060. value: function hideAll() {
  2061. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2062. this.xAvatarManager.hideAll(e);
  2063. }
  2064. }, {
  2065. key: "showAll",
  2066. value: function showAll() {
  2067. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  2068. this.xAvatarManager.showAll(e);
  2069. }
  2070. }, {
  2071. key: "init",
  2072. value: function () {
  2073. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2074. var e, t;
  2075. return regenerator.wrap(function _callee2$(_context2) {
  2076. while (1) {
  2077. switch (_context2.prev = _context2.next) {
  2078. case 0:
  2079. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  2080. _context2.prev = 1;
  2081. _context2.next = 4;
  2082. return this._room.modelManager.getApplicationConfig();
  2083. case 4:
  2084. e = _context2.sent;
  2085. t = e.avatars;
  2086. if (!t) {
  2087. _context2.next = 10;
  2088. break;
  2089. }
  2090. _context2.next = 9;
  2091. return avatarLoader.parse(this._room.sceneManager, t);
  2092. case 9:
  2093. return _context2.abrupt("return");
  2094. case 10:
  2095. return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
  2096. case 13:
  2097. _context2.prev = 13;
  2098. _context2.t0 = _context2["catch"](1);
  2099. return _context2.abrupt("return", (logger.error(_context2.t0), Promise.reject("avatar mananger init error!")));
  2100. case 16:
  2101. case "end":
  2102. return _context2.stop();
  2103. }
  2104. }
  2105. }, _callee2, this, [[1, 13]]);
  2106. }));
  2107. function init() {
  2108. return _init.apply(this, arguments);
  2109. }
  2110. return init;
  2111. }()
  2112. }, {
  2113. key: "handleAvatar",
  2114. value: function () {
  2115. var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  2116. var _this3 = this;
  2117. var r, t, n, o, _n, a;
  2118. return regenerator.wrap(function _callee3$(_context3) {
  2119. while (1) {
  2120. switch (_context3.prev = _context3.next) {
  2121. case 0:
  2122. if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
  2123. _context3.next = 2;
  2124. break;
  2125. }
  2126. return _context3.abrupt("return");
  2127. case 2:
  2128. t = e.newUserStates;
  2129. if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
  2130. n = t.filter(function (a) {
  2131. return a.userId === _this3._room.userId;
  2132. }), o = t.filter(function (a) {
  2133. return a.userId !== _this3._room.userId;
  2134. }).slice(0, 2);
  2135. t = n.concat(o);
  2136. }
  2137. if (e.getStateType === GetStateTypes.Event) {
  2138. this.syncAvatarsLength = (t || []).length;
  2139. _n = this._room.avatars.filter(function (s) {
  2140. return s.group == AvatarGroup.User;
  2141. });
  2142. _n.filter(function (s) {
  2143. return !(t != null && t.find(function (l) {
  2144. return l.userId == s.userId;
  2145. }));
  2146. }).forEach(function (s) {
  2147. _this3.removeAvatar(s.userId);
  2148. });
  2149. a = t.filter(function (s) {
  2150. return !_n.find(function (l) {
  2151. return l.userId == s.userId;
  2152. });
  2153. });
  2154. this._handleAvatar(a);
  2155. }
  2156. this._handleAvatar(t);
  2157. case 6:
  2158. case "end":
  2159. return _context3.stop();
  2160. }
  2161. }
  2162. }, _callee3, this);
  2163. }));
  2164. function handleAvatar(_x2) {
  2165. return _handleAvatar2.apply(this, arguments);
  2166. }
  2167. return handleAvatar;
  2168. }()
  2169. }, {
  2170. key: "_handleAvatar",
  2171. value: function () {
  2172. var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  2173. var _this4 = this;
  2174. return regenerator.wrap(function _callee4$(_context4) {
  2175. while (1) {
  2176. switch (_context4.prev = _context4.next) {
  2177. case 0:
  2178. e == null || e.forEach(function (t) {
  2179. var n, o, a, s, l, u, c, h, f;
  2180. var r = _this4._room.userId === t.userId;
  2181. if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
  2182. var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
  2183. _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
  2184. g = _.code,
  2185. m = _.msg;
  2186. d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
  2187. code: g,
  2188. msg: m
  2189. });
  2190. }
  2191. if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
  2192. var _d = _this4.avatars.get(t.userId);
  2193. if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
  2194. 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) {
  2195. var _2 = safeParseComponents(t.playerState.avatarComponents);
  2196. _d._changeComponents({
  2197. avatarComponents: _2,
  2198. mode: ChangeComponentsMode.Preview
  2199. });
  2200. }
  2201. } else {
  2202. var _t$playerState$player = t.playerState.player,
  2203. _3 = _t$playerState$player.position,
  2204. _g = _t$playerState$player.angle,
  2205. _m = t.playerState.avatarId,
  2206. v = t.playerState.prioritySync,
  2207. y = safelyJsonParse(t.playerState.extra);
  2208. if (!_m) return;
  2209. var b = safeParseComponents(t.playerState.avatarComponents),
  2210. T = safeDecodeURIComponent(t.playerState.nickName),
  2211. C = _this4.calculatePriority(t.userId, y);
  2212. _this4.addAvatar({
  2213. userId: t.userId,
  2214. isHost: t.playerState.isHost,
  2215. nickname: T,
  2216. avatarPosition: _3,
  2217. avatarRotation: _g,
  2218. avatarScale: t.playerState.avatarSize,
  2219. avatarId: _m,
  2220. avatarComponents: t.playerState.person === Person.First ? [] : b,
  2221. priority: C,
  2222. group: AvatarGroup.User,
  2223. prioritySync: v,
  2224. extraInfo: y
  2225. }).then(function () {
  2226. var A;
  2227. (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"));
  2228. }).catch(function (A) {
  2229. r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
  2230. error: A
  2231. }), logger.error("userAvatarFailed", A));
  2232. });
  2233. }
  2234. }
  2235. 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) {
  2236. (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
  2237. var _d2 = _this4.avatars.get(t.userId);
  2238. _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
  2239. }
  2240. if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
  2241. var _d3 = _this4.avatars.get(t.userId);
  2242. _d3.statusSyncQueue.append({
  2243. type: QueueType.Rotate,
  2244. action: function action() {
  2245. return _d3.statusSync(t);
  2246. }
  2247. });
  2248. }
  2249. });
  2250. case 1:
  2251. case "end":
  2252. return _context4.stop();
  2253. }
  2254. }
  2255. }, _callee4);
  2256. }));
  2257. function _handleAvatar(_x3) {
  2258. return _handleAvatar3.apply(this, arguments);
  2259. }
  2260. return _handleAvatar;
  2261. }()
  2262. }, {
  2263. key: "calculatePriority",
  2264. value: function calculatePriority(e, t) {
  2265. var n;
  2266. return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
  2267. }
  2268. }, {
  2269. key: "updateAvatarPositionAndRotation",
  2270. value: function updateAvatarPositionAndRotation(e) {
  2271. var t, r;
  2272. if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
  2273. var _e$playerState$player = e.playerState.player,
  2274. n = _e$playerState$player.position,
  2275. o = _e$playerState$player.angle;
  2276. var a = this.avatars.get(e.userId);
  2277. if (!a) return;
  2278. 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({
  2279. type: QueueType.Move,
  2280. action: function action() {
  2281. return a.statusSync(e);
  2282. }
  2283. }), e.renderInfo && a.isSelf) {
  2284. var _e$renderInfo = e.renderInfo,
  2285. s = _e$renderInfo.isMoving,
  2286. l = _e$renderInfo.isRotating;
  2287. this._updateAvatarMovingStatus({
  2288. id: e.userId,
  2289. isMoving: !!s,
  2290. isRotating: !!l
  2291. });
  2292. }
  2293. }
  2294. }
  2295. }, {
  2296. key: "addAvatar",
  2297. value: function () {
  2298. var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  2299. 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;
  2300. return regenerator.wrap(function _callee5$(_context5) {
  2301. while (1) {
  2302. switch (_context5.prev = _context5.next) {
  2303. case 0:
  2304. 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;
  2305. g = this.avatars.get(t);
  2306. if (!g) {
  2307. _context5.next = 4;
  2308. break;
  2309. }
  2310. return _context5.abrupt("return", Promise.resolve(g));
  2311. case 4:
  2312. if (!(g = new xe.subAvatar({
  2313. userId: t,
  2314. isHost: r,
  2315. isSelf: _,
  2316. room: this._room,
  2317. avatarComponents: l,
  2318. avatarId: o,
  2319. nickname: s,
  2320. group: c
  2321. }), this.avatars.set(t, g), !g.withModel)) {
  2322. _context5.next = 6;
  2323. break;
  2324. }
  2325. return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  2326. avatars: this._room.avatars
  2327. }), g));
  2328. case 6:
  2329. _context5.next = 8;
  2330. return this._room.modelManager.getAvatarModelList();
  2331. case 8:
  2332. v = _context5.sent.find(function (b) {
  2333. return b.id === o;
  2334. });
  2335. y = Date.now();
  2336. if (v) {
  2337. _context5.next = 12;
  2338. break;
  2339. }
  2340. return _context5.abrupt("return", (this._room.emit("avatarChanged", {
  2341. avatars: this._room.avatars
  2342. }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
  2343. case 12:
  2344. _context5.prev = 12;
  2345. _context5.next = 15;
  2346. return avatarComponentsModify(v, l);
  2347. case 15:
  2348. b = _context5.sent;
  2349. b = b.filter(function (A) {
  2350. return A.type != "pendant";
  2351. });
  2352. _context5.next = 19;
  2353. return avatarComponentsParser(v, b);
  2354. case 19:
  2355. T = _context5.sent;
  2356. _context5.next = 22;
  2357. return this.xAvatarManager.loadAvatar({
  2358. id: t,
  2359. avatarType: o,
  2360. priority: u,
  2361. avatarManager: this.xAvatarManager,
  2362. assets: T,
  2363. status: {
  2364. avatarPosition: n,
  2365. avatarRotation: a,
  2366. avatarScale: h
  2367. }
  2368. })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
  2369. case 22:
  2370. C = _context5.sent;
  2371. 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", {
  2372. avatars: this._room.avatars
  2373. }), s && g._setNickname(s), t === this._room.userId && (logger.infoAndReportMeasurement({
  2374. metric: "avatarLoadDuration",
  2375. startTime: y,
  2376. group: "costs"
  2377. }), logger.infoAndReportMeasurement({
  2378. metric: "avatarLoadAt",
  2379. startTime: this._room._startTime,
  2380. group: "costs"
  2381. })), g));
  2382. case 26:
  2383. _context5.prev = 26;
  2384. _context5.t0 = _context5["catch"](12);
  2385. return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
  2386. avatars: this._room.avatars
  2387. }), logger.error(_context5.t0), Promise.reject(_context5.t0)));
  2388. case 29:
  2389. case "end":
  2390. return _context5.stop();
  2391. }
  2392. }
  2393. }, _callee5, this, [[12, 26]]);
  2394. }));
  2395. function addAvatar(_x4) {
  2396. return _addAvatar.apply(this, arguments);
  2397. }
  2398. return addAvatar;
  2399. }()
  2400. }, {
  2401. key: "removeAvatar",
  2402. value: function removeAvatar(e) {
  2403. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  2404. var r = this.avatars.get(e);
  2405. if (!!r) {
  2406. if (r.removeWhenDisconnected || t) {
  2407. r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
  2408. avatars: this._room.avatars
  2409. });
  2410. return;
  2411. }
  2412. r.setConnectionStatus(!0);
  2413. }
  2414. }
  2415. }, {
  2416. key: "clearOtherUsers",
  2417. value: function clearOtherUsers() {
  2418. var _this5 = this;
  2419. this.avatars.forEach(function (e) {
  2420. !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
  2421. });
  2422. }
  2423. }, {
  2424. key: "_updateAvatarMovingStatus",
  2425. value: function () {
  2426. var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  2427. var t, r, n, o, a, _a;
  2428. return regenerator.wrap(function _callee6$(_context6) {
  2429. while (1) {
  2430. switch (_context6.prev = _context6.next) {
  2431. case 0:
  2432. t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
  2433. if (!!o) {
  2434. if (o.isRotating !== n) {
  2435. o.isRotating = n;
  2436. a = "Idle";
  2437. n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger.infoAndReportMeasurement({
  2438. startTime: Date.now(),
  2439. value: 0,
  2440. metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
  2441. extra: {
  2442. motionType: o.motionType,
  2443. moveToExtra: this._room.moveToExtra
  2444. }
  2445. });
  2446. }
  2447. if (o.isMoving !== r) {
  2448. o.isMoving = r;
  2449. _a = "Idle";
  2450. r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
  2451. target: o,
  2452. extra: this._room.moveToExtra
  2453. })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
  2454. target: o,
  2455. extra: this._room.moveToExtra
  2456. })), o._playAnimation(_a, !0, !0), logger.infoAndReportMeasurement({
  2457. startTime: Date.now(),
  2458. value: 0,
  2459. metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
  2460. extra: {
  2461. motionType: o.motionType,
  2462. moveToExtra: this._room.moveToExtra
  2463. }
  2464. });
  2465. }
  2466. }
  2467. case 2:
  2468. case "end":
  2469. return _context6.stop();
  2470. }
  2471. }
  2472. }, _callee6, this);
  2473. }));
  2474. function _updateAvatarMovingStatus(_x5) {
  2475. return _updateAvatarMovingStatus2.apply(this, arguments);
  2476. }
  2477. return _updateAvatarMovingStatus;
  2478. }()
  2479. }, {
  2480. key: "_usersStatistics",
  2481. value: function _usersStatistics() {
  2482. var _this6 = this;
  2483. this.on("userAvatarLoaded", function () {
  2484. window.setInterval(function () {
  2485. var e = _this6._room.avatars.filter(function (r) {
  2486. return r.group === AvatarGroup.User;
  2487. }).length || 0,
  2488. t = _this6._room.avatars.filter(function (r) {
  2489. return r.group === AvatarGroup.User && r.isRender;
  2490. }).length || 0;
  2491. _this6._room.stats.assign({
  2492. userNum: e,
  2493. syncUserNum: _this6.syncAvatarsLength,
  2494. renderedUserNum: t
  2495. });
  2496. }, 3e3);
  2497. });
  2498. }
  2499. }]);
  2500. return XverseAvatarManager;
  2501. }(EventEmitter);
  2502. var PathManager = /*#__PURE__*/function () {
  2503. function PathManager() {
  2504. _classCallCheck(this, PathManager);
  2505. this.currentArea = '';
  2506. this.currentPathName = '';
  2507. this.currentAttitude = '';
  2508. this.speed = 0;
  2509. }
  2510. _createClass(PathManager, [{
  2511. key: "getSpeed",
  2512. value: function getSpeed(e) {
  2513. var t = {
  2514. guangchang: {
  2515. [MotionType.Walk]: 17,
  2516. [MotionType.Run]: 51
  2517. },
  2518. tower: {
  2519. [MotionType.Walk]: 12.5,
  2520. [MotionType.Run]: 25
  2521. },
  2522. zhiboting: {
  2523. [MotionType.Walk]: 12.5,
  2524. [MotionType.Run]: 25
  2525. },
  2526. youxiting: {
  2527. [MotionType.Walk]: 12.5,
  2528. [MotionType.Run]: 25
  2529. },
  2530. diqing: {
  2531. [MotionType.Walk]: 12.5,
  2532. [MotionType.Run]: 25
  2533. }
  2534. },
  2535. r = t[this.currentArea] || t.guangchang;
  2536. return this.speed = r[e] * 30, this.speed;
  2537. }
  2538. }]);
  2539. return PathManager;
  2540. }();
  2541. var CameraStates = {
  2542. Normal: 0,
  2543. ItemView: 1,
  2544. CGView: 2,
  2545. PathView: 3
  2546. };
  2547. var Person$1 = {
  2548. Third: 0,
  2549. First: 1
  2550. };
  2551. var EImageQuality = {
  2552. low: 0,
  2553. mid: 1,
  2554. high: 2
  2555. };
  2556. 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); }; }
  2557. 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; } }
  2558. var Camera = /*#__PURE__*/function (_EventEmitter) {
  2559. _inherits(Camera, _EventEmitter);
  2560. var _super = _createSuper$g(Camera);
  2561. function Camera(e) {
  2562. var _this;
  2563. _classCallCheck(this, Camera);
  2564. _this = _super.call(this);
  2565. _this.initialFov = 0;
  2566. _this._state = CameraStates.Normal;
  2567. _this._person = Person$1.Third;
  2568. _this._cameraFollowing = !0;
  2569. _this._room = e;
  2570. return _this;
  2571. }
  2572. _createClass(Camera, [{
  2573. key: "checkPointOnLeftOrRight",
  2574. value: function checkPointOnLeftOrRight(e) {
  2575. var t = ue4Position2Xverse(e);
  2576. if (!t || this.checkPointInView(e)) return;
  2577. var o = this._room.scene.activeCamera;
  2578. if (!o) return;
  2579. var a = [o.target.x, o.target.y, o.target.z],
  2580. s = [o.position.x, o.position.y, o.position.z],
  2581. l = t.x,
  2582. u = t.y,
  2583. c = t.z,
  2584. h = calNormVector(s, a),
  2585. f = calNormVector(s, [l, u, c]);
  2586. return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
  2587. }
  2588. }, {
  2589. key: "checkPointInView",
  2590. value: function checkPointInView(e, t, r) {
  2591. var n = ue4Position2Xverse({
  2592. x: e,
  2593. y: t,
  2594. z: r
  2595. });
  2596. if (!n) return !1;
  2597. for (var o = 0; o < 6; o++) {
  2598. if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  2599. }
  2600. return !0;
  2601. }
  2602. }, {
  2603. key: "person",
  2604. get: function get() {
  2605. return this._person;
  2606. }
  2607. }, {
  2608. key: "state",
  2609. get: function get() {
  2610. return this._state;
  2611. }
  2612. }, {
  2613. key: "pose",
  2614. get: function get() {
  2615. return this._room.currentClickingState.camera;
  2616. }
  2617. }, {
  2618. key: "cameraFollowing",
  2619. get: function get() {
  2620. return this._cameraFollowing;
  2621. },
  2622. set: function set(e) {
  2623. logger.info("cameraFollowing setter", e), this.setCameraFollowing({
  2624. isFollowHost: e
  2625. });
  2626. }
  2627. }, {
  2628. key: "setCameraFollowing",
  2629. value: function setCameraFollowing(_ref) {
  2630. _ref.isFollowHost;
  2631. }
  2632. }, {
  2633. key: "handleRenderInfo",
  2634. value: function handleRenderInfo(e) {
  2635. var t = e.renderInfo.cameraStateType,
  2636. r = this._room.sceneManager;
  2637. 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", {
  2638. state: t
  2639. })), this._room.isHost) return;
  2640. var n = e.playerState.isFollowHost;
  2641. !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
  2642. cameraFollowing: !!n
  2643. }));
  2644. }
  2645. }, {
  2646. key: "setCameraState",
  2647. value: function setCameraState(_ref2) {
  2648. var e = _ref2.state;
  2649. if (this._state === e) {
  2650. logger.warn("You are already in ".concat(CameraStates[e], " camera state"));
  2651. return;
  2652. }
  2653. e === CameraStates.Normal || this._state === CameraStates.ItemView && logger.warn("CloseUp camera state can only be triggerd by room internally");
  2654. }
  2655. }, {
  2656. key: "turnToFace",
  2657. value: function turnToFace(_ref3) {
  2658. var _ref3$extra = _ref3.extra,
  2659. e = _ref3$extra === void 0 ? "" : _ref3$extra,
  2660. _ref3$offset = _ref3.offset,
  2661. t = _ref3$offset === void 0 ? 0 : _ref3$offset;
  2662. var r = {
  2663. action_type: Actions.TurnToFace,
  2664. turn_to_face_action: {
  2665. offset: t
  2666. }
  2667. };
  2668. return this.emit("viewChanged", {
  2669. extra: e
  2670. }), this._room.actionsHandler.sendData({
  2671. data: r
  2672. });
  2673. }
  2674. }, {
  2675. key: "isInDefaultView",
  2676. value: function isInDefaultView() {
  2677. if (!this._room.isHost) {
  2678. logger.warn("It is recommended to call the function on the host side");
  2679. return;
  2680. }
  2681. if (!this._room._currentClickingState) return logger.error("CurrentState should not be empty"), !1;
  2682. var _this$_room$_currentC = this._room._currentClickingState,
  2683. e = _this$_room$_currentC.camera,
  2684. t = _this$_room$_currentC.player;
  2685. return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
  2686. }
  2687. }, {
  2688. key: "screenShot",
  2689. value: function () {
  2690. var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
  2691. var e, _ref4$autoSave, t, r, n, o;
  2692. return regenerator.wrap(function _callee$(_context) {
  2693. while (1) {
  2694. switch (_context.prev = _context.next) {
  2695. case 0:
  2696. e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
  2697. r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
  2698. _context.prev = 2;
  2699. this._room.sceneManager.setImageQuality(EImageQuality.high);
  2700. _context.next = 6;
  2701. return CreateScreenshotAsync(r, n, {
  2702. precision: 1
  2703. });
  2704. case 6:
  2705. o = _context.sent;
  2706. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
  2707. case 10:
  2708. _context.prev = 10;
  2709. _context.t0 = _context["catch"](2);
  2710. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
  2711. case 13:
  2712. case "end":
  2713. return _context.stop();
  2714. }
  2715. }
  2716. }, _callee, this, [[2, 10]]);
  2717. }));
  2718. function screenShot(_x) {
  2719. return _screenShot.apply(this, arguments);
  2720. }
  2721. return screenShot;
  2722. }()
  2723. }, {
  2724. key: "changeToFirstPerson",
  2725. value: function changeToFirstPerson(e, t, r) {
  2726. var _this2 = this;
  2727. var n = e.camera,
  2728. o = e.player,
  2729. a = e.attitude,
  2730. s = e.areaName,
  2731. l = e.pathName;
  2732. return this._room.actionsHandler.requestPanorama({
  2733. camera: n,
  2734. player: o,
  2735. attitude: a,
  2736. areaName: s,
  2737. pathName: l
  2738. }, t, r).then(function () {
  2739. _this2._room.networkController.rtcp.workers.changePanoMode(!0);
  2740. var _ref5 = o || {},
  2741. u = _ref5.position,
  2742. c = _ref5.angle;
  2743. _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
  2744. position: u,
  2745. rotation: c
  2746. });
  2747. });
  2748. }
  2749. }, {
  2750. key: "setPerson",
  2751. value: function setPerson(e) {
  2752. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  2753. camera: this._room._currentClickingState.camera,
  2754. player: this._room._currentClickingState.player
  2755. };
  2756. var r = Date.now();
  2757. return this._setPerson(e, t).then(function (n) {
  2758. return logger.infoAndReportMeasurement({
  2759. tag: Person$1[e],
  2760. startTime: r,
  2761. metric: "setPerson"
  2762. }), n;
  2763. }).catch(function (n) {
  2764. return logger.infoAndReportMeasurement({
  2765. tag: Person$1[e],
  2766. startTime: r,
  2767. metric: "setPerson",
  2768. error: n
  2769. }), Promise.reject(n);
  2770. });
  2771. }
  2772. }, {
  2773. key: "_setPerson",
  2774. value: function _setPerson(e) {
  2775. var _this3 = this;
  2776. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  2777. camera: this._room._currentClickingState.camera,
  2778. player: this._room._currentClickingState.player
  2779. };
  2780. 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({
  2781. camera: t.camera,
  2782. player: t.player,
  2783. tag: "setPerson"
  2784. }).then(function () {
  2785. var o, a;
  2786. _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
  2787. var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
  2788. r = _ref6.position,
  2789. n = _ref6.angle;
  2790. !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
  2791. position: r,
  2792. rotation: n
  2793. });
  2794. }) : this._room.panorama.exit({
  2795. camera: t.camera,
  2796. player: t.player
  2797. }).then(function () {
  2798. var r, n;
  2799. _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
  2800. });
  2801. }
  2802. }, {
  2803. key: "setCameraPose",
  2804. value: function setCameraPose(e) {
  2805. this._room.sceneManager.cameraComponent.setCameraPose({
  2806. position: e.position,
  2807. rotation: e.angle
  2808. });
  2809. }
  2810. }, {
  2811. key: "setMainCameraRotationLimit",
  2812. value: function setMainCameraRotationLimit(e) {
  2813. var t = e.limitAxis,
  2814. r = e.limitRotation;
  2815. this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
  2816. }
  2817. }]);
  2818. return Camera;
  2819. }(EventEmitter);
  2820. 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); }; }
  2821. 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; } }
  2822. var numberFormat = new Intl.NumberFormat(window.navigator.language, {
  2823. maximumFractionDigits: 0
  2824. });
  2825. var Stats = /*#__PURE__*/function (_EventEmitter) {
  2826. _inherits(Stats, _EventEmitter);
  2827. var _super = _createSuper$f(Stats);
  2828. function Stats(e) {
  2829. var _this;
  2830. _classCallCheck(this, Stats);
  2831. _this = _super.call(this);
  2832. _this._netInterval = null;
  2833. _this._disabled = !1;
  2834. _this._show = !1;
  2835. _this._aggregatedStats = {};
  2836. _this._displayElement = null;
  2837. _this._extraStats = {};
  2838. _this._networkSamples = [];
  2839. _this.externalStats = null;
  2840. _this.constructedTime = null;
  2841. _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
  2842. var t, r, n;
  2843. _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
  2844. }, 1e3), _this._netInterval = window.setInterval(function () {
  2845. _this.getIsWeakNet();
  2846. }, NET_INTERVAL * 1e3);
  2847. return _this;
  2848. }
  2849. _createClass(Stats, [{
  2850. key: "isShow",
  2851. get: function get() {
  2852. return this._show;
  2853. }
  2854. }, {
  2855. key: "assign",
  2856. value: function assign(e) {
  2857. Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
  2858. }
  2859. }, {
  2860. key: "appendExternalStats",
  2861. value: function appendExternalStats(e) {
  2862. var _this2 = this;
  2863. var t = {};
  2864. if (!e || typeof e != "object") {
  2865. console.warn("appendExternalStats should be plain object");
  2866. return;
  2867. }
  2868. Object.keys(e).forEach(function (r) {
  2869. Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
  2870. }), !(Object.keys(t).length > 10) && (this.externalStats = t);
  2871. }
  2872. }, {
  2873. key: "getRtt",
  2874. value: function getRtt() {
  2875. var e = this._extraStats.rtt;
  2876. return typeof e != "number" ? 0 : e > 999 ? 999 : e;
  2877. }
  2878. }, {
  2879. key: "enable",
  2880. value: function enable() {
  2881. this._disabled = !1;
  2882. }
  2883. }, {
  2884. key: "disable",
  2885. value: function disable() {
  2886. this._disabled = !0;
  2887. }
  2888. }, {
  2889. key: "disableNet",
  2890. value: function disableNet() {
  2891. this._netInterval && window.clearInterval(this._netInterval);
  2892. }
  2893. }, {
  2894. key: "show",
  2895. value: function show() {
  2896. this._show = !0, this._render();
  2897. }
  2898. }, {
  2899. key: "hide",
  2900. value: function hide() {
  2901. this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
  2902. }
  2903. }, {
  2904. key: "getIsWeakNet",
  2905. value: function getIsWeakNet() {
  2906. var _this3 = this;
  2907. var e = !1;
  2908. var t = this._networkSamples.length - 1;
  2909. if (t < 0) return;
  2910. var r = this._networkSamples[t].time,
  2911. n = this._networkSamples[0].time,
  2912. o = r - n,
  2913. a = 1e3 * (DURATION - 2);
  2914. if (o < a) return;
  2915. var s = this._networkSamples.map(function (g) {
  2916. return _this3.isNetDelay(g, "rtt");
  2917. }),
  2918. l = this._networkSamples.map(function (g) {
  2919. return _this3.isNetDelay(g, "hb");
  2920. }),
  2921. u = s.reduce(function (g, m) {
  2922. return g + m;
  2923. }, 0),
  2924. c = l.reduce(function (g, m) {
  2925. return g + m;
  2926. }, 0),
  2927. h = Math.floor(u / this._networkSamples.length) * 100,
  2928. f = Math.floor(c / this._networkSamples.length) * 100,
  2929. d = 70;
  2930. (h >= d || f >= d) && (e = !0);
  2931. var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
  2932. e && !_ && (logger.infoAndReportMeasurement({
  2933. metric: "weakNetwork",
  2934. startTime: Date.now(),
  2935. extra: {
  2936. msg: this._networkSamples.slice(20),
  2937. netDelayRTTValues: u,
  2938. netDelayHBValues: c
  2939. }
  2940. }), this.emit("weakNetwork"));
  2941. }
  2942. }, {
  2943. key: "startStatsNetSamples",
  2944. value: function startStatsNetSamples() {
  2945. var _this$_extraStats = this._extraStats,
  2946. e = _this$_extraStats.rtt,
  2947. t = _this$_extraStats.hb;
  2948. if (e || t) {
  2949. var r = {
  2950. rtt: e,
  2951. hb: t,
  2952. time: new Date().getTime()
  2953. };
  2954. this._networkSamples.push(r);
  2955. var n = this._networkSamples.length - 1;
  2956. if (n < 0) return;
  2957. var o = this._networkSamples[n].time,
  2958. a = 1e3 * DURATION;
  2959. this._networkSamples = this._networkSamples.filter(function (s) {
  2960. return s.time > o - a;
  2961. });
  2962. }
  2963. }
  2964. }, {
  2965. key: "isNetDelay",
  2966. value: function isNetDelay(e, t) {
  2967. return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
  2968. }
  2969. }, {
  2970. key: "getPreciesTimer",
  2971. value: function getPreciesTimer(e, t) {
  2972. var r = t * 1e3,
  2973. n = new Date().getTime();
  2974. var o = 0;
  2975. o++;
  2976. var a = new Date().getTime() - (n + o * 1e3),
  2977. s = r - a,
  2978. l = setTimeout(function () {
  2979. clearTimeout(l), e();
  2980. }, s);
  2981. }
  2982. }, {
  2983. key: "_render",
  2984. value: function _render() {
  2985. var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
  2986. if (!this._aggregatedStats) return;
  2987. 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));
  2988. var e = [],
  2989. t = Date.now() - this.constructedTime,
  2990. r = Math.floor(t / 1e3 % 60),
  2991. n = Math.floor(t / (1e3 * 60) % 60),
  2992. o = Math.floor(t / (1e3 * 60 * 60) % 24),
  2993. a = o < 10 ? "0" + o.toString() : o.toString(),
  2994. s = n < 10 ? "0" + n : n,
  2995. l = r < 10 ? "0" + r : r;
  2996. e.push({
  2997. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  2998. value: a + ":" + s + ":" + l
  2999. }), e.push({
  3000. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  3001. value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
  3002. }), e.push({
  3003. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  3004. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  3005. }), e.push({
  3006. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  3007. value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
  3008. }), e.push({
  3009. key: "media/meta bitrate(kbps)",
  3010. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  3011. }), e.push({
  3012. key: ":----------------Decoding---------------",
  3013. value: ""
  3014. }), e.push({
  3015. key: "-max/avg decodeTime(ms)",
  3016. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  3017. }), e.push({
  3018. key: "-frmAwait/Lost/Drop",
  3019. 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
  3020. }), e.push({
  3021. key: ":----------------FrameLoop-------------",
  3022. value: ""
  3023. }), e.push({
  3024. key: "interval(max/avg/>40)",
  3025. 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
  3026. }), e.push({
  3027. key: "systemStuck",
  3028. value: this._extraStats.systemStuckCnt
  3029. }), e.push({
  3030. key: "--update",
  3031. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
  3032. }), e.push({
  3033. key: "--timeout",
  3034. value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
  3035. }), e.push({
  3036. key: "--render",
  3037. value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
  3038. }), e.push({
  3039. key: "---anim/regBR/clip(avg ms)",
  3040. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  3041. }), e.push({
  3042. key: "---anim/regBR/clip(max ms)",
  3043. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  3044. }), e.push({
  3045. key: "---rTR/drC/regAF(avg ms)",
  3046. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  3047. }), e.push({
  3048. key: "---rTR/drC/regAF(max ms)",
  3049. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  3050. }), e.push({
  3051. key: "--tri/drC/pati/bones/anim(Num)",
  3052. 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)
  3053. }), e.push({
  3054. key: "--rootN/mesh/geo/tex/mat(Num)",
  3055. 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)
  3056. }), e.push({
  3057. key: "--registerBF/AF(Num)",
  3058. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  3059. }), e.push({
  3060. key: ":----------------Rotation-------------------",
  3061. value: ""
  3062. }), e.push({
  3063. key: "Total(ms/miss)",
  3064. value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  3065. }), e.push({
  3066. key: "--rotateRsp",
  3067. value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  3068. }), e.push({
  3069. key: "--rotateProc",
  3070. value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  3071. }), e.push({
  3072. key: "--rotateShow",
  3073. value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  3074. }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
  3075. key: ":----------------Move----------------------",
  3076. value: ""
  3077. }), e.push({
  3078. key: "-startDelay",
  3079. 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)
  3080. }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
  3081. key: "-srvInterFrm(max/avg)",
  3082. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  3083. }), e.push({
  3084. key: "-interFrameDelay",
  3085. value: "(max/avg/jank)"
  3086. }), e.push({
  3087. key: "--toDisplay",
  3088. 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)
  3089. }), e.push({
  3090. key: "--received",
  3091. 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)
  3092. }), e.push({
  3093. key: "--decoded",
  3094. 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)
  3095. }), e.push({
  3096. key: ":----------------DevInfo-----------------",
  3097. value: ""
  3098. }), e.push({
  3099. key: "sd",
  3100. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  3101. }), e.push({
  3102. key: "----hardwareInfo",
  3103. value: this._extraStats.hardwareInfo
  3104. });
  3105. var u = "";
  3106. for (var _i = 0, _e = e; _i < _e.length; _i++) {
  3107. var O = _e[_i];
  3108. u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
  3109. }
  3110. this._displayElement.innerHTML = u;
  3111. }
  3112. }, {
  3113. key: "onStats",
  3114. value: function onStats(e) {
  3115. var _this4 = this;
  3116. var n;
  3117. if (!e) return;
  3118. var t = {},
  3119. r = this;
  3120. 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) {
  3121. t[o] = _this4.externalStats[o];
  3122. }), r._aggregatedStats = t, this.emit("stats", {
  3123. stats: t
  3124. });
  3125. }
  3126. }]);
  3127. return Stats;
  3128. }(EventEmitter);
  3129. var Actions$1 = {
  3130. Clicking: 1,
  3131. PlayCG: 6,
  3132. Back: 7,
  3133. ChangeRoom: 8,
  3134. ChangeSkin: 13,
  3135. Joystick: 15,
  3136. Transfer: 18,
  3137. GetOnVehicle: 22,
  3138. GetOffVehicle: 23,
  3139. StopMoving: 34,
  3140. UnaryActionLine: 1e3,
  3141. Init: 1001,
  3142. Exit: 1002,
  3143. SetIFrameInfo: 1003,
  3144. GetNeighborPoints: 1004,
  3145. ReserveSeat: 1005,
  3146. GetReserveStatus: 1006,
  3147. ChangeNickname: 1007,
  3148. ChangeBitRateInfo: 1008,
  3149. Echo: 1009,
  3150. SetPlayerState: 1010,
  3151. TurnTo: 1011,
  3152. TurnToFace: 1012,
  3153. RotateTo: 1013,
  3154. Rotation: 1014,
  3155. CameraTurnTo: 1015,
  3156. ConfirmEvent: 1016,
  3157. Broadcast: 1017,
  3158. NotifyActionLine: 2e4,
  3159. AudienceChangeToVisitor: 1020,
  3160. VisitorChangeToAudience: 1021,
  3161. RemoveVisitor: 1022,
  3162. GetUserWithAvatar: 1023
  3163. };
  3164. 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); }; }
  3165. 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; } }
  3166. var EventsManager = /*#__PURE__*/function (_EventEmitter) {
  3167. _inherits(EventsManager, _EventEmitter);
  3168. var _super = _createSuper$e(EventsManager);
  3169. function EventsManager() {
  3170. var _this;
  3171. _classCallCheck(this, EventsManager);
  3172. _this = _super.apply(this, arguments);
  3173. E(_assertThisInitialized(_this), "events", new Map());
  3174. E(_assertThisInitialized(_this), "specialEvents", new Map());
  3175. return _this;
  3176. }
  3177. _createClass(EventsManager, [{
  3178. key: "remove",
  3179. value: function remove(e, t, r, n) {
  3180. if (this.specialEvents.has(e) && !n && t === Codes$1.Success) return;
  3181. this.events.get(e) && (this.emit(e, {
  3182. code: t,
  3183. data: r
  3184. }), this.events.delete(e), this.specialEvents.delete(e));
  3185. }
  3186. }, {
  3187. key: "track",
  3188. value: function () {
  3189. var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  3190. var _this2 = this;
  3191. var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
  3192. return regenerator.wrap(function _callee$(_context) {
  3193. while (1) {
  3194. switch (_context.prev = _context.next) {
  3195. case 0:
  3196. r = e.traceId;
  3197. this.emitTraceIdToDecoder(e);
  3198. _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
  3199. if (!(n && Math.random() > n)) {
  3200. _context.next = 5;
  3201. break;
  3202. }
  3203. return _context.abrupt("return", Promise.resolve());
  3204. case 5:
  3205. s = Actions[e.event] + "Action", l = e.tag;
  3206. this.events.set(r, !0), a && this.specialEvents.set(r, !0);
  3207. u = Date.now();
  3208. c = null;
  3209. return _context.abrupt("return", new Promise(function (h, f) {
  3210. if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
  3211. _this2.on(r, function (_ref2) {
  3212. var _ = _ref2.code,
  3213. g = _ref2.data,
  3214. m = _ref2.msg;
  3215. if (_ === Codes$1.Success) h(g), _this2.off(r), logger.infoAndReportMeasurement({
  3216. metric: s,
  3217. tag: l,
  3218. extra: e.extra,
  3219. startTime: u,
  3220. traceId: r
  3221. });else {
  3222. if (_ === Codes$1.ActionMaybeDelay) return;
  3223. if (_ === Codes$1.DoActionBlocked && e.event === Actions.Rotation) {
  3224. logger.debug(s + " response code: " + _);
  3225. return;
  3226. }
  3227. var v = getErrorByCode(_),
  3228. y = new v(m);
  3229. _this2.off(r), f(y), _this2.emit("actionResponseError", {
  3230. error: y,
  3231. event: e,
  3232. tag: l
  3233. }), logger.infoAndReportMeasurement({
  3234. metric: s,
  3235. tag: l,
  3236. extra: e.extra,
  3237. error: y,
  3238. startTime: u,
  3239. traceId: r
  3240. });
  3241. }
  3242. });
  3243. var d = e.timeout || 2e3;
  3244. c = window.setTimeout(function () {
  3245. if (c && clearTimeout(c), !_this2.events.get(r)) return;
  3246. var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
  3247. _this2.emit("actionResponseTimeout", {
  3248. error: _,
  3249. event: e,
  3250. tag: l
  3251. }), f(_), _this2.events.delete(r), _this2.off(r), logger.infoAndReportMeasurement({
  3252. metric: s,
  3253. tag: l,
  3254. extra: e.extra,
  3255. error: _,
  3256. startTime: u,
  3257. traceId: r
  3258. });
  3259. }, d);
  3260. }));
  3261. case 10:
  3262. case "end":
  3263. return _context.stop();
  3264. }
  3265. }
  3266. }, _callee, this);
  3267. }));
  3268. function track(_x, _x2) {
  3269. return _track.apply(this, arguments);
  3270. }
  3271. return track;
  3272. }()
  3273. }, {
  3274. key: "emitTraceIdToDecoder",
  3275. value: function emitTraceIdToDecoder(e) {
  3276. if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
  3277. var t = {
  3278. [Actions.Rotation]: "Rotation",
  3279. [Actions.GetOnVehicle]: "GetOnVehicle",
  3280. [Actions.GetOffVehicle]: "GetOffVehicle",
  3281. [Actions.Clicking]: "MoveTo"
  3282. };
  3283. this.emit("traceId", {
  3284. traceId: e.traceId,
  3285. timestamp: Date.now(),
  3286. event: t[e.event]
  3287. });
  3288. }
  3289. }
  3290. }]);
  3291. return EventsManager;
  3292. }(EventEmitter);
  3293. var eventsManager = new EventsManager();
  3294. var QueueActions = [Actions$1.Transfer, Actions$1.ChangeSkin, Actions$1.GetOnVehicle, Actions$1.GetOffVehicle];
  3295. var ActionsHandler = /*#__PURE__*/function () {
  3296. function ActionsHandler(e) {
  3297. _classCallCheck(this, ActionsHandler);
  3298. this.currentActiveAction = null;
  3299. this.room = e;
  3300. }
  3301. _createClass(ActionsHandler, [{
  3302. key: "avatarComponentsSync",
  3303. value: function () {
  3304. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3305. var t;
  3306. return regenerator.wrap(function _callee$(_context) {
  3307. while (1) {
  3308. switch (_context.prev = _context.next) {
  3309. case 0:
  3310. t = {
  3311. action_type: Actions$1.SetPlayerState,
  3312. set_player_state_action: {
  3313. player_state: {
  3314. avatar_components: JSON.stringify(e)
  3315. }
  3316. }
  3317. };
  3318. this.sendData({
  3319. data: t
  3320. });
  3321. case 2:
  3322. case "end":
  3323. return _context.stop();
  3324. }
  3325. }
  3326. }, _callee, this);
  3327. }));
  3328. function avatarComponentsSync(_x) {
  3329. return _avatarComponentsSync.apply(this, arguments);
  3330. }
  3331. return avatarComponentsSync;
  3332. }()
  3333. }, {
  3334. key: "sendData",
  3335. value: function () {
  3336. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  3337. var _this = this;
  3338. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  3339. return regenerator.wrap(function _callee2$(_context2) {
  3340. while (1) {
  3341. switch (_context2.prev = _context2.next) {
  3342. case 0:
  3343. _context2.next = 2;
  3344. return this.beforeSend(e);
  3345. case 2:
  3346. t = util.uuid();
  3347. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  3348. trace_id: t,
  3349. user_id: this.room.options.userId
  3350. })), e.track === !1)) {
  3351. _context2.next = 5;
  3352. break;
  3353. }
  3354. return _context2.abrupt("return", Promise.resolve(null));
  3355. case 5:
  3356. _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;
  3357. return _context2.abrupt("return", eventsManager.track({
  3358. timeout: n,
  3359. traceId: t,
  3360. event: a.action_type,
  3361. tag: o,
  3362. extra: a
  3363. }, {
  3364. special: s,
  3365. sampleRate: r,
  3366. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  3367. }).finally(function () {
  3368. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  3369. }));
  3370. case 7:
  3371. case "end":
  3372. return _context2.stop();
  3373. }
  3374. }
  3375. }, _callee2, this);
  3376. }));
  3377. function sendData(_x2) {
  3378. return _sendData.apply(this, arguments);
  3379. }
  3380. return sendData;
  3381. }()
  3382. }, {
  3383. key: "beforeSend",
  3384. value: function () {
  3385. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3386. var o, t, r;
  3387. return regenerator.wrap(function _callee3$(_context3) {
  3388. while (1) {
  3389. switch (_context3.prev = _context3.next) {
  3390. case 0:
  3391. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  3392. if (!QueueActions.includes(r)) {
  3393. _context3.next = 5;
  3394. break;
  3395. }
  3396. if (!this.currentActiveAction) {
  3397. _context3.next = 4;
  3398. break;
  3399. }
  3400. 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")))));
  3401. case 4:
  3402. this.currentActiveAction = r;
  3403. case 5:
  3404. if (!(t && QueueActions.includes(e.data.action_type))) {
  3405. _context3.next = 14;
  3406. break;
  3407. }
  3408. _context3.prev = 6;
  3409. _context3.next = 9;
  3410. return this.stopMoving();
  3411. case 9:
  3412. _context3.next = 14;
  3413. break;
  3414. case 11:
  3415. _context3.prev = 11;
  3416. _context3.t0 = _context3["catch"](6);
  3417. this.currentActiveAction = void 0, logger.error("before action stopMoving failed", _context3.t0);
  3418. case 14:
  3419. case "end":
  3420. return _context3.stop();
  3421. }
  3422. }
  3423. }, _callee3, this, [[6, 11]]);
  3424. }));
  3425. function beforeSend(_x3) {
  3426. return _beforeSend.apply(this, arguments);
  3427. }
  3428. return beforeSend;
  3429. }()
  3430. }, {
  3431. key: "moveTo",
  3432. value: function () {
  3433. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3434. var t, _e$extra, r, n, o;
  3435. return regenerator.wrap(function _callee4$(_context4) {
  3436. while (1) {
  3437. switch (_context4.prev = _context4.next) {
  3438. case 0:
  3439. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  3440. action_type: Actions$1.Clicking,
  3441. clicking_action: {
  3442. clicking_point: t,
  3443. clicking_type: ClickType.IgnoreView,
  3444. extra: encodeURIComponent(r),
  3445. attitude: n
  3446. },
  3447. clicking_state: this.room._currentClickingState
  3448. };
  3449. return _context4.abrupt("return", this.sendData({
  3450. data: o
  3451. }));
  3452. case 2:
  3453. case "end":
  3454. return _context4.stop();
  3455. }
  3456. }
  3457. }, _callee4, this);
  3458. }));
  3459. function moveTo(_x4) {
  3460. return _moveTo.apply(this, arguments);
  3461. }
  3462. return moveTo;
  3463. }()
  3464. }, {
  3465. key: "transfer",
  3466. value: function transfer(e) {
  3467. var _this2 = this;
  3468. var t = e.renderType,
  3469. r = e.player,
  3470. n = e.camera,
  3471. o = e.areaName,
  3472. a = e.attitude,
  3473. s = e.pathName,
  3474. l = e.person,
  3475. u = e.noMedia,
  3476. c = e.timeout,
  3477. h = e.tag,
  3478. f = e.special,
  3479. d = {
  3480. data: {
  3481. action_type: Actions$1.Transfer,
  3482. transfer_action: {
  3483. render_type: t,
  3484. player: r,
  3485. camera: n,
  3486. areaName: o,
  3487. attitude: a,
  3488. pathName: s,
  3489. person: {
  3490. type: l
  3491. },
  3492. noMedia: u,
  3493. tiles: [0, 1, 2, 4]
  3494. }
  3495. },
  3496. special: f,
  3497. timeout: c || 4e3,
  3498. tag: h
  3499. };
  3500. return this.sendData(d).then(function (_) {
  3501. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  3502. person: l,
  3503. rotationRenderType: t
  3504. }), _;
  3505. });
  3506. }
  3507. }, {
  3508. key: "changeRotationRenderType",
  3509. value: function changeRotationRenderType(e) {
  3510. var t = e.renderType,
  3511. r = e.player,
  3512. n = e.camera,
  3513. o = e.areaName,
  3514. a = e.attitude,
  3515. s = e.pathName;
  3516. return this.transfer({
  3517. renderType: t,
  3518. player: r,
  3519. camera: n,
  3520. areaName: o,
  3521. attitude: a,
  3522. pathName: s,
  3523. tag: "changeToRotationVideo"
  3524. });
  3525. }
  3526. }, {
  3527. key: "requestPanorama",
  3528. value: function requestPanorama(e, t, r) {
  3529. var n = e.camera,
  3530. o = e.player,
  3531. a = e.areaName,
  3532. s = e.attitude,
  3533. l = e.pathName,
  3534. u = e.tag;
  3535. return this.transfer({
  3536. renderType: RenderType.ClientRotationPano,
  3537. player: o,
  3538. camera: n,
  3539. person: Person.First,
  3540. areaName: a,
  3541. attitude: s,
  3542. pathName: l,
  3543. noMedia: t,
  3544. timeout: r,
  3545. tag: u || "requestPanorama",
  3546. special: !t
  3547. });
  3548. }
  3549. }, {
  3550. key: "setMotionType",
  3551. value: function setMotionType(e) {
  3552. return this.transfer({
  3553. attitude: e,
  3554. tag: "setMotionType"
  3555. });
  3556. }
  3557. }, {
  3558. key: "setNickName",
  3559. value: function setNickName(e) {
  3560. var t = {
  3561. action_type: Actions$1.ChangeNickname,
  3562. change_nickname_action: {
  3563. nickname: e
  3564. }
  3565. };
  3566. return this.sendData({
  3567. data: t
  3568. });
  3569. }
  3570. }, {
  3571. key: "getReserveSeat",
  3572. value: function getReserveSeat(_ref) {
  3573. var e = _ref.routeId,
  3574. t = _ref.name;
  3575. var r = {
  3576. action_type: Actions$1.ReserveSeat,
  3577. reserve_seat_action: {
  3578. route_id: e,
  3579. name: t
  3580. }
  3581. };
  3582. return this.sendData({
  3583. data: r
  3584. });
  3585. }
  3586. }, {
  3587. key: "getReserveStatus",
  3588. value: function getReserveStatus(_ref2) {
  3589. var e = _ref2.routeId,
  3590. t = _ref2.name,
  3591. r = _ref2.need_detail;
  3592. var n = {
  3593. action_type: Actions$1.GetReserveStatus,
  3594. get_reserve_status_action: {
  3595. route_id: e,
  3596. name: t,
  3597. need_detail: r
  3598. }
  3599. };
  3600. return this.sendData({
  3601. data: n,
  3602. timeout: 2e3
  3603. }).then(function (o) {
  3604. return o.reserveDetail;
  3605. });
  3606. }
  3607. }, {
  3608. key: "stopMoving",
  3609. value: function stopMoving() {
  3610. var e = {
  3611. action_type: Actions$1.StopMoving,
  3612. stop_move_action: {}
  3613. };
  3614. return this.sendData({
  3615. data: e
  3616. });
  3617. }
  3618. }, {
  3619. key: "getOnVehicle",
  3620. value: function getOnVehicle(_ref3) {
  3621. var e = _ref3.routeId,
  3622. t = _ref3.name,
  3623. r = _ref3.camera;
  3624. var n = {
  3625. action_type: Actions$1.GetOnVehicle,
  3626. get_on_vehicle_action: {
  3627. route_id: e,
  3628. name: t,
  3629. camera: r
  3630. }
  3631. };
  3632. return this.sendData({
  3633. data: n
  3634. });
  3635. }
  3636. }, {
  3637. key: "getOffVehicle",
  3638. value: function getOffVehicle(_ref4) {
  3639. var e = _ref4.renderType,
  3640. t = _ref4.player,
  3641. r = _ref4.camera;
  3642. var n = {
  3643. action_type: Actions$1.GetOffVehicle,
  3644. get_off_vehicle_action: {
  3645. render_type: e,
  3646. player: t,
  3647. camera: r
  3648. }
  3649. };
  3650. return this.sendData({
  3651. data: n
  3652. });
  3653. }
  3654. }, {
  3655. key: "confirmEvent",
  3656. value: function confirmEvent(e) {
  3657. var t = {
  3658. action_type: Actions$1.ConfirmEvent,
  3659. confirm_event_action: {
  3660. id: e
  3661. }
  3662. };
  3663. return this.sendData({
  3664. data: t,
  3665. track: !1
  3666. });
  3667. }
  3668. }, {
  3669. key: "echo",
  3670. value: function echo(e) {
  3671. var t = {
  3672. action_type: Actions$1.Echo,
  3673. echo_msg: {
  3674. echoMsg: e
  3675. }
  3676. };
  3677. return this.sendData({
  3678. data: t,
  3679. track: !1
  3680. });
  3681. }
  3682. }, {
  3683. key: "changeSkin",
  3684. value: function () {
  3685. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3686. var _this3 = this;
  3687. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  3688. return regenerator.wrap(function _callee6$(_context6) {
  3689. while (1) {
  3690. switch (_context6.prev = _context6.next) {
  3691. case 0:
  3692. 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) {
  3693. return y.id === r;
  3694. })[0];
  3695. if (m) {
  3696. _context6.next = 4;
  3697. break;
  3698. }
  3699. y = "skin ".concat(r, " is invalid");
  3700. return _context6.abrupt("return", (logger.error(y), Promise.reject(new ParamError(y))));
  3701. case 4:
  3702. v = {
  3703. action_type: Actions$1.ChangeSkin,
  3704. change_skin_action: {
  3705. skinID: r,
  3706. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  3707. skin_data_version: r + m.versionId,
  3708. landing_type: o,
  3709. landing_point: a,
  3710. landing_camera: s,
  3711. render_wrapper: {
  3712. render_type: l
  3713. },
  3714. areaName: u,
  3715. attitude: c,
  3716. noMedia: d,
  3717. person: f,
  3718. pathName: h,
  3719. roomTypeId: g
  3720. }
  3721. };
  3722. return _context6.abrupt("return", this.sendData({
  3723. data: v,
  3724. timeout: _ || 6e3,
  3725. special: t
  3726. }).then( /*#__PURE__*/function () {
  3727. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  3728. var b, _ref6, T;
  3729. return regenerator.wrap(function _callee5$(_context5) {
  3730. while (1) {
  3731. switch (_context5.prev = _context5.next) {
  3732. case 0:
  3733. if (!(l === RenderType.ClientRotationPano && y)) {
  3734. _context5.next = 8;
  3735. break;
  3736. }
  3737. _context5.next = 3;
  3738. return _this3.room.modelManager.findRoute(r, h);
  3739. case 3:
  3740. b = _context5.sent;
  3741. _ref6 = util.getRandomItem(b.birthPointList) || {};
  3742. T = _ref6.camera;
  3743. _context5.next = 8;
  3744. return _this3.room.panorama.handleReceivePanorama(y, T);
  3745. case 8:
  3746. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  3747. case 9:
  3748. case "end":
  3749. return _context5.stop();
  3750. }
  3751. }
  3752. }, _callee5);
  3753. }));
  3754. return function (_x6) {
  3755. return _ref5.apply(this, arguments);
  3756. };
  3757. }()).catch(function (y) {
  3758. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  3759. }));
  3760. case 6:
  3761. case "end":
  3762. return _context6.stop();
  3763. }
  3764. }
  3765. }, _callee6, this);
  3766. }));
  3767. function changeSkin(_x5) {
  3768. return _changeSkin.apply(this, arguments);
  3769. }
  3770. return changeSkin;
  3771. }()
  3772. }, {
  3773. key: "handleChangeSkin",
  3774. value: function handleChangeSkin(e) {
  3775. var _this4 = this;
  3776. var t = e.skinId,
  3777. r = e.mode,
  3778. n = e.renderType,
  3779. o = e.areaName,
  3780. a = e.attitude,
  3781. s = e.pathName;
  3782. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  3783. _this4.room.sceneManager.staticmeshComponent.getCgMesh().hide(), _this4.room.sceneManager.cameraComponent.switchToMainCamera(), _this4.room.pathManager.currentArea = o, logger.info("changeSkin _updateSkinAssets susccss"), _this4.room.updateCurrentNetworkOptions({
  3784. pathName: s,
  3785. attitude: a,
  3786. areaName: o
  3787. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  3788. skin: {
  3789. id: t
  3790. },
  3791. mode: r
  3792. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  3793. });
  3794. }
  3795. }, {
  3796. key: "rotate",
  3797. value: function rotate(_ref7) {
  3798. var e = _ref7.pitch,
  3799. t = _ref7.yaw;
  3800. var n;
  3801. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  3802. var r = {
  3803. action_type: Actions$1.Rotation,
  3804. rotation_action: {
  3805. vertical_move: e,
  3806. horizontal_move: -t
  3807. }
  3808. };
  3809. this.sendData({
  3810. data: r,
  3811. sampleRate: .02
  3812. });
  3813. }
  3814. }, {
  3815. key: "turnTo",
  3816. value: function turnTo(e) {
  3817. var _ref8 = e || {},
  3818. t = _ref8.point,
  3819. _ref8$timeout = _ref8.timeout,
  3820. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  3821. _ref8$offset = _ref8.offset,
  3822. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  3823. o = {
  3824. action_type: Actions$1.TurnTo,
  3825. turn_to_action: {
  3826. turn_to_point: t,
  3827. offset: n
  3828. }
  3829. };
  3830. return this.sendData({
  3831. data: o,
  3832. timeout: r
  3833. });
  3834. }
  3835. }, {
  3836. key: "rotateTo",
  3837. value: function rotateTo(e) {
  3838. var _ref9 = e || {},
  3839. t = _ref9.point,
  3840. _ref9$offset = _ref9.offset,
  3841. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  3842. _ref9$speed = _ref9.speed,
  3843. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  3844. o = {
  3845. action_type: Actions$1.RotateTo,
  3846. rotate_to_action: {
  3847. rotate_to_point: t,
  3848. offset: r,
  3849. speed: n
  3850. }
  3851. };
  3852. return this.sendData({
  3853. data: o
  3854. });
  3855. }
  3856. }, {
  3857. key: "broadcast",
  3858. value: function broadcast(e) {
  3859. var t = e.data,
  3860. _e$msgType = e.msgType,
  3861. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  3862. n = e.targetUserIds;
  3863. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  3864. var o = {
  3865. action_type: Actions$1.Broadcast,
  3866. broadcast_action: {
  3867. data: JSON.stringify(t),
  3868. user_id: this.room.options.userId,
  3869. msgType: r
  3870. }
  3871. };
  3872. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  3873. data: o,
  3874. tag: t.broadcastType
  3875. });
  3876. }
  3877. }, {
  3878. key: "getNeighborPoints",
  3879. value: function getNeighborPoints(e) {
  3880. var t = e.point,
  3881. _e$containSelf = e.containSelf,
  3882. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  3883. _e$searchRange = e.searchRange,
  3884. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  3885. o = {
  3886. action_type: Actions$1.GetNeighborPoints,
  3887. get_neighbor_points_action: {
  3888. point: t,
  3889. level: 1,
  3890. containSelf: r,
  3891. searchRange: n
  3892. }
  3893. };
  3894. return this.sendData({
  3895. data: o
  3896. }).then(function (a) {
  3897. return a.nps;
  3898. });
  3899. }
  3900. }, {
  3901. key: "playCG",
  3902. value: function playCG(e) {
  3903. var t = {
  3904. action_type: Actions$1.PlayCG,
  3905. play_cg_action: {
  3906. cg_name: e
  3907. }
  3908. };
  3909. return this.sendData({
  3910. data: t
  3911. });
  3912. }
  3913. }, {
  3914. key: "audienceToVisitor",
  3915. value: function audienceToVisitor(e) {
  3916. var t = e.avatarId,
  3917. r = e.avatarComponents,
  3918. n = e.player,
  3919. o = e.camera,
  3920. a = {
  3921. action_type: Actions$1.AudienceChangeToVisitor,
  3922. audienceChangeToVisitorAction: {
  3923. avatarID: t,
  3924. avatarComponents: r,
  3925. player: n,
  3926. camera: o
  3927. }
  3928. };
  3929. return logger.debug("send data: audience to visitor"), this.sendData({
  3930. data: a
  3931. });
  3932. }
  3933. }, {
  3934. key: "visitorToAudience",
  3935. value: function visitorToAudience(e) {
  3936. var t = e.renderType,
  3937. r = e.player,
  3938. n = e.camera,
  3939. o = e.areaName,
  3940. a = e.attitude,
  3941. s = e.pathName,
  3942. l = e.person,
  3943. u = e.noMedia,
  3944. c = {
  3945. action_type: Actions$1.VisitorChangeToAudience,
  3946. visitorChangeToAudienceAction: {
  3947. transferAction: {
  3948. render_type: t,
  3949. player: r,
  3950. camera: n,
  3951. areaName: o,
  3952. attitude: a,
  3953. pathName: s,
  3954. person: {
  3955. type: l
  3956. },
  3957. noMedia: u,
  3958. tiles: [0, 1, 2, 4]
  3959. }
  3960. }
  3961. };
  3962. return logger.debug("send data: visitor to audience"), this.sendData({
  3963. data: c
  3964. });
  3965. }
  3966. }, {
  3967. key: "removeVisitor",
  3968. value: function removeVisitor(e) {
  3969. var t = e.removeType,
  3970. r = e.userIDList,
  3971. _e$extraInfo = e.extraInfo,
  3972. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  3973. o = {
  3974. action_type: Actions$1.RemoveVisitor,
  3975. removeVisitorAction: {
  3976. removeVisitorEvent: t,
  3977. userIDList: r,
  3978. extraInfo: encodeURIComponent(n)
  3979. }
  3980. };
  3981. return logger.debug("send data: remove visitor"), this.sendData({
  3982. data: o
  3983. });
  3984. }
  3985. }, {
  3986. key: "getUserWithAvatar",
  3987. value: function getUserWithAvatar(e, t) {
  3988. var r = {
  3989. action_type: Actions$1.GetUserWithAvatar,
  3990. getUserWithAvatarAction: {
  3991. userType: e,
  3992. roomID: t
  3993. }
  3994. };
  3995. return logger.debug("send data: get user with avatar"), this.sendData({
  3996. data: r
  3997. }).then(function (n) {
  3998. return n.userWithAvatarList;
  3999. });
  4000. }
  4001. }, {
  4002. key: "joystick",
  4003. value: function joystick(e) {
  4004. var t = e.degree,
  4005. _e$level = e.level,
  4006. r = _e$level === void 0 ? 1 : _e$level,
  4007. n = util.uuid();
  4008. var o = -t + 90 + 360;
  4009. o >= 360 && (o -= 360);
  4010. var a = {
  4011. action_type: Actions$1.Joystick,
  4012. dir_action: {
  4013. move_angle: o,
  4014. speed_level: r
  4015. },
  4016. trace_id: n,
  4017. user_id: this.room.options.userId,
  4018. packet_id: n
  4019. };
  4020. return this.sendData({
  4021. data: a,
  4022. track: !1
  4023. });
  4024. }
  4025. }]);
  4026. return ActionsHandler;
  4027. }();
  4028. var ECurrentShaderMode = {
  4029. default: 0,
  4030. video: 1,
  4031. pano: 2
  4032. };
  4033. var Signal = /*#__PURE__*/function () {
  4034. function Signal(e) {
  4035. _classCallCheck(this, Signal);
  4036. this.signalHandleActived = !0;
  4037. this.isUpdatedYUV = !0;
  4038. this._room = e;
  4039. }
  4040. _createClass(Signal, [{
  4041. key: "handleSignal",
  4042. value: function handleSignal(e) {
  4043. var _this = this;
  4044. var a, s, l;
  4045. if (!this.signalHandleActived) return;
  4046. var t = e.signal,
  4047. r = e.alreadyUpdateYUV;
  4048. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  4049. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  4050. return c.userId === _this._room.userId;
  4051. });
  4052. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  4053. logger.debug("stream stoped, make avatar to stop");
  4054. var _u$renderInfo = u.renderInfo,
  4055. c = _u$renderInfo.isMoving,
  4056. h = _u$renderInfo.isRotating;
  4057. this._room.avatarManager._updateAvatarMovingStatus({
  4058. id: u.userId,
  4059. isMoving: !!c,
  4060. isRotating: !!h
  4061. });
  4062. }
  4063. return;
  4064. }
  4065. this.isUpdatedYUV = r;
  4066. var n = t;
  4067. if (!t) {
  4068. logger.warn("metadata signal is empty");
  4069. return;
  4070. }
  4071. if (n.code === Codes.RepeatLogin) {
  4072. this._room.handleRepetLogin();
  4073. return;
  4074. }
  4075. 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));
  4076. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  4077. return u.userId === _this._room.userId;
  4078. });
  4079. if (n.broadcastAction) try {
  4080. var _u = JSON.parse(n.broadcastAction.data);
  4081. Broadcast.handlers.forEach(function (c) {
  4082. return c(_u);
  4083. });
  4084. } catch (u) {
  4085. logger.error(u);
  4086. }
  4087. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  4088. this._room._currentClickingState = o.playerState;
  4089. var _o$playerState = o.playerState,
  4090. _u2 = _o$playerState.pathName,
  4091. _c = _o$playerState.attitude,
  4092. _h = _o$playerState.areaName,
  4093. f = _o$playerState.skinId;
  4094. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  4095. pathName: _u2
  4096. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  4097. areaName: _h
  4098. }), _c) {
  4099. var d = this._room.skin.routeList.find(function (g) {
  4100. return g.areaName === _this._room.currentState.areaName;
  4101. }),
  4102. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  4103. this._room.updateCurrentState({
  4104. speed: _,
  4105. attitude: _c
  4106. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  4107. }
  4108. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  4109. }
  4110. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  4111. var _u3 = n.actionType,
  4112. _c2 = n.code,
  4113. _h2 = n.echoMsg,
  4114. _f = n.traceId;
  4115. _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);
  4116. }
  4117. }
  4118. }, {
  4119. key: "handleActionResponses",
  4120. value: function handleActionResponses(e) {
  4121. var _this2 = this;
  4122. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  4123. if (t.actionType == null) return;
  4124. var r = t.pointType,
  4125. n = t.extra,
  4126. o = t.actionType,
  4127. a = t.traceId,
  4128. s = t.code,
  4129. l = t.msg;
  4130. 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));
  4131. });
  4132. }
  4133. }, {
  4134. key: "udpateSkinInfo",
  4135. value: function () {
  4136. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4137. var t;
  4138. return regenerator.wrap(function _callee$(_context) {
  4139. while (1) {
  4140. switch (_context.prev = _context.next) {
  4141. case 0:
  4142. this._room.updateCurrentState({
  4143. skinId: e
  4144. });
  4145. _context.next = 3;
  4146. return this._room.skinList.find(function (r) {
  4147. return r.id === e;
  4148. });
  4149. case 3:
  4150. t = _context.sent;
  4151. t && this._room.updateCurrentState({
  4152. skin: t
  4153. });
  4154. case 5:
  4155. case "end":
  4156. return _context.stop();
  4157. }
  4158. }
  4159. }, _callee, this);
  4160. }));
  4161. function udpateSkinInfo(_x) {
  4162. return _udpateSkinInfo.apply(this, arguments);
  4163. }
  4164. return udpateSkinInfo;
  4165. }()
  4166. }]);
  4167. return Signal;
  4168. }();
  4169. 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); }; }
  4170. 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; } }
  4171. var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
  4172. _inherits(XverseEffectManager, _EventEmitter);
  4173. var _super = _createSuper$d(XverseEffectManager);
  4174. function XverseEffectManager(e) {
  4175. var _this;
  4176. _classCallCheck(this, XverseEffectManager);
  4177. _this = _super.call(this);
  4178. E(_assertThisInitialized(_this), "effects", new Map());
  4179. E(_assertThisInitialized(_this), "room");
  4180. _this.room = e;
  4181. return _this;
  4182. }
  4183. _createClass(XverseEffectManager, [{
  4184. key: "addEffect",
  4185. value: function () {
  4186. var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4187. var o, t, r, _e$type, n, a;
  4188. return regenerator.wrap(function _callee$(_context) {
  4189. while (1) {
  4190. switch (_context.prev = _context.next) {
  4191. case 0:
  4192. t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
  4193. _context.prev = 1;
  4194. this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
  4195. a = new Ae.subEffect({
  4196. id: r,
  4197. jsonPath: t,
  4198. type: n,
  4199. room: this.room
  4200. });
  4201. this.effects.set(r, a);
  4202. _context.next = 7;
  4203. return a.init();
  4204. case 7:
  4205. return _context.abrupt("return", a);
  4206. case 10:
  4207. _context.prev = 10;
  4208. _context.t0 = _context["catch"](1);
  4209. return _context.abrupt("return", (this.effects.delete(r), logger.error(_context.t0), Promise.reject(_context.t0)));
  4210. case 13:
  4211. case "end":
  4212. return _context.stop();
  4213. }
  4214. }
  4215. }, _callee, this, [[1, 10]]);
  4216. }));
  4217. function addEffect(_x) {
  4218. return _addEffect.apply(this, arguments);
  4219. }
  4220. return addEffect;
  4221. }()
  4222. }, {
  4223. key: "clearEffects",
  4224. value: function clearEffects() {
  4225. var _this2 = this;
  4226. this.effects.forEach(function (e) {
  4227. e.dispose(), _this2.effects.delete(e.id);
  4228. });
  4229. }
  4230. }, {
  4231. key: "removeEffect",
  4232. value: function removeEffect(e) {
  4233. var t = this.effects.get(e);
  4234. t == null || t.dispose(), t && this.effects.delete(t.id);
  4235. }
  4236. }]);
  4237. return XverseEffectManager;
  4238. }(EventEmitter);
  4239. 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); }; }
  4240. 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; } }
  4241. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  4242. _inherits(ParamError, _XverseError);
  4243. var _super = _createSuper$c(ParamError);
  4244. function ParamError(e) {
  4245. _classCallCheck(this, ParamError);
  4246. return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
  4247. }
  4248. return _createClass(ParamError);
  4249. }(XverseError);
  4250. var MotionType$1 = {
  4251. Walk: 'walk',
  4252. Run: 'run',
  4253. Fly: 'fly'
  4254. };
  4255. var Heartbeat = /*#__PURE__*/function () {
  4256. function Heartbeat(e) {
  4257. var _this = this;
  4258. _classCallCheck(this, Heartbeat);
  4259. E(this, "_interval", null);
  4260. E(this, "ping", function () {
  4261. var e = Date.now().toString();
  4262. _this.handler.ping(e);
  4263. });
  4264. this.handler = e;
  4265. }
  4266. _createClass(Heartbeat, [{
  4267. key: "ping",
  4268. value: function ping() {
  4269. var e = Date.now().toString();
  4270. this.handler.ping(e);
  4271. }
  4272. }, {
  4273. key: "start",
  4274. value: function start() {
  4275. this.stop(), logger.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
  4276. }
  4277. }, {
  4278. key: "stop",
  4279. value: function stop() {
  4280. logger.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
  4281. }
  4282. }, {
  4283. key: "pong",
  4284. value: function pong(e, t) {
  4285. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
  4286. }
  4287. }]);
  4288. return Heartbeat;
  4289. }();
  4290. var Timeout$1 = /*#__PURE__*/function () {
  4291. function Timeout(e, t) {
  4292. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  4293. _classCallCheck(this, Timeout);
  4294. this._timeout = null;
  4295. this._fn = e, this._delay = t, r && this.start();
  4296. }
  4297. _createClass(Timeout, [{
  4298. key: "delay",
  4299. get: function get() {
  4300. return this._delay;
  4301. }
  4302. }, {
  4303. key: "isSet",
  4304. get: function get() {
  4305. return !!this._timeout;
  4306. }
  4307. }, {
  4308. key: "setDelay",
  4309. value: function setDelay(e) {
  4310. this._delay = e;
  4311. }
  4312. }, {
  4313. key: "start",
  4314. value: function start() {
  4315. var _this = this;
  4316. this.isSet || (this._timeout = window.setTimeout(function () {
  4317. var e = _this._fn;
  4318. _this.clear(), e();
  4319. }, this._delay));
  4320. }
  4321. }, {
  4322. key: "clear",
  4323. value: function clear() {
  4324. window.clearTimeout(this._timeout), this._timeout = void 0;
  4325. }
  4326. }, {
  4327. key: "reset",
  4328. value: function reset() {
  4329. this.clear(), this.start();
  4330. }
  4331. }]);
  4332. return Timeout;
  4333. }();
  4334. 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); }; }
  4335. 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; } }
  4336. var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
  4337. _inherits(InitNetworkTimeoutError, _XverseError);
  4338. var _super = _createSuper$b(InitNetworkTimeoutError);
  4339. function InitNetworkTimeoutError(e) {
  4340. _classCallCheck(this, InitNetworkTimeoutError);
  4341. return _super.call(this, 1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6");
  4342. }
  4343. return _createClass(InitNetworkTimeoutError);
  4344. }(XverseError);
  4345. 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); }; }
  4346. 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; } }
  4347. var Socket = /*#__PURE__*/function (_EventEmitter) {
  4348. _inherits(Socket, _EventEmitter);
  4349. var _super = _createSuper$a(Socket);
  4350. function Socket(e) {
  4351. var _this;
  4352. _classCallCheck(this, Socket);
  4353. _this = _super.call(this);
  4354. E(_assertThisInitialized(_this), "_ws");
  4355. E(_assertThisInitialized(_this), "_openTimer");
  4356. E(_assertThisInitialized(_this), "connected", !1);
  4357. E(_assertThisInitialized(_this), "_hasTimeout", !1);
  4358. E(_assertThisInitialized(_this), "heartbeat");
  4359. E(_assertThisInitialized(_this), "latency", function (e, t) {
  4360. return _this.send({
  4361. id: "checkLatency",
  4362. data: JSON.stringify(e),
  4363. packet_id: t
  4364. });
  4365. });
  4366. E(_assertThisInitialized(_this), "send", function (e) {
  4367. if (_this.wsNoReady()) return;
  4368. var t = JSON.stringify(e);
  4369. e.id !== "heartbeat" && logger.info("send ws frame", t), _this._ws.send(t);
  4370. });
  4371. E(_assertThisInitialized(_this), "startGame", function () {
  4372. var _this$network$room$cu = _this.network.room.currentNetworkOptions,
  4373. e = _this$network$room$cu.roomId,
  4374. t = _this$network$room$cu.userId,
  4375. r = _this$network$room$cu.avatarId,
  4376. n = _this$network$room$cu.skinId,
  4377. o = _this$network$room$cu.role,
  4378. a = _this$network$room$cu.avatarComponents,
  4379. s = _this$network$room$cu.versionId,
  4380. l = _this$network$room$cu.rotationRenderType,
  4381. u = _this$network$room$cu.isAllSync,
  4382. c = _this$network$room$cu.nickname,
  4383. h = _this$network$room$cu.avatarScale,
  4384. f = _this$network$room$cu.appId,
  4385. d = _this$network$room$cu.camera,
  4386. _ = _this$network$room$cu.player,
  4387. g = _this$network$room$cu.firends,
  4388. m = _this$network$room$cu.syncByEvent,
  4389. v = _this$network$room$cu.areaName,
  4390. y = _this$network$room$cu.attitude,
  4391. b = _this$network$room$cu.pathName,
  4392. T = _this$network$room$cu.person,
  4393. _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
  4394. C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
  4395. A = _this$network$room$cu.syncToOthers,
  4396. S = _this$network$room$cu.hasAvatar,
  4397. P = _this$network$room$cu.prioritySync,
  4398. _this$network$room$cu3 = _this$network$room$cu.extra,
  4399. R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
  4400. M = _this$network$room$cu.removeWhenDisconnected;
  4401. R.removeWhenDisconnected = M;
  4402. var x = {
  4403. id: "start",
  4404. room_id: e,
  4405. user_id: t,
  4406. trace_id: util.uuid(),
  4407. data: JSON.stringify({
  4408. avatar_components: JSON.stringify(a),
  4409. avatar_id: r,
  4410. skin_id: n,
  4411. is_host: o ? o == "host" : !0,
  4412. skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
  4413. rotation_render_type: l,
  4414. is_all_sync: u,
  4415. nick_name: encodeURIComponent(c || ""),
  4416. app_id: f,
  4417. camera: d,
  4418. player: _,
  4419. person: T,
  4420. firends: JSON.stringify(g),
  4421. sync_by_event: m,
  4422. area_name: v,
  4423. path_name: b,
  4424. attitude: y,
  4425. room_type_id: C,
  4426. syncToOthers: A,
  4427. hasAvatar: S,
  4428. avatarSize: h,
  4429. prioritySync: P,
  4430. extra: JSON.stringify(R)
  4431. })
  4432. };
  4433. _this.send(x), logger.warn("startGame", le(oe({}, x), {
  4434. data: JSON.parse(x.data)
  4435. }));
  4436. });
  4437. _this.network = e, _this.heartbeat = new Heartbeat({
  4438. ping: function ping(t) {
  4439. var r;
  4440. if (!_this.connected) {
  4441. _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
  4442. rtt: 0
  4443. });
  4444. return;
  4445. }
  4446. _this.send({
  4447. id: "heartbeat",
  4448. data: t
  4449. });
  4450. },
  4451. pong(t) {
  4452. var r;
  4453. (r = e.room.stats) == null || r.assign({
  4454. rtt: t
  4455. });
  4456. }
  4457. });
  4458. return _this;
  4459. }
  4460. _createClass(Socket, [{
  4461. key: "connection",
  4462. get: function get() {
  4463. return this._ws;
  4464. }
  4465. }, {
  4466. key: "start",
  4467. value: function start() {
  4468. var _this2 = this;
  4469. this._hasTimeout = !1;
  4470. var e = this.getAddress();
  4471. logger.info("connecting to ".concat(e));
  4472. var t = Date.now();
  4473. this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
  4474. var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
  4475. _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
  4476. }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
  4477. var r;
  4478. (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger.infoAndReportMeasurement({
  4479. metric: "wsOpenedAt",
  4480. group: "joinRoom",
  4481. startTime: _this2.network.room._startTime
  4482. }), logger.infoAndReportMeasurement({
  4483. metric: "wsOpenedCost",
  4484. group: "joinRoom",
  4485. startTime: t
  4486. }));
  4487. }, this.handleWSEvent();
  4488. }
  4489. }, {
  4490. key: "getAddress",
  4491. value: function getAddress() {
  4492. var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
  4493. e = _this$network$room$cu4.wsServerUrl,
  4494. t = _this$network$room$cu4.reconnect,
  4495. r = _this$network$room$cu4.sessionId,
  4496. n = _this$network$room$cu4.token,
  4497. o = _this$network$room$cu4.roomId,
  4498. a = _this$network$room$cu4.userId,
  4499. s = _this$network$room$cu4.pageSession,
  4500. l = this.network.room.skinId;
  4501. var u = e;
  4502. t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
  4503. var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
  4504. return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
  4505. }
  4506. }, {
  4507. key: "handleWSEvent",
  4508. value: function handleWSEvent() {
  4509. var _this3 = this;
  4510. var e = this._ws;
  4511. e.addEventListener("error", function (t) {
  4512. _this3.connected = !1, logger.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
  4513. }), e.addEventListener("close", function (t) {
  4514. _this3.connected = !1, _this3._onClose(t);
  4515. }), e.addEventListener("message", function (t) {
  4516. if (!t || _this3._hasTimeout || !_this3.connected) return;
  4517. var r = null;
  4518. try {
  4519. r = JSON.parse(t.data);
  4520. } catch (o) {
  4521. logger.error(o);
  4522. return;
  4523. }
  4524. if (!r) return;
  4525. var n = r.id;
  4526. if (!!n) switch (n !== "heartbeat" && logger.info("receive ws frame: ".concat(t.data)), n) {
  4527. case "fail":
  4528. break;
  4529. case "init":
  4530. try {
  4531. var o = r.data.slice(-37, -1);
  4532. reporter$1.updateBody({
  4533. serverSession: o
  4534. });
  4535. } catch (o) {
  4536. console.error(o);
  4537. }
  4538. _this3.network.rtcp.start();
  4539. break;
  4540. case "heartbeat":
  4541. _this3.heartbeat.pong(r.data);
  4542. break;
  4543. case "offer":
  4544. _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
  4545. break;
  4546. case "ice_candidate":
  4547. _this3.network.rtcp.addCandidate(r.data);
  4548. break;
  4549. case "start":
  4550. _this3.emit("gameRoomAvailable", r);
  4551. break;
  4552. case "error":
  4553. try {
  4554. var _JSON$parse = JSON.parse(r.data),
  4555. _o = _JSON$parse.Code,
  4556. a = _JSON$parse.Msg;
  4557. if (_o) {
  4558. if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
  4559. if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
  4560. {
  4561. var s = getErrorByCode(_o);
  4562. _this3.emit("socketClosed", new s(a));
  4563. }
  4564. }
  4565. } catch (o) {
  4566. logger.error(o), _this3.emit("socketClosed", new InternalError(r.data));
  4567. }
  4568. break;
  4569. case "checkLatency":
  4570. {
  4571. var _o2 = r.packet_id,
  4572. _a = r.data.split(",");
  4573. _this3.onLatencyCheck({
  4574. packetId: _o2,
  4575. addresses: _a
  4576. });
  4577. break;
  4578. }
  4579. default:
  4580. logger.warn("unkown ws message type", n, r);
  4581. }
  4582. });
  4583. }
  4584. }, {
  4585. key: "onLatencyCheck",
  4586. value: function onLatencyCheck(e) {
  4587. var _this4 = this;
  4588. var t = _toConsumableArray(new Set(e.addresses || []));
  4589. Promise.all(t.map(function (r) {
  4590. return {
  4591. [r]: 9999
  4592. };
  4593. })).then(function (r) {
  4594. var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
  4595. _this4.latency(n, e.packetId);
  4596. });
  4597. }
  4598. }, {
  4599. key: "wsNoReady",
  4600. value: function wsNoReady() {
  4601. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
  4602. }
  4603. }, {
  4604. key: "prepareReconnect",
  4605. value: function prepareReconnect() {
  4606. this._close({
  4607. code: WS_CLOSE_RECONNECT,
  4608. reason: "reconnect"
  4609. });
  4610. }
  4611. }, {
  4612. key: "_onClose",
  4613. value: function _onClose(_ref) {
  4614. var e = _ref.code,
  4615. t = _ref.reason;
  4616. 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"));
  4617. }
  4618. }, {
  4619. key: "_close",
  4620. value: function _close(_ref2) {
  4621. var e = _ref2.code,
  4622. t = _ref2.reason;
  4623. var r;
  4624. (r = this._ws) == null || r.close(e, t);
  4625. }
  4626. }, {
  4627. key: "quit",
  4628. value: function quit() {
  4629. this._close({
  4630. code: WS_CLOSE_NORMAL,
  4631. reason: "quit"
  4632. });
  4633. }
  4634. }]);
  4635. return Socket;
  4636. }(EventEmitter);
  4637. function add(i, e) {
  4638. return e == -1 && (e = 0), i + e;
  4639. }
  4640. function max(i, e) {
  4641. return Math.max(i, e);
  4642. }
  4643. function count_sd(i, e) {
  4644. function t(r, n) {
  4645. var o = 0;
  4646. return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
  4647. }
  4648. return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
  4649. }
  4650. function count_valid(i, e) {
  4651. var t = 0;
  4652. return e != -1 && (t = 1), i + t;
  4653. }
  4654. function count_less(i, e) {
  4655. function t(r, n) {
  4656. var o = 0;
  4657. return n != -1 && n < e && (o = 1), r + o;
  4658. }
  4659. return i.reduce(t, 0);
  4660. }
  4661. var CircularArray = /*#__PURE__*/function () {
  4662. function CircularArray(e, t, r) {
  4663. _classCallCheck(this, CircularArray);
  4664. 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);
  4665. }
  4666. _createClass(CircularArray, [{
  4667. key: "add",
  4668. value: function add(e) {
  4669. 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);
  4670. }
  4671. }, {
  4672. key: "computeAvg",
  4673. value: function computeAvg(e) {
  4674. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
  4675. }
  4676. }, {
  4677. key: "computeMax",
  4678. value: function computeMax(e) {
  4679. return e.reduce(max, 0) || 0;
  4680. }
  4681. }, {
  4682. key: "computeThreshPercent",
  4683. value: function computeThreshPercent(e) {
  4684. if (this.countLess) {
  4685. var t = count_less(e, this.lessThreshes[0]) || 0,
  4686. r = count_less(e, this.lessThreshes[1]) || 0,
  4687. n = count_less(e, this.lessThreshes[2]) || 0,
  4688. o = count_less(e, this.lessThreshes[3]) || 0,
  4689. a = e.reduce(count_valid, 0);
  4690. return [t, r, n, o, a];
  4691. } else return [0, 0, 0, 0, 0];
  4692. }
  4693. }, {
  4694. key: "getAvg",
  4695. value: function getAvg() {
  4696. var e = this.sum / this.count || 0,
  4697. t = this.computeAvg(this.circularData) || 0;
  4698. return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
  4699. }
  4700. }, {
  4701. key: "getMax",
  4702. value: function getMax() {
  4703. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  4704. var t = this.computeMax(this.circularData) || 0;
  4705. return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
  4706. }
  4707. }, {
  4708. key: "getStandardDeviation",
  4709. value: function getStandardDeviation() {
  4710. return count_sd(this.circularData, this.getAvg());
  4711. }
  4712. }, {
  4713. key: "getThreshPercent",
  4714. value: function getThreshPercent() {
  4715. return this.computeThreshPercent(this.circularData);
  4716. }
  4717. }, {
  4718. key: "getIncomingMax",
  4719. value: function getIncomingMax() {
  4720. return this.computeMax(this.incomingData) || 0;
  4721. }
  4722. }, {
  4723. key: "getIncomingAvg",
  4724. value: function getIncomingAvg() {
  4725. return this.computeAvg(this.incomingData) || 0;
  4726. }
  4727. }, {
  4728. key: "getIncomingStandardDeviation",
  4729. value: function getIncomingStandardDeviation() {
  4730. return count_sd(this.incomingData, this.getIncomingAvg());
  4731. }
  4732. }, {
  4733. key: "getIncomingThreshPercent",
  4734. value: function getIncomingThreshPercent() {
  4735. return this.computeThreshPercent(this.incomingData);
  4736. }
  4737. }, {
  4738. key: "clearFastComputeItem",
  4739. value: function clearFastComputeItem() {
  4740. 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;
  4741. }
  4742. }, {
  4743. key: "clearIncoming",
  4744. value: function clearIncoming() {
  4745. for (; this.incomingData.length > 0;) {
  4746. this.incomingData.pop();
  4747. }
  4748. }
  4749. }, {
  4750. key: "clear",
  4751. value: function clear() {
  4752. this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
  4753. }
  4754. }]);
  4755. return CircularArray;
  4756. }();
  4757. function _createForOfIteratorHelper$1(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(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; } } }; }
  4758. function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(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$1(o, minLen); }
  4759. function _arrayLikeToArray$1(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; }
  4760. var defaultLogger = {
  4761. info: console.log,
  4762. debug: console.log,
  4763. error: console.error,
  4764. infoAndReportMeasurement: function infoAndReportMeasurement() {}
  4765. };
  4766. var USER_ID = "987412365",
  4767. PAGE_SESSION = "aaabbbccc",
  4768. SERVER_SESSION = "cccbbbaaa",
  4769. COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
  4770. FRAME_COMPOSE_LENGTH = 5;
  4771. var Workers = /*#__PURE__*/function () {
  4772. function Workers(e, t) {
  4773. var _this = this;
  4774. _classCallCheck(this, Workers);
  4775. 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 = {
  4776. x: 0,
  4777. y: 0,
  4778. z: 0,
  4779. tiles: []
  4780. }, 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 () {
  4781. return DECODER_VERSION;
  4782. }, this.downloadBlob = function (r, n, o) {
  4783. var a = new Blob([r], {
  4784. type: o
  4785. }),
  4786. s = window.URL.createObjectURL(a);
  4787. _this.downloadURL(s, n), setTimeout(function () {
  4788. return window.URL.revokeObjectURL(s);
  4789. }, 1e3);
  4790. }, this.downloadURL = function (r, n) {
  4791. var o = document.createElement("a");
  4792. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  4793. }, this.Stringify = function (r) {
  4794. var n = "";
  4795. for (var a = 0; a < r.length / 8192; a++) {
  4796. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  4797. }
  4798. return n;
  4799. }, this._rtcp = e;
  4800. }
  4801. _createClass(Workers, [{
  4802. key: "registerLogger",
  4803. value: function registerLogger(e) {//defaultLogger = e
  4804. }
  4805. }, {
  4806. key: "registerFunction",
  4807. value: function registerFunction(e, t) {
  4808. this.functionMap.set(e, t);
  4809. }
  4810. }, {
  4811. key: "hasFrmCntInCache",
  4812. value: function hasFrmCntInCache(e) {
  4813. var t = -1;
  4814. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  4815. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  4816. }
  4817. return t;
  4818. }
  4819. }, {
  4820. key: "requestPanoramaTest",
  4821. value: function requestPanoramaTest(e, t, r, n, o) {
  4822. var a = o,
  4823. s = {
  4824. action_type: 16,
  4825. change_rotation_render_type_action: {
  4826. render_type: 5,
  4827. player: {
  4828. position: {
  4829. x: 0,
  4830. y: 0,
  4831. z: 0
  4832. },
  4833. angle: {
  4834. yaw: 0,
  4835. pitch: 0,
  4836. roll: 0
  4837. }
  4838. },
  4839. camera: {
  4840. position: {
  4841. x: e,
  4842. y: t,
  4843. z: r
  4844. },
  4845. angle: {
  4846. yaw: 0,
  4847. pitch: 0,
  4848. roll: 0
  4849. }
  4850. },
  4851. client_pano_titles_bitmap: n
  4852. },
  4853. trace_id: a,
  4854. user_id: this.userId_test,
  4855. packet_id: a
  4856. };
  4857. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  4858. }
  4859. }, {
  4860. key: "onRotateInPanoMode",
  4861. value: function onRotateInPanoMode(e) {
  4862. var t = e.traceId,
  4863. r = {};
  4864. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  4865. yaw: 100,
  4866. pitch: 30
  4867. };
  4868. var n = new ArrayBuffer(8),
  4869. o = new DataView(n);
  4870. getTilesInView(r, n);
  4871. var a = n.slice(0);
  4872. this.PendingMasks.unshift({
  4873. buffer: a,
  4874. angle: r.angle
  4875. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  4876. return s ^ s & l;
  4877. }), 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);
  4878. }
  4879. }, {
  4880. key: "processMetaWithTraceId",
  4881. value: function processMetaWithTraceId(e) {
  4882. var _iterator = _createForOfIteratorHelper$1(e.traceIds),
  4883. _step;
  4884. try {
  4885. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4886. var t = _step.value;
  4887. if (this.traceIdMap.has(t)) {
  4888. var r = this.traceIdMap.get(t);
  4889. r != null && (r.receiveTime = Date.now(), r.status = 1);
  4890. }
  4891. if (t == this.PendingMovingTraceId) {
  4892. 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());
  4893. var _r = Date.now();
  4894. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  4895. }
  4896. }
  4897. } catch (err) {
  4898. _iterator.e(err);
  4899. } finally {
  4900. _iterator.f();
  4901. }
  4902. }
  4903. }, {
  4904. key: "onTraceId",
  4905. value: function onTraceId(e) {
  4906. var _this2 = this;
  4907. var r = e.traceId,
  4908. n = e.timestamp,
  4909. o = e.event;
  4910. if (o === "Rotation") {
  4911. var a = {
  4912. traceId: r,
  4913. pts: 0,
  4914. startTime: n,
  4915. receiveTime: 0,
  4916. readyTime: 0,
  4917. displayTime: 0,
  4918. status: 0
  4919. };
  4920. this.traceIdMap.set(r, a);
  4921. var s = setTimeout(function () {
  4922. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  4923. var l = _this2.traceIdMap.get(r);
  4924. switch (l == null ? void 0 : l.status) {
  4925. case 0:
  4926. {
  4927. _this2.responseMiss += 1;
  4928. break;
  4929. }
  4930. case 1:
  4931. {
  4932. _this2.processMiss += 1;
  4933. var u = l.receiveTime - l.startTime;
  4934. _this2.responseTimeArray.push(u);
  4935. break;
  4936. }
  4937. case 2:
  4938. {
  4939. _this2.displayMiss += 1;
  4940. var _u = l.receiveTime - l.startTime,
  4941. c = l.readyTime - l.receiveTime;
  4942. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  4943. break;
  4944. }
  4945. case 3:
  4946. defaultLogger.debug("status is 3");
  4947. }
  4948. }
  4949. }, 1e3);
  4950. } 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();
  4951. }
  4952. }, {
  4953. key: "executeFunction",
  4954. value: function executeFunction(e, t) {
  4955. if (this.functionMap.has(e)) {
  4956. var r = this.functionMap.get(e);
  4957. r != null && r(t);
  4958. }
  4959. }
  4960. }, {
  4961. key: "UpdateStats",
  4962. value: function UpdateStats(e) {
  4963. var _this3 = this;
  4964. var t;
  4965. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  4966. r.forEach(function (n) {
  4967. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  4968. });
  4969. }), 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;
  4970. }
  4971. }, {
  4972. key: "ReceiveDecodeMessage",
  4973. value: function ReceiveDecodeMessage(e) {
  4974. var n;
  4975. if (!this.firstYUVReceived) {
  4976. this.firstYUVDecoded = e.data.yuv_ts;
  4977. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  4978. defaultLogger.infoAndReportMeasurement({
  4979. metric: "firstYUVDecodedAt",
  4980. value: o,
  4981. group: "joinRoom"
  4982. }), this.firstRender = Date.now();
  4983. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  4984. defaultLogger.infoAndReportMeasurement({
  4985. metric: "firstRenderAt",
  4986. value: a,
  4987. group: "joinRoom"
  4988. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  4989. }
  4990. !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", {
  4991. stream: this.cachedStreams[this.setPtr],
  4992. width: this.cachedResolution[this.setPtr].width,
  4993. height: this.cachedResolution[this.setPtr].height,
  4994. pts: this.cachedPtss[this.setPtr]
  4995. }), this.executeFunction("signal", {
  4996. signal: this.cachedMetas[this.setPtr],
  4997. pts: this.cachedPtss[this.setPtr],
  4998. alreadyUpdateYUV: !0
  4999. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  5000. t: 2,
  5001. frameCnt: this.cachedPtss[this.setPtr],
  5002. buffer: this.cachedStreams[this.setPtr]
  5003. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  5004. var t = e.data.metadata;
  5005. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  5006. var _iterator2 = _createForOfIteratorHelper$1(t.traceIds),
  5007. _step2;
  5008. try {
  5009. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  5010. var _o = _step2.value;
  5011. if (this.traceIdMap.has(_o)) {
  5012. var _a = this.traceIdMap.get(_o);
  5013. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  5014. }
  5015. }
  5016. } catch (err) {
  5017. _iterator2.e(err);
  5018. } finally {
  5019. _iterator2.f();
  5020. }
  5021. }
  5022. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  5023. var _o2 = Date.now(),
  5024. _a2 = _o2 - this.lastMoveProcessTime;
  5025. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  5026. }
  5027. var r = this.setPtr;
  5028. 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] = {
  5029. width: e.data.width,
  5030. height: e.data.height
  5031. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  5032. }
  5033. }, {
  5034. key: "SendCacheFrameInfo",
  5035. value: function SendCacheFrameInfo(e) {
  5036. var _this4 = this;
  5037. var h, f, d, _, g, m, v;
  5038. var t = e.data.cachedKey,
  5039. r = e.data.metadata,
  5040. n = t,
  5041. o = r,
  5042. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  5043. return y.userId === _this4.rtcp.network.room.userId;
  5044. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  5045. s = this.rtcp.network.room.skinId,
  5046. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  5047. return y.userId === _this4._rtcp.network.room.userId;
  5048. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  5049. u = {
  5050. MsgType: 1,
  5051. FrameCacheMsg: {
  5052. FrameIndex: n,
  5053. RoomTypeId: a,
  5054. SkinID: s,
  5055. Position: l
  5056. }
  5057. };
  5058. var c = "";
  5059. try {
  5060. c = JSON.stringify(u);
  5061. } catch (y) {
  5062. defaultLogger.error(y);
  5063. return;
  5064. }
  5065. }
  5066. }, {
  5067. key: "ReceivePanoramaDecodeMessage",
  5068. value: function ReceivePanoramaDecodeMessage(e) {
  5069. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  5070. var t = 0,
  5071. r;
  5072. var n = this.PendingMasks.length;
  5073. for (t = 0; t < n; t++) {
  5074. var o = this.PendingMasks[t].buffer,
  5075. a = new DataView(o),
  5076. s = new ArrayBuffer(8),
  5077. l = new DataView(s);
  5078. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  5079. return c ^ u & c;
  5080. }), IsAll0(l)) {
  5081. r = this.PendingMasks[t].angle;
  5082. break;
  5083. }
  5084. }
  5085. for (var _o3 = t; _o3 < n; _o3++) {
  5086. this.PendingMasks.pop();
  5087. }
  5088. this.executeFunction("panorama", {
  5089. data: e.data.data,
  5090. tileId: e.data.tileId,
  5091. pos: {
  5092. x: e.data.x,
  5093. y: e.data.y,
  5094. z: e.data.z
  5095. },
  5096. uuid: e.data.uuid,
  5097. finished: !0,
  5098. matchAngle: r
  5099. });
  5100. }
  5101. }, {
  5102. key: "enable_decoder_queue_logging",
  5103. value: function enable_decoder_queue_logging() {
  5104. this.decoderWorker.postMessage({
  5105. t: 100,
  5106. status: !0
  5107. });
  5108. }
  5109. }, {
  5110. key: "disable_decoder_queue_logging",
  5111. value: function disable_decoder_queue_logging() {
  5112. this.decoderWorker.postMessage({
  5113. t: 100,
  5114. status: !1
  5115. });
  5116. }
  5117. }, {
  5118. key: "init",
  5119. value: function () {
  5120. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  5121. var _this5 = this;
  5122. var e,
  5123. r,
  5124. n,
  5125. t,
  5126. _args = arguments;
  5127. return regenerator.wrap(function _callee$(_context) {
  5128. while (1) {
  5129. switch (_context.prev = _context.next) {
  5130. case 0:
  5131. e = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
  5132. width: 1280,
  5133. height: 720
  5134. };
  5135. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  5136. n = {
  5137. buffer: new Uint8Array(2621440),
  5138. size: 0,
  5139. startReceiveTime: 0,
  5140. serverTime: 0,
  5141. frameCnt: -1
  5142. };
  5143. this.cacheFrameComposes.push(n);
  5144. }
  5145. t = new Blob([decoder], {
  5146. type: "application/javascript"
  5147. });
  5148. return _context.abrupt("return", (this.decoderWorker = new Worker(URL.createObjectURL(t)), this.decoderWorker.postMessage({
  5149. t: 9,
  5150. url: WASM_URLS[WASM_Version],
  5151. jitterLength: DECODER_PASSIVE_JITTER
  5152. }), this.decoderWorker.postMessage({
  5153. t: 1,
  5154. config: e
  5155. }), new Promise(function (r) {
  5156. _this5.decoderWorker.onmessage = function (n) {
  5157. switch (n.data.t) {
  5158. case 0:
  5159. _this5.ReceiveDecodeMessage(n);
  5160. break;
  5161. case 1:
  5162. _this5.UpdateStats(n);
  5163. break;
  5164. case 2:
  5165. r();
  5166. break;
  5167. case 3:
  5168. _this5.SendCacheFrameInfo(n);
  5169. break;
  5170. case 4:
  5171. {
  5172. var o = new Date().toISOString(),
  5173. a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  5174. uploadStream(COS_PREFIX + a, n.data.fileObj);
  5175. break;
  5176. }
  5177. case 5:
  5178. _this5.executeFunction("signal", {
  5179. signal: n.data.metadata,
  5180. pts: -1,
  5181. alreadyUpdateYUV: !1
  5182. });
  5183. break;
  5184. case 6:
  5185. defaultLogger.infoAndReportMeasurement(n.data), defaultLogger.debug("WASM Ready Cost");
  5186. break;
  5187. case 7:
  5188. _this5.ReceivePanoramaDecodeMessage(n);
  5189. break;
  5190. case 8:
  5191. {
  5192. var _o4 = {
  5193. MstType: 0
  5194. };
  5195. var _a3 = "";
  5196. try {
  5197. _a3 = JSON.stringify(_o4);
  5198. } catch (l) {
  5199. defaultLogger.error(l);
  5200. return;
  5201. }
  5202. var s = "wasm:" + _a3;
  5203. _this5._rtcp.sendStringData(s);
  5204. break;
  5205. }
  5206. case 9:
  5207. {
  5208. defaultLogger.info(n.data.printMsg);
  5209. break;
  5210. }
  5211. case 10:
  5212. {
  5213. defaultLogger.error(n.data.printMsg), _this5.executeFunction("error", {
  5214. code: n.data.code,
  5215. message: n.data.printMsg
  5216. });
  5217. break;
  5218. }
  5219. default:
  5220. defaultLogger.error("Receive unknown message event from decoder"), defaultLogger.debug(n.data);
  5221. break;
  5222. }
  5223. };
  5224. })));
  5225. case 4:
  5226. case "end":
  5227. return _context.stop();
  5228. }
  5229. }
  5230. }, _callee, this);
  5231. }));
  5232. function init() {
  5233. return _init.apply(this, arguments);
  5234. }
  5235. return init;
  5236. }()
  5237. }, {
  5238. key: "UpdateYUV",
  5239. value: function UpdateYUV() {
  5240. var t, r;
  5241. var e = this.getPtr;
  5242. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  5243. var n = Date.now();
  5244. if (this.firstUpdateYUV) {
  5245. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  5246. defaultLogger.infoAndReportMeasurement({
  5247. metric: "firstUpdateStreamLength",
  5248. value: h,
  5249. group: "joinRoom"
  5250. }), this.firstUpdateYUV = !1;
  5251. }
  5252. this.cachedStreams[e] != null && this.executeFunction("stream", {
  5253. stream: this.cachedStreams[e],
  5254. width: this.cachedResolution[e].width,
  5255. height: this.cachedResolution[e].height,
  5256. pts: this.cachedPtss[e]
  5257. });
  5258. var o = Date.now();
  5259. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  5260. t: 2,
  5261. frameCnt: this.cachedPtss[e],
  5262. buffer: this.cachedStreams[e]
  5263. }, [this.cachedStreams[e].buffer]);
  5264. var a = Date.now(),
  5265. s = o - n,
  5266. l = a - o;
  5267. (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;
  5268. var u = o - n;
  5269. this.updateYUVCircular.add(u);
  5270. var c = this.cachedMetas[e];
  5271. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  5272. var _iterator3 = _createForOfIteratorHelper$1(c.traceIds),
  5273. _step3;
  5274. try {
  5275. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  5276. var _h = _step3.value;
  5277. if (this.traceIdMap.has(_h)) {
  5278. var f = this.traceIdMap.get(_h);
  5279. if (f != null) {
  5280. f.displayTime = Date.now(), f.status = 3;
  5281. var d = f.receiveTime - f.startTime,
  5282. _ = f.readyTime - f.receiveTime,
  5283. g = f.displayTime - f.readyTime,
  5284. m = f.displayTime - f.startTime;
  5285. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  5286. }
  5287. }
  5288. }
  5289. } catch (err) {
  5290. _iterator3.e(err);
  5291. } finally {
  5292. _iterator3.f();
  5293. }
  5294. }
  5295. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  5296. var _h2 = Date.now(),
  5297. _f = _h2 - this.lastMoveDisplayTime;
  5298. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  5299. }
  5300. this.executeFunction("signal", {
  5301. signal: this.cachedMetas[e],
  5302. pts: this.cachedPtss[e],
  5303. alreadyUpdateYUV: !0
  5304. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  5305. }
  5306. }
  5307. }, {
  5308. key: "unmarshalPano",
  5309. value: function unmarshalPano(e) {
  5310. var t = new DataView(e);
  5311. if (t.getUint32(0) != 1723558763) return !1;
  5312. console.log("Receive Pano Message"), t.getUint16(4);
  5313. var n = t.getUint16(6),
  5314. o = t.getUint32(8),
  5315. a = t.getUint32(12) - (1 << 30) * 2,
  5316. s = t.getUint32(16) - (1 << 30) * 2,
  5317. l = t.getUint32(20) - (1 << 30) * 2,
  5318. u = t.getUint32(24),
  5319. c = new Uint8Array(e).subarray(28, 64),
  5320. h = String.fromCharCode.apply(null, c),
  5321. f = t.getUint32(64),
  5322. d = e.byteLength - n;
  5323. if (d == u) {
  5324. var g = {
  5325. data: new Uint8Array(e).subarray(n),
  5326. mediaLen: u,
  5327. tileId: o,
  5328. uuid: h,
  5329. x: a,
  5330. y: s,
  5331. z: l
  5332. };
  5333. this.decoderWorker.postMessage({
  5334. t: 8,
  5335. data: g
  5336. });
  5337. } else {
  5338. var _ = new Uint8Array(e, n, d);
  5339. if (this.cachePanoTileID == o) {
  5340. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  5341. var m = {
  5342. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  5343. mediaLen: u,
  5344. tileId: o,
  5345. uuid: h,
  5346. x: a,
  5347. y: s,
  5348. z: l
  5349. };
  5350. this.decoderWorker.postMessage({
  5351. t: 8,
  5352. data: m
  5353. }), this.panoCacheSize = 0;
  5354. }
  5355. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  5356. }
  5357. return !0;
  5358. }
  5359. }, {
  5360. key: "clearMoveArray",
  5361. value: function clearMoveArray() {
  5362. 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 = "";
  5363. }
  5364. }, {
  5365. key: "getIsMoving",
  5366. value: function getIsMoving(e) {
  5367. var t;
  5368. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  5369. var n = e.newUserStates[r];
  5370. if (n.userId == this.rtcp.network.room.userId) {
  5371. t = n.renderInfo.isMoving;
  5372. break;
  5373. }
  5374. }
  5375. return t;
  5376. }
  5377. }, {
  5378. key: "isHeartBeatPacket",
  5379. value: function isHeartBeatPacket(e, t) {
  5380. return new DataView(e).getUint32(0) == 2009889916;
  5381. }
  5382. }, {
  5383. key: "resetSendTimeDiff",
  5384. value: function resetSendTimeDiff() {
  5385. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  5386. }
  5387. }, {
  5388. key: "calcSendTimeDiff",
  5389. value: function calcSendTimeDiff(e) {
  5390. if (this.prevSenderTs == -1) {
  5391. this.prevSenderTs = e;
  5392. return;
  5393. }
  5394. var t = e - this.prevSenderTs;
  5395. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  5396. }
  5397. }, {
  5398. key: "unmarshalStream",
  5399. value: function unmarshalStream(e) {
  5400. var _this6 = this;
  5401. var T, C, A, S, P, R, M, x, I, w;
  5402. var t = new DataView(e);
  5403. if (t.getUint32(0) != 1437227610) return !1;
  5404. t.getUint16(4);
  5405. var n = t.getUint16(6),
  5406. o = t.getUint16(8),
  5407. a = o,
  5408. s = t.getUint16(10);
  5409. var l = !1;
  5410. s == 1 && (l = !0);
  5411. var u = t.getUint32(12),
  5412. c = t.getUint32(16),
  5413. h = t.getUint32(20),
  5414. f = t.getUint16(24),
  5415. d = t.getUint16(26),
  5416. _ = t.getUint32(28),
  5417. g = t.getUint32(n - 4),
  5418. m = u + c,
  5419. v = e.byteLength - n,
  5420. y = new Uint8Array(e, n, v);
  5421. this.calcSendTimeDiff(h);
  5422. var b;
  5423. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  5424. if (v === m) {
  5425. this.receivedMedia++;
  5426. var O = new Uint8Array(e).subarray(n);
  5427. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  5428. var D = Date.now();
  5429. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  5430. var F = c === 0,
  5431. V = h - this.lastServerTS;
  5432. 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;
  5433. var N = O.subarray(0, u),
  5434. L = Date.now(),
  5435. k = JSON.parse(this.Stringify(N)),
  5436. U = Date.now();
  5437. 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));
  5438. var z = this.getIsMoving(k);
  5439. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  5440. var G = Date.now(),
  5441. W = G - this.lastMoveResponseTime;
  5442. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  5443. }
  5444. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  5445. return G.userId === _this6._rtcp.network.room.userId;
  5446. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  5447. var H = {
  5448. t: 0,
  5449. data: O,
  5450. mediaLen: c,
  5451. metaLen: u,
  5452. metadata: k,
  5453. frameCnt: a,
  5454. server_ts: h,
  5455. isIDR: l,
  5456. cacheRequest: d,
  5457. cached: f,
  5458. cachedKey: _,
  5459. position: b
  5460. };
  5461. if (this.inPanoMode) return this.executeFunction("signal", {
  5462. signal: k,
  5463. pts: -1,
  5464. alreadyUpdateYUV: !0
  5465. }), !0;
  5466. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  5467. this.firstMediaArraval = Date.now();
  5468. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  5469. defaultLogger.infoAndReportMeasurement({
  5470. metric: "firstMediaArravalAt",
  5471. value: _G,
  5472. group: "joinRoom"
  5473. }), this.firstMediaReceived = !0;
  5474. }
  5475. } else {
  5476. var _O = this.hasFrmCntInCache(a);
  5477. if (_O != -1) {
  5478. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  5479. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  5480. 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++;
  5481. var _F = Date.now();
  5482. _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;
  5483. var _V = _D.subarray(0, u),
  5484. _N = Date.now(),
  5485. _L = JSON.parse(this.Stringify(_V)),
  5486. _k = Date.now();
  5487. 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);
  5488. var _U = this.getIsMoving(_L);
  5489. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  5490. var _H = Date.now(),
  5491. _G2 = _H - this.lastMoveResponseTime;
  5492. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  5493. }
  5494. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  5495. return H.userId === _this6._rtcp.network.room.userId;
  5496. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  5497. var _z = {
  5498. t: 0,
  5499. data: _D,
  5500. mediaLen: c,
  5501. metaLen: u,
  5502. metadata: _L,
  5503. frameCnt: a,
  5504. server_ts: h,
  5505. isIDR: l,
  5506. cacheRequest: d,
  5507. cached: f,
  5508. cachedKey: _,
  5509. position: b
  5510. };
  5511. if (this.inPanoMode) return this.executeFunction("signal", {
  5512. signal: _L,
  5513. pts: -1,
  5514. alreadyUpdateYUV: !0
  5515. }), !0;
  5516. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  5517. this.firstMediaArraval = Date.now();
  5518. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  5519. defaultLogger.infoAndReportMeasurement({
  5520. metric: "firstMediaArravalAt",
  5521. value: _H2,
  5522. group: "joinRoom"
  5523. }), this.firstMediaReceived = !0;
  5524. }
  5525. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  5526. } else if (_O == -1) {
  5527. var _D2 = this.hasFrmCntInCache(-1);
  5528. if (_D2 == -1) {
  5529. var _F2 = Date.now() + 1e18,
  5530. _V2 = -1;
  5531. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  5532. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  5533. }
  5534. _D2 = _V2;
  5535. }
  5536. 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;
  5537. }
  5538. }
  5539. return !0;
  5540. }
  5541. }, {
  5542. key: "reset",
  5543. value: function reset() {
  5544. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  5545. t: 4
  5546. });
  5547. }
  5548. }, {
  5549. key: "dataHandleOff",
  5550. value: function dataHandleOff(e) {
  5551. defaultLogger.debug("hhh");
  5552. }
  5553. }, {
  5554. key: "dataHandle",
  5555. value: function dataHandle(e) {
  5556. this.saveframe && (this.decoderWorker.postMessage({
  5557. t: 6
  5558. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  5559. t: 7
  5560. }), this.SaveMediaStream = !1);
  5561. var t = new Uint8Array(e);
  5562. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  5563. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  5564. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  5565. return;
  5566. }
  5567. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  5568. this.noWasmBytesReceived += e.byteLength;
  5569. var r = JSON.parse(this.Stringify(t));
  5570. this.executeFunction("signal", {
  5571. signal: r,
  5572. pts: -1,
  5573. alreadyUpdateYUV: !0
  5574. });
  5575. }
  5576. }, {
  5577. key: "changePanoMode",
  5578. value: function changePanoMode(e) {
  5579. this.inPanoMode = e;
  5580. }
  5581. }, {
  5582. key: "uploadDataToServer",
  5583. value: function uploadDataToServer() {
  5584. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  5585. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  5586. }), this.DynamicPanoTest = !1);
  5587. function e(ie, ee) {
  5588. return ee == -1 && (ee = 0), ie + ee;
  5589. }
  5590. function t(ie, ee) {
  5591. return Math.max(ie, ee);
  5592. }
  5593. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  5594. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  5595. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  5596. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  5597. s = this.overallTimeArray.length;
  5598. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  5599. var l = this.moveResponseCircular.getThreshPercent(),
  5600. u = l[0],
  5601. c = l[1],
  5602. h = l[2],
  5603. f = l[3],
  5604. d = l[4],
  5605. _ = d - f,
  5606. g = 1 - c / d || 0,
  5607. m = [u, c - u, h - c, f - h, _],
  5608. v = this.moveProcessCircular.getThreshPercent(),
  5609. y = v[0],
  5610. b = v[1],
  5611. T = v[2],
  5612. C = v[3],
  5613. A = v[4],
  5614. S = A - C,
  5615. P = 1 - b / A || 0,
  5616. R = [y, b - y, T - b, C - T, S],
  5617. M = this.moveDisplayCircular.getThreshPercent(),
  5618. x = M[0],
  5619. I = M[1],
  5620. w = M[2],
  5621. O = M[3],
  5622. D = M[4],
  5623. F = D - O,
  5624. V = 1 - I / D || 0,
  5625. N = [x, I - x, w - I, O - w, F],
  5626. L = x,
  5627. k = I - x,
  5628. U = w - I,
  5629. z = O - w,
  5630. H = F,
  5631. G = this.moveResponseCircular.getAvg(),
  5632. W = this.moveProcessCircular.getAvg(),
  5633. j = this.moveDisplayCircular.getAvg(),
  5634. B = this.moveResponseCircular.getMax(),
  5635. X = this.moveProcessCircular.getMax(),
  5636. $ = this.moveDisplayCircular.getMax(),
  5637. Y = this.moveResponseCircular.getStandardDeviation(),
  5638. K = this.moveProcessCircular.getStandardDeviation(),
  5639. Z = this.moveDisplayCircular.getStandardDeviation();
  5640. 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();
  5641. var q = this.frameServerCircular.getAvg(),
  5642. J = this.frameServerCircular.getMax();
  5643. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  5644. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  5645. te = this.metaParseAraay.reduce(t, 0);
  5646. this.metaParseAraay = [];
  5647. var re = {
  5648. mediaBytesReceived: this.mediaBytesReceived,
  5649. metaBytesReceived: this.metaBytesReceived,
  5650. packetsLost: this.packetsLost,
  5651. timestamp: Date.now(),
  5652. frameHeight: 1280,
  5653. frameWidth: 720,
  5654. framesReceived: this.receivedMedia,
  5655. framesReceivedWorker: this.receivedMedia_worker,
  5656. framesDecoded: this.receivedYUV,
  5657. framesEmited: this.receivedEmit,
  5658. decodeTimePerFrame: this.decodeTimePerFrame,
  5659. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  5660. packetsDrop: this.packetsDrop,
  5661. framesAwait: this.framesAwait,
  5662. firstMediaArraval: this.firstMediaArraval,
  5663. firstYUVDecoded: this.firstYUVDecoded,
  5664. firstRender: this.firstRender,
  5665. returnFrames: this.returnFrames,
  5666. sendOutBuffer: this.sendOutBuffer,
  5667. maxGraphicTime: this.updateYUVCircular.getMax(),
  5668. averageGraphicTime: this.updateYUVCircular.getAvg(),
  5669. jankTimes: this.JankTimes,
  5670. bigJankTimes: this.bigJankTimes,
  5671. decodeJankTimes: this.DecodeJankTimes,
  5672. bigDecodeJankTimes: this.bigDecodeJankTimes,
  5673. serverFrameSlow: this.serverFrameSlow,
  5674. serverFrameFast: this.serverFrameFast,
  5675. clientFrameSlow: this.clientFrameSlow,
  5676. clientFrameFast: this.clientFrameFast,
  5677. rtcMessageReceived: this.rtcMessageReceived,
  5678. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  5679. receiveIframes: this.receiveIframes,
  5680. decodeIframes: this.decodeIframes,
  5681. avgResponseTime: r,
  5682. avgProcessTime: n,
  5683. avgDisplayTime: o,
  5684. avgOverallTime: a,
  5685. overallTimeCount: s,
  5686. responseMiss: this.responseMiss,
  5687. processMiss: this.processMiss,
  5688. displayMiss: this.displayMiss,
  5689. updateDropFrame: this.updateDropFrame,
  5690. moveEvent: this.moveEvent,
  5691. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  5692. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  5693. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  5694. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  5695. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  5696. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  5697. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  5698. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  5699. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  5700. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  5701. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  5702. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  5703. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  5704. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  5705. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  5706. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  5707. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  5708. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  5709. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  5710. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  5711. sdMoveResponseLongTime: Y,
  5712. sdMoveProcessLongTime: K,
  5713. sdMoveDisplayLongTime: Z,
  5714. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  5715. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  5716. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  5717. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  5718. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  5719. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  5720. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  5721. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  5722. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  5723. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  5724. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  5725. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  5726. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  5727. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  5728. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  5729. avgMetaParseTime: Q,
  5730. maxMetaParseTime: te,
  5731. avgServerDiff: q,
  5732. maxServerDiff: J,
  5733. streamType: WASM_Version
  5734. };
  5735. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  5736. }
  5737. }]);
  5738. return Workers;
  5739. }();
  5740. 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); }; }
  5741. 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; } }
  5742. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  5743. _inherits(Rtcp, _EventEmitter);
  5744. var _super = _createSuper$9(Rtcp);
  5745. function Rtcp(e) {
  5746. var _this;
  5747. _classCallCheck(this, Rtcp);
  5748. _this = _super.call(this);
  5749. E(_assertThisInitialized(_this), "connection", null);
  5750. E(_assertThisInitialized(_this), "inputChannel", null);
  5751. E(_assertThisInitialized(_this), "mediaStream");
  5752. E(_assertThisInitialized(_this), "socket");
  5753. E(_assertThisInitialized(_this), "connected", !1);
  5754. E(_assertThisInitialized(_this), "candidates", []);
  5755. E(_assertThisInitialized(_this), "isAnswered", !1);
  5756. E(_assertThisInitialized(_this), "isFlushing", !1);
  5757. E(_assertThisInitialized(_this), "inputReady", !1);
  5758. E(_assertThisInitialized(_this), "workers");
  5759. E(_assertThisInitialized(_this), "actived", !0);
  5760. E(_assertThisInitialized(_this), "heartbeat");
  5761. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  5762. if (e.candidate != null) {
  5763. var t = JSON.stringify(e.candidate);
  5764. logger.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  5765. id: "ice_candidate",
  5766. data: btoa(t)
  5767. });
  5768. }
  5769. });
  5770. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  5771. logger.error("onicecandidateerror", e.errorCode, e.errorText, e);
  5772. });
  5773. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  5774. switch (e.target.iceGatheringState) {
  5775. case "gathering":
  5776. logger.info("ice gathering");
  5777. break;
  5778. case "complete":
  5779. logger.info("Ice gathering completed");
  5780. }
  5781. });
  5782. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  5783. if (!!_this.connection) switch (logger.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  5784. case "connected":
  5785. {
  5786. _this.connected = !0;
  5787. break;
  5788. }
  5789. case "disconnected":
  5790. {
  5791. _this.connected = !1, _this.emit("rtcDisconnected");
  5792. break;
  5793. }
  5794. case "failed":
  5795. {
  5796. _this.emit("rtcDisconnected"), _this.connected = !1;
  5797. break;
  5798. }
  5799. }
  5800. });
  5801. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  5802. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  5803. var a, s, l, r, n, o, u;
  5804. return regenerator.wrap(function _callee$(_context) {
  5805. while (1) {
  5806. switch (_context.prev = _context.next) {
  5807. case 0:
  5808. if (_this.connection) {
  5809. _context.next = 2;
  5810. break;
  5811. }
  5812. return _context.abrupt("return");
  5813. case 2:
  5814. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  5815. _context.next = 5;
  5816. return _this.connection.setRemoteDescription(n);
  5817. case 5:
  5818. _context.next = 7;
  5819. return _this.connection.createAnswer();
  5820. case 7:
  5821. o = _context.sent;
  5822. 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) {
  5823. u = o.sdp.lastIndexOf("a=mid:1");
  5824. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  5825. }
  5826. _context.prev = 9;
  5827. _context.next = 12;
  5828. return _this.connection.setLocalDescription(o);
  5829. case 12:
  5830. _context.next = 17;
  5831. break;
  5832. case 14:
  5833. _context.prev = 14;
  5834. _context.t0 = _context["catch"](9);
  5835. logger.error("error", _context.t0);
  5836. case 17:
  5837. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  5838. id: "answer",
  5839. data: btoa(JSON.stringify(o))
  5840. }), t.srcObject = _this.mediaStream;
  5841. case 18:
  5842. case "end":
  5843. return _context.stop();
  5844. }
  5845. }
  5846. }, _callee, null, [[9, 14]]);
  5847. }));
  5848. return function (_x, _x2) {
  5849. return _ref.apply(this, arguments);
  5850. };
  5851. }());
  5852. E(_assertThisInitialized(_this), "flushCandidate", function () {
  5853. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  5854. var t = atob(e),
  5855. r = JSON.parse(t);
  5856. if (/172\./.test(r.candidate)) return;
  5857. var n = new RTCIceCandidate(r);
  5858. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  5859. logger.info("add candidate failed", o);
  5860. });
  5861. }), _this.isFlushing = !1);
  5862. });
  5863. E(_assertThisInitialized(_this), "input", function (e) {
  5864. var t;
  5865. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  5866. });
  5867. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger), _this.workers.registerLogger(logger), _this.workers.registerFunction("data", function (t) {
  5868. _this.emit("data", t);
  5869. }), _this.heartbeat = new Heartbeat({
  5870. ping: function ping(t) {
  5871. e.room.actionsHandler.echo(t);
  5872. },
  5873. pong(t, r) {
  5874. var n;
  5875. r && t > 500 && logger.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  5876. hb: t
  5877. });
  5878. }
  5879. });
  5880. return _this;
  5881. }
  5882. _createClass(Rtcp, [{
  5883. key: "start",
  5884. value: function start() {
  5885. var _this2 = this;
  5886. this.connection = new RTCPeerConnection();
  5887. var e = Date.now();
  5888. this.connection.ondatachannel = function (t) {
  5889. logger.info("ondatachannel: ".concat(t.channel.label));
  5890. _this2.inputChannel = t.channel;
  5891. _this2.inputChannel.onopen = function () {
  5892. var r;
  5893. 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({
  5894. metric: "datachannelOpenedAt",
  5895. startTime: _this2.network.room._startTime,
  5896. group: "joinRoom"
  5897. }), logger.infoAndReportMeasurement({
  5898. metric: "datachannelOpenedCost",
  5899. startTime: e,
  5900. group: "joinRoom"
  5901. }));
  5902. }, _this2.inputChannel.onclose = function () {
  5903. var r;
  5904. return logger.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  5905. }, _this2.inputChannel.onmessage = function (r) {
  5906. _this2.workers.dataHandle(r.data);
  5907. };
  5908. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  5909. id: "init_webrtc",
  5910. data: JSON.stringify({
  5911. is_mobile: !0
  5912. })
  5913. });
  5914. }
  5915. }, {
  5916. key: "addCandidate",
  5917. value: function addCandidate(e) {
  5918. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  5919. }
  5920. }, {
  5921. key: "disconnect",
  5922. value: function disconnect() {
  5923. var e, t, r;
  5924. 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;
  5925. }
  5926. }, {
  5927. key: "sendStringData",
  5928. value: function sendStringData(e) {
  5929. console.log('e', e);
  5930. this.input(e);
  5931. }
  5932. }, {
  5933. key: "sendData",
  5934. value: function sendData(e) {
  5935. var t = "";
  5936. try {
  5937. t = JSON.stringify(e);
  5938. } catch (r) {
  5939. logger.error(r);
  5940. return;
  5941. }
  5942. this.input(t);
  5943. }
  5944. }]);
  5945. return Rtcp;
  5946. }(EventEmitter);
  5947. var NetworkMonitor = /*#__PURE__*/function () {
  5948. function NetworkMonitor(e) {
  5949. _classCallCheck(this, NetworkMonitor);
  5950. this._listener = e;
  5951. }
  5952. _createClass(NetworkMonitor, [{
  5953. key: "isOnline",
  5954. get: function get() {
  5955. var e = window.navigator;
  5956. return typeof e.onLine == "boolean" ? e.onLine : !0;
  5957. }
  5958. }, {
  5959. key: "start",
  5960. value: function start() {
  5961. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  5962. }
  5963. }, {
  5964. key: "stop",
  5965. value: function stop() {
  5966. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  5967. }
  5968. }]);
  5969. return NetworkMonitor;
  5970. }();
  5971. var Stream = /*#__PURE__*/function () {
  5972. function Stream(e) {
  5973. _classCallCheck(this, Stream);
  5974. this.el = null;
  5975. this._streamPlayTimer = null;
  5976. if (!e) {
  5977. this.el = this.createVideoElement();
  5978. return;
  5979. }
  5980. this.el = e;
  5981. }
  5982. _createClass(Stream, [{
  5983. key: "play",
  5984. value: function play() {
  5985. var _this = this;
  5986. return new Promise(function (e, t) {
  5987. _this._streamPlayTimer = new Timeout(function () {
  5988. t(new InternalError("Stream play timeout"));
  5989. }, 5e3), _this.el && _this.el.play().then(function () {
  5990. var r;
  5991. e(), logger.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  5992. }).catch(function (r) {
  5993. var n;
  5994. logger.error("Media Failed to autoplay"), logger.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  5995. });
  5996. });
  5997. }
  5998. }, {
  5999. key: "createVideoElement",
  6000. value: function createVideoElement() {
  6001. var e = document.createElement("video");
  6002. 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;
  6003. }
  6004. }]);
  6005. return Stream;
  6006. }();
  6007. 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); }; }
  6008. 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; } }
  6009. var InternalError$1 = /*#__PURE__*/function (_XverseError) {
  6010. _inherits(InternalError, _XverseError);
  6011. var _super = _createSuper$8(InternalError);
  6012. function InternalError(e) {
  6013. _classCallCheck(this, InternalError);
  6014. return _super.call(this, 1002, e || "\u5185\u90E8\u9519\u8BEF");
  6015. }
  6016. return _createClass(InternalError);
  6017. }(XverseError);
  6018. 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); }; }
  6019. 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; } }
  6020. 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 ";
  6021. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  6022. _inherits(NetworkController, _EventEmitter);
  6023. var _super = _createSuper$7(NetworkController);
  6024. function NetworkController(e) {
  6025. var _this;
  6026. _classCallCheck(this, NetworkController);
  6027. _this = _super.call(this);
  6028. _this.socket = null;
  6029. _this.rtcp = null;
  6030. _this.stream = null;
  6031. _this._state = 'connecting';
  6032. _this._networkMonitor = null;
  6033. _this.blockedActions = [];
  6034. _this.reconnectCount = 0;
  6035. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  6036. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  6037. _this.stream = new Stream();
  6038. _this._networkMonitor = new NetworkMonitor(function () {
  6039. 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());
  6040. });
  6041. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  6042. _this._networkMonitor.start();
  6043. new VisibilityChangeHandler().subscribe(function (r) {
  6044. var n, o;
  6045. r ? ((o = _this.room.stats) == null || o.disable(), logger.infoAndReportMeasurement({
  6046. metric: "pageHide",
  6047. startTime: Date.now()
  6048. })) : ((n = _this.room.stats) == null || n.enable(), logger.infoAndReportMeasurement({
  6049. metric: "pageShow",
  6050. startTime: Date.now(),
  6051. extra: {
  6052. state: _this._state
  6053. }
  6054. }), _this._state === "disconnected" && _this.reconnect());
  6055. });
  6056. return _this;
  6057. }
  6058. _createClass(NetworkController, [{
  6059. key: "startGame",
  6060. value: function startGame() {
  6061. var _this2 = this;
  6062. return new Promise(function (e, t) {
  6063. if (!_this2.rtcp.connected) return t(new InternalError$1("Game cannot load. Please refresh"));
  6064. if (!_this2.rtcp.inputReady) return t(new InternalError$1("Game is not ready yet. Please wait"));
  6065. _this2.socket.on("gameRoomAvailable", function (r) {
  6066. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  6067. }), _this2.socket.on("socketClosed", function (r) {
  6068. t(r);
  6069. }), _this2.socket.startGame();
  6070. });
  6071. }
  6072. }, {
  6073. key: "addBlockedActions",
  6074. value: function addBlockedActions(e) {
  6075. var _this$blockedActions;
  6076. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  6077. }
  6078. }, {
  6079. key: "removeBlockedActions",
  6080. value: function removeBlockedActions(e) {
  6081. if (!e) {
  6082. this.blockedActions = [];
  6083. return;
  6084. }
  6085. var t = this.blockedActions.indexOf(e);
  6086. this.blockedActions.splice(t, 1);
  6087. }
  6088. }, {
  6089. key: "setState",
  6090. value: function setState(e) {
  6091. this._state !== e && (logger.info("Set network state to ", e), this._state = e);
  6092. }
  6093. }, {
  6094. key: "connectAndStart",
  6095. value: function () {
  6096. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6097. return regenerator.wrap(function _callee$(_context) {
  6098. while (1) {
  6099. switch (_context.prev = _context.next) {
  6100. case 0:
  6101. return _context.abrupt("return", this.connect(e).then(this.startGame));
  6102. case 1:
  6103. case "end":
  6104. return _context.stop();
  6105. }
  6106. }
  6107. }, _callee, this);
  6108. }));
  6109. function connectAndStart(_x) {
  6110. return _connectAndStart.apply(this, arguments);
  6111. }
  6112. return connectAndStart;
  6113. }()
  6114. }, {
  6115. key: "connect",
  6116. value: function () {
  6117. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6118. var _this3 = this;
  6119. var e,
  6120. _args2 = arguments;
  6121. return regenerator.wrap(function _callee2$(_context2) {
  6122. while (1) {
  6123. switch (_context2.prev = _context2.next) {
  6124. case 0:
  6125. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  6126. this.room.updateCurrentNetworkOptions({
  6127. reconnect: e
  6128. });
  6129. return _context2.abrupt("return", new Promise(function (t, r) {
  6130. _this3.rtcp.on("rtcConnected", function () {
  6131. _this3.setState("connected"), t();
  6132. }), _this3.rtcp.on("rtcDisconnected", function () {
  6133. 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());
  6134. }), _this3.socket.on("socketQuit", function () {
  6135. logger.info("socket quit success"), _this3.setState("closed");
  6136. }), _this3.socket.on("socketClosed", function (n) {
  6137. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  6138. }), _this3.socket.start();
  6139. }));
  6140. case 3:
  6141. case "end":
  6142. return _context2.stop();
  6143. }
  6144. }
  6145. }, _callee2, this);
  6146. }));
  6147. function connect() {
  6148. return _connect.apply(this, arguments);
  6149. }
  6150. return connect;
  6151. }()
  6152. }, {
  6153. key: "reconnect",
  6154. value: function reconnect() {
  6155. var _this4 = this;
  6156. if (this.room.viewMode === "observer") return;
  6157. var e = Date.now();
  6158. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  6159. logger.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  6160. state: "disconnected"
  6161. });
  6162. return;
  6163. }
  6164. return logger.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  6165. logger.infoAndReportMeasurement({
  6166. startTime: e,
  6167. metric: "reconnect"
  6168. });
  6169. }).catch(function (t) {
  6170. if (logger.infoAndReportMeasurement({
  6171. startTime: e,
  6172. metric: "reconnect",
  6173. error: t
  6174. }), t.code === Codes.RepeatLogin) {
  6175. _this4.room.handleRepetLogin();
  6176. return;
  6177. }
  6178. var r = 1e3;
  6179. logger.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  6180. _this4.reconnect();
  6181. }, r);
  6182. });
  6183. }
  6184. }, {
  6185. key: "_reconnect",
  6186. value: function _reconnect() {
  6187. var _this5 = this;
  6188. 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", {
  6189. state: "reconnecting",
  6190. count: this.reconnectCount
  6191. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  6192. var e = _ref.session_id;
  6193. _this5.room.updateCurrentNetworkOptions({
  6194. sessionId: e
  6195. }), reporter.updateBody({
  6196. serverSession: e
  6197. }), logger.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  6198. state: "reconnected"
  6199. });
  6200. }));
  6201. }
  6202. }, {
  6203. key: "prepareReconnect",
  6204. value: function prepareReconnect() {
  6205. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  6206. }
  6207. }, {
  6208. key: "prepareReconnectOptions",
  6209. value: function prepareReconnectOptions() {
  6210. var _ref2 = this.room.currentClickingState || {},
  6211. e = _ref2.camera,
  6212. t = _ref2.player;
  6213. e && t && this.room.updateCurrentNetworkOptions({
  6214. camera: e,
  6215. player: t
  6216. });
  6217. }
  6218. }, {
  6219. key: "sendRtcData",
  6220. value: function sendRtcData(e) {
  6221. if (this.blockedActions.includes(e.action_type)) {
  6222. logger.info("action: ".concat(Actions[e.action_type], " was blocked"));
  6223. return;
  6224. }
  6225. this.rtcp.sendData(e);
  6226. }
  6227. }, {
  6228. key: "sendSocketData",
  6229. value: function sendSocketData(e) {
  6230. logger.debug("ws send ->", e), this.socket.send(e);
  6231. }
  6232. }, {
  6233. key: "quit",
  6234. value: function quit() {
  6235. var e = util.uuid(),
  6236. t = {
  6237. action_type: Actions.Exit,
  6238. trace_id: e,
  6239. exit_action: {},
  6240. user_id: this.room.options.userId,
  6241. packet_id: e
  6242. };
  6243. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  6244. }
  6245. }, {
  6246. key: "checkNetworkQuality",
  6247. value: function checkNetworkQuality(i) {
  6248. var worker = null;
  6249. if (!i) return;
  6250. var e = Date.now();
  6251. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  6252. logger.infoAndReportMeasurement({
  6253. metric: "baiduRtt",
  6254. group: "http",
  6255. value: r,
  6256. startTime: e
  6257. });
  6258. }), !worker) {
  6259. var t = new Blob([workerSourceCode], {
  6260. type: "application/javascript"
  6261. });
  6262. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  6263. logger.infoAndReportMeasurement({
  6264. metric: "workerRtt",
  6265. group: "http",
  6266. startTime: e,
  6267. value: r.data
  6268. });
  6269. };
  6270. }
  6271. }
  6272. }, {
  6273. key: "pingOthers",
  6274. value: function pingOthers(i, e) {
  6275. var t = !1;
  6276. var r = new Image();
  6277. r.onload = o, r.onerror = a;
  6278. var n = Date.now();
  6279. function o(l) {
  6280. t = !0, s();
  6281. }
  6282. function a(l) {}
  6283. function s() {
  6284. var l = Date.now() - n;
  6285. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  6286. }
  6287. r.src = i + "/favicon.ico?" + +new Date();
  6288. }
  6289. }]);
  6290. return NetworkController;
  6291. }(EventEmitter);
  6292. 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); }; }
  6293. 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; } }
  6294. var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
  6295. _inherits(InitConfigTimeoutError, _XverseError);
  6296. var _super = _createSuper$6(InitConfigTimeoutError);
  6297. function InitConfigTimeoutError(e) {
  6298. _classCallCheck(this, InitConfigTimeoutError);
  6299. return _super.call(this, 1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6");
  6300. }
  6301. return _createClass(InitConfigTimeoutError);
  6302. }(XverseError);
  6303. 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); }; }
  6304. 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; } }
  6305. var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
  6306. _inherits(InitDecoderTimeoutError, _XverseError);
  6307. var _super = _createSuper$5(InitDecoderTimeoutError);
  6308. function InitDecoderTimeoutError(e) {
  6309. _classCallCheck(this, InitDecoderTimeoutError);
  6310. return _super.call(this, 1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6");
  6311. }
  6312. return _createClass(InitDecoderTimeoutError);
  6313. }(XverseError);
  6314. 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); }; }
  6315. 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; } }
  6316. var InitEngineError = /*#__PURE__*/function (_XverseError) {
  6317. _inherits(InitEngineError, _XverseError);
  6318. var _super = _createSuper$4(InitEngineError);
  6319. function InitEngineError(e) {
  6320. _classCallCheck(this, InitEngineError);
  6321. return _super.call(this, 1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF");
  6322. }
  6323. return _createClass(InitEngineError);
  6324. }(XverseError);
  6325. var AssetTypeName = {
  6326. Config: 'CONFIG',
  6327. Model: 'MODEL',
  6328. Vedio: 'VEDIO',
  6329. Media: 'MEDIA',
  6330. Effects: 'EFFECTS',
  6331. Gift: 'GIFT',
  6332. Textures: 'TEXTURES'
  6333. };
  6334. var AssetClassName = {
  6335. Effects: '\u7279\u6548',
  6336. Tv: 'TV',
  6337. Lpm: '\u7C97\u6A21',
  6338. Reward: '\u571F\u8C6A\u699C',
  6339. Env: '\u73AF\u5883\u5149',
  6340. Gbq: '\u544A\u767D\u5899',
  6341. BreathPoint: '\u547C\u5438\u70B9',
  6342. Gifts: '\u9001\u793C',
  6343. Panorama: '\u5168\u666F\u56FE',
  6344. GiftBubble: '\u9001\u793C\u6C14\u6CE1',
  6345. SayBubble: '\u804A\u5929\u6C14\u6CE1'
  6346. };
  6347. var LoggerLevels$1 = {
  6348. Debug: 1,
  6349. Info: 2,
  6350. Warn: 3,
  6351. Error: 4,
  6352. Off: 5
  6353. };
  6354. var EShaderMode$1 = {
  6355. default: 0,
  6356. video: 1,
  6357. videoAndPano: 2
  6358. };
  6359. var BaseTable = /*#__PURE__*/function () {
  6360. function BaseTable(e, t) {
  6361. _classCallCheck(this, BaseTable);
  6362. this.db = null;
  6363. this.isCreatingTable = !1;
  6364. this.hasCleared = !1;
  6365. this.dbName = e, this.dbVersion = t;
  6366. }
  6367. _createClass(BaseTable, [{
  6368. key: "clearDataBase",
  6369. value: function () {
  6370. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  6371. var _this = this;
  6372. return regenerator.wrap(function _callee$(_context) {
  6373. while (1) {
  6374. switch (_context.prev = _context.next) {
  6375. case 0:
  6376. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  6377. var n = window.indexedDB.deleteDatabase(_this.dbName);
  6378. n.onsuccess = function () {
  6379. t();
  6380. }, n.onerror = r;
  6381. }));
  6382. case 1:
  6383. case "end":
  6384. return _context.stop();
  6385. }
  6386. }
  6387. }, _callee, this);
  6388. }));
  6389. function clearDataBase(_x) {
  6390. return _clearDataBase.apply(this, arguments);
  6391. }
  6392. return clearDataBase;
  6393. }()
  6394. }, {
  6395. key: "tableName",
  6396. value: function tableName() {
  6397. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  6398. }
  6399. }, {
  6400. key: "keyPath",
  6401. value: function keyPath() {
  6402. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  6403. }
  6404. }, {
  6405. key: "index",
  6406. value: function index() {
  6407. throw new Error("Derived class have to override 'index', and set a proper index name!");
  6408. }
  6409. }, {
  6410. key: "checkAndOpenDatabase",
  6411. value: function () {
  6412. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6413. var _this2 = this;
  6414. return regenerator.wrap(function _callee2$(_context2) {
  6415. while (1) {
  6416. switch (_context2.prev = _context2.next) {
  6417. case 0:
  6418. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  6419. var n = setTimeout(function () {
  6420. logger.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  6421. }, 200);
  6422. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  6423. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  6424. }, function () {
  6425. t(new Error("Failed to open database!")), clearTimeout(n);
  6426. }, function () {
  6427. _this2.db && e(_this2.db), clearTimeout(n), logger.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  6428. });
  6429. }));
  6430. case 1:
  6431. case "end":
  6432. return _context2.stop();
  6433. }
  6434. }
  6435. }, _callee2, this);
  6436. }));
  6437. function checkAndOpenDatabase() {
  6438. return _checkAndOpenDatabase.apply(this, arguments);
  6439. }
  6440. return checkAndOpenDatabase;
  6441. }()
  6442. }, {
  6443. key: "openDatabase",
  6444. value: function openDatabase(e, t, r, n, o) {
  6445. var _this3 = this;
  6446. if (this.isCreatingTable) return;
  6447. this.isCreatingTable = !0, logger.info(e, t);
  6448. var a = window.indexedDB.open(e, t),
  6449. s = this.tableName();
  6450. a.onsuccess = function (l) {
  6451. _this3.db = a.result, logger.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  6452. }, a.onerror = function (l) {
  6453. var u;
  6454. 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);
  6455. }, a.onupgradeneeded = function (l) {
  6456. var u = l.target.result,
  6457. c = _this3.index();
  6458. logger.info("Creating table ".concat(s, "."));
  6459. var h = u.objectStoreNames.contains(s);
  6460. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  6461. var f = _this3.keyPath();
  6462. h = u.createObjectStore(s, {
  6463. keyPath: f
  6464. });
  6465. }
  6466. c.map(function (f) {
  6467. h.createIndex(f, f, {
  6468. unique: !1
  6469. });
  6470. }), _this3.isCreatingTable = !1, logger.info("Table ".concat(s, " opened")), o && o(l);
  6471. };
  6472. }
  6473. }, {
  6474. key: "add",
  6475. value: function () {
  6476. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  6477. var t, o;
  6478. return regenerator.wrap(function _callee3$(_context3) {
  6479. while (1) {
  6480. switch (_context3.prev = _context3.next) {
  6481. case 0:
  6482. t = this.tableName();
  6483. _context3.next = 3;
  6484. return this.checkAndOpenDatabase();
  6485. case 3:
  6486. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  6487. return _context3.abrupt("return", new Promise(function (a, s) {
  6488. o.onsuccess = function (l) {
  6489. a(l);
  6490. }, o.onerror = function (l) {
  6491. var u;
  6492. logger.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  6493. };
  6494. }));
  6495. case 5:
  6496. case "end":
  6497. return _context3.stop();
  6498. }
  6499. }
  6500. }, _callee3, this);
  6501. }));
  6502. function add(_x2) {
  6503. return _add.apply(this, arguments);
  6504. }
  6505. return add;
  6506. }()
  6507. }, {
  6508. key: "put",
  6509. value: function () {
  6510. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  6511. var t, o;
  6512. return regenerator.wrap(function _callee4$(_context4) {
  6513. while (1) {
  6514. switch (_context4.prev = _context4.next) {
  6515. case 0:
  6516. t = this.tableName();
  6517. _context4.next = 3;
  6518. return this.checkAndOpenDatabase();
  6519. case 3:
  6520. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  6521. return _context4.abrupt("return", new Promise(function (a, s) {
  6522. o.onsuccess = function (l) {
  6523. a(l);
  6524. }, o.onerror = function (l) {
  6525. var u;
  6526. logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  6527. };
  6528. }));
  6529. case 5:
  6530. case "end":
  6531. return _context4.stop();
  6532. }
  6533. }
  6534. }, _callee4, this);
  6535. }));
  6536. function put(_x3) {
  6537. return _put.apply(this, arguments);
  6538. }
  6539. return put;
  6540. }()
  6541. }, {
  6542. key: "delete",
  6543. value: function _delete(e, t, r) {
  6544. var n = this.tableName();
  6545. this.checkAndOpenDatabase().then(function (o) {
  6546. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  6547. s.onsuccess = t, s.onerror = r;
  6548. });
  6549. }
  6550. }, {
  6551. key: "update",
  6552. value: function update() {
  6553. this.checkAndOpenDatabase().then(function (e) {});
  6554. }
  6555. }, {
  6556. key: "getAllKeys",
  6557. value: function () {
  6558. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  6559. var e, t;
  6560. return regenerator.wrap(function _callee5$(_context5) {
  6561. while (1) {
  6562. switch (_context5.prev = _context5.next) {
  6563. case 0:
  6564. e = this.tableName();
  6565. _context5.next = 3;
  6566. return this.checkAndOpenDatabase();
  6567. case 3:
  6568. t = _context5.sent;
  6569. return _context5.abrupt("return", new Promise(function (r, n) {
  6570. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  6571. a.onsuccess = function (s) {
  6572. r(s.target.result);
  6573. }, a.onerror = function (s) {
  6574. logger.error("db getAllKeys error", s), n(s);
  6575. };
  6576. }));
  6577. case 5:
  6578. case "end":
  6579. return _context5.stop();
  6580. }
  6581. }
  6582. }, _callee5, this);
  6583. }));
  6584. function getAllKeys() {
  6585. return _getAllKeys.apply(this, arguments);
  6586. }
  6587. return getAllKeys;
  6588. }()
  6589. }, {
  6590. key: "query",
  6591. value: function () {
  6592. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  6593. var r, n;
  6594. return regenerator.wrap(function _callee6$(_context6) {
  6595. while (1) {
  6596. switch (_context6.prev = _context6.next) {
  6597. case 0:
  6598. r = this.tableName();
  6599. _context6.next = 3;
  6600. return this.checkAndOpenDatabase();
  6601. case 3:
  6602. n = _context6.sent;
  6603. return _context6.abrupt("return", new Promise(function (o, a) {
  6604. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  6605. u.onsuccess = function (c) {
  6606. var f;
  6607. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  6608. o && o(h);
  6609. }, u.onerror = function (c) {
  6610. logger.error("db query error", c), a(c);
  6611. };
  6612. }));
  6613. case 5:
  6614. case "end":
  6615. return _context6.stop();
  6616. }
  6617. }
  6618. }, _callee6, this);
  6619. }));
  6620. function query(_x4, _x5) {
  6621. return _query.apply(this, arguments);
  6622. }
  6623. return query;
  6624. }()
  6625. }, {
  6626. key: "sleep",
  6627. value: function () {
  6628. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  6629. return regenerator.wrap(function _callee7$(_context7) {
  6630. while (1) {
  6631. switch (_context7.prev = _context7.next) {
  6632. case 0:
  6633. return _context7.abrupt("return", new Promise(function (t) {
  6634. setTimeout(function () {
  6635. t("");
  6636. }, e);
  6637. }));
  6638. case 1:
  6639. case "end":
  6640. return _context7.stop();
  6641. }
  6642. }
  6643. }, _callee7);
  6644. }));
  6645. function sleep(_x6) {
  6646. return _sleep.apply(this, arguments);
  6647. }
  6648. return sleep;
  6649. }()
  6650. }]);
  6651. return BaseTable;
  6652. }();
  6653. 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); }; }
  6654. 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; } }
  6655. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  6656. _inherits(ModelTable, _BaseTable);
  6657. var _super = _createSuper$3(ModelTable);
  6658. function ModelTable() {
  6659. _classCallCheck(this, ModelTable);
  6660. return _super.call(this, "XverseDatabase", 1);
  6661. }
  6662. _createClass(ModelTable, [{
  6663. key: "tableName",
  6664. value: function tableName() {
  6665. return "models";
  6666. }
  6667. }, {
  6668. key: "index",
  6669. value: function index() {
  6670. return ["url"];
  6671. }
  6672. }, {
  6673. key: "keyPath",
  6674. value: function keyPath() {
  6675. return "url";
  6676. }
  6677. }]);
  6678. return ModelTable;
  6679. }(BaseTable);
  6680. var modelTable = new ModelTable();
  6681. 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); }; }
  6682. 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; } }
  6683. var Http = /*#__PURE__*/function (_EventEmitter) {
  6684. _inherits(Http, _EventEmitter);
  6685. var _super = _createSuper$2(Http);
  6686. function Http() {
  6687. _classCallCheck(this, Http);
  6688. return _super.apply(this, arguments);
  6689. }
  6690. _createClass(Http, [{
  6691. key: "get",
  6692. value: function () {
  6693. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  6694. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  6695. return regenerator.wrap(function _callee2$(_context2) {
  6696. while (1) {
  6697. switch (_context2.prev = _context2.next) {
  6698. case 0:
  6699. e = _ref.url, _ref$useIndexedDb = _ref.useIndexedDb, t = _ref$useIndexedDb === void 0 ? !1 : _ref$useIndexedDb, _ref$timeout = _ref.timeout, r = _ref$timeout === void 0 ? 15e3 : _ref$timeout, n = _ref.key, _ref$isOutPutObjectUR = _ref.isOutPutObjectURL, o = _ref$isOutPutObjectUR === void 0 ? !0 : _ref$isOutPutObjectUR;
  6700. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  6701. _context2.next = 25;
  6702. break;
  6703. }
  6704. if (!isIndexedDbSupported()) {
  6705. _context2.next = 22;
  6706. break;
  6707. }
  6708. window.performance.now();
  6709. a = null;
  6710. _context2.prev = 5;
  6711. _context2.next = 8;
  6712. return modelTable.query("url", e);
  6713. case 8:
  6714. a = _context2.sent;
  6715. _context2.next = 14;
  6716. break;
  6717. case 11:
  6718. _context2.prev = 11;
  6719. _context2.t0 = _context2["catch"](5);
  6720. return _context2.abrupt("return", (logger.debug(_context2.t0), logger.warn("cache query error", e), Promise.resolve(e)));
  6721. case 14:
  6722. if (!(a && a.model)) {
  6723. _context2.next = 19;
  6724. break;
  6725. }
  6726. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  6727. return _context2.abrupt("return", (window.performance.now(), l));
  6728. case 19:
  6729. return _context2.abrupt("return", this.request({
  6730. url: e,
  6731. timeout: r,
  6732. contentType: "blob",
  6733. key: n
  6734. }).then( /*#__PURE__*/function () {
  6735. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  6736. var l;
  6737. return regenerator.wrap(function _callee$(_context) {
  6738. while (1) {
  6739. switch (_context.prev = _context.next) {
  6740. case 0:
  6741. _context.next = 2;
  6742. return blobToDataURI(s.response);
  6743. case 2:
  6744. l = _context.sent;
  6745. _context.prev = 3;
  6746. _context.next = 6;
  6747. return modelTable.put({
  6748. url: e,
  6749. model: l
  6750. });
  6751. case 6:
  6752. _context.next = 11;
  6753. break;
  6754. case 8:
  6755. _context.prev = 8;
  6756. _context.t0 = _context["catch"](3);
  6757. logger.warn("unable to add data to indexedDB", _context.t0);
  6758. case 11:
  6759. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  6760. case 12:
  6761. case "end":
  6762. return _context.stop();
  6763. }
  6764. }
  6765. }, _callee, null, [[3, 8]]);
  6766. }));
  6767. return function (_x2) {
  6768. return _ref2.apply(this, arguments);
  6769. };
  6770. }()));
  6771. case 20:
  6772. _context2.next = 23;
  6773. break;
  6774. case 22:
  6775. return _context2.abrupt("return", this.request({
  6776. url: e,
  6777. timeout: r,
  6778. contentType: "blob",
  6779. key: n
  6780. }).then(function (a) {
  6781. var s = a.response;
  6782. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  6783. }).catch(function (a) {
  6784. return Promise.reject(a);
  6785. }));
  6786. case 23:
  6787. _context2.next = 26;
  6788. break;
  6789. case 25:
  6790. return _context2.abrupt("return", this.request({
  6791. url: e,
  6792. timeout: r,
  6793. key: n
  6794. }).then(function (a) {
  6795. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  6796. }));
  6797. case 26:
  6798. case "end":
  6799. return _context2.stop();
  6800. }
  6801. }
  6802. }, _callee2, this, [[5, 11]]);
  6803. }));
  6804. function get(_x) {
  6805. return _get.apply(this, arguments);
  6806. }
  6807. return get;
  6808. }()
  6809. }, {
  6810. key: "request",
  6811. value: function request(e) {
  6812. var _this = this;
  6813. var _e$timeout = e.timeout,
  6814. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  6815. r = e.contentType;
  6816. e.key;
  6817. var o = e.onRequestStart,
  6818. a = e.url;
  6819. return new Promise(function (s, l) {
  6820. window.performance.now();
  6821. var u = new XMLHttpRequest();
  6822. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  6823. if (u.readyState == 4) {
  6824. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  6825. message: "request ".concat(a, " load success")
  6826. }), s(u);
  6827. {
  6828. var c = "Unable to load the request ".concat(a);
  6829. return _this.emit("error", {
  6830. message: c
  6831. }), logger.error(c), l(c);
  6832. }
  6833. }
  6834. }), o && o(u), u.open("GET", a), u.send();
  6835. });
  6836. }
  6837. }]);
  6838. return Http;
  6839. }(EventEmitter); // const http = new Http();
  6840. 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; } } }; }
  6841. 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); }
  6842. 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; }
  6843. var XSceneManager = /*#__PURE__*/function () {
  6844. function XSceneManager(e, t) {
  6845. var _this = this;
  6846. _classCallCheck(this, XSceneManager);
  6847. E(this, "scene");
  6848. E(this, "engine");
  6849. E(this, "canvas");
  6850. E(this, "gl");
  6851. E(this, "_yuvInfo");
  6852. E(this, "cameraParam");
  6853. E(this, "shaderMode");
  6854. E(this, "panoInfo");
  6855. E(this, "_initEngineScaleNumber");
  6856. E(this, "_forceKeepVertical", !1);
  6857. E(this, "_currentShader");
  6858. E(this, "_currentPanoId");
  6859. E(this, "_renderStatusCheckCount", 0);
  6860. E(this, "_renderStatusNotChecktCount", 0);
  6861. E(this, "_nonlinearCanvasResize", !1);
  6862. E(this, "_bChangeEngineSize", !0);
  6863. E(this, "_cameraManager");
  6864. E(this, "_lowpolyManager");
  6865. E(this, "_materialManager");
  6866. E(this, "_statisticManager");
  6867. E(this, "_breathPointManager");
  6868. E(this, "_skytv");
  6869. E(this, "_mv", []);
  6870. E(this, "_decalManager");
  6871. E(this, "_lightManager");
  6872. E(this, "_avatarManager");
  6873. E(this, "urlTransformer");
  6874. E(this, "_billboardManager");
  6875. E(this, "_backgroundImg");
  6876. E(this, "engineRunTimeStats");
  6877. E(this, "uploadHardwareSystemInfo", function () {
  6878. var e = _this.statisticComponent.getHardwareRenderInfo(),
  6879. t = _this.statisticComponent.getSystemInfo(),
  6880. r = {
  6881. driver: t.driver,
  6882. vender: t.vender,
  6883. webgl: t.version,
  6884. os: t.os
  6885. };
  6886. logger.warn(JSON.stringify(e)), logger.warn(JSON.stringify(r));
  6887. });
  6888. E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
  6889. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  6890. return regenerator.wrap(function _callee$(_context) {
  6891. while (1) {
  6892. switch (_context.prev = _context.next) {
  6893. case 0:
  6894. _context.t0 = _this._currentShader == null;
  6895. if (!_context.t0) {
  6896. _context.next = 4;
  6897. break;
  6898. }
  6899. _context.next = 4;
  6900. return _this.initSceneManager();
  6901. case 4:
  6902. return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
  6903. case 5:
  6904. case "end":
  6905. return _context.stop();
  6906. }
  6907. }
  6908. }, _callee);
  6909. }));
  6910. return function (_x, _x2) {
  6911. return _ref.apply(this, arguments);
  6912. };
  6913. }());
  6914. E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  6915. return regenerator.wrap(function _callee2$(_context2) {
  6916. while (1) {
  6917. switch (_context2.prev = _context2.next) {
  6918. case 0:
  6919. _context2.next = 2;
  6920. return _this._materialManager.initMaterial();
  6921. case 2:
  6922. return _context2.abrupt("return", _this.applyShader());
  6923. case 3:
  6924. case "end":
  6925. return _context2.stop();
  6926. }
  6927. }
  6928. }, _callee2);
  6929. })));
  6930. E(this, "registerAfterRender", function () {
  6931. var e;
  6932. if (_this._forceKeepVertical) {
  6933. var _t = _this.canvas.width,
  6934. _r = _this.canvas.height;
  6935. var _n = 0,
  6936. _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
  6937. if (((e = _this._cameraManager.MainCamera) == null ? void 0 : e.fovMode) === BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? (_n = Math.ceil((_r - _this._yuvInfo.height * _t / _this._yuvInfo.width) / 2), _o = [[0, 0, _t, _n], [0, _r - _n, _t, _n]]) : (_n = Math.ceil((_t - _this._yuvInfo.width * _r / _this._yuvInfo.height) / 2), _o = [[0, 0, _n, _r], [_t - _n, 0, _n, _r]]), _n > 0) {
  6938. _this.gl.enable(_this.gl.SCISSOR_TEST);
  6939. for (var a = 0; a < _o.length; ++a) {
  6940. _this.gl.scissor(_o[a][0], _o[a][1], _o[a][2], _o[a][3]), _this.gl.clearColor(0, 0, 0, 1), _this.gl.clear(_this.gl.COLOR_BUFFER_BIT);
  6941. }
  6942. _this.gl.disable(_this.gl.SCISSOR_TEST);
  6943. }
  6944. }
  6945. });
  6946. E(this, "resetRender", function () {
  6947. _this.scene.environmentTexture && (_this.scene.environmentTexture._texture ? _this.lightComponent.setIBL(_this.scene.environmentTexture._texture.url) : _this.scene.environmentTexture.url && _this.lightComponent.setIBL(_this.scene.environmentTexture.url));
  6948. });
  6949. var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
  6950. n = new Engine(e, !0, {
  6951. preserveDrawingBuffer: !0,
  6952. stencil: !0,
  6953. disableWebGL2Support: r
  6954. }, !0),
  6955. o = new Scene(n);
  6956. this.scene = o, this.engine = n, this.canvas = e, this.scene.clearColor = new Color4(.7, .7, .7, 1), this.engine.getCaps().parallelShaderCompile = void 0, this._initEngineScaleNumber = this.engine.getHardwareScalingLevel(), this.engine.enableOfflineSupport = !1, this.engine.doNotHandleContextLost = !0, this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.urlTransformer = t.urlTransformer || function (s) {
  6957. return Promise.resolve(s);
  6958. }, t.logger && Logger$1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
  6959. preserveDrawingBuffer: !0
  6960. }) || e.getContext("webgl", {
  6961. preserveDrawingBuffer: !0
  6962. }) || e.getContext("experimental-webgl", {
  6963. preserveDrawingBuffer: !0
  6964. }), this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1), this._currentPanoId = 0, t.forceKeepVertical != null && (this._forceKeepVertical = t.forceKeepVertical), t.panoInfo != null && (this.panoInfo = t.panoInfo), t.shaderMode != null && (this.shaderMode = t.shaderMode), t.yuvInfo != null ? this._yuvInfo = t.yuvInfo : this._yuvInfo = {
  6965. width: t.videoResOriArray[0].width,
  6966. height: t.videoResOriArray[0].height,
  6967. fov: 50
  6968. }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
  6969. cameraParam: this.cameraParam,
  6970. yuvInfo: this._yuvInfo,
  6971. forceKeepVertical: this._forceKeepVertical
  6972. }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
  6973. videoResOriArray: t.videoResOriArray,
  6974. yuvInfo: this._yuvInfo,
  6975. panoInfo: this.panoInfo,
  6976. shaderMode: this.shaderMode
  6977. }), this._statisticManager = new XStats(this), this._breathPointManager = new XBreathPointManager(this), this._decalManager = new XDecalManager(this), this._avatarManager = new XAvatarManager(this), this._billboardManager = new XBillboardManager(this), this.billboardComponent.loadBackGroundTexToIDB(), this._lightManager = new XLightManager(this), this.postprocessing(), this.initSceneManager(), this.engineRunTimeStats = new XEngineRunTimeStats(), /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812 ? this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 2) : this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.8), this.scene.registerBeforeRender(function () {
  6978. _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
  6979. }), this.scene.registerAfterRender(function () {
  6980. _this._nonlinearCanvasResize || _this.registerAfterRender();
  6981. }), window.addEventListener("resize", function () {
  6982. _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
  6983. }), XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
  6984. }
  6985. _createClass(XSceneManager, [{
  6986. key: "yuvInfo",
  6987. get: function get() {
  6988. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  6989. width: -1,
  6990. height: -1,
  6991. fov: -1
  6992. };
  6993. },
  6994. set: function set(e) {
  6995. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
  6996. }
  6997. }, {
  6998. key: "mainScene",
  6999. get: function get() {
  7000. return this.scene;
  7001. }
  7002. }, {
  7003. key: "cameraComponent",
  7004. get: function get() {
  7005. return this._cameraManager;
  7006. }
  7007. }, {
  7008. key: "staticmeshComponent",
  7009. get: function get() {
  7010. return this._lowpolyManager;
  7011. }
  7012. }, {
  7013. key: "materialComponent",
  7014. get: function get() {
  7015. return this._materialManager;
  7016. }
  7017. }, {
  7018. key: "statisticComponent",
  7019. get: function get() {
  7020. return this._statisticManager;
  7021. }
  7022. }, {
  7023. key: "avatarComponent",
  7024. get: function get() {
  7025. return this._avatarManager;
  7026. }
  7027. }, {
  7028. key: "lightComponent",
  7029. get: function get() {
  7030. return this._lightManager;
  7031. }
  7032. }, {
  7033. key: "Engine",
  7034. get: function get() {
  7035. return this.engine;
  7036. }
  7037. }, {
  7038. key: "Scene",
  7039. get: function get() {
  7040. return this.scene;
  7041. }
  7042. }, {
  7043. key: "billboardComponent",
  7044. get: function get() {
  7045. return this._billboardManager;
  7046. }
  7047. }, {
  7048. key: "breathPointComponent",
  7049. get: function get() {
  7050. return this._breathPointManager;
  7051. }
  7052. }, {
  7053. key: "skytvComponent",
  7054. get: function get() {
  7055. return this._skytv;
  7056. }
  7057. }, {
  7058. key: "mvComponent",
  7059. get: function get() {
  7060. return this._mv;
  7061. }
  7062. }, {
  7063. key: "decalComponent",
  7064. get: function get() {
  7065. return this._decalManager;
  7066. }
  7067. }, {
  7068. key: "currentShader",
  7069. get: function get() {
  7070. return this._currentShader;
  7071. }
  7072. }, {
  7073. key: "initEngineScaleNumber",
  7074. get: function get() {
  7075. return this._initEngineScaleNumber;
  7076. }
  7077. }, {
  7078. key: "setImageQuality",
  7079. value: function setImageQuality(e) {
  7080. e == 0 ? (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.8), logger.info("[Engine] change image quality to low, [" + this._initEngineScaleNumber * 1.8 + "]")) : e == 1 ? (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.5), logger.info("[Engine] change image quality to mid, [" + this._initEngineScaleNumber * 1.5 + "]")) : e == 2 && (this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1), logger.info("[Engine] change image quality to high, [" + this._initEngineScaleNumber * 1 + "]"));
  7081. }
  7082. }, {
  7083. key: "setNonlinearCanvasResize",
  7084. value: function setNonlinearCanvasResize(e) {
  7085. this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
  7086. }
  7087. }, {
  7088. key: "setBackgroundColor",
  7089. value: function setBackgroundColor(e) {
  7090. this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
  7091. }
  7092. }, {
  7093. key: "setBackgroundImg",
  7094. value: function setBackgroundImg(e) {
  7095. var _this2 = this;
  7096. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
  7097. _this2.urlTransformer(e).then(function (n) {
  7098. _this2._backgroundImg == null ? _this2._backgroundImg = {
  7099. layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
  7100. url: e
  7101. } : _this2._backgroundImg.url != e && _this2._backgroundImg.layer != null && _this2._backgroundImg.layer.texture != null && (_this2._backgroundImg.layer.texture.updateURL(n), _this2._backgroundImg.layer.name = "tex_background_" + Date.now(), _this2._backgroundImg.url = e), t(!0);
  7102. }).catch(function (n) {
  7103. logger.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
  7104. });
  7105. });
  7106. }
  7107. }, {
  7108. key: "cleanTheWholeScene",
  7109. value: function cleanTheWholeScene() {
  7110. var _this3 = this;
  7111. var e = this.scene.getFrameId();
  7112. this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
  7113. _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
  7114. });
  7115. }
  7116. }, {
  7117. key: "getAreaAvatar",
  7118. value: function getAreaAvatar(e, t) {
  7119. var r = [];
  7120. return this._avatarManager.getAvatarList().forEach(function (n) {
  7121. var o = e,
  7122. a = n.position;
  7123. a && o && calcDistance3D(o, a) < t && r.push(n.id);
  7124. }), r;
  7125. }
  7126. }, {
  7127. key: "setEngineSize",
  7128. value: function setEngineSize(e) {
  7129. var t = e.width,
  7130. r = e.height,
  7131. n = this.canvas.width;
  7132. this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
  7133. }
  7134. }, {
  7135. key: "getCurrentShaderMode",
  7136. value: function getCurrentShaderMode() {
  7137. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
  7138. }
  7139. }, {
  7140. key: "addSkyTV",
  7141. value: function addSkyTV(e, t) {
  7142. return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
  7143. }
  7144. }, {
  7145. key: "addMv",
  7146. value: function addMv(e, t) {
  7147. this._mv.push(new XTelevision(this.scene, e, this, t));
  7148. }
  7149. }, {
  7150. key: "addMeshInfo",
  7151. value: function addMeshInfo(e) {
  7152. this._lowpolyManager.setMeshInfo(e);
  7153. }
  7154. }, {
  7155. key: "applyShader",
  7156. value: function applyShader() {
  7157. var _this4 = this;
  7158. return new Promise(function (e, t) {
  7159. _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
  7160. });
  7161. }
  7162. }, {
  7163. key: "changeHardwareScaling",
  7164. value: function changeHardwareScaling(e) {
  7165. e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
  7166. }
  7167. }, {
  7168. key: "getCurrentUsedPanoId",
  7169. value: function getCurrentUsedPanoId() {
  7170. return this._currentPanoId;
  7171. }
  7172. }, {
  7173. key: "render",
  7174. value: function render() {
  7175. try {
  7176. this.scene.render();
  7177. } catch (e) {
  7178. throw logger.error("[Engine] Render Error: ".concat(e)), e;
  7179. }
  7180. }
  7181. }, {
  7182. key: "isReadyToRender",
  7183. value: function isReadyToRender(e) {
  7184. var _e$checkMesh = e.checkMesh,
  7185. t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
  7186. _e$checkEffect = e.checkEffect,
  7187. r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
  7188. _e$checkPostProgress = e.checkPostProgress,
  7189. n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
  7190. _e$checkParticle = e.checkParticle,
  7191. o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
  7192. _e$checkAnimation = e.checkAnimation,
  7193. a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
  7194. e.materialNameWhiteLists;
  7195. if (this.scene._isDisposed) return logger.error("[Engine] this.scene._isDisposed== false "), !1;
  7196. var l;
  7197. var u = this.scene.getEngine();
  7198. if (r && !u.areAllEffectsReady()) return logger.error("[Engine] engine.areAllEffectsReady == false"), !1;
  7199. if (a && this.scene._pendingData.length > 0) return logger.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
  7200. if (t) {
  7201. for (l = 0; l < this.scene.meshes.length; l++) {
  7202. var c = this.scene.meshes[l];
  7203. if (!c.isEnabled() || !c.subMeshes || c.subMeshes.length === 0 || c != null && c.material != null && !(c.material.name.startsWith("Pure") || c.material.name.startsWith("Pano"))) continue;
  7204. if (!c.isReady(!0)) return logger.error("[Engine] scene. mesh isReady == false, mesh name:".concat(c.name, ", mesh xtype: ").concat(c == null ? void 0 : c.xtype, ", mesh xgroup: ").concat(c == null ? void 0 : c.xgroup, ", mesh xskinInfo: ").concat(c == null ? void 0 : c.xskinInfo)), !1;
  7205. var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
  7206. var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
  7207. _step;
  7208. try {
  7209. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  7210. var f = _step.value;
  7211. if (!f.action(c, h)) return logger.error("[Engine] scene._isReadyForMeshStage == false, mesh name:".concat(c.name, ", mesh xtype: ").concat(c == null ? void 0 : c.xtype, ", mesh xgroup: ").concat(c == null ? void 0 : c.xgroup, ", mesh xskinInfo: ").concat(c == null ? void 0 : c.xskinInfo)), !1;
  7212. }
  7213. } catch (err) {
  7214. _iterator.e(err);
  7215. } finally {
  7216. _iterator.f();
  7217. }
  7218. }
  7219. for (l = 0; l < this.scene.geometries.length; l++) {
  7220. if (this.scene.geometries[l].delayLoadState === 2) return logger.error("[Engine] geometry.delayLoadState === 2"), !1;
  7221. }
  7222. }
  7223. if (n) {
  7224. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  7225. var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
  7226. _step2;
  7227. try {
  7228. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  7229. var _c = _step2.value;
  7230. if (!_c.isReady(!0)) return logger.error("[Engine] camera not ready === false, ", _c.name), !1;
  7231. }
  7232. } catch (err) {
  7233. _iterator2.e(err);
  7234. } finally {
  7235. _iterator2.f();
  7236. }
  7237. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
  7238. }
  7239. if (o) {
  7240. var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
  7241. _step3;
  7242. try {
  7243. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  7244. var _c2 = _step3.value;
  7245. if (!_c2.isReady()) return logger.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
  7246. }
  7247. } catch (err) {
  7248. _iterator3.e(err);
  7249. } finally {
  7250. _iterator3.f();
  7251. }
  7252. }
  7253. return !0;
  7254. }
  7255. }, {
  7256. key: "changePanoShaderForLowModel",
  7257. value: function changePanoShaderForLowModel(e) {
  7258. var _this5 = this;
  7259. return logger.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
  7260. _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
  7261. t(!0);
  7262. });
  7263. });
  7264. }
  7265. }, {
  7266. key: "changeVideoShaderForLowModel",
  7267. value: function changeVideoShaderForLowModel() {
  7268. return logger.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
  7269. }
  7270. }, {
  7271. key: "changeDefaultShaderForLowModel",
  7272. value: function changeDefaultShaderForLowModel() {
  7273. return logger.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
  7274. }
  7275. }, {
  7276. key: "changeShaderForLowModel",
  7277. value: function changeShaderForLowModel() {
  7278. var _this6 = this;
  7279. return new Promise(function (e, t) {
  7280. _this6._lowpolyManager.getMeshes().forEach(function (r) {
  7281. r.setMaterial(_this6._currentShader);
  7282. }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
  7283. });
  7284. }
  7285. }, {
  7286. key: "setIBL",
  7287. value: function setIBL(e) {
  7288. this._lightManager.setIBL(e);
  7289. }
  7290. }, {
  7291. key: "postprocessing",
  7292. value: function postprocessing() {
  7293. var e = new DefaultRenderingPipeline("default", !0, this.scene);
  7294. e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
  7295. }
  7296. }, {
  7297. key: "getGround",
  7298. value: function getGround(e) {
  7299. var t = this._lowpolyManager.getMeshes(),
  7300. r = [];
  7301. return t.forEach(function (n) {
  7302. n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
  7303. }), this.Scene.meshes.forEach(function (n) {
  7304. n.name.split("_")[0] === "ground" && r.push(n);
  7305. }), r;
  7306. }
  7307. }]);
  7308. return XSceneManager;
  7309. }();
  7310. var http = new Http(),
  7311. urlMap = new Map(),
  7312. urlTransformer = /*#__PURE__*/function () {
  7313. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
  7314. var e,
  7315. _args2 = arguments;
  7316. return regenerator.wrap(function _callee2$(_context2) {
  7317. while (1) {
  7318. switch (_context2.prev = _context2.next) {
  7319. case 0:
  7320. e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
  7321. return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
  7322. url: i,
  7323. useIndexedDb: !0,
  7324. key: "url",
  7325. isOutPutObjectURL: !1
  7326. }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  7327. url: i,
  7328. useIndexedDb: !0,
  7329. key: "url"
  7330. }).then(function (t) {
  7331. return urlMap.set(i, t), t;
  7332. }));
  7333. case 2:
  7334. case "end":
  7335. return _context2.stop();
  7336. }
  7337. }
  7338. }, _callee2);
  7339. }));
  7340. return function urlTransformer(_x2) {
  7341. return _ref2.apply(this, arguments);
  7342. };
  7343. }();
  7344. var sceneManager;
  7345. function getSceneManager(i, e) {
  7346. return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
  7347. }
  7348. var EngineProxy = /*#__PURE__*/function () {
  7349. function EngineProxy(e) {
  7350. var _this = this;
  7351. _classCallCheck(this, EngineProxy);
  7352. E(this, "_tvs", []);
  7353. E(this, "isRenderFirstFrame", !1);
  7354. E(this, "_idleTime", 0);
  7355. E(this, "renderTimer");
  7356. E(this, "lightManager");
  7357. E(this, "_checkSceneNotReadyCount", 0);
  7358. E(this, "_checkSceneDurationFrameNum", 0);
  7359. E(this, "_checkSceneFrameCount", 0);
  7360. E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
  7361. E(this, "frameCircularArray", new CircularArray(120, !1, []));
  7362. E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
  7363. E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
  7364. E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
  7365. E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
  7366. E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
  7367. E(this, "animationCircularArray", new CircularArray(120, !1, []));
  7368. E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
  7369. E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
  7370. E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
  7371. E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
  7372. E(this, "renderCnt", 0);
  7373. E(this, "renderErrorCount", 0);
  7374. E(this, "engineSloppyCnt", 0);
  7375. E(this, "systemStuckCnt", 0);
  7376. E(this, "frameRenderNumber", 0);
  7377. E(this, "_setFPS", function (e) {
  7378. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
  7379. logger.info("Set fps to", t);
  7380. var r = t > 60 ? 60 : t < 24 ? 24 : t;
  7381. e.Engine.stopRenderLoop();
  7382. var n = 1e3 / r;
  7383. var o = Date.now(),
  7384. a = Date.now(),
  7385. s = n,
  7386. l = 1;
  7387. var u = function u() {
  7388. var T;
  7389. var c = Date.now(),
  7390. h = c - o,
  7391. f = c - a;
  7392. a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
  7393. var d = h / s;
  7394. l = .9 * l + .1 * d;
  7395. var _ = Date.now();
  7396. var g = 0,
  7397. m = 0;
  7398. if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
  7399. if (_this.isRenderFirstFrame = !0, _this._checkSceneDurationFrameNum > 0) _this._checkSceneFrameCount++, _this.room.sceneManager.isReadyToRender({}) && _this._checkSceneDurationFrameNum--, _this._checkSceneFrameCount > ye._CHECK_DURATION && (_this._checkSceneDurationFrameNum = ye._CHECK_DURATION, _this._checkSceneFrameCount = 0, _this._checkSceneNotReadyCount++, (_this._checkSceneNotReadyCount == 1 || _this._checkSceneNotReadyCount % 100 == 0) && logger.error("[SDK] Scene not ready, skip render. loop: ".concat(_this._checkSceneNotReadyCount)), _this._checkSceneNotReadyCount > 10 && (logger.error("[SDK] Scene not ready, reload later"), _this.room.proxyEvents("renderError", {
  7400. error: new Error("[SDK] Scene not ready, skip render and reload.")
  7401. })), _this.room.stats.assign({
  7402. renderErrorCount: _this._checkSceneNotReadyCount
  7403. }), logger.infoAndReportMeasurement({
  7404. value: 0,
  7405. startTime: Date.now(),
  7406. metric: "renderError",
  7407. error: new Error("[SDK] Scene not ready, skip render and reload."),
  7408. reportOptions: {
  7409. sampleRate: .1
  7410. }
  7411. }));else try {
  7412. e.render();
  7413. } catch (C) {
  7414. _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
  7415. error: C
  7416. }), _this.room.stats.assign({
  7417. renderErrorCount: _this.renderErrorCount
  7418. }), logger.infoAndReportMeasurement({
  7419. value: 0,
  7420. startTime: Date.now(),
  7421. metric: "renderError",
  7422. error: C,
  7423. reportOptions: {
  7424. sampleRate: .1
  7425. }
  7426. });
  7427. }
  7428. g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
  7429. }
  7430. _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
  7431. var y = Date.now() - _;
  7432. o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
  7433. var b = s;
  7434. if (s > 150 && console.log("lastGap is ", s, ", ratio is ", l, ", usedTimeMs is ", y, ", cpuRenderTime is ", g, ", cpuUpdateYUVTime is ", m), _this.timeoutCircularArray.add(b), _this.renderCnt % 25 == 0) {
  7435. var C = _this.frameCircularArray.getAvg(),
  7436. A = _this.timeoutCircularArray.getAvg(),
  7437. S = _this.frameCircularArray.getMax(),
  7438. P = _this.timeoutCircularArray.getMax();
  7439. (T = _this.room.stats) == null || T.assign({
  7440. avgFrameTime: C,
  7441. avgTimeoutTime: A,
  7442. maxFrameTime: S,
  7443. maxTimeoutTime: P,
  7444. systemStuckCnt: _this.systemStuckCnt
  7445. });
  7446. }
  7447. _this.renderTimer = window.setTimeout(u, s);
  7448. };
  7449. _this.renderTimer = window.setTimeout(u, n / l);
  7450. });
  7451. E(this, "updateStats", function () {
  7452. var e;
  7453. (e = _this.room.stats) == null || e.assign({
  7454. renderFrameTime: _this.renderTimeCircularArray.getAvg(),
  7455. maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
  7456. interFrameTime: _this.interFrameCircularArray.getAvg(),
  7457. animationTime: _this.animationCircularArray.getAvg(),
  7458. meshSelectTime: _this.meshSelectCircularArray.getAvg(),
  7459. drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
  7460. idleTime: _this._idleTime,
  7461. registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
  7462. registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
  7463. renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
  7464. fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
  7465. drawcall: _this.drawCallCntCircularArray.getAvg(),
  7466. engineSloppyCnt: _this.engineSloppyCnt,
  7467. maxInterFrameTime: _this.interFrameCircularArray.getMax(),
  7468. maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
  7469. maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
  7470. maxAnimationTime: _this.animationCircularArray.getMax(),
  7471. maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
  7472. maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
  7473. maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
  7474. avgFrameTime: _this.frameCircularArray.getAvg(),
  7475. avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
  7476. maxFrameTime: _this.frameCircularArray.getMax(),
  7477. maxTimeoutTime: _this.timeoutCircularArray.getMax()
  7478. });
  7479. });
  7480. this.room = e;
  7481. }
  7482. _createClass(EngineProxy, [{
  7483. key: "initEngine",
  7484. value: function () {
  7485. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  7486. var t, r, n, o, a;
  7487. return regenerator.wrap(function _callee3$(_context3) {
  7488. while (1) {
  7489. switch (_context3.prev = _context3.next) {
  7490. case 0:
  7491. _context3.next = 2;
  7492. return this.updateBillboard();
  7493. case 2:
  7494. logger.info("engine version:", VERSION$1);
  7495. t = logger;
  7496. t.setLevel(LoggerLevels$1.Warn);
  7497. r = {
  7498. videoResOriArray: [{
  7499. width: 720,
  7500. height: 1280
  7501. }, {
  7502. width: 1280,
  7503. height: 720
  7504. }, {
  7505. width: 480,
  7506. height: 654
  7507. }, {
  7508. width: 654,
  7509. height: 480
  7510. }, {
  7511. width: 1920,
  7512. height: 1080
  7513. }, {
  7514. width: 1080,
  7515. height: 1920
  7516. }, {
  7517. width: 414,
  7518. height: 896
  7519. }],
  7520. forceKeepVertical: this.room.options.objectFit !== "cover",
  7521. panoInfo: {
  7522. dynamicRange: 1,
  7523. width: 4096,
  7524. height: 2048
  7525. },
  7526. shaderMode: EShaderMode$1.videoAndPano,
  7527. yuvInfo: {
  7528. width: 1280,
  7529. height: 720,
  7530. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  7531. },
  7532. cameraParam: {
  7533. maxZ: 1e4
  7534. },
  7535. urlTransformer,
  7536. logger: t,
  7537. disableWebGL2: this.room.options.disableWebGL2 || !1
  7538. }, n = this.room.options.resolution;
  7539. n && (r.videoResOriArray.some(function (l) {
  7540. return l.width === n.width && l.height === n.height;
  7541. }) || r.videoResOriArray.push(n));
  7542. o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  7543. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
  7544. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
  7545. this.room.scene = o.Scene;
  7546. this.room.breathPointManager = o.breathPointComponent;
  7547. this.lightManager = o.lightComponent;
  7548. this.registerStats();
  7549. this.setEnv(e);
  7550. _context3.next = 17;
  7551. return this.room.avatarManager.init();
  7552. case 17:
  7553. a = this._createAssetList(e);
  7554. _context3.next = 20;
  7555. return this.loadAssets(a, "");
  7556. case 20:
  7557. this._setFPS(o);
  7558. case 21:
  7559. case "end":
  7560. return _context3.stop();
  7561. }
  7562. }
  7563. }, _callee3, this);
  7564. }));
  7565. function initEngine(_x3) {
  7566. return _initEngine.apply(this, arguments);
  7567. }
  7568. return initEngine;
  7569. }()
  7570. }, {
  7571. key: "pause",
  7572. value: function pause() {
  7573. clearTimeout(this.renderTimer), logger.info("Invoke room.pause to pause render");
  7574. var e = {
  7575. roomId: this.room.id,
  7576. effects: [],
  7577. lowPolyModels: [],
  7578. breathPointsConfig: [],
  7579. skinId: this.room.skinId
  7580. };
  7581. return this.loadAssets(e, this.room.skinId);
  7582. }
  7583. }, {
  7584. key: "resume",
  7585. value: function () {
  7586. var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  7587. var e;
  7588. return regenerator.wrap(function _callee4$(_context4) {
  7589. while (1) {
  7590. switch (_context4.prev = _context4.next) {
  7591. case 0:
  7592. this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger.info("Invoke room.resume to render");
  7593. e = this._createAssetList(this.room.skin);
  7594. _context4.next = 4;
  7595. return this.loadAssets(e, "");
  7596. case 4:
  7597. case "end":
  7598. return _context4.stop();
  7599. }
  7600. }
  7601. }, _callee4, this);
  7602. }));
  7603. function resume() {
  7604. return _resume.apply(this, arguments);
  7605. }
  7606. return resume;
  7607. }()
  7608. }, {
  7609. key: "setEnv",
  7610. value: function setEnv(e) {
  7611. var r;
  7612. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
  7613. var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  7614. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger.error("env file not found"), Promise.resolve());
  7615. }
  7616. }, {
  7617. key: "_parseModelsAndLoad",
  7618. value: function () {
  7619. var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
  7620. var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
  7621. return regenerator.wrap(function _callee5$(_context5) {
  7622. while (1) {
  7623. switch (_context5.prev = _context5.next) {
  7624. case 0:
  7625. logger.info("Invoke _parseModelsAndLoad start", t);
  7626. n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
  7627. r == null && (r = "xxxx");
  7628. a = !0;
  7629. u = 0;
  7630. case 5:
  7631. if (!(u < e.length)) {
  7632. _context5.next = 20;
  7633. break;
  7634. }
  7635. a = !0;
  7636. c = 0;
  7637. case 8:
  7638. if (!(c < n.length)) {
  7639. _context5.next = 16;
  7640. break;
  7641. }
  7642. if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
  7643. _context5.next = 13;
  7644. break;
  7645. }
  7646. h = o.get(n[c]);
  7647. h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
  7648. return _context5.abrupt("break", 16);
  7649. case 13:
  7650. ++c;
  7651. _context5.next = 8;
  7652. break;
  7653. case 16:
  7654. if (a) {
  7655. _c = o.get("default");
  7656. _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
  7657. }
  7658. case 17:
  7659. ++u;
  7660. _context5.next = 5;
  7661. break;
  7662. case 20:
  7663. s = o.get(t) || [];
  7664. if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
  7665. return !u.modelUrl.endsWith("zip");
  7666. })), !s)) {
  7667. _context5.next = 23;
  7668. break;
  7669. }
  7670. return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
  7671. case 23:
  7672. l = [];
  7673. for (_u = 0; _u < s.length; ++_u) {
  7674. _c2 = s[_u];
  7675. if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  7676. url: _c2.modelUrl,
  7677. skinInfo: r
  7678. }));else {
  7679. _h = t;
  7680. l.push(this.room.sceneManager.addNewLowPolyMesh({
  7681. url: _c2.modelUrl,
  7682. group: _h,
  7683. pick: !0,
  7684. skinInfo: r
  7685. }));
  7686. }
  7687. }
  7688. return _context5.abrupt("return", Promise.all(l));
  7689. case 26:
  7690. case "end":
  7691. return _context5.stop();
  7692. }
  7693. }
  7694. }, _callee5, this);
  7695. }));
  7696. function _parseModelsAndLoad(_x4, _x5, _x6) {
  7697. return _parseModelsAndLoad2.apply(this, arguments);
  7698. }
  7699. return _parseModelsAndLoad;
  7700. }()
  7701. }, {
  7702. key: "_deleteAssetsLowpolyModel",
  7703. value: function () {
  7704. var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  7705. var t;
  7706. return regenerator.wrap(function _callee6$(_context6) {
  7707. while (1) {
  7708. switch (_context6.prev = _context6.next) {
  7709. case 0:
  7710. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  7711. t = [];
  7712. this.room.sceneManager.Scene.meshes.forEach(function (r) {
  7713. r.xskinInfo == e && t.push(r);
  7714. }), t.forEach(function (r) {
  7715. r.dispose(!1, !1);
  7716. });
  7717. case 3:
  7718. case "end":
  7719. return _context6.stop();
  7720. }
  7721. }
  7722. }, _callee6, this);
  7723. }));
  7724. function _deleteAssetsLowpolyModel(_x7) {
  7725. return _deleteAssetsLowpolyModel2.apply(this, arguments);
  7726. }
  7727. return _deleteAssetsLowpolyModel;
  7728. }()
  7729. }, {
  7730. key: "loadLandAssets",
  7731. value: function () {
  7732. var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  7733. var _this2 = this;
  7734. var e;
  7735. return regenerator.wrap(function _callee7$(_context7) {
  7736. while (1) {
  7737. switch (_context7.prev = _context7.next) {
  7738. case 0:
  7739. e = this._createAssetList(this.room.skin);
  7740. return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
  7741. return _this2.loadAssets(e, _this2.room.skinId);
  7742. }));
  7743. case 2:
  7744. case "end":
  7745. return _context7.stop();
  7746. }
  7747. }
  7748. }, _callee7, this);
  7749. }));
  7750. function loadLandAssets() {
  7751. return _loadLandAssets.apply(this, arguments);
  7752. }
  7753. return loadLandAssets;
  7754. }()
  7755. }, {
  7756. key: "loadAssets",
  7757. value: function () {
  7758. var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  7759. var t,
  7760. r,
  7761. n,
  7762. _args8 = arguments;
  7763. return regenerator.wrap(function _callee8$(_context8) {
  7764. while (1) {
  7765. switch (_context8.prev = _context8.next) {
  7766. case 0:
  7767. t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
  7768. r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
  7769. n = Date.now();
  7770. return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
  7771. return logger.infoAndReportMeasurement({
  7772. tag: "loadAssets",
  7773. startTime: n,
  7774. metric: "loadAssets"
  7775. }), o;
  7776. }).catch(function (o) {
  7777. return logger.infoAndReportMeasurement({
  7778. tag: "loadAssets",
  7779. startTime: n,
  7780. metric: "loadAssets",
  7781. error: o
  7782. }), Promise.reject(o);
  7783. }));
  7784. case 4:
  7785. case "end":
  7786. return _context8.stop();
  7787. }
  7788. }
  7789. }, _callee8, this);
  7790. }));
  7791. function loadAssets(_x8) {
  7792. return _loadAssets2.apply(this, arguments);
  7793. }
  7794. return loadAssets;
  7795. }()
  7796. }, {
  7797. key: "_loadAssets",
  7798. value: function () {
  7799. var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
  7800. var t,
  7801. r,
  7802. _args9 = arguments;
  7803. return regenerator.wrap(function _callee9$(_context9) {
  7804. while (1) {
  7805. switch (_context9.prev = _context9.next) {
  7806. case 0:
  7807. t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
  7808. _context9.prev = 1;
  7809. r = [];
  7810. r.push(this._loadAssetsLowpolyModel(e, t));
  7811. _context9.next = 6;
  7812. return Promise.all(r);
  7813. case 6:
  7814. _context9.next = 8;
  7815. return this.setEnv();
  7816. case 8:
  7817. this._checkSceneDurationFrameNum = ye._CHECK_DURATION;
  7818. this._checkSceneNotReadyCount = 0;
  7819. this._checkSceneFrameCount = 0;
  7820. this.updateAnimationList();
  7821. this.room.loadAssetsHook();
  7822. _context9.next = 18;
  7823. break;
  7824. case 15:
  7825. _context9.prev = 15;
  7826. _context9.t0 = _context9["catch"](1);
  7827. return _context9.abrupt("return", Promise.reject(_context9.t0));
  7828. case 18:
  7829. case "end":
  7830. return _context9.stop();
  7831. }
  7832. }
  7833. }, _callee9, this, [[1, 15]]);
  7834. }));
  7835. function _loadAssets(_x9) {
  7836. return _loadAssets3.apply(this, arguments);
  7837. }
  7838. return _loadAssets;
  7839. }()
  7840. }, {
  7841. key: "updateAnimationList",
  7842. value: function updateAnimationList() {
  7843. var _this3 = this;
  7844. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  7845. var e = this.room.skin.animationList;
  7846. if (!e) return;
  7847. e.forEach(function (t) {
  7848. _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
  7849. });
  7850. }
  7851. }
  7852. }, {
  7853. key: "_loadAssetsLowpolyModel",
  7854. value: function () {
  7855. var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  7856. var _this4 = this;
  7857. var t,
  7858. r,
  7859. n,
  7860. o,
  7861. a,
  7862. s,
  7863. u,
  7864. c,
  7865. h,
  7866. _args11 = arguments;
  7867. return regenerator.wrap(function _callee11$(_context11) {
  7868. while (1) {
  7869. switch (_context11.prev = _context11.next) {
  7870. case 0:
  7871. t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
  7872. r = [], n = [], o = [];
  7873. e.lowPolyModels.forEach(function (f) {
  7874. f.group === "TV" ? n.push({
  7875. id: "",
  7876. name: "",
  7877. thumbnailUrl: "",
  7878. typeName: AssetTypeName.Model,
  7879. className: AssetClassName.Tv,
  7880. modelUrl: f.url
  7881. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  7882. id: "",
  7883. name: "",
  7884. thumbnailUrl: "",
  7885. typeName: AssetTypeName.Model,
  7886. className: AssetClassName.Lpm,
  7887. modelUrl: f.url
  7888. }) : r.push({
  7889. id: "",
  7890. name: "",
  7891. thumbnailUrl: "",
  7892. typeName: AssetTypeName.Model,
  7893. className: AssetClassName.Lpm,
  7894. modelUrl: f.url
  7895. });
  7896. }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  7897. a = e.skinId;
  7898. logger.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
  7899. return f.clean();
  7900. }), this._tvs = [];
  7901. s = EFitMode.cover;
  7902. a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
  7903. _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
  7904. fitMode: s
  7905. }));
  7906. }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
  7907. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
  7908. var d;
  7909. return regenerator.wrap(function _callee10$(_context10) {
  7910. while (1) {
  7911. switch (_context10.prev = _context10.next) {
  7912. case 0:
  7913. _context10.prev = 0;
  7914. _context10.next = 3;
  7915. return urlTransformer(f.imageUrl);
  7916. case 3:
  7917. d = _context10.sent;
  7918. _context10.next = 9;
  7919. break;
  7920. case 6:
  7921. _context10.prev = 6;
  7922. _context10.t0 = _context10["catch"](0);
  7923. d = f.imageUrl, logger.error("urlTransformer error", _context10.t0);
  7924. case 9:
  7925. _this4.room.breathPointManager.addBreathPoint({
  7926. id: f.id,
  7927. position: f.position,
  7928. spriteSheet: d,
  7929. rotation: f.rotation || {
  7930. pitch: 0,
  7931. yaw: 270,
  7932. roll: 0
  7933. },
  7934. billboardMode: !0,
  7935. type: f.type || "no_type",
  7936. spriteWidthNumber: f.spriteWidthNum || 1,
  7937. spriteHeightNumber: f.spriteHeightNum || 1,
  7938. maxVisibleRegion: f.maxVisibleRegion || 150,
  7939. width: f.width,
  7940. height: f.height,
  7941. skinInfo: f.skinId
  7942. });
  7943. case 10:
  7944. case "end":
  7945. return _context10.stop();
  7946. }
  7947. }
  7948. }, _callee10, null, [[0, 6]]);
  7949. }));
  7950. return function (_x11) {
  7951. return _ref3.apply(this, arguments);
  7952. };
  7953. }()), o.forEach(function (f) {
  7954. _this4.room.sceneManager.decalComponent.addDecal({
  7955. id: f.id || "gbq",
  7956. meshPath: f.modelUrl,
  7957. skinInfo: a
  7958. });
  7959. });
  7960. u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
  7961. return !f.startsWith("region_");
  7962. }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  7963. return _context11.abrupt("return", new Promise(function (f, d) {
  7964. Promise.all(h.map(function (_) {
  7965. return _this4._parseModelsAndLoad(r, _, a);
  7966. })).then(function () {
  7967. var _ = !1;
  7968. r.forEach(function (v) {
  7969. v.modelUrl.endsWith("zip") && (_ = !0);
  7970. }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
  7971. var g = Array.from(u.keys()).filter(function (v) {
  7972. return !v.startsWith("region_");
  7973. }),
  7974. m = c.filter(function (v) {
  7975. return g.indexOf(v) < 0;
  7976. });
  7977. m.length > 0 && m.forEach(function (v) {
  7978. _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
  7979. }), f(!0);
  7980. }).catch(function (_) {
  7981. d(_);
  7982. });
  7983. }));
  7984. case 9:
  7985. case "end":
  7986. return _context11.stop();
  7987. }
  7988. }
  7989. }, _callee11, this);
  7990. }));
  7991. function _loadAssetsLowpolyModel(_x10) {
  7992. return _loadAssetsLowpolyModel2.apply(this, arguments);
  7993. }
  7994. return _loadAssetsLowpolyModel;
  7995. }()
  7996. }, {
  7997. key: "_updateSkinAssets",
  7998. value: function () {
  7999. var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
  8000. var t, r, n;
  8001. return regenerator.wrap(function _callee12$(_context12) {
  8002. while (1) {
  8003. switch (_context12.prev = _context12.next) {
  8004. case 0:
  8005. t = this.room.lastSkinId;
  8006. _context12.next = 3;
  8007. return this.room.getSkin(e);
  8008. case 3:
  8009. r = _context12.sent;
  8010. n = this._createAssetList(r);
  8011. _context12.prev = 5;
  8012. _context12.next = 8;
  8013. return this.loadAssets(n, t);
  8014. case 8:
  8015. this.room.updateCurrentState({
  8016. versionId: r.versionId,
  8017. skinId: r.id,
  8018. skin: r
  8019. });
  8020. _context12.next = 16;
  8021. break;
  8022. case 11:
  8023. _context12.prev = 11;
  8024. _context12.t0 = _context12["catch"](5);
  8025. _context12.next = 15;
  8026. return this.loadAssets(n, t);
  8027. case 15:
  8028. this.room.updateCurrentState({
  8029. versionId: r.versionId,
  8030. skinId: r.id,
  8031. skin: r
  8032. });
  8033. case 16:
  8034. this.setEnv(r);
  8035. case 17:
  8036. case "end":
  8037. return _context12.stop();
  8038. }
  8039. }
  8040. }, _callee12, this, [[5, 11]]);
  8041. }));
  8042. function _updateSkinAssets(_x12) {
  8043. return _updateSkinAssets2.apply(this, arguments);
  8044. }
  8045. return _updateSkinAssets;
  8046. }()
  8047. }, {
  8048. key: "_createAssetList",
  8049. value: function _createAssetList(e) {
  8050. var t = [],
  8051. r = [],
  8052. n = [];
  8053. var o = e.models;
  8054. var a = this.room.modelManager.config.preload;
  8055. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
  8056. return l.modelUrl = l.url, l;
  8057. })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
  8058. t.push({
  8059. url: l.modelUrl,
  8060. group: l.className,
  8061. name: l.name
  8062. });
  8063. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
  8064. r.push({
  8065. url: l.modelUrl,
  8066. group: l.className
  8067. });
  8068. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
  8069. r.push({
  8070. url: l.modelUrl,
  8071. group: l.className
  8072. });
  8073. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
  8074. r.push({
  8075. url: l.modelUrl,
  8076. group: l.className
  8077. });
  8078. }), [].forEach(function (l) {
  8079. l.skinId == e.id && n.push(l);
  8080. }), {
  8081. roomId: this.room.id,
  8082. effects: t,
  8083. lowPolyModels: r,
  8084. breathPointsConfig: n,
  8085. skinId: e.id
  8086. };
  8087. }
  8088. }, {
  8089. key: "registerStats",
  8090. value: function registerStats() {
  8091. var _this5 = this;
  8092. var e = this.room.sceneManager;
  8093. this.room.scene.registerAfterRender(function () {
  8094. var I;
  8095. var t = e.statisticComponent.getInterFrameTimeCounter(),
  8096. r = e.statisticComponent.getDrawCall(),
  8097. n = e.statisticComponent.getActiveFaces(),
  8098. o = e.statisticComponent.getFrameTimeCounter(),
  8099. a = e.statisticComponent.getDrawCallTime(),
  8100. s = e.statisticComponent.getAnimationTime(),
  8101. l = e.statisticComponent.getActiveMeshEvaluationTime(),
  8102. u = e.statisticComponent.getRenderTargetRenderTime(),
  8103. c = e.statisticComponent.getRegisterBeforeRenderTime(),
  8104. h = e.statisticComponent.getRegisterAfterRenderTime(),
  8105. f = e.statisticComponent.getActiveParticles(),
  8106. d = e.statisticComponent.getActiveBones(),
  8107. _ = e.Scene._activeAnimatables.length,
  8108. g = e.statisticComponent.getTotalRootNodes(),
  8109. m = e.Scene.geometries.length,
  8110. v = e.Scene.onBeforeRenderObservable.observers.length,
  8111. y = e.Scene.onAfterRenderObservable.observers.length,
  8112. b = e.statisticComponent.getTotalMeshes(),
  8113. T = e.statisticComponent.getTotalTextures(),
  8114. C = e.statisticComponent.getTotalMaterials(),
  8115. A = e.statisticComponent.getSystemInfo(),
  8116. S = A.resolution,
  8117. P = A.driver;
  8118. A.vender;
  8119. var R = A.version,
  8120. M = A.hardwareScalingLevel,
  8121. x = S + "_" + P + "_" + R + "_" + M;
  8122. _this5.interFrameCircularArray.add(t), _this5.renderTimeCircularArray.add(o), _this5.animationCircularArray.add(s), _this5.meshSelectCircularArray.add(l), _this5.drawCallTimeCircularArray.add(a), _this5.regAfterRenderCircularArray.add(h), _this5.regBeforeRenderCircularArray.add(c), _this5.renderTargetCircularArray.add(u), _this5.drawCallCntCircularArray.add(r), _this5.renderCnt += 1, _this5.renderCnt % 25 == 0 && ((I = _this5.room.stats) == null || I.assign({
  8123. renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
  8124. maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
  8125. interFrameTime: _this5.interFrameCircularArray.getAvg(),
  8126. animationTime: _this5.animationCircularArray.getAvg(),
  8127. meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
  8128. drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
  8129. idleTime: _this5._idleTime,
  8130. registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
  8131. registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
  8132. renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
  8133. fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
  8134. drawcall: _this5.drawCallCntCircularArray.getAvg(),
  8135. triangle: n.toString(),
  8136. engineSloppyCnt: _this5.engineSloppyCnt,
  8137. maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
  8138. maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
  8139. maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
  8140. maxAnimationTime: _this5.animationCircularArray.getMax(),
  8141. maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
  8142. maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
  8143. maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
  8144. activeParticles: f,
  8145. activeBones: d,
  8146. activeAnimation: _,
  8147. totalMeshes: b,
  8148. totalRootNodes: g,
  8149. totalGeometries: m,
  8150. totalTextures: T,
  8151. totalMaterials: C,
  8152. registerBeforeCount: v,
  8153. registerAfterCount: y,
  8154. hardwareInfo: x
  8155. }));
  8156. });
  8157. }
  8158. }, {
  8159. key: "updateBillboard",
  8160. value: function () {
  8161. var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
  8162. var e, r, n, o, a, s;
  8163. return regenerator.wrap(function _callee13$(_context13) {
  8164. while (1) {
  8165. switch (_context13.prev = _context13.next) {
  8166. case 0:
  8167. e = this.room.options.skinId;
  8168. _context13.next = 3;
  8169. return this.room.modelManager.findAssetList(e);
  8170. case 3:
  8171. r = _context13.sent.filter(function (a) {
  8172. return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
  8173. });
  8174. n = ["bubble01", "bubble02", "bubble03"];
  8175. o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  8176. if (r.length) {
  8177. a = r.filter(function (l) {
  8178. return n.includes(l.name);
  8179. }).map(function (l) {
  8180. return l.url;
  8181. }), s = r.filter(function (l) {
  8182. return o.includes(l.name);
  8183. }).map(function (l) {
  8184. return l.url;
  8185. });
  8186. a.length && (XBillboardManager.userBubbleUrls = a), s.length && (XBillboardManager.npcBubbleUrls = s);
  8187. }
  8188. case 7:
  8189. case "end":
  8190. return _context13.stop();
  8191. }
  8192. }
  8193. }, _callee13, this);
  8194. }));
  8195. function updateBillboard() {
  8196. return _updateBillboard.apply(this, arguments);
  8197. }
  8198. return updateBillboard;
  8199. }()
  8200. }]);
  8201. return EngineProxy;
  8202. }();
  8203. 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); }; }
  8204. 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; } }
  8205. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  8206. _inherits(Xverse_Room, _EventEmitter);
  8207. var _super = _createSuper$1(Xverse_Room);
  8208. function Xverse_Room(e) {
  8209. var _this;
  8210. _classCallCheck(this, Xverse_Room);
  8211. _this = _super.call(this);
  8212. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  8213. E(_assertThisInitialized(_this), "options");
  8214. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  8215. E(_assertThisInitialized(_this), "lastSkinId");
  8216. E(_assertThisInitialized(_this), "debug");
  8217. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  8218. E(_assertThisInitialized(_this), "userId", null);
  8219. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  8220. E(_assertThisInitialized(_this), "networkController");
  8221. E(_assertThisInitialized(_this), "_startTime", Date.now());
  8222. E(_assertThisInitialized(_this), "canvas");
  8223. E(_assertThisInitialized(_this), "modelManager");
  8224. E(_assertThisInitialized(_this), "eventsController");
  8225. E(_assertThisInitialized(_this), "panorama");
  8226. E(_assertThisInitialized(_this), "engineProxy");
  8227. E(_assertThisInitialized(_this), "_id");
  8228. E(_assertThisInitialized(_this), "skinList", []);
  8229. E(_assertThisInitialized(_this), "isHost", !1);
  8230. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  8231. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  8232. E(_assertThisInitialized(_this), "sceneManager");
  8233. E(_assertThisInitialized(_this), "scene");
  8234. E(_assertThisInitialized(_this), "breathPointManager");
  8235. E(_assertThisInitialized(_this), "_currentState");
  8236. E(_assertThisInitialized(_this), "joined", !1);
  8237. E(_assertThisInitialized(_this), "disableRotate", !1);
  8238. E(_assertThisInitialized(_this), "isPano", !1);
  8239. E(_assertThisInitialized(_this), "movingByClick", !0);
  8240. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  8241. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  8242. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  8243. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  8244. E(_assertThisInitialized(_this), "_currentClickingState", null);
  8245. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  8246. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  8247. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  8248. var e, t, r, n;
  8249. return regenerator.wrap(function _callee$(_context) {
  8250. while (1) {
  8251. switch (_context.prev = _context.next) {
  8252. case 0:
  8253. logger.info("Invoke receiveRtcData");
  8254. e = !1, t = !1, r = !1, n = !1;
  8255. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  8256. return _assertThisInitialized(_this);
  8257. }, function () {
  8258. return _assertThisInitialized(_this);
  8259. })) : new Promise(function (o) {
  8260. var a = _this.networkController.rtcp.workers;
  8261. a.registerFunction("signal", function (s) {
  8262. _this.signal.handleSignal(s);
  8263. }), a.registerFunction("stream", function (s) {
  8264. var l;
  8265. if (_this.emit("streamTimestamp", {
  8266. timestamp: Date.now()
  8267. }), t || (t = !0, logger.info("Invoke stream event")), s.stream) {
  8268. r || (r = !0, logger.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  8269. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  8270. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  8271. }
  8272. e || (logger.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  8273. _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()));
  8274. }));
  8275. }), _this.panorama.bindListener(function () {
  8276. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  8277. }), a.registerFunction("reconnectedFrame", function () {}), logger.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  8278. t: 5
  8279. });
  8280. }));
  8281. case 3:
  8282. case "end":
  8283. return _context.stop();
  8284. }
  8285. }
  8286. }, _callee);
  8287. })));
  8288. E(_assertThisInitialized(_this), "moveToExtra", "");
  8289. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager$1.getInstance(e.appId, e.releaseId), _this.updateReporter();
  8290. var n = e;
  8291. n.canvas;
  8292. var r = Oe(n, ["canvas"]);
  8293. logger.infoAndReportMeasurement({
  8294. metric: "startJoinRoomAt",
  8295. startTime: Date.now(),
  8296. group: "joinRoom",
  8297. extra: r,
  8298. value: 0
  8299. });
  8300. return _this;
  8301. }
  8302. _createClass(Xverse_Room, [{
  8303. key: "currentNetworkOptions",
  8304. get: function get() {
  8305. return this._currentNetworkOptions;
  8306. }
  8307. }, {
  8308. key: "viewMode",
  8309. get: function get() {
  8310. var e;
  8311. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  8312. }
  8313. }, {
  8314. key: "id",
  8315. get: function get() {
  8316. return this._id;
  8317. }
  8318. }, {
  8319. key: "skinId",
  8320. get: function get() {
  8321. return this._currentState.skinId;
  8322. }
  8323. }, {
  8324. key: "skin",
  8325. get: function get() {
  8326. return this._currentState.skin;
  8327. }
  8328. }, {
  8329. key: "sessionId",
  8330. get: function get() {
  8331. return this.currentNetworkOptions.sessionId;
  8332. }
  8333. }, {
  8334. key: "pictureQualityLevel",
  8335. get: function get() {
  8336. return this.currentState.pictureQualityLevel;
  8337. }
  8338. }, {
  8339. key: "avatars",
  8340. get: function get() {
  8341. return Array.from(this.avatarManager.avatars.values());
  8342. }
  8343. }, {
  8344. key: "currentState",
  8345. get: function get() {
  8346. var e;
  8347. return le(oe({}, this._currentState), {
  8348. state: (e = this.networkController) == null ? void 0 : e._state
  8349. });
  8350. }
  8351. }, {
  8352. key: "_userAvatar",
  8353. get: function get() {
  8354. var _this2 = this;
  8355. return this.avatars.find(function (e) {
  8356. return e.userId === _this2.userId;
  8357. });
  8358. }
  8359. }, {
  8360. key: "tvs",
  8361. get: function get() {
  8362. return this.engineProxy._tvs;
  8363. }
  8364. }, {
  8365. key: "tv",
  8366. get: function get() {
  8367. return this.tvs[0];
  8368. }
  8369. }, {
  8370. key: "currentClickingState",
  8371. get: function get() {
  8372. return this._currentClickingState;
  8373. }
  8374. }, {
  8375. key: "afterJoinRoomHook",
  8376. value: function afterJoinRoomHook() {}
  8377. }, {
  8378. key: "beforeJoinRoomResolveHook",
  8379. value: function beforeJoinRoomResolveHook() {}
  8380. }, {
  8381. key: "afterReconnectedHook",
  8382. value: function afterReconnectedHook() {}
  8383. }, {
  8384. key: "handleSignalHook",
  8385. value: function handleSignalHook(e) {}
  8386. }, {
  8387. key: "skinChangedHook",
  8388. value: function skinChangedHook() {}
  8389. }, {
  8390. key: "beforeStartGameHook",
  8391. value: function () {
  8392. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  8393. return regenerator.wrap(function _callee2$(_context2) {
  8394. while (1) {
  8395. switch (_context2.prev = _context2.next) {
  8396. case 0:
  8397. case "end":
  8398. return _context2.stop();
  8399. }
  8400. }
  8401. }, _callee2);
  8402. }));
  8403. function beforeStartGameHook(_x) {
  8404. return _beforeStartGameHook.apply(this, arguments);
  8405. }
  8406. return beforeStartGameHook;
  8407. }()
  8408. }, {
  8409. key: "loadAssetsHook",
  8410. value: function loadAssetsHook() {}
  8411. }, {
  8412. key: "afterUserAvatarLoadedHook",
  8413. value: function afterUserAvatarLoadedHook() {}
  8414. }, {
  8415. key: "audienceViewModeHook",
  8416. value: function audienceViewModeHook() {}
  8417. }, {
  8418. key: "setViewModeToObserver",
  8419. value: function setViewModeToObserver() {}
  8420. }, {
  8421. key: "handleVehicleHook",
  8422. value: function handleVehicleHook(e) {}
  8423. }, {
  8424. key: "updateReporter",
  8425. value: function updateReporter() {
  8426. var _this$options = this.options,
  8427. e = _this$options.avatarId,
  8428. t = _this$options.skinId,
  8429. r = _this$options.userId,
  8430. n = _this$options.roomId,
  8431. o = _this$options.role,
  8432. a = _this$options.appId,
  8433. s = _this$options.wsServerUrl;
  8434. reporter$1.updateHeader({
  8435. userId: r
  8436. }), reporter$1.updateBody({
  8437. roomId: n,
  8438. role: o,
  8439. skinId: t,
  8440. avatarId: e,
  8441. appId: a,
  8442. wsServerUrl: s
  8443. });
  8444. }
  8445. }, {
  8446. key: "initRoom",
  8447. value: function () {
  8448. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  8449. var _this$options$timeout, e;
  8450. return regenerator.wrap(function _callee3$(_context3) {
  8451. while (1) {
  8452. switch (_context3.prev = _context3.next) {
  8453. case 0:
  8454. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  8455. if (!util.isSupported()) {
  8456. _context3.next = 5;
  8457. break;
  8458. }
  8459. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  8460. case 5:
  8461. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  8462. case 6:
  8463. case "end":
  8464. return _context3.stop();
  8465. }
  8466. }
  8467. }, _callee3, this);
  8468. }));
  8469. function initRoom() {
  8470. return _initRoom2.apply(this, arguments);
  8471. }
  8472. return initRoom;
  8473. }()
  8474. }, {
  8475. key: "_initRoom",
  8476. value: function () {
  8477. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  8478. 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;
  8479. return regenerator.wrap(function _callee4$(_context4) {
  8480. while (1) {
  8481. switch (_context4.prev = _context4.next) {
  8482. case 0:
  8483. e = this.validateOptions(this.options);
  8484. if (!e) {
  8485. _context4.next = 3;
  8486. break;
  8487. }
  8488. return _context4.abrupt("return", (logger.error("initRoom param error", e), Promise.reject(e)));
  8489. case 3:
  8490. _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;
  8491. this.setCurrentNetworkOptions({
  8492. avatarId: r,
  8493. skinId: n,
  8494. roomId: R,
  8495. userId: o,
  8496. wsServerUrl: a,
  8497. role: s,
  8498. token: l,
  8499. pageSession: u,
  8500. rotationRenderType: c,
  8501. isAllSync: h,
  8502. appId: f,
  8503. camera: d,
  8504. player: _,
  8505. avatarComponents: g,
  8506. nickname: m,
  8507. avatarScale: v,
  8508. firends: y,
  8509. syncByEvent: b,
  8510. areaName: T,
  8511. attitude: C,
  8512. pathName: A,
  8513. person: P,
  8514. roomTypeId: M,
  8515. hasAvatar: x,
  8516. syncToOthers: I,
  8517. prioritySync: w,
  8518. extra: D,
  8519. removeWhenDisconnected: O
  8520. });
  8521. this.userId = o;
  8522. this.canvas = t;
  8523. T && (this.pathManager.currentArea = T);
  8524. this.networkController = new NetworkController(this);
  8525. this.setCurrentState({
  8526. areaName: T,
  8527. pathName: A,
  8528. attitude: C,
  8529. speed: 0,
  8530. viewMode: S,
  8531. state: this.networkController._state,
  8532. skinId: n
  8533. });
  8534. _context4.prev = 10;
  8535. _context4.next = 13;
  8536. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  8537. case 13:
  8538. logger.info("network config wasm all ready, start to create game");
  8539. _context4.next = 16;
  8540. return this.requestCreateRoom({
  8541. skinId: n
  8542. });
  8543. case 16:
  8544. F = _context4.sent;
  8545. V = F.routeList.find(function (L) {
  8546. return L.areaName === T;
  8547. });
  8548. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  8549. this.updateCurrentState({
  8550. skin: F,
  8551. skinId: F.id,
  8552. versionId: F.versionId,
  8553. speed: N
  8554. });
  8555. _context4.next = 22;
  8556. return this.initEngine(F);
  8557. case 22:
  8558. _context4.next = 27;
  8559. break;
  8560. case 24:
  8561. _context4.prev = 24;
  8562. _context4.t0 = _context4["catch"](10);
  8563. return _context4.abrupt("return", Promise.reject(_context4.t0));
  8564. case 27:
  8565. return _context4.abrupt("return", (this.beforeJoinRoomResolve(), this.receiveRtcData()));
  8566. case 28:
  8567. case "end":
  8568. return _context4.stop();
  8569. }
  8570. }
  8571. }, _callee4, this, [[10, 24]]);
  8572. }));
  8573. function _initRoom() {
  8574. return _initRoom3.apply(this, arguments);
  8575. }
  8576. return _initRoom;
  8577. }()
  8578. }, {
  8579. key: "beforeJoinRoomResolve",
  8580. value: function beforeJoinRoomResolve() {
  8581. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  8582. }
  8583. }, {
  8584. key: "afterJoinRoom",
  8585. value: function afterJoinRoom() {
  8586. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger.infoAndReportMeasurement({
  8587. tag: this.viewMode,
  8588. value: this.firstFrameTimestamp - this._startTime,
  8589. startTime: Date.now(),
  8590. metric: "joinRoom"
  8591. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  8592. var e = _ref2.stats;
  8593. reporter$1.report("stats", oe({}, e));
  8594. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  8595. }
  8596. }, {
  8597. key: "afterReconnected",
  8598. value: function afterReconnected() {
  8599. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  8600. }
  8601. }, {
  8602. key: "leave",
  8603. value: function leave() {
  8604. var e, t;
  8605. return logger.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  8606. }
  8607. }, {
  8608. key: "validateOptions",
  8609. value: function validateOptions(e) {
  8610. var _ref3 = e || {},
  8611. t = _ref3.canvas,
  8612. r = _ref3.avatarId,
  8613. n = _ref3.skinId,
  8614. o = _ref3.userId,
  8615. a = _ref3.role;
  8616. _ref3.roomId;
  8617. var l = _ref3.token,
  8618. u = _ref3.appId;
  8619. _ref3.avatarComponents;
  8620. var h = [];
  8621. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  8622. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  8623. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  8624. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  8625. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  8626. return h[0];
  8627. }
  8628. }, {
  8629. key: "initNetwork",
  8630. value: function () {
  8631. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  8632. var e;
  8633. return regenerator.wrap(function _callee5$(_context5) {
  8634. while (1) {
  8635. switch (_context5.prev = _context5.next) {
  8636. case 0:
  8637. if (!(this.viewMode === "serverless")) {
  8638. _context5.next = 2;
  8639. break;
  8640. }
  8641. return _context5.abrupt("return", Promise.resolve());
  8642. case 2:
  8643. e = Date.now();
  8644. _context5.prev = 3;
  8645. _context5.next = 6;
  8646. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  8647. case 6:
  8648. logger.infoAndReportMeasurement({
  8649. metric: "networkInitAt",
  8650. startTime: this._startTime,
  8651. group: "joinRoom"
  8652. });
  8653. logger.infoAndReportMeasurement({
  8654. metric: "networkInitCost",
  8655. startTime: e,
  8656. group: "joinRoom"
  8657. });
  8658. _context5.next = 13;
  8659. break;
  8660. case 10:
  8661. _context5.prev = 10;
  8662. _context5.t0 = _context5["catch"](3);
  8663. throw logger.infoAndReportMeasurement({
  8664. metric: "networkInitAt",
  8665. startTime: e,
  8666. group: "joinRoom",
  8667. error: _context5.t0
  8668. }), _context5.t0;
  8669. case 13:
  8670. case "end":
  8671. return _context5.stop();
  8672. }
  8673. }
  8674. }, _callee5, this, [[3, 10]]);
  8675. }));
  8676. function initNetwork() {
  8677. return _initNetwork.apply(this, arguments);
  8678. }
  8679. return initNetwork;
  8680. }()
  8681. }, {
  8682. key: "initConfig",
  8683. value: function () {
  8684. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  8685. var e;
  8686. return regenerator.wrap(function _callee6$(_context6) {
  8687. while (1) {
  8688. switch (_context6.prev = _context6.next) {
  8689. case 0:
  8690. e = Date.now();
  8691. _context6.prev = 1;
  8692. _context6.next = 4;
  8693. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  8694. case 4:
  8695. logger.infoAndReportMeasurement({
  8696. metric: "configInitAt",
  8697. startTime: this._startTime,
  8698. group: "joinRoom"
  8699. });
  8700. logger.infoAndReportMeasurement({
  8701. metric: "configInitCost",
  8702. startTime: e,
  8703. group: "joinRoom"
  8704. });
  8705. _context6.next = 11;
  8706. break;
  8707. case 8:
  8708. _context6.prev = 8;
  8709. _context6.t0 = _context6["catch"](1);
  8710. throw logger.infoAndReportMeasurement({
  8711. metric: "configInitAt",
  8712. startTime: e,
  8713. group: "joinRoom",
  8714. error: _context6.t0
  8715. }), _context6.t0;
  8716. case 11:
  8717. case "end":
  8718. return _context6.stop();
  8719. }
  8720. }
  8721. }, _callee6, this, [[1, 8]]);
  8722. }));
  8723. function initConfig() {
  8724. return _initConfig.apply(this, arguments);
  8725. }
  8726. return initConfig;
  8727. }()
  8728. }, {
  8729. key: "initEngine",
  8730. value: function () {
  8731. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  8732. var t, n;
  8733. return regenerator.wrap(function _callee7$(_context7) {
  8734. while (1) {
  8735. switch (_context7.prev = _context7.next) {
  8736. case 0:
  8737. t = Date.now();
  8738. _context7.prev = 1;
  8739. this.engineProxy = new EngineProxy(this);
  8740. _context7.next = 5;
  8741. return this.engineProxy.initEngine(e);
  8742. case 5:
  8743. logger.infoAndReportMeasurement({
  8744. metric: "webglInitAt",
  8745. startTime: this._startTime,
  8746. group: "joinRoom"
  8747. });
  8748. logger.infoAndReportMeasurement({
  8749. metric: "webglInitCost",
  8750. startTime: t,
  8751. group: "joinRoom"
  8752. });
  8753. return _context7.abrupt("return");
  8754. case 10:
  8755. _context7.prev = 10;
  8756. _context7.t0 = _context7["catch"](1);
  8757. n = _context7.t0;
  8758. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger.error(_context7.t0), logger.infoAndReportMeasurement({
  8759. metric: "webglInitAt",
  8760. startTime: t,
  8761. group: "joinRoom",
  8762. error: n
  8763. }), Promise.reject(n)));
  8764. case 14:
  8765. case "end":
  8766. return _context7.stop();
  8767. }
  8768. }
  8769. }, _callee7, this, [[1, 10]]);
  8770. }));
  8771. function initEngine(_x2) {
  8772. return _initEngine.apply(this, arguments);
  8773. }
  8774. return initEngine;
  8775. }()
  8776. }, {
  8777. key: "initWasm",
  8778. value: function () {
  8779. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  8780. var _this3 = this;
  8781. var e;
  8782. return regenerator.wrap(function _callee8$(_context8) {
  8783. while (1) {
  8784. switch (_context8.prev = _context8.next) {
  8785. case 0:
  8786. if (!(this.viewMode === "serverless")) {
  8787. _context8.next = 2;
  8788. break;
  8789. }
  8790. return _context8.abrupt("return", Promise.resolve());
  8791. case 2:
  8792. e = Date.now();
  8793. _context8.prev = 3;
  8794. _context8.next = 6;
  8795. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  8796. case 6:
  8797. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  8798. logger.error("decode error", t);
  8799. var r = t.code,
  8800. n = t.message;
  8801. _this3.emit("error", {
  8802. code: r,
  8803. msg: n
  8804. });
  8805. });
  8806. logger.infoAndReportMeasurement({
  8807. metric: "wasmInitAt",
  8808. group: "joinRoom",
  8809. startTime: this._startTime
  8810. });
  8811. logger.infoAndReportMeasurement({
  8812. metric: "wasmInitCost",
  8813. group: "joinRoom",
  8814. startTime: e
  8815. });
  8816. eventsManager.on("traceId", function (t) {
  8817. _this3.networkController.rtcp.workers.onTraceId(t);
  8818. });
  8819. _context8.next = 15;
  8820. break;
  8821. case 12:
  8822. _context8.prev = 12;
  8823. _context8.t0 = _context8["catch"](3);
  8824. throw logger.infoAndReportMeasurement({
  8825. metric: "wasmInitAt",
  8826. group: "joinRoom",
  8827. startTime: e,
  8828. error: _context8.t0
  8829. }), _context8.t0;
  8830. case 15:
  8831. case "end":
  8832. return _context8.stop();
  8833. }
  8834. }
  8835. }, _callee8, this, [[3, 12]]);
  8836. }));
  8837. function initWasm() {
  8838. return _initWasm.apply(this, arguments);
  8839. }
  8840. return initWasm;
  8841. }()
  8842. }, {
  8843. key: "requestCreateRoom",
  8844. value: function () {
  8845. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  8846. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  8847. return regenerator.wrap(function _callee9$(_context9) {
  8848. while (1) {
  8849. switch (_context9.prev = _context9.next) {
  8850. case 0:
  8851. e = _ref4.skinId;
  8852. if (!e) {
  8853. _context9.next = 11;
  8854. break;
  8855. }
  8856. _context9.next = 4;
  8857. return this.getSkin(e);
  8858. case 4:
  8859. t = _context9.sent;
  8860. _context9.next = 7;
  8861. return this.modelManager.findRoute(e, this.options.pathName);
  8862. case 7:
  8863. r = _context9.sent;
  8864. this.updateCurrentNetworkOptions({
  8865. areaName: r.areaName,
  8866. attitude: r.attitude,
  8867. versionId: t.versionId
  8868. });
  8869. _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  8870. this.options.camera || this.updateCurrentNetworkOptions({
  8871. camera: n
  8872. }), this.options.player || this.updateCurrentNetworkOptions({
  8873. player: o
  8874. });
  8875. case 11:
  8876. if (!(this.viewMode === "serverless")) {
  8877. _context9.next = 13;
  8878. break;
  8879. }
  8880. return _context9.abrupt("return", t);
  8881. case 13:
  8882. _context9.prev = 13;
  8883. _context9.next = 16;
  8884. return this.beforeStartGameHook(this.options);
  8885. case 16:
  8886. _context9.next = 18;
  8887. return this.networkController.startGame();
  8888. case 18:
  8889. _yield$this$networkCo = _context9.sent;
  8890. _r = _yield$this$networkCo.room_id;
  8891. _n = _yield$this$networkCo.data;
  8892. _o = _yield$this$networkCo.session_id;
  8893. this._id = _r;
  8894. a = JSON.parse(_n);
  8895. this.isHost = a.IsHost, e = a.SkinID || e;
  8896. _context9.next = 27;
  8897. return this.getSkin(e);
  8898. case 27:
  8899. s = _context9.sent;
  8900. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  8901. roomId: _r,
  8902. sessionId: _o
  8903. }), reporter$1.updateBody({
  8904. roomId: _r,
  8905. skinId: e,
  8906. serverSession: _o
  8907. }), s));
  8908. case 31:
  8909. _context9.prev = 31;
  8910. _context9.t0 = _context9["catch"](13);
  8911. throw logger.error("Request create room error", _context9.t0), _context9.t0;
  8912. case 34:
  8913. case "end":
  8914. return _context9.stop();
  8915. }
  8916. }
  8917. }, _callee9, this, [[13, 31]]);
  8918. }));
  8919. function requestCreateRoom(_x3) {
  8920. return _requestCreateRoom.apply(this, arguments);
  8921. }
  8922. return requestCreateRoom;
  8923. }()
  8924. }, {
  8925. key: "pause",
  8926. value: function pause() {
  8927. return this.engineProxy.pause();
  8928. }
  8929. }, {
  8930. key: "resume",
  8931. value: function resume() {
  8932. return this.engineProxy.resume();
  8933. }
  8934. }, {
  8935. key: "reconnect",
  8936. value: function reconnect() {
  8937. this.networkController.reconnect();
  8938. }
  8939. }, {
  8940. key: "setViewMode",
  8941. value: function () {
  8942. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  8943. return regenerator.wrap(function _callee10$(_context10) {
  8944. while (1) {
  8945. switch (_context10.prev = _context10.next) {
  8946. case 0:
  8947. case "end":
  8948. return _context10.stop();
  8949. }
  8950. }
  8951. }, _callee10);
  8952. }));
  8953. function setViewMode(_x4) {
  8954. return _setViewMode.apply(this, arguments);
  8955. }
  8956. return setViewMode;
  8957. }()
  8958. }, {
  8959. key: "handleRepetLogin",
  8960. value: function handleRepetLogin() {
  8961. logger.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  8962. }
  8963. }, {
  8964. key: "setPictureQualityLevel",
  8965. value: function setPictureQualityLevel(e) {
  8966. var t = {
  8967. high: EImageQuality.high,
  8968. low: EImageQuality.low,
  8969. average: EImageQuality.mid
  8970. };
  8971. return this.updateCurrentState({
  8972. pictureQualityLevel: e
  8973. }), this.sceneManager.setImageQuality(t[e]);
  8974. }
  8975. }, {
  8976. key: "getSkin",
  8977. value: function () {
  8978. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  8979. var t, n;
  8980. return regenerator.wrap(function _callee11$(_context11) {
  8981. while (1) {
  8982. switch (_context11.prev = _context11.next) {
  8983. case 0:
  8984. t = null;
  8985. _context11.next = 3;
  8986. return this.modelManager.getSkinsList();
  8987. case 3:
  8988. t = (this.skinList = _context11.sent).find(function (n) {
  8989. return n.id === e || n.id === e;
  8990. });
  8991. if (!t) {
  8992. _context11.next = 6;
  8993. break;
  8994. }
  8995. return _context11.abrupt("return", t);
  8996. case 6:
  8997. n = "skin is invalid: skinId: ".concat(e);
  8998. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  8999. case 8:
  9000. case "end":
  9001. return _context11.stop();
  9002. }
  9003. }
  9004. }, _callee11, this);
  9005. }));
  9006. function getSkin(_x5) {
  9007. return _getSkin.apply(this, arguments);
  9008. }
  9009. return getSkin;
  9010. }()
  9011. }, {
  9012. key: "setupStats",
  9013. value: function setupStats() {
  9014. this.stats.assign({
  9015. roomId: this.id,
  9016. userId: this.userId
  9017. }), setInterval(this.engineProxy.updateStats, 1e3);
  9018. }
  9019. }, {
  9020. key: "proxyEvents",
  9021. value: function proxyEvents(e, t) {
  9022. this.emit(e, t);
  9023. }
  9024. }, {
  9025. key: "setCurrentNetworkOptions",
  9026. value: function setCurrentNetworkOptions(e) {
  9027. this._currentNetworkOptions = e;
  9028. }
  9029. }, {
  9030. key: "updateCurrentNetworkOptions",
  9031. value: function updateCurrentNetworkOptions(e) {
  9032. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  9033. }
  9034. }, {
  9035. key: "setCurrentState",
  9036. value: function setCurrentState(e) {
  9037. this._currentState = e;
  9038. }
  9039. }, {
  9040. key: "updateCurrentState",
  9041. value: function updateCurrentState(e) {
  9042. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  9043. skinId: e.skinId
  9044. })), e.versionId && this.updateCurrentNetworkOptions({
  9045. versionId: e.versionId
  9046. }), Object.assign(this._currentState, e);
  9047. }
  9048. }]);
  9049. return Xverse_Room;
  9050. }(EventEmitter);
  9051. 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); }; }
  9052. 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; } }
  9053. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  9054. _inherits(XverseRoom, _Xverse_Room);
  9055. var _super = _createSuper(XverseRoom);
  9056. function XverseRoom(e) {
  9057. var _this;
  9058. _classCallCheck(this, XverseRoom);
  9059. _this = _super.call(this, e);
  9060. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  9061. return _this;
  9062. }
  9063. _createClass(XverseRoom, [{
  9064. key: "afterJoinRoomHook",
  9065. value: function afterJoinRoomHook() {
  9066. this.joyStick.init({});
  9067. }
  9068. }]);
  9069. return XverseRoom;
  9070. }(Xverse_Room);
  9071. var Preload = /*#__PURE__*/function () {
  9072. function Preload(e) {
  9073. _classCallCheck(this, Preload);
  9074. this.config = null;
  9075. this.allKeys = [];
  9076. this.oldResourcesDeleted = !1;
  9077. this.requests = {
  9078. simple: {
  9079. stopped: !0,
  9080. requests: {}
  9081. },
  9082. observer: {
  9083. stopped: !0,
  9084. requests: {}
  9085. },
  9086. full: {
  9087. stopped: !0,
  9088. requests: {}
  9089. }
  9090. };
  9091. this.modelManager = e, this.init(e.appId);
  9092. }
  9093. _createClass(Preload, [{
  9094. key: "init",
  9095. value: function init(e) {
  9096. reporter$1.updateBody({
  9097. appId: e
  9098. });
  9099. }
  9100. }, {
  9101. key: "getConfig",
  9102. value: function () {
  9103. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  9104. var _yield$this$modelMana, t;
  9105. return regenerator.wrap(function _callee$(_context) {
  9106. while (1) {
  9107. switch (_context.prev = _context.next) {
  9108. case 0:
  9109. if (!this.config) {
  9110. _context.next = 2;
  9111. break;
  9112. }
  9113. return _context.abrupt("return", this.config);
  9114. case 2:
  9115. _context.next = 4;
  9116. return this.modelManager.requestConfig();
  9117. case 4:
  9118. _yield$this$modelMana = _context.sent;
  9119. t = _yield$this$modelMana.preload;
  9120. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  9121. case 7:
  9122. case "end":
  9123. return _context.stop();
  9124. }
  9125. }
  9126. }, _callee, this);
  9127. }));
  9128. function getConfig(_x) {
  9129. return _getConfig.apply(this, arguments);
  9130. }
  9131. return getConfig;
  9132. }()
  9133. }, {
  9134. key: "getAllKeys",
  9135. value: function () {
  9136. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  9137. var e, t;
  9138. return regenerator.wrap(function _callee2$(_context2) {
  9139. while (1) {
  9140. switch (_context2.prev = _context2.next) {
  9141. case 0:
  9142. if (!this.allKeys.length) {
  9143. _context2.next = 2;
  9144. break;
  9145. }
  9146. return _context2.abrupt("return", this.allKeys);
  9147. case 2:
  9148. _context2.prev = 2;
  9149. _context2.next = 5;
  9150. return modelTable.getAllKeys();
  9151. case 5:
  9152. e = _context2.sent;
  9153. this.allKeys = e;
  9154. return _context2.abrupt("return", e);
  9155. case 10:
  9156. _context2.prev = 10;
  9157. _context2.t0 = _context2["catch"](2);
  9158. t = "preload getAllKeys error";
  9159. return _context2.abrupt("return", (logger.error(t), Promise.reject(t)));
  9160. case 14:
  9161. case "end":
  9162. return _context2.stop();
  9163. }
  9164. }
  9165. }, _callee2, this, [[2, 10]]);
  9166. }));
  9167. function getAllKeys() {
  9168. return _getAllKeys.apply(this, arguments);
  9169. }
  9170. return getAllKeys;
  9171. }()
  9172. }, {
  9173. key: "stop",
  9174. value: function stop(e) {
  9175. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  9176. var t = this.requests[e].requests;
  9177. Object.keys(t).forEach(function (r) {
  9178. http1.canceler.removePending(r), delete t[r];
  9179. });
  9180. }
  9181. }, {
  9182. key: "clearPreload",
  9183. value: function clearPreload(e) {
  9184. this.requests[e].stopped = !1, this.allKeys = [];
  9185. }
  9186. }, {
  9187. key: "start",
  9188. value: function () {
  9189. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  9190. var n, o, a, s, l, u, h, f, _s;
  9191. return regenerator.wrap(function _callee3$(_context3) {
  9192. while (1) {
  9193. switch (_context3.prev = _context3.next) {
  9194. case 0:
  9195. n = Date.now(), o = 0;
  9196. _context3.prev = 1;
  9197. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  9198. _context3.next = 4;
  9199. break;
  9200. }
  9201. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  9202. case 4:
  9203. this.clearPreload(e);
  9204. _context3.next = 7;
  9205. return this.getConfig(e);
  9206. case 7:
  9207. a = _context3.sent;
  9208. _context3.next = 10;
  9209. return this.getAllKeys();
  9210. case 10:
  9211. s = _context3.sent;
  9212. _context3.prev = 11;
  9213. _context3.next = 14;
  9214. return this.deleteOldResources(a.assetUrls.map(function (d) {
  9215. return d.url;
  9216. }), s);
  9217. case 14:
  9218. _context3.next = 19;
  9219. break;
  9220. case 16:
  9221. _context3.prev = 16;
  9222. _context3.t0 = _context3["catch"](11);
  9223. logger.error(_context3.t0);
  9224. case 19:
  9225. l = a.baseUrls, u = a.assetUrls;
  9226. _context3.t1 = e;
  9227. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  9228. break;
  9229. case 23:
  9230. h = l;
  9231. return _context3.abrupt("break", 30);
  9232. case 25:
  9233. h = u;
  9234. return _context3.abrupt("break", 30);
  9235. case 27:
  9236. h = u;
  9237. return _context3.abrupt("break", 30);
  9238. case 29:
  9239. h = u;
  9240. case 30:
  9241. f = h.filter(function (d) {
  9242. return !s.includes(d.url);
  9243. });
  9244. r && isFunction(r) && (f = f.filter(r));
  9245. o = f.length;
  9246. logger.debug("keysNeedToPreload", f);
  9247. f.length || t && t(h.length, h.length);
  9248. n = Date.now();
  9249. _context3.next = 38;
  9250. return this._preload(e, f, t);
  9251. case 38:
  9252. logger.infoAndReportMeasurement({
  9253. tag: e,
  9254. startTime: n,
  9255. metric: "assetsPreload",
  9256. extra: {
  9257. total: o
  9258. }
  9259. });
  9260. return _context3.abrupt("return");
  9261. case 42:
  9262. _context3.prev = 42;
  9263. _context3.t2 = _context3["catch"](1);
  9264. _s = _context3.t2;
  9265. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger.infoAndReportMeasurement({
  9266. tag: e,
  9267. startTime: n,
  9268. metric: "assetsPreload",
  9269. extra: {
  9270. total: o
  9271. },
  9272. error: _s,
  9273. reportOptions: {
  9274. immediate: !0
  9275. }
  9276. }), Promise.reject(_s)));
  9277. case 46:
  9278. case "end":
  9279. return _context3.stop();
  9280. }
  9281. }
  9282. }, _callee3, this, [[1, 42], [11, 16]]);
  9283. }));
  9284. function start(_x2, _x3, _x4) {
  9285. return _start.apply(this, arguments);
  9286. }
  9287. return start;
  9288. }()
  9289. }, {
  9290. key: "deleteOldResources",
  9291. value: function deleteOldResources(e, t) {
  9292. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  9293. var r = t.filter(function (n) {
  9294. return !e.includes(n);
  9295. });
  9296. return logger.debug("keysNeedToDelete", r), logger.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  9297. return modelTable.delete(n);
  9298. }));
  9299. }
  9300. }, {
  9301. key: "_preload",
  9302. value: function () {
  9303. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  9304. var _this = this;
  9305. var n, o, a;
  9306. return regenerator.wrap(function _callee6$(_context6) {
  9307. while (1) {
  9308. switch (_context6.prev = _context6.next) {
  9309. case 0:
  9310. n = t.length;
  9311. if (n) {
  9312. _context6.next = 3;
  9313. break;
  9314. }
  9315. return _context6.abrupt("return", Promise.resolve());
  9316. case 3:
  9317. o = 0;
  9318. a = window.setInterval(function () {
  9319. r && r(o, n), o >= n && window.clearInterval(a);
  9320. }, 1e3);
  9321. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  9322. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  9323. var l, u;
  9324. return regenerator.wrap(function _callee5$(_context5) {
  9325. while (1) {
  9326. switch (_context5.prev = _context5.next) {
  9327. case 0:
  9328. l = s.size, u = s.url;
  9329. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  9330. url: u,
  9331. timeout: Preload.getTimeoutBySize(l),
  9332. responseType: "blob",
  9333. retry: 2,
  9334. beforeRequest: function beforeRequest() {
  9335. _this.requests[e].requests[u] = !0;
  9336. }
  9337. }).then( /*#__PURE__*/function () {
  9338. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  9339. var h, f;
  9340. return regenerator.wrap(function _callee4$(_context4) {
  9341. while (1) {
  9342. switch (_context4.prev = _context4.next) {
  9343. case 0:
  9344. h = c.data;
  9345. if (h instanceof Blob) {
  9346. _context4.next = 3;
  9347. break;
  9348. }
  9349. return _context4.abrupt("return", (logger.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  9350. case 3:
  9351. _context4.next = 5;
  9352. return blobToDataURI(h);
  9353. case 5:
  9354. f = _context4.sent;
  9355. _context4.prev = 6;
  9356. _context4.next = 9;
  9357. return modelTable.put({
  9358. url: u,
  9359. model: f
  9360. });
  9361. case 9:
  9362. return _context4.abrupt("return");
  9363. case 12:
  9364. _context4.prev = 12;
  9365. _context4.t0 = _context4["catch"](6);
  9366. return _context4.abrupt("return", (logger.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  9367. case 15:
  9368. case "end":
  9369. return _context4.stop();
  9370. }
  9371. }
  9372. }, _callee4, null, [[6, 12]]);
  9373. }));
  9374. return function (_x9) {
  9375. return _ref2.apply(this, arguments);
  9376. };
  9377. }()).then(function () {
  9378. o++, delete _this.requests[e].requests[u];
  9379. }, function (c) {
  9380. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  9381. }));
  9382. case 2:
  9383. case "end":
  9384. return _context5.stop();
  9385. }
  9386. }
  9387. }, _callee5);
  9388. }));
  9389. return function (_x8) {
  9390. return _ref.apply(this, arguments);
  9391. };
  9392. }()));
  9393. case 6:
  9394. case "end":
  9395. return _context6.stop();
  9396. }
  9397. }
  9398. }, _callee6);
  9399. }));
  9400. function _preload(_x5, _x6, _x7) {
  9401. return _preload2.apply(this, arguments);
  9402. }
  9403. return _preload;
  9404. }()
  9405. }], [{
  9406. key: "getTimeoutBySize",
  9407. value: function getTimeoutBySize(e) {
  9408. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  9409. }
  9410. }]);
  9411. return Preload;
  9412. }();
  9413. var RenderType$1 = {
  9414. PathVideo: 0,
  9415. RotationVideo: 1,
  9416. RotationImage: 2,
  9417. PanoramaImage: 3,
  9418. CGVideo: 4,
  9419. ClientRotationPano: 5,
  9420. CloudRotationPano: 6
  9421. };
  9422. var Xverse = /*#__PURE__*/function () {
  9423. function Xverse(e) {
  9424. _classCallCheck(this, Xverse);
  9425. e || (e = {});
  9426. var _e = e,
  9427. t = _e.onLog,
  9428. r = _e.env,
  9429. n = _e.appId,
  9430. o = _e.releaseId,
  9431. a = _e.subPackageVersion;
  9432. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger.setLevel(LoggerLevels.Debug);
  9433. var s = this.pageSession = util.uuid();
  9434. reporter$1.updateHeader({
  9435. pageSession: s
  9436. });
  9437. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  9438. a && reporter$1.updateBody({
  9439. sdkVersion: a
  9440. });
  9441. logger.infoAndReportMeasurement({
  9442. metric: "sdkInit",
  9443. startTime: Date.now(),
  9444. extra: {
  9445. version: a,
  9446. enviroment: r,
  9447. pageSession: s
  9448. }
  9449. });
  9450. logger.debug("debug mode:", this.debug);
  9451. reporter$1.on("report", function (l) {
  9452. t && t(l);
  9453. });
  9454. if (n) {
  9455. this.appId = n, this.releaseId = o;
  9456. var l = ModelManager$1.getInstance(n, o);
  9457. this.preload = new Preload(l);
  9458. }
  9459. }
  9460. _createClass(Xverse, [{
  9461. key: "isSupported",
  9462. get: function get() {
  9463. return isSupported();
  9464. }
  9465. }, {
  9466. key: "disableLogUpload",
  9467. value: function disableLogUpload() {
  9468. reporter$1.disable(), logger.debug("logger upload has been disabled");
  9469. }
  9470. }, {
  9471. key: "getSkinList",
  9472. value: function () {
  9473. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  9474. return regenerator.wrap(function _callee$(_context) {
  9475. while (1) {
  9476. switch (_context.prev = _context.next) {
  9477. case 0:
  9478. return _context.abrupt("return", []);
  9479. case 1:
  9480. case "end":
  9481. return _context.stop();
  9482. }
  9483. }
  9484. }, _callee);
  9485. }));
  9486. function getSkinList() {
  9487. return _getSkinList.apply(this, arguments);
  9488. }
  9489. return getSkinList;
  9490. }()
  9491. }, {
  9492. key: "getAvatarList",
  9493. value: function () {
  9494. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  9495. return regenerator.wrap(function _callee2$(_context2) {
  9496. while (1) {
  9497. switch (_context2.prev = _context2.next) {
  9498. case 0:
  9499. return _context2.abrupt("return", []);
  9500. case 1:
  9501. case "end":
  9502. return _context2.stop();
  9503. }
  9504. }
  9505. }, _callee2);
  9506. }));
  9507. function getAvatarList() {
  9508. return _getAvatarList.apply(this, arguments);
  9509. }
  9510. return getAvatarList;
  9511. }()
  9512. }, {
  9513. key: "getGiftList",
  9514. value: function () {
  9515. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  9516. return regenerator.wrap(function _callee3$(_context3) {
  9517. while (1) {
  9518. switch (_context3.prev = _context3.next) {
  9519. case 0:
  9520. return _context3.abrupt("return", [{
  9521. id: "hack "
  9522. }]);
  9523. case 1:
  9524. case "end":
  9525. return _context3.stop();
  9526. }
  9527. }
  9528. }, _callee3);
  9529. }));
  9530. function getGiftList() {
  9531. return _getGiftList.apply(this, arguments);
  9532. }
  9533. return getGiftList;
  9534. }()
  9535. }, {
  9536. key: "joinRoom",
  9537. value: function () {
  9538. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  9539. var t, r, n, o;
  9540. return regenerator.wrap(function _callee4$(_context4) {
  9541. while (1) {
  9542. switch (_context4.prev = _context4.next) {
  9543. case 0:
  9544. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
  9545. appId: e.appId || this.appId,
  9546. releaseId: e.releaseId || this.releaseId,
  9547. pageSession: this.pageSession,
  9548. isAllSync: !0,
  9549. rotationRenderType: r,
  9550. syncByEvent: !0,
  9551. pathName: t,
  9552. person: n,
  9553. role: e.role || "audience"
  9554. }));
  9555. return _context4.abrupt("return", o.initRoom().then(function () {
  9556. return o;
  9557. }));
  9558. case 2:
  9559. case "end":
  9560. return _context4.stop();
  9561. }
  9562. }
  9563. }, _callee4, this);
  9564. }));
  9565. function joinRoom(_x) {
  9566. return _joinRoom.apply(this, arguments);
  9567. }
  9568. return joinRoom;
  9569. }()
  9570. }]);
  9571. return Xverse;
  9572. }();
  9573. var xverse = new Xverse({
  9574. env: "DEV",
  9575. appId: "10016",
  9576. releaseId: '2203120033_29769e'
  9577. });
  9578. var l = /*#__PURE__*/function () {
  9579. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  9580. var R;
  9581. return regenerator.wrap(function _callee$(_context) {
  9582. while (1) {
  9583. switch (_context.prev = _context.next) {
  9584. case 0:
  9585. _context.prev = 0;
  9586. _context.next = 3;
  9587. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  9588. });
  9589. case 3:
  9590. _context.next = 12;
  9591. break;
  9592. case 5:
  9593. _context.prev = 5;
  9594. _context.t0 = _context["catch"](0);
  9595. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  9596. _context.next = 10;
  9597. break;
  9598. }
  9599. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  9600. return _context.abrupt("return");
  9601. case 10:
  9602. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  9603. return _context.abrupt("return");
  9604. case 12:
  9605. _context.prev = 12;
  9606. _context.next = 15;
  9607. return xverse.joinRoom({
  9608. canvas: document.getElementById('canvas'),
  9609. skinId: '10092',
  9610. avatarId: 'KGe_Boy',
  9611. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  9612. userId: '1f7acca1db9d5',
  9613. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  9614. appId: "10016",
  9615. token: " ",
  9616. nickname: '1f7acca1db9d5',
  9617. firends: ["user1"],
  9618. viewMode: "full",
  9619. resolution: {
  9620. width: 1728,
  9621. height: 720
  9622. },
  9623. pathName: 'thirdwalk',
  9624. objectFit: null,
  9625. hasAvatar: !0,
  9626. syncToOthers: !0
  9627. });
  9628. case 15:
  9629. room = _context.sent;
  9630. debugger;
  9631. u();
  9632. c();
  9633. window.room = room;
  9634. e(!1);
  9635. _context.next = 28;
  9636. break;
  9637. case 23:
  9638. _context.prev = 23;
  9639. _context.t1 = _context["catch"](12);
  9640. console.error(_context.t1);
  9641. alert(_context.t1);
  9642. return _context.abrupt("return");
  9643. case 28:
  9644. case "end":
  9645. return _context.stop();
  9646. }
  9647. }
  9648. }, _callee, null, [[0, 5], [12, 23]]);
  9649. }));
  9650. return function l() {
  9651. return _ref.apply(this, arguments);
  9652. };
  9653. }();
  9654. var u = function u() {
  9655. room.on("_coreClick", function (_ref2) {
  9656. var f = _ref2.point;
  9657. room._userAvatar.moveTo({
  9658. point: f
  9659. });
  9660. });
  9661. };
  9662. var c = function c() {
  9663. room.on("repeatLogin", function () {
  9664. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  9665. duration: 1e4
  9666. });
  9667. }), room.on("reconnecting", function (_ref3) {
  9668. var f = _ref3.count;
  9669. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  9670. }), room.on("reconnected", function () {
  9671. toast("\u91CD\u8FDE\u6210\u529F");
  9672. }), room.on("disconnected", function () {
  9673. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  9674. duration: 1e5,
  9675. onClick() {
  9676. f.hideToast(), room.reconnect();
  9677. }
  9678. });
  9679. });
  9680. };
  9681. l();
  9682. }));
  9683. //# sourceMappingURL=index.js.map