runtime-dom.esm-browser.js 397 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944
  1. /**
  2. * Make a map and return a function for checking if a key
  3. * is in that map.
  4. * IMPORTANT: all calls of this function must be prefixed with
  5. * \/\*#\_\_PURE\_\_\*\/
  6. * So that rollup can tree-shake them if necessary.
  7. */
  8. function makeMap(str, expectsLowerCase) {
  9. const map = Object.create(null);
  10. const list = str.split(',');
  11. for (let i = 0; i < list.length; i++) {
  12. map[list[i]] = true;
  13. }
  14. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  15. }
  16. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  17. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  18. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  19. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  20. function normalizeStyle(value) {
  21. if (isArray(value)) {
  22. const res = {};
  23. for (let i = 0; i < value.length; i++) {
  24. const item = value[i];
  25. const normalized = isString(item)
  26. ? parseStringStyle(item)
  27. : normalizeStyle(item);
  28. if (normalized) {
  29. for (const key in normalized) {
  30. res[key] = normalized[key];
  31. }
  32. }
  33. }
  34. return res;
  35. }
  36. else if (isString(value)) {
  37. return value;
  38. }
  39. else if (isObject(value)) {
  40. return value;
  41. }
  42. }
  43. const listDelimiterRE = /;(?![^(]*\))/g;
  44. const propertyDelimiterRE = /:([^]+)/;
  45. const styleCommentRE = /\/\*.*?\*\//gs;
  46. function parseStringStyle(cssText) {
  47. const ret = {};
  48. cssText
  49. .replace(styleCommentRE, '')
  50. .split(listDelimiterRE)
  51. .forEach(item => {
  52. if (item) {
  53. const tmp = item.split(propertyDelimiterRE);
  54. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  55. }
  56. });
  57. return ret;
  58. }
  59. function normalizeClass(value) {
  60. let res = '';
  61. if (isString(value)) {
  62. res = value;
  63. }
  64. else if (isArray(value)) {
  65. for (let i = 0; i < value.length; i++) {
  66. const normalized = normalizeClass(value[i]);
  67. if (normalized) {
  68. res += normalized + ' ';
  69. }
  70. }
  71. }
  72. else if (isObject(value)) {
  73. for (const name in value) {
  74. if (value[name]) {
  75. res += name + ' ';
  76. }
  77. }
  78. }
  79. return res.trim();
  80. }
  81. function normalizeProps(props) {
  82. if (!props)
  83. return null;
  84. let { class: klass, style } = props;
  85. if (klass && !isString(klass)) {
  86. props.class = normalizeClass(klass);
  87. }
  88. if (style) {
  89. props.style = normalizeStyle(style);
  90. }
  91. return props;
  92. }
  93. // These tag configs are shared between compiler-dom and runtime-dom, so they
  94. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  95. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  96. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  97. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  98. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  99. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  100. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  101. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  102. 'option,output,progress,select,textarea,details,dialog,menu,' +
  103. 'summary,template,blockquote,iframe,tfoot';
  104. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  105. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  106. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  107. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  108. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  109. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  110. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  111. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  112. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  113. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  114. 'text,textPath,title,tspan,unknown,use,view';
  115. /**
  116. * Compiler only.
  117. * Do NOT use in runtime code paths unless behind `true` flag.
  118. */
  119. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  120. /**
  121. * Compiler only.
  122. * Do NOT use in runtime code paths unless behind `true` flag.
  123. */
  124. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  125. /**
  126. * On the client we only need to offer special cases for boolean attributes that
  127. * have different names from their corresponding dom properties:
  128. * - itemscope -> N/A
  129. * - allowfullscreen -> allowFullscreen
  130. * - formnovalidate -> formNoValidate
  131. * - ismap -> isMap
  132. * - nomodule -> noModule
  133. * - novalidate -> noValidate
  134. * - readonly -> readOnly
  135. */
  136. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  137. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  138. /**
  139. * Boolean attributes should be included if the value is truthy or ''.
  140. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  141. */
  142. function includeBooleanAttr(value) {
  143. return !!value || value === '';
  144. }
  145. function looseCompareArrays(a, b) {
  146. if (a.length !== b.length)
  147. return false;
  148. let equal = true;
  149. for (let i = 0; equal && i < a.length; i++) {
  150. equal = looseEqual(a[i], b[i]);
  151. }
  152. return equal;
  153. }
  154. function looseEqual(a, b) {
  155. if (a === b)
  156. return true;
  157. let aValidType = isDate(a);
  158. let bValidType = isDate(b);
  159. if (aValidType || bValidType) {
  160. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  161. }
  162. aValidType = isSymbol(a);
  163. bValidType = isSymbol(b);
  164. if (aValidType || bValidType) {
  165. return a === b;
  166. }
  167. aValidType = isArray(a);
  168. bValidType = isArray(b);
  169. if (aValidType || bValidType) {
  170. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  171. }
  172. aValidType = isObject(a);
  173. bValidType = isObject(b);
  174. if (aValidType || bValidType) {
  175. /* istanbul ignore if: this if will probably never be called */
  176. if (!aValidType || !bValidType) {
  177. return false;
  178. }
  179. const aKeysCount = Object.keys(a).length;
  180. const bKeysCount = Object.keys(b).length;
  181. if (aKeysCount !== bKeysCount) {
  182. return false;
  183. }
  184. for (const key in a) {
  185. const aHasKey = a.hasOwnProperty(key);
  186. const bHasKey = b.hasOwnProperty(key);
  187. if ((aHasKey && !bHasKey) ||
  188. (!aHasKey && bHasKey) ||
  189. !looseEqual(a[key], b[key])) {
  190. return false;
  191. }
  192. }
  193. }
  194. return String(a) === String(b);
  195. }
  196. function looseIndexOf(arr, val) {
  197. return arr.findIndex(item => looseEqual(item, val));
  198. }
  199. /**
  200. * For converting {{ interpolation }} values to displayed strings.
  201. * @private
  202. */
  203. const toDisplayString = (val) => {
  204. return isString(val)
  205. ? val
  206. : val == null
  207. ? ''
  208. : isArray(val) ||
  209. (isObject(val) &&
  210. (val.toString === objectToString || !isFunction(val.toString)))
  211. ? JSON.stringify(val, replacer, 2)
  212. : String(val);
  213. };
  214. const replacer = (_key, val) => {
  215. // can't use isRef here since @vue/shared has no deps
  216. if (val && val.__v_isRef) {
  217. return replacer(_key, val.value);
  218. }
  219. else if (isMap(val)) {
  220. return {
  221. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  222. entries[`${key} =>`] = val;
  223. return entries;
  224. }, {})
  225. };
  226. }
  227. else if (isSet(val)) {
  228. return {
  229. [`Set(${val.size})`]: [...val.values()]
  230. };
  231. }
  232. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  233. return String(val);
  234. }
  235. return val;
  236. };
  237. const EMPTY_OBJ = Object.freeze({})
  238. ;
  239. const EMPTY_ARR = Object.freeze([]) ;
  240. const NOOP = () => { };
  241. /**
  242. * Always return false.
  243. */
  244. const NO = () => false;
  245. const onRE = /^on[^a-z]/;
  246. const isOn = (key) => onRE.test(key);
  247. const isModelListener = (key) => key.startsWith('onUpdate:');
  248. const extend = Object.assign;
  249. const remove = (arr, el) => {
  250. const i = arr.indexOf(el);
  251. if (i > -1) {
  252. arr.splice(i, 1);
  253. }
  254. };
  255. const hasOwnProperty = Object.prototype.hasOwnProperty;
  256. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  257. const isArray = Array.isArray;
  258. const isMap = (val) => toTypeString(val) === '[object Map]';
  259. const isSet = (val) => toTypeString(val) === '[object Set]';
  260. const isDate = (val) => toTypeString(val) === '[object Date]';
  261. const isFunction = (val) => typeof val === 'function';
  262. const isString = (val) => typeof val === 'string';
  263. const isSymbol = (val) => typeof val === 'symbol';
  264. const isObject = (val) => val !== null && typeof val === 'object';
  265. const isPromise = (val) => {
  266. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  267. };
  268. const objectToString = Object.prototype.toString;
  269. const toTypeString = (value) => objectToString.call(value);
  270. const toRawType = (value) => {
  271. // extract "RawType" from strings like "[object RawType]"
  272. return toTypeString(value).slice(8, -1);
  273. };
  274. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  275. const isIntegerKey = (key) => isString(key) &&
  276. key !== 'NaN' &&
  277. key[0] !== '-' &&
  278. '' + parseInt(key, 10) === key;
  279. const isReservedProp = /*#__PURE__*/ makeMap(
  280. // the leading comma is intentional so empty string "" is also included
  281. ',key,ref,ref_for,ref_key,' +
  282. 'onVnodeBeforeMount,onVnodeMounted,' +
  283. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  284. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  285. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  286. const cacheStringFunction = (fn) => {
  287. const cache = Object.create(null);
  288. return ((str) => {
  289. const hit = cache[str];
  290. return hit || (cache[str] = fn(str));
  291. });
  292. };
  293. const camelizeRE = /-(\w)/g;
  294. /**
  295. * @private
  296. */
  297. const camelize = cacheStringFunction((str) => {
  298. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  299. });
  300. const hyphenateRE = /\B([A-Z])/g;
  301. /**
  302. * @private
  303. */
  304. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  305. /**
  306. * @private
  307. */
  308. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  309. /**
  310. * @private
  311. */
  312. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  313. // compare whether a value has changed, accounting for NaN.
  314. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  315. const invokeArrayFns = (fns, arg) => {
  316. for (let i = 0; i < fns.length; i++) {
  317. fns[i](arg);
  318. }
  319. };
  320. const def = (obj, key, value) => {
  321. Object.defineProperty(obj, key, {
  322. configurable: true,
  323. enumerable: false,
  324. value
  325. });
  326. };
  327. const toNumber = (val) => {
  328. const n = parseFloat(val);
  329. return isNaN(n) ? val : n;
  330. };
  331. let _globalThis;
  332. const getGlobalThis = () => {
  333. return (_globalThis ||
  334. (_globalThis =
  335. typeof globalThis !== 'undefined'
  336. ? globalThis
  337. : typeof self !== 'undefined'
  338. ? self
  339. : typeof window !== 'undefined'
  340. ? window
  341. : typeof global !== 'undefined'
  342. ? global
  343. : {}));
  344. };
  345. function warn(msg, ...args) {
  346. console.warn(`[Vue warn] ${msg}`, ...args);
  347. }
  348. let activeEffectScope;
  349. class EffectScope {
  350. constructor(detached = false) {
  351. this.detached = detached;
  352. /**
  353. * @internal
  354. */
  355. this.active = true;
  356. /**
  357. * @internal
  358. */
  359. this.effects = [];
  360. /**
  361. * @internal
  362. */
  363. this.cleanups = [];
  364. this.parent = activeEffectScope;
  365. if (!detached && activeEffectScope) {
  366. this.index =
  367. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  368. }
  369. }
  370. run(fn) {
  371. if (this.active) {
  372. const currentEffectScope = activeEffectScope;
  373. try {
  374. activeEffectScope = this;
  375. return fn();
  376. }
  377. finally {
  378. activeEffectScope = currentEffectScope;
  379. }
  380. }
  381. else {
  382. warn(`cannot run an inactive effect scope.`);
  383. }
  384. }
  385. /**
  386. * This should only be called on non-detached scopes
  387. * @internal
  388. */
  389. on() {
  390. activeEffectScope = this;
  391. }
  392. /**
  393. * This should only be called on non-detached scopes
  394. * @internal
  395. */
  396. off() {
  397. activeEffectScope = this.parent;
  398. }
  399. stop(fromParent) {
  400. if (this.active) {
  401. let i, l;
  402. for (i = 0, l = this.effects.length; i < l; i++) {
  403. this.effects[i].stop();
  404. }
  405. for (i = 0, l = this.cleanups.length; i < l; i++) {
  406. this.cleanups[i]();
  407. }
  408. if (this.scopes) {
  409. for (i = 0, l = this.scopes.length; i < l; i++) {
  410. this.scopes[i].stop(true);
  411. }
  412. }
  413. // nested scope, dereference from parent to avoid memory leaks
  414. if (!this.detached && this.parent && !fromParent) {
  415. // optimized O(1) removal
  416. const last = this.parent.scopes.pop();
  417. if (last && last !== this) {
  418. this.parent.scopes[this.index] = last;
  419. last.index = this.index;
  420. }
  421. }
  422. this.parent = undefined;
  423. this.active = false;
  424. }
  425. }
  426. }
  427. function effectScope(detached) {
  428. return new EffectScope(detached);
  429. }
  430. function recordEffectScope(effect, scope = activeEffectScope) {
  431. if (scope && scope.active) {
  432. scope.effects.push(effect);
  433. }
  434. }
  435. function getCurrentScope() {
  436. return activeEffectScope;
  437. }
  438. function onScopeDispose(fn) {
  439. if (activeEffectScope) {
  440. activeEffectScope.cleanups.push(fn);
  441. }
  442. else {
  443. warn(`onScopeDispose() is called when there is no active effect scope` +
  444. ` to be associated with.`);
  445. }
  446. }
  447. const createDep = (effects) => {
  448. const dep = new Set(effects);
  449. dep.w = 0;
  450. dep.n = 0;
  451. return dep;
  452. };
  453. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  454. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  455. const initDepMarkers = ({ deps }) => {
  456. if (deps.length) {
  457. for (let i = 0; i < deps.length; i++) {
  458. deps[i].w |= trackOpBit; // set was tracked
  459. }
  460. }
  461. };
  462. const finalizeDepMarkers = (effect) => {
  463. const { deps } = effect;
  464. if (deps.length) {
  465. let ptr = 0;
  466. for (let i = 0; i < deps.length; i++) {
  467. const dep = deps[i];
  468. if (wasTracked(dep) && !newTracked(dep)) {
  469. dep.delete(effect);
  470. }
  471. else {
  472. deps[ptr++] = dep;
  473. }
  474. // clear bits
  475. dep.w &= ~trackOpBit;
  476. dep.n &= ~trackOpBit;
  477. }
  478. deps.length = ptr;
  479. }
  480. };
  481. const targetMap = new WeakMap();
  482. // The number of effects currently being tracked recursively.
  483. let effectTrackDepth = 0;
  484. let trackOpBit = 1;
  485. /**
  486. * The bitwise track markers support at most 30 levels of recursion.
  487. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  488. * When recursion depth is greater, fall back to using a full cleanup.
  489. */
  490. const maxMarkerBits = 30;
  491. let activeEffect;
  492. const ITERATE_KEY = Symbol('iterate' );
  493. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  494. class ReactiveEffect {
  495. constructor(fn, scheduler = null, scope) {
  496. this.fn = fn;
  497. this.scheduler = scheduler;
  498. this.active = true;
  499. this.deps = [];
  500. this.parent = undefined;
  501. recordEffectScope(this, scope);
  502. }
  503. run() {
  504. if (!this.active) {
  505. return this.fn();
  506. }
  507. let parent = activeEffect;
  508. let lastShouldTrack = shouldTrack;
  509. while (parent) {
  510. if (parent === this) {
  511. return;
  512. }
  513. parent = parent.parent;
  514. }
  515. try {
  516. this.parent = activeEffect;
  517. activeEffect = this;
  518. shouldTrack = true;
  519. trackOpBit = 1 << ++effectTrackDepth;
  520. if (effectTrackDepth <= maxMarkerBits) {
  521. initDepMarkers(this);
  522. }
  523. else {
  524. cleanupEffect(this);
  525. }
  526. return this.fn();
  527. }
  528. finally {
  529. if (effectTrackDepth <= maxMarkerBits) {
  530. finalizeDepMarkers(this);
  531. }
  532. trackOpBit = 1 << --effectTrackDepth;
  533. activeEffect = this.parent;
  534. shouldTrack = lastShouldTrack;
  535. this.parent = undefined;
  536. if (this.deferStop) {
  537. this.stop();
  538. }
  539. }
  540. }
  541. stop() {
  542. // stopped while running itself - defer the cleanup
  543. if (activeEffect === this) {
  544. this.deferStop = true;
  545. }
  546. else if (this.active) {
  547. cleanupEffect(this);
  548. if (this.onStop) {
  549. this.onStop();
  550. }
  551. this.active = false;
  552. }
  553. }
  554. }
  555. function cleanupEffect(effect) {
  556. const { deps } = effect;
  557. if (deps.length) {
  558. for (let i = 0; i < deps.length; i++) {
  559. deps[i].delete(effect);
  560. }
  561. deps.length = 0;
  562. }
  563. }
  564. function effect(fn, options) {
  565. if (fn.effect) {
  566. fn = fn.effect.fn;
  567. }
  568. const _effect = new ReactiveEffect(fn);
  569. if (options) {
  570. extend(_effect, options);
  571. if (options.scope)
  572. recordEffectScope(_effect, options.scope);
  573. }
  574. if (!options || !options.lazy) {
  575. _effect.run();
  576. }
  577. const runner = _effect.run.bind(_effect);
  578. runner.effect = _effect;
  579. return runner;
  580. }
  581. function stop(runner) {
  582. runner.effect.stop();
  583. }
  584. let shouldTrack = true;
  585. const trackStack = [];
  586. function pauseTracking() {
  587. trackStack.push(shouldTrack);
  588. shouldTrack = false;
  589. }
  590. function resetTracking() {
  591. const last = trackStack.pop();
  592. shouldTrack = last === undefined ? true : last;
  593. }
  594. function track(target, type, key) {
  595. if (shouldTrack && activeEffect) {
  596. let depsMap = targetMap.get(target);
  597. if (!depsMap) {
  598. targetMap.set(target, (depsMap = new Map()));
  599. }
  600. let dep = depsMap.get(key);
  601. if (!dep) {
  602. depsMap.set(key, (dep = createDep()));
  603. }
  604. const eventInfo = { effect: activeEffect, target, type, key }
  605. ;
  606. trackEffects(dep, eventInfo);
  607. }
  608. }
  609. function trackEffects(dep, debuggerEventExtraInfo) {
  610. let shouldTrack = false;
  611. if (effectTrackDepth <= maxMarkerBits) {
  612. if (!newTracked(dep)) {
  613. dep.n |= trackOpBit; // set newly tracked
  614. shouldTrack = !wasTracked(dep);
  615. }
  616. }
  617. else {
  618. // Full cleanup mode.
  619. shouldTrack = !dep.has(activeEffect);
  620. }
  621. if (shouldTrack) {
  622. dep.add(activeEffect);
  623. activeEffect.deps.push(dep);
  624. if (activeEffect.onTrack) {
  625. activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
  626. }
  627. }
  628. }
  629. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  630. const depsMap = targetMap.get(target);
  631. if (!depsMap) {
  632. // never been tracked
  633. return;
  634. }
  635. let deps = [];
  636. if (type === "clear" /* TriggerOpTypes.CLEAR */) {
  637. // collection being cleared
  638. // trigger all effects for target
  639. deps = [...depsMap.values()];
  640. }
  641. else if (key === 'length' && isArray(target)) {
  642. const newLength = toNumber(newValue);
  643. depsMap.forEach((dep, key) => {
  644. if (key === 'length' || key >= newLength) {
  645. deps.push(dep);
  646. }
  647. });
  648. }
  649. else {
  650. // schedule runs for SET | ADD | DELETE
  651. if (key !== void 0) {
  652. deps.push(depsMap.get(key));
  653. }
  654. // also run for iteration key on ADD | DELETE | Map.SET
  655. switch (type) {
  656. case "add" /* TriggerOpTypes.ADD */:
  657. if (!isArray(target)) {
  658. deps.push(depsMap.get(ITERATE_KEY));
  659. if (isMap(target)) {
  660. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  661. }
  662. }
  663. else if (isIntegerKey(key)) {
  664. // new index added to array -> length changes
  665. deps.push(depsMap.get('length'));
  666. }
  667. break;
  668. case "delete" /* TriggerOpTypes.DELETE */:
  669. if (!isArray(target)) {
  670. deps.push(depsMap.get(ITERATE_KEY));
  671. if (isMap(target)) {
  672. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  673. }
  674. }
  675. break;
  676. case "set" /* TriggerOpTypes.SET */:
  677. if (isMap(target)) {
  678. deps.push(depsMap.get(ITERATE_KEY));
  679. }
  680. break;
  681. }
  682. }
  683. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  684. ;
  685. if (deps.length === 1) {
  686. if (deps[0]) {
  687. {
  688. triggerEffects(deps[0], eventInfo);
  689. }
  690. }
  691. }
  692. else {
  693. const effects = [];
  694. for (const dep of deps) {
  695. if (dep) {
  696. effects.push(...dep);
  697. }
  698. }
  699. {
  700. triggerEffects(createDep(effects), eventInfo);
  701. }
  702. }
  703. }
  704. function triggerEffects(dep, debuggerEventExtraInfo) {
  705. // spread into array for stabilization
  706. const effects = isArray(dep) ? dep : [...dep];
  707. for (const effect of effects) {
  708. if (effect.computed) {
  709. triggerEffect(effect, debuggerEventExtraInfo);
  710. }
  711. }
  712. for (const effect of effects) {
  713. if (!effect.computed) {
  714. triggerEffect(effect, debuggerEventExtraInfo);
  715. }
  716. }
  717. }
  718. function triggerEffect(effect, debuggerEventExtraInfo) {
  719. if (effect !== activeEffect || effect.allowRecurse) {
  720. if (effect.onTrigger) {
  721. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  722. }
  723. if (effect.scheduler) {
  724. effect.scheduler();
  725. }
  726. else {
  727. effect.run();
  728. }
  729. }
  730. }
  731. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  732. const builtInSymbols = new Set(
  733. /*#__PURE__*/
  734. Object.getOwnPropertyNames(Symbol)
  735. // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
  736. // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
  737. // function
  738. .filter(key => key !== 'arguments' && key !== 'caller')
  739. .map(key => Symbol[key])
  740. .filter(isSymbol));
  741. const get = /*#__PURE__*/ createGetter();
  742. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  743. const readonlyGet = /*#__PURE__*/ createGetter(true);
  744. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  745. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  746. function createArrayInstrumentations() {
  747. const instrumentations = {};
  748. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  749. instrumentations[key] = function (...args) {
  750. const arr = toRaw(this);
  751. for (let i = 0, l = this.length; i < l; i++) {
  752. track(arr, "get" /* TrackOpTypes.GET */, i + '');
  753. }
  754. // we run the method using the original args first (which may be reactive)
  755. const res = arr[key](...args);
  756. if (res === -1 || res === false) {
  757. // if that didn't work, run it again using raw values.
  758. return arr[key](...args.map(toRaw));
  759. }
  760. else {
  761. return res;
  762. }
  763. };
  764. });
  765. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  766. instrumentations[key] = function (...args) {
  767. pauseTracking();
  768. const res = toRaw(this)[key].apply(this, args);
  769. resetTracking();
  770. return res;
  771. };
  772. });
  773. return instrumentations;
  774. }
  775. function createGetter(isReadonly = false, shallow = false) {
  776. return function get(target, key, receiver) {
  777. if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
  778. return !isReadonly;
  779. }
  780. else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
  781. return isReadonly;
  782. }
  783. else if (key === "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */) {
  784. return shallow;
  785. }
  786. else if (key === "__v_raw" /* ReactiveFlags.RAW */ &&
  787. receiver ===
  788. (isReadonly
  789. ? shallow
  790. ? shallowReadonlyMap
  791. : readonlyMap
  792. : shallow
  793. ? shallowReactiveMap
  794. : reactiveMap).get(target)) {
  795. return target;
  796. }
  797. const targetIsArray = isArray(target);
  798. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  799. return Reflect.get(arrayInstrumentations, key, receiver);
  800. }
  801. const res = Reflect.get(target, key, receiver);
  802. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  803. return res;
  804. }
  805. if (!isReadonly) {
  806. track(target, "get" /* TrackOpTypes.GET */, key);
  807. }
  808. if (shallow) {
  809. return res;
  810. }
  811. if (isRef(res)) {
  812. // ref unwrapping - skip unwrap for Array + integer key.
  813. return targetIsArray && isIntegerKey(key) ? res : res.value;
  814. }
  815. if (isObject(res)) {
  816. // Convert returned value into a proxy as well. we do the isObject check
  817. // here to avoid invalid value warning. Also need to lazy access readonly
  818. // and reactive here to avoid circular dependency.
  819. return isReadonly ? readonly(res) : reactive(res);
  820. }
  821. return res;
  822. };
  823. }
  824. const set = /*#__PURE__*/ createSetter();
  825. const shallowSet = /*#__PURE__*/ createSetter(true);
  826. function createSetter(shallow = false) {
  827. return function set(target, key, value, receiver) {
  828. let oldValue = target[key];
  829. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  830. return false;
  831. }
  832. if (!shallow) {
  833. if (!isShallow(value) && !isReadonly(value)) {
  834. oldValue = toRaw(oldValue);
  835. value = toRaw(value);
  836. }
  837. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  838. oldValue.value = value;
  839. return true;
  840. }
  841. }
  842. const hadKey = isArray(target) && isIntegerKey(key)
  843. ? Number(key) < target.length
  844. : hasOwn(target, key);
  845. const result = Reflect.set(target, key, value, receiver);
  846. // don't trigger if target is something up in the prototype chain of original
  847. if (target === toRaw(receiver)) {
  848. if (!hadKey) {
  849. trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
  850. }
  851. else if (hasChanged(value, oldValue)) {
  852. trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
  853. }
  854. }
  855. return result;
  856. };
  857. }
  858. function deleteProperty(target, key) {
  859. const hadKey = hasOwn(target, key);
  860. const oldValue = target[key];
  861. const result = Reflect.deleteProperty(target, key);
  862. if (result && hadKey) {
  863. trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
  864. }
  865. return result;
  866. }
  867. function has(target, key) {
  868. const result = Reflect.has(target, key);
  869. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  870. track(target, "has" /* TrackOpTypes.HAS */, key);
  871. }
  872. return result;
  873. }
  874. function ownKeys(target) {
  875. track(target, "iterate" /* TrackOpTypes.ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  876. return Reflect.ownKeys(target);
  877. }
  878. const mutableHandlers = {
  879. get,
  880. set,
  881. deleteProperty,
  882. has,
  883. ownKeys
  884. };
  885. const readonlyHandlers = {
  886. get: readonlyGet,
  887. set(target, key) {
  888. {
  889. warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  890. }
  891. return true;
  892. },
  893. deleteProperty(target, key) {
  894. {
  895. warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  896. }
  897. return true;
  898. }
  899. };
  900. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  901. get: shallowGet,
  902. set: shallowSet
  903. });
  904. // Props handlers are special in the sense that it should not unwrap top-level
  905. // refs (in order to allow refs to be explicitly passed down), but should
  906. // retain the reactivity of the normal readonly object.
  907. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  908. get: shallowReadonlyGet
  909. });
  910. const toShallow = (value) => value;
  911. const getProto = (v) => Reflect.getPrototypeOf(v);
  912. function get$1(target, key, isReadonly = false, isShallow = false) {
  913. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  914. // of the value
  915. target = target["__v_raw" /* ReactiveFlags.RAW */];
  916. const rawTarget = toRaw(target);
  917. const rawKey = toRaw(key);
  918. if (!isReadonly) {
  919. if (key !== rawKey) {
  920. track(rawTarget, "get" /* TrackOpTypes.GET */, key);
  921. }
  922. track(rawTarget, "get" /* TrackOpTypes.GET */, rawKey);
  923. }
  924. const { has } = getProto(rawTarget);
  925. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  926. if (has.call(rawTarget, key)) {
  927. return wrap(target.get(key));
  928. }
  929. else if (has.call(rawTarget, rawKey)) {
  930. return wrap(target.get(rawKey));
  931. }
  932. else if (target !== rawTarget) {
  933. // #3602 readonly(reactive(Map))
  934. // ensure that the nested reactive `Map` can do tracking for itself
  935. target.get(key);
  936. }
  937. }
  938. function has$1(key, isReadonly = false) {
  939. const target = this["__v_raw" /* ReactiveFlags.RAW */];
  940. const rawTarget = toRaw(target);
  941. const rawKey = toRaw(key);
  942. if (!isReadonly) {
  943. if (key !== rawKey) {
  944. track(rawTarget, "has" /* TrackOpTypes.HAS */, key);
  945. }
  946. track(rawTarget, "has" /* TrackOpTypes.HAS */, rawKey);
  947. }
  948. return key === rawKey
  949. ? target.has(key)
  950. : target.has(key) || target.has(rawKey);
  951. }
  952. function size(target, isReadonly = false) {
  953. target = target["__v_raw" /* ReactiveFlags.RAW */];
  954. !isReadonly && track(toRaw(target), "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
  955. return Reflect.get(target, 'size', target);
  956. }
  957. function add(value) {
  958. value = toRaw(value);
  959. const target = toRaw(this);
  960. const proto = getProto(target);
  961. const hadKey = proto.has.call(target, value);
  962. if (!hadKey) {
  963. target.add(value);
  964. trigger(target, "add" /* TriggerOpTypes.ADD */, value, value);
  965. }
  966. return this;
  967. }
  968. function set$1(key, value) {
  969. value = toRaw(value);
  970. const target = toRaw(this);
  971. const { has, get } = getProto(target);
  972. let hadKey = has.call(target, key);
  973. if (!hadKey) {
  974. key = toRaw(key);
  975. hadKey = has.call(target, key);
  976. }
  977. else {
  978. checkIdentityKeys(target, has, key);
  979. }
  980. const oldValue = get.call(target, key);
  981. target.set(key, value);
  982. if (!hadKey) {
  983. trigger(target, "add" /* TriggerOpTypes.ADD */, key, value);
  984. }
  985. else if (hasChanged(value, oldValue)) {
  986. trigger(target, "set" /* TriggerOpTypes.SET */, key, value, oldValue);
  987. }
  988. return this;
  989. }
  990. function deleteEntry(key) {
  991. const target = toRaw(this);
  992. const { has, get } = getProto(target);
  993. let hadKey = has.call(target, key);
  994. if (!hadKey) {
  995. key = toRaw(key);
  996. hadKey = has.call(target, key);
  997. }
  998. else {
  999. checkIdentityKeys(target, has, key);
  1000. }
  1001. const oldValue = get ? get.call(target, key) : undefined;
  1002. // forward the operation before queueing reactions
  1003. const result = target.delete(key);
  1004. if (hadKey) {
  1005. trigger(target, "delete" /* TriggerOpTypes.DELETE */, key, undefined, oldValue);
  1006. }
  1007. return result;
  1008. }
  1009. function clear() {
  1010. const target = toRaw(this);
  1011. const hadItems = target.size !== 0;
  1012. const oldTarget = isMap(target)
  1013. ? new Map(target)
  1014. : new Set(target)
  1015. ;
  1016. // forward the operation before queueing reactions
  1017. const result = target.clear();
  1018. if (hadItems) {
  1019. trigger(target, "clear" /* TriggerOpTypes.CLEAR */, undefined, undefined, oldTarget);
  1020. }
  1021. return result;
  1022. }
  1023. function createForEach(isReadonly, isShallow) {
  1024. return function forEach(callback, thisArg) {
  1025. const observed = this;
  1026. const target = observed["__v_raw" /* ReactiveFlags.RAW */];
  1027. const rawTarget = toRaw(target);
  1028. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1029. !isReadonly && track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, ITERATE_KEY);
  1030. return target.forEach((value, key) => {
  1031. // important: make sure the callback is
  1032. // 1. invoked with the reactive map as `this` and 3rd arg
  1033. // 2. the value received should be a corresponding reactive/readonly.
  1034. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1035. });
  1036. };
  1037. }
  1038. function createIterableMethod(method, isReadonly, isShallow) {
  1039. return function (...args) {
  1040. const target = this["__v_raw" /* ReactiveFlags.RAW */];
  1041. const rawTarget = toRaw(target);
  1042. const targetIsMap = isMap(rawTarget);
  1043. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  1044. const isKeyOnly = method === 'keys' && targetIsMap;
  1045. const innerIterator = target[method](...args);
  1046. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1047. !isReadonly &&
  1048. track(rawTarget, "iterate" /* TrackOpTypes.ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1049. // return a wrapped iterator which returns observed versions of the
  1050. // values emitted from the real iterator
  1051. return {
  1052. // iterator protocol
  1053. next() {
  1054. const { value, done } = innerIterator.next();
  1055. return done
  1056. ? { value, done }
  1057. : {
  1058. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1059. done
  1060. };
  1061. },
  1062. // iterable protocol
  1063. [Symbol.iterator]() {
  1064. return this;
  1065. }
  1066. };
  1067. };
  1068. }
  1069. function createReadonlyMethod(type) {
  1070. return function (...args) {
  1071. {
  1072. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1073. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1074. }
  1075. return type === "delete" /* TriggerOpTypes.DELETE */ ? false : this;
  1076. };
  1077. }
  1078. function createInstrumentations() {
  1079. const mutableInstrumentations = {
  1080. get(key) {
  1081. return get$1(this, key);
  1082. },
  1083. get size() {
  1084. return size(this);
  1085. },
  1086. has: has$1,
  1087. add,
  1088. set: set$1,
  1089. delete: deleteEntry,
  1090. clear,
  1091. forEach: createForEach(false, false)
  1092. };
  1093. const shallowInstrumentations = {
  1094. get(key) {
  1095. return get$1(this, key, false, true);
  1096. },
  1097. get size() {
  1098. return size(this);
  1099. },
  1100. has: has$1,
  1101. add,
  1102. set: set$1,
  1103. delete: deleteEntry,
  1104. clear,
  1105. forEach: createForEach(false, true)
  1106. };
  1107. const readonlyInstrumentations = {
  1108. get(key) {
  1109. return get$1(this, key, true);
  1110. },
  1111. get size() {
  1112. return size(this, true);
  1113. },
  1114. has(key) {
  1115. return has$1.call(this, key, true);
  1116. },
  1117. add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
  1118. set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
  1119. delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
  1120. clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
  1121. forEach: createForEach(true, false)
  1122. };
  1123. const shallowReadonlyInstrumentations = {
  1124. get(key) {
  1125. return get$1(this, key, true, true);
  1126. },
  1127. get size() {
  1128. return size(this, true);
  1129. },
  1130. has(key) {
  1131. return has$1.call(this, key, true);
  1132. },
  1133. add: createReadonlyMethod("add" /* TriggerOpTypes.ADD */),
  1134. set: createReadonlyMethod("set" /* TriggerOpTypes.SET */),
  1135. delete: createReadonlyMethod("delete" /* TriggerOpTypes.DELETE */),
  1136. clear: createReadonlyMethod("clear" /* TriggerOpTypes.CLEAR */),
  1137. forEach: createForEach(true, true)
  1138. };
  1139. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1140. iteratorMethods.forEach(method => {
  1141. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1142. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1143. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1144. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1145. });
  1146. return [
  1147. mutableInstrumentations,
  1148. readonlyInstrumentations,
  1149. shallowInstrumentations,
  1150. shallowReadonlyInstrumentations
  1151. ];
  1152. }
  1153. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1154. function createInstrumentationGetter(isReadonly, shallow) {
  1155. const instrumentations = shallow
  1156. ? isReadonly
  1157. ? shallowReadonlyInstrumentations
  1158. : shallowInstrumentations
  1159. : isReadonly
  1160. ? readonlyInstrumentations
  1161. : mutableInstrumentations;
  1162. return (target, key, receiver) => {
  1163. if (key === "__v_isReactive" /* ReactiveFlags.IS_REACTIVE */) {
  1164. return !isReadonly;
  1165. }
  1166. else if (key === "__v_isReadonly" /* ReactiveFlags.IS_READONLY */) {
  1167. return isReadonly;
  1168. }
  1169. else if (key === "__v_raw" /* ReactiveFlags.RAW */) {
  1170. return target;
  1171. }
  1172. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1173. ? instrumentations
  1174. : target, key, receiver);
  1175. };
  1176. }
  1177. const mutableCollectionHandlers = {
  1178. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1179. };
  1180. const shallowCollectionHandlers = {
  1181. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1182. };
  1183. const readonlyCollectionHandlers = {
  1184. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1185. };
  1186. const shallowReadonlyCollectionHandlers = {
  1187. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1188. };
  1189. function checkIdentityKeys(target, has, key) {
  1190. const rawKey = toRaw(key);
  1191. if (rawKey !== key && has.call(target, rawKey)) {
  1192. const type = toRawType(target);
  1193. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1194. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1195. `which can lead to inconsistencies. ` +
  1196. `Avoid differentiating between the raw and reactive versions ` +
  1197. `of an object and only use the reactive version if possible.`);
  1198. }
  1199. }
  1200. const reactiveMap = new WeakMap();
  1201. const shallowReactiveMap = new WeakMap();
  1202. const readonlyMap = new WeakMap();
  1203. const shallowReadonlyMap = new WeakMap();
  1204. function targetTypeMap(rawType) {
  1205. switch (rawType) {
  1206. case 'Object':
  1207. case 'Array':
  1208. return 1 /* TargetType.COMMON */;
  1209. case 'Map':
  1210. case 'Set':
  1211. case 'WeakMap':
  1212. case 'WeakSet':
  1213. return 2 /* TargetType.COLLECTION */;
  1214. default:
  1215. return 0 /* TargetType.INVALID */;
  1216. }
  1217. }
  1218. function getTargetType(value) {
  1219. return value["__v_skip" /* ReactiveFlags.SKIP */] || !Object.isExtensible(value)
  1220. ? 0 /* TargetType.INVALID */
  1221. : targetTypeMap(toRawType(value));
  1222. }
  1223. function reactive(target) {
  1224. // if trying to observe a readonly proxy, return the readonly version.
  1225. if (isReadonly(target)) {
  1226. return target;
  1227. }
  1228. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1229. }
  1230. /**
  1231. * Return a shallowly-reactive copy of the original object, where only the root
  1232. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1233. * root level).
  1234. */
  1235. function shallowReactive(target) {
  1236. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1237. }
  1238. /**
  1239. * Creates a readonly copy of the original object. Note the returned copy is not
  1240. * made reactive, but `readonly` can be called on an already reactive object.
  1241. */
  1242. function readonly(target) {
  1243. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1244. }
  1245. /**
  1246. * Returns a reactive-copy of the original object, where only the root level
  1247. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1248. * returned properties.
  1249. * This is used for creating the props proxy object for stateful components.
  1250. */
  1251. function shallowReadonly(target) {
  1252. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1253. }
  1254. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1255. if (!isObject(target)) {
  1256. {
  1257. console.warn(`value cannot be made reactive: ${String(target)}`);
  1258. }
  1259. return target;
  1260. }
  1261. // target is already a Proxy, return it.
  1262. // exception: calling readonly() on a reactive object
  1263. if (target["__v_raw" /* ReactiveFlags.RAW */] &&
  1264. !(isReadonly && target["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */])) {
  1265. return target;
  1266. }
  1267. // target already has corresponding Proxy
  1268. const existingProxy = proxyMap.get(target);
  1269. if (existingProxy) {
  1270. return existingProxy;
  1271. }
  1272. // only specific value types can be observed.
  1273. const targetType = getTargetType(target);
  1274. if (targetType === 0 /* TargetType.INVALID */) {
  1275. return target;
  1276. }
  1277. const proxy = new Proxy(target, targetType === 2 /* TargetType.COLLECTION */ ? collectionHandlers : baseHandlers);
  1278. proxyMap.set(target, proxy);
  1279. return proxy;
  1280. }
  1281. function isReactive(value) {
  1282. if (isReadonly(value)) {
  1283. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1284. }
  1285. return !!(value && value["__v_isReactive" /* ReactiveFlags.IS_REACTIVE */]);
  1286. }
  1287. function isReadonly(value) {
  1288. return !!(value && value["__v_isReadonly" /* ReactiveFlags.IS_READONLY */]);
  1289. }
  1290. function isShallow(value) {
  1291. return !!(value && value["__v_isShallow" /* ReactiveFlags.IS_SHALLOW */]);
  1292. }
  1293. function isProxy(value) {
  1294. return isReactive(value) || isReadonly(value);
  1295. }
  1296. function toRaw(observed) {
  1297. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1298. return raw ? toRaw(raw) : observed;
  1299. }
  1300. function markRaw(value) {
  1301. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1302. return value;
  1303. }
  1304. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1305. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1306. function trackRefValue(ref) {
  1307. if (shouldTrack && activeEffect) {
  1308. ref = toRaw(ref);
  1309. {
  1310. trackEffects(ref.dep || (ref.dep = createDep()), {
  1311. target: ref,
  1312. type: "get" /* TrackOpTypes.GET */,
  1313. key: 'value'
  1314. });
  1315. }
  1316. }
  1317. }
  1318. function triggerRefValue(ref, newVal) {
  1319. ref = toRaw(ref);
  1320. if (ref.dep) {
  1321. {
  1322. triggerEffects(ref.dep, {
  1323. target: ref,
  1324. type: "set" /* TriggerOpTypes.SET */,
  1325. key: 'value',
  1326. newValue: newVal
  1327. });
  1328. }
  1329. }
  1330. }
  1331. function isRef(r) {
  1332. return !!(r && r.__v_isRef === true);
  1333. }
  1334. function ref(value) {
  1335. return createRef(value, false);
  1336. }
  1337. function shallowRef(value) {
  1338. return createRef(value, true);
  1339. }
  1340. function createRef(rawValue, shallow) {
  1341. if (isRef(rawValue)) {
  1342. return rawValue;
  1343. }
  1344. return new RefImpl(rawValue, shallow);
  1345. }
  1346. class RefImpl {
  1347. constructor(value, __v_isShallow) {
  1348. this.__v_isShallow = __v_isShallow;
  1349. this.dep = undefined;
  1350. this.__v_isRef = true;
  1351. this._rawValue = __v_isShallow ? value : toRaw(value);
  1352. this._value = __v_isShallow ? value : toReactive(value);
  1353. }
  1354. get value() {
  1355. trackRefValue(this);
  1356. return this._value;
  1357. }
  1358. set value(newVal) {
  1359. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1360. newVal = useDirectValue ? newVal : toRaw(newVal);
  1361. if (hasChanged(newVal, this._rawValue)) {
  1362. this._rawValue = newVal;
  1363. this._value = useDirectValue ? newVal : toReactive(newVal);
  1364. triggerRefValue(this, newVal);
  1365. }
  1366. }
  1367. }
  1368. function triggerRef(ref) {
  1369. triggerRefValue(ref, ref.value );
  1370. }
  1371. function unref(ref) {
  1372. return isRef(ref) ? ref.value : ref;
  1373. }
  1374. const shallowUnwrapHandlers = {
  1375. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1376. set: (target, key, value, receiver) => {
  1377. const oldValue = target[key];
  1378. if (isRef(oldValue) && !isRef(value)) {
  1379. oldValue.value = value;
  1380. return true;
  1381. }
  1382. else {
  1383. return Reflect.set(target, key, value, receiver);
  1384. }
  1385. }
  1386. };
  1387. function proxyRefs(objectWithRefs) {
  1388. return isReactive(objectWithRefs)
  1389. ? objectWithRefs
  1390. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1391. }
  1392. class CustomRefImpl {
  1393. constructor(factory) {
  1394. this.dep = undefined;
  1395. this.__v_isRef = true;
  1396. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1397. this._get = get;
  1398. this._set = set;
  1399. }
  1400. get value() {
  1401. return this._get();
  1402. }
  1403. set value(newVal) {
  1404. this._set(newVal);
  1405. }
  1406. }
  1407. function customRef(factory) {
  1408. return new CustomRefImpl(factory);
  1409. }
  1410. function toRefs(object) {
  1411. if (!isProxy(object)) {
  1412. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1413. }
  1414. const ret = isArray(object) ? new Array(object.length) : {};
  1415. for (const key in object) {
  1416. ret[key] = toRef(object, key);
  1417. }
  1418. return ret;
  1419. }
  1420. class ObjectRefImpl {
  1421. constructor(_object, _key, _defaultValue) {
  1422. this._object = _object;
  1423. this._key = _key;
  1424. this._defaultValue = _defaultValue;
  1425. this.__v_isRef = true;
  1426. }
  1427. get value() {
  1428. const val = this._object[this._key];
  1429. return val === undefined ? this._defaultValue : val;
  1430. }
  1431. set value(newVal) {
  1432. this._object[this._key] = newVal;
  1433. }
  1434. }
  1435. function toRef(object, key, defaultValue) {
  1436. const val = object[key];
  1437. return isRef(val)
  1438. ? val
  1439. : new ObjectRefImpl(object, key, defaultValue);
  1440. }
  1441. var _a;
  1442. class ComputedRefImpl {
  1443. constructor(getter, _setter, isReadonly, isSSR) {
  1444. this._setter = _setter;
  1445. this.dep = undefined;
  1446. this.__v_isRef = true;
  1447. this[_a] = false;
  1448. this._dirty = true;
  1449. this.effect = new ReactiveEffect(getter, () => {
  1450. if (!this._dirty) {
  1451. this._dirty = true;
  1452. triggerRefValue(this);
  1453. }
  1454. });
  1455. this.effect.computed = this;
  1456. this.effect.active = this._cacheable = !isSSR;
  1457. this["__v_isReadonly" /* ReactiveFlags.IS_READONLY */] = isReadonly;
  1458. }
  1459. get value() {
  1460. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1461. const self = toRaw(this);
  1462. trackRefValue(self);
  1463. if (self._dirty || !self._cacheable) {
  1464. self._dirty = false;
  1465. self._value = self.effect.run();
  1466. }
  1467. return self._value;
  1468. }
  1469. set value(newValue) {
  1470. this._setter(newValue);
  1471. }
  1472. }
  1473. _a = "__v_isReadonly" /* ReactiveFlags.IS_READONLY */;
  1474. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1475. let getter;
  1476. let setter;
  1477. const onlyGetter = isFunction(getterOrOptions);
  1478. if (onlyGetter) {
  1479. getter = getterOrOptions;
  1480. setter = () => {
  1481. console.warn('Write operation failed: computed value is readonly');
  1482. }
  1483. ;
  1484. }
  1485. else {
  1486. getter = getterOrOptions.get;
  1487. setter = getterOrOptions.set;
  1488. }
  1489. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1490. if (debugOptions && !isSSR) {
  1491. cRef.effect.onTrack = debugOptions.onTrack;
  1492. cRef.effect.onTrigger = debugOptions.onTrigger;
  1493. }
  1494. return cRef;
  1495. }
  1496. const stack = [];
  1497. function pushWarningContext(vnode) {
  1498. stack.push(vnode);
  1499. }
  1500. function popWarningContext() {
  1501. stack.pop();
  1502. }
  1503. function warn$1(msg, ...args) {
  1504. // avoid props formatting or warn handler tracking deps that might be mutated
  1505. // during patch, leading to infinite recursion.
  1506. pauseTracking();
  1507. const instance = stack.length ? stack[stack.length - 1].component : null;
  1508. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1509. const trace = getComponentTrace();
  1510. if (appWarnHandler) {
  1511. callWithErrorHandling(appWarnHandler, instance, 11 /* ErrorCodes.APP_WARN_HANDLER */, [
  1512. msg + args.join(''),
  1513. instance && instance.proxy,
  1514. trace
  1515. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1516. .join('\n'),
  1517. trace
  1518. ]);
  1519. }
  1520. else {
  1521. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1522. /* istanbul ignore if */
  1523. if (trace.length &&
  1524. // avoid spamming console during tests
  1525. !false) {
  1526. warnArgs.push(`\n`, ...formatTrace(trace));
  1527. }
  1528. console.warn(...warnArgs);
  1529. }
  1530. resetTracking();
  1531. }
  1532. function getComponentTrace() {
  1533. let currentVNode = stack[stack.length - 1];
  1534. if (!currentVNode) {
  1535. return [];
  1536. }
  1537. // we can't just use the stack because it will be incomplete during updates
  1538. // that did not start from the root. Re-construct the parent chain using
  1539. // instance parent pointers.
  1540. const normalizedStack = [];
  1541. while (currentVNode) {
  1542. const last = normalizedStack[0];
  1543. if (last && last.vnode === currentVNode) {
  1544. last.recurseCount++;
  1545. }
  1546. else {
  1547. normalizedStack.push({
  1548. vnode: currentVNode,
  1549. recurseCount: 0
  1550. });
  1551. }
  1552. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1553. currentVNode = parentInstance && parentInstance.vnode;
  1554. }
  1555. return normalizedStack;
  1556. }
  1557. /* istanbul ignore next */
  1558. function formatTrace(trace) {
  1559. const logs = [];
  1560. trace.forEach((entry, i) => {
  1561. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1562. });
  1563. return logs;
  1564. }
  1565. function formatTraceEntry({ vnode, recurseCount }) {
  1566. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1567. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1568. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1569. const close = `>` + postfix;
  1570. return vnode.props
  1571. ? [open, ...formatProps(vnode.props), close]
  1572. : [open + close];
  1573. }
  1574. /* istanbul ignore next */
  1575. function formatProps(props) {
  1576. const res = [];
  1577. const keys = Object.keys(props);
  1578. keys.slice(0, 3).forEach(key => {
  1579. res.push(...formatProp(key, props[key]));
  1580. });
  1581. if (keys.length > 3) {
  1582. res.push(` ...`);
  1583. }
  1584. return res;
  1585. }
  1586. /* istanbul ignore next */
  1587. function formatProp(key, value, raw) {
  1588. if (isString(value)) {
  1589. value = JSON.stringify(value);
  1590. return raw ? value : [`${key}=${value}`];
  1591. }
  1592. else if (typeof value === 'number' ||
  1593. typeof value === 'boolean' ||
  1594. value == null) {
  1595. return raw ? value : [`${key}=${value}`];
  1596. }
  1597. else if (isRef(value)) {
  1598. value = formatProp(key, toRaw(value.value), true);
  1599. return raw ? value : [`${key}=Ref<`, value, `>`];
  1600. }
  1601. else if (isFunction(value)) {
  1602. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1603. }
  1604. else {
  1605. value = toRaw(value);
  1606. return raw ? value : [`${key}=`, value];
  1607. }
  1608. }
  1609. const ErrorTypeStrings = {
  1610. ["sp" /* LifecycleHooks.SERVER_PREFETCH */]: 'serverPrefetch hook',
  1611. ["bc" /* LifecycleHooks.BEFORE_CREATE */]: 'beforeCreate hook',
  1612. ["c" /* LifecycleHooks.CREATED */]: 'created hook',
  1613. ["bm" /* LifecycleHooks.BEFORE_MOUNT */]: 'beforeMount hook',
  1614. ["m" /* LifecycleHooks.MOUNTED */]: 'mounted hook',
  1615. ["bu" /* LifecycleHooks.BEFORE_UPDATE */]: 'beforeUpdate hook',
  1616. ["u" /* LifecycleHooks.UPDATED */]: 'updated',
  1617. ["bum" /* LifecycleHooks.BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1618. ["um" /* LifecycleHooks.UNMOUNTED */]: 'unmounted hook',
  1619. ["a" /* LifecycleHooks.ACTIVATED */]: 'activated hook',
  1620. ["da" /* LifecycleHooks.DEACTIVATED */]: 'deactivated hook',
  1621. ["ec" /* LifecycleHooks.ERROR_CAPTURED */]: 'errorCaptured hook',
  1622. ["rtc" /* LifecycleHooks.RENDER_TRACKED */]: 'renderTracked hook',
  1623. ["rtg" /* LifecycleHooks.RENDER_TRIGGERED */]: 'renderTriggered hook',
  1624. [0 /* ErrorCodes.SETUP_FUNCTION */]: 'setup function',
  1625. [1 /* ErrorCodes.RENDER_FUNCTION */]: 'render function',
  1626. [2 /* ErrorCodes.WATCH_GETTER */]: 'watcher getter',
  1627. [3 /* ErrorCodes.WATCH_CALLBACK */]: 'watcher callback',
  1628. [4 /* ErrorCodes.WATCH_CLEANUP */]: 'watcher cleanup function',
  1629. [5 /* ErrorCodes.NATIVE_EVENT_HANDLER */]: 'native event handler',
  1630. [6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1631. [7 /* ErrorCodes.VNODE_HOOK */]: 'vnode hook',
  1632. [8 /* ErrorCodes.DIRECTIVE_HOOK */]: 'directive hook',
  1633. [9 /* ErrorCodes.TRANSITION_HOOK */]: 'transition hook',
  1634. [10 /* ErrorCodes.APP_ERROR_HANDLER */]: 'app errorHandler',
  1635. [11 /* ErrorCodes.APP_WARN_HANDLER */]: 'app warnHandler',
  1636. [12 /* ErrorCodes.FUNCTION_REF */]: 'ref function',
  1637. [13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1638. [14 /* ErrorCodes.SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1639. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
  1640. };
  1641. function callWithErrorHandling(fn, instance, type, args) {
  1642. let res;
  1643. try {
  1644. res = args ? fn(...args) : fn();
  1645. }
  1646. catch (err) {
  1647. handleError(err, instance, type);
  1648. }
  1649. return res;
  1650. }
  1651. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1652. if (isFunction(fn)) {
  1653. const res = callWithErrorHandling(fn, instance, type, args);
  1654. if (res && isPromise(res)) {
  1655. res.catch(err => {
  1656. handleError(err, instance, type);
  1657. });
  1658. }
  1659. return res;
  1660. }
  1661. const values = [];
  1662. for (let i = 0; i < fn.length; i++) {
  1663. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1664. }
  1665. return values;
  1666. }
  1667. function handleError(err, instance, type, throwInDev = true) {
  1668. const contextVNode = instance ? instance.vnode : null;
  1669. if (instance) {
  1670. let cur = instance.parent;
  1671. // the exposed instance is the render proxy to keep it consistent with 2.x
  1672. const exposedInstance = instance.proxy;
  1673. // in production the hook receives only the error code
  1674. const errorInfo = ErrorTypeStrings[type] ;
  1675. while (cur) {
  1676. const errorCapturedHooks = cur.ec;
  1677. if (errorCapturedHooks) {
  1678. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1679. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1680. return;
  1681. }
  1682. }
  1683. }
  1684. cur = cur.parent;
  1685. }
  1686. // app-level handling
  1687. const appErrorHandler = instance.appContext.config.errorHandler;
  1688. if (appErrorHandler) {
  1689. callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1690. return;
  1691. }
  1692. }
  1693. logError(err, type, contextVNode, throwInDev);
  1694. }
  1695. function logError(err, type, contextVNode, throwInDev = true) {
  1696. {
  1697. const info = ErrorTypeStrings[type];
  1698. if (contextVNode) {
  1699. pushWarningContext(contextVNode);
  1700. }
  1701. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1702. if (contextVNode) {
  1703. popWarningContext();
  1704. }
  1705. // crash in dev by default so it's more noticeable
  1706. if (throwInDev) {
  1707. throw err;
  1708. }
  1709. else {
  1710. console.error(err);
  1711. }
  1712. }
  1713. }
  1714. let isFlushing = false;
  1715. let isFlushPending = false;
  1716. const queue = [];
  1717. let flushIndex = 0;
  1718. const pendingPostFlushCbs = [];
  1719. let activePostFlushCbs = null;
  1720. let postFlushIndex = 0;
  1721. const resolvedPromise = /*#__PURE__*/ Promise.resolve();
  1722. let currentFlushPromise = null;
  1723. const RECURSION_LIMIT = 100;
  1724. function nextTick(fn) {
  1725. const p = currentFlushPromise || resolvedPromise;
  1726. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1727. }
  1728. // #2768
  1729. // Use binary-search to find a suitable position in the queue,
  1730. // so that the queue maintains the increasing order of job's id,
  1731. // which can prevent the job from being skipped and also can avoid repeated patching.
  1732. function findInsertionIndex(id) {
  1733. // the start index should be `flushIndex + 1`
  1734. let start = flushIndex + 1;
  1735. let end = queue.length;
  1736. while (start < end) {
  1737. const middle = (start + end) >>> 1;
  1738. const middleJobId = getId(queue[middle]);
  1739. middleJobId < id ? (start = middle + 1) : (end = middle);
  1740. }
  1741. return start;
  1742. }
  1743. function queueJob(job) {
  1744. // the dedupe search uses the startIndex argument of Array.includes()
  1745. // by default the search index includes the current job that is being run
  1746. // so it cannot recursively trigger itself again.
  1747. // if the job is a watch() callback, the search will start with a +1 index to
  1748. // allow it recursively trigger itself - it is the user's responsibility to
  1749. // ensure it doesn't end up in an infinite loop.
  1750. if (!queue.length ||
  1751. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) {
  1752. if (job.id == null) {
  1753. queue.push(job);
  1754. }
  1755. else {
  1756. queue.splice(findInsertionIndex(job.id), 0, job);
  1757. }
  1758. queueFlush();
  1759. }
  1760. }
  1761. function queueFlush() {
  1762. if (!isFlushing && !isFlushPending) {
  1763. isFlushPending = true;
  1764. currentFlushPromise = resolvedPromise.then(flushJobs);
  1765. }
  1766. }
  1767. function invalidateJob(job) {
  1768. const i = queue.indexOf(job);
  1769. if (i > flushIndex) {
  1770. queue.splice(i, 1);
  1771. }
  1772. }
  1773. function queuePostFlushCb(cb) {
  1774. if (!isArray(cb)) {
  1775. if (!activePostFlushCbs ||
  1776. !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) {
  1777. pendingPostFlushCbs.push(cb);
  1778. }
  1779. }
  1780. else {
  1781. // if cb is an array, it is a component lifecycle hook which can only be
  1782. // triggered by a job, which is already deduped in the main queue, so
  1783. // we can skip duplicate check here to improve perf
  1784. pendingPostFlushCbs.push(...cb);
  1785. }
  1786. queueFlush();
  1787. }
  1788. function flushPreFlushCbs(seen,
  1789. // if currently flushing, skip the current job itself
  1790. i = isFlushing ? flushIndex + 1 : 0) {
  1791. {
  1792. seen = seen || new Map();
  1793. }
  1794. for (; i < queue.length; i++) {
  1795. const cb = queue[i];
  1796. if (cb && cb.pre) {
  1797. if (checkRecursiveUpdates(seen, cb)) {
  1798. continue;
  1799. }
  1800. queue.splice(i, 1);
  1801. i--;
  1802. cb();
  1803. }
  1804. }
  1805. }
  1806. function flushPostFlushCbs(seen) {
  1807. if (pendingPostFlushCbs.length) {
  1808. const deduped = [...new Set(pendingPostFlushCbs)];
  1809. pendingPostFlushCbs.length = 0;
  1810. // #1947 already has active queue, nested flushPostFlushCbs call
  1811. if (activePostFlushCbs) {
  1812. activePostFlushCbs.push(...deduped);
  1813. return;
  1814. }
  1815. activePostFlushCbs = deduped;
  1816. {
  1817. seen = seen || new Map();
  1818. }
  1819. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1820. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1821. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1822. continue;
  1823. }
  1824. activePostFlushCbs[postFlushIndex]();
  1825. }
  1826. activePostFlushCbs = null;
  1827. postFlushIndex = 0;
  1828. }
  1829. }
  1830. const getId = (job) => job.id == null ? Infinity : job.id;
  1831. const comparator = (a, b) => {
  1832. const diff = getId(a) - getId(b);
  1833. if (diff === 0) {
  1834. if (a.pre && !b.pre)
  1835. return -1;
  1836. if (b.pre && !a.pre)
  1837. return 1;
  1838. }
  1839. return diff;
  1840. };
  1841. function flushJobs(seen) {
  1842. isFlushPending = false;
  1843. isFlushing = true;
  1844. {
  1845. seen = seen || new Map();
  1846. }
  1847. // Sort queue before flush.
  1848. // This ensures that:
  1849. // 1. Components are updated from parent to child. (because parent is always
  1850. // created before the child so its render effect will have smaller
  1851. // priority number)
  1852. // 2. If a component is unmounted during a parent component's update,
  1853. // its update can be skipped.
  1854. queue.sort(comparator);
  1855. // conditional usage of checkRecursiveUpdate must be determined out of
  1856. // try ... catch block since Rollup by default de-optimizes treeshaking
  1857. // inside try-catch. This can leave all warning code unshaked. Although
  1858. // they would get eventually shaken by a minifier like terser, some minifiers
  1859. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  1860. const check = (job) => checkRecursiveUpdates(seen, job)
  1861. ;
  1862. try {
  1863. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1864. const job = queue[flushIndex];
  1865. if (job && job.active !== false) {
  1866. if (true && check(job)) {
  1867. continue;
  1868. }
  1869. // console.log(`running:`, job.id)
  1870. callWithErrorHandling(job, null, 14 /* ErrorCodes.SCHEDULER */);
  1871. }
  1872. }
  1873. }
  1874. finally {
  1875. flushIndex = 0;
  1876. queue.length = 0;
  1877. flushPostFlushCbs(seen);
  1878. isFlushing = false;
  1879. currentFlushPromise = null;
  1880. // some postFlushCb queued jobs!
  1881. // keep flushing until it drains.
  1882. if (queue.length || pendingPostFlushCbs.length) {
  1883. flushJobs(seen);
  1884. }
  1885. }
  1886. }
  1887. function checkRecursiveUpdates(seen, fn) {
  1888. if (!seen.has(fn)) {
  1889. seen.set(fn, 1);
  1890. }
  1891. else {
  1892. const count = seen.get(fn);
  1893. if (count > RECURSION_LIMIT) {
  1894. const instance = fn.ownerInstance;
  1895. const componentName = instance && getComponentName(instance.type);
  1896. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  1897. `This means you have a reactive effect that is mutating its own ` +
  1898. `dependencies and thus recursively triggering itself. Possible sources ` +
  1899. `include component template, render function, updated hook or ` +
  1900. `watcher source function.`);
  1901. return true;
  1902. }
  1903. else {
  1904. seen.set(fn, count + 1);
  1905. }
  1906. }
  1907. }
  1908. /* eslint-disable no-restricted-globals */
  1909. let isHmrUpdating = false;
  1910. const hmrDirtyComponents = new Set();
  1911. // Expose the HMR runtime on the global object
  1912. // This makes it entirely tree-shakable without polluting the exports and makes
  1913. // it easier to be used in toolings like vue-loader
  1914. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1915. // to be set so that its instances can be registered / removed.
  1916. {
  1917. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1918. createRecord: tryWrap(createRecord),
  1919. rerender: tryWrap(rerender),
  1920. reload: tryWrap(reload)
  1921. };
  1922. }
  1923. const map = new Map();
  1924. function registerHMR(instance) {
  1925. const id = instance.type.__hmrId;
  1926. let record = map.get(id);
  1927. if (!record) {
  1928. createRecord(id, instance.type);
  1929. record = map.get(id);
  1930. }
  1931. record.instances.add(instance);
  1932. }
  1933. function unregisterHMR(instance) {
  1934. map.get(instance.type.__hmrId).instances.delete(instance);
  1935. }
  1936. function createRecord(id, initialDef) {
  1937. if (map.has(id)) {
  1938. return false;
  1939. }
  1940. map.set(id, {
  1941. initialDef: normalizeClassComponent(initialDef),
  1942. instances: new Set()
  1943. });
  1944. return true;
  1945. }
  1946. function normalizeClassComponent(component) {
  1947. return isClassComponent(component) ? component.__vccOpts : component;
  1948. }
  1949. function rerender(id, newRender) {
  1950. const record = map.get(id);
  1951. if (!record) {
  1952. return;
  1953. }
  1954. // update initial record (for not-yet-rendered component)
  1955. record.initialDef.render = newRender;
  1956. [...record.instances].forEach(instance => {
  1957. if (newRender) {
  1958. instance.render = newRender;
  1959. normalizeClassComponent(instance.type).render = newRender;
  1960. }
  1961. instance.renderCache = [];
  1962. // this flag forces child components with slot content to update
  1963. isHmrUpdating = true;
  1964. instance.update();
  1965. isHmrUpdating = false;
  1966. });
  1967. }
  1968. function reload(id, newComp) {
  1969. const record = map.get(id);
  1970. if (!record)
  1971. return;
  1972. newComp = normalizeClassComponent(newComp);
  1973. // update initial def (for not-yet-rendered components)
  1974. updateComponentDef(record.initialDef, newComp);
  1975. // create a snapshot which avoids the set being mutated during updates
  1976. const instances = [...record.instances];
  1977. for (const instance of instances) {
  1978. const oldComp = normalizeClassComponent(instance.type);
  1979. if (!hmrDirtyComponents.has(oldComp)) {
  1980. // 1. Update existing comp definition to match new one
  1981. if (oldComp !== record.initialDef) {
  1982. updateComponentDef(oldComp, newComp);
  1983. }
  1984. // 2. mark definition dirty. This forces the renderer to replace the
  1985. // component on patch.
  1986. hmrDirtyComponents.add(oldComp);
  1987. }
  1988. // 3. invalidate options resolution cache
  1989. instance.appContext.optionsCache.delete(instance.type);
  1990. // 4. actually update
  1991. if (instance.ceReload) {
  1992. // custom element
  1993. hmrDirtyComponents.add(oldComp);
  1994. instance.ceReload(newComp.styles);
  1995. hmrDirtyComponents.delete(oldComp);
  1996. }
  1997. else if (instance.parent) {
  1998. // 4. Force the parent instance to re-render. This will cause all updated
  1999. // components to be unmounted and re-mounted. Queue the update so that we
  2000. // don't end up forcing the same parent to re-render multiple times.
  2001. queueJob(instance.parent.update);
  2002. }
  2003. else if (instance.appContext.reload) {
  2004. // root instance mounted via createApp() has a reload method
  2005. instance.appContext.reload();
  2006. }
  2007. else if (typeof window !== 'undefined') {
  2008. // root instance inside tree created via raw render(). Force reload.
  2009. window.location.reload();
  2010. }
  2011. else {
  2012. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  2013. }
  2014. }
  2015. // 5. make sure to cleanup dirty hmr components after update
  2016. queuePostFlushCb(() => {
  2017. for (const instance of instances) {
  2018. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  2019. }
  2020. });
  2021. }
  2022. function updateComponentDef(oldComp, newComp) {
  2023. extend(oldComp, newComp);
  2024. for (const key in oldComp) {
  2025. if (key !== '__file' && !(key in newComp)) {
  2026. delete oldComp[key];
  2027. }
  2028. }
  2029. }
  2030. function tryWrap(fn) {
  2031. return (id, arg) => {
  2032. try {
  2033. return fn(id, arg);
  2034. }
  2035. catch (e) {
  2036. console.error(e);
  2037. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  2038. `Full reload required.`);
  2039. }
  2040. };
  2041. }
  2042. let devtools;
  2043. let buffer = [];
  2044. let devtoolsNotInstalled = false;
  2045. function emit(event, ...args) {
  2046. if (devtools) {
  2047. devtools.emit(event, ...args);
  2048. }
  2049. else if (!devtoolsNotInstalled) {
  2050. buffer.push({ event, args });
  2051. }
  2052. }
  2053. function setDevtoolsHook(hook, target) {
  2054. var _a, _b;
  2055. devtools = hook;
  2056. if (devtools) {
  2057. devtools.enabled = true;
  2058. buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
  2059. buffer = [];
  2060. }
  2061. else if (
  2062. // handle late devtools injection - only do this if we are in an actual
  2063. // browser environment to avoid the timer handle stalling test runner exit
  2064. // (#4815)
  2065. typeof window !== 'undefined' &&
  2066. // some envs mock window but not fully
  2067. window.HTMLElement &&
  2068. // also exclude jsdom
  2069. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  2070. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  2071. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  2072. replay.push((newHook) => {
  2073. setDevtoolsHook(newHook, target);
  2074. });
  2075. // clear buffer after 3s - the user probably doesn't have devtools installed
  2076. // at all, and keeping the buffer will cause memory leaks (#4738)
  2077. setTimeout(() => {
  2078. if (!devtools) {
  2079. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2080. devtoolsNotInstalled = true;
  2081. buffer = [];
  2082. }
  2083. }, 3000);
  2084. }
  2085. else {
  2086. // non-browser env, assume not installed
  2087. devtoolsNotInstalled = true;
  2088. buffer = [];
  2089. }
  2090. }
  2091. function devtoolsInitApp(app, version) {
  2092. emit("app:init" /* DevtoolsHooks.APP_INIT */, app, version, {
  2093. Fragment,
  2094. Text,
  2095. Comment,
  2096. Static
  2097. });
  2098. }
  2099. function devtoolsUnmountApp(app) {
  2100. emit("app:unmount" /* DevtoolsHooks.APP_UNMOUNT */, app);
  2101. }
  2102. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* DevtoolsHooks.COMPONENT_ADDED */);
  2103. const devtoolsComponentUpdated =
  2104. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* DevtoolsHooks.COMPONENT_UPDATED */);
  2105. const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* DevtoolsHooks.COMPONENT_REMOVED */);
  2106. const devtoolsComponentRemoved = (component) => {
  2107. if (devtools &&
  2108. typeof devtools.cleanupBuffer === 'function' &&
  2109. // remove the component if it wasn't buffered
  2110. !devtools.cleanupBuffer(component)) {
  2111. _devtoolsComponentRemoved(component);
  2112. }
  2113. };
  2114. function createDevtoolsComponentHook(hook) {
  2115. return (component) => {
  2116. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  2117. };
  2118. }
  2119. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* DevtoolsHooks.PERFORMANCE_START */);
  2120. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* DevtoolsHooks.PERFORMANCE_END */);
  2121. function createDevtoolsPerformanceHook(hook) {
  2122. return (component, type, time) => {
  2123. emit(hook, component.appContext.app, component.uid, component, type, time);
  2124. };
  2125. }
  2126. function devtoolsComponentEmit(component, event, params) {
  2127. emit("component:emit" /* DevtoolsHooks.COMPONENT_EMIT */, component.appContext.app, component, event, params);
  2128. }
  2129. function emit$1(instance, event, ...rawArgs) {
  2130. if (instance.isUnmounted)
  2131. return;
  2132. const props = instance.vnode.props || EMPTY_OBJ;
  2133. {
  2134. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  2135. if (emitsOptions) {
  2136. if (!(event in emitsOptions) &&
  2137. !(false )) {
  2138. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2139. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  2140. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  2141. }
  2142. }
  2143. else {
  2144. const validator = emitsOptions[event];
  2145. if (isFunction(validator)) {
  2146. const isValid = validator(...rawArgs);
  2147. if (!isValid) {
  2148. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  2149. }
  2150. }
  2151. }
  2152. }
  2153. }
  2154. let args = rawArgs;
  2155. const isModelListener = event.startsWith('update:');
  2156. // for v-model update:xxx events, apply modifiers on args
  2157. const modelArg = isModelListener && event.slice(7);
  2158. if (modelArg && modelArg in props) {
  2159. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  2160. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2161. if (trim) {
  2162. args = rawArgs.map(a => (isString(a) ? a.trim() : a));
  2163. }
  2164. if (number) {
  2165. args = rawArgs.map(toNumber);
  2166. }
  2167. }
  2168. {
  2169. devtoolsComponentEmit(instance, event, args);
  2170. }
  2171. {
  2172. const lowerCaseEvent = event.toLowerCase();
  2173. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2174. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  2175. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  2176. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2177. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2178. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2179. }
  2180. }
  2181. let handlerName;
  2182. let handler = props[(handlerName = toHandlerKey(event))] ||
  2183. // also try camelCase event handler (#2249)
  2184. props[(handlerName = toHandlerKey(camelize(event)))];
  2185. // for v-model update:xxx events, also trigger kebab-case equivalent
  2186. // for props passed via kebab-case
  2187. if (!handler && isModelListener) {
  2188. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  2189. }
  2190. if (handler) {
  2191. callWithAsyncErrorHandling(handler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  2192. }
  2193. const onceHandler = props[handlerName + `Once`];
  2194. if (onceHandler) {
  2195. if (!instance.emitted) {
  2196. instance.emitted = {};
  2197. }
  2198. else if (instance.emitted[handlerName]) {
  2199. return;
  2200. }
  2201. instance.emitted[handlerName] = true;
  2202. callWithAsyncErrorHandling(onceHandler, instance, 6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */, args);
  2203. }
  2204. }
  2205. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2206. const cache = appContext.emitsCache;
  2207. const cached = cache.get(comp);
  2208. if (cached !== undefined) {
  2209. return cached;
  2210. }
  2211. const raw = comp.emits;
  2212. let normalized = {};
  2213. // apply mixin/extends props
  2214. let hasExtends = false;
  2215. if (!isFunction(comp)) {
  2216. const extendEmits = (raw) => {
  2217. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  2218. if (normalizedFromExtend) {
  2219. hasExtends = true;
  2220. extend(normalized, normalizedFromExtend);
  2221. }
  2222. };
  2223. if (!asMixin && appContext.mixins.length) {
  2224. appContext.mixins.forEach(extendEmits);
  2225. }
  2226. if (comp.extends) {
  2227. extendEmits(comp.extends);
  2228. }
  2229. if (comp.mixins) {
  2230. comp.mixins.forEach(extendEmits);
  2231. }
  2232. }
  2233. if (!raw && !hasExtends) {
  2234. if (isObject(comp)) {
  2235. cache.set(comp, null);
  2236. }
  2237. return null;
  2238. }
  2239. if (isArray(raw)) {
  2240. raw.forEach(key => (normalized[key] = null));
  2241. }
  2242. else {
  2243. extend(normalized, raw);
  2244. }
  2245. if (isObject(comp)) {
  2246. cache.set(comp, normalized);
  2247. }
  2248. return normalized;
  2249. }
  2250. // Check if an incoming prop key is a declared emit event listener.
  2251. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  2252. // both considered matched listeners.
  2253. function isEmitListener(options, key) {
  2254. if (!options || !isOn(key)) {
  2255. return false;
  2256. }
  2257. key = key.slice(2).replace(/Once$/, '');
  2258. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  2259. hasOwn(options, hyphenate(key)) ||
  2260. hasOwn(options, key));
  2261. }
  2262. /**
  2263. * mark the current rendering instance for asset resolution (e.g.
  2264. * resolveComponent, resolveDirective) during render
  2265. */
  2266. let currentRenderingInstance = null;
  2267. let currentScopeId = null;
  2268. /**
  2269. * Note: rendering calls maybe nested. The function returns the parent rendering
  2270. * instance if present, which should be restored after the render is done:
  2271. *
  2272. * ```js
  2273. * const prev = setCurrentRenderingInstance(i)
  2274. * // ...render
  2275. * setCurrentRenderingInstance(prev)
  2276. * ```
  2277. */
  2278. function setCurrentRenderingInstance(instance) {
  2279. const prev = currentRenderingInstance;
  2280. currentRenderingInstance = instance;
  2281. currentScopeId = (instance && instance.type.__scopeId) || null;
  2282. return prev;
  2283. }
  2284. /**
  2285. * Set scope id when creating hoisted vnodes.
  2286. * @private compiler helper
  2287. */
  2288. function pushScopeId(id) {
  2289. currentScopeId = id;
  2290. }
  2291. /**
  2292. * Technically we no longer need this after 3.0.8 but we need to keep the same
  2293. * API for backwards compat w/ code generated by compilers.
  2294. * @private
  2295. */
  2296. function popScopeId() {
  2297. currentScopeId = null;
  2298. }
  2299. /**
  2300. * Only for backwards compat
  2301. * @private
  2302. */
  2303. const withScopeId = (_id) => withCtx;
  2304. /**
  2305. * Wrap a slot function to memoize current rendering instance
  2306. * @private compiler helper
  2307. */
  2308. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  2309. ) {
  2310. if (!ctx)
  2311. return fn;
  2312. // already normalized
  2313. if (fn._n) {
  2314. return fn;
  2315. }
  2316. const renderFnWithContext = (...args) => {
  2317. // If a user calls a compiled slot inside a template expression (#1745), it
  2318. // can mess up block tracking, so by default we disable block tracking and
  2319. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  2320. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  2321. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  2322. if (renderFnWithContext._d) {
  2323. setBlockTracking(-1);
  2324. }
  2325. const prevInstance = setCurrentRenderingInstance(ctx);
  2326. let res;
  2327. try {
  2328. res = fn(...args);
  2329. }
  2330. finally {
  2331. setCurrentRenderingInstance(prevInstance);
  2332. if (renderFnWithContext._d) {
  2333. setBlockTracking(1);
  2334. }
  2335. }
  2336. {
  2337. devtoolsComponentUpdated(ctx);
  2338. }
  2339. return res;
  2340. };
  2341. // mark normalized to avoid duplicated wrapping
  2342. renderFnWithContext._n = true;
  2343. // mark this as compiled by default
  2344. // this is used in vnode.ts -> normalizeChildren() to set the slot
  2345. // rendering flag.
  2346. renderFnWithContext._c = true;
  2347. // disable block tracking by default
  2348. renderFnWithContext._d = true;
  2349. return renderFnWithContext;
  2350. }
  2351. /**
  2352. * dev only flag to track whether $attrs was used during render.
  2353. * If $attrs was used during render then the warning for failed attrs
  2354. * fallthrough can be suppressed.
  2355. */
  2356. let accessedAttrs = false;
  2357. function markAttrsAccessed() {
  2358. accessedAttrs = true;
  2359. }
  2360. function renderComponentRoot(instance) {
  2361. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  2362. let result;
  2363. let fallthroughAttrs;
  2364. const prev = setCurrentRenderingInstance(instance);
  2365. {
  2366. accessedAttrs = false;
  2367. }
  2368. try {
  2369. if (vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) {
  2370. // withProxy is a proxy with a different `has` trap only for
  2371. // runtime-compiled render functions using `with` block.
  2372. const proxyToUse = withProxy || proxy;
  2373. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  2374. fallthroughAttrs = attrs;
  2375. }
  2376. else {
  2377. // functional
  2378. const render = Component;
  2379. // in dev, mark attrs accessed if optional props (attrs === props)
  2380. if (true && attrs === props) {
  2381. markAttrsAccessed();
  2382. }
  2383. result = normalizeVNode(render.length > 1
  2384. ? render(props, true
  2385. ? {
  2386. get attrs() {
  2387. markAttrsAccessed();
  2388. return attrs;
  2389. },
  2390. slots,
  2391. emit
  2392. }
  2393. : { attrs, slots, emit })
  2394. : render(props, null /* we know it doesn't need it */));
  2395. fallthroughAttrs = Component.props
  2396. ? attrs
  2397. : getFunctionalFallthrough(attrs);
  2398. }
  2399. }
  2400. catch (err) {
  2401. blockStack.length = 0;
  2402. handleError(err, instance, 1 /* ErrorCodes.RENDER_FUNCTION */);
  2403. result = createVNode(Comment);
  2404. }
  2405. // attr merging
  2406. // in dev mode, comments are preserved, and it's possible for a template
  2407. // to have comments along side the root element which makes it a fragment
  2408. let root = result;
  2409. let setRoot = undefined;
  2410. if (result.patchFlag > 0 &&
  2411. result.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
  2412. [root, setRoot] = getChildRoot(result);
  2413. }
  2414. if (fallthroughAttrs && inheritAttrs !== false) {
  2415. const keys = Object.keys(fallthroughAttrs);
  2416. const { shapeFlag } = root;
  2417. if (keys.length) {
  2418. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 6 /* ShapeFlags.COMPONENT */)) {
  2419. if (propsOptions && keys.some(isModelListener)) {
  2420. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  2421. // prop, it indicates this component expects to handle v-model and
  2422. // it should not fallthrough.
  2423. // related: #1543, #1643, #1989
  2424. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  2425. }
  2426. root = cloneVNode(root, fallthroughAttrs);
  2427. }
  2428. else if (!accessedAttrs && root.type !== Comment) {
  2429. const allAttrs = Object.keys(attrs);
  2430. const eventAttrs = [];
  2431. const extraAttrs = [];
  2432. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2433. const key = allAttrs[i];
  2434. if (isOn(key)) {
  2435. // ignore v-model handlers when they fail to fallthrough
  2436. if (!isModelListener(key)) {
  2437. // remove `on`, lowercase first letter to reflect event casing
  2438. // accurately
  2439. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2440. }
  2441. }
  2442. else {
  2443. extraAttrs.push(key);
  2444. }
  2445. }
  2446. if (extraAttrs.length) {
  2447. warn$1(`Extraneous non-props attributes (` +
  2448. `${extraAttrs.join(', ')}) ` +
  2449. `were passed to component but could not be automatically inherited ` +
  2450. `because component renders fragment or text root nodes.`);
  2451. }
  2452. if (eventAttrs.length) {
  2453. warn$1(`Extraneous non-emits event listeners (` +
  2454. `${eventAttrs.join(', ')}) ` +
  2455. `were passed to component but could not be automatically inherited ` +
  2456. `because component renders fragment or text root nodes. ` +
  2457. `If the listener is intended to be a component custom event listener only, ` +
  2458. `declare it using the "emits" option.`);
  2459. }
  2460. }
  2461. }
  2462. }
  2463. // inherit directives
  2464. if (vnode.dirs) {
  2465. if (!isElementRoot(root)) {
  2466. warn$1(`Runtime directive used on component with non-element root node. ` +
  2467. `The directives will not function as intended.`);
  2468. }
  2469. // clone before mutating since the root may be a hoisted vnode
  2470. root = cloneVNode(root);
  2471. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2472. }
  2473. // inherit transition data
  2474. if (vnode.transition) {
  2475. if (!isElementRoot(root)) {
  2476. warn$1(`Component inside <Transition> renders non-element root node ` +
  2477. `that cannot be animated.`);
  2478. }
  2479. root.transition = vnode.transition;
  2480. }
  2481. if (setRoot) {
  2482. setRoot(root);
  2483. }
  2484. else {
  2485. result = root;
  2486. }
  2487. setCurrentRenderingInstance(prev);
  2488. return result;
  2489. }
  2490. /**
  2491. * dev only
  2492. * In dev mode, template root level comments are rendered, which turns the
  2493. * template into a fragment root, but we need to locate the single element
  2494. * root for attrs and scope id processing.
  2495. */
  2496. const getChildRoot = (vnode) => {
  2497. const rawChildren = vnode.children;
  2498. const dynamicChildren = vnode.dynamicChildren;
  2499. const childRoot = filterSingleRoot(rawChildren);
  2500. if (!childRoot) {
  2501. return [vnode, undefined];
  2502. }
  2503. const index = rawChildren.indexOf(childRoot);
  2504. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2505. const setRoot = (updatedRoot) => {
  2506. rawChildren[index] = updatedRoot;
  2507. if (dynamicChildren) {
  2508. if (dynamicIndex > -1) {
  2509. dynamicChildren[dynamicIndex] = updatedRoot;
  2510. }
  2511. else if (updatedRoot.patchFlag > 0) {
  2512. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2513. }
  2514. }
  2515. };
  2516. return [normalizeVNode(childRoot), setRoot];
  2517. };
  2518. function filterSingleRoot(children) {
  2519. let singleRoot;
  2520. for (let i = 0; i < children.length; i++) {
  2521. const child = children[i];
  2522. if (isVNode(child)) {
  2523. // ignore user comment
  2524. if (child.type !== Comment || child.children === 'v-if') {
  2525. if (singleRoot) {
  2526. // has more than 1 non-comment child, return now
  2527. return;
  2528. }
  2529. else {
  2530. singleRoot = child;
  2531. }
  2532. }
  2533. }
  2534. else {
  2535. return;
  2536. }
  2537. }
  2538. return singleRoot;
  2539. }
  2540. const getFunctionalFallthrough = (attrs) => {
  2541. let res;
  2542. for (const key in attrs) {
  2543. if (key === 'class' || key === 'style' || isOn(key)) {
  2544. (res || (res = {}))[key] = attrs[key];
  2545. }
  2546. }
  2547. return res;
  2548. };
  2549. const filterModelListeners = (attrs, props) => {
  2550. const res = {};
  2551. for (const key in attrs) {
  2552. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2553. res[key] = attrs[key];
  2554. }
  2555. }
  2556. return res;
  2557. };
  2558. const isElementRoot = (vnode) => {
  2559. return (vnode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 1 /* ShapeFlags.ELEMENT */) ||
  2560. vnode.type === Comment // potential v-if branch switch
  2561. );
  2562. };
  2563. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2564. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2565. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2566. const emits = component.emitsOptions;
  2567. // Parent component's render function was hot-updated. Since this may have
  2568. // caused the child component's slots content to have changed, we need to
  2569. // force the child to update as well.
  2570. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2571. return true;
  2572. }
  2573. // force child update for runtime directive or transition on component vnode.
  2574. if (nextVNode.dirs || nextVNode.transition) {
  2575. return true;
  2576. }
  2577. if (optimized && patchFlag >= 0) {
  2578. if (patchFlag & 1024 /* PatchFlags.DYNAMIC_SLOTS */) {
  2579. // slot content that references values that might have changed,
  2580. // e.g. in a v-for
  2581. return true;
  2582. }
  2583. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  2584. if (!prevProps) {
  2585. return !!nextProps;
  2586. }
  2587. // presence of this flag indicates props are always non-null
  2588. return hasPropsChanged(prevProps, nextProps, emits);
  2589. }
  2590. else if (patchFlag & 8 /* PatchFlags.PROPS */) {
  2591. const dynamicProps = nextVNode.dynamicProps;
  2592. for (let i = 0; i < dynamicProps.length; i++) {
  2593. const key = dynamicProps[i];
  2594. if (nextProps[key] !== prevProps[key] &&
  2595. !isEmitListener(emits, key)) {
  2596. return true;
  2597. }
  2598. }
  2599. }
  2600. }
  2601. else {
  2602. // this path is only taken by manually written render functions
  2603. // so presence of any children leads to a forced update
  2604. if (prevChildren || nextChildren) {
  2605. if (!nextChildren || !nextChildren.$stable) {
  2606. return true;
  2607. }
  2608. }
  2609. if (prevProps === nextProps) {
  2610. return false;
  2611. }
  2612. if (!prevProps) {
  2613. return !!nextProps;
  2614. }
  2615. if (!nextProps) {
  2616. return true;
  2617. }
  2618. return hasPropsChanged(prevProps, nextProps, emits);
  2619. }
  2620. return false;
  2621. }
  2622. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2623. const nextKeys = Object.keys(nextProps);
  2624. if (nextKeys.length !== Object.keys(prevProps).length) {
  2625. return true;
  2626. }
  2627. for (let i = 0; i < nextKeys.length; i++) {
  2628. const key = nextKeys[i];
  2629. if (nextProps[key] !== prevProps[key] &&
  2630. !isEmitListener(emitsOptions, key)) {
  2631. return true;
  2632. }
  2633. }
  2634. return false;
  2635. }
  2636. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2637. ) {
  2638. while (parent && parent.subTree === vnode) {
  2639. (vnode = parent.vnode).el = el;
  2640. parent = parent.parent;
  2641. }
  2642. }
  2643. const isSuspense = (type) => type.__isSuspense;
  2644. // Suspense exposes a component-like API, and is treated like a component
  2645. // in the compiler, but internally it's a special built-in type that hooks
  2646. // directly into the renderer.
  2647. const SuspenseImpl = {
  2648. name: 'Suspense',
  2649. // In order to make Suspense tree-shakable, we need to avoid importing it
  2650. // directly in the renderer. The renderer checks for the __isSuspense flag
  2651. // on a vnode's type and calls the `process` method, passing in renderer
  2652. // internals.
  2653. __isSuspense: true,
  2654. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2655. // platform-specific impl passed from renderer
  2656. rendererInternals) {
  2657. if (n1 == null) {
  2658. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2659. }
  2660. else {
  2661. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2662. }
  2663. },
  2664. hydrate: hydrateSuspense,
  2665. create: createSuspenseBoundary,
  2666. normalize: normalizeSuspenseChildren
  2667. };
  2668. // Force-casted public typing for h and TSX props inference
  2669. const Suspense = (SuspenseImpl
  2670. );
  2671. function triggerEvent(vnode, name) {
  2672. const eventListener = vnode.props && vnode.props[name];
  2673. if (isFunction(eventListener)) {
  2674. eventListener();
  2675. }
  2676. }
  2677. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2678. const { p: patch, o: { createElement } } = rendererInternals;
  2679. const hiddenContainer = createElement('div');
  2680. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2681. // start mounting the content subtree in an off-dom container
  2682. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2683. // now check if we have encountered any async deps
  2684. if (suspense.deps > 0) {
  2685. // has async
  2686. // invoke @fallback event
  2687. triggerEvent(vnode, 'onPending');
  2688. triggerEvent(vnode, 'onFallback');
  2689. // mount the fallback tree
  2690. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2691. isSVG, slotScopeIds);
  2692. setActiveBranch(suspense, vnode.ssFallback);
  2693. }
  2694. else {
  2695. // Suspense has no async deps. Just resolve.
  2696. suspense.resolve();
  2697. }
  2698. }
  2699. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2700. const suspense = (n2.suspense = n1.suspense);
  2701. suspense.vnode = n2;
  2702. n2.el = n1.el;
  2703. const newBranch = n2.ssContent;
  2704. const newFallback = n2.ssFallback;
  2705. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2706. if (pendingBranch) {
  2707. suspense.pendingBranch = newBranch;
  2708. if (isSameVNodeType(newBranch, pendingBranch)) {
  2709. // same root type but content may have changed.
  2710. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2711. if (suspense.deps <= 0) {
  2712. suspense.resolve();
  2713. }
  2714. else if (isInFallback) {
  2715. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2716. isSVG, slotScopeIds, optimized);
  2717. setActiveBranch(suspense, newFallback);
  2718. }
  2719. }
  2720. else {
  2721. // toggled before pending tree is resolved
  2722. suspense.pendingId++;
  2723. if (isHydrating) {
  2724. // if toggled before hydration is finished, the current DOM tree is
  2725. // no longer valid. set it as the active branch so it will be unmounted
  2726. // when resolved
  2727. suspense.isHydrating = false;
  2728. suspense.activeBranch = pendingBranch;
  2729. }
  2730. else {
  2731. unmount(pendingBranch, parentComponent, suspense);
  2732. }
  2733. // increment pending ID. this is used to invalidate async callbacks
  2734. // reset suspense state
  2735. suspense.deps = 0;
  2736. // discard effects from pending branch
  2737. suspense.effects.length = 0;
  2738. // discard previous container
  2739. suspense.hiddenContainer = createElement('div');
  2740. if (isInFallback) {
  2741. // already in fallback state
  2742. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2743. if (suspense.deps <= 0) {
  2744. suspense.resolve();
  2745. }
  2746. else {
  2747. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2748. isSVG, slotScopeIds, optimized);
  2749. setActiveBranch(suspense, newFallback);
  2750. }
  2751. }
  2752. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2753. // toggled "back" to current active branch
  2754. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2755. // force resolve
  2756. suspense.resolve(true);
  2757. }
  2758. else {
  2759. // switched to a 3rd branch
  2760. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2761. if (suspense.deps <= 0) {
  2762. suspense.resolve();
  2763. }
  2764. }
  2765. }
  2766. }
  2767. else {
  2768. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2769. // root did not change, just normal patch
  2770. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2771. setActiveBranch(suspense, newBranch);
  2772. }
  2773. else {
  2774. // root node toggled
  2775. // invoke @pending event
  2776. triggerEvent(n2, 'onPending');
  2777. // mount pending branch in off-dom container
  2778. suspense.pendingBranch = newBranch;
  2779. suspense.pendingId++;
  2780. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2781. if (suspense.deps <= 0) {
  2782. // incoming branch has no async deps, resolve now.
  2783. suspense.resolve();
  2784. }
  2785. else {
  2786. const { timeout, pendingId } = suspense;
  2787. if (timeout > 0) {
  2788. setTimeout(() => {
  2789. if (suspense.pendingId === pendingId) {
  2790. suspense.fallback(newFallback);
  2791. }
  2792. }, timeout);
  2793. }
  2794. else if (timeout === 0) {
  2795. suspense.fallback(newFallback);
  2796. }
  2797. }
  2798. }
  2799. }
  2800. }
  2801. let hasWarned = false;
  2802. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2803. /* istanbul ignore if */
  2804. if (!hasWarned) {
  2805. hasWarned = true;
  2806. // @ts-ignore `console.info` cannot be null error
  2807. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2808. }
  2809. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2810. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2811. const suspense = {
  2812. vnode,
  2813. parent,
  2814. parentComponent,
  2815. isSVG,
  2816. container,
  2817. hiddenContainer,
  2818. anchor,
  2819. deps: 0,
  2820. pendingId: 0,
  2821. timeout: typeof timeout === 'number' ? timeout : -1,
  2822. activeBranch: null,
  2823. pendingBranch: null,
  2824. isInFallback: true,
  2825. isHydrating,
  2826. isUnmounted: false,
  2827. effects: [],
  2828. resolve(resume = false) {
  2829. {
  2830. if (!resume && !suspense.pendingBranch) {
  2831. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2832. }
  2833. if (suspense.isUnmounted) {
  2834. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2835. }
  2836. }
  2837. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2838. if (suspense.isHydrating) {
  2839. suspense.isHydrating = false;
  2840. }
  2841. else if (!resume) {
  2842. const delayEnter = activeBranch &&
  2843. pendingBranch.transition &&
  2844. pendingBranch.transition.mode === 'out-in';
  2845. if (delayEnter) {
  2846. activeBranch.transition.afterLeave = () => {
  2847. if (pendingId === suspense.pendingId) {
  2848. move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
  2849. }
  2850. };
  2851. }
  2852. // this is initial anchor on mount
  2853. let { anchor } = suspense;
  2854. // unmount current active tree
  2855. if (activeBranch) {
  2856. // if the fallback tree was mounted, it may have been moved
  2857. // as part of a parent suspense. get the latest anchor for insertion
  2858. anchor = next(activeBranch);
  2859. unmount(activeBranch, parentComponent, suspense, true);
  2860. }
  2861. if (!delayEnter) {
  2862. // move content from off-dom container to actual container
  2863. move(pendingBranch, container, anchor, 0 /* MoveType.ENTER */);
  2864. }
  2865. }
  2866. setActiveBranch(suspense, pendingBranch);
  2867. suspense.pendingBranch = null;
  2868. suspense.isInFallback = false;
  2869. // flush buffered effects
  2870. // check if there is a pending parent suspense
  2871. let parent = suspense.parent;
  2872. let hasUnresolvedAncestor = false;
  2873. while (parent) {
  2874. if (parent.pendingBranch) {
  2875. // found a pending parent suspense, merge buffered post jobs
  2876. // into that parent
  2877. parent.effects.push(...effects);
  2878. hasUnresolvedAncestor = true;
  2879. break;
  2880. }
  2881. parent = parent.parent;
  2882. }
  2883. // no pending parent suspense, flush all jobs
  2884. if (!hasUnresolvedAncestor) {
  2885. queuePostFlushCb(effects);
  2886. }
  2887. suspense.effects = [];
  2888. // invoke @resolve event
  2889. triggerEvent(vnode, 'onResolve');
  2890. },
  2891. fallback(fallbackVNode) {
  2892. if (!suspense.pendingBranch) {
  2893. return;
  2894. }
  2895. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2896. // invoke @fallback event
  2897. triggerEvent(vnode, 'onFallback');
  2898. const anchor = next(activeBranch);
  2899. const mountFallback = () => {
  2900. if (!suspense.isInFallback) {
  2901. return;
  2902. }
  2903. // mount the fallback tree
  2904. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2905. isSVG, slotScopeIds, optimized);
  2906. setActiveBranch(suspense, fallbackVNode);
  2907. };
  2908. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2909. if (delayEnter) {
  2910. activeBranch.transition.afterLeave = mountFallback;
  2911. }
  2912. suspense.isInFallback = true;
  2913. // unmount current active branch
  2914. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2915. true // shouldRemove
  2916. );
  2917. if (!delayEnter) {
  2918. mountFallback();
  2919. }
  2920. },
  2921. move(container, anchor, type) {
  2922. suspense.activeBranch &&
  2923. move(suspense.activeBranch, container, anchor, type);
  2924. suspense.container = container;
  2925. },
  2926. next() {
  2927. return suspense.activeBranch && next(suspense.activeBranch);
  2928. },
  2929. registerDep(instance, setupRenderEffect) {
  2930. const isInPendingSuspense = !!suspense.pendingBranch;
  2931. if (isInPendingSuspense) {
  2932. suspense.deps++;
  2933. }
  2934. const hydratedEl = instance.vnode.el;
  2935. instance
  2936. .asyncDep.catch(err => {
  2937. handleError(err, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  2938. })
  2939. .then(asyncSetupResult => {
  2940. // retry when the setup() promise resolves.
  2941. // component may have been unmounted before resolve.
  2942. if (instance.isUnmounted ||
  2943. suspense.isUnmounted ||
  2944. suspense.pendingId !== instance.suspenseId) {
  2945. return;
  2946. }
  2947. // retry from this component
  2948. instance.asyncResolved = true;
  2949. const { vnode } = instance;
  2950. {
  2951. pushWarningContext(vnode);
  2952. }
  2953. handleSetupResult(instance, asyncSetupResult, false);
  2954. if (hydratedEl) {
  2955. // vnode may have been replaced if an update happened before the
  2956. // async dep is resolved.
  2957. vnode.el = hydratedEl;
  2958. }
  2959. const placeholder = !hydratedEl && instance.subTree.el;
  2960. setupRenderEffect(instance, vnode,
  2961. // component may have been moved before resolve.
  2962. // if this is not a hydration, instance.subTree will be the comment
  2963. // placeholder.
  2964. parentNode(hydratedEl || instance.subTree.el),
  2965. // anchor will not be used if this is hydration, so only need to
  2966. // consider the comment placeholder case.
  2967. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2968. if (placeholder) {
  2969. remove(placeholder);
  2970. }
  2971. updateHOCHostEl(instance, vnode.el);
  2972. {
  2973. popWarningContext();
  2974. }
  2975. // only decrease deps count if suspense is not already resolved
  2976. if (isInPendingSuspense && --suspense.deps === 0) {
  2977. suspense.resolve();
  2978. }
  2979. });
  2980. },
  2981. unmount(parentSuspense, doRemove) {
  2982. suspense.isUnmounted = true;
  2983. if (suspense.activeBranch) {
  2984. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2985. }
  2986. if (suspense.pendingBranch) {
  2987. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2988. }
  2989. }
  2990. };
  2991. return suspense;
  2992. }
  2993. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2994. /* eslint-disable no-restricted-globals */
  2995. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2996. // there are two possible scenarios for server-rendered suspense:
  2997. // - success: ssr content should be fully resolved
  2998. // - failure: ssr content should be the fallback branch.
  2999. // however, on the client we don't really know if it has failed or not
  3000. // attempt to hydrate the DOM assuming it has succeeded, but we still
  3001. // need to construct a suspense boundary first
  3002. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  3003. if (suspense.deps === 0) {
  3004. suspense.resolve();
  3005. }
  3006. return result;
  3007. /* eslint-enable no-restricted-globals */
  3008. }
  3009. function normalizeSuspenseChildren(vnode) {
  3010. const { shapeFlag, children } = vnode;
  3011. const isSlotChildren = shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */;
  3012. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  3013. vnode.ssFallback = isSlotChildren
  3014. ? normalizeSuspenseSlot(children.fallback)
  3015. : createVNode(Comment);
  3016. }
  3017. function normalizeSuspenseSlot(s) {
  3018. let block;
  3019. if (isFunction(s)) {
  3020. const trackBlock = isBlockTreeEnabled && s._c;
  3021. if (trackBlock) {
  3022. // disableTracking: false
  3023. // allow block tracking for compiled slots
  3024. // (see ./componentRenderContext.ts)
  3025. s._d = false;
  3026. openBlock();
  3027. }
  3028. s = s();
  3029. if (trackBlock) {
  3030. s._d = true;
  3031. block = currentBlock;
  3032. closeBlock();
  3033. }
  3034. }
  3035. if (isArray(s)) {
  3036. const singleChild = filterSingleRoot(s);
  3037. if (!singleChild) {
  3038. warn$1(`<Suspense> slots expect a single root node.`);
  3039. }
  3040. s = singleChild;
  3041. }
  3042. s = normalizeVNode(s);
  3043. if (block && !s.dynamicChildren) {
  3044. s.dynamicChildren = block.filter(c => c !== s);
  3045. }
  3046. return s;
  3047. }
  3048. function queueEffectWithSuspense(fn, suspense) {
  3049. if (suspense && suspense.pendingBranch) {
  3050. if (isArray(fn)) {
  3051. suspense.effects.push(...fn);
  3052. }
  3053. else {
  3054. suspense.effects.push(fn);
  3055. }
  3056. }
  3057. else {
  3058. queuePostFlushCb(fn);
  3059. }
  3060. }
  3061. function setActiveBranch(suspense, branch) {
  3062. suspense.activeBranch = branch;
  3063. const { vnode, parentComponent } = suspense;
  3064. const el = (vnode.el = branch.el);
  3065. // in case suspense is the root node of a component,
  3066. // recursively update the HOC el
  3067. if (parentComponent && parentComponent.subTree === vnode) {
  3068. parentComponent.vnode.el = el;
  3069. updateHOCHostEl(parentComponent, el);
  3070. }
  3071. }
  3072. function provide(key, value) {
  3073. if (!currentInstance) {
  3074. {
  3075. warn$1(`provide() can only be used inside setup().`);
  3076. }
  3077. }
  3078. else {
  3079. let provides = currentInstance.provides;
  3080. // by default an instance inherits its parent's provides object
  3081. // but when it needs to provide values of its own, it creates its
  3082. // own provides object using parent provides object as prototype.
  3083. // this way in `inject` we can simply look up injections from direct
  3084. // parent and let the prototype chain do the work.
  3085. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3086. if (parentProvides === provides) {
  3087. provides = currentInstance.provides = Object.create(parentProvides);
  3088. }
  3089. // TS doesn't allow symbol as index type
  3090. provides[key] = value;
  3091. }
  3092. }
  3093. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3094. // fallback to `currentRenderingInstance` so that this can be called in
  3095. // a functional component
  3096. const instance = currentInstance || currentRenderingInstance;
  3097. if (instance) {
  3098. // #2400
  3099. // to support `app.use` plugins,
  3100. // fallback to appContext's `provides` if the instance is at root
  3101. const provides = instance.parent == null
  3102. ? instance.vnode.appContext && instance.vnode.appContext.provides
  3103. : instance.parent.provides;
  3104. if (provides && key in provides) {
  3105. // TS doesn't allow symbol as index type
  3106. return provides[key];
  3107. }
  3108. else if (arguments.length > 1) {
  3109. return treatDefaultAsFactory && isFunction(defaultValue)
  3110. ? defaultValue.call(instance.proxy)
  3111. : defaultValue;
  3112. }
  3113. else {
  3114. warn$1(`injection "${String(key)}" not found.`);
  3115. }
  3116. }
  3117. else {
  3118. warn$1(`inject() can only be used inside setup() or functional components.`);
  3119. }
  3120. }
  3121. // Simple effect.
  3122. function watchEffect(effect, options) {
  3123. return doWatch(effect, null, options);
  3124. }
  3125. function watchPostEffect(effect, options) {
  3126. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3127. }
  3128. function watchSyncEffect(effect, options) {
  3129. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3130. }
  3131. // initial value for watchers to trigger on undefined initial values
  3132. const INITIAL_WATCHER_VALUE = {};
  3133. // implementation
  3134. function watch(source, cb, options) {
  3135. if (!isFunction(cb)) {
  3136. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3137. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3138. `supports \`watch(source, cb, options?) signature.`);
  3139. }
  3140. return doWatch(source, cb, options);
  3141. }
  3142. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3143. if (!cb) {
  3144. if (immediate !== undefined) {
  3145. warn$1(`watch() "immediate" option is only respected when using the ` +
  3146. `watch(source, callback, options?) signature.`);
  3147. }
  3148. if (deep !== undefined) {
  3149. warn$1(`watch() "deep" option is only respected when using the ` +
  3150. `watch(source, callback, options?) signature.`);
  3151. }
  3152. }
  3153. const warnInvalidSource = (s) => {
  3154. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  3155. `a reactive object, or an array of these types.`);
  3156. };
  3157. const instance = currentInstance;
  3158. let getter;
  3159. let forceTrigger = false;
  3160. let isMultiSource = false;
  3161. if (isRef(source)) {
  3162. getter = () => source.value;
  3163. forceTrigger = isShallow(source);
  3164. }
  3165. else if (isReactive(source)) {
  3166. getter = () => source;
  3167. deep = true;
  3168. }
  3169. else if (isArray(source)) {
  3170. isMultiSource = true;
  3171. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3172. getter = () => source.map(s => {
  3173. if (isRef(s)) {
  3174. return s.value;
  3175. }
  3176. else if (isReactive(s)) {
  3177. return traverse(s);
  3178. }
  3179. else if (isFunction(s)) {
  3180. return callWithErrorHandling(s, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  3181. }
  3182. else {
  3183. warnInvalidSource(s);
  3184. }
  3185. });
  3186. }
  3187. else if (isFunction(source)) {
  3188. if (cb) {
  3189. // getter with cb
  3190. getter = () => callWithErrorHandling(source, instance, 2 /* ErrorCodes.WATCH_GETTER */);
  3191. }
  3192. else {
  3193. // no cb -> simple effect
  3194. getter = () => {
  3195. if (instance && instance.isUnmounted) {
  3196. return;
  3197. }
  3198. if (cleanup) {
  3199. cleanup();
  3200. }
  3201. return callWithAsyncErrorHandling(source, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [onCleanup]);
  3202. };
  3203. }
  3204. }
  3205. else {
  3206. getter = NOOP;
  3207. warnInvalidSource(source);
  3208. }
  3209. if (cb && deep) {
  3210. const baseGetter = getter;
  3211. getter = () => traverse(baseGetter());
  3212. }
  3213. let cleanup;
  3214. let onCleanup = (fn) => {
  3215. cleanup = effect.onStop = () => {
  3216. callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
  3217. };
  3218. };
  3219. let oldValue = isMultiSource
  3220. ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
  3221. : INITIAL_WATCHER_VALUE;
  3222. const job = () => {
  3223. if (!effect.active) {
  3224. return;
  3225. }
  3226. if (cb) {
  3227. // watch(source, cb)
  3228. const newValue = effect.run();
  3229. if (deep ||
  3230. forceTrigger ||
  3231. (isMultiSource
  3232. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3233. : hasChanged(newValue, oldValue)) ||
  3234. (false )) {
  3235. // cleanup before running cb again
  3236. if (cleanup) {
  3237. cleanup();
  3238. }
  3239. callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
  3240. newValue,
  3241. // pass undefined as the old value when it's changed for the first time
  3242. oldValue === INITIAL_WATCHER_VALUE
  3243. ? undefined
  3244. : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
  3245. ? []
  3246. : oldValue,
  3247. onCleanup
  3248. ]);
  3249. oldValue = newValue;
  3250. }
  3251. }
  3252. else {
  3253. // watchEffect
  3254. effect.run();
  3255. }
  3256. };
  3257. // important: mark the job as a watcher callback so that scheduler knows
  3258. // it is allowed to self-trigger (#1727)
  3259. job.allowRecurse = !!cb;
  3260. let scheduler;
  3261. if (flush === 'sync') {
  3262. scheduler = job; // the scheduler function gets called directly
  3263. }
  3264. else if (flush === 'post') {
  3265. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3266. }
  3267. else {
  3268. // default: 'pre'
  3269. job.pre = true;
  3270. if (instance)
  3271. job.id = instance.uid;
  3272. scheduler = () => queueJob(job);
  3273. }
  3274. const effect = new ReactiveEffect(getter, scheduler);
  3275. {
  3276. effect.onTrack = onTrack;
  3277. effect.onTrigger = onTrigger;
  3278. }
  3279. // initial run
  3280. if (cb) {
  3281. if (immediate) {
  3282. job();
  3283. }
  3284. else {
  3285. oldValue = effect.run();
  3286. }
  3287. }
  3288. else if (flush === 'post') {
  3289. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  3290. }
  3291. else {
  3292. effect.run();
  3293. }
  3294. const unwatch = () => {
  3295. effect.stop();
  3296. if (instance && instance.scope) {
  3297. remove(instance.scope.effects, effect);
  3298. }
  3299. };
  3300. return unwatch;
  3301. }
  3302. // this.$watch
  3303. function instanceWatch(source, value, options) {
  3304. const publicThis = this.proxy;
  3305. const getter = isString(source)
  3306. ? source.includes('.')
  3307. ? createPathGetter(publicThis, source)
  3308. : () => publicThis[source]
  3309. : source.bind(publicThis, publicThis);
  3310. let cb;
  3311. if (isFunction(value)) {
  3312. cb = value;
  3313. }
  3314. else {
  3315. cb = value.handler;
  3316. options = value;
  3317. }
  3318. const cur = currentInstance;
  3319. setCurrentInstance(this);
  3320. const res = doWatch(getter, cb.bind(publicThis), options);
  3321. if (cur) {
  3322. setCurrentInstance(cur);
  3323. }
  3324. else {
  3325. unsetCurrentInstance();
  3326. }
  3327. return res;
  3328. }
  3329. function createPathGetter(ctx, path) {
  3330. const segments = path.split('.');
  3331. return () => {
  3332. let cur = ctx;
  3333. for (let i = 0; i < segments.length && cur; i++) {
  3334. cur = cur[segments[i]];
  3335. }
  3336. return cur;
  3337. };
  3338. }
  3339. function traverse(value, seen) {
  3340. if (!isObject(value) || value["__v_skip" /* ReactiveFlags.SKIP */]) {
  3341. return value;
  3342. }
  3343. seen = seen || new Set();
  3344. if (seen.has(value)) {
  3345. return value;
  3346. }
  3347. seen.add(value);
  3348. if (isRef(value)) {
  3349. traverse(value.value, seen);
  3350. }
  3351. else if (isArray(value)) {
  3352. for (let i = 0; i < value.length; i++) {
  3353. traverse(value[i], seen);
  3354. }
  3355. }
  3356. else if (isSet(value) || isMap(value)) {
  3357. value.forEach((v) => {
  3358. traverse(v, seen);
  3359. });
  3360. }
  3361. else if (isPlainObject(value)) {
  3362. for (const key in value) {
  3363. traverse(value[key], seen);
  3364. }
  3365. }
  3366. return value;
  3367. }
  3368. function useTransitionState() {
  3369. const state = {
  3370. isMounted: false,
  3371. isLeaving: false,
  3372. isUnmounting: false,
  3373. leavingVNodes: new Map()
  3374. };
  3375. onMounted(() => {
  3376. state.isMounted = true;
  3377. });
  3378. onBeforeUnmount(() => {
  3379. state.isUnmounting = true;
  3380. });
  3381. return state;
  3382. }
  3383. const TransitionHookValidator = [Function, Array];
  3384. const BaseTransitionImpl = {
  3385. name: `BaseTransition`,
  3386. props: {
  3387. mode: String,
  3388. appear: Boolean,
  3389. persisted: Boolean,
  3390. // enter
  3391. onBeforeEnter: TransitionHookValidator,
  3392. onEnter: TransitionHookValidator,
  3393. onAfterEnter: TransitionHookValidator,
  3394. onEnterCancelled: TransitionHookValidator,
  3395. // leave
  3396. onBeforeLeave: TransitionHookValidator,
  3397. onLeave: TransitionHookValidator,
  3398. onAfterLeave: TransitionHookValidator,
  3399. onLeaveCancelled: TransitionHookValidator,
  3400. // appear
  3401. onBeforeAppear: TransitionHookValidator,
  3402. onAppear: TransitionHookValidator,
  3403. onAfterAppear: TransitionHookValidator,
  3404. onAppearCancelled: TransitionHookValidator
  3405. },
  3406. setup(props, { slots }) {
  3407. const instance = getCurrentInstance();
  3408. const state = useTransitionState();
  3409. let prevTransitionKey;
  3410. return () => {
  3411. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3412. if (!children || !children.length) {
  3413. return;
  3414. }
  3415. let child = children[0];
  3416. if (children.length > 1) {
  3417. let hasFound = false;
  3418. // locate first non-comment child
  3419. for (const c of children) {
  3420. if (c.type !== Comment) {
  3421. if (hasFound) {
  3422. // warn more than one non-comment child
  3423. warn$1('<transition> can only be used on a single element or component. ' +
  3424. 'Use <transition-group> for lists.');
  3425. break;
  3426. }
  3427. child = c;
  3428. hasFound = true;
  3429. }
  3430. }
  3431. }
  3432. // there's no need to track reactivity for these props so use the raw
  3433. // props for a bit better perf
  3434. const rawProps = toRaw(props);
  3435. const { mode } = rawProps;
  3436. // check mode
  3437. if (mode &&
  3438. mode !== 'in-out' &&
  3439. mode !== 'out-in' &&
  3440. mode !== 'default') {
  3441. warn$1(`invalid <transition> mode: ${mode}`);
  3442. }
  3443. if (state.isLeaving) {
  3444. return emptyPlaceholder(child);
  3445. }
  3446. // in the case of <transition><keep-alive/></transition>, we need to
  3447. // compare the type of the kept-alive children.
  3448. const innerChild = getKeepAliveChild(child);
  3449. if (!innerChild) {
  3450. return emptyPlaceholder(child);
  3451. }
  3452. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3453. setTransitionHooks(innerChild, enterHooks);
  3454. const oldChild = instance.subTree;
  3455. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3456. let transitionKeyChanged = false;
  3457. const { getTransitionKey } = innerChild.type;
  3458. if (getTransitionKey) {
  3459. const key = getTransitionKey();
  3460. if (prevTransitionKey === undefined) {
  3461. prevTransitionKey = key;
  3462. }
  3463. else if (key !== prevTransitionKey) {
  3464. prevTransitionKey = key;
  3465. transitionKeyChanged = true;
  3466. }
  3467. }
  3468. // handle mode
  3469. if (oldInnerChild &&
  3470. oldInnerChild.type !== Comment &&
  3471. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3472. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3473. // update old tree's hooks in case of dynamic transition
  3474. setTransitionHooks(oldInnerChild, leavingHooks);
  3475. // switching between different views
  3476. if (mode === 'out-in') {
  3477. state.isLeaving = true;
  3478. // return placeholder node and queue update when leave finishes
  3479. leavingHooks.afterLeave = () => {
  3480. state.isLeaving = false;
  3481. // #6835
  3482. // it also needs to be updated when active is undefined
  3483. if (instance.update.active !== false) {
  3484. instance.update();
  3485. }
  3486. };
  3487. return emptyPlaceholder(child);
  3488. }
  3489. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3490. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3491. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3492. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3493. // early removal callback
  3494. el._leaveCb = () => {
  3495. earlyRemove();
  3496. el._leaveCb = undefined;
  3497. delete enterHooks.delayedLeave;
  3498. };
  3499. enterHooks.delayedLeave = delayedLeave;
  3500. };
  3501. }
  3502. }
  3503. return child;
  3504. };
  3505. }
  3506. };
  3507. // export the public type for h/tsx inference
  3508. // also to avoid inline import() in generated d.ts files
  3509. const BaseTransition = BaseTransitionImpl;
  3510. function getLeavingNodesForType(state, vnode) {
  3511. const { leavingVNodes } = state;
  3512. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3513. if (!leavingVNodesCache) {
  3514. leavingVNodesCache = Object.create(null);
  3515. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3516. }
  3517. return leavingVNodesCache;
  3518. }
  3519. // The transition hooks are attached to the vnode as vnode.transition
  3520. // and will be called at appropriate timing in the renderer.
  3521. function resolveTransitionHooks(vnode, props, state, instance) {
  3522. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3523. const key = String(vnode.key);
  3524. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3525. const callHook = (hook, args) => {
  3526. hook &&
  3527. callWithAsyncErrorHandling(hook, instance, 9 /* ErrorCodes.TRANSITION_HOOK */, args);
  3528. };
  3529. const callAsyncHook = (hook, args) => {
  3530. const done = args[1];
  3531. callHook(hook, args);
  3532. if (isArray(hook)) {
  3533. if (hook.every(hook => hook.length <= 1))
  3534. done();
  3535. }
  3536. else if (hook.length <= 1) {
  3537. done();
  3538. }
  3539. };
  3540. const hooks = {
  3541. mode,
  3542. persisted,
  3543. beforeEnter(el) {
  3544. let hook = onBeforeEnter;
  3545. if (!state.isMounted) {
  3546. if (appear) {
  3547. hook = onBeforeAppear || onBeforeEnter;
  3548. }
  3549. else {
  3550. return;
  3551. }
  3552. }
  3553. // for same element (v-show)
  3554. if (el._leaveCb) {
  3555. el._leaveCb(true /* cancelled */);
  3556. }
  3557. // for toggled element with same key (v-if)
  3558. const leavingVNode = leavingVNodesCache[key];
  3559. if (leavingVNode &&
  3560. isSameVNodeType(vnode, leavingVNode) &&
  3561. leavingVNode.el._leaveCb) {
  3562. // force early removal (not cancelled)
  3563. leavingVNode.el._leaveCb();
  3564. }
  3565. callHook(hook, [el]);
  3566. },
  3567. enter(el) {
  3568. let hook = onEnter;
  3569. let afterHook = onAfterEnter;
  3570. let cancelHook = onEnterCancelled;
  3571. if (!state.isMounted) {
  3572. if (appear) {
  3573. hook = onAppear || onEnter;
  3574. afterHook = onAfterAppear || onAfterEnter;
  3575. cancelHook = onAppearCancelled || onEnterCancelled;
  3576. }
  3577. else {
  3578. return;
  3579. }
  3580. }
  3581. let called = false;
  3582. const done = (el._enterCb = (cancelled) => {
  3583. if (called)
  3584. return;
  3585. called = true;
  3586. if (cancelled) {
  3587. callHook(cancelHook, [el]);
  3588. }
  3589. else {
  3590. callHook(afterHook, [el]);
  3591. }
  3592. if (hooks.delayedLeave) {
  3593. hooks.delayedLeave();
  3594. }
  3595. el._enterCb = undefined;
  3596. });
  3597. if (hook) {
  3598. callAsyncHook(hook, [el, done]);
  3599. }
  3600. else {
  3601. done();
  3602. }
  3603. },
  3604. leave(el, remove) {
  3605. const key = String(vnode.key);
  3606. if (el._enterCb) {
  3607. el._enterCb(true /* cancelled */);
  3608. }
  3609. if (state.isUnmounting) {
  3610. return remove();
  3611. }
  3612. callHook(onBeforeLeave, [el]);
  3613. let called = false;
  3614. const done = (el._leaveCb = (cancelled) => {
  3615. if (called)
  3616. return;
  3617. called = true;
  3618. remove();
  3619. if (cancelled) {
  3620. callHook(onLeaveCancelled, [el]);
  3621. }
  3622. else {
  3623. callHook(onAfterLeave, [el]);
  3624. }
  3625. el._leaveCb = undefined;
  3626. if (leavingVNodesCache[key] === vnode) {
  3627. delete leavingVNodesCache[key];
  3628. }
  3629. });
  3630. leavingVNodesCache[key] = vnode;
  3631. if (onLeave) {
  3632. callAsyncHook(onLeave, [el, done]);
  3633. }
  3634. else {
  3635. done();
  3636. }
  3637. },
  3638. clone(vnode) {
  3639. return resolveTransitionHooks(vnode, props, state, instance);
  3640. }
  3641. };
  3642. return hooks;
  3643. }
  3644. // the placeholder really only handles one special case: KeepAlive
  3645. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3646. // placeholder with empty content to avoid the KeepAlive instance from being
  3647. // unmounted.
  3648. function emptyPlaceholder(vnode) {
  3649. if (isKeepAlive(vnode)) {
  3650. vnode = cloneVNode(vnode);
  3651. vnode.children = null;
  3652. return vnode;
  3653. }
  3654. }
  3655. function getKeepAliveChild(vnode) {
  3656. return isKeepAlive(vnode)
  3657. ? vnode.children
  3658. ? vnode.children[0]
  3659. : undefined
  3660. : vnode;
  3661. }
  3662. function setTransitionHooks(vnode, hooks) {
  3663. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */ && vnode.component) {
  3664. setTransitionHooks(vnode.component.subTree, hooks);
  3665. }
  3666. else if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  3667. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3668. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3669. }
  3670. else {
  3671. vnode.transition = hooks;
  3672. }
  3673. }
  3674. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3675. let ret = [];
  3676. let keyedFragmentCount = 0;
  3677. for (let i = 0; i < children.length; i++) {
  3678. let child = children[i];
  3679. // #5360 inherit parent key in case of <template v-for>
  3680. const key = parentKey == null
  3681. ? child.key
  3682. : String(parentKey) + String(child.key != null ? child.key : i);
  3683. // handle fragment children case, e.g. v-for
  3684. if (child.type === Fragment) {
  3685. if (child.patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */)
  3686. keyedFragmentCount++;
  3687. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  3688. }
  3689. // comment placeholders should be skipped, e.g. v-if
  3690. else if (keepComment || child.type !== Comment) {
  3691. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3692. }
  3693. }
  3694. // #1126 if a transition children list contains multiple sub fragments, these
  3695. // fragments will be merged into a flat children array. Since each v-for
  3696. // fragment may contain different static bindings inside, we need to de-op
  3697. // these children to force full diffs to ensure correct behavior.
  3698. if (keyedFragmentCount > 1) {
  3699. for (let i = 0; i < ret.length; i++) {
  3700. ret[i].patchFlag = -2 /* PatchFlags.BAIL */;
  3701. }
  3702. }
  3703. return ret;
  3704. }
  3705. // implementation, close to no-op
  3706. function defineComponent(options) {
  3707. return isFunction(options) ? { setup: options, name: options.name } : options;
  3708. }
  3709. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3710. function defineAsyncComponent(source) {
  3711. if (isFunction(source)) {
  3712. source = { loader: source };
  3713. }
  3714. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3715. suspensible = true, onError: userOnError } = source;
  3716. let pendingRequest = null;
  3717. let resolvedComp;
  3718. let retries = 0;
  3719. const retry = () => {
  3720. retries++;
  3721. pendingRequest = null;
  3722. return load();
  3723. };
  3724. const load = () => {
  3725. let thisRequest;
  3726. return (pendingRequest ||
  3727. (thisRequest = pendingRequest =
  3728. loader()
  3729. .catch(err => {
  3730. err = err instanceof Error ? err : new Error(String(err));
  3731. if (userOnError) {
  3732. return new Promise((resolve, reject) => {
  3733. const userRetry = () => resolve(retry());
  3734. const userFail = () => reject(err);
  3735. userOnError(err, userRetry, userFail, retries + 1);
  3736. });
  3737. }
  3738. else {
  3739. throw err;
  3740. }
  3741. })
  3742. .then((comp) => {
  3743. if (thisRequest !== pendingRequest && pendingRequest) {
  3744. return pendingRequest;
  3745. }
  3746. if (!comp) {
  3747. warn$1(`Async component loader resolved to undefined. ` +
  3748. `If you are using retry(), make sure to return its return value.`);
  3749. }
  3750. // interop module default
  3751. if (comp &&
  3752. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3753. comp = comp.default;
  3754. }
  3755. if (comp && !isObject(comp) && !isFunction(comp)) {
  3756. throw new Error(`Invalid async component load result: ${comp}`);
  3757. }
  3758. resolvedComp = comp;
  3759. return comp;
  3760. })));
  3761. };
  3762. return defineComponent({
  3763. name: 'AsyncComponentWrapper',
  3764. __asyncLoader: load,
  3765. get __asyncResolved() {
  3766. return resolvedComp;
  3767. },
  3768. setup() {
  3769. const instance = currentInstance;
  3770. // already resolved
  3771. if (resolvedComp) {
  3772. return () => createInnerComp(resolvedComp, instance);
  3773. }
  3774. const onError = (err) => {
  3775. pendingRequest = null;
  3776. handleError(err, instance, 13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3777. };
  3778. // suspense-controlled or SSR.
  3779. if ((suspensible && instance.suspense) ||
  3780. (false )) {
  3781. return load()
  3782. .then(comp => {
  3783. return () => createInnerComp(comp, instance);
  3784. })
  3785. .catch(err => {
  3786. onError(err);
  3787. return () => errorComponent
  3788. ? createVNode(errorComponent, {
  3789. error: err
  3790. })
  3791. : null;
  3792. });
  3793. }
  3794. const loaded = ref(false);
  3795. const error = ref();
  3796. const delayed = ref(!!delay);
  3797. if (delay) {
  3798. setTimeout(() => {
  3799. delayed.value = false;
  3800. }, delay);
  3801. }
  3802. if (timeout != null) {
  3803. setTimeout(() => {
  3804. if (!loaded.value && !error.value) {
  3805. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3806. onError(err);
  3807. error.value = err;
  3808. }
  3809. }, timeout);
  3810. }
  3811. load()
  3812. .then(() => {
  3813. loaded.value = true;
  3814. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3815. // parent is keep-alive, force update so the loaded component's
  3816. // name is taken into account
  3817. queueJob(instance.parent.update);
  3818. }
  3819. })
  3820. .catch(err => {
  3821. onError(err);
  3822. error.value = err;
  3823. });
  3824. return () => {
  3825. if (loaded.value && resolvedComp) {
  3826. return createInnerComp(resolvedComp, instance);
  3827. }
  3828. else if (error.value && errorComponent) {
  3829. return createVNode(errorComponent, {
  3830. error: error.value
  3831. });
  3832. }
  3833. else if (loadingComponent && !delayed.value) {
  3834. return createVNode(loadingComponent);
  3835. }
  3836. };
  3837. }
  3838. });
  3839. }
  3840. function createInnerComp(comp, parent) {
  3841. const { ref, props, children, ce } = parent.vnode;
  3842. const vnode = createVNode(comp, props, children);
  3843. // ensure inner component inherits the async wrapper's ref owner
  3844. vnode.ref = ref;
  3845. // pass the custom element callback on to the inner comp
  3846. // and remove it from the async wrapper
  3847. vnode.ce = ce;
  3848. delete parent.vnode.ce;
  3849. return vnode;
  3850. }
  3851. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3852. const KeepAliveImpl = {
  3853. name: `KeepAlive`,
  3854. // Marker for special handling inside the renderer. We are not using a ===
  3855. // check directly on KeepAlive in the renderer, because importing it directly
  3856. // would prevent it from being tree-shaken.
  3857. __isKeepAlive: true,
  3858. props: {
  3859. include: [String, RegExp, Array],
  3860. exclude: [String, RegExp, Array],
  3861. max: [String, Number]
  3862. },
  3863. setup(props, { slots }) {
  3864. const instance = getCurrentInstance();
  3865. // KeepAlive communicates with the instantiated renderer via the
  3866. // ctx where the renderer passes in its internals,
  3867. // and the KeepAlive instance exposes activate/deactivate implementations.
  3868. // The whole point of this is to avoid importing KeepAlive directly in the
  3869. // renderer to facilitate tree-shaking.
  3870. const sharedContext = instance.ctx;
  3871. const cache = new Map();
  3872. const keys = new Set();
  3873. let current = null;
  3874. {
  3875. instance.__v_cache = cache;
  3876. }
  3877. const parentSuspense = instance.suspense;
  3878. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3879. const storageContainer = createElement('div');
  3880. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3881. const instance = vnode.component;
  3882. move(vnode, container, anchor, 0 /* MoveType.ENTER */, parentSuspense);
  3883. // in case props have changed
  3884. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3885. queuePostRenderEffect(() => {
  3886. instance.isDeactivated = false;
  3887. if (instance.a) {
  3888. invokeArrayFns(instance.a);
  3889. }
  3890. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3891. if (vnodeHook) {
  3892. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3893. }
  3894. }, parentSuspense);
  3895. {
  3896. // Update components tree
  3897. devtoolsComponentAdded(instance);
  3898. }
  3899. };
  3900. sharedContext.deactivate = (vnode) => {
  3901. const instance = vnode.component;
  3902. move(vnode, storageContainer, null, 1 /* MoveType.LEAVE */, parentSuspense);
  3903. queuePostRenderEffect(() => {
  3904. if (instance.da) {
  3905. invokeArrayFns(instance.da);
  3906. }
  3907. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3908. if (vnodeHook) {
  3909. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3910. }
  3911. instance.isDeactivated = true;
  3912. }, parentSuspense);
  3913. {
  3914. // Update components tree
  3915. devtoolsComponentAdded(instance);
  3916. }
  3917. };
  3918. function unmount(vnode) {
  3919. // reset the shapeFlag so it can be properly unmounted
  3920. resetShapeFlag(vnode);
  3921. _unmount(vnode, instance, parentSuspense, true);
  3922. }
  3923. function pruneCache(filter) {
  3924. cache.forEach((vnode, key) => {
  3925. const name = getComponentName(vnode.type);
  3926. if (name && (!filter || !filter(name))) {
  3927. pruneCacheEntry(key);
  3928. }
  3929. });
  3930. }
  3931. function pruneCacheEntry(key) {
  3932. const cached = cache.get(key);
  3933. if (!current || cached.type !== current.type) {
  3934. unmount(cached);
  3935. }
  3936. else if (current) {
  3937. // current active instance should no longer be kept-alive.
  3938. // we can't unmount it now but it might be later, so reset its flag now.
  3939. resetShapeFlag(current);
  3940. }
  3941. cache.delete(key);
  3942. keys.delete(key);
  3943. }
  3944. // prune cache on include/exclude prop change
  3945. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3946. include && pruneCache(name => matches(include, name));
  3947. exclude && pruneCache(name => !matches(exclude, name));
  3948. },
  3949. // prune post-render after `current` has been updated
  3950. { flush: 'post', deep: true });
  3951. // cache sub tree after render
  3952. let pendingCacheKey = null;
  3953. const cacheSubtree = () => {
  3954. // fix #1621, the pendingCacheKey could be 0
  3955. if (pendingCacheKey != null) {
  3956. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3957. }
  3958. };
  3959. onMounted(cacheSubtree);
  3960. onUpdated(cacheSubtree);
  3961. onBeforeUnmount(() => {
  3962. cache.forEach(cached => {
  3963. const { subTree, suspense } = instance;
  3964. const vnode = getInnerChild(subTree);
  3965. if (cached.type === vnode.type) {
  3966. // current instance will be unmounted as part of keep-alive's unmount
  3967. resetShapeFlag(vnode);
  3968. // but invoke its deactivated hook here
  3969. const da = vnode.component.da;
  3970. da && queuePostRenderEffect(da, suspense);
  3971. return;
  3972. }
  3973. unmount(cached);
  3974. });
  3975. });
  3976. return () => {
  3977. pendingCacheKey = null;
  3978. if (!slots.default) {
  3979. return null;
  3980. }
  3981. const children = slots.default();
  3982. const rawVNode = children[0];
  3983. if (children.length > 1) {
  3984. {
  3985. warn$1(`KeepAlive should contain exactly one component child.`);
  3986. }
  3987. current = null;
  3988. return children;
  3989. }
  3990. else if (!isVNode(rawVNode) ||
  3991. (!(rawVNode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */) &&
  3992. !(rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */))) {
  3993. current = null;
  3994. return rawVNode;
  3995. }
  3996. let vnode = getInnerChild(rawVNode);
  3997. const comp = vnode.type;
  3998. // for async components, name check should be based in its loaded
  3999. // inner component if available
  4000. const name = getComponentName(isAsyncWrapper(vnode)
  4001. ? vnode.type.__asyncResolved || {}
  4002. : comp);
  4003. const { include, exclude, max } = props;
  4004. if ((include && (!name || !matches(include, name))) ||
  4005. (exclude && name && matches(exclude, name))) {
  4006. current = vnode;
  4007. return rawVNode;
  4008. }
  4009. const key = vnode.key == null ? comp : vnode.key;
  4010. const cachedVNode = cache.get(key);
  4011. // clone vnode if it's reused because we are going to mutate it
  4012. if (vnode.el) {
  4013. vnode = cloneVNode(vnode);
  4014. if (rawVNode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  4015. rawVNode.ssContent = vnode;
  4016. }
  4017. }
  4018. // #1513 it's possible for the returned vnode to be cloned due to attr
  4019. // fallthrough or scopeId, so the vnode here may not be the final vnode
  4020. // that is mounted. Instead of caching it directly, we store the pending
  4021. // key and cache `instance.subTree` (the normalized vnode) in
  4022. // beforeMount/beforeUpdate hooks.
  4023. pendingCacheKey = key;
  4024. if (cachedVNode) {
  4025. // copy over mounted state
  4026. vnode.el = cachedVNode.el;
  4027. vnode.component = cachedVNode.component;
  4028. if (vnode.transition) {
  4029. // recursively update transition hooks on subTree
  4030. setTransitionHooks(vnode, vnode.transition);
  4031. }
  4032. // avoid vnode being mounted as fresh
  4033. vnode.shapeFlag |= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  4034. // make this key the freshest
  4035. keys.delete(key);
  4036. keys.add(key);
  4037. }
  4038. else {
  4039. keys.add(key);
  4040. // prune oldest entry
  4041. if (max && keys.size > parseInt(max, 10)) {
  4042. pruneCacheEntry(keys.values().next().value);
  4043. }
  4044. }
  4045. // avoid vnode being unmounted
  4046. vnode.shapeFlag |= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  4047. current = vnode;
  4048. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4049. };
  4050. }
  4051. };
  4052. // export the public type for h/tsx inference
  4053. // also to avoid inline import() in generated d.ts files
  4054. const KeepAlive = KeepAliveImpl;
  4055. function matches(pattern, name) {
  4056. if (isArray(pattern)) {
  4057. return pattern.some((p) => matches(p, name));
  4058. }
  4059. else if (isString(pattern)) {
  4060. return pattern.split(',').includes(name);
  4061. }
  4062. else if (pattern.test) {
  4063. return pattern.test(name);
  4064. }
  4065. /* istanbul ignore next */
  4066. return false;
  4067. }
  4068. function onActivated(hook, target) {
  4069. registerKeepAliveHook(hook, "a" /* LifecycleHooks.ACTIVATED */, target);
  4070. }
  4071. function onDeactivated(hook, target) {
  4072. registerKeepAliveHook(hook, "da" /* LifecycleHooks.DEACTIVATED */, target);
  4073. }
  4074. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4075. // cache the deactivate branch check wrapper for injected hooks so the same
  4076. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4077. // deactivation check".
  4078. const wrappedHook = hook.__wdc ||
  4079. (hook.__wdc = () => {
  4080. // only fire the hook if the target instance is NOT in a deactivated branch.
  4081. let current = target;
  4082. while (current) {
  4083. if (current.isDeactivated) {
  4084. return;
  4085. }
  4086. current = current.parent;
  4087. }
  4088. return hook();
  4089. });
  4090. injectHook(type, wrappedHook, target);
  4091. // In addition to registering it on the target instance, we walk up the parent
  4092. // chain and register it on all ancestor instances that are keep-alive roots.
  4093. // This avoids the need to walk the entire component tree when invoking these
  4094. // hooks, and more importantly, avoids the need to track child components in
  4095. // arrays.
  4096. if (target) {
  4097. let current = target.parent;
  4098. while (current && current.parent) {
  4099. if (isKeepAlive(current.parent.vnode)) {
  4100. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4101. }
  4102. current = current.parent;
  4103. }
  4104. }
  4105. }
  4106. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4107. // injectHook wraps the original for error handling, so make sure to remove
  4108. // the wrapped version.
  4109. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4110. onUnmounted(() => {
  4111. remove(keepAliveRoot[type], injected);
  4112. }, target);
  4113. }
  4114. function resetShapeFlag(vnode) {
  4115. // bitwise operations to remove keep alive flags
  4116. vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  4117. vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  4118. }
  4119. function getInnerChild(vnode) {
  4120. return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
  4121. }
  4122. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4123. if (target) {
  4124. const hooks = target[type] || (target[type] = []);
  4125. // cache the error handling wrapper for injected hooks so the same hook
  4126. // can be properly deduped by the scheduler. "__weh" stands for "with error
  4127. // handling".
  4128. const wrappedHook = hook.__weh ||
  4129. (hook.__weh = (...args) => {
  4130. if (target.isUnmounted) {
  4131. return;
  4132. }
  4133. // disable tracking inside all lifecycle hooks
  4134. // since they can potentially be called inside effects.
  4135. pauseTracking();
  4136. // Set currentInstance during hook invocation.
  4137. // This assumes the hook does not synchronously trigger other hooks, which
  4138. // can only be false when the user does something really funky.
  4139. setCurrentInstance(target);
  4140. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4141. unsetCurrentInstance();
  4142. resetTracking();
  4143. return res;
  4144. });
  4145. if (prepend) {
  4146. hooks.unshift(wrappedHook);
  4147. }
  4148. else {
  4149. hooks.push(wrappedHook);
  4150. }
  4151. return wrappedHook;
  4152. }
  4153. else {
  4154. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  4155. warn$1(`${apiName} is called when there is no active component instance to be ` +
  4156. `associated with. ` +
  4157. `Lifecycle injection APIs can only be used during execution of setup().` +
  4158. (` If you are using async setup(), make sure to register lifecycle ` +
  4159. `hooks before the first await statement.`
  4160. ));
  4161. }
  4162. }
  4163. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  4164. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4165. (!isInSSRComponentSetup || lifecycle === "sp" /* LifecycleHooks.SERVER_PREFETCH */) &&
  4166. injectHook(lifecycle, (...args) => hook(...args), target);
  4167. const onBeforeMount = createHook("bm" /* LifecycleHooks.BEFORE_MOUNT */);
  4168. const onMounted = createHook("m" /* LifecycleHooks.MOUNTED */);
  4169. const onBeforeUpdate = createHook("bu" /* LifecycleHooks.BEFORE_UPDATE */);
  4170. const onUpdated = createHook("u" /* LifecycleHooks.UPDATED */);
  4171. const onBeforeUnmount = createHook("bum" /* LifecycleHooks.BEFORE_UNMOUNT */);
  4172. const onUnmounted = createHook("um" /* LifecycleHooks.UNMOUNTED */);
  4173. const onServerPrefetch = createHook("sp" /* LifecycleHooks.SERVER_PREFETCH */);
  4174. const onRenderTriggered = createHook("rtg" /* LifecycleHooks.RENDER_TRIGGERED */);
  4175. const onRenderTracked = createHook("rtc" /* LifecycleHooks.RENDER_TRACKED */);
  4176. function onErrorCaptured(hook, target = currentInstance) {
  4177. injectHook("ec" /* LifecycleHooks.ERROR_CAPTURED */, hook, target);
  4178. }
  4179. /**
  4180. Runtime helper for applying directives to a vnode. Example usage:
  4181. const comp = resolveComponent('comp')
  4182. const foo = resolveDirective('foo')
  4183. const bar = resolveDirective('bar')
  4184. return withDirectives(h(comp), [
  4185. [foo, this.x],
  4186. [bar, this.y]
  4187. ])
  4188. */
  4189. function validateDirectiveName(name) {
  4190. if (isBuiltInDirective(name)) {
  4191. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  4192. }
  4193. }
  4194. /**
  4195. * Adds directives to a VNode.
  4196. */
  4197. function withDirectives(vnode, directives) {
  4198. const internalInstance = currentRenderingInstance;
  4199. if (internalInstance === null) {
  4200. warn$1(`withDirectives can only be used inside render functions.`);
  4201. return vnode;
  4202. }
  4203. const instance = getExposeProxy(internalInstance) ||
  4204. internalInstance.proxy;
  4205. const bindings = vnode.dirs || (vnode.dirs = []);
  4206. for (let i = 0; i < directives.length; i++) {
  4207. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4208. if (dir) {
  4209. if (isFunction(dir)) {
  4210. dir = {
  4211. mounted: dir,
  4212. updated: dir
  4213. };
  4214. }
  4215. if (dir.deep) {
  4216. traverse(value);
  4217. }
  4218. bindings.push({
  4219. dir,
  4220. instance,
  4221. value,
  4222. oldValue: void 0,
  4223. arg,
  4224. modifiers
  4225. });
  4226. }
  4227. }
  4228. return vnode;
  4229. }
  4230. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4231. const bindings = vnode.dirs;
  4232. const oldBindings = prevVNode && prevVNode.dirs;
  4233. for (let i = 0; i < bindings.length; i++) {
  4234. const binding = bindings[i];
  4235. if (oldBindings) {
  4236. binding.oldValue = oldBindings[i].value;
  4237. }
  4238. let hook = binding.dir[name];
  4239. if (hook) {
  4240. // disable tracking inside all lifecycle hooks
  4241. // since they can potentially be called inside effects.
  4242. pauseTracking();
  4243. callWithAsyncErrorHandling(hook, instance, 8 /* ErrorCodes.DIRECTIVE_HOOK */, [
  4244. vnode.el,
  4245. binding,
  4246. vnode,
  4247. prevVNode
  4248. ]);
  4249. resetTracking();
  4250. }
  4251. }
  4252. }
  4253. const COMPONENTS = 'components';
  4254. const DIRECTIVES = 'directives';
  4255. /**
  4256. * @private
  4257. */
  4258. function resolveComponent(name, maybeSelfReference) {
  4259. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4260. }
  4261. const NULL_DYNAMIC_COMPONENT = Symbol();
  4262. /**
  4263. * @private
  4264. */
  4265. function resolveDynamicComponent(component) {
  4266. if (isString(component)) {
  4267. return resolveAsset(COMPONENTS, component, false) || component;
  4268. }
  4269. else {
  4270. // invalid types will fallthrough to createVNode and raise warning
  4271. return (component || NULL_DYNAMIC_COMPONENT);
  4272. }
  4273. }
  4274. /**
  4275. * @private
  4276. */
  4277. function resolveDirective(name) {
  4278. return resolveAsset(DIRECTIVES, name);
  4279. }
  4280. // implementation
  4281. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4282. const instance = currentRenderingInstance || currentInstance;
  4283. if (instance) {
  4284. const Component = instance.type;
  4285. // explicit self name has highest priority
  4286. if (type === COMPONENTS) {
  4287. const selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
  4288. if (selfName &&
  4289. (selfName === name ||
  4290. selfName === camelize(name) ||
  4291. selfName === capitalize(camelize(name)))) {
  4292. return Component;
  4293. }
  4294. }
  4295. const res =
  4296. // local registration
  4297. // check instance[type] first which is resolved for options API
  4298. resolve(instance[type] || Component[type], name) ||
  4299. // global registration
  4300. resolve(instance.appContext[type], name);
  4301. if (!res && maybeSelfReference) {
  4302. // fallback to implicit self-reference
  4303. return Component;
  4304. }
  4305. if (warnMissing && !res) {
  4306. const extra = type === COMPONENTS
  4307. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  4308. `component resolution via compilerOptions.isCustomElement.`
  4309. : ``;
  4310. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4311. }
  4312. return res;
  4313. }
  4314. else {
  4315. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  4316. `can only be used in render() or setup().`);
  4317. }
  4318. }
  4319. function resolve(registry, name) {
  4320. return (registry &&
  4321. (registry[name] ||
  4322. registry[camelize(name)] ||
  4323. registry[capitalize(camelize(name))]));
  4324. }
  4325. /**
  4326. * Actual implementation
  4327. */
  4328. function renderList(source, renderItem, cache, index) {
  4329. let ret;
  4330. const cached = (cache && cache[index]);
  4331. if (isArray(source) || isString(source)) {
  4332. ret = new Array(source.length);
  4333. for (let i = 0, l = source.length; i < l; i++) {
  4334. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  4335. }
  4336. }
  4337. else if (typeof source === 'number') {
  4338. if (!Number.isInteger(source)) {
  4339. warn$1(`The v-for range expect an integer value but got ${source}.`);
  4340. }
  4341. ret = new Array(source);
  4342. for (let i = 0; i < source; i++) {
  4343. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  4344. }
  4345. }
  4346. else if (isObject(source)) {
  4347. if (source[Symbol.iterator]) {
  4348. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  4349. }
  4350. else {
  4351. const keys = Object.keys(source);
  4352. ret = new Array(keys.length);
  4353. for (let i = 0, l = keys.length; i < l; i++) {
  4354. const key = keys[i];
  4355. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4356. }
  4357. }
  4358. }
  4359. else {
  4360. ret = [];
  4361. }
  4362. if (cache) {
  4363. cache[index] = ret;
  4364. }
  4365. return ret;
  4366. }
  4367. /**
  4368. * Compiler runtime helper for creating dynamic slots object
  4369. * @private
  4370. */
  4371. function createSlots(slots, dynamicSlots) {
  4372. for (let i = 0; i < dynamicSlots.length; i++) {
  4373. const slot = dynamicSlots[i];
  4374. // array of dynamic slot generated by <template v-for="..." #[...]>
  4375. if (isArray(slot)) {
  4376. for (let j = 0; j < slot.length; j++) {
  4377. slots[slot[j].name] = slot[j].fn;
  4378. }
  4379. }
  4380. else if (slot) {
  4381. // conditional single slot generated by <template v-if="..." #foo>
  4382. slots[slot.name] = slot.key
  4383. ? (...args) => {
  4384. const res = slot.fn(...args);
  4385. // attach branch key so each conditional branch is considered a
  4386. // different fragment
  4387. if (res)
  4388. res.key = slot.key;
  4389. return res;
  4390. }
  4391. : slot.fn;
  4392. }
  4393. }
  4394. return slots;
  4395. }
  4396. /**
  4397. * Compiler runtime helper for rendering `<slot/>`
  4398. * @private
  4399. */
  4400. function renderSlot(slots, name, props = {},
  4401. // this is not a user-facing function, so the fallback is always generated by
  4402. // the compiler and guaranteed to be a function returning an array
  4403. fallback, noSlotted) {
  4404. if (currentRenderingInstance.isCE ||
  4405. (currentRenderingInstance.parent &&
  4406. isAsyncWrapper(currentRenderingInstance.parent) &&
  4407. currentRenderingInstance.parent.isCE)) {
  4408. if (name !== 'default')
  4409. props.name = name;
  4410. return createVNode('slot', props, fallback && fallback());
  4411. }
  4412. let slot = slots[name];
  4413. if (slot && slot.length > 1) {
  4414. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  4415. `function. You need to mark this component with $dynamic-slots in the ` +
  4416. `parent template.`);
  4417. slot = () => [];
  4418. }
  4419. // a compiled slot disables block tracking by default to avoid manual
  4420. // invocation interfering with template-based block tracking, but in
  4421. // `renderSlot` we can be sure that it's template-based so we can force
  4422. // enable it.
  4423. if (slot && slot._c) {
  4424. slot._d = false;
  4425. }
  4426. openBlock();
  4427. const validSlotContent = slot && ensureValidVNode(slot(props));
  4428. const rendered = createBlock(Fragment, {
  4429. key: props.key ||
  4430. // slot content array of a dynamic conditional slot may have a branch
  4431. // key attached in the `createSlots` helper, respect that
  4432. (validSlotContent && validSlotContent.key) ||
  4433. `_${name}`
  4434. }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* SlotFlags.STABLE */
  4435. ? 64 /* PatchFlags.STABLE_FRAGMENT */
  4436. : -2 /* PatchFlags.BAIL */);
  4437. if (!noSlotted && rendered.scopeId) {
  4438. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  4439. }
  4440. if (slot && slot._c) {
  4441. slot._d = true;
  4442. }
  4443. return rendered;
  4444. }
  4445. function ensureValidVNode(vnodes) {
  4446. return vnodes.some(child => {
  4447. if (!isVNode(child))
  4448. return true;
  4449. if (child.type === Comment)
  4450. return false;
  4451. if (child.type === Fragment &&
  4452. !ensureValidVNode(child.children))
  4453. return false;
  4454. return true;
  4455. })
  4456. ? vnodes
  4457. : null;
  4458. }
  4459. /**
  4460. * For prefixing keys in v-on="obj" with "on"
  4461. * @private
  4462. */
  4463. function toHandlers(obj, preserveCaseIfNecessary) {
  4464. const ret = {};
  4465. if (!isObject(obj)) {
  4466. warn$1(`v-on with no argument expects an object value.`);
  4467. return ret;
  4468. }
  4469. for (const key in obj) {
  4470. ret[preserveCaseIfNecessary && /[A-Z]/.test(key)
  4471. ? `on:${key}`
  4472. : toHandlerKey(key)] = obj[key];
  4473. }
  4474. return ret;
  4475. }
  4476. /**
  4477. * #2437 In Vue 3, functional components do not have a public instance proxy but
  4478. * they exist in the internal parent chain. For code that relies on traversing
  4479. * public $parent chains, skip functional ones and go to the parent instead.
  4480. */
  4481. const getPublicInstance = (i) => {
  4482. if (!i)
  4483. return null;
  4484. if (isStatefulComponent(i))
  4485. return getExposeProxy(i) || i.proxy;
  4486. return getPublicInstance(i.parent);
  4487. };
  4488. const publicPropertiesMap =
  4489. // Move PURE marker to new line to workaround compiler discarding it
  4490. // due to type annotation
  4491. /*#__PURE__*/ extend(Object.create(null), {
  4492. $: i => i,
  4493. $el: i => i.vnode.el,
  4494. $data: i => i.data,
  4495. $props: i => (shallowReadonly(i.props) ),
  4496. $attrs: i => (shallowReadonly(i.attrs) ),
  4497. $slots: i => (shallowReadonly(i.slots) ),
  4498. $refs: i => (shallowReadonly(i.refs) ),
  4499. $parent: i => getPublicInstance(i.parent),
  4500. $root: i => getPublicInstance(i.root),
  4501. $emit: i => i.emit,
  4502. $options: i => (resolveMergedOptions(i) ),
  4503. $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
  4504. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  4505. $watch: i => (instanceWatch.bind(i) )
  4506. });
  4507. const isReservedPrefix = (key) => key === '_' || key === '$';
  4508. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  4509. const PublicInstanceProxyHandlers = {
  4510. get({ _: instance }, key) {
  4511. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4512. // for internal formatters to know that this is a Vue instance
  4513. if (key === '__isVue') {
  4514. return true;
  4515. }
  4516. // data / props / ctx
  4517. // This getter gets called for every property access on the render context
  4518. // during render and is a major hotspot. The most expensive part of this
  4519. // is the multiple hasOwn() calls. It's much faster to do a simple property
  4520. // access on a plain object, so we use an accessCache object (with null
  4521. // prototype) to memoize what access type a key corresponds to.
  4522. let normalizedProps;
  4523. if (key[0] !== '$') {
  4524. const n = accessCache[key];
  4525. if (n !== undefined) {
  4526. switch (n) {
  4527. case 1 /* AccessTypes.SETUP */:
  4528. return setupState[key];
  4529. case 2 /* AccessTypes.DATA */:
  4530. return data[key];
  4531. case 4 /* AccessTypes.CONTEXT */:
  4532. return ctx[key];
  4533. case 3 /* AccessTypes.PROPS */:
  4534. return props[key];
  4535. // default: just fallthrough
  4536. }
  4537. }
  4538. else if (hasSetupBinding(setupState, key)) {
  4539. accessCache[key] = 1 /* AccessTypes.SETUP */;
  4540. return setupState[key];
  4541. }
  4542. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4543. accessCache[key] = 2 /* AccessTypes.DATA */;
  4544. return data[key];
  4545. }
  4546. else if (
  4547. // only cache other properties when instance has declared (thus stable)
  4548. // props
  4549. (normalizedProps = instance.propsOptions[0]) &&
  4550. hasOwn(normalizedProps, key)) {
  4551. accessCache[key] = 3 /* AccessTypes.PROPS */;
  4552. return props[key];
  4553. }
  4554. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4555. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  4556. return ctx[key];
  4557. }
  4558. else if (shouldCacheAccess) {
  4559. accessCache[key] = 0 /* AccessTypes.OTHER */;
  4560. }
  4561. }
  4562. const publicGetter = publicPropertiesMap[key];
  4563. let cssModule, globalProperties;
  4564. // public $xxx properties
  4565. if (publicGetter) {
  4566. if (key === '$attrs') {
  4567. track(instance, "get" /* TrackOpTypes.GET */, key);
  4568. markAttrsAccessed();
  4569. }
  4570. return publicGetter(instance);
  4571. }
  4572. else if (
  4573. // css module (injected by vue-loader)
  4574. (cssModule = type.__cssModules) &&
  4575. (cssModule = cssModule[key])) {
  4576. return cssModule;
  4577. }
  4578. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4579. // user may set custom properties to `this` that start with `$`
  4580. accessCache[key] = 4 /* AccessTypes.CONTEXT */;
  4581. return ctx[key];
  4582. }
  4583. else if (
  4584. // global properties
  4585. ((globalProperties = appContext.config.globalProperties),
  4586. hasOwn(globalProperties, key))) {
  4587. {
  4588. return globalProperties[key];
  4589. }
  4590. }
  4591. else if (currentRenderingInstance &&
  4592. (!isString(key) ||
  4593. // #1091 avoid internal isRef/isVNode checks on component instance leading
  4594. // to infinite warning loop
  4595. key.indexOf('__v') !== 0)) {
  4596. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4597. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  4598. `character ("$" or "_") and is not proxied on the render context.`);
  4599. }
  4600. else if (instance === currentRenderingInstance) {
  4601. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  4602. `but is not defined on instance.`);
  4603. }
  4604. }
  4605. },
  4606. set({ _: instance }, key, value) {
  4607. const { data, setupState, ctx } = instance;
  4608. if (hasSetupBinding(setupState, key)) {
  4609. setupState[key] = value;
  4610. return true;
  4611. }
  4612. else if (setupState.__isScriptSetup &&
  4613. hasOwn(setupState, key)) {
  4614. warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  4615. return false;
  4616. }
  4617. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4618. data[key] = value;
  4619. return true;
  4620. }
  4621. else if (hasOwn(instance.props, key)) {
  4622. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
  4623. return false;
  4624. }
  4625. if (key[0] === '$' && key.slice(1) in instance) {
  4626. warn$1(`Attempting to mutate public property "${key}". ` +
  4627. `Properties starting with $ are reserved and readonly.`);
  4628. return false;
  4629. }
  4630. else {
  4631. if (key in instance.appContext.config.globalProperties) {
  4632. Object.defineProperty(ctx, key, {
  4633. enumerable: true,
  4634. configurable: true,
  4635. value
  4636. });
  4637. }
  4638. else {
  4639. ctx[key] = value;
  4640. }
  4641. }
  4642. return true;
  4643. },
  4644. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  4645. let normalizedProps;
  4646. return (!!accessCache[key] ||
  4647. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  4648. hasSetupBinding(setupState, key) ||
  4649. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  4650. hasOwn(ctx, key) ||
  4651. hasOwn(publicPropertiesMap, key) ||
  4652. hasOwn(appContext.config.globalProperties, key));
  4653. },
  4654. defineProperty(target, key, descriptor) {
  4655. if (descriptor.get != null) {
  4656. // invalidate key cache of a getter based property #5417
  4657. target._.accessCache[key] = 0;
  4658. }
  4659. else if (hasOwn(descriptor, 'value')) {
  4660. this.set(target, key, descriptor.value, null);
  4661. }
  4662. return Reflect.defineProperty(target, key, descriptor);
  4663. }
  4664. };
  4665. {
  4666. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4667. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  4668. `The keys will be empty in production mode to avoid performance overhead.`);
  4669. return Reflect.ownKeys(target);
  4670. };
  4671. }
  4672. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  4673. get(target, key) {
  4674. // fast path for unscopables when using `with` block
  4675. if (key === Symbol.unscopables) {
  4676. return;
  4677. }
  4678. return PublicInstanceProxyHandlers.get(target, key, target);
  4679. },
  4680. has(_, key) {
  4681. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  4682. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4683. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  4684. }
  4685. return has;
  4686. }
  4687. });
  4688. // dev only
  4689. // In dev mode, the proxy target exposes the same properties as seen on `this`
  4690. // for easier console inspection. In prod mode it will be an empty object so
  4691. // these properties definitions can be skipped.
  4692. function createDevRenderContext(instance) {
  4693. const target = {};
  4694. // expose internal instance for proxy handlers
  4695. Object.defineProperty(target, `_`, {
  4696. configurable: true,
  4697. enumerable: false,
  4698. get: () => instance
  4699. });
  4700. // expose public properties
  4701. Object.keys(publicPropertiesMap).forEach(key => {
  4702. Object.defineProperty(target, key, {
  4703. configurable: true,
  4704. enumerable: false,
  4705. get: () => publicPropertiesMap[key](instance),
  4706. // intercepted by the proxy so no need for implementation,
  4707. // but needed to prevent set errors
  4708. set: NOOP
  4709. });
  4710. });
  4711. return target;
  4712. }
  4713. // dev only
  4714. function exposePropsOnRenderContext(instance) {
  4715. const { ctx, propsOptions: [propsOptions] } = instance;
  4716. if (propsOptions) {
  4717. Object.keys(propsOptions).forEach(key => {
  4718. Object.defineProperty(ctx, key, {
  4719. enumerable: true,
  4720. configurable: true,
  4721. get: () => instance.props[key],
  4722. set: NOOP
  4723. });
  4724. });
  4725. }
  4726. }
  4727. // dev only
  4728. function exposeSetupStateOnRenderContext(instance) {
  4729. const { ctx, setupState } = instance;
  4730. Object.keys(toRaw(setupState)).forEach(key => {
  4731. if (!setupState.__isScriptSetup) {
  4732. if (isReservedPrefix(key[0])) {
  4733. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  4734. `which are reserved prefixes for Vue internals.`);
  4735. return;
  4736. }
  4737. Object.defineProperty(ctx, key, {
  4738. enumerable: true,
  4739. configurable: true,
  4740. get: () => setupState[key],
  4741. set: NOOP
  4742. });
  4743. }
  4744. });
  4745. }
  4746. function createDuplicateChecker() {
  4747. const cache = Object.create(null);
  4748. return (type, key) => {
  4749. if (cache[key]) {
  4750. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4751. }
  4752. else {
  4753. cache[key] = type;
  4754. }
  4755. };
  4756. }
  4757. let shouldCacheAccess = true;
  4758. function applyOptions(instance) {
  4759. const options = resolveMergedOptions(instance);
  4760. const publicThis = instance.proxy;
  4761. const ctx = instance.ctx;
  4762. // do not cache property access on public proxy during state initialization
  4763. shouldCacheAccess = false;
  4764. // call beforeCreate first before accessing other options since
  4765. // the hook may mutate resolved options (#2791)
  4766. if (options.beforeCreate) {
  4767. callHook(options.beforeCreate, instance, "bc" /* LifecycleHooks.BEFORE_CREATE */);
  4768. }
  4769. const {
  4770. // state
  4771. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  4772. // lifecycle
  4773. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  4774. // public API
  4775. expose, inheritAttrs,
  4776. // assets
  4777. components, directives, filters } = options;
  4778. const checkDuplicateProperties = createDuplicateChecker() ;
  4779. {
  4780. const [propsOptions] = instance.propsOptions;
  4781. if (propsOptions) {
  4782. for (const key in propsOptions) {
  4783. checkDuplicateProperties("Props" /* OptionTypes.PROPS */, key);
  4784. }
  4785. }
  4786. }
  4787. // options initialization order (to be consistent with Vue 2):
  4788. // - props (already done outside of this function)
  4789. // - inject
  4790. // - methods
  4791. // - data (deferred since it relies on `this` access)
  4792. // - computed
  4793. // - watch (deferred since it relies on `this` access)
  4794. if (injectOptions) {
  4795. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  4796. }
  4797. if (methods) {
  4798. for (const key in methods) {
  4799. const methodHandler = methods[key];
  4800. if (isFunction(methodHandler)) {
  4801. // In dev mode, we use the `createRenderContext` function to define
  4802. // methods to the proxy target, and those are read-only but
  4803. // reconfigurable, so it needs to be redefined here
  4804. {
  4805. Object.defineProperty(ctx, key, {
  4806. value: methodHandler.bind(publicThis),
  4807. configurable: true,
  4808. enumerable: true,
  4809. writable: true
  4810. });
  4811. }
  4812. {
  4813. checkDuplicateProperties("Methods" /* OptionTypes.METHODS */, key);
  4814. }
  4815. }
  4816. else {
  4817. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  4818. `Did you reference the function correctly?`);
  4819. }
  4820. }
  4821. }
  4822. if (dataOptions) {
  4823. if (!isFunction(dataOptions)) {
  4824. warn$1(`The data option must be a function. ` +
  4825. `Plain object usage is no longer supported.`);
  4826. }
  4827. const data = dataOptions.call(publicThis, publicThis);
  4828. if (isPromise(data)) {
  4829. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  4830. `intend to perform data fetching before component renders, use ` +
  4831. `async setup() + <Suspense>.`);
  4832. }
  4833. if (!isObject(data)) {
  4834. warn$1(`data() should return an object.`);
  4835. }
  4836. else {
  4837. instance.data = reactive(data);
  4838. {
  4839. for (const key in data) {
  4840. checkDuplicateProperties("Data" /* OptionTypes.DATA */, key);
  4841. // expose data on ctx during dev
  4842. if (!isReservedPrefix(key[0])) {
  4843. Object.defineProperty(ctx, key, {
  4844. configurable: true,
  4845. enumerable: true,
  4846. get: () => data[key],
  4847. set: NOOP
  4848. });
  4849. }
  4850. }
  4851. }
  4852. }
  4853. }
  4854. // state initialization complete at this point - start caching access
  4855. shouldCacheAccess = true;
  4856. if (computedOptions) {
  4857. for (const key in computedOptions) {
  4858. const opt = computedOptions[key];
  4859. const get = isFunction(opt)
  4860. ? opt.bind(publicThis, publicThis)
  4861. : isFunction(opt.get)
  4862. ? opt.get.bind(publicThis, publicThis)
  4863. : NOOP;
  4864. if (get === NOOP) {
  4865. warn$1(`Computed property "${key}" has no getter.`);
  4866. }
  4867. const set = !isFunction(opt) && isFunction(opt.set)
  4868. ? opt.set.bind(publicThis)
  4869. : () => {
  4870. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  4871. }
  4872. ;
  4873. const c = computed$1({
  4874. get,
  4875. set
  4876. });
  4877. Object.defineProperty(ctx, key, {
  4878. enumerable: true,
  4879. configurable: true,
  4880. get: () => c.value,
  4881. set: v => (c.value = v)
  4882. });
  4883. {
  4884. checkDuplicateProperties("Computed" /* OptionTypes.COMPUTED */, key);
  4885. }
  4886. }
  4887. }
  4888. if (watchOptions) {
  4889. for (const key in watchOptions) {
  4890. createWatcher(watchOptions[key], ctx, publicThis, key);
  4891. }
  4892. }
  4893. if (provideOptions) {
  4894. const provides = isFunction(provideOptions)
  4895. ? provideOptions.call(publicThis)
  4896. : provideOptions;
  4897. Reflect.ownKeys(provides).forEach(key => {
  4898. provide(key, provides[key]);
  4899. });
  4900. }
  4901. if (created) {
  4902. callHook(created, instance, "c" /* LifecycleHooks.CREATED */);
  4903. }
  4904. function registerLifecycleHook(register, hook) {
  4905. if (isArray(hook)) {
  4906. hook.forEach(_hook => register(_hook.bind(publicThis)));
  4907. }
  4908. else if (hook) {
  4909. register(hook.bind(publicThis));
  4910. }
  4911. }
  4912. registerLifecycleHook(onBeforeMount, beforeMount);
  4913. registerLifecycleHook(onMounted, mounted);
  4914. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4915. registerLifecycleHook(onUpdated, updated);
  4916. registerLifecycleHook(onActivated, activated);
  4917. registerLifecycleHook(onDeactivated, deactivated);
  4918. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4919. registerLifecycleHook(onRenderTracked, renderTracked);
  4920. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4921. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4922. registerLifecycleHook(onUnmounted, unmounted);
  4923. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4924. if (isArray(expose)) {
  4925. if (expose.length) {
  4926. const exposed = instance.exposed || (instance.exposed = {});
  4927. expose.forEach(key => {
  4928. Object.defineProperty(exposed, key, {
  4929. get: () => publicThis[key],
  4930. set: val => (publicThis[key] = val)
  4931. });
  4932. });
  4933. }
  4934. else if (!instance.exposed) {
  4935. instance.exposed = {};
  4936. }
  4937. }
  4938. // options that are handled when creating the instance but also need to be
  4939. // applied from mixins
  4940. if (render && instance.render === NOOP) {
  4941. instance.render = render;
  4942. }
  4943. if (inheritAttrs != null) {
  4944. instance.inheritAttrs = inheritAttrs;
  4945. }
  4946. // asset options.
  4947. if (components)
  4948. instance.components = components;
  4949. if (directives)
  4950. instance.directives = directives;
  4951. }
  4952. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  4953. if (isArray(injectOptions)) {
  4954. injectOptions = normalizeInject(injectOptions);
  4955. }
  4956. for (const key in injectOptions) {
  4957. const opt = injectOptions[key];
  4958. let injected;
  4959. if (isObject(opt)) {
  4960. if ('default' in opt) {
  4961. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  4962. }
  4963. else {
  4964. injected = inject(opt.from || key);
  4965. }
  4966. }
  4967. else {
  4968. injected = inject(opt);
  4969. }
  4970. if (isRef(injected)) {
  4971. // TODO remove the check in 3.3
  4972. if (unwrapRef) {
  4973. Object.defineProperty(ctx, key, {
  4974. enumerable: true,
  4975. configurable: true,
  4976. get: () => injected.value,
  4977. set: v => (injected.value = v)
  4978. });
  4979. }
  4980. else {
  4981. {
  4982. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  4983. `and no longer needs \`.value\` in the next minor release. ` +
  4984. `To opt-in to the new behavior now, ` +
  4985. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  4986. `temporary and will not be needed in the future.)`);
  4987. }
  4988. ctx[key] = injected;
  4989. }
  4990. }
  4991. else {
  4992. ctx[key] = injected;
  4993. }
  4994. {
  4995. checkDuplicateProperties("Inject" /* OptionTypes.INJECT */, key);
  4996. }
  4997. }
  4998. }
  4999. function callHook(hook, instance, type) {
  5000. callWithAsyncErrorHandling(isArray(hook)
  5001. ? hook.map(h => h.bind(instance.proxy))
  5002. : hook.bind(instance.proxy), instance, type);
  5003. }
  5004. function createWatcher(raw, ctx, publicThis, key) {
  5005. const getter = key.includes('.')
  5006. ? createPathGetter(publicThis, key)
  5007. : () => publicThis[key];
  5008. if (isString(raw)) {
  5009. const handler = ctx[raw];
  5010. if (isFunction(handler)) {
  5011. watch(getter, handler);
  5012. }
  5013. else {
  5014. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  5015. }
  5016. }
  5017. else if (isFunction(raw)) {
  5018. watch(getter, raw.bind(publicThis));
  5019. }
  5020. else if (isObject(raw)) {
  5021. if (isArray(raw)) {
  5022. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  5023. }
  5024. else {
  5025. const handler = isFunction(raw.handler)
  5026. ? raw.handler.bind(publicThis)
  5027. : ctx[raw.handler];
  5028. if (isFunction(handler)) {
  5029. watch(getter, handler, raw);
  5030. }
  5031. else {
  5032. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  5033. }
  5034. }
  5035. }
  5036. else {
  5037. warn$1(`Invalid watch option: "${key}"`, raw);
  5038. }
  5039. }
  5040. /**
  5041. * Resolve merged options and cache it on the component.
  5042. * This is done only once per-component since the merging does not involve
  5043. * instances.
  5044. */
  5045. function resolveMergedOptions(instance) {
  5046. const base = instance.type;
  5047. const { mixins, extends: extendsOptions } = base;
  5048. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  5049. const cached = cache.get(base);
  5050. let resolved;
  5051. if (cached) {
  5052. resolved = cached;
  5053. }
  5054. else if (!globalMixins.length && !mixins && !extendsOptions) {
  5055. {
  5056. resolved = base;
  5057. }
  5058. }
  5059. else {
  5060. resolved = {};
  5061. if (globalMixins.length) {
  5062. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  5063. }
  5064. mergeOptions(resolved, base, optionMergeStrategies);
  5065. }
  5066. if (isObject(base)) {
  5067. cache.set(base, resolved);
  5068. }
  5069. return resolved;
  5070. }
  5071. function mergeOptions(to, from, strats, asMixin = false) {
  5072. const { mixins, extends: extendsOptions } = from;
  5073. if (extendsOptions) {
  5074. mergeOptions(to, extendsOptions, strats, true);
  5075. }
  5076. if (mixins) {
  5077. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  5078. }
  5079. for (const key in from) {
  5080. if (asMixin && key === 'expose') {
  5081. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  5082. `It should only be declared in the base component itself.`);
  5083. }
  5084. else {
  5085. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  5086. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5087. }
  5088. }
  5089. return to;
  5090. }
  5091. const internalOptionMergeStrats = {
  5092. data: mergeDataFn,
  5093. props: mergeObjectOptions,
  5094. emits: mergeObjectOptions,
  5095. // objects
  5096. methods: mergeObjectOptions,
  5097. computed: mergeObjectOptions,
  5098. // lifecycle
  5099. beforeCreate: mergeAsArray,
  5100. created: mergeAsArray,
  5101. beforeMount: mergeAsArray,
  5102. mounted: mergeAsArray,
  5103. beforeUpdate: mergeAsArray,
  5104. updated: mergeAsArray,
  5105. beforeDestroy: mergeAsArray,
  5106. beforeUnmount: mergeAsArray,
  5107. destroyed: mergeAsArray,
  5108. unmounted: mergeAsArray,
  5109. activated: mergeAsArray,
  5110. deactivated: mergeAsArray,
  5111. errorCaptured: mergeAsArray,
  5112. serverPrefetch: mergeAsArray,
  5113. // assets
  5114. components: mergeObjectOptions,
  5115. directives: mergeObjectOptions,
  5116. // watch
  5117. watch: mergeWatchOptions,
  5118. // provide / inject
  5119. provide: mergeDataFn,
  5120. inject: mergeInject
  5121. };
  5122. function mergeDataFn(to, from) {
  5123. if (!from) {
  5124. return to;
  5125. }
  5126. if (!to) {
  5127. return from;
  5128. }
  5129. return function mergedDataFn() {
  5130. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  5131. };
  5132. }
  5133. function mergeInject(to, from) {
  5134. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5135. }
  5136. function normalizeInject(raw) {
  5137. if (isArray(raw)) {
  5138. const res = {};
  5139. for (let i = 0; i < raw.length; i++) {
  5140. res[raw[i]] = raw[i];
  5141. }
  5142. return res;
  5143. }
  5144. return raw;
  5145. }
  5146. function mergeAsArray(to, from) {
  5147. return to ? [...new Set([].concat(to, from))] : from;
  5148. }
  5149. function mergeObjectOptions(to, from) {
  5150. return to ? extend(extend(Object.create(null), to), from) : from;
  5151. }
  5152. function mergeWatchOptions(to, from) {
  5153. if (!to)
  5154. return from;
  5155. if (!from)
  5156. return to;
  5157. const merged = extend(Object.create(null), to);
  5158. for (const key in from) {
  5159. merged[key] = mergeAsArray(to[key], from[key]);
  5160. }
  5161. return merged;
  5162. }
  5163. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  5164. isSSR = false) {
  5165. const props = {};
  5166. const attrs = {};
  5167. def(attrs, InternalObjectKey, 1);
  5168. instance.propsDefaults = Object.create(null);
  5169. setFullProps(instance, rawProps, props, attrs);
  5170. // ensure all declared prop keys are present
  5171. for (const key in instance.propsOptions[0]) {
  5172. if (!(key in props)) {
  5173. props[key] = undefined;
  5174. }
  5175. }
  5176. // validation
  5177. {
  5178. validateProps(rawProps || {}, props, instance);
  5179. }
  5180. if (isStateful) {
  5181. // stateful
  5182. instance.props = isSSR ? props : shallowReactive(props);
  5183. }
  5184. else {
  5185. if (!instance.type.props) {
  5186. // functional w/ optional props, props === attrs
  5187. instance.props = attrs;
  5188. }
  5189. else {
  5190. // functional w/ declared props
  5191. instance.props = props;
  5192. }
  5193. }
  5194. instance.attrs = attrs;
  5195. }
  5196. function isInHmrContext(instance) {
  5197. while (instance) {
  5198. if (instance.type.__hmrId)
  5199. return true;
  5200. instance = instance.parent;
  5201. }
  5202. }
  5203. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5204. const { props, attrs, vnode: { patchFlag } } = instance;
  5205. const rawCurrentProps = toRaw(props);
  5206. const [options] = instance.propsOptions;
  5207. let hasAttrsChanged = false;
  5208. if (
  5209. // always force full diff in dev
  5210. // - #1942 if hmr is enabled with sfc component
  5211. // - vite#872 non-sfc component used by sfc component
  5212. !(isInHmrContext(instance)) &&
  5213. (optimized || patchFlag > 0) &&
  5214. !(patchFlag & 16 /* PatchFlags.FULL_PROPS */)) {
  5215. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  5216. // Compiler-generated props & no keys change, just set the updated
  5217. // the props.
  5218. const propsToUpdate = instance.vnode.dynamicProps;
  5219. for (let i = 0; i < propsToUpdate.length; i++) {
  5220. let key = propsToUpdate[i];
  5221. // skip if the prop key is a declared emit event listener
  5222. if (isEmitListener(instance.emitsOptions, key)) {
  5223. continue;
  5224. }
  5225. // PROPS flag guarantees rawProps to be non-null
  5226. const value = rawProps[key];
  5227. if (options) {
  5228. // attr / props separation was done on init and will be consistent
  5229. // in this code path, so just check if attrs have it.
  5230. if (hasOwn(attrs, key)) {
  5231. if (value !== attrs[key]) {
  5232. attrs[key] = value;
  5233. hasAttrsChanged = true;
  5234. }
  5235. }
  5236. else {
  5237. const camelizedKey = camelize(key);
  5238. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  5239. }
  5240. }
  5241. else {
  5242. if (value !== attrs[key]) {
  5243. attrs[key] = value;
  5244. hasAttrsChanged = true;
  5245. }
  5246. }
  5247. }
  5248. }
  5249. }
  5250. else {
  5251. // full props update.
  5252. if (setFullProps(instance, rawProps, props, attrs)) {
  5253. hasAttrsChanged = true;
  5254. }
  5255. // in case of dynamic props, check if we need to delete keys from
  5256. // the props object
  5257. let kebabKey;
  5258. for (const key in rawCurrentProps) {
  5259. if (!rawProps ||
  5260. // for camelCase
  5261. (!hasOwn(rawProps, key) &&
  5262. // it's possible the original props was passed in as kebab-case
  5263. // and converted to camelCase (#955)
  5264. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  5265. if (options) {
  5266. if (rawPrevProps &&
  5267. // for camelCase
  5268. (rawPrevProps[key] !== undefined ||
  5269. // for kebab-case
  5270. rawPrevProps[kebabKey] !== undefined)) {
  5271. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  5272. }
  5273. }
  5274. else {
  5275. delete props[key];
  5276. }
  5277. }
  5278. }
  5279. // in the case of functional component w/o props declaration, props and
  5280. // attrs point to the same object so it should already have been updated.
  5281. if (attrs !== rawCurrentProps) {
  5282. for (const key in attrs) {
  5283. if (!rawProps ||
  5284. (!hasOwn(rawProps, key) &&
  5285. (!false ))) {
  5286. delete attrs[key];
  5287. hasAttrsChanged = true;
  5288. }
  5289. }
  5290. }
  5291. }
  5292. // trigger updates for $attrs in case it's used in component slots
  5293. if (hasAttrsChanged) {
  5294. trigger(instance, "set" /* TriggerOpTypes.SET */, '$attrs');
  5295. }
  5296. {
  5297. validateProps(rawProps || {}, props, instance);
  5298. }
  5299. }
  5300. function setFullProps(instance, rawProps, props, attrs) {
  5301. const [options, needCastKeys] = instance.propsOptions;
  5302. let hasAttrsChanged = false;
  5303. let rawCastValues;
  5304. if (rawProps) {
  5305. for (let key in rawProps) {
  5306. // key, ref are reserved and never passed down
  5307. if (isReservedProp(key)) {
  5308. continue;
  5309. }
  5310. const value = rawProps[key];
  5311. // prop option names are camelized during normalization, so to support
  5312. // kebab -> camel conversion here we need to camelize the key.
  5313. let camelKey;
  5314. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  5315. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5316. props[camelKey] = value;
  5317. }
  5318. else {
  5319. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5320. }
  5321. }
  5322. else if (!isEmitListener(instance.emitsOptions, key)) {
  5323. if (!(key in attrs) || value !== attrs[key]) {
  5324. attrs[key] = value;
  5325. hasAttrsChanged = true;
  5326. }
  5327. }
  5328. }
  5329. }
  5330. if (needCastKeys) {
  5331. const rawCurrentProps = toRaw(props);
  5332. const castValues = rawCastValues || EMPTY_OBJ;
  5333. for (let i = 0; i < needCastKeys.length; i++) {
  5334. const key = needCastKeys[i];
  5335. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  5336. }
  5337. }
  5338. return hasAttrsChanged;
  5339. }
  5340. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5341. const opt = options[key];
  5342. if (opt != null) {
  5343. const hasDefault = hasOwn(opt, 'default');
  5344. // default values
  5345. if (hasDefault && value === undefined) {
  5346. const defaultValue = opt.default;
  5347. if (opt.type !== Function && isFunction(defaultValue)) {
  5348. const { propsDefaults } = instance;
  5349. if (key in propsDefaults) {
  5350. value = propsDefaults[key];
  5351. }
  5352. else {
  5353. setCurrentInstance(instance);
  5354. value = propsDefaults[key] = defaultValue.call(null, props);
  5355. unsetCurrentInstance();
  5356. }
  5357. }
  5358. else {
  5359. value = defaultValue;
  5360. }
  5361. }
  5362. // boolean casting
  5363. if (opt[0 /* BooleanFlags.shouldCast */]) {
  5364. if (isAbsent && !hasDefault) {
  5365. value = false;
  5366. }
  5367. else if (opt[1 /* BooleanFlags.shouldCastTrue */] &&
  5368. (value === '' || value === hyphenate(key))) {
  5369. value = true;
  5370. }
  5371. }
  5372. }
  5373. return value;
  5374. }
  5375. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5376. const cache = appContext.propsCache;
  5377. const cached = cache.get(comp);
  5378. if (cached) {
  5379. return cached;
  5380. }
  5381. const raw = comp.props;
  5382. const normalized = {};
  5383. const needCastKeys = [];
  5384. // apply mixin/extends props
  5385. let hasExtends = false;
  5386. if (!isFunction(comp)) {
  5387. const extendProps = (raw) => {
  5388. hasExtends = true;
  5389. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  5390. extend(normalized, props);
  5391. if (keys)
  5392. needCastKeys.push(...keys);
  5393. };
  5394. if (!asMixin && appContext.mixins.length) {
  5395. appContext.mixins.forEach(extendProps);
  5396. }
  5397. if (comp.extends) {
  5398. extendProps(comp.extends);
  5399. }
  5400. if (comp.mixins) {
  5401. comp.mixins.forEach(extendProps);
  5402. }
  5403. }
  5404. if (!raw && !hasExtends) {
  5405. if (isObject(comp)) {
  5406. cache.set(comp, EMPTY_ARR);
  5407. }
  5408. return EMPTY_ARR;
  5409. }
  5410. if (isArray(raw)) {
  5411. for (let i = 0; i < raw.length; i++) {
  5412. if (!isString(raw[i])) {
  5413. warn$1(`props must be strings when using array syntax.`, raw[i]);
  5414. }
  5415. const normalizedKey = camelize(raw[i]);
  5416. if (validatePropName(normalizedKey)) {
  5417. normalized[normalizedKey] = EMPTY_OBJ;
  5418. }
  5419. }
  5420. }
  5421. else if (raw) {
  5422. if (!isObject(raw)) {
  5423. warn$1(`invalid props options`, raw);
  5424. }
  5425. for (const key in raw) {
  5426. const normalizedKey = camelize(key);
  5427. if (validatePropName(normalizedKey)) {
  5428. const opt = raw[key];
  5429. const prop = (normalized[normalizedKey] =
  5430. isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
  5431. if (prop) {
  5432. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5433. const stringIndex = getTypeIndex(String, prop.type);
  5434. prop[0 /* BooleanFlags.shouldCast */] = booleanIndex > -1;
  5435. prop[1 /* BooleanFlags.shouldCastTrue */] =
  5436. stringIndex < 0 || booleanIndex < stringIndex;
  5437. // if the prop needs boolean casting or default value
  5438. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  5439. needCastKeys.push(normalizedKey);
  5440. }
  5441. }
  5442. }
  5443. }
  5444. }
  5445. const res = [normalized, needCastKeys];
  5446. if (isObject(comp)) {
  5447. cache.set(comp, res);
  5448. }
  5449. return res;
  5450. }
  5451. function validatePropName(key) {
  5452. if (key[0] !== '$') {
  5453. return true;
  5454. }
  5455. else {
  5456. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  5457. }
  5458. return false;
  5459. }
  5460. // use function string name to check type constructors
  5461. // so that it works across vms / iframes.
  5462. function getType(ctor) {
  5463. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  5464. return match ? match[1] : ctor === null ? 'null' : '';
  5465. }
  5466. function isSameType(a, b) {
  5467. return getType(a) === getType(b);
  5468. }
  5469. function getTypeIndex(type, expectedTypes) {
  5470. if (isArray(expectedTypes)) {
  5471. return expectedTypes.findIndex(t => isSameType(t, type));
  5472. }
  5473. else if (isFunction(expectedTypes)) {
  5474. return isSameType(expectedTypes, type) ? 0 : -1;
  5475. }
  5476. return -1;
  5477. }
  5478. /**
  5479. * dev only
  5480. */
  5481. function validateProps(rawProps, props, instance) {
  5482. const resolvedValues = toRaw(props);
  5483. const options = instance.propsOptions[0];
  5484. for (const key in options) {
  5485. let opt = options[key];
  5486. if (opt == null)
  5487. continue;
  5488. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  5489. }
  5490. }
  5491. /**
  5492. * dev only
  5493. */
  5494. function validateProp(name, value, prop, isAbsent) {
  5495. const { type, required, validator } = prop;
  5496. // required!
  5497. if (required && isAbsent) {
  5498. warn$1('Missing required prop: "' + name + '"');
  5499. return;
  5500. }
  5501. // missing but optional
  5502. if (value == null && !prop.required) {
  5503. return;
  5504. }
  5505. // type check
  5506. if (type != null && type !== true) {
  5507. let isValid = false;
  5508. const types = isArray(type) ? type : [type];
  5509. const expectedTypes = [];
  5510. // value is valid as long as one of the specified types match
  5511. for (let i = 0; i < types.length && !isValid; i++) {
  5512. const { valid, expectedType } = assertType(value, types[i]);
  5513. expectedTypes.push(expectedType || '');
  5514. isValid = valid;
  5515. }
  5516. if (!isValid) {
  5517. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  5518. return;
  5519. }
  5520. }
  5521. // custom validator
  5522. if (validator && !validator(value)) {
  5523. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  5524. }
  5525. }
  5526. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  5527. /**
  5528. * dev only
  5529. */
  5530. function assertType(value, type) {
  5531. let valid;
  5532. const expectedType = getType(type);
  5533. if (isSimpleType(expectedType)) {
  5534. const t = typeof value;
  5535. valid = t === expectedType.toLowerCase();
  5536. // for primitive wrapper objects
  5537. if (!valid && t === 'object') {
  5538. valid = value instanceof type;
  5539. }
  5540. }
  5541. else if (expectedType === 'Object') {
  5542. valid = isObject(value);
  5543. }
  5544. else if (expectedType === 'Array') {
  5545. valid = isArray(value);
  5546. }
  5547. else if (expectedType === 'null') {
  5548. valid = value === null;
  5549. }
  5550. else {
  5551. valid = value instanceof type;
  5552. }
  5553. return {
  5554. valid,
  5555. expectedType
  5556. };
  5557. }
  5558. /**
  5559. * dev only
  5560. */
  5561. function getInvalidTypeMessage(name, value, expectedTypes) {
  5562. let message = `Invalid prop: type check failed for prop "${name}".` +
  5563. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  5564. const expectedType = expectedTypes[0];
  5565. const receivedType = toRawType(value);
  5566. const expectedValue = styleValue(value, expectedType);
  5567. const receivedValue = styleValue(value, receivedType);
  5568. // check if we need to specify expected value
  5569. if (expectedTypes.length === 1 &&
  5570. isExplicable(expectedType) &&
  5571. !isBoolean(expectedType, receivedType)) {
  5572. message += ` with value ${expectedValue}`;
  5573. }
  5574. message += `, got ${receivedType} `;
  5575. // check if we need to specify received value
  5576. if (isExplicable(receivedType)) {
  5577. message += `with value ${receivedValue}.`;
  5578. }
  5579. return message;
  5580. }
  5581. /**
  5582. * dev only
  5583. */
  5584. function styleValue(value, type) {
  5585. if (type === 'String') {
  5586. return `"${value}"`;
  5587. }
  5588. else if (type === 'Number') {
  5589. return `${Number(value)}`;
  5590. }
  5591. else {
  5592. return `${value}`;
  5593. }
  5594. }
  5595. /**
  5596. * dev only
  5597. */
  5598. function isExplicable(type) {
  5599. const explicitTypes = ['string', 'number', 'boolean'];
  5600. return explicitTypes.some(elem => type.toLowerCase() === elem);
  5601. }
  5602. /**
  5603. * dev only
  5604. */
  5605. function isBoolean(...args) {
  5606. return args.some(elem => elem.toLowerCase() === 'boolean');
  5607. }
  5608. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  5609. const normalizeSlotValue = (value) => isArray(value)
  5610. ? value.map(normalizeVNode)
  5611. : [normalizeVNode(value)];
  5612. const normalizeSlot = (key, rawSlot, ctx) => {
  5613. if (rawSlot._n) {
  5614. // already normalized - #5353
  5615. return rawSlot;
  5616. }
  5617. const normalized = withCtx((...args) => {
  5618. if (true && currentInstance) {
  5619. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  5620. `this will not track dependencies used in the slot. ` +
  5621. `Invoke the slot function inside the render function instead.`);
  5622. }
  5623. return normalizeSlotValue(rawSlot(...args));
  5624. }, ctx);
  5625. normalized._c = false;
  5626. return normalized;
  5627. };
  5628. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5629. const ctx = rawSlots._ctx;
  5630. for (const key in rawSlots) {
  5631. if (isInternalKey(key))
  5632. continue;
  5633. const value = rawSlots[key];
  5634. if (isFunction(value)) {
  5635. slots[key] = normalizeSlot(key, value, ctx);
  5636. }
  5637. else if (value != null) {
  5638. {
  5639. warn$1(`Non-function value encountered for slot "${key}". ` +
  5640. `Prefer function slots for better performance.`);
  5641. }
  5642. const normalized = normalizeSlotValue(value);
  5643. slots[key] = () => normalized;
  5644. }
  5645. }
  5646. };
  5647. const normalizeVNodeSlots = (instance, children) => {
  5648. if (!isKeepAlive(instance.vnode) &&
  5649. !(false )) {
  5650. warn$1(`Non-function value encountered for default slot. ` +
  5651. `Prefer function slots for better performance.`);
  5652. }
  5653. const normalized = normalizeSlotValue(children);
  5654. instance.slots.default = () => normalized;
  5655. };
  5656. const initSlots = (instance, children) => {
  5657. if (instance.vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  5658. const type = children._;
  5659. if (type) {
  5660. // users can get the shallow readonly version of the slots object through `this.$slots`,
  5661. // we should avoid the proxy object polluting the slots of the internal instance
  5662. instance.slots = toRaw(children);
  5663. // make compiler marker non-enumerable
  5664. def(children, '_', type);
  5665. }
  5666. else {
  5667. normalizeObjectSlots(children, (instance.slots = {}));
  5668. }
  5669. }
  5670. else {
  5671. instance.slots = {};
  5672. if (children) {
  5673. normalizeVNodeSlots(instance, children);
  5674. }
  5675. }
  5676. def(instance.slots, InternalObjectKey, 1);
  5677. };
  5678. const updateSlots = (instance, children, optimized) => {
  5679. const { vnode, slots } = instance;
  5680. let needDeletionCheck = true;
  5681. let deletionComparisonTarget = EMPTY_OBJ;
  5682. if (vnode.shapeFlag & 32 /* ShapeFlags.SLOTS_CHILDREN */) {
  5683. const type = children._;
  5684. if (type) {
  5685. // compiled slots.
  5686. if (isHmrUpdating) {
  5687. // Parent was HMR updated so slot content may have changed.
  5688. // force update slots and mark instance for hmr as well
  5689. extend(slots, children);
  5690. }
  5691. else if (optimized && type === 1 /* SlotFlags.STABLE */) {
  5692. // compiled AND stable.
  5693. // no need to update, and skip stale slots removal.
  5694. needDeletionCheck = false;
  5695. }
  5696. else {
  5697. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  5698. // normalization.
  5699. extend(slots, children);
  5700. // #2893
  5701. // when rendering the optimized slots by manually written render function,
  5702. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  5703. // i.e. let the `renderSlot` create the bailed Fragment
  5704. if (!optimized && type === 1 /* SlotFlags.STABLE */) {
  5705. delete slots._;
  5706. }
  5707. }
  5708. }
  5709. else {
  5710. needDeletionCheck = !children.$stable;
  5711. normalizeObjectSlots(children, slots);
  5712. }
  5713. deletionComparisonTarget = children;
  5714. }
  5715. else if (children) {
  5716. // non slot object children (direct value) passed to a component
  5717. normalizeVNodeSlots(instance, children);
  5718. deletionComparisonTarget = { default: 1 };
  5719. }
  5720. // delete stale slots
  5721. if (needDeletionCheck) {
  5722. for (const key in slots) {
  5723. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5724. delete slots[key];
  5725. }
  5726. }
  5727. }
  5728. };
  5729. function createAppContext() {
  5730. return {
  5731. app: null,
  5732. config: {
  5733. isNativeTag: NO,
  5734. performance: false,
  5735. globalProperties: {},
  5736. optionMergeStrategies: {},
  5737. errorHandler: undefined,
  5738. warnHandler: undefined,
  5739. compilerOptions: {}
  5740. },
  5741. mixins: [],
  5742. components: {},
  5743. directives: {},
  5744. provides: Object.create(null),
  5745. optionsCache: new WeakMap(),
  5746. propsCache: new WeakMap(),
  5747. emitsCache: new WeakMap()
  5748. };
  5749. }
  5750. let uid = 0;
  5751. function createAppAPI(render, hydrate) {
  5752. return function createApp(rootComponent, rootProps = null) {
  5753. if (!isFunction(rootComponent)) {
  5754. rootComponent = Object.assign({}, rootComponent);
  5755. }
  5756. if (rootProps != null && !isObject(rootProps)) {
  5757. warn$1(`root props passed to app.mount() must be an object.`);
  5758. rootProps = null;
  5759. }
  5760. const context = createAppContext();
  5761. const installedPlugins = new Set();
  5762. let isMounted = false;
  5763. const app = (context.app = {
  5764. _uid: uid++,
  5765. _component: rootComponent,
  5766. _props: rootProps,
  5767. _container: null,
  5768. _context: context,
  5769. _instance: null,
  5770. version,
  5771. get config() {
  5772. return context.config;
  5773. },
  5774. set config(v) {
  5775. {
  5776. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  5777. }
  5778. },
  5779. use(plugin, ...options) {
  5780. if (installedPlugins.has(plugin)) {
  5781. warn$1(`Plugin has already been applied to target app.`);
  5782. }
  5783. else if (plugin && isFunction(plugin.install)) {
  5784. installedPlugins.add(plugin);
  5785. plugin.install(app, ...options);
  5786. }
  5787. else if (isFunction(plugin)) {
  5788. installedPlugins.add(plugin);
  5789. plugin(app, ...options);
  5790. }
  5791. else {
  5792. warn$1(`A plugin must either be a function or an object with an "install" ` +
  5793. `function.`);
  5794. }
  5795. return app;
  5796. },
  5797. mixin(mixin) {
  5798. {
  5799. if (!context.mixins.includes(mixin)) {
  5800. context.mixins.push(mixin);
  5801. }
  5802. else {
  5803. warn$1('Mixin has already been applied to target app' +
  5804. (mixin.name ? `: ${mixin.name}` : ''));
  5805. }
  5806. }
  5807. return app;
  5808. },
  5809. component(name, component) {
  5810. {
  5811. validateComponentName(name, context.config);
  5812. }
  5813. if (!component) {
  5814. return context.components[name];
  5815. }
  5816. if (context.components[name]) {
  5817. warn$1(`Component "${name}" has already been registered in target app.`);
  5818. }
  5819. context.components[name] = component;
  5820. return app;
  5821. },
  5822. directive(name, directive) {
  5823. {
  5824. validateDirectiveName(name);
  5825. }
  5826. if (!directive) {
  5827. return context.directives[name];
  5828. }
  5829. if (context.directives[name]) {
  5830. warn$1(`Directive "${name}" has already been registered in target app.`);
  5831. }
  5832. context.directives[name] = directive;
  5833. return app;
  5834. },
  5835. mount(rootContainer, isHydrate, isSVG) {
  5836. if (!isMounted) {
  5837. // #5571
  5838. if (rootContainer.__vue_app__) {
  5839. warn$1(`There is already an app instance mounted on the host container.\n` +
  5840. ` If you want to mount another app on the same host container,` +
  5841. ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
  5842. }
  5843. const vnode = createVNode(rootComponent, rootProps);
  5844. // store app context on the root VNode.
  5845. // this will be set on the root instance on initial mount.
  5846. vnode.appContext = context;
  5847. // HMR root reload
  5848. {
  5849. context.reload = () => {
  5850. render(cloneVNode(vnode), rootContainer, isSVG);
  5851. };
  5852. }
  5853. if (isHydrate && hydrate) {
  5854. hydrate(vnode, rootContainer);
  5855. }
  5856. else {
  5857. render(vnode, rootContainer, isSVG);
  5858. }
  5859. isMounted = true;
  5860. app._container = rootContainer;
  5861. rootContainer.__vue_app__ = app;
  5862. {
  5863. app._instance = vnode.component;
  5864. devtoolsInitApp(app, version);
  5865. }
  5866. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5867. }
  5868. else {
  5869. warn$1(`App has already been mounted.\n` +
  5870. `If you want to remount the same app, move your app creation logic ` +
  5871. `into a factory function and create fresh app instances for each ` +
  5872. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  5873. }
  5874. },
  5875. unmount() {
  5876. if (isMounted) {
  5877. render(null, app._container);
  5878. {
  5879. app._instance = null;
  5880. devtoolsUnmountApp(app);
  5881. }
  5882. delete app._container.__vue_app__;
  5883. }
  5884. else {
  5885. warn$1(`Cannot unmount an app that is not mounted.`);
  5886. }
  5887. },
  5888. provide(key, value) {
  5889. if (key in context.provides) {
  5890. warn$1(`App already provides property with key "${String(key)}". ` +
  5891. `It will be overwritten with the new value.`);
  5892. }
  5893. context.provides[key] = value;
  5894. return app;
  5895. }
  5896. });
  5897. return app;
  5898. };
  5899. }
  5900. /**
  5901. * Function for handling a template ref
  5902. */
  5903. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5904. if (isArray(rawRef)) {
  5905. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  5906. return;
  5907. }
  5908. if (isAsyncWrapper(vnode) && !isUnmount) {
  5909. // when mounting async components, nothing needs to be done,
  5910. // because the template ref is forwarded to inner component
  5911. return;
  5912. }
  5913. const refValue = vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */
  5914. ? getExposeProxy(vnode.component) || vnode.component.proxy
  5915. : vnode.el;
  5916. const value = isUnmount ? null : refValue;
  5917. const { i: owner, r: ref } = rawRef;
  5918. if (!owner) {
  5919. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  5920. `A vnode with ref must be created inside the render function.`);
  5921. return;
  5922. }
  5923. const oldRef = oldRawRef && oldRawRef.r;
  5924. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  5925. const setupState = owner.setupState;
  5926. // dynamic ref changed. unset old ref
  5927. if (oldRef != null && oldRef !== ref) {
  5928. if (isString(oldRef)) {
  5929. refs[oldRef] = null;
  5930. if (hasOwn(setupState, oldRef)) {
  5931. setupState[oldRef] = null;
  5932. }
  5933. }
  5934. else if (isRef(oldRef)) {
  5935. oldRef.value = null;
  5936. }
  5937. }
  5938. if (isFunction(ref)) {
  5939. callWithErrorHandling(ref, owner, 12 /* ErrorCodes.FUNCTION_REF */, [value, refs]);
  5940. }
  5941. else {
  5942. const _isString = isString(ref);
  5943. const _isRef = isRef(ref);
  5944. if (_isString || _isRef) {
  5945. const doSet = () => {
  5946. if (rawRef.f) {
  5947. const existing = _isString
  5948. ? hasOwn(setupState, ref)
  5949. ? setupState[ref]
  5950. : refs[ref]
  5951. : ref.value;
  5952. if (isUnmount) {
  5953. isArray(existing) && remove(existing, refValue);
  5954. }
  5955. else {
  5956. if (!isArray(existing)) {
  5957. if (_isString) {
  5958. refs[ref] = [refValue];
  5959. if (hasOwn(setupState, ref)) {
  5960. setupState[ref] = refs[ref];
  5961. }
  5962. }
  5963. else {
  5964. ref.value = [refValue];
  5965. if (rawRef.k)
  5966. refs[rawRef.k] = ref.value;
  5967. }
  5968. }
  5969. else if (!existing.includes(refValue)) {
  5970. existing.push(refValue);
  5971. }
  5972. }
  5973. }
  5974. else if (_isString) {
  5975. refs[ref] = value;
  5976. if (hasOwn(setupState, ref)) {
  5977. setupState[ref] = value;
  5978. }
  5979. }
  5980. else if (_isRef) {
  5981. ref.value = value;
  5982. if (rawRef.k)
  5983. refs[rawRef.k] = value;
  5984. }
  5985. else {
  5986. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5987. }
  5988. };
  5989. if (value) {
  5990. doSet.id = -1;
  5991. queuePostRenderEffect(doSet, parentSuspense);
  5992. }
  5993. else {
  5994. doSet();
  5995. }
  5996. }
  5997. else {
  5998. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5999. }
  6000. }
  6001. }
  6002. let hasMismatch = false;
  6003. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  6004. const isComment = (node) => node.nodeType === 8 /* DOMNodeTypes.COMMENT */;
  6005. // Note: hydration is DOM-specific
  6006. // But we have to place it in core due to tight coupling with core - splitting
  6007. // it out creates a ton of unnecessary complexity.
  6008. // Hydration also depends on some renderer internal logic which needs to be
  6009. // passed in via arguments.
  6010. function createHydrationFunctions(rendererInternals) {
  6011. const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  6012. const hydrate = (vnode, container) => {
  6013. if (!container.hasChildNodes()) {
  6014. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  6015. `Performing full mount instead.`);
  6016. patch(null, vnode, container);
  6017. flushPostFlushCbs();
  6018. container._vnode = vnode;
  6019. return;
  6020. }
  6021. hasMismatch = false;
  6022. hydrateNode(container.firstChild, vnode, null, null, null);
  6023. flushPostFlushCbs();
  6024. container._vnode = vnode;
  6025. if (hasMismatch && !false) {
  6026. // this error should show up in production
  6027. console.error(`Hydration completed but contains mismatches.`);
  6028. }
  6029. };
  6030. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  6031. const isFragmentStart = isComment(node) && node.data === '[';
  6032. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  6033. const { type, ref, shapeFlag, patchFlag } = vnode;
  6034. let domType = node.nodeType;
  6035. vnode.el = node;
  6036. if (patchFlag === -2 /* PatchFlags.BAIL */) {
  6037. optimized = false;
  6038. vnode.dynamicChildren = null;
  6039. }
  6040. let nextNode = null;
  6041. switch (type) {
  6042. case Text:
  6043. if (domType !== 3 /* DOMNodeTypes.TEXT */) {
  6044. // #5728 empty text node inside a slot can cause hydration failure
  6045. // because the server rendered HTML won't contain a text node
  6046. if (vnode.children === '') {
  6047. insert((vnode.el = createText('')), parentNode(node), node);
  6048. nextNode = node;
  6049. }
  6050. else {
  6051. nextNode = onMismatch();
  6052. }
  6053. }
  6054. else {
  6055. if (node.data !== vnode.children) {
  6056. hasMismatch = true;
  6057. warn$1(`Hydration text mismatch:` +
  6058. `\n- Client: ${JSON.stringify(node.data)}` +
  6059. `\n- Server: ${JSON.stringify(vnode.children)}`);
  6060. node.data = vnode.children;
  6061. }
  6062. nextNode = nextSibling(node);
  6063. }
  6064. break;
  6065. case Comment:
  6066. if (domType !== 8 /* DOMNodeTypes.COMMENT */ || isFragmentStart) {
  6067. nextNode = onMismatch();
  6068. }
  6069. else {
  6070. nextNode = nextSibling(node);
  6071. }
  6072. break;
  6073. case Static:
  6074. if (isFragmentStart) {
  6075. // entire template is static but SSRed as a fragment
  6076. node = nextSibling(node);
  6077. domType = node.nodeType;
  6078. }
  6079. if (domType === 1 /* DOMNodeTypes.ELEMENT */ || domType === 3 /* DOMNodeTypes.TEXT */) {
  6080. // determine anchor, adopt content
  6081. nextNode = node;
  6082. // if the static vnode has its content stripped during build,
  6083. // adopt it from the server-rendered HTML.
  6084. const needToAdoptContent = !vnode.children.length;
  6085. for (let i = 0; i < vnode.staticCount; i++) {
  6086. if (needToAdoptContent)
  6087. vnode.children +=
  6088. nextNode.nodeType === 1 /* DOMNodeTypes.ELEMENT */
  6089. ? nextNode.outerHTML
  6090. : nextNode.data;
  6091. if (i === vnode.staticCount - 1) {
  6092. vnode.anchor = nextNode;
  6093. }
  6094. nextNode = nextSibling(nextNode);
  6095. }
  6096. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  6097. }
  6098. else {
  6099. onMismatch();
  6100. }
  6101. break;
  6102. case Fragment:
  6103. if (!isFragmentStart) {
  6104. nextNode = onMismatch();
  6105. }
  6106. else {
  6107. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6108. }
  6109. break;
  6110. default:
  6111. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  6112. if (domType !== 1 /* DOMNodeTypes.ELEMENT */ ||
  6113. vnode.type.toLowerCase() !==
  6114. node.tagName.toLowerCase()) {
  6115. nextNode = onMismatch();
  6116. }
  6117. else {
  6118. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6119. }
  6120. }
  6121. else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  6122. // when setting up the render effect, if the initial vnode already
  6123. // has .el set, the component will perform hydration instead of mount
  6124. // on its sub-tree.
  6125. vnode.slotScopeIds = slotScopeIds;
  6126. const container = parentNode(node);
  6127. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  6128. // component may be async, so in the case of fragments we cannot rely
  6129. // on component's rendered output to determine the end of the fragment
  6130. // instead, we do a lookahead to find the end anchor node.
  6131. nextNode = isFragmentStart
  6132. ? locateClosingAsyncAnchor(node)
  6133. : nextSibling(node);
  6134. // #4293 teleport as component root
  6135. if (nextNode &&
  6136. isComment(nextNode) &&
  6137. nextNode.data === 'teleport end') {
  6138. nextNode = nextSibling(nextNode);
  6139. }
  6140. // #3787
  6141. // if component is async, it may get moved / unmounted before its
  6142. // inner component is loaded, so we need to give it a placeholder
  6143. // vnode that matches its adopted DOM.
  6144. if (isAsyncWrapper(vnode)) {
  6145. let subTree;
  6146. if (isFragmentStart) {
  6147. subTree = createVNode(Fragment);
  6148. subTree.anchor = nextNode
  6149. ? nextNode.previousSibling
  6150. : container.lastChild;
  6151. }
  6152. else {
  6153. subTree =
  6154. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  6155. }
  6156. subTree.el = node;
  6157. vnode.component.subTree = subTree;
  6158. }
  6159. }
  6160. else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  6161. if (domType !== 8 /* DOMNodeTypes.COMMENT */) {
  6162. nextNode = onMismatch();
  6163. }
  6164. else {
  6165. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  6166. }
  6167. }
  6168. else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  6169. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  6170. }
  6171. else {
  6172. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  6173. }
  6174. }
  6175. if (ref != null) {
  6176. setRef(ref, null, parentSuspense, vnode);
  6177. }
  6178. return nextNode;
  6179. };
  6180. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6181. optimized = optimized || !!vnode.dynamicChildren;
  6182. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6183. // #4006 for form elements with non-string v-model value bindings
  6184. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  6185. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  6186. // skip props & children if this is hoisted static nodes
  6187. // #5405 in dev, always hydrate children for HMR
  6188. {
  6189. if (dirs) {
  6190. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6191. }
  6192. // props
  6193. if (props) {
  6194. if (forcePatchValue ||
  6195. !optimized ||
  6196. patchFlag & (16 /* PatchFlags.FULL_PROPS */ | 32 /* PatchFlags.HYDRATE_EVENTS */)) {
  6197. for (const key in props) {
  6198. if ((forcePatchValue && key.endsWith('value')) ||
  6199. (isOn(key) && !isReservedProp(key))) {
  6200. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  6201. }
  6202. }
  6203. }
  6204. else if (props.onClick) {
  6205. // Fast path for click listeners (which is most often) to avoid
  6206. // iterating through props.
  6207. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  6208. }
  6209. }
  6210. // vnode / directive hooks
  6211. let vnodeHooks;
  6212. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  6213. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6214. }
  6215. if (dirs) {
  6216. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6217. }
  6218. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6219. queueEffectWithSuspense(() => {
  6220. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6221. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6222. }, parentSuspense);
  6223. }
  6224. // children
  6225. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */ &&
  6226. // skip if element has innerHTML / textContent
  6227. !(props && (props.innerHTML || props.textContent))) {
  6228. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  6229. let hasWarned = false;
  6230. while (next) {
  6231. hasMismatch = true;
  6232. if (!hasWarned) {
  6233. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  6234. `server rendered element contains more child nodes than client vdom.`);
  6235. hasWarned = true;
  6236. }
  6237. // The SSRed DOM contains more nodes than it should. Remove them.
  6238. const cur = next;
  6239. next = next.nextSibling;
  6240. remove(cur);
  6241. }
  6242. }
  6243. else if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  6244. if (el.textContent !== vnode.children) {
  6245. hasMismatch = true;
  6246. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  6247. `- Client: ${el.textContent}\n` +
  6248. `- Server: ${vnode.children}`);
  6249. el.textContent = vnode.children;
  6250. }
  6251. }
  6252. }
  6253. return el.nextSibling;
  6254. };
  6255. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6256. optimized = optimized || !!parentVNode.dynamicChildren;
  6257. const children = parentVNode.children;
  6258. const l = children.length;
  6259. let hasWarned = false;
  6260. for (let i = 0; i < l; i++) {
  6261. const vnode = optimized
  6262. ? children[i]
  6263. : (children[i] = normalizeVNode(children[i]));
  6264. if (node) {
  6265. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6266. }
  6267. else if (vnode.type === Text && !vnode.children) {
  6268. continue;
  6269. }
  6270. else {
  6271. hasMismatch = true;
  6272. if (!hasWarned) {
  6273. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  6274. `server rendered element contains fewer child nodes than client vdom.`);
  6275. hasWarned = true;
  6276. }
  6277. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  6278. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6279. }
  6280. }
  6281. return node;
  6282. };
  6283. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6284. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6285. if (fragmentSlotScopeIds) {
  6286. slotScopeIds = slotScopeIds
  6287. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6288. : fragmentSlotScopeIds;
  6289. }
  6290. const container = parentNode(node);
  6291. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  6292. if (next && isComment(next) && next.data === ']') {
  6293. return nextSibling((vnode.anchor = next));
  6294. }
  6295. else {
  6296. // fragment didn't hydrate successfully, since we didn't get a end anchor
  6297. // back. This should have led to node/children mismatch warnings.
  6298. hasMismatch = true;
  6299. // since the anchor is missing, we need to create one and insert it
  6300. insert((vnode.anchor = createComment(`]`)), container, next);
  6301. return next;
  6302. }
  6303. };
  6304. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6305. hasMismatch = true;
  6306. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* DOMNodeTypes.TEXT */
  6307. ? `(text)`
  6308. : isComment(node) && node.data === '['
  6309. ? `(start of fragment)`
  6310. : ``);
  6311. vnode.el = null;
  6312. if (isFragment) {
  6313. // remove excessive fragment nodes
  6314. const end = locateClosingAsyncAnchor(node);
  6315. while (true) {
  6316. const next = nextSibling(node);
  6317. if (next && next !== end) {
  6318. remove(next);
  6319. }
  6320. else {
  6321. break;
  6322. }
  6323. }
  6324. }
  6325. const next = nextSibling(node);
  6326. const container = parentNode(node);
  6327. remove(node);
  6328. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6329. return next;
  6330. };
  6331. const locateClosingAsyncAnchor = (node) => {
  6332. let match = 0;
  6333. while (node) {
  6334. node = nextSibling(node);
  6335. if (node && isComment(node)) {
  6336. if (node.data === '[')
  6337. match++;
  6338. if (node.data === ']') {
  6339. if (match === 0) {
  6340. return nextSibling(node);
  6341. }
  6342. else {
  6343. match--;
  6344. }
  6345. }
  6346. }
  6347. }
  6348. return node;
  6349. };
  6350. return [hydrate, hydrateNode];
  6351. }
  6352. /* eslint-disable no-restricted-globals */
  6353. let supported;
  6354. let perf;
  6355. function startMeasure(instance, type) {
  6356. if (instance.appContext.config.performance && isSupported()) {
  6357. perf.mark(`vue-${type}-${instance.uid}`);
  6358. }
  6359. {
  6360. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6361. }
  6362. }
  6363. function endMeasure(instance, type) {
  6364. if (instance.appContext.config.performance && isSupported()) {
  6365. const startTag = `vue-${type}-${instance.uid}`;
  6366. const endTag = startTag + `:end`;
  6367. perf.mark(endTag);
  6368. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  6369. perf.clearMarks(startTag);
  6370. perf.clearMarks(endTag);
  6371. }
  6372. {
  6373. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6374. }
  6375. }
  6376. function isSupported() {
  6377. if (supported !== undefined) {
  6378. return supported;
  6379. }
  6380. if (typeof window !== 'undefined' && window.performance) {
  6381. supported = true;
  6382. perf = window.performance;
  6383. }
  6384. else {
  6385. supported = false;
  6386. }
  6387. return supported;
  6388. }
  6389. const queuePostRenderEffect = queueEffectWithSuspense
  6390. ;
  6391. /**
  6392. * The createRenderer function accepts two generic arguments:
  6393. * HostNode and HostElement, corresponding to Node and Element types in the
  6394. * host environment. For example, for runtime-dom, HostNode would be the DOM
  6395. * `Node` interface and HostElement would be the DOM `Element` interface.
  6396. *
  6397. * Custom renderers can pass in the platform specific types like this:
  6398. *
  6399. * ``` js
  6400. * const { render, createApp } = createRenderer<Node, Element>({
  6401. * patchProp,
  6402. * ...nodeOps
  6403. * })
  6404. * ```
  6405. */
  6406. function createRenderer(options) {
  6407. return baseCreateRenderer(options);
  6408. }
  6409. // Separate API for creating hydration-enabled renderer.
  6410. // Hydration logic is only used when calling this function, making it
  6411. // tree-shakable.
  6412. function createHydrationRenderer(options) {
  6413. return baseCreateRenderer(options, createHydrationFunctions);
  6414. }
  6415. // implementation
  6416. function baseCreateRenderer(options, createHydrationFns) {
  6417. const target = getGlobalThis();
  6418. target.__VUE__ = true;
  6419. {
  6420. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6421. }
  6422. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, insertStaticContent: hostInsertStaticContent } = options;
  6423. // Note: functions inside this closure should use `const xxx = () => {}`
  6424. // style in order to prevent being inlined by minifiers.
  6425. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6426. if (n1 === n2) {
  6427. return;
  6428. }
  6429. // patching & not same type, unmount old tree
  6430. if (n1 && !isSameVNodeType(n1, n2)) {
  6431. anchor = getNextHostNode(n1);
  6432. unmount(n1, parentComponent, parentSuspense, true);
  6433. n1 = null;
  6434. }
  6435. if (n2.patchFlag === -2 /* PatchFlags.BAIL */) {
  6436. optimized = false;
  6437. n2.dynamicChildren = null;
  6438. }
  6439. const { type, ref, shapeFlag } = n2;
  6440. switch (type) {
  6441. case Text:
  6442. processText(n1, n2, container, anchor);
  6443. break;
  6444. case Comment:
  6445. processCommentNode(n1, n2, container, anchor);
  6446. break;
  6447. case Static:
  6448. if (n1 == null) {
  6449. mountStaticNode(n2, container, anchor, isSVG);
  6450. }
  6451. else {
  6452. patchStaticNode(n1, n2, container, isSVG);
  6453. }
  6454. break;
  6455. case Fragment:
  6456. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6457. break;
  6458. default:
  6459. if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
  6460. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6461. }
  6462. else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  6463. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6464. }
  6465. else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  6466. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6467. }
  6468. else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  6469. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6470. }
  6471. else {
  6472. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  6473. }
  6474. }
  6475. // set ref
  6476. if (ref != null && parentComponent) {
  6477. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6478. }
  6479. };
  6480. const processText = (n1, n2, container, anchor) => {
  6481. if (n1 == null) {
  6482. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  6483. }
  6484. else {
  6485. const el = (n2.el = n1.el);
  6486. if (n2.children !== n1.children) {
  6487. hostSetText(el, n2.children);
  6488. }
  6489. }
  6490. };
  6491. const processCommentNode = (n1, n2, container, anchor) => {
  6492. if (n1 == null) {
  6493. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  6494. }
  6495. else {
  6496. // there's no support for dynamic comments
  6497. n2.el = n1.el;
  6498. }
  6499. };
  6500. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6501. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  6502. };
  6503. /**
  6504. * Dev / HMR only
  6505. */
  6506. const patchStaticNode = (n1, n2, container, isSVG) => {
  6507. // static nodes are only patched during dev for HMR
  6508. if (n2.children !== n1.children) {
  6509. const anchor = hostNextSibling(n1.anchor);
  6510. // remove existing
  6511. removeStaticNode(n1);
  6512. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  6513. }
  6514. else {
  6515. n2.el = n1.el;
  6516. n2.anchor = n1.anchor;
  6517. }
  6518. };
  6519. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6520. let next;
  6521. while (el && el !== anchor) {
  6522. next = hostNextSibling(el);
  6523. hostInsert(el, container, nextSibling);
  6524. el = next;
  6525. }
  6526. hostInsert(anchor, container, nextSibling);
  6527. };
  6528. const removeStaticNode = ({ el, anchor }) => {
  6529. let next;
  6530. while (el && el !== anchor) {
  6531. next = hostNextSibling(el);
  6532. hostRemove(el);
  6533. el = next;
  6534. }
  6535. hostRemove(anchor);
  6536. };
  6537. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6538. isSVG = isSVG || n2.type === 'svg';
  6539. if (n1 == null) {
  6540. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6541. }
  6542. else {
  6543. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6544. }
  6545. };
  6546. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6547. let el;
  6548. let vnodeHook;
  6549. const { type, props, shapeFlag, transition, dirs } = vnode;
  6550. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  6551. // mount children first, since some props may rely on child content
  6552. // being already rendered, e.g. `<select value>`
  6553. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  6554. hostSetElementText(el, vnode.children);
  6555. }
  6556. else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  6557. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  6558. }
  6559. if (dirs) {
  6560. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6561. }
  6562. // props
  6563. if (props) {
  6564. for (const key in props) {
  6565. if (key !== 'value' && !isReservedProp(key)) {
  6566. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6567. }
  6568. }
  6569. /**
  6570. * Special case for setting value on DOM elements:
  6571. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  6572. * - it needs to be forced (#1471)
  6573. * #2353 proposes adding another renderer option to configure this, but
  6574. * the properties affects are so finite it is worth special casing it
  6575. * here to reduce the complexity. (Special casing it also should not
  6576. * affect non-DOM renderers)
  6577. */
  6578. if ('value' in props) {
  6579. hostPatchProp(el, 'value', null, props.value);
  6580. }
  6581. if ((vnodeHook = props.onVnodeBeforeMount)) {
  6582. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6583. }
  6584. }
  6585. // scopeId
  6586. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6587. {
  6588. Object.defineProperty(el, '__vnode', {
  6589. value: vnode,
  6590. enumerable: false
  6591. });
  6592. Object.defineProperty(el, '__vueParentComponent', {
  6593. value: parentComponent,
  6594. enumerable: false
  6595. });
  6596. }
  6597. if (dirs) {
  6598. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6599. }
  6600. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  6601. // #1689 For inside suspense + suspense resolved case, just call it
  6602. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  6603. transition &&
  6604. !transition.persisted;
  6605. if (needCallTransitionHooks) {
  6606. transition.beforeEnter(el);
  6607. }
  6608. hostInsert(el, container, anchor);
  6609. if ((vnodeHook = props && props.onVnodeMounted) ||
  6610. needCallTransitionHooks ||
  6611. dirs) {
  6612. queuePostRenderEffect(() => {
  6613. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6614. needCallTransitionHooks && transition.enter(el);
  6615. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6616. }, parentSuspense);
  6617. }
  6618. };
  6619. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6620. if (scopeId) {
  6621. hostSetScopeId(el, scopeId);
  6622. }
  6623. if (slotScopeIds) {
  6624. for (let i = 0; i < slotScopeIds.length; i++) {
  6625. hostSetScopeId(el, slotScopeIds[i]);
  6626. }
  6627. }
  6628. if (parentComponent) {
  6629. let subTree = parentComponent.subTree;
  6630. if (subTree.patchFlag > 0 &&
  6631. subTree.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */) {
  6632. subTree =
  6633. filterSingleRoot(subTree.children) || subTree;
  6634. }
  6635. if (vnode === subTree) {
  6636. const parentVNode = parentComponent.vnode;
  6637. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  6638. }
  6639. }
  6640. };
  6641. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6642. for (let i = start; i < children.length; i++) {
  6643. const child = (children[i] = optimized
  6644. ? cloneIfMounted(children[i])
  6645. : normalizeVNode(children[i]));
  6646. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6647. }
  6648. };
  6649. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6650. const el = (n2.el = n1.el);
  6651. let { patchFlag, dynamicChildren, dirs } = n2;
  6652. // #1426 take the old vnode's patch flag into account since user may clone a
  6653. // compiler-generated vnode, which de-opts to FULL_PROPS
  6654. patchFlag |= n1.patchFlag & 16 /* PatchFlags.FULL_PROPS */;
  6655. const oldProps = n1.props || EMPTY_OBJ;
  6656. const newProps = n2.props || EMPTY_OBJ;
  6657. let vnodeHook;
  6658. // disable recurse in beforeUpdate hooks
  6659. parentComponent && toggleRecurse(parentComponent, false);
  6660. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  6661. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6662. }
  6663. if (dirs) {
  6664. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  6665. }
  6666. parentComponent && toggleRecurse(parentComponent, true);
  6667. if (isHmrUpdating) {
  6668. // HMR updated, force full diff
  6669. patchFlag = 0;
  6670. optimized = false;
  6671. dynamicChildren = null;
  6672. }
  6673. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  6674. if (dynamicChildren) {
  6675. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  6676. if (parentComponent && parentComponent.type.__hmrId) {
  6677. traverseStaticChildren(n1, n2);
  6678. }
  6679. }
  6680. else if (!optimized) {
  6681. // full diff
  6682. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  6683. }
  6684. if (patchFlag > 0) {
  6685. // the presence of a patchFlag means this element's render code was
  6686. // generated by the compiler and can take the fast path.
  6687. // in this path old node and new node are guaranteed to have the same shape
  6688. // (i.e. at the exact same position in the source template)
  6689. if (patchFlag & 16 /* PatchFlags.FULL_PROPS */) {
  6690. // element props contain dynamic keys, full diff needed
  6691. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6692. }
  6693. else {
  6694. // class
  6695. // this flag is matched when the element has dynamic class bindings.
  6696. if (patchFlag & 2 /* PatchFlags.CLASS */) {
  6697. if (oldProps.class !== newProps.class) {
  6698. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  6699. }
  6700. }
  6701. // style
  6702. // this flag is matched when the element has dynamic style bindings
  6703. if (patchFlag & 4 /* PatchFlags.STYLE */) {
  6704. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  6705. }
  6706. // props
  6707. // This flag is matched when the element has dynamic prop/attr bindings
  6708. // other than class and style. The keys of dynamic prop/attrs are saved for
  6709. // faster iteration.
  6710. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  6711. // bail out and go through a full diff because we need to unset the old key
  6712. if (patchFlag & 8 /* PatchFlags.PROPS */) {
  6713. // if the flag is present then dynamicProps must be non-null
  6714. const propsToUpdate = n2.dynamicProps;
  6715. for (let i = 0; i < propsToUpdate.length; i++) {
  6716. const key = propsToUpdate[i];
  6717. const prev = oldProps[key];
  6718. const next = newProps[key];
  6719. // #1471 force patch value
  6720. if (next !== prev || key === 'value') {
  6721. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  6722. }
  6723. }
  6724. }
  6725. }
  6726. // text
  6727. // This flag is matched when the element has only dynamic text children.
  6728. if (patchFlag & 1 /* PatchFlags.TEXT */) {
  6729. if (n1.children !== n2.children) {
  6730. hostSetElementText(el, n2.children);
  6731. }
  6732. }
  6733. }
  6734. else if (!optimized && dynamicChildren == null) {
  6735. // unoptimized, full diff
  6736. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6737. }
  6738. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6739. queuePostRenderEffect(() => {
  6740. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6741. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  6742. }, parentSuspense);
  6743. }
  6744. };
  6745. // The fast path for blocks.
  6746. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6747. for (let i = 0; i < newChildren.length; i++) {
  6748. const oldVNode = oldChildren[i];
  6749. const newVNode = newChildren[i];
  6750. // Determine the container (parent element) for the patch.
  6751. const container =
  6752. // oldVNode may be an errored async setup() component inside Suspense
  6753. // which will not have a mounted element
  6754. oldVNode.el &&
  6755. // - In the case of a Fragment, we need to provide the actual parent
  6756. // of the Fragment itself so it can move its children.
  6757. (oldVNode.type === Fragment ||
  6758. // - In the case of different nodes, there is going to be a replacement
  6759. // which also requires the correct parent container
  6760. !isSameVNodeType(oldVNode, newVNode) ||
  6761. // - In the case of a component, it could contain anything.
  6762. oldVNode.shapeFlag & (6 /* ShapeFlags.COMPONENT */ | 64 /* ShapeFlags.TELEPORT */))
  6763. ? hostParentNode(oldVNode.el)
  6764. : // In other cases, the parent container is not actually used so we
  6765. // just pass the block element here to avoid a DOM parentNode call.
  6766. fallbackContainer;
  6767. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  6768. }
  6769. };
  6770. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6771. if (oldProps !== newProps) {
  6772. if (oldProps !== EMPTY_OBJ) {
  6773. for (const key in oldProps) {
  6774. if (!isReservedProp(key) && !(key in newProps)) {
  6775. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6776. }
  6777. }
  6778. }
  6779. for (const key in newProps) {
  6780. // empty string is not valid prop
  6781. if (isReservedProp(key))
  6782. continue;
  6783. const next = newProps[key];
  6784. const prev = oldProps[key];
  6785. // defer patching value
  6786. if (next !== prev && key !== 'value') {
  6787. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6788. }
  6789. }
  6790. if ('value' in newProps) {
  6791. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  6792. }
  6793. }
  6794. };
  6795. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6796. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  6797. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  6798. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6799. if (// #5523 dev root fragment may inherit directives
  6800. (isHmrUpdating || patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */)) {
  6801. // HMR updated / Dev root fragment (w/ comments), force full diff
  6802. patchFlag = 0;
  6803. optimized = false;
  6804. dynamicChildren = null;
  6805. }
  6806. // check if this is a slot fragment with :slotted scope ids
  6807. if (fragmentSlotScopeIds) {
  6808. slotScopeIds = slotScopeIds
  6809. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6810. : fragmentSlotScopeIds;
  6811. }
  6812. if (n1 == null) {
  6813. hostInsert(fragmentStartAnchor, container, anchor);
  6814. hostInsert(fragmentEndAnchor, container, anchor);
  6815. // a fragment can only have array children
  6816. // since they are either generated by the compiler, or implicitly created
  6817. // from arrays.
  6818. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6819. }
  6820. else {
  6821. if (patchFlag > 0 &&
  6822. patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */ &&
  6823. dynamicChildren &&
  6824. // #2715 the previous fragment could've been a BAILed one as a result
  6825. // of renderSlot() with no valid children
  6826. n1.dynamicChildren) {
  6827. // a stable fragment (template root or <template v-for>) doesn't need to
  6828. // patch children order, but it may contain dynamicChildren.
  6829. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6830. if (parentComponent && parentComponent.type.__hmrId) {
  6831. traverseStaticChildren(n1, n2);
  6832. }
  6833. else if (
  6834. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  6835. // get moved around. Make sure all root level vnodes inherit el.
  6836. // #2134 or if it's a component root, it may also get moved around
  6837. // as the component is being moved.
  6838. n2.key != null ||
  6839. (parentComponent && n2 === parentComponent.subTree)) {
  6840. traverseStaticChildren(n1, n2, true /* shallow */);
  6841. }
  6842. }
  6843. else {
  6844. // keyed / unkeyed, or manual fragments.
  6845. // for keyed & unkeyed, since they are compiler generated from v-for,
  6846. // each child is guaranteed to be a block so the fragment will never
  6847. // have dynamicChildren.
  6848. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6849. }
  6850. }
  6851. };
  6852. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6853. n2.slotScopeIds = slotScopeIds;
  6854. if (n1 == null) {
  6855. if (n2.shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
  6856. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  6857. }
  6858. else {
  6859. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  6860. }
  6861. }
  6862. else {
  6863. updateComponent(n1, n2, optimized);
  6864. }
  6865. };
  6866. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6867. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  6868. if (instance.type.__hmrId) {
  6869. registerHMR(instance);
  6870. }
  6871. {
  6872. pushWarningContext(initialVNode);
  6873. startMeasure(instance, `mount`);
  6874. }
  6875. // inject renderer internals for keepAlive
  6876. if (isKeepAlive(initialVNode)) {
  6877. instance.ctx.renderer = internals;
  6878. }
  6879. // resolve props and slots for setup context
  6880. {
  6881. {
  6882. startMeasure(instance, `init`);
  6883. }
  6884. setupComponent(instance);
  6885. {
  6886. endMeasure(instance, `init`);
  6887. }
  6888. }
  6889. // setup() is async. This component relies on async logic to be resolved
  6890. // before proceeding
  6891. if (instance.asyncDep) {
  6892. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6893. // Give it a placeholder if this is not hydration
  6894. // TODO handle self-defined fallback
  6895. if (!initialVNode.el) {
  6896. const placeholder = (instance.subTree = createVNode(Comment));
  6897. processCommentNode(null, placeholder, container, anchor);
  6898. }
  6899. return;
  6900. }
  6901. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  6902. {
  6903. popWarningContext();
  6904. endMeasure(instance, `mount`);
  6905. }
  6906. };
  6907. const updateComponent = (n1, n2, optimized) => {
  6908. const instance = (n2.component = n1.component);
  6909. if (shouldUpdateComponent(n1, n2, optimized)) {
  6910. if (instance.asyncDep &&
  6911. !instance.asyncResolved) {
  6912. // async & still pending - just update props and slots
  6913. // since the component's reactive effect for render isn't set-up yet
  6914. {
  6915. pushWarningContext(n2);
  6916. }
  6917. updateComponentPreRender(instance, n2, optimized);
  6918. {
  6919. popWarningContext();
  6920. }
  6921. return;
  6922. }
  6923. else {
  6924. // normal update
  6925. instance.next = n2;
  6926. // in case the child component is also queued, remove it to avoid
  6927. // double updating the same child component in the same flush.
  6928. invalidateJob(instance.update);
  6929. // instance.update is the reactive effect.
  6930. instance.update();
  6931. }
  6932. }
  6933. else {
  6934. // no update needed. just copy over properties
  6935. n2.el = n1.el;
  6936. instance.vnode = n2;
  6937. }
  6938. };
  6939. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6940. const componentUpdateFn = () => {
  6941. if (!instance.isMounted) {
  6942. let vnodeHook;
  6943. const { el, props } = initialVNode;
  6944. const { bm, m, parent } = instance;
  6945. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  6946. toggleRecurse(instance, false);
  6947. // beforeMount hook
  6948. if (bm) {
  6949. invokeArrayFns(bm);
  6950. }
  6951. // onVnodeBeforeMount
  6952. if (!isAsyncWrapperVNode &&
  6953. (vnodeHook = props && props.onVnodeBeforeMount)) {
  6954. invokeVNodeHook(vnodeHook, parent, initialVNode);
  6955. }
  6956. toggleRecurse(instance, true);
  6957. if (el && hydrateNode) {
  6958. // vnode has adopted host node - perform hydration instead of mount.
  6959. const hydrateSubTree = () => {
  6960. {
  6961. startMeasure(instance, `render`);
  6962. }
  6963. instance.subTree = renderComponentRoot(instance);
  6964. {
  6965. endMeasure(instance, `render`);
  6966. }
  6967. {
  6968. startMeasure(instance, `hydrate`);
  6969. }
  6970. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  6971. {
  6972. endMeasure(instance, `hydrate`);
  6973. }
  6974. };
  6975. if (isAsyncWrapperVNode) {
  6976. initialVNode.type.__asyncLoader().then(
  6977. // note: we are moving the render call into an async callback,
  6978. // which means it won't track dependencies - but it's ok because
  6979. // a server-rendered async wrapper is already in resolved state
  6980. // and it will never need to change.
  6981. () => !instance.isUnmounted && hydrateSubTree());
  6982. }
  6983. else {
  6984. hydrateSubTree();
  6985. }
  6986. }
  6987. else {
  6988. {
  6989. startMeasure(instance, `render`);
  6990. }
  6991. const subTree = (instance.subTree = renderComponentRoot(instance));
  6992. {
  6993. endMeasure(instance, `render`);
  6994. }
  6995. {
  6996. startMeasure(instance, `patch`);
  6997. }
  6998. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  6999. {
  7000. endMeasure(instance, `patch`);
  7001. }
  7002. initialVNode.el = subTree.el;
  7003. }
  7004. // mounted hook
  7005. if (m) {
  7006. queuePostRenderEffect(m, parentSuspense);
  7007. }
  7008. // onVnodeMounted
  7009. if (!isAsyncWrapperVNode &&
  7010. (vnodeHook = props && props.onVnodeMounted)) {
  7011. const scopedInitialVNode = initialVNode;
  7012. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  7013. }
  7014. // activated hook for keep-alive roots.
  7015. // #1742 activated hook must be accessed after first render
  7016. // since the hook may be injected by a child keep-alive
  7017. if (initialVNode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */ ||
  7018. (parent &&
  7019. isAsyncWrapper(parent.vnode) &&
  7020. parent.vnode.shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */)) {
  7021. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  7022. }
  7023. instance.isMounted = true;
  7024. {
  7025. devtoolsComponentAdded(instance);
  7026. }
  7027. // #2458: deference mount-only object parameters to prevent memleaks
  7028. initialVNode = container = anchor = null;
  7029. }
  7030. else {
  7031. // updateComponent
  7032. // This is triggered by mutation of component's own state (next: null)
  7033. // OR parent calling processComponent (next: VNode)
  7034. let { next, bu, u, parent, vnode } = instance;
  7035. let originNext = next;
  7036. let vnodeHook;
  7037. {
  7038. pushWarningContext(next || instance.vnode);
  7039. }
  7040. // Disallow component effect recursion during pre-lifecycle hooks.
  7041. toggleRecurse(instance, false);
  7042. if (next) {
  7043. next.el = vnode.el;
  7044. updateComponentPreRender(instance, next, optimized);
  7045. }
  7046. else {
  7047. next = vnode;
  7048. }
  7049. // beforeUpdate hook
  7050. if (bu) {
  7051. invokeArrayFns(bu);
  7052. }
  7053. // onVnodeBeforeUpdate
  7054. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  7055. invokeVNodeHook(vnodeHook, parent, next, vnode);
  7056. }
  7057. toggleRecurse(instance, true);
  7058. // render
  7059. {
  7060. startMeasure(instance, `render`);
  7061. }
  7062. const nextTree = renderComponentRoot(instance);
  7063. {
  7064. endMeasure(instance, `render`);
  7065. }
  7066. const prevTree = instance.subTree;
  7067. instance.subTree = nextTree;
  7068. {
  7069. startMeasure(instance, `patch`);
  7070. }
  7071. patch(prevTree, nextTree,
  7072. // parent may have changed if it's in a teleport
  7073. hostParentNode(prevTree.el),
  7074. // anchor may have changed if it's in a fragment
  7075. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  7076. {
  7077. endMeasure(instance, `patch`);
  7078. }
  7079. next.el = nextTree.el;
  7080. if (originNext === null) {
  7081. // self-triggered update. In case of HOC, update parent component
  7082. // vnode el. HOC is indicated by parent instance's subTree pointing
  7083. // to child component's vnode
  7084. updateHOCHostEl(instance, nextTree.el);
  7085. }
  7086. // updated hook
  7087. if (u) {
  7088. queuePostRenderEffect(u, parentSuspense);
  7089. }
  7090. // onVnodeUpdated
  7091. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  7092. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  7093. }
  7094. {
  7095. devtoolsComponentUpdated(instance);
  7096. }
  7097. {
  7098. popWarningContext();
  7099. }
  7100. }
  7101. };
  7102. // create reactive effect for rendering
  7103. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
  7104. ));
  7105. const update = (instance.update = () => effect.run());
  7106. update.id = instance.uid;
  7107. // allowRecurse
  7108. // #1801, #2043 component render effects should allow recursive updates
  7109. toggleRecurse(instance, true);
  7110. {
  7111. effect.onTrack = instance.rtc
  7112. ? e => invokeArrayFns(instance.rtc, e)
  7113. : void 0;
  7114. effect.onTrigger = instance.rtg
  7115. ? e => invokeArrayFns(instance.rtg, e)
  7116. : void 0;
  7117. update.ownerInstance = instance;
  7118. }
  7119. update();
  7120. };
  7121. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7122. nextVNode.component = instance;
  7123. const prevProps = instance.vnode.props;
  7124. instance.vnode = nextVNode;
  7125. instance.next = null;
  7126. updateProps(instance, nextVNode.props, prevProps, optimized);
  7127. updateSlots(instance, nextVNode.children, optimized);
  7128. pauseTracking();
  7129. // props update may have triggered pre-flush watchers.
  7130. // flush them before the render update.
  7131. flushPreFlushCbs();
  7132. resetTracking();
  7133. };
  7134. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7135. const c1 = n1 && n1.children;
  7136. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7137. const c2 = n2.children;
  7138. const { patchFlag, shapeFlag } = n2;
  7139. // fast path
  7140. if (patchFlag > 0) {
  7141. if (patchFlag & 128 /* PatchFlags.KEYED_FRAGMENT */) {
  7142. // this could be either fully-keyed or mixed (some keyed some not)
  7143. // presence of patchFlag means children are guaranteed to be arrays
  7144. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7145. return;
  7146. }
  7147. else if (patchFlag & 256 /* PatchFlags.UNKEYED_FRAGMENT */) {
  7148. // unkeyed
  7149. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7150. return;
  7151. }
  7152. }
  7153. // children has 3 possibilities: text, array or no children.
  7154. if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  7155. // text children fast path
  7156. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7157. unmountChildren(c1, parentComponent, parentSuspense);
  7158. }
  7159. if (c2 !== c1) {
  7160. hostSetElementText(container, c2);
  7161. }
  7162. }
  7163. else {
  7164. if (prevShapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7165. // prev children was array
  7166. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7167. // two arrays, cannot assume anything, do full diff
  7168. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7169. }
  7170. else {
  7171. // no new children, just unmount old
  7172. unmountChildren(c1, parentComponent, parentSuspense, true);
  7173. }
  7174. }
  7175. else {
  7176. // prev children was text OR null
  7177. // new children is array OR null
  7178. if (prevShapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
  7179. hostSetElementText(container, '');
  7180. }
  7181. // mount new if array
  7182. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7183. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7184. }
  7185. }
  7186. }
  7187. };
  7188. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7189. c1 = c1 || EMPTY_ARR;
  7190. c2 = c2 || EMPTY_ARR;
  7191. const oldLength = c1.length;
  7192. const newLength = c2.length;
  7193. const commonLength = Math.min(oldLength, newLength);
  7194. let i;
  7195. for (i = 0; i < commonLength; i++) {
  7196. const nextChild = (c2[i] = optimized
  7197. ? cloneIfMounted(c2[i])
  7198. : normalizeVNode(c2[i]));
  7199. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7200. }
  7201. if (oldLength > newLength) {
  7202. // remove old
  7203. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  7204. }
  7205. else {
  7206. // mount new
  7207. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  7208. }
  7209. };
  7210. // can be all-keyed or mixed
  7211. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7212. let i = 0;
  7213. const l2 = c2.length;
  7214. let e1 = c1.length - 1; // prev ending index
  7215. let e2 = l2 - 1; // next ending index
  7216. // 1. sync from start
  7217. // (a b) c
  7218. // (a b) d e
  7219. while (i <= e1 && i <= e2) {
  7220. const n1 = c1[i];
  7221. const n2 = (c2[i] = optimized
  7222. ? cloneIfMounted(c2[i])
  7223. : normalizeVNode(c2[i]));
  7224. if (isSameVNodeType(n1, n2)) {
  7225. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7226. }
  7227. else {
  7228. break;
  7229. }
  7230. i++;
  7231. }
  7232. // 2. sync from end
  7233. // a (b c)
  7234. // d e (b c)
  7235. while (i <= e1 && i <= e2) {
  7236. const n1 = c1[e1];
  7237. const n2 = (c2[e2] = optimized
  7238. ? cloneIfMounted(c2[e2])
  7239. : normalizeVNode(c2[e2]));
  7240. if (isSameVNodeType(n1, n2)) {
  7241. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7242. }
  7243. else {
  7244. break;
  7245. }
  7246. e1--;
  7247. e2--;
  7248. }
  7249. // 3. common sequence + mount
  7250. // (a b)
  7251. // (a b) c
  7252. // i = 2, e1 = 1, e2 = 2
  7253. // (a b)
  7254. // c (a b)
  7255. // i = 0, e1 = -1, e2 = 0
  7256. if (i > e1) {
  7257. if (i <= e2) {
  7258. const nextPos = e2 + 1;
  7259. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7260. while (i <= e2) {
  7261. patch(null, (c2[i] = optimized
  7262. ? cloneIfMounted(c2[i])
  7263. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7264. i++;
  7265. }
  7266. }
  7267. }
  7268. // 4. common sequence + unmount
  7269. // (a b) c
  7270. // (a b)
  7271. // i = 2, e1 = 2, e2 = 1
  7272. // a (b c)
  7273. // (b c)
  7274. // i = 0, e1 = 0, e2 = -1
  7275. else if (i > e2) {
  7276. while (i <= e1) {
  7277. unmount(c1[i], parentComponent, parentSuspense, true);
  7278. i++;
  7279. }
  7280. }
  7281. // 5. unknown sequence
  7282. // [i ... e1 + 1]: a b [c d e] f g
  7283. // [i ... e2 + 1]: a b [e d c h] f g
  7284. // i = 2, e1 = 4, e2 = 5
  7285. else {
  7286. const s1 = i; // prev starting index
  7287. const s2 = i; // next starting index
  7288. // 5.1 build key:index map for newChildren
  7289. const keyToNewIndexMap = new Map();
  7290. for (i = s2; i <= e2; i++) {
  7291. const nextChild = (c2[i] = optimized
  7292. ? cloneIfMounted(c2[i])
  7293. : normalizeVNode(c2[i]));
  7294. if (nextChild.key != null) {
  7295. if (keyToNewIndexMap.has(nextChild.key)) {
  7296. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  7297. }
  7298. keyToNewIndexMap.set(nextChild.key, i);
  7299. }
  7300. }
  7301. // 5.2 loop through old children left to be patched and try to patch
  7302. // matching nodes & remove nodes that are no longer present
  7303. let j;
  7304. let patched = 0;
  7305. const toBePatched = e2 - s2 + 1;
  7306. let moved = false;
  7307. // used to track whether any node has moved
  7308. let maxNewIndexSoFar = 0;
  7309. // works as Map<newIndex, oldIndex>
  7310. // Note that oldIndex is offset by +1
  7311. // and oldIndex = 0 is a special value indicating the new node has
  7312. // no corresponding old node.
  7313. // used for determining longest stable subsequence
  7314. const newIndexToOldIndexMap = new Array(toBePatched);
  7315. for (i = 0; i < toBePatched; i++)
  7316. newIndexToOldIndexMap[i] = 0;
  7317. for (i = s1; i <= e1; i++) {
  7318. const prevChild = c1[i];
  7319. if (patched >= toBePatched) {
  7320. // all new children have been patched so this can only be a removal
  7321. unmount(prevChild, parentComponent, parentSuspense, true);
  7322. continue;
  7323. }
  7324. let newIndex;
  7325. if (prevChild.key != null) {
  7326. newIndex = keyToNewIndexMap.get(prevChild.key);
  7327. }
  7328. else {
  7329. // key-less node, try to locate a key-less node of the same type
  7330. for (j = s2; j <= e2; j++) {
  7331. if (newIndexToOldIndexMap[j - s2] === 0 &&
  7332. isSameVNodeType(prevChild, c2[j])) {
  7333. newIndex = j;
  7334. break;
  7335. }
  7336. }
  7337. }
  7338. if (newIndex === undefined) {
  7339. unmount(prevChild, parentComponent, parentSuspense, true);
  7340. }
  7341. else {
  7342. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7343. if (newIndex >= maxNewIndexSoFar) {
  7344. maxNewIndexSoFar = newIndex;
  7345. }
  7346. else {
  7347. moved = true;
  7348. }
  7349. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7350. patched++;
  7351. }
  7352. }
  7353. // 5.3 move and mount
  7354. // generate longest stable subsequence only when nodes have moved
  7355. const increasingNewIndexSequence = moved
  7356. ? getSequence(newIndexToOldIndexMap)
  7357. : EMPTY_ARR;
  7358. j = increasingNewIndexSequence.length - 1;
  7359. // looping backwards so that we can use last patched node as anchor
  7360. for (i = toBePatched - 1; i >= 0; i--) {
  7361. const nextIndex = s2 + i;
  7362. const nextChild = c2[nextIndex];
  7363. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7364. if (newIndexToOldIndexMap[i] === 0) {
  7365. // mount new
  7366. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7367. }
  7368. else if (moved) {
  7369. // move if:
  7370. // There is no stable subsequence (e.g. a reverse)
  7371. // OR current node is not among the stable sequence
  7372. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7373. move(nextChild, container, anchor, 2 /* MoveType.REORDER */);
  7374. }
  7375. else {
  7376. j--;
  7377. }
  7378. }
  7379. }
  7380. }
  7381. };
  7382. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7383. const { el, type, transition, children, shapeFlag } = vnode;
  7384. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7385. move(vnode.component.subTree, container, anchor, moveType);
  7386. return;
  7387. }
  7388. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7389. vnode.suspense.move(container, anchor, moveType);
  7390. return;
  7391. }
  7392. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  7393. type.move(vnode, container, anchor, internals);
  7394. return;
  7395. }
  7396. if (type === Fragment) {
  7397. hostInsert(el, container, anchor);
  7398. for (let i = 0; i < children.length; i++) {
  7399. move(children[i], container, anchor, moveType);
  7400. }
  7401. hostInsert(vnode.anchor, container, anchor);
  7402. return;
  7403. }
  7404. if (type === Static) {
  7405. moveStaticNode(vnode, container, anchor);
  7406. return;
  7407. }
  7408. // single nodes
  7409. const needTransition = moveType !== 2 /* MoveType.REORDER */ &&
  7410. shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
  7411. transition;
  7412. if (needTransition) {
  7413. if (moveType === 0 /* MoveType.ENTER */) {
  7414. transition.beforeEnter(el);
  7415. hostInsert(el, container, anchor);
  7416. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7417. }
  7418. else {
  7419. const { leave, delayLeave, afterLeave } = transition;
  7420. const remove = () => hostInsert(el, container, anchor);
  7421. const performLeave = () => {
  7422. leave(el, () => {
  7423. remove();
  7424. afterLeave && afterLeave();
  7425. });
  7426. };
  7427. if (delayLeave) {
  7428. delayLeave(el, remove, performLeave);
  7429. }
  7430. else {
  7431. performLeave();
  7432. }
  7433. }
  7434. }
  7435. else {
  7436. hostInsert(el, container, anchor);
  7437. }
  7438. };
  7439. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7440. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  7441. // unset ref
  7442. if (ref != null) {
  7443. setRef(ref, null, parentSuspense, vnode, true);
  7444. }
  7445. if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
  7446. parentComponent.ctx.deactivate(vnode);
  7447. return;
  7448. }
  7449. const shouldInvokeDirs = shapeFlag & 1 /* ShapeFlags.ELEMENT */ && dirs;
  7450. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7451. let vnodeHook;
  7452. if (shouldInvokeVnodeHook &&
  7453. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7454. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7455. }
  7456. if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7457. unmountComponent(vnode.component, parentSuspense, doRemove);
  7458. }
  7459. else {
  7460. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7461. vnode.suspense.unmount(parentSuspense, doRemove);
  7462. return;
  7463. }
  7464. if (shouldInvokeDirs) {
  7465. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  7466. }
  7467. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  7468. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  7469. }
  7470. else if (dynamicChildren &&
  7471. // #1153: fast path should not be taken for non-stable (v-for) fragments
  7472. (type !== Fragment ||
  7473. (patchFlag > 0 && patchFlag & 64 /* PatchFlags.STABLE_FRAGMENT */))) {
  7474. // fast path for block nodes: only need to unmount dynamic children.
  7475. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  7476. }
  7477. else if ((type === Fragment &&
  7478. patchFlag &
  7479. (128 /* PatchFlags.KEYED_FRAGMENT */ | 256 /* PatchFlags.UNKEYED_FRAGMENT */)) ||
  7480. (!optimized && shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */)) {
  7481. unmountChildren(children, parentComponent, parentSuspense);
  7482. }
  7483. if (doRemove) {
  7484. remove(vnode);
  7485. }
  7486. }
  7487. if ((shouldInvokeVnodeHook &&
  7488. (vnodeHook = props && props.onVnodeUnmounted)) ||
  7489. shouldInvokeDirs) {
  7490. queuePostRenderEffect(() => {
  7491. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7492. shouldInvokeDirs &&
  7493. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  7494. }, parentSuspense);
  7495. }
  7496. };
  7497. const remove = vnode => {
  7498. const { type, el, anchor, transition } = vnode;
  7499. if (type === Fragment) {
  7500. if (vnode.patchFlag > 0 &&
  7501. vnode.patchFlag & 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */ &&
  7502. transition &&
  7503. !transition.persisted) {
  7504. vnode.children.forEach(child => {
  7505. if (child.type === Comment) {
  7506. hostRemove(child.el);
  7507. }
  7508. else {
  7509. remove(child);
  7510. }
  7511. });
  7512. }
  7513. else {
  7514. removeFragment(el, anchor);
  7515. }
  7516. return;
  7517. }
  7518. if (type === Static) {
  7519. removeStaticNode(vnode);
  7520. return;
  7521. }
  7522. const performRemove = () => {
  7523. hostRemove(el);
  7524. if (transition && !transition.persisted && transition.afterLeave) {
  7525. transition.afterLeave();
  7526. }
  7527. };
  7528. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ &&
  7529. transition &&
  7530. !transition.persisted) {
  7531. const { leave, delayLeave } = transition;
  7532. const performLeave = () => leave(el, performRemove);
  7533. if (delayLeave) {
  7534. delayLeave(vnode.el, performRemove, performLeave);
  7535. }
  7536. else {
  7537. performLeave();
  7538. }
  7539. }
  7540. else {
  7541. performRemove();
  7542. }
  7543. };
  7544. const removeFragment = (cur, end) => {
  7545. // For fragments, directly remove all contained DOM nodes.
  7546. // (fragment child nodes cannot have transition)
  7547. let next;
  7548. while (cur !== end) {
  7549. next = hostNextSibling(cur);
  7550. hostRemove(cur);
  7551. cur = next;
  7552. }
  7553. hostRemove(end);
  7554. };
  7555. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7556. if (instance.type.__hmrId) {
  7557. unregisterHMR(instance);
  7558. }
  7559. const { bum, scope, update, subTree, um } = instance;
  7560. // beforeUnmount hook
  7561. if (bum) {
  7562. invokeArrayFns(bum);
  7563. }
  7564. // stop effects in component scope
  7565. scope.stop();
  7566. // update may be null if a component is unmounted before its async
  7567. // setup has resolved.
  7568. if (update) {
  7569. // so that scheduler will no longer invoke it
  7570. update.active = false;
  7571. unmount(subTree, instance, parentSuspense, doRemove);
  7572. }
  7573. // unmounted hook
  7574. if (um) {
  7575. queuePostRenderEffect(um, parentSuspense);
  7576. }
  7577. queuePostRenderEffect(() => {
  7578. instance.isUnmounted = true;
  7579. }, parentSuspense);
  7580. // A component with async dep inside a pending suspense is unmounted before
  7581. // its async dep resolves. This should remove the dep from the suspense, and
  7582. // cause the suspense to resolve immediately if that was the last dep.
  7583. if (parentSuspense &&
  7584. parentSuspense.pendingBranch &&
  7585. !parentSuspense.isUnmounted &&
  7586. instance.asyncDep &&
  7587. !instance.asyncResolved &&
  7588. instance.suspenseId === parentSuspense.pendingId) {
  7589. parentSuspense.deps--;
  7590. if (parentSuspense.deps === 0) {
  7591. parentSuspense.resolve();
  7592. }
  7593. }
  7594. {
  7595. devtoolsComponentRemoved(instance);
  7596. }
  7597. };
  7598. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7599. for (let i = start; i < children.length; i++) {
  7600. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7601. }
  7602. };
  7603. const getNextHostNode = vnode => {
  7604. if (vnode.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  7605. return getNextHostNode(vnode.component.subTree);
  7606. }
  7607. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  7608. return vnode.suspense.next();
  7609. }
  7610. return hostNextSibling((vnode.anchor || vnode.el));
  7611. };
  7612. const render = (vnode, container, isSVG) => {
  7613. if (vnode == null) {
  7614. if (container._vnode) {
  7615. unmount(container._vnode, null, null, true);
  7616. }
  7617. }
  7618. else {
  7619. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7620. }
  7621. flushPreFlushCbs();
  7622. flushPostFlushCbs();
  7623. container._vnode = vnode;
  7624. };
  7625. const internals = {
  7626. p: patch,
  7627. um: unmount,
  7628. m: move,
  7629. r: remove,
  7630. mt: mountComponent,
  7631. mc: mountChildren,
  7632. pc: patchChildren,
  7633. pbc: patchBlockChildren,
  7634. n: getNextHostNode,
  7635. o: options
  7636. };
  7637. let hydrate;
  7638. let hydrateNode;
  7639. if (createHydrationFns) {
  7640. [hydrate, hydrateNode] = createHydrationFns(internals);
  7641. }
  7642. return {
  7643. render,
  7644. hydrate,
  7645. createApp: createAppAPI(render, hydrate)
  7646. };
  7647. }
  7648. function toggleRecurse({ effect, update }, allowed) {
  7649. effect.allowRecurse = update.allowRecurse = allowed;
  7650. }
  7651. /**
  7652. * #1156
  7653. * When a component is HMR-enabled, we need to make sure that all static nodes
  7654. * inside a block also inherit the DOM element from the previous tree so that
  7655. * HMR updates (which are full updates) can retrieve the element for patching.
  7656. *
  7657. * #2080
  7658. * Inside keyed `template` fragment static children, if a fragment is moved,
  7659. * the children will always be moved. Therefore, in order to ensure correct move
  7660. * position, el should be inherited from previous nodes.
  7661. */
  7662. function traverseStaticChildren(n1, n2, shallow = false) {
  7663. const ch1 = n1.children;
  7664. const ch2 = n2.children;
  7665. if (isArray(ch1) && isArray(ch2)) {
  7666. for (let i = 0; i < ch1.length; i++) {
  7667. // this is only called in the optimized path so array children are
  7668. // guaranteed to be vnodes
  7669. const c1 = ch1[i];
  7670. let c2 = ch2[i];
  7671. if (c2.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && !c2.dynamicChildren) {
  7672. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) {
  7673. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7674. c2.el = c1.el;
  7675. }
  7676. if (!shallow)
  7677. traverseStaticChildren(c1, c2);
  7678. }
  7679. // #6852 also inherit for text nodes
  7680. if (c2.type === Text) {
  7681. c2.el = c1.el;
  7682. }
  7683. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  7684. // would have received .el during block patch)
  7685. if (c2.type === Comment && !c2.el) {
  7686. c2.el = c1.el;
  7687. }
  7688. }
  7689. }
  7690. }
  7691. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  7692. function getSequence(arr) {
  7693. const p = arr.slice();
  7694. const result = [0];
  7695. let i, j, u, v, c;
  7696. const len = arr.length;
  7697. for (i = 0; i < len; i++) {
  7698. const arrI = arr[i];
  7699. if (arrI !== 0) {
  7700. j = result[result.length - 1];
  7701. if (arr[j] < arrI) {
  7702. p[i] = j;
  7703. result.push(i);
  7704. continue;
  7705. }
  7706. u = 0;
  7707. v = result.length - 1;
  7708. while (u < v) {
  7709. c = (u + v) >> 1;
  7710. if (arr[result[c]] < arrI) {
  7711. u = c + 1;
  7712. }
  7713. else {
  7714. v = c;
  7715. }
  7716. }
  7717. if (arrI < arr[result[u]]) {
  7718. if (u > 0) {
  7719. p[i] = result[u - 1];
  7720. }
  7721. result[u] = i;
  7722. }
  7723. }
  7724. }
  7725. u = result.length;
  7726. v = result[u - 1];
  7727. while (u-- > 0) {
  7728. result[u] = v;
  7729. v = p[v];
  7730. }
  7731. return result;
  7732. }
  7733. const isTeleport = (type) => type.__isTeleport;
  7734. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  7735. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  7736. const resolveTarget = (props, select) => {
  7737. const targetSelector = props && props.to;
  7738. if (isString(targetSelector)) {
  7739. if (!select) {
  7740. warn$1(`Current renderer does not support string target for Teleports. ` +
  7741. `(missing querySelector renderer option)`);
  7742. return null;
  7743. }
  7744. else {
  7745. const target = select(targetSelector);
  7746. if (!target) {
  7747. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  7748. `Note the target element must exist before the component is mounted - ` +
  7749. `i.e. the target cannot be rendered by the component itself, and ` +
  7750. `ideally should be outside of the entire Vue component tree.`);
  7751. }
  7752. return target;
  7753. }
  7754. }
  7755. else {
  7756. if (!targetSelector && !isTeleportDisabled(props)) {
  7757. warn$1(`Invalid Teleport target: ${targetSelector}`);
  7758. }
  7759. return targetSelector;
  7760. }
  7761. };
  7762. const TeleportImpl = {
  7763. __isTeleport: true,
  7764. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7765. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  7766. const disabled = isTeleportDisabled(n2.props);
  7767. let { shapeFlag, children, dynamicChildren } = n2;
  7768. // #3302
  7769. // HMR updated, force full diff
  7770. if (isHmrUpdating) {
  7771. optimized = false;
  7772. dynamicChildren = null;
  7773. }
  7774. if (n1 == null) {
  7775. // insert anchors in the main view
  7776. const placeholder = (n2.el = createComment('teleport start')
  7777. );
  7778. const mainAnchor = (n2.anchor = createComment('teleport end')
  7779. );
  7780. insert(placeholder, container, anchor);
  7781. insert(mainAnchor, container, anchor);
  7782. const target = (n2.target = resolveTarget(n2.props, querySelector));
  7783. const targetAnchor = (n2.targetAnchor = createText(''));
  7784. if (target) {
  7785. insert(targetAnchor, target);
  7786. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  7787. isSVG = isSVG || isTargetSVG(target);
  7788. }
  7789. else if (!disabled) {
  7790. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  7791. }
  7792. const mount = (container, anchor) => {
  7793. // Teleport *always* has Array children. This is enforced in both the
  7794. // compiler and vnode children normalization.
  7795. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7796. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7797. }
  7798. };
  7799. if (disabled) {
  7800. mount(container, mainAnchor);
  7801. }
  7802. else if (target) {
  7803. mount(target, targetAnchor);
  7804. }
  7805. }
  7806. else {
  7807. // update content
  7808. n2.el = n1.el;
  7809. const mainAnchor = (n2.anchor = n1.anchor);
  7810. const target = (n2.target = n1.target);
  7811. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  7812. const wasDisabled = isTeleportDisabled(n1.props);
  7813. const currentContainer = wasDisabled ? container : target;
  7814. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7815. isSVG = isSVG || isTargetSVG(target);
  7816. if (dynamicChildren) {
  7817. // fast path when the teleport happens to be a block root
  7818. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  7819. // even in block tree mode we need to make sure all root-level nodes
  7820. // in the teleport inherit previous DOM references so that they can
  7821. // be moved in future patches.
  7822. traverseStaticChildren(n1, n2, true);
  7823. }
  7824. else if (!optimized) {
  7825. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  7826. }
  7827. if (disabled) {
  7828. if (!wasDisabled) {
  7829. // enabled -> disabled
  7830. // move into main container
  7831. moveTeleport(n2, container, mainAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  7832. }
  7833. }
  7834. else {
  7835. // target changed
  7836. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7837. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  7838. if (nextTarget) {
  7839. moveTeleport(n2, nextTarget, null, internals, 0 /* TeleportMoveTypes.TARGET_CHANGE */);
  7840. }
  7841. else {
  7842. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  7843. }
  7844. }
  7845. else if (wasDisabled) {
  7846. // disabled -> enabled
  7847. // move into teleport target
  7848. moveTeleport(n2, target, targetAnchor, internals, 1 /* TeleportMoveTypes.TOGGLE */);
  7849. }
  7850. }
  7851. }
  7852. updateCssVars(n2);
  7853. },
  7854. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7855. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7856. if (target) {
  7857. hostRemove(targetAnchor);
  7858. }
  7859. // an unmounted teleport should always remove its children if not disabled
  7860. if (doRemove || !isTeleportDisabled(props)) {
  7861. hostRemove(anchor);
  7862. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7863. for (let i = 0; i < children.length; i++) {
  7864. const child = children[i];
  7865. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  7866. }
  7867. }
  7868. }
  7869. },
  7870. move: moveTeleport,
  7871. hydrate: hydrateTeleport
  7872. };
  7873. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* TeleportMoveTypes.REORDER */) {
  7874. // move target anchor if this is a target change.
  7875. if (moveType === 0 /* TeleportMoveTypes.TARGET_CHANGE */) {
  7876. insert(vnode.targetAnchor, container, parentAnchor);
  7877. }
  7878. const { el, anchor, shapeFlag, children, props } = vnode;
  7879. const isReorder = moveType === 2 /* TeleportMoveTypes.REORDER */;
  7880. // move main view anchor if this is a re-order.
  7881. if (isReorder) {
  7882. insert(el, container, parentAnchor);
  7883. }
  7884. // if this is a re-order and teleport is enabled (content is in target)
  7885. // do not move children. So the opposite is: only move children if this
  7886. // is not a reorder, or the teleport is disabled
  7887. if (!isReorder || isTeleportDisabled(props)) {
  7888. // Teleport has either Array children or no children.
  7889. if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7890. for (let i = 0; i < children.length; i++) {
  7891. move(children[i], container, parentAnchor, 2 /* MoveType.REORDER */);
  7892. }
  7893. }
  7894. }
  7895. // move main view anchor if this is a re-order.
  7896. if (isReorder) {
  7897. insert(anchor, container, parentAnchor);
  7898. }
  7899. }
  7900. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  7901. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  7902. if (target) {
  7903. // if multiple teleports rendered to the same target element, we need to
  7904. // pick up from where the last teleport finished instead of the first node
  7905. const targetNode = target._lpa || target.firstChild;
  7906. if (vnode.shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
  7907. if (isTeleportDisabled(vnode.props)) {
  7908. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  7909. vnode.targetAnchor = targetNode;
  7910. }
  7911. else {
  7912. vnode.anchor = nextSibling(node);
  7913. // lookahead until we find the target anchor
  7914. // we cannot rely on return value of hydrateChildren() because there
  7915. // could be nested teleports
  7916. let targetAnchor = targetNode;
  7917. while (targetAnchor) {
  7918. targetAnchor = nextSibling(targetAnchor);
  7919. if (targetAnchor &&
  7920. targetAnchor.nodeType === 8 &&
  7921. targetAnchor.data === 'teleport anchor') {
  7922. vnode.targetAnchor = targetAnchor;
  7923. target._lpa =
  7924. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  7925. break;
  7926. }
  7927. }
  7928. hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  7929. }
  7930. }
  7931. updateCssVars(vnode);
  7932. }
  7933. return vnode.anchor && nextSibling(vnode.anchor);
  7934. }
  7935. // Force-casted public typing for h and TSX props inference
  7936. const Teleport = TeleportImpl;
  7937. function updateCssVars(vnode) {
  7938. // presence of .ut method indicates owner component uses css vars.
  7939. // code path here can assume browser environment.
  7940. const ctx = vnode.ctx;
  7941. if (ctx && ctx.ut) {
  7942. let node = vnode.children[0].el;
  7943. while (node !== vnode.targetAnchor) {
  7944. if (node.nodeType === 1)
  7945. node.setAttribute('data-v-owner', ctx.uid);
  7946. node = node.nextSibling;
  7947. }
  7948. ctx.ut();
  7949. }
  7950. }
  7951. const Fragment = Symbol('Fragment' );
  7952. const Text = Symbol('Text' );
  7953. const Comment = Symbol('Comment' );
  7954. const Static = Symbol('Static' );
  7955. // Since v-if and v-for are the two possible ways node structure can dynamically
  7956. // change, once we consider v-if branches and each v-for fragment a block, we
  7957. // can divide a template into nested blocks, and within each block the node
  7958. // structure would be stable. This allows us to skip most children diffing
  7959. // and only worry about the dynamic nodes (indicated by patch flags).
  7960. const blockStack = [];
  7961. let currentBlock = null;
  7962. /**
  7963. * Open a block.
  7964. * This must be called before `createBlock`. It cannot be part of `createBlock`
  7965. * because the children of the block are evaluated before `createBlock` itself
  7966. * is called. The generated code typically looks like this:
  7967. *
  7968. * ```js
  7969. * function render() {
  7970. * return (openBlock(),createBlock('div', null, [...]))
  7971. * }
  7972. * ```
  7973. * disableTracking is true when creating a v-for fragment block, since a v-for
  7974. * fragment always diffs its children.
  7975. *
  7976. * @private
  7977. */
  7978. function openBlock(disableTracking = false) {
  7979. blockStack.push((currentBlock = disableTracking ? null : []));
  7980. }
  7981. function closeBlock() {
  7982. blockStack.pop();
  7983. currentBlock = blockStack[blockStack.length - 1] || null;
  7984. }
  7985. // Whether we should be tracking dynamic child nodes inside a block.
  7986. // Only tracks when this value is > 0
  7987. // We are not using a simple boolean because this value may need to be
  7988. // incremented/decremented by nested usage of v-once (see below)
  7989. let isBlockTreeEnabled = 1;
  7990. /**
  7991. * Block tracking sometimes needs to be disabled, for example during the
  7992. * creation of a tree that needs to be cached by v-once. The compiler generates
  7993. * code like this:
  7994. *
  7995. * ``` js
  7996. * _cache[1] || (
  7997. * setBlockTracking(-1),
  7998. * _cache[1] = createVNode(...),
  7999. * setBlockTracking(1),
  8000. * _cache[1]
  8001. * )
  8002. * ```
  8003. *
  8004. * @private
  8005. */
  8006. function setBlockTracking(value) {
  8007. isBlockTreeEnabled += value;
  8008. }
  8009. function setupBlock(vnode) {
  8010. // save current block children on the block vnode
  8011. vnode.dynamicChildren =
  8012. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  8013. // close block
  8014. closeBlock();
  8015. // a block is always going to be patched, so track it as a child of its
  8016. // parent block
  8017. if (isBlockTreeEnabled > 0 && currentBlock) {
  8018. currentBlock.push(vnode);
  8019. }
  8020. return vnode;
  8021. }
  8022. /**
  8023. * @private
  8024. */
  8025. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8026. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  8027. }
  8028. /**
  8029. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  8030. * A block root keeps track of dynamic nodes within the block in the
  8031. * `dynamicChildren` array.
  8032. *
  8033. * @private
  8034. */
  8035. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8036. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  8037. }
  8038. function isVNode(value) {
  8039. return value ? value.__v_isVNode === true : false;
  8040. }
  8041. function isSameVNodeType(n1, n2) {
  8042. if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
  8043. hmrDirtyComponents.has(n2.type)) {
  8044. // #7042, ensure the vnode being unmounted during HMR
  8045. // bitwise operations to remove keep alive flags
  8046. n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
  8047. n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
  8048. // HMR only: if the component has been hot-updated, force a reload.
  8049. return false;
  8050. }
  8051. return n1.type === n2.type && n1.key === n2.key;
  8052. }
  8053. let vnodeArgsTransformer;
  8054. /**
  8055. * Internal API for registering an arguments transform for createVNode
  8056. * used for creating stubs in the test-utils
  8057. * It is *internal* but needs to be exposed for test-utils to pick up proper
  8058. * typings
  8059. */
  8060. function transformVNodeArgs(transformer) {
  8061. vnodeArgsTransformer = transformer;
  8062. }
  8063. const createVNodeWithArgsTransform = (...args) => {
  8064. return _createVNode(...(vnodeArgsTransformer
  8065. ? vnodeArgsTransformer(args, currentRenderingInstance)
  8066. : args));
  8067. };
  8068. const InternalObjectKey = `__vInternal`;
  8069. const normalizeKey = ({ key }) => key != null ? key : null;
  8070. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  8071. return (ref != null
  8072. ? isString(ref) || isRef(ref) || isFunction(ref)
  8073. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  8074. : ref
  8075. : null);
  8076. };
  8077. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ShapeFlags.ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  8078. const vnode = {
  8079. __v_isVNode: true,
  8080. __v_skip: true,
  8081. type,
  8082. props,
  8083. key: props && normalizeKey(props),
  8084. ref: props && normalizeRef(props),
  8085. scopeId: currentScopeId,
  8086. slotScopeIds: null,
  8087. children,
  8088. component: null,
  8089. suspense: null,
  8090. ssContent: null,
  8091. ssFallback: null,
  8092. dirs: null,
  8093. transition: null,
  8094. el: null,
  8095. anchor: null,
  8096. target: null,
  8097. targetAnchor: null,
  8098. staticCount: 0,
  8099. shapeFlag,
  8100. patchFlag,
  8101. dynamicProps,
  8102. dynamicChildren: null,
  8103. appContext: null,
  8104. ctx: currentRenderingInstance
  8105. };
  8106. if (needFullChildrenNormalization) {
  8107. normalizeChildren(vnode, children);
  8108. // normalize suspense children
  8109. if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  8110. type.normalize(vnode);
  8111. }
  8112. }
  8113. else if (children) {
  8114. // compiled element vnode - if children is passed, only possible types are
  8115. // string or Array.
  8116. vnode.shapeFlag |= isString(children)
  8117. ? 8 /* ShapeFlags.TEXT_CHILDREN */
  8118. : 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8119. }
  8120. // validate key
  8121. if (vnode.key !== vnode.key) {
  8122. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8123. }
  8124. // track vnode for block tree
  8125. if (isBlockTreeEnabled > 0 &&
  8126. // avoid a block node from tracking itself
  8127. !isBlockNode &&
  8128. // has current parent block
  8129. currentBlock &&
  8130. // presence of a patch flag indicates this node needs patching on updates.
  8131. // component nodes also should always be patched, because even if the
  8132. // component doesn't need to update, it needs to persist the instance on to
  8133. // the next vnode so that it can be properly unmounted later.
  8134. (vnode.patchFlag > 0 || shapeFlag & 6 /* ShapeFlags.COMPONENT */) &&
  8135. // the EVENTS flag is only for hydration and if it is the only flag, the
  8136. // vnode should not be considered dynamic due to handler caching.
  8137. vnode.patchFlag !== 32 /* PatchFlags.HYDRATE_EVENTS */) {
  8138. currentBlock.push(vnode);
  8139. }
  8140. return vnode;
  8141. }
  8142. const createVNode = (createVNodeWithArgsTransform );
  8143. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8144. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8145. if (!type) {
  8146. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  8147. }
  8148. type = Comment;
  8149. }
  8150. if (isVNode(type)) {
  8151. // createVNode receiving an existing vnode. This happens in cases like
  8152. // <component :is="vnode"/>
  8153. // #2078 make sure to merge refs during the clone instead of overwriting it
  8154. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  8155. if (children) {
  8156. normalizeChildren(cloned, children);
  8157. }
  8158. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8159. if (cloned.shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
  8160. currentBlock[currentBlock.indexOf(type)] = cloned;
  8161. }
  8162. else {
  8163. currentBlock.push(cloned);
  8164. }
  8165. }
  8166. cloned.patchFlag |= -2 /* PatchFlags.BAIL */;
  8167. return cloned;
  8168. }
  8169. // class component normalization.
  8170. if (isClassComponent(type)) {
  8171. type = type.__vccOpts;
  8172. }
  8173. // class & style normalization.
  8174. if (props) {
  8175. // for reactive or proxy objects, we need to clone it to enable mutation.
  8176. props = guardReactiveProps(props);
  8177. let { class: klass, style } = props;
  8178. if (klass && !isString(klass)) {
  8179. props.class = normalizeClass(klass);
  8180. }
  8181. if (isObject(style)) {
  8182. // reactive state objects need to be cloned since they are likely to be
  8183. // mutated
  8184. if (isProxy(style) && !isArray(style)) {
  8185. style = extend({}, style);
  8186. }
  8187. props.style = normalizeStyle(style);
  8188. }
  8189. }
  8190. // encode the vnode type information into a bitmap
  8191. const shapeFlag = isString(type)
  8192. ? 1 /* ShapeFlags.ELEMENT */
  8193. : isSuspense(type)
  8194. ? 128 /* ShapeFlags.SUSPENSE */
  8195. : isTeleport(type)
  8196. ? 64 /* ShapeFlags.TELEPORT */
  8197. : isObject(type)
  8198. ? 4 /* ShapeFlags.STATEFUL_COMPONENT */
  8199. : isFunction(type)
  8200. ? 2 /* ShapeFlags.FUNCTIONAL_COMPONENT */
  8201. : 0;
  8202. if (shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */ && isProxy(type)) {
  8203. type = toRaw(type);
  8204. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  8205. `lead to unnecessary performance overhead, and should be avoided by ` +
  8206. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  8207. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  8208. }
  8209. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  8210. }
  8211. function guardReactiveProps(props) {
  8212. if (!props)
  8213. return null;
  8214. return isProxy(props) || InternalObjectKey in props
  8215. ? extend({}, props)
  8216. : props;
  8217. }
  8218. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8219. // This is intentionally NOT using spread or extend to avoid the runtime
  8220. // key enumeration cost.
  8221. const { props, ref, patchFlag, children } = vnode;
  8222. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8223. const cloned = {
  8224. __v_isVNode: true,
  8225. __v_skip: true,
  8226. type: vnode.type,
  8227. props: mergedProps,
  8228. key: mergedProps && normalizeKey(mergedProps),
  8229. ref: extraProps && extraProps.ref
  8230. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  8231. // if the vnode itself already has a ref, cloneVNode will need to merge
  8232. // the refs so the single vnode can be set on multiple refs
  8233. mergeRef && ref
  8234. ? isArray(ref)
  8235. ? ref.concat(normalizeRef(extraProps))
  8236. : [ref, normalizeRef(extraProps)]
  8237. : normalizeRef(extraProps)
  8238. : ref,
  8239. scopeId: vnode.scopeId,
  8240. slotScopeIds: vnode.slotScopeIds,
  8241. children: patchFlag === -1 /* PatchFlags.HOISTED */ && isArray(children)
  8242. ? children.map(deepCloneVNode)
  8243. : children,
  8244. target: vnode.target,
  8245. targetAnchor: vnode.targetAnchor,
  8246. staticCount: vnode.staticCount,
  8247. shapeFlag: vnode.shapeFlag,
  8248. // if the vnode is cloned with extra props, we can no longer assume its
  8249. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8250. // note: preserve flag for fragments since they use the flag for children
  8251. // fast paths only.
  8252. patchFlag: extraProps && vnode.type !== Fragment
  8253. ? patchFlag === -1 // hoisted node
  8254. ? 16 /* PatchFlags.FULL_PROPS */
  8255. : patchFlag | 16 /* PatchFlags.FULL_PROPS */
  8256. : patchFlag,
  8257. dynamicProps: vnode.dynamicProps,
  8258. dynamicChildren: vnode.dynamicChildren,
  8259. appContext: vnode.appContext,
  8260. dirs: vnode.dirs,
  8261. transition: vnode.transition,
  8262. // These should technically only be non-null on mounted VNodes. However,
  8263. // they *should* be copied for kept-alive vnodes. So we just always copy
  8264. // them since them being non-null during a mount doesn't affect the logic as
  8265. // they will simply be overwritten.
  8266. component: vnode.component,
  8267. suspense: vnode.suspense,
  8268. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8269. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8270. el: vnode.el,
  8271. anchor: vnode.anchor,
  8272. ctx: vnode.ctx
  8273. };
  8274. return cloned;
  8275. }
  8276. /**
  8277. * Dev only, for HMR of hoisted vnodes reused in v-for
  8278. * https://github.com/vitejs/vite/issues/2022
  8279. */
  8280. function deepCloneVNode(vnode) {
  8281. const cloned = cloneVNode(vnode);
  8282. if (isArray(vnode.children)) {
  8283. cloned.children = vnode.children.map(deepCloneVNode);
  8284. }
  8285. return cloned;
  8286. }
  8287. /**
  8288. * @private
  8289. */
  8290. function createTextVNode(text = ' ', flag = 0) {
  8291. return createVNode(Text, null, text, flag);
  8292. }
  8293. /**
  8294. * @private
  8295. */
  8296. function createStaticVNode(content, numberOfNodes) {
  8297. // A static vnode can contain multiple stringified elements, and the number
  8298. // of elements is necessary for hydration.
  8299. const vnode = createVNode(Static, null, content);
  8300. vnode.staticCount = numberOfNodes;
  8301. return vnode;
  8302. }
  8303. /**
  8304. * @private
  8305. */
  8306. function createCommentVNode(text = '',
  8307. // when used as the v-else branch, the comment node must be created as a
  8308. // block to ensure correct updates.
  8309. asBlock = false) {
  8310. return asBlock
  8311. ? (openBlock(), createBlock(Comment, null, text))
  8312. : createVNode(Comment, null, text);
  8313. }
  8314. function normalizeVNode(child) {
  8315. if (child == null || typeof child === 'boolean') {
  8316. // empty placeholder
  8317. return createVNode(Comment);
  8318. }
  8319. else if (isArray(child)) {
  8320. // fragment
  8321. return createVNode(Fragment, null,
  8322. // #3666, avoid reference pollution when reusing vnode
  8323. child.slice());
  8324. }
  8325. else if (typeof child === 'object') {
  8326. // already vnode, this should be the most common since compiled templates
  8327. // always produce all-vnode children arrays
  8328. return cloneIfMounted(child);
  8329. }
  8330. else {
  8331. // strings and numbers
  8332. return createVNode(Text, null, String(child));
  8333. }
  8334. }
  8335. // optimized normalization for template-compiled render fns
  8336. function cloneIfMounted(child) {
  8337. return (child.el === null && child.patchFlag !== -1 /* PatchFlags.HOISTED */) ||
  8338. child.memo
  8339. ? child
  8340. : cloneVNode(child);
  8341. }
  8342. function normalizeChildren(vnode, children) {
  8343. let type = 0;
  8344. const { shapeFlag } = vnode;
  8345. if (children == null) {
  8346. children = null;
  8347. }
  8348. else if (isArray(children)) {
  8349. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8350. }
  8351. else if (typeof children === 'object') {
  8352. if (shapeFlag & (1 /* ShapeFlags.ELEMENT */ | 64 /* ShapeFlags.TELEPORT */)) {
  8353. // Normalize slot to plain children for plain element and Teleport
  8354. const slot = children.default;
  8355. if (slot) {
  8356. // _c marker is added by withCtx() indicating this is a compiled slot
  8357. slot._c && (slot._d = false);
  8358. normalizeChildren(vnode, slot());
  8359. slot._c && (slot._d = true);
  8360. }
  8361. return;
  8362. }
  8363. else {
  8364. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  8365. const slotFlag = children._;
  8366. if (!slotFlag && !(InternalObjectKey in children)) {
  8367. children._ctx = currentRenderingInstance;
  8368. }
  8369. else if (slotFlag === 3 /* SlotFlags.FORWARDED */ && currentRenderingInstance) {
  8370. // a child component receives forwarded slots from the parent.
  8371. // its slot type is determined by its parent's slot type.
  8372. if (currentRenderingInstance.slots._ === 1 /* SlotFlags.STABLE */) {
  8373. children._ = 1 /* SlotFlags.STABLE */;
  8374. }
  8375. else {
  8376. children._ = 2 /* SlotFlags.DYNAMIC */;
  8377. vnode.patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
  8378. }
  8379. }
  8380. }
  8381. }
  8382. else if (isFunction(children)) {
  8383. children = { default: children, _ctx: currentRenderingInstance };
  8384. type = 32 /* ShapeFlags.SLOTS_CHILDREN */;
  8385. }
  8386. else {
  8387. children = String(children);
  8388. // force teleport children to array so it can be moved around
  8389. if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
  8390. type = 16 /* ShapeFlags.ARRAY_CHILDREN */;
  8391. children = [createTextVNode(children)];
  8392. }
  8393. else {
  8394. type = 8 /* ShapeFlags.TEXT_CHILDREN */;
  8395. }
  8396. }
  8397. vnode.children = children;
  8398. vnode.shapeFlag |= type;
  8399. }
  8400. function mergeProps(...args) {
  8401. const ret = {};
  8402. for (let i = 0; i < args.length; i++) {
  8403. const toMerge = args[i];
  8404. for (const key in toMerge) {
  8405. if (key === 'class') {
  8406. if (ret.class !== toMerge.class) {
  8407. ret.class = normalizeClass([ret.class, toMerge.class]);
  8408. }
  8409. }
  8410. else if (key === 'style') {
  8411. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8412. }
  8413. else if (isOn(key)) {
  8414. const existing = ret[key];
  8415. const incoming = toMerge[key];
  8416. if (incoming &&
  8417. existing !== incoming &&
  8418. !(isArray(existing) && existing.includes(incoming))) {
  8419. ret[key] = existing
  8420. ? [].concat(existing, incoming)
  8421. : incoming;
  8422. }
  8423. }
  8424. else if (key !== '') {
  8425. ret[key] = toMerge[key];
  8426. }
  8427. }
  8428. }
  8429. return ret;
  8430. }
  8431. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8432. callWithAsyncErrorHandling(hook, instance, 7 /* ErrorCodes.VNODE_HOOK */, [
  8433. vnode,
  8434. prevVNode
  8435. ]);
  8436. }
  8437. const emptyAppContext = createAppContext();
  8438. let uid$1 = 0;
  8439. function createComponentInstance(vnode, parent, suspense) {
  8440. const type = vnode.type;
  8441. // inherit parent app context - or - if root, adopt from root vnode
  8442. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8443. const instance = {
  8444. uid: uid$1++,
  8445. vnode,
  8446. type,
  8447. parent,
  8448. appContext,
  8449. root: null,
  8450. next: null,
  8451. subTree: null,
  8452. effect: null,
  8453. update: null,
  8454. scope: new EffectScope(true /* detached */),
  8455. render: null,
  8456. proxy: null,
  8457. exposed: null,
  8458. exposeProxy: null,
  8459. withProxy: null,
  8460. provides: parent ? parent.provides : Object.create(appContext.provides),
  8461. accessCache: null,
  8462. renderCache: [],
  8463. // local resolved assets
  8464. components: null,
  8465. directives: null,
  8466. // resolved props and emits options
  8467. propsOptions: normalizePropsOptions(type, appContext),
  8468. emitsOptions: normalizeEmitsOptions(type, appContext),
  8469. // emit
  8470. emit: null,
  8471. emitted: null,
  8472. // props default value
  8473. propsDefaults: EMPTY_OBJ,
  8474. // inheritAttrs
  8475. inheritAttrs: type.inheritAttrs,
  8476. // state
  8477. ctx: EMPTY_OBJ,
  8478. data: EMPTY_OBJ,
  8479. props: EMPTY_OBJ,
  8480. attrs: EMPTY_OBJ,
  8481. slots: EMPTY_OBJ,
  8482. refs: EMPTY_OBJ,
  8483. setupState: EMPTY_OBJ,
  8484. setupContext: null,
  8485. // suspense related
  8486. suspense,
  8487. suspenseId: suspense ? suspense.pendingId : 0,
  8488. asyncDep: null,
  8489. asyncResolved: false,
  8490. // lifecycle hooks
  8491. // not using enums here because it results in computed properties
  8492. isMounted: false,
  8493. isUnmounted: false,
  8494. isDeactivated: false,
  8495. bc: null,
  8496. c: null,
  8497. bm: null,
  8498. m: null,
  8499. bu: null,
  8500. u: null,
  8501. um: null,
  8502. bum: null,
  8503. da: null,
  8504. a: null,
  8505. rtg: null,
  8506. rtc: null,
  8507. ec: null,
  8508. sp: null
  8509. };
  8510. {
  8511. instance.ctx = createDevRenderContext(instance);
  8512. }
  8513. instance.root = parent ? parent.root : instance;
  8514. instance.emit = emit$1.bind(null, instance);
  8515. // apply custom element special handling
  8516. if (vnode.ce) {
  8517. vnode.ce(instance);
  8518. }
  8519. return instance;
  8520. }
  8521. let currentInstance = null;
  8522. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8523. const setCurrentInstance = (instance) => {
  8524. currentInstance = instance;
  8525. instance.scope.on();
  8526. };
  8527. const unsetCurrentInstance = () => {
  8528. currentInstance && currentInstance.scope.off();
  8529. currentInstance = null;
  8530. };
  8531. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  8532. function validateComponentName(name, config) {
  8533. const appIsNativeTag = config.isNativeTag || NO;
  8534. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8535. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  8536. }
  8537. }
  8538. function isStatefulComponent(instance) {
  8539. return instance.vnode.shapeFlag & 4 /* ShapeFlags.STATEFUL_COMPONENT */;
  8540. }
  8541. let isInSSRComponentSetup = false;
  8542. function setupComponent(instance, isSSR = false) {
  8543. isInSSRComponentSetup = isSSR;
  8544. const { props, children } = instance.vnode;
  8545. const isStateful = isStatefulComponent(instance);
  8546. initProps(instance, props, isStateful, isSSR);
  8547. initSlots(instance, children);
  8548. const setupResult = isStateful
  8549. ? setupStatefulComponent(instance, isSSR)
  8550. : undefined;
  8551. isInSSRComponentSetup = false;
  8552. return setupResult;
  8553. }
  8554. function setupStatefulComponent(instance, isSSR) {
  8555. var _a;
  8556. const Component = instance.type;
  8557. {
  8558. if (Component.name) {
  8559. validateComponentName(Component.name, instance.appContext.config);
  8560. }
  8561. if (Component.components) {
  8562. const names = Object.keys(Component.components);
  8563. for (let i = 0; i < names.length; i++) {
  8564. validateComponentName(names[i], instance.appContext.config);
  8565. }
  8566. }
  8567. if (Component.directives) {
  8568. const names = Object.keys(Component.directives);
  8569. for (let i = 0; i < names.length; i++) {
  8570. validateDirectiveName(names[i]);
  8571. }
  8572. }
  8573. if (Component.compilerOptions && isRuntimeOnly()) {
  8574. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  8575. `includes the runtime compiler. Since you are using a runtime-only ` +
  8576. `build, the options should be passed via your build tool config instead.`);
  8577. }
  8578. }
  8579. // 0. create render proxy property access cache
  8580. instance.accessCache = Object.create(null);
  8581. // 1. create public instance / render proxy
  8582. // also mark it raw so it's never observed
  8583. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8584. {
  8585. exposePropsOnRenderContext(instance);
  8586. }
  8587. // 2. call setup()
  8588. const { setup } = Component;
  8589. if (setup) {
  8590. const setupContext = (instance.setupContext =
  8591. setup.length > 1 ? createSetupContext(instance) : null);
  8592. setCurrentInstance(instance);
  8593. pauseTracking();
  8594. const setupResult = callWithErrorHandling(setup, instance, 0 /* ErrorCodes.SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  8595. resetTracking();
  8596. unsetCurrentInstance();
  8597. if (isPromise(setupResult)) {
  8598. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8599. if (isSSR) {
  8600. // return the promise so server-renderer can wait on it
  8601. return setupResult
  8602. .then((resolvedResult) => {
  8603. handleSetupResult(instance, resolvedResult, isSSR);
  8604. })
  8605. .catch(e => {
  8606. handleError(e, instance, 0 /* ErrorCodes.SETUP_FUNCTION */);
  8607. });
  8608. }
  8609. else {
  8610. // async setup returned Promise.
  8611. // bail here and wait for re-entry.
  8612. instance.asyncDep = setupResult;
  8613. if (!instance.suspense) {
  8614. const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
  8615. warn$1(`Component <${name}>: setup function returned a promise, but no ` +
  8616. `<Suspense> boundary was found in the parent component tree. ` +
  8617. `A component with async setup() must be nested in a <Suspense> ` +
  8618. `in order to be rendered.`);
  8619. }
  8620. }
  8621. }
  8622. else {
  8623. handleSetupResult(instance, setupResult, isSSR);
  8624. }
  8625. }
  8626. else {
  8627. finishComponentSetup(instance, isSSR);
  8628. }
  8629. }
  8630. function handleSetupResult(instance, setupResult, isSSR) {
  8631. if (isFunction(setupResult)) {
  8632. // setup returned an inline render function
  8633. {
  8634. instance.render = setupResult;
  8635. }
  8636. }
  8637. else if (isObject(setupResult)) {
  8638. if (isVNode(setupResult)) {
  8639. warn$1(`setup() should not return VNodes directly - ` +
  8640. `return a render function instead.`);
  8641. }
  8642. // setup returned bindings.
  8643. // assuming a render function compiled from template is present.
  8644. {
  8645. instance.devtoolsRawSetupState = setupResult;
  8646. }
  8647. instance.setupState = proxyRefs(setupResult);
  8648. {
  8649. exposeSetupStateOnRenderContext(instance);
  8650. }
  8651. }
  8652. else if (setupResult !== undefined) {
  8653. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  8654. }
  8655. finishComponentSetup(instance, isSSR);
  8656. }
  8657. let compile;
  8658. let installWithProxy;
  8659. /**
  8660. * For runtime-dom to register the compiler.
  8661. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  8662. */
  8663. function registerRuntimeCompiler(_compile) {
  8664. compile = _compile;
  8665. installWithProxy = i => {
  8666. if (i.render._rc) {
  8667. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8668. }
  8669. };
  8670. }
  8671. // dev only
  8672. const isRuntimeOnly = () => !compile;
  8673. function finishComponentSetup(instance, isSSR, skipOptions) {
  8674. const Component = instance.type;
  8675. // template / render function normalization
  8676. // could be already set when returned from setup()
  8677. if (!instance.render) {
  8678. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  8679. // is done by server-renderer
  8680. if (!isSSR && compile && !Component.render) {
  8681. const template = Component.template ||
  8682. resolveMergedOptions(instance).template;
  8683. if (template) {
  8684. {
  8685. startMeasure(instance, `compile`);
  8686. }
  8687. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8688. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8689. const finalCompilerOptions = extend(extend({
  8690. isCustomElement,
  8691. delimiters
  8692. }, compilerOptions), componentCompilerOptions);
  8693. Component.render = compile(template, finalCompilerOptions);
  8694. {
  8695. endMeasure(instance, `compile`);
  8696. }
  8697. }
  8698. }
  8699. instance.render = (Component.render || NOOP);
  8700. // for runtime-compiled render functions using `with` blocks, the render
  8701. // proxy used needs a different `has` handler which is more performant and
  8702. // also only allows a whitelist of globals to fallthrough.
  8703. if (installWithProxy) {
  8704. installWithProxy(instance);
  8705. }
  8706. }
  8707. // support for 2.x options
  8708. {
  8709. setCurrentInstance(instance);
  8710. pauseTracking();
  8711. applyOptions(instance);
  8712. resetTracking();
  8713. unsetCurrentInstance();
  8714. }
  8715. // warn missing template/render
  8716. // the runtime compilation of template in SSR is done by server-render
  8717. if (!Component.render && instance.render === NOOP && !isSSR) {
  8718. /* istanbul ignore if */
  8719. if (!compile && Component.template) {
  8720. warn$1(`Component provided template option but ` +
  8721. `runtime compilation is not supported in this build of Vue.` +
  8722. (` Use "vue.esm-browser.js" instead.`
  8723. ) /* should not happen */);
  8724. }
  8725. else {
  8726. warn$1(`Component is missing template or render function.`);
  8727. }
  8728. }
  8729. }
  8730. function createAttrsProxy(instance) {
  8731. return new Proxy(instance.attrs, {
  8732. get(target, key) {
  8733. markAttrsAccessed();
  8734. track(instance, "get" /* TrackOpTypes.GET */, '$attrs');
  8735. return target[key];
  8736. },
  8737. set() {
  8738. warn$1(`setupContext.attrs is readonly.`);
  8739. return false;
  8740. },
  8741. deleteProperty() {
  8742. warn$1(`setupContext.attrs is readonly.`);
  8743. return false;
  8744. }
  8745. }
  8746. );
  8747. }
  8748. function createSetupContext(instance) {
  8749. const expose = exposed => {
  8750. if (instance.exposed) {
  8751. warn$1(`expose() should be called only once per setup().`);
  8752. }
  8753. instance.exposed = exposed || {};
  8754. };
  8755. let attrs;
  8756. {
  8757. // We use getters in dev in case libs like test-utils overwrite instance
  8758. // properties (overwrites should not be done in prod)
  8759. return Object.freeze({
  8760. get attrs() {
  8761. return attrs || (attrs = createAttrsProxy(instance));
  8762. },
  8763. get slots() {
  8764. return shallowReadonly(instance.slots);
  8765. },
  8766. get emit() {
  8767. return (event, ...args) => instance.emit(event, ...args);
  8768. },
  8769. expose
  8770. });
  8771. }
  8772. }
  8773. function getExposeProxy(instance) {
  8774. if (instance.exposed) {
  8775. return (instance.exposeProxy ||
  8776. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8777. get(target, key) {
  8778. if (key in target) {
  8779. return target[key];
  8780. }
  8781. else if (key in publicPropertiesMap) {
  8782. return publicPropertiesMap[key](instance);
  8783. }
  8784. },
  8785. has(target, key) {
  8786. return key in target || key in publicPropertiesMap;
  8787. }
  8788. })));
  8789. }
  8790. }
  8791. const classifyRE = /(?:^|[-_])(\w)/g;
  8792. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  8793. function getComponentName(Component, includeInferred = true) {
  8794. return isFunction(Component)
  8795. ? Component.displayName || Component.name
  8796. : Component.name || (includeInferred && Component.__name);
  8797. }
  8798. /* istanbul ignore next */
  8799. function formatComponentName(instance, Component, isRoot = false) {
  8800. let name = getComponentName(Component);
  8801. if (!name && Component.__file) {
  8802. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8803. if (match) {
  8804. name = match[1];
  8805. }
  8806. }
  8807. if (!name && instance && instance.parent) {
  8808. // try to infer the name based on reverse resolution
  8809. const inferFromRegistry = (registry) => {
  8810. for (const key in registry) {
  8811. if (registry[key] === Component) {
  8812. return key;
  8813. }
  8814. }
  8815. };
  8816. name =
  8817. inferFromRegistry(instance.components ||
  8818. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  8819. }
  8820. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8821. }
  8822. function isClassComponent(value) {
  8823. return isFunction(value) && '__vccOpts' in value;
  8824. }
  8825. const computed$1 = ((getterOrOptions, debugOptions) => {
  8826. // @ts-ignore
  8827. return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8828. });
  8829. // dev only
  8830. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8831. `<script setup> of a single file component. Its arguments should be ` +
  8832. `compiled away and passing it at runtime has no effect.`);
  8833. // implementation
  8834. function defineProps() {
  8835. {
  8836. warnRuntimeUsage(`defineProps`);
  8837. }
  8838. return null;
  8839. }
  8840. // implementation
  8841. function defineEmits() {
  8842. {
  8843. warnRuntimeUsage(`defineEmits`);
  8844. }
  8845. return null;
  8846. }
  8847. /**
  8848. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8849. * instance properties when it is accessed by a parent component via template
  8850. * refs.
  8851. *
  8852. * `<script setup>` components are closed by default - i.e. variables inside
  8853. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8854. * via `defineExpose`.
  8855. *
  8856. * This is only usable inside `<script setup>`, is compiled away in the
  8857. * output and should **not** be actually called at runtime.
  8858. */
  8859. function defineExpose(exposed) {
  8860. {
  8861. warnRuntimeUsage(`defineExpose`);
  8862. }
  8863. }
  8864. /**
  8865. * Vue `<script setup>` compiler macro for providing props default values when
  8866. * using type-based `defineProps` declaration.
  8867. *
  8868. * Example usage:
  8869. * ```ts
  8870. * withDefaults(defineProps<{
  8871. * size?: number
  8872. * labels?: string[]
  8873. * }>(), {
  8874. * size: 3,
  8875. * labels: () => ['default label']
  8876. * })
  8877. * ```
  8878. *
  8879. * This is only usable inside `<script setup>`, is compiled away in the output
  8880. * and should **not** be actually called at runtime.
  8881. */
  8882. function withDefaults(props, defaults) {
  8883. {
  8884. warnRuntimeUsage(`withDefaults`);
  8885. }
  8886. return null;
  8887. }
  8888. function useSlots() {
  8889. return getContext().slots;
  8890. }
  8891. function useAttrs() {
  8892. return getContext().attrs;
  8893. }
  8894. function getContext() {
  8895. const i = getCurrentInstance();
  8896. if (!i) {
  8897. warn$1(`useContext() called without active instance.`);
  8898. }
  8899. return i.setupContext || (i.setupContext = createSetupContext(i));
  8900. }
  8901. /**
  8902. * Runtime helper for merging default declarations. Imported by compiled code
  8903. * only.
  8904. * @internal
  8905. */
  8906. function mergeDefaults(raw, defaults) {
  8907. const props = isArray(raw)
  8908. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8909. : raw;
  8910. for (const key in defaults) {
  8911. const opt = props[key];
  8912. if (opt) {
  8913. if (isArray(opt) || isFunction(opt)) {
  8914. props[key] = { type: opt, default: defaults[key] };
  8915. }
  8916. else {
  8917. opt.default = defaults[key];
  8918. }
  8919. }
  8920. else if (opt === null) {
  8921. props[key] = { default: defaults[key] };
  8922. }
  8923. else {
  8924. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8925. }
  8926. }
  8927. return props;
  8928. }
  8929. /**
  8930. * Used to create a proxy for the rest element when destructuring props with
  8931. * defineProps().
  8932. * @internal
  8933. */
  8934. function createPropsRestProxy(props, excludedKeys) {
  8935. const ret = {};
  8936. for (const key in props) {
  8937. if (!excludedKeys.includes(key)) {
  8938. Object.defineProperty(ret, key, {
  8939. enumerable: true,
  8940. get: () => props[key]
  8941. });
  8942. }
  8943. }
  8944. return ret;
  8945. }
  8946. /**
  8947. * `<script setup>` helper for persisting the current instance context over
  8948. * async/await flows.
  8949. *
  8950. * `@vue/compiler-sfc` converts the following:
  8951. *
  8952. * ```ts
  8953. * const x = await foo()
  8954. * ```
  8955. *
  8956. * into:
  8957. *
  8958. * ```ts
  8959. * let __temp, __restore
  8960. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8961. * ```
  8962. * @internal
  8963. */
  8964. function withAsyncContext(getAwaitable) {
  8965. const ctx = getCurrentInstance();
  8966. if (!ctx) {
  8967. warn$1(`withAsyncContext called without active current instance. ` +
  8968. `This is likely a bug.`);
  8969. }
  8970. let awaitable = getAwaitable();
  8971. unsetCurrentInstance();
  8972. if (isPromise(awaitable)) {
  8973. awaitable = awaitable.catch(e => {
  8974. setCurrentInstance(ctx);
  8975. throw e;
  8976. });
  8977. }
  8978. return [awaitable, () => setCurrentInstance(ctx)];
  8979. }
  8980. // Actual implementation
  8981. function h(type, propsOrChildren, children) {
  8982. const l = arguments.length;
  8983. if (l === 2) {
  8984. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8985. // single vnode without props
  8986. if (isVNode(propsOrChildren)) {
  8987. return createVNode(type, null, [propsOrChildren]);
  8988. }
  8989. // props without children
  8990. return createVNode(type, propsOrChildren);
  8991. }
  8992. else {
  8993. // omit props
  8994. return createVNode(type, null, propsOrChildren);
  8995. }
  8996. }
  8997. else {
  8998. if (l > 3) {
  8999. children = Array.prototype.slice.call(arguments, 2);
  9000. }
  9001. else if (l === 3 && isVNode(children)) {
  9002. children = [children];
  9003. }
  9004. return createVNode(type, propsOrChildren, children);
  9005. }
  9006. }
  9007. const ssrContextKey = Symbol(`ssrContext` );
  9008. const useSSRContext = () => {
  9009. {
  9010. const ctx = inject(ssrContextKey);
  9011. if (!ctx) {
  9012. warn$1(`Server rendering context not provided. Make sure to only call ` +
  9013. `useSSRContext() conditionally in the server build.`);
  9014. }
  9015. return ctx;
  9016. }
  9017. };
  9018. function initCustomFormatter() {
  9019. /* eslint-disable no-restricted-globals */
  9020. if (typeof window === 'undefined') {
  9021. return;
  9022. }
  9023. const vueStyle = { style: 'color:#3ba776' };
  9024. const numberStyle = { style: 'color:#0b1bc9' };
  9025. const stringStyle = { style: 'color:#b62e24' };
  9026. const keywordStyle = { style: 'color:#9d288c' };
  9027. // custom formatter for Chrome
  9028. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  9029. const formatter = {
  9030. header(obj) {
  9031. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  9032. if (!isObject(obj)) {
  9033. return null;
  9034. }
  9035. if (obj.__isVue) {
  9036. return ['div', vueStyle, `VueInstance`];
  9037. }
  9038. else if (isRef(obj)) {
  9039. return [
  9040. 'div',
  9041. {},
  9042. ['span', vueStyle, genRefFlag(obj)],
  9043. '<',
  9044. formatValue(obj.value),
  9045. `>`
  9046. ];
  9047. }
  9048. else if (isReactive(obj)) {
  9049. return [
  9050. 'div',
  9051. {},
  9052. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  9053. '<',
  9054. formatValue(obj),
  9055. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  9056. ];
  9057. }
  9058. else if (isReadonly(obj)) {
  9059. return [
  9060. 'div',
  9061. {},
  9062. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  9063. '<',
  9064. formatValue(obj),
  9065. '>'
  9066. ];
  9067. }
  9068. return null;
  9069. },
  9070. hasBody(obj) {
  9071. return obj && obj.__isVue;
  9072. },
  9073. body(obj) {
  9074. if (obj && obj.__isVue) {
  9075. return [
  9076. 'div',
  9077. {},
  9078. ...formatInstance(obj.$)
  9079. ];
  9080. }
  9081. }
  9082. };
  9083. function formatInstance(instance) {
  9084. const blocks = [];
  9085. if (instance.type.props && instance.props) {
  9086. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  9087. }
  9088. if (instance.setupState !== EMPTY_OBJ) {
  9089. blocks.push(createInstanceBlock('setup', instance.setupState));
  9090. }
  9091. if (instance.data !== EMPTY_OBJ) {
  9092. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  9093. }
  9094. const computed = extractKeys(instance, 'computed');
  9095. if (computed) {
  9096. blocks.push(createInstanceBlock('computed', computed));
  9097. }
  9098. const injected = extractKeys(instance, 'inject');
  9099. if (injected) {
  9100. blocks.push(createInstanceBlock('injected', injected));
  9101. }
  9102. blocks.push([
  9103. 'div',
  9104. {},
  9105. [
  9106. 'span',
  9107. {
  9108. style: keywordStyle.style + ';opacity:0.66'
  9109. },
  9110. '$ (internal): '
  9111. ],
  9112. ['object', { object: instance }]
  9113. ]);
  9114. return blocks;
  9115. }
  9116. function createInstanceBlock(type, target) {
  9117. target = extend({}, target);
  9118. if (!Object.keys(target).length) {
  9119. return ['span', {}];
  9120. }
  9121. return [
  9122. 'div',
  9123. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  9124. [
  9125. 'div',
  9126. {
  9127. style: 'color:#476582'
  9128. },
  9129. type
  9130. ],
  9131. [
  9132. 'div',
  9133. {
  9134. style: 'padding-left:1.25em'
  9135. },
  9136. ...Object.keys(target).map(key => {
  9137. return [
  9138. 'div',
  9139. {},
  9140. ['span', keywordStyle, key + ': '],
  9141. formatValue(target[key], false)
  9142. ];
  9143. })
  9144. ]
  9145. ];
  9146. }
  9147. function formatValue(v, asRaw = true) {
  9148. if (typeof v === 'number') {
  9149. return ['span', numberStyle, v];
  9150. }
  9151. else if (typeof v === 'string') {
  9152. return ['span', stringStyle, JSON.stringify(v)];
  9153. }
  9154. else if (typeof v === 'boolean') {
  9155. return ['span', keywordStyle, v];
  9156. }
  9157. else if (isObject(v)) {
  9158. return ['object', { object: asRaw ? toRaw(v) : v }];
  9159. }
  9160. else {
  9161. return ['span', stringStyle, String(v)];
  9162. }
  9163. }
  9164. function extractKeys(instance, type) {
  9165. const Comp = instance.type;
  9166. if (isFunction(Comp)) {
  9167. return;
  9168. }
  9169. const extracted = {};
  9170. for (const key in instance.ctx) {
  9171. if (isKeyOfType(Comp, key, type)) {
  9172. extracted[key] = instance.ctx[key];
  9173. }
  9174. }
  9175. return extracted;
  9176. }
  9177. function isKeyOfType(Comp, key, type) {
  9178. const opts = Comp[type];
  9179. if ((isArray(opts) && opts.includes(key)) ||
  9180. (isObject(opts) && key in opts)) {
  9181. return true;
  9182. }
  9183. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9184. return true;
  9185. }
  9186. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  9187. return true;
  9188. }
  9189. }
  9190. function genRefFlag(v) {
  9191. if (isShallow(v)) {
  9192. return `ShallowRef`;
  9193. }
  9194. if (v.effect) {
  9195. return `ComputedRef`;
  9196. }
  9197. return `Ref`;
  9198. }
  9199. if (window.devtoolsFormatters) {
  9200. window.devtoolsFormatters.push(formatter);
  9201. }
  9202. else {
  9203. window.devtoolsFormatters = [formatter];
  9204. }
  9205. }
  9206. function withMemo(memo, render, cache, index) {
  9207. const cached = cache[index];
  9208. if (cached && isMemoSame(cached, memo)) {
  9209. return cached;
  9210. }
  9211. const ret = render();
  9212. // shallow clone
  9213. ret.memo = memo.slice();
  9214. return (cache[index] = ret);
  9215. }
  9216. function isMemoSame(cached, memo) {
  9217. const prev = cached.memo;
  9218. if (prev.length != memo.length) {
  9219. return false;
  9220. }
  9221. for (let i = 0; i < prev.length; i++) {
  9222. if (hasChanged(prev[i], memo[i])) {
  9223. return false;
  9224. }
  9225. }
  9226. // make sure to let parent block track it when returning cached
  9227. if (isBlockTreeEnabled > 0 && currentBlock) {
  9228. currentBlock.push(cached);
  9229. }
  9230. return true;
  9231. }
  9232. // Core API ------------------------------------------------------------------
  9233. const version = "3.2.45";
  9234. /**
  9235. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  9236. * @internal
  9237. */
  9238. const ssrUtils = (null);
  9239. /**
  9240. * @internal only exposed in compat builds
  9241. */
  9242. const resolveFilter = null;
  9243. /**
  9244. * @internal only exposed in compat builds.
  9245. */
  9246. const compatUtils = (null);
  9247. const svgNS = 'http://www.w3.org/2000/svg';
  9248. const doc = (typeof document !== 'undefined' ? document : null);
  9249. const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
  9250. const nodeOps = {
  9251. insert: (child, parent, anchor) => {
  9252. parent.insertBefore(child, anchor || null);
  9253. },
  9254. remove: child => {
  9255. const parent = child.parentNode;
  9256. if (parent) {
  9257. parent.removeChild(child);
  9258. }
  9259. },
  9260. createElement: (tag, isSVG, is, props) => {
  9261. const el = isSVG
  9262. ? doc.createElementNS(svgNS, tag)
  9263. : doc.createElement(tag, is ? { is } : undefined);
  9264. if (tag === 'select' && props && props.multiple != null) {
  9265. el.setAttribute('multiple', props.multiple);
  9266. }
  9267. return el;
  9268. },
  9269. createText: text => doc.createTextNode(text),
  9270. createComment: text => doc.createComment(text),
  9271. setText: (node, text) => {
  9272. node.nodeValue = text;
  9273. },
  9274. setElementText: (el, text) => {
  9275. el.textContent = text;
  9276. },
  9277. parentNode: node => node.parentNode,
  9278. nextSibling: node => node.nextSibling,
  9279. querySelector: selector => doc.querySelector(selector),
  9280. setScopeId(el, id) {
  9281. el.setAttribute(id, '');
  9282. },
  9283. // __UNSAFE__
  9284. // Reason: innerHTML.
  9285. // Static content here can only come from compiled templates.
  9286. // As long as the user only uses trusted templates, this is safe.
  9287. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9288. // <parent> before | first ... last | anchor </parent>
  9289. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9290. // #5308 can only take cached path if:
  9291. // - has a single root node
  9292. // - nextSibling info is still available
  9293. if (start && (start === end || start.nextSibling)) {
  9294. // cached
  9295. while (true) {
  9296. parent.insertBefore(start.cloneNode(true), anchor);
  9297. if (start === end || !(start = start.nextSibling))
  9298. break;
  9299. }
  9300. }
  9301. else {
  9302. // fresh insert
  9303. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9304. const template = templateContainer.content;
  9305. if (isSVG) {
  9306. // remove outer svg wrapper
  9307. const wrapper = template.firstChild;
  9308. while (wrapper.firstChild) {
  9309. template.appendChild(wrapper.firstChild);
  9310. }
  9311. template.removeChild(wrapper);
  9312. }
  9313. parent.insertBefore(template, anchor);
  9314. }
  9315. return [
  9316. // first
  9317. before ? before.nextSibling : parent.firstChild,
  9318. // last
  9319. anchor ? anchor.previousSibling : parent.lastChild
  9320. ];
  9321. }
  9322. };
  9323. // compiler should normalize class + :class bindings on the same element
  9324. // into a single binding ['staticClass', dynamic]
  9325. function patchClass(el, value, isSVG) {
  9326. // directly setting className should be faster than setAttribute in theory
  9327. // if this is an element during a transition, take the temporary transition
  9328. // classes into account.
  9329. const transitionClasses = el._vtc;
  9330. if (transitionClasses) {
  9331. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9332. }
  9333. if (value == null) {
  9334. el.removeAttribute('class');
  9335. }
  9336. else if (isSVG) {
  9337. el.setAttribute('class', value);
  9338. }
  9339. else {
  9340. el.className = value;
  9341. }
  9342. }
  9343. function patchStyle(el, prev, next) {
  9344. const style = el.style;
  9345. const isCssString = isString(next);
  9346. if (next && !isCssString) {
  9347. for (const key in next) {
  9348. setStyle(style, key, next[key]);
  9349. }
  9350. if (prev && !isString(prev)) {
  9351. for (const key in prev) {
  9352. if (next[key] == null) {
  9353. setStyle(style, key, '');
  9354. }
  9355. }
  9356. }
  9357. }
  9358. else {
  9359. const currentDisplay = style.display;
  9360. if (isCssString) {
  9361. if (prev !== next) {
  9362. style.cssText = next;
  9363. }
  9364. }
  9365. else if (prev) {
  9366. el.removeAttribute('style');
  9367. }
  9368. // indicates that the `display` of the element is controlled by `v-show`,
  9369. // so we always keep the current `display` value regardless of the `style`
  9370. // value, thus handing over control to `v-show`.
  9371. if ('_vod' in el) {
  9372. style.display = currentDisplay;
  9373. }
  9374. }
  9375. }
  9376. const semicolonRE = /[^\\];\s*$/;
  9377. const importantRE = /\s*!important$/;
  9378. function setStyle(style, name, val) {
  9379. if (isArray(val)) {
  9380. val.forEach(v => setStyle(style, name, v));
  9381. }
  9382. else {
  9383. if (val == null)
  9384. val = '';
  9385. {
  9386. if (semicolonRE.test(val)) {
  9387. warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
  9388. }
  9389. }
  9390. if (name.startsWith('--')) {
  9391. // custom property definition
  9392. style.setProperty(name, val);
  9393. }
  9394. else {
  9395. const prefixed = autoPrefix(style, name);
  9396. if (importantRE.test(val)) {
  9397. // !important
  9398. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9399. }
  9400. else {
  9401. style[prefixed] = val;
  9402. }
  9403. }
  9404. }
  9405. }
  9406. const prefixes = ['Webkit', 'Moz', 'ms'];
  9407. const prefixCache = {};
  9408. function autoPrefix(style, rawName) {
  9409. const cached = prefixCache[rawName];
  9410. if (cached) {
  9411. return cached;
  9412. }
  9413. let name = camelize(rawName);
  9414. if (name !== 'filter' && name in style) {
  9415. return (prefixCache[rawName] = name);
  9416. }
  9417. name = capitalize(name);
  9418. for (let i = 0; i < prefixes.length; i++) {
  9419. const prefixed = prefixes[i] + name;
  9420. if (prefixed in style) {
  9421. return (prefixCache[rawName] = prefixed);
  9422. }
  9423. }
  9424. return rawName;
  9425. }
  9426. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9427. function patchAttr(el, key, value, isSVG, instance) {
  9428. if (isSVG && key.startsWith('xlink:')) {
  9429. if (value == null) {
  9430. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9431. }
  9432. else {
  9433. el.setAttributeNS(xlinkNS, key, value);
  9434. }
  9435. }
  9436. else {
  9437. // note we are only checking boolean attributes that don't have a
  9438. // corresponding dom prop of the same name here.
  9439. const isBoolean = isSpecialBooleanAttr(key);
  9440. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9441. el.removeAttribute(key);
  9442. }
  9443. else {
  9444. el.setAttribute(key, isBoolean ? '' : value);
  9445. }
  9446. }
  9447. }
  9448. // __UNSAFE__
  9449. // functions. The user is responsible for using them with only trusted content.
  9450. function patchDOMProp(el, key, value,
  9451. // the following args are passed only due to potential innerHTML/textContent
  9452. // overriding existing VNodes, in which case the old tree must be properly
  9453. // unmounted.
  9454. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9455. if (key === 'innerHTML' || key === 'textContent') {
  9456. if (prevChildren) {
  9457. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9458. }
  9459. el[key] = value == null ? '' : value;
  9460. return;
  9461. }
  9462. if (key === 'value' &&
  9463. el.tagName !== 'PROGRESS' &&
  9464. // custom elements may use _value internally
  9465. !el.tagName.includes('-')) {
  9466. // store value as _value as well since
  9467. // non-string values will be stringified.
  9468. el._value = value;
  9469. const newValue = value == null ? '' : value;
  9470. if (el.value !== newValue ||
  9471. // #4956: always set for OPTION elements because its value falls back to
  9472. // textContent if no value attribute is present. And setting .value for
  9473. // OPTION has no side effect
  9474. el.tagName === 'OPTION') {
  9475. el.value = newValue;
  9476. }
  9477. if (value == null) {
  9478. el.removeAttribute(key);
  9479. }
  9480. return;
  9481. }
  9482. let needRemove = false;
  9483. if (value === '' || value == null) {
  9484. const type = typeof el[key];
  9485. if (type === 'boolean') {
  9486. // e.g. <select multiple> compiles to { multiple: '' }
  9487. value = includeBooleanAttr(value);
  9488. }
  9489. else if (value == null && type === 'string') {
  9490. // e.g. <div :id="null">
  9491. value = '';
  9492. needRemove = true;
  9493. }
  9494. else if (type === 'number') {
  9495. // e.g. <img :width="null">
  9496. value = 0;
  9497. needRemove = true;
  9498. }
  9499. }
  9500. // some properties perform value validation and throw,
  9501. // some properties has getter, no setter, will error in 'use strict'
  9502. // eg. <select :type="null"></select> <select :willValidate="null"></select>
  9503. try {
  9504. el[key] = value;
  9505. }
  9506. catch (e) {
  9507. // do not warn if value is auto-coerced from nullish values
  9508. if (!needRemove) {
  9509. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9510. `value ${value} is invalid.`, e);
  9511. }
  9512. }
  9513. needRemove && el.removeAttribute(key);
  9514. }
  9515. function addEventListener(el, event, handler, options) {
  9516. el.addEventListener(event, handler, options);
  9517. }
  9518. function removeEventListener(el, event, handler, options) {
  9519. el.removeEventListener(event, handler, options);
  9520. }
  9521. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9522. // vei = vue event invokers
  9523. const invokers = el._vei || (el._vei = {});
  9524. const existingInvoker = invokers[rawName];
  9525. if (nextValue && existingInvoker) {
  9526. // patch
  9527. existingInvoker.value = nextValue;
  9528. }
  9529. else {
  9530. const [name, options] = parseName(rawName);
  9531. if (nextValue) {
  9532. // add
  9533. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9534. addEventListener(el, name, invoker, options);
  9535. }
  9536. else if (existingInvoker) {
  9537. // remove
  9538. removeEventListener(el, name, existingInvoker, options);
  9539. invokers[rawName] = undefined;
  9540. }
  9541. }
  9542. }
  9543. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9544. function parseName(name) {
  9545. let options;
  9546. if (optionsModifierRE.test(name)) {
  9547. options = {};
  9548. let m;
  9549. while ((m = name.match(optionsModifierRE))) {
  9550. name = name.slice(0, name.length - m[0].length);
  9551. options[m[0].toLowerCase()] = true;
  9552. }
  9553. }
  9554. const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2));
  9555. return [event, options];
  9556. }
  9557. // To avoid the overhead of repeatedly calling Date.now(), we cache
  9558. // and use the same timestamp for all event listeners attached in the same tick.
  9559. let cachedNow = 0;
  9560. const p = /*#__PURE__*/ Promise.resolve();
  9561. const getNow = () => cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()));
  9562. function createInvoker(initialValue, instance) {
  9563. const invoker = (e) => {
  9564. // async edge case vuejs/vue#6566
  9565. // inner click event triggers patch, event handler
  9566. // attached to outer element during patch, and triggered again. This
  9567. // happens because browsers fire microtask ticks between event propagation.
  9568. // this no longer happens for templates in Vue 3, but could still be
  9569. // theoretically possible for hand-written render functions.
  9570. // the solution: we save the timestamp when a handler is attached,
  9571. // and also attach the timestamp to any event that was handled by vue
  9572. // for the first time (to avoid inconsistent event timestamp implementations
  9573. // or events fired from iframes, e.g. #2513)
  9574. // The handler would only fire if the event passed to it was fired
  9575. // AFTER it was attached.
  9576. if (!e._vts) {
  9577. e._vts = Date.now();
  9578. }
  9579. else if (e._vts <= invoker.attached) {
  9580. return;
  9581. }
  9582. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
  9583. };
  9584. invoker.value = initialValue;
  9585. invoker.attached = getNow();
  9586. return invoker;
  9587. }
  9588. function patchStopImmediatePropagation(e, value) {
  9589. if (isArray(value)) {
  9590. const originalStop = e.stopImmediatePropagation;
  9591. e.stopImmediatePropagation = () => {
  9592. originalStop.call(e);
  9593. e._stopped = true;
  9594. };
  9595. return value.map(fn => (e) => !e._stopped && fn && fn(e));
  9596. }
  9597. else {
  9598. return value;
  9599. }
  9600. }
  9601. const nativeOnRE = /^on[a-z]/;
  9602. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9603. if (key === 'class') {
  9604. patchClass(el, nextValue, isSVG);
  9605. }
  9606. else if (key === 'style') {
  9607. patchStyle(el, prevValue, nextValue);
  9608. }
  9609. else if (isOn(key)) {
  9610. // ignore v-model listeners
  9611. if (!isModelListener(key)) {
  9612. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9613. }
  9614. }
  9615. else if (key[0] === '.'
  9616. ? ((key = key.slice(1)), true)
  9617. : key[0] === '^'
  9618. ? ((key = key.slice(1)), false)
  9619. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9620. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9621. }
  9622. else {
  9623. // special case for <input v-model type="checkbox"> with
  9624. // :true-value & :false-value
  9625. // store value as dom properties since non-string values will be
  9626. // stringified.
  9627. if (key === 'true-value') {
  9628. el._trueValue = nextValue;
  9629. }
  9630. else if (key === 'false-value') {
  9631. el._falseValue = nextValue;
  9632. }
  9633. patchAttr(el, key, nextValue, isSVG);
  9634. }
  9635. };
  9636. function shouldSetAsProp(el, key, value, isSVG) {
  9637. if (isSVG) {
  9638. // most keys must be set as attribute on svg elements to work
  9639. // ...except innerHTML & textContent
  9640. if (key === 'innerHTML' || key === 'textContent') {
  9641. return true;
  9642. }
  9643. // or native onclick with function values
  9644. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9645. return true;
  9646. }
  9647. return false;
  9648. }
  9649. // these are enumerated attrs, however their corresponding DOM properties
  9650. // are actually booleans - this leads to setting it with a string "false"
  9651. // value leading it to be coerced to `true`, so we need to always treat
  9652. // them as attributes.
  9653. // Note that `contentEditable` doesn't have this problem: its DOM
  9654. // property is also enumerated string values.
  9655. if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
  9656. return false;
  9657. }
  9658. // #1787, #2840 form property on form elements is readonly and must be set as
  9659. // attribute.
  9660. if (key === 'form') {
  9661. return false;
  9662. }
  9663. // #1526 <input list> must be set as attribute
  9664. if (key === 'list' && el.tagName === 'INPUT') {
  9665. return false;
  9666. }
  9667. // #2766 <textarea type> must be set as attribute
  9668. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9669. return false;
  9670. }
  9671. // native onclick with string value, must be set as attribute
  9672. if (nativeOnRE.test(key) && isString(value)) {
  9673. return false;
  9674. }
  9675. return key in el;
  9676. }
  9677. function defineCustomElement(options, hydrate) {
  9678. const Comp = defineComponent(options);
  9679. class VueCustomElement extends VueElement {
  9680. constructor(initialProps) {
  9681. super(Comp, initialProps, hydrate);
  9682. }
  9683. }
  9684. VueCustomElement.def = Comp;
  9685. return VueCustomElement;
  9686. }
  9687. const defineSSRCustomElement = ((options) => {
  9688. // @ts-ignore
  9689. return defineCustomElement(options, hydrate);
  9690. });
  9691. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9692. });
  9693. class VueElement extends BaseClass {
  9694. constructor(_def, _props = {}, hydrate) {
  9695. super();
  9696. this._def = _def;
  9697. this._props = _props;
  9698. /**
  9699. * @internal
  9700. */
  9701. this._instance = null;
  9702. this._connected = false;
  9703. this._resolved = false;
  9704. this._numberProps = null;
  9705. if (this.shadowRoot && hydrate) {
  9706. hydrate(this._createVNode(), this.shadowRoot);
  9707. }
  9708. else {
  9709. if (this.shadowRoot) {
  9710. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9711. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9712. }
  9713. this.attachShadow({ mode: 'open' });
  9714. if (!this._def.__asyncLoader) {
  9715. // for sync component defs we can immediately resolve props
  9716. this._resolveProps(this._def);
  9717. }
  9718. }
  9719. }
  9720. connectedCallback() {
  9721. this._connected = true;
  9722. if (!this._instance) {
  9723. if (this._resolved) {
  9724. this._update();
  9725. }
  9726. else {
  9727. this._resolveDef();
  9728. }
  9729. }
  9730. }
  9731. disconnectedCallback() {
  9732. this._connected = false;
  9733. nextTick(() => {
  9734. if (!this._connected) {
  9735. render(null, this.shadowRoot);
  9736. this._instance = null;
  9737. }
  9738. });
  9739. }
  9740. /**
  9741. * resolve inner component definition (handle possible async component)
  9742. */
  9743. _resolveDef() {
  9744. this._resolved = true;
  9745. // set initial attrs
  9746. for (let i = 0; i < this.attributes.length; i++) {
  9747. this._setAttr(this.attributes[i].name);
  9748. }
  9749. // watch future attr changes
  9750. new MutationObserver(mutations => {
  9751. for (const m of mutations) {
  9752. this._setAttr(m.attributeName);
  9753. }
  9754. }).observe(this, { attributes: true });
  9755. const resolve = (def, isAsync = false) => {
  9756. const { props, styles } = def;
  9757. // cast Number-type props set before resolve
  9758. let numberProps;
  9759. if (props && !isArray(props)) {
  9760. for (const key in props) {
  9761. const opt = props[key];
  9762. if (opt === Number || (opt && opt.type === Number)) {
  9763. if (key in this._props) {
  9764. this._props[key] = toNumber(this._props[key]);
  9765. }
  9766. (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
  9767. }
  9768. }
  9769. }
  9770. this._numberProps = numberProps;
  9771. if (isAsync) {
  9772. // defining getter/setters on prototype
  9773. // for sync defs, this already happened in the constructor
  9774. this._resolveProps(def);
  9775. }
  9776. // apply CSS
  9777. this._applyStyles(styles);
  9778. // initial render
  9779. this._update();
  9780. };
  9781. const asyncDef = this._def.__asyncLoader;
  9782. if (asyncDef) {
  9783. asyncDef().then(def => resolve(def, true));
  9784. }
  9785. else {
  9786. resolve(this._def);
  9787. }
  9788. }
  9789. _resolveProps(def) {
  9790. const { props } = def;
  9791. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  9792. // check if there are props set pre-upgrade or connect
  9793. for (const key of Object.keys(this)) {
  9794. if (key[0] !== '_' && declaredPropKeys.includes(key)) {
  9795. this._setProp(key, this[key], true, false);
  9796. }
  9797. }
  9798. // defining getter/setters on prototype
  9799. for (const key of declaredPropKeys.map(camelize)) {
  9800. Object.defineProperty(this, key, {
  9801. get() {
  9802. return this._getProp(key);
  9803. },
  9804. set(val) {
  9805. this._setProp(key, val);
  9806. }
  9807. });
  9808. }
  9809. }
  9810. _setAttr(key) {
  9811. let value = this.getAttribute(key);
  9812. const camelKey = camelize(key);
  9813. if (this._numberProps && this._numberProps[camelKey]) {
  9814. value = toNumber(value);
  9815. }
  9816. this._setProp(camelKey, value, false);
  9817. }
  9818. /**
  9819. * @internal
  9820. */
  9821. _getProp(key) {
  9822. return this._props[key];
  9823. }
  9824. /**
  9825. * @internal
  9826. */
  9827. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9828. if (val !== this._props[key]) {
  9829. this._props[key] = val;
  9830. if (shouldUpdate && this._instance) {
  9831. this._update();
  9832. }
  9833. // reflect
  9834. if (shouldReflect) {
  9835. if (val === true) {
  9836. this.setAttribute(hyphenate(key), '');
  9837. }
  9838. else if (typeof val === 'string' || typeof val === 'number') {
  9839. this.setAttribute(hyphenate(key), val + '');
  9840. }
  9841. else if (!val) {
  9842. this.removeAttribute(hyphenate(key));
  9843. }
  9844. }
  9845. }
  9846. }
  9847. _update() {
  9848. render(this._createVNode(), this.shadowRoot);
  9849. }
  9850. _createVNode() {
  9851. const vnode = createVNode(this._def, extend({}, this._props));
  9852. if (!this._instance) {
  9853. vnode.ce = instance => {
  9854. this._instance = instance;
  9855. instance.isCE = true;
  9856. // HMR
  9857. {
  9858. instance.ceReload = newStyles => {
  9859. // always reset styles
  9860. if (this._styles) {
  9861. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9862. this._styles.length = 0;
  9863. }
  9864. this._applyStyles(newStyles);
  9865. this._instance = null;
  9866. this._update();
  9867. };
  9868. }
  9869. const dispatch = (event, args) => {
  9870. this.dispatchEvent(new CustomEvent(event, {
  9871. detail: args
  9872. }));
  9873. };
  9874. // intercept emit
  9875. instance.emit = (event, ...args) => {
  9876. // dispatch both the raw and hyphenated versions of an event
  9877. // to match Vue behavior
  9878. dispatch(event, args);
  9879. if (hyphenate(event) !== event) {
  9880. dispatch(hyphenate(event), args);
  9881. }
  9882. };
  9883. // locate nearest Vue custom element parent for provide/inject
  9884. let parent = this;
  9885. while ((parent =
  9886. parent && (parent.parentNode || parent.host))) {
  9887. if (parent instanceof VueElement) {
  9888. instance.parent = parent._instance;
  9889. instance.provides = parent._instance.provides;
  9890. break;
  9891. }
  9892. }
  9893. };
  9894. }
  9895. return vnode;
  9896. }
  9897. _applyStyles(styles) {
  9898. if (styles) {
  9899. styles.forEach(css => {
  9900. const s = document.createElement('style');
  9901. s.textContent = css;
  9902. this.shadowRoot.appendChild(s);
  9903. // record for HMR
  9904. {
  9905. (this._styles || (this._styles = [])).push(s);
  9906. }
  9907. });
  9908. }
  9909. }
  9910. }
  9911. function useCssModule(name = '$style') {
  9912. /* istanbul ignore else */
  9913. {
  9914. const instance = getCurrentInstance();
  9915. if (!instance) {
  9916. warn$1(`useCssModule must be called inside setup()`);
  9917. return EMPTY_OBJ;
  9918. }
  9919. const modules = instance.type.__cssModules;
  9920. if (!modules) {
  9921. warn$1(`Current instance does not have CSS modules injected.`);
  9922. return EMPTY_OBJ;
  9923. }
  9924. const mod = modules[name];
  9925. if (!mod) {
  9926. warn$1(`Current instance does not have CSS module named "${name}".`);
  9927. return EMPTY_OBJ;
  9928. }
  9929. return mod;
  9930. }
  9931. }
  9932. /**
  9933. * Runtime helper for SFC's CSS variable injection feature.
  9934. * @private
  9935. */
  9936. function useCssVars(getter) {
  9937. const instance = getCurrentInstance();
  9938. /* istanbul ignore next */
  9939. if (!instance) {
  9940. warn$1(`useCssVars is called without current active component instance.`);
  9941. return;
  9942. }
  9943. const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
  9944. Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
  9945. });
  9946. const setVars = () => {
  9947. const vars = getter(instance.proxy);
  9948. setVarsOnVNode(instance.subTree, vars);
  9949. updateTeleports(vars);
  9950. };
  9951. watchPostEffect(setVars);
  9952. onMounted(() => {
  9953. const ob = new MutationObserver(setVars);
  9954. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9955. onUnmounted(() => ob.disconnect());
  9956. });
  9957. }
  9958. function setVarsOnVNode(vnode, vars) {
  9959. if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
  9960. const suspense = vnode.suspense;
  9961. vnode = suspense.activeBranch;
  9962. if (suspense.pendingBranch && !suspense.isHydrating) {
  9963. suspense.effects.push(() => {
  9964. setVarsOnVNode(suspense.activeBranch, vars);
  9965. });
  9966. }
  9967. }
  9968. // drill down HOCs until it's a non-component vnode
  9969. while (vnode.component) {
  9970. vnode = vnode.component.subTree;
  9971. }
  9972. if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && vnode.el) {
  9973. setVarsOnNode(vnode.el, vars);
  9974. }
  9975. else if (vnode.type === Fragment) {
  9976. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9977. }
  9978. else if (vnode.type === Static) {
  9979. let { el, anchor } = vnode;
  9980. while (el) {
  9981. setVarsOnNode(el, vars);
  9982. if (el === anchor)
  9983. break;
  9984. el = el.nextSibling;
  9985. }
  9986. }
  9987. }
  9988. function setVarsOnNode(el, vars) {
  9989. if (el.nodeType === 1) {
  9990. const style = el.style;
  9991. for (const key in vars) {
  9992. style.setProperty(`--${key}`, vars[key]);
  9993. }
  9994. }
  9995. }
  9996. const TRANSITION = 'transition';
  9997. const ANIMATION = 'animation';
  9998. // DOM Transition is a higher-order-component based on the platform-agnostic
  9999. // base Transition component, with DOM-specific logic.
  10000. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  10001. Transition.displayName = 'Transition';
  10002. const DOMTransitionPropsValidators = {
  10003. name: String,
  10004. type: String,
  10005. css: {
  10006. type: Boolean,
  10007. default: true
  10008. },
  10009. duration: [String, Number, Object],
  10010. enterFromClass: String,
  10011. enterActiveClass: String,
  10012. enterToClass: String,
  10013. appearFromClass: String,
  10014. appearActiveClass: String,
  10015. appearToClass: String,
  10016. leaveFromClass: String,
  10017. leaveActiveClass: String,
  10018. leaveToClass: String
  10019. };
  10020. const TransitionPropsValidators = (Transition.props =
  10021. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  10022. /**
  10023. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  10024. * with custom HOCs.
  10025. */
  10026. const callHook$1 = (hook, args = []) => {
  10027. if (isArray(hook)) {
  10028. hook.forEach(h => h(...args));
  10029. }
  10030. else if (hook) {
  10031. hook(...args);
  10032. }
  10033. };
  10034. /**
  10035. * Check if a hook expects a callback (2nd arg), which means the user
  10036. * intends to explicitly control the end of the transition.
  10037. */
  10038. const hasExplicitCallback = (hook) => {
  10039. return hook
  10040. ? isArray(hook)
  10041. ? hook.some(h => h.length > 1)
  10042. : hook.length > 1
  10043. : false;
  10044. };
  10045. function resolveTransitionProps(rawProps) {
  10046. const baseProps = {};
  10047. for (const key in rawProps) {
  10048. if (!(key in DOMTransitionPropsValidators)) {
  10049. baseProps[key] = rawProps[key];
  10050. }
  10051. }
  10052. if (rawProps.css === false) {
  10053. return baseProps;
  10054. }
  10055. const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
  10056. const durations = normalizeDuration(duration);
  10057. const enterDuration = durations && durations[0];
  10058. const leaveDuration = durations && durations[1];
  10059. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  10060. const finishEnter = (el, isAppear, done) => {
  10061. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  10062. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  10063. done && done();
  10064. };
  10065. const finishLeave = (el, done) => {
  10066. el._isLeaving = false;
  10067. removeTransitionClass(el, leaveFromClass);
  10068. removeTransitionClass(el, leaveToClass);
  10069. removeTransitionClass(el, leaveActiveClass);
  10070. done && done();
  10071. };
  10072. const makeEnterHook = (isAppear) => {
  10073. return (el, done) => {
  10074. const hook = isAppear ? onAppear : onEnter;
  10075. const resolve = () => finishEnter(el, isAppear, done);
  10076. callHook$1(hook, [el, resolve]);
  10077. nextFrame(() => {
  10078. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  10079. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  10080. if (!hasExplicitCallback(hook)) {
  10081. whenTransitionEnds(el, type, enterDuration, resolve);
  10082. }
  10083. });
  10084. };
  10085. };
  10086. return extend(baseProps, {
  10087. onBeforeEnter(el) {
  10088. callHook$1(onBeforeEnter, [el]);
  10089. addTransitionClass(el, enterFromClass);
  10090. addTransitionClass(el, enterActiveClass);
  10091. },
  10092. onBeforeAppear(el) {
  10093. callHook$1(onBeforeAppear, [el]);
  10094. addTransitionClass(el, appearFromClass);
  10095. addTransitionClass(el, appearActiveClass);
  10096. },
  10097. onEnter: makeEnterHook(false),
  10098. onAppear: makeEnterHook(true),
  10099. onLeave(el, done) {
  10100. el._isLeaving = true;
  10101. const resolve = () => finishLeave(el, done);
  10102. addTransitionClass(el, leaveFromClass);
  10103. // force reflow so *-leave-from classes immediately take effect (#2593)
  10104. forceReflow();
  10105. addTransitionClass(el, leaveActiveClass);
  10106. nextFrame(() => {
  10107. if (!el._isLeaving) {
  10108. // cancelled
  10109. return;
  10110. }
  10111. removeTransitionClass(el, leaveFromClass);
  10112. addTransitionClass(el, leaveToClass);
  10113. if (!hasExplicitCallback(onLeave)) {
  10114. whenTransitionEnds(el, type, leaveDuration, resolve);
  10115. }
  10116. });
  10117. callHook$1(onLeave, [el, resolve]);
  10118. },
  10119. onEnterCancelled(el) {
  10120. finishEnter(el, false);
  10121. callHook$1(onEnterCancelled, [el]);
  10122. },
  10123. onAppearCancelled(el) {
  10124. finishEnter(el, true);
  10125. callHook$1(onAppearCancelled, [el]);
  10126. },
  10127. onLeaveCancelled(el) {
  10128. finishLeave(el);
  10129. callHook$1(onLeaveCancelled, [el]);
  10130. }
  10131. });
  10132. }
  10133. function normalizeDuration(duration) {
  10134. if (duration == null) {
  10135. return null;
  10136. }
  10137. else if (isObject(duration)) {
  10138. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  10139. }
  10140. else {
  10141. const n = NumberOf(duration);
  10142. return [n, n];
  10143. }
  10144. }
  10145. function NumberOf(val) {
  10146. const res = toNumber(val);
  10147. validateDuration(res);
  10148. return res;
  10149. }
  10150. function validateDuration(val) {
  10151. if (typeof val !== 'number') {
  10152. warn$1(`<transition> explicit duration is not a valid number - ` +
  10153. `got ${JSON.stringify(val)}.`);
  10154. }
  10155. else if (isNaN(val)) {
  10156. warn$1(`<transition> explicit duration is NaN - ` +
  10157. 'the duration expression might be incorrect.');
  10158. }
  10159. }
  10160. function addTransitionClass(el, cls) {
  10161. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  10162. (el._vtc ||
  10163. (el._vtc = new Set())).add(cls);
  10164. }
  10165. function removeTransitionClass(el, cls) {
  10166. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  10167. const { _vtc } = el;
  10168. if (_vtc) {
  10169. _vtc.delete(cls);
  10170. if (!_vtc.size) {
  10171. el._vtc = undefined;
  10172. }
  10173. }
  10174. }
  10175. function nextFrame(cb) {
  10176. requestAnimationFrame(() => {
  10177. requestAnimationFrame(cb);
  10178. });
  10179. }
  10180. let endId = 0;
  10181. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  10182. const id = (el._endId = ++endId);
  10183. const resolveIfNotStale = () => {
  10184. if (id === el._endId) {
  10185. resolve();
  10186. }
  10187. };
  10188. if (explicitTimeout) {
  10189. return setTimeout(resolveIfNotStale, explicitTimeout);
  10190. }
  10191. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  10192. if (!type) {
  10193. return resolve();
  10194. }
  10195. const endEvent = type + 'end';
  10196. let ended = 0;
  10197. const end = () => {
  10198. el.removeEventListener(endEvent, onEnd);
  10199. resolveIfNotStale();
  10200. };
  10201. const onEnd = (e) => {
  10202. if (e.target === el && ++ended >= propCount) {
  10203. end();
  10204. }
  10205. };
  10206. setTimeout(() => {
  10207. if (ended < propCount) {
  10208. end();
  10209. }
  10210. }, timeout + 1);
  10211. el.addEventListener(endEvent, onEnd);
  10212. }
  10213. function getTransitionInfo(el, expectedType) {
  10214. const styles = window.getComputedStyle(el);
  10215. // JSDOM may return undefined for transition properties
  10216. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  10217. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  10218. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  10219. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  10220. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  10221. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  10222. const animationTimeout = getTimeout(animationDelays, animationDurations);
  10223. let type = null;
  10224. let timeout = 0;
  10225. let propCount = 0;
  10226. /* istanbul ignore if */
  10227. if (expectedType === TRANSITION) {
  10228. if (transitionTimeout > 0) {
  10229. type = TRANSITION;
  10230. timeout = transitionTimeout;
  10231. propCount = transitionDurations.length;
  10232. }
  10233. }
  10234. else if (expectedType === ANIMATION) {
  10235. if (animationTimeout > 0) {
  10236. type = ANIMATION;
  10237. timeout = animationTimeout;
  10238. propCount = animationDurations.length;
  10239. }
  10240. }
  10241. else {
  10242. timeout = Math.max(transitionTimeout, animationTimeout);
  10243. type =
  10244. timeout > 0
  10245. ? transitionTimeout > animationTimeout
  10246. ? TRANSITION
  10247. : ANIMATION
  10248. : null;
  10249. propCount = type
  10250. ? type === TRANSITION
  10251. ? transitionDurations.length
  10252. : animationDurations.length
  10253. : 0;
  10254. }
  10255. const hasTransform = type === TRANSITION &&
  10256. /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
  10257. return {
  10258. type,
  10259. timeout,
  10260. propCount,
  10261. hasTransform
  10262. };
  10263. }
  10264. function getTimeout(delays, durations) {
  10265. while (delays.length < durations.length) {
  10266. delays = delays.concat(delays);
  10267. }
  10268. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10269. }
  10270. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  10271. // numbers in a locale-dependent way, using a comma instead of a dot.
  10272. // If comma is not replaced with a dot, the input will be rounded down
  10273. // (i.e. acting as a floor function) causing unexpected behaviors
  10274. function toMs(s) {
  10275. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  10276. }
  10277. // synchronously force layout to put elements into a certain state
  10278. function forceReflow() {
  10279. return document.body.offsetHeight;
  10280. }
  10281. const positionMap = new WeakMap();
  10282. const newPositionMap = new WeakMap();
  10283. const TransitionGroupImpl = {
  10284. name: 'TransitionGroup',
  10285. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  10286. tag: String,
  10287. moveClass: String
  10288. }),
  10289. setup(props, { slots }) {
  10290. const instance = getCurrentInstance();
  10291. const state = useTransitionState();
  10292. let prevChildren;
  10293. let children;
  10294. onUpdated(() => {
  10295. // children is guaranteed to exist after initial render
  10296. if (!prevChildren.length) {
  10297. return;
  10298. }
  10299. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  10300. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  10301. return;
  10302. }
  10303. // we divide the work into three loops to avoid mixing DOM reads and writes
  10304. // in each iteration - which helps prevent layout thrashing.
  10305. prevChildren.forEach(callPendingCbs);
  10306. prevChildren.forEach(recordPosition);
  10307. const movedChildren = prevChildren.filter(applyTranslation);
  10308. // force reflow to put everything in position
  10309. forceReflow();
  10310. movedChildren.forEach(c => {
  10311. const el = c.el;
  10312. const style = el.style;
  10313. addTransitionClass(el, moveClass);
  10314. style.transform = style.webkitTransform = style.transitionDuration = '';
  10315. const cb = (el._moveCb = (e) => {
  10316. if (e && e.target !== el) {
  10317. return;
  10318. }
  10319. if (!e || /transform$/.test(e.propertyName)) {
  10320. el.removeEventListener('transitionend', cb);
  10321. el._moveCb = null;
  10322. removeTransitionClass(el, moveClass);
  10323. }
  10324. });
  10325. el.addEventListener('transitionend', cb);
  10326. });
  10327. });
  10328. return () => {
  10329. const rawProps = toRaw(props);
  10330. const cssTransitionProps = resolveTransitionProps(rawProps);
  10331. let tag = rawProps.tag || Fragment;
  10332. prevChildren = children;
  10333. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10334. for (let i = 0; i < children.length; i++) {
  10335. const child = children[i];
  10336. if (child.key != null) {
  10337. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10338. }
  10339. else {
  10340. warn$1(`<TransitionGroup> children must be keyed.`);
  10341. }
  10342. }
  10343. if (prevChildren) {
  10344. for (let i = 0; i < prevChildren.length; i++) {
  10345. const child = prevChildren[i];
  10346. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10347. positionMap.set(child, child.el.getBoundingClientRect());
  10348. }
  10349. }
  10350. return createVNode(tag, null, children);
  10351. };
  10352. }
  10353. };
  10354. const TransitionGroup = TransitionGroupImpl;
  10355. function callPendingCbs(c) {
  10356. const el = c.el;
  10357. if (el._moveCb) {
  10358. el._moveCb();
  10359. }
  10360. if (el._enterCb) {
  10361. el._enterCb();
  10362. }
  10363. }
  10364. function recordPosition(c) {
  10365. newPositionMap.set(c, c.el.getBoundingClientRect());
  10366. }
  10367. function applyTranslation(c) {
  10368. const oldPos = positionMap.get(c);
  10369. const newPos = newPositionMap.get(c);
  10370. const dx = oldPos.left - newPos.left;
  10371. const dy = oldPos.top - newPos.top;
  10372. if (dx || dy) {
  10373. const s = c.el.style;
  10374. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10375. s.transitionDuration = '0s';
  10376. return c;
  10377. }
  10378. }
  10379. function hasCSSTransform(el, root, moveClass) {
  10380. // Detect whether an element with the move class applied has
  10381. // CSS transitions. Since the element may be inside an entering
  10382. // transition at this very moment, we make a clone of it and remove
  10383. // all other transition classes applied to ensure only the move class
  10384. // is applied.
  10385. const clone = el.cloneNode();
  10386. if (el._vtc) {
  10387. el._vtc.forEach(cls => {
  10388. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10389. });
  10390. }
  10391. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10392. clone.style.display = 'none';
  10393. const container = (root.nodeType === 1 ? root : root.parentNode);
  10394. container.appendChild(clone);
  10395. const { hasTransform } = getTransitionInfo(clone);
  10396. container.removeChild(clone);
  10397. return hasTransform;
  10398. }
  10399. const getModelAssigner = (vnode) => {
  10400. const fn = vnode.props['onUpdate:modelValue'] ||
  10401. (false );
  10402. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10403. };
  10404. function onCompositionStart(e) {
  10405. e.target.composing = true;
  10406. }
  10407. function onCompositionEnd(e) {
  10408. const target = e.target;
  10409. if (target.composing) {
  10410. target.composing = false;
  10411. target.dispatchEvent(new Event('input'));
  10412. }
  10413. }
  10414. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10415. // be tree-shaken in case v-model is never used.
  10416. const vModelText = {
  10417. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10418. el._assign = getModelAssigner(vnode);
  10419. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10420. addEventListener(el, lazy ? 'change' : 'input', e => {
  10421. if (e.target.composing)
  10422. return;
  10423. let domValue = el.value;
  10424. if (trim) {
  10425. domValue = domValue.trim();
  10426. }
  10427. if (castToNumber) {
  10428. domValue = toNumber(domValue);
  10429. }
  10430. el._assign(domValue);
  10431. });
  10432. if (trim) {
  10433. addEventListener(el, 'change', () => {
  10434. el.value = el.value.trim();
  10435. });
  10436. }
  10437. if (!lazy) {
  10438. addEventListener(el, 'compositionstart', onCompositionStart);
  10439. addEventListener(el, 'compositionend', onCompositionEnd);
  10440. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10441. // switching focus before confirming composition choice
  10442. // this also fixes the issue where some browsers e.g. iOS Chrome
  10443. // fires "change" instead of "input" on autocomplete.
  10444. addEventListener(el, 'change', onCompositionEnd);
  10445. }
  10446. },
  10447. // set value on mounted so it's after min/max for type="range"
  10448. mounted(el, { value }) {
  10449. el.value = value == null ? '' : value;
  10450. },
  10451. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10452. el._assign = getModelAssigner(vnode);
  10453. // avoid clearing unresolved text. #2302
  10454. if (el.composing)
  10455. return;
  10456. if (document.activeElement === el && el.type !== 'range') {
  10457. if (lazy) {
  10458. return;
  10459. }
  10460. if (trim && el.value.trim() === value) {
  10461. return;
  10462. }
  10463. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10464. return;
  10465. }
  10466. }
  10467. const newValue = value == null ? '' : value;
  10468. if (el.value !== newValue) {
  10469. el.value = newValue;
  10470. }
  10471. }
  10472. };
  10473. const vModelCheckbox = {
  10474. // #4096 array checkboxes need to be deep traversed
  10475. deep: true,
  10476. created(el, _, vnode) {
  10477. el._assign = getModelAssigner(vnode);
  10478. addEventListener(el, 'change', () => {
  10479. const modelValue = el._modelValue;
  10480. const elementValue = getValue(el);
  10481. const checked = el.checked;
  10482. const assign = el._assign;
  10483. if (isArray(modelValue)) {
  10484. const index = looseIndexOf(modelValue, elementValue);
  10485. const found = index !== -1;
  10486. if (checked && !found) {
  10487. assign(modelValue.concat(elementValue));
  10488. }
  10489. else if (!checked && found) {
  10490. const filtered = [...modelValue];
  10491. filtered.splice(index, 1);
  10492. assign(filtered);
  10493. }
  10494. }
  10495. else if (isSet(modelValue)) {
  10496. const cloned = new Set(modelValue);
  10497. if (checked) {
  10498. cloned.add(elementValue);
  10499. }
  10500. else {
  10501. cloned.delete(elementValue);
  10502. }
  10503. assign(cloned);
  10504. }
  10505. else {
  10506. assign(getCheckboxValue(el, checked));
  10507. }
  10508. });
  10509. },
  10510. // set initial checked on mount to wait for true-value/false-value
  10511. mounted: setChecked,
  10512. beforeUpdate(el, binding, vnode) {
  10513. el._assign = getModelAssigner(vnode);
  10514. setChecked(el, binding, vnode);
  10515. }
  10516. };
  10517. function setChecked(el, { value, oldValue }, vnode) {
  10518. el._modelValue = value;
  10519. if (isArray(value)) {
  10520. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10521. }
  10522. else if (isSet(value)) {
  10523. el.checked = value.has(vnode.props.value);
  10524. }
  10525. else if (value !== oldValue) {
  10526. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10527. }
  10528. }
  10529. const vModelRadio = {
  10530. created(el, { value }, vnode) {
  10531. el.checked = looseEqual(value, vnode.props.value);
  10532. el._assign = getModelAssigner(vnode);
  10533. addEventListener(el, 'change', () => {
  10534. el._assign(getValue(el));
  10535. });
  10536. },
  10537. beforeUpdate(el, { value, oldValue }, vnode) {
  10538. el._assign = getModelAssigner(vnode);
  10539. if (value !== oldValue) {
  10540. el.checked = looseEqual(value, vnode.props.value);
  10541. }
  10542. }
  10543. };
  10544. const vModelSelect = {
  10545. // <select multiple> value need to be deep traversed
  10546. deep: true,
  10547. created(el, { value, modifiers: { number } }, vnode) {
  10548. const isSetModel = isSet(value);
  10549. addEventListener(el, 'change', () => {
  10550. const selectedVal = Array.prototype.filter
  10551. .call(el.options, (o) => o.selected)
  10552. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10553. el._assign(el.multiple
  10554. ? isSetModel
  10555. ? new Set(selectedVal)
  10556. : selectedVal
  10557. : selectedVal[0]);
  10558. });
  10559. el._assign = getModelAssigner(vnode);
  10560. },
  10561. // set value in mounted & updated because <select> relies on its children
  10562. // <option>s.
  10563. mounted(el, { value }) {
  10564. setSelected(el, value);
  10565. },
  10566. beforeUpdate(el, _binding, vnode) {
  10567. el._assign = getModelAssigner(vnode);
  10568. },
  10569. updated(el, { value }) {
  10570. setSelected(el, value);
  10571. }
  10572. };
  10573. function setSelected(el, value) {
  10574. const isMultiple = el.multiple;
  10575. if (isMultiple && !isArray(value) && !isSet(value)) {
  10576. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10577. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10578. return;
  10579. }
  10580. for (let i = 0, l = el.options.length; i < l; i++) {
  10581. const option = el.options[i];
  10582. const optionValue = getValue(option);
  10583. if (isMultiple) {
  10584. if (isArray(value)) {
  10585. option.selected = looseIndexOf(value, optionValue) > -1;
  10586. }
  10587. else {
  10588. option.selected = value.has(optionValue);
  10589. }
  10590. }
  10591. else {
  10592. if (looseEqual(getValue(option), value)) {
  10593. if (el.selectedIndex !== i)
  10594. el.selectedIndex = i;
  10595. return;
  10596. }
  10597. }
  10598. }
  10599. if (!isMultiple && el.selectedIndex !== -1) {
  10600. el.selectedIndex = -1;
  10601. }
  10602. }
  10603. // retrieve raw value set via :value bindings
  10604. function getValue(el) {
  10605. return '_value' in el ? el._value : el.value;
  10606. }
  10607. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10608. function getCheckboxValue(el, checked) {
  10609. const key = checked ? '_trueValue' : '_falseValue';
  10610. return key in el ? el[key] : checked;
  10611. }
  10612. const vModelDynamic = {
  10613. created(el, binding, vnode) {
  10614. callModelHook(el, binding, vnode, null, 'created');
  10615. },
  10616. mounted(el, binding, vnode) {
  10617. callModelHook(el, binding, vnode, null, 'mounted');
  10618. },
  10619. beforeUpdate(el, binding, vnode, prevVNode) {
  10620. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10621. },
  10622. updated(el, binding, vnode, prevVNode) {
  10623. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10624. }
  10625. };
  10626. function resolveDynamicModel(tagName, type) {
  10627. switch (tagName) {
  10628. case 'SELECT':
  10629. return vModelSelect;
  10630. case 'TEXTAREA':
  10631. return vModelText;
  10632. default:
  10633. switch (type) {
  10634. case 'checkbox':
  10635. return vModelCheckbox;
  10636. case 'radio':
  10637. return vModelRadio;
  10638. default:
  10639. return vModelText;
  10640. }
  10641. }
  10642. }
  10643. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10644. const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
  10645. const fn = modelToUse[hook];
  10646. fn && fn(el, binding, vnode, prevVNode);
  10647. }
  10648. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10649. const modifierGuards = {
  10650. stop: e => e.stopPropagation(),
  10651. prevent: e => e.preventDefault(),
  10652. self: e => e.target !== e.currentTarget,
  10653. ctrl: e => !e.ctrlKey,
  10654. shift: e => !e.shiftKey,
  10655. alt: e => !e.altKey,
  10656. meta: e => !e.metaKey,
  10657. left: e => 'button' in e && e.button !== 0,
  10658. middle: e => 'button' in e && e.button !== 1,
  10659. right: e => 'button' in e && e.button !== 2,
  10660. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10661. };
  10662. /**
  10663. * @private
  10664. */
  10665. const withModifiers = (fn, modifiers) => {
  10666. return (event, ...args) => {
  10667. for (let i = 0; i < modifiers.length; i++) {
  10668. const guard = modifierGuards[modifiers[i]];
  10669. if (guard && guard(event, modifiers))
  10670. return;
  10671. }
  10672. return fn(event, ...args);
  10673. };
  10674. };
  10675. // Kept for 2.x compat.
  10676. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10677. const keyNames = {
  10678. esc: 'escape',
  10679. space: ' ',
  10680. up: 'arrow-up',
  10681. left: 'arrow-left',
  10682. right: 'arrow-right',
  10683. down: 'arrow-down',
  10684. delete: 'backspace'
  10685. };
  10686. /**
  10687. * @private
  10688. */
  10689. const withKeys = (fn, modifiers) => {
  10690. return (event) => {
  10691. if (!('key' in event)) {
  10692. return;
  10693. }
  10694. const eventKey = hyphenate(event.key);
  10695. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10696. return fn(event);
  10697. }
  10698. };
  10699. };
  10700. const vShow = {
  10701. beforeMount(el, { value }, { transition }) {
  10702. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10703. if (transition && value) {
  10704. transition.beforeEnter(el);
  10705. }
  10706. else {
  10707. setDisplay(el, value);
  10708. }
  10709. },
  10710. mounted(el, { value }, { transition }) {
  10711. if (transition && value) {
  10712. transition.enter(el);
  10713. }
  10714. },
  10715. updated(el, { value, oldValue }, { transition }) {
  10716. if (!value === !oldValue)
  10717. return;
  10718. if (transition) {
  10719. if (value) {
  10720. transition.beforeEnter(el);
  10721. setDisplay(el, true);
  10722. transition.enter(el);
  10723. }
  10724. else {
  10725. transition.leave(el, () => {
  10726. setDisplay(el, false);
  10727. });
  10728. }
  10729. }
  10730. else {
  10731. setDisplay(el, value);
  10732. }
  10733. },
  10734. beforeUnmount(el, { value }) {
  10735. setDisplay(el, value);
  10736. }
  10737. };
  10738. function setDisplay(el, value) {
  10739. el.style.display = value ? el._vod : 'none';
  10740. }
  10741. const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
  10742. // lazy create the renderer - this makes core renderer logic tree-shakable
  10743. // in case the user only imports reactivity utilities from Vue.
  10744. let renderer;
  10745. let enabledHydration = false;
  10746. function ensureRenderer() {
  10747. return (renderer ||
  10748. (renderer = createRenderer(rendererOptions)));
  10749. }
  10750. function ensureHydrationRenderer() {
  10751. renderer = enabledHydration
  10752. ? renderer
  10753. : createHydrationRenderer(rendererOptions);
  10754. enabledHydration = true;
  10755. return renderer;
  10756. }
  10757. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10758. const render = ((...args) => {
  10759. ensureRenderer().render(...args);
  10760. });
  10761. const hydrate = ((...args) => {
  10762. ensureHydrationRenderer().hydrate(...args);
  10763. });
  10764. const createApp = ((...args) => {
  10765. const app = ensureRenderer().createApp(...args);
  10766. {
  10767. injectNativeTagCheck(app);
  10768. injectCompilerOptionsCheck(app);
  10769. }
  10770. const { mount } = app;
  10771. app.mount = (containerOrSelector) => {
  10772. const container = normalizeContainer(containerOrSelector);
  10773. if (!container)
  10774. return;
  10775. const component = app._component;
  10776. if (!isFunction(component) && !component.render && !component.template) {
  10777. // __UNSAFE__
  10778. // Reason: potential execution of JS expressions in in-DOM template.
  10779. // The user must make sure the in-DOM template is trusted. If it's
  10780. // rendered by the server, the template should not contain any user data.
  10781. component.template = container.innerHTML;
  10782. }
  10783. // clear content before mounting
  10784. container.innerHTML = '';
  10785. const proxy = mount(container, false, container instanceof SVGElement);
  10786. if (container instanceof Element) {
  10787. container.removeAttribute('v-cloak');
  10788. container.setAttribute('data-v-app', '');
  10789. }
  10790. return proxy;
  10791. };
  10792. return app;
  10793. });
  10794. const createSSRApp = ((...args) => {
  10795. const app = ensureHydrationRenderer().createApp(...args);
  10796. {
  10797. injectNativeTagCheck(app);
  10798. injectCompilerOptionsCheck(app);
  10799. }
  10800. const { mount } = app;
  10801. app.mount = (containerOrSelector) => {
  10802. const container = normalizeContainer(containerOrSelector);
  10803. if (container) {
  10804. return mount(container, true, container instanceof SVGElement);
  10805. }
  10806. };
  10807. return app;
  10808. });
  10809. function injectNativeTagCheck(app) {
  10810. // Inject `isNativeTag`
  10811. // this is used for component name validation (dev only)
  10812. Object.defineProperty(app.config, 'isNativeTag', {
  10813. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10814. writable: false
  10815. });
  10816. }
  10817. // dev only
  10818. function injectCompilerOptionsCheck(app) {
  10819. if (isRuntimeOnly()) {
  10820. const isCustomElement = app.config.isCustomElement;
  10821. Object.defineProperty(app.config, 'isCustomElement', {
  10822. get() {
  10823. return isCustomElement;
  10824. },
  10825. set() {
  10826. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10827. `\`compilerOptions.isCustomElement\` instead.`);
  10828. }
  10829. });
  10830. const compilerOptions = app.config.compilerOptions;
  10831. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10832. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10833. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10834. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10835. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10836. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10837. `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
  10838. Object.defineProperty(app.config, 'compilerOptions', {
  10839. get() {
  10840. warn$1(msg);
  10841. return compilerOptions;
  10842. },
  10843. set() {
  10844. warn$1(msg);
  10845. }
  10846. });
  10847. }
  10848. }
  10849. function normalizeContainer(container) {
  10850. if (isString(container)) {
  10851. const res = document.querySelector(container);
  10852. if (!res) {
  10853. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10854. }
  10855. return res;
  10856. }
  10857. if (window.ShadowRoot &&
  10858. container instanceof window.ShadowRoot &&
  10859. container.mode === 'closed') {
  10860. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10861. }
  10862. return container;
  10863. }
  10864. /**
  10865. * @internal
  10866. */
  10867. const initDirectivesForSSR = NOOP;
  10868. export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, computed$1 as computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };