runtime-core.cjs.js 261 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var reactivity = require('@vue/reactivity');
  4. var shared = require('@vue/shared');
  5. const stack = [];
  6. function pushWarningContext(vnode) {
  7. stack.push(vnode);
  8. }
  9. function popWarningContext() {
  10. stack.pop();
  11. }
  12. function warn(msg, ...args) {
  13. // avoid props formatting or warn handler tracking deps that might be mutated
  14. // during patch, leading to infinite recursion.
  15. reactivity.pauseTracking();
  16. const instance = stack.length ? stack[stack.length - 1].component : null;
  17. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  18. const trace = getComponentTrace();
  19. if (appWarnHandler) {
  20. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  21. msg + args.join(''),
  22. instance && instance.proxy,
  23. trace
  24. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  25. .join('\n'),
  26. trace
  27. ]);
  28. }
  29. else {
  30. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  31. /* istanbul ignore if */
  32. if (trace.length &&
  33. // avoid spamming console during tests
  34. !false) {
  35. warnArgs.push(`\n`, ...formatTrace(trace));
  36. }
  37. console.warn(...warnArgs);
  38. }
  39. reactivity.resetTracking();
  40. }
  41. function getComponentTrace() {
  42. let currentVNode = stack[stack.length - 1];
  43. if (!currentVNode) {
  44. return [];
  45. }
  46. // we can't just use the stack because it will be incomplete during updates
  47. // that did not start from the root. Re-construct the parent chain using
  48. // instance parent pointers.
  49. const normalizedStack = [];
  50. while (currentVNode) {
  51. const last = normalizedStack[0];
  52. if (last && last.vnode === currentVNode) {
  53. last.recurseCount++;
  54. }
  55. else {
  56. normalizedStack.push({
  57. vnode: currentVNode,
  58. recurseCount: 0
  59. });
  60. }
  61. const parentInstance = currentVNode.component && currentVNode.component.parent;
  62. currentVNode = parentInstance && parentInstance.vnode;
  63. }
  64. return normalizedStack;
  65. }
  66. /* istanbul ignore next */
  67. function formatTrace(trace) {
  68. const logs = [];
  69. trace.forEach((entry, i) => {
  70. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  71. });
  72. return logs;
  73. }
  74. function formatTraceEntry({ vnode, recurseCount }) {
  75. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  76. const isRoot = vnode.component ? vnode.component.parent == null : false;
  77. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  78. const close = `>` + postfix;
  79. return vnode.props
  80. ? [open, ...formatProps(vnode.props), close]
  81. : [open + close];
  82. }
  83. /* istanbul ignore next */
  84. function formatProps(props) {
  85. const res = [];
  86. const keys = Object.keys(props);
  87. keys.slice(0, 3).forEach(key => {
  88. res.push(...formatProp(key, props[key]));
  89. });
  90. if (keys.length > 3) {
  91. res.push(` ...`);
  92. }
  93. return res;
  94. }
  95. /* istanbul ignore next */
  96. function formatProp(key, value, raw) {
  97. if (shared.isString(value)) {
  98. value = JSON.stringify(value);
  99. return raw ? value : [`${key}=${value}`];
  100. }
  101. else if (typeof value === 'number' ||
  102. typeof value === 'boolean' ||
  103. value == null) {
  104. return raw ? value : [`${key}=${value}`];
  105. }
  106. else if (reactivity.isRef(value)) {
  107. value = formatProp(key, reactivity.toRaw(value.value), true);
  108. return raw ? value : [`${key}=Ref<`, value, `>`];
  109. }
  110. else if (shared.isFunction(value)) {
  111. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  112. }
  113. else {
  114. value = reactivity.toRaw(value);
  115. return raw ? value : [`${key}=`, value];
  116. }
  117. }
  118. const ErrorTypeStrings = {
  119. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  120. ["c" /* CREATED */]: 'created hook',
  121. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  122. ["m" /* MOUNTED */]: 'mounted hook',
  123. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  124. ["u" /* UPDATED */]: 'updated',
  125. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  126. ["um" /* UNMOUNTED */]: 'unmounted hook',
  127. ["a" /* ACTIVATED */]: 'activated hook',
  128. ["da" /* DEACTIVATED */]: 'deactivated hook',
  129. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  130. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  131. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  132. [0 /* SETUP_FUNCTION */]: 'setup function',
  133. [1 /* RENDER_FUNCTION */]: 'render function',
  134. [2 /* WATCH_GETTER */]: 'watcher getter',
  135. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  136. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  137. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  138. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  139. [7 /* VNODE_HOOK */]: 'vnode hook',
  140. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  141. [9 /* TRANSITION_HOOK */]: 'transition hook',
  142. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  143. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  144. [12 /* FUNCTION_REF */]: 'ref function',
  145. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  146. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  147. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
  148. };
  149. function callWithErrorHandling(fn, instance, type, args) {
  150. let res;
  151. try {
  152. res = args ? fn(...args) : fn();
  153. }
  154. catch (err) {
  155. handleError(err, instance, type);
  156. }
  157. return res;
  158. }
  159. function callWithAsyncErrorHandling(fn, instance, type, args) {
  160. if (shared.isFunction(fn)) {
  161. const res = callWithErrorHandling(fn, instance, type, args);
  162. if (res && shared.isPromise(res)) {
  163. res.catch(err => {
  164. handleError(err, instance, type);
  165. });
  166. }
  167. return res;
  168. }
  169. const values = [];
  170. for (let i = 0; i < fn.length; i++) {
  171. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  172. }
  173. return values;
  174. }
  175. function handleError(err, instance, type, throwInDev = true) {
  176. const contextVNode = instance ? instance.vnode : null;
  177. if (instance) {
  178. let cur = instance.parent;
  179. // the exposed instance is the render proxy to keep it consistent with 2.x
  180. const exposedInstance = instance.proxy;
  181. // in production the hook receives only the error code
  182. const errorInfo = ErrorTypeStrings[type] ;
  183. while (cur) {
  184. const errorCapturedHooks = cur.ec;
  185. if (errorCapturedHooks) {
  186. for (let i = 0; i < errorCapturedHooks.length; i++) {
  187. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  188. return;
  189. }
  190. }
  191. }
  192. cur = cur.parent;
  193. }
  194. // app-level handling
  195. const appErrorHandler = instance.appContext.config.errorHandler;
  196. if (appErrorHandler) {
  197. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  198. return;
  199. }
  200. }
  201. logError(err, type, contextVNode, throwInDev);
  202. }
  203. function logError(err, type, contextVNode, throwInDev = true) {
  204. {
  205. const info = ErrorTypeStrings[type];
  206. if (contextVNode) {
  207. pushWarningContext(contextVNode);
  208. }
  209. warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  210. if (contextVNode) {
  211. popWarningContext();
  212. }
  213. // crash in dev by default so it's more noticeable
  214. if (throwInDev) {
  215. throw err;
  216. }
  217. else {
  218. console.error(err);
  219. }
  220. }
  221. }
  222. let isFlushing = false;
  223. let isFlushPending = false;
  224. const queue = [];
  225. let flushIndex = 0;
  226. const pendingPreFlushCbs = [];
  227. let activePreFlushCbs = null;
  228. let preFlushIndex = 0;
  229. const pendingPostFlushCbs = [];
  230. let activePostFlushCbs = null;
  231. let postFlushIndex = 0;
  232. const resolvedPromise = Promise.resolve();
  233. let currentFlushPromise = null;
  234. let currentPreFlushParentJob = null;
  235. const RECURSION_LIMIT = 100;
  236. function nextTick(fn) {
  237. const p = currentFlushPromise || resolvedPromise;
  238. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  239. }
  240. function queueJob(job) {
  241. // the dedupe search uses the startIndex argument of Array.includes()
  242. // by default the search index includes the current job that is being run
  243. // so it cannot recursively trigger itself again.
  244. // if the job is a watch() callback, the search will start with a +1 index to
  245. // allow it recursively trigger itself - it is the user's responsibility to
  246. // ensure it doesn't end up in an infinite loop.
  247. if ((!queue.length ||
  248. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  249. job !== currentPreFlushParentJob) {
  250. queue.push(job);
  251. queueFlush();
  252. }
  253. }
  254. function queueFlush() {
  255. if (!isFlushing && !isFlushPending) {
  256. isFlushPending = true;
  257. currentFlushPromise = resolvedPromise.then(flushJobs);
  258. }
  259. }
  260. function invalidateJob(job) {
  261. const i = queue.indexOf(job);
  262. if (i > -1) {
  263. queue.splice(i, 1);
  264. }
  265. }
  266. function queueCb(cb, activeQueue, pendingQueue, index) {
  267. if (!shared.isArray(cb)) {
  268. if (!activeQueue ||
  269. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  270. pendingQueue.push(cb);
  271. }
  272. }
  273. else {
  274. // if cb is an array, it is a component lifecycle hook which can only be
  275. // triggered by a job, which is already deduped in the main queue, so
  276. // we can skip duplicate check here to improve perf
  277. pendingQueue.push(...cb);
  278. }
  279. queueFlush();
  280. }
  281. function queuePreFlushCb(cb) {
  282. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  283. }
  284. function queuePostFlushCb(cb) {
  285. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  286. }
  287. function flushPreFlushCbs(seen, parentJob = null) {
  288. if (pendingPreFlushCbs.length) {
  289. currentPreFlushParentJob = parentJob;
  290. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  291. pendingPreFlushCbs.length = 0;
  292. {
  293. seen = seen || new Map();
  294. }
  295. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  296. {
  297. checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex]);
  298. }
  299. activePreFlushCbs[preFlushIndex]();
  300. }
  301. activePreFlushCbs = null;
  302. preFlushIndex = 0;
  303. currentPreFlushParentJob = null;
  304. // recursively flush until it drains
  305. flushPreFlushCbs(seen, parentJob);
  306. }
  307. }
  308. function flushPostFlushCbs(seen) {
  309. if (pendingPostFlushCbs.length) {
  310. const deduped = [...new Set(pendingPostFlushCbs)];
  311. pendingPostFlushCbs.length = 0;
  312. // #1947 already has active queue, nested flushPostFlushCbs call
  313. if (activePostFlushCbs) {
  314. activePostFlushCbs.push(...deduped);
  315. return;
  316. }
  317. activePostFlushCbs = deduped;
  318. {
  319. seen = seen || new Map();
  320. }
  321. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  322. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  323. {
  324. checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]);
  325. }
  326. activePostFlushCbs[postFlushIndex]();
  327. }
  328. activePostFlushCbs = null;
  329. postFlushIndex = 0;
  330. }
  331. }
  332. const getId = (job) => job.id == null ? Infinity : job.id;
  333. function flushJobs(seen) {
  334. isFlushPending = false;
  335. isFlushing = true;
  336. {
  337. seen = seen || new Map();
  338. }
  339. flushPreFlushCbs(seen);
  340. // Sort queue before flush.
  341. // This ensures that:
  342. // 1. Components are updated from parent to child. (because parent is always
  343. // created before the child so its render effect will have smaller
  344. // priority number)
  345. // 2. If a component is unmounted during a parent component's update,
  346. // its update can be skipped.
  347. queue.sort((a, b) => getId(a) - getId(b));
  348. try {
  349. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  350. const job = queue[flushIndex];
  351. if (job) {
  352. if (true) {
  353. checkRecursiveUpdates(seen, job);
  354. }
  355. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  356. }
  357. }
  358. }
  359. finally {
  360. flushIndex = 0;
  361. queue.length = 0;
  362. flushPostFlushCbs(seen);
  363. isFlushing = false;
  364. currentFlushPromise = null;
  365. // some postFlushCb queued jobs!
  366. // keep flushing until it drains.
  367. if (queue.length || pendingPostFlushCbs.length) {
  368. flushJobs(seen);
  369. }
  370. }
  371. }
  372. function checkRecursiveUpdates(seen, fn) {
  373. if (!seen.has(fn)) {
  374. seen.set(fn, 1);
  375. }
  376. else {
  377. const count = seen.get(fn);
  378. if (count > RECURSION_LIMIT) {
  379. throw new Error(`Maximum recursive updates exceeded. ` +
  380. `This means you have a reactive effect that is mutating its own ` +
  381. `dependencies and thus recursively triggering itself. Possible sources ` +
  382. `include component template, render function, updated hook or ` +
  383. `watcher source function.`);
  384. }
  385. else {
  386. seen.set(fn, count + 1);
  387. }
  388. }
  389. }
  390. /* eslint-disable no-restricted-globals */
  391. let isHmrUpdating = false;
  392. const hmrDirtyComponents = new Set();
  393. // Expose the HMR runtime on the global object
  394. // This makes it entirely tree-shakable without polluting the exports and makes
  395. // it easier to be used in toolings like vue-loader
  396. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  397. // to be set so that its instances can be registered / removed.
  398. {
  399. const globalObject = typeof global !== 'undefined'
  400. ? global
  401. : typeof self !== 'undefined'
  402. ? self
  403. : typeof window !== 'undefined'
  404. ? window
  405. : {};
  406. globalObject.__VUE_HMR_RUNTIME__ = {
  407. createRecord: tryWrap(createRecord),
  408. rerender: tryWrap(rerender),
  409. reload: tryWrap(reload)
  410. };
  411. }
  412. const map = new Map();
  413. function registerHMR(instance) {
  414. const id = instance.type.__hmrId;
  415. let record = map.get(id);
  416. if (!record) {
  417. createRecord(id, instance.type);
  418. record = map.get(id);
  419. }
  420. record.instances.add(instance);
  421. }
  422. function unregisterHMR(instance) {
  423. map.get(instance.type.__hmrId).instances.delete(instance);
  424. }
  425. function createRecord(id, component) {
  426. if (!component) {
  427. warn(`HMR API usage is out of date.\n` +
  428. `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
  429. `dependency that handles Vue SFC compilation.`);
  430. component = {};
  431. }
  432. if (map.has(id)) {
  433. return false;
  434. }
  435. map.set(id, {
  436. component: isClassComponent(component) ? component.__vccOpts : component,
  437. instances: new Set()
  438. });
  439. return true;
  440. }
  441. function rerender(id, newRender) {
  442. const record = map.get(id);
  443. if (!record)
  444. return;
  445. if (newRender)
  446. record.component.render = newRender;
  447. // Array.from creates a snapshot which avoids the set being mutated during
  448. // updates
  449. Array.from(record.instances).forEach(instance => {
  450. if (newRender) {
  451. instance.render = newRender;
  452. }
  453. instance.renderCache = [];
  454. // this flag forces child components with slot content to update
  455. isHmrUpdating = true;
  456. instance.update();
  457. isHmrUpdating = false;
  458. });
  459. }
  460. function reload(id, newComp) {
  461. const record = map.get(id);
  462. if (!record)
  463. return;
  464. // Array.from creates a snapshot which avoids the set being mutated during
  465. // updates
  466. const { component, instances } = record;
  467. if (!hmrDirtyComponents.has(component)) {
  468. // 1. Update existing comp definition to match new one
  469. newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
  470. shared.extend(component, newComp);
  471. for (const key in component) {
  472. if (!(key in newComp)) {
  473. delete component[key];
  474. }
  475. }
  476. // 2. Mark component dirty. This forces the renderer to replace the component
  477. // on patch.
  478. hmrDirtyComponents.add(component);
  479. // 3. Make sure to unmark the component after the reload.
  480. queuePostFlushCb(() => {
  481. hmrDirtyComponents.delete(component);
  482. });
  483. }
  484. Array.from(instances).forEach(instance => {
  485. if (instance.parent) {
  486. // 4. Force the parent instance to re-render. This will cause all updated
  487. // components to be unmounted and re-mounted. Queue the update so that we
  488. // don't end up forcing the same parent to re-render multiple times.
  489. queueJob(instance.parent.update);
  490. }
  491. else if (instance.appContext.reload) {
  492. // root instance mounted via createApp() has a reload method
  493. instance.appContext.reload();
  494. }
  495. else if (typeof window !== 'undefined') {
  496. // root instance inside tree created via raw render(). Force reload.
  497. window.location.reload();
  498. }
  499. else {
  500. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  501. }
  502. });
  503. }
  504. function tryWrap(fn) {
  505. return (id, arg) => {
  506. try {
  507. return fn(id, arg);
  508. }
  509. catch (e) {
  510. console.error(e);
  511. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  512. `Full reload required.`);
  513. }
  514. };
  515. }
  516. exports.devtools = void 0;
  517. function setDevtoolsHook(hook) {
  518. exports.devtools = hook;
  519. }
  520. function devtoolsInitApp(app, version) {
  521. // TODO queue if devtools is undefined
  522. if (!exports.devtools)
  523. return;
  524. exports.devtools.emit("app:init" /* APP_INIT */, app, version, {
  525. Fragment,
  526. Text,
  527. Comment,
  528. Static
  529. });
  530. }
  531. function devtoolsUnmountApp(app) {
  532. if (!exports.devtools)
  533. return;
  534. exports.devtools.emit("app:unmount" /* APP_UNMOUNT */, app);
  535. }
  536. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  537. const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  538. const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  539. function createDevtoolsComponentHook(hook) {
  540. return (component) => {
  541. if (!exports.devtools)
  542. return;
  543. exports.devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  544. };
  545. }
  546. function devtoolsComponentEmit(component, event, params) {
  547. if (!exports.devtools)
  548. return;
  549. exports.devtools.emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  550. }
  551. function emit(instance, event, ...rawArgs) {
  552. const props = instance.vnode.props || shared.EMPTY_OBJ;
  553. {
  554. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  555. if (emitsOptions) {
  556. if (!(event in emitsOptions)) {
  557. if (!propsOptions || !(shared.toHandlerKey(event) in propsOptions)) {
  558. warn(`Component emitted event "${event}" but it is neither declared in ` +
  559. `the emits option nor as an "${shared.toHandlerKey(event)}" prop.`);
  560. }
  561. }
  562. else {
  563. const validator = emitsOptions[event];
  564. if (shared.isFunction(validator)) {
  565. const isValid = validator(...rawArgs);
  566. if (!isValid) {
  567. warn(`Invalid event arguments: event validation failed for event "${event}".`);
  568. }
  569. }
  570. }
  571. }
  572. }
  573. let args = rawArgs;
  574. const isModelListener = event.startsWith('update:');
  575. // for v-model update:xxx events, apply modifiers on args
  576. const modelArg = isModelListener && event.slice(7);
  577. if (modelArg && modelArg in props) {
  578. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  579. const { number, trim } = props[modifiersKey] || shared.EMPTY_OBJ;
  580. if (trim) {
  581. args = rawArgs.map(a => a.trim());
  582. }
  583. else if (number) {
  584. args = rawArgs.map(shared.toNumber);
  585. }
  586. }
  587. {
  588. devtoolsComponentEmit(instance, event, args);
  589. }
  590. {
  591. const lowerCaseEvent = event.toLowerCase();
  592. if (lowerCaseEvent !== event && props[shared.toHandlerKey(lowerCaseEvent)]) {
  593. warn(`Event "${lowerCaseEvent}" is emitted in component ` +
  594. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  595. `Note that HTML attributes are case-insensitive and you cannot use ` +
  596. `v-on to listen to camelCase events when using in-DOM templates. ` +
  597. `You should probably use "${shared.hyphenate(event)}" instead of "${event}".`);
  598. }
  599. }
  600. // convert handler name to camelCase. See issue #2249
  601. let handlerName = shared.toHandlerKey(shared.camelize(event));
  602. let handler = props[handlerName];
  603. // for v-model update:xxx events, also trigger kebab-case equivalent
  604. // for props passed via kebab-case
  605. if (!handler && isModelListener) {
  606. handlerName = shared.toHandlerKey(shared.hyphenate(event));
  607. handler = props[handlerName];
  608. }
  609. if (handler) {
  610. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  611. }
  612. const onceHandler = props[handlerName + `Once`];
  613. if (onceHandler) {
  614. if (!instance.emitted) {
  615. (instance.emitted = {})[handlerName] = true;
  616. }
  617. else if (instance.emitted[handlerName]) {
  618. return;
  619. }
  620. callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  621. }
  622. }
  623. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  624. if (!appContext.deopt && comp.__emits !== undefined) {
  625. return comp.__emits;
  626. }
  627. const raw = comp.emits;
  628. let normalized = {};
  629. // apply mixin/extends props
  630. let hasExtends = false;
  631. if (!shared.isFunction(comp)) {
  632. const extendEmits = (raw) => {
  633. hasExtends = true;
  634. shared.extend(normalized, normalizeEmitsOptions(raw, appContext, true));
  635. };
  636. if (!asMixin && appContext.mixins.length) {
  637. appContext.mixins.forEach(extendEmits);
  638. }
  639. if (comp.extends) {
  640. extendEmits(comp.extends);
  641. }
  642. if (comp.mixins) {
  643. comp.mixins.forEach(extendEmits);
  644. }
  645. }
  646. if (!raw && !hasExtends) {
  647. return (comp.__emits = null);
  648. }
  649. if (shared.isArray(raw)) {
  650. raw.forEach(key => (normalized[key] = null));
  651. }
  652. else {
  653. shared.extend(normalized, raw);
  654. }
  655. return (comp.__emits = normalized);
  656. }
  657. // Check if an incoming prop key is a declared emit event listener.
  658. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  659. // both considered matched listeners.
  660. function isEmitListener(options, key) {
  661. if (!options || !shared.isOn(key)) {
  662. return false;
  663. }
  664. key = key.slice(2).replace(/Once$/, '');
  665. return (shared.hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  666. shared.hasOwn(options, shared.hyphenate(key)) ||
  667. shared.hasOwn(options, key));
  668. }
  669. /**
  670. * mark the current rendering instance for asset resolution (e.g.
  671. * resolveComponent, resolveDirective) during render
  672. */
  673. let currentRenderingInstance = null;
  674. function setCurrentRenderingInstance(instance) {
  675. currentRenderingInstance = instance;
  676. }
  677. /**
  678. * dev only flag to track whether $attrs was used during render.
  679. * If $attrs was used during render then the warning for failed attrs
  680. * fallthrough can be suppressed.
  681. */
  682. let accessedAttrs = false;
  683. function markAttrsAccessed() {
  684. accessedAttrs = true;
  685. }
  686. function renderComponentRoot(instance) {
  687. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
  688. let result;
  689. currentRenderingInstance = instance;
  690. {
  691. accessedAttrs = false;
  692. }
  693. try {
  694. let fallthroughAttrs;
  695. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  696. // withProxy is a proxy with a different `has` trap only for
  697. // runtime-compiled render functions using `with` block.
  698. const proxyToUse = withProxy || proxy;
  699. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  700. fallthroughAttrs = attrs;
  701. }
  702. else {
  703. // functional
  704. const render = Component;
  705. // in dev, mark attrs accessed if optional props (attrs === props)
  706. if (true && attrs === props) {
  707. markAttrsAccessed();
  708. }
  709. result = normalizeVNode(render.length > 1
  710. ? render(props, true
  711. ? {
  712. get attrs() {
  713. markAttrsAccessed();
  714. return attrs;
  715. },
  716. slots,
  717. emit
  718. }
  719. : { attrs, slots, emit })
  720. : render(props, null /* we know it doesn't need it */));
  721. fallthroughAttrs = Component.props
  722. ? attrs
  723. : getFunctionalFallthrough(attrs);
  724. }
  725. // attr merging
  726. // in dev mode, comments are preserved, and it's possible for a template
  727. // to have comments along side the root element which makes it a fragment
  728. let root = result;
  729. let setRoot = undefined;
  730. if (true &&
  731. result.patchFlag > 0 &&
  732. result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  733. ;
  734. [root, setRoot] = getChildRoot(result);
  735. }
  736. if (Component.inheritAttrs !== false && fallthroughAttrs) {
  737. const keys = Object.keys(fallthroughAttrs);
  738. const { shapeFlag } = root;
  739. if (keys.length) {
  740. if (shapeFlag & 1 /* ELEMENT */ ||
  741. shapeFlag & 6 /* COMPONENT */) {
  742. if (propsOptions && keys.some(shared.isModelListener)) {
  743. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  744. // prop, it indicates this component expects to handle v-model and
  745. // it should not fallthrough.
  746. // related: #1543, #1643, #1989
  747. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  748. }
  749. root = cloneVNode(root, fallthroughAttrs);
  750. }
  751. else if (true && !accessedAttrs && root.type !== Comment) {
  752. const allAttrs = Object.keys(attrs);
  753. const eventAttrs = [];
  754. const extraAttrs = [];
  755. for (let i = 0, l = allAttrs.length; i < l; i++) {
  756. const key = allAttrs[i];
  757. if (shared.isOn(key)) {
  758. // ignore v-model handlers when they fail to fallthrough
  759. if (!shared.isModelListener(key)) {
  760. // remove `on`, lowercase first letter to reflect event casing
  761. // accurately
  762. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  763. }
  764. }
  765. else {
  766. extraAttrs.push(key);
  767. }
  768. }
  769. if (extraAttrs.length) {
  770. warn(`Extraneous non-props attributes (` +
  771. `${extraAttrs.join(', ')}) ` +
  772. `were passed to component but could not be automatically inherited ` +
  773. `because component renders fragment or text root nodes.`);
  774. }
  775. if (eventAttrs.length) {
  776. warn(`Extraneous non-emits event listeners (` +
  777. `${eventAttrs.join(', ')}) ` +
  778. `were passed to component but could not be automatically inherited ` +
  779. `because component renders fragment or text root nodes. ` +
  780. `If the listener is intended to be a component custom event listener only, ` +
  781. `declare it using the "emits" option.`);
  782. }
  783. }
  784. }
  785. }
  786. // inherit directives
  787. if (vnode.dirs) {
  788. if (true && !isElementRoot(root)) {
  789. warn(`Runtime directive used on component with non-element root node. ` +
  790. `The directives will not function as intended.`);
  791. }
  792. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  793. }
  794. // inherit transition data
  795. if (vnode.transition) {
  796. if (true && !isElementRoot(root)) {
  797. warn(`Component inside <Transition> renders non-element root node ` +
  798. `that cannot be animated.`);
  799. }
  800. root.transition = vnode.transition;
  801. }
  802. if (true && setRoot) {
  803. setRoot(root);
  804. }
  805. else {
  806. result = root;
  807. }
  808. }
  809. catch (err) {
  810. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  811. result = createVNode(Comment);
  812. }
  813. currentRenderingInstance = null;
  814. return result;
  815. }
  816. /**
  817. * dev only
  818. * In dev mode, template root level comments are rendered, which turns the
  819. * template into a fragment root, but we need to locate the single element
  820. * root for attrs and scope id processing.
  821. */
  822. const getChildRoot = (vnode) => {
  823. const rawChildren = vnode.children;
  824. const dynamicChildren = vnode.dynamicChildren;
  825. const childRoot = filterSingleRoot(rawChildren);
  826. if (!childRoot) {
  827. return [vnode, undefined];
  828. }
  829. const index = rawChildren.indexOf(childRoot);
  830. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  831. const setRoot = (updatedRoot) => {
  832. rawChildren[index] = updatedRoot;
  833. if (dynamicChildren) {
  834. if (dynamicIndex > -1) {
  835. dynamicChildren[dynamicIndex] = updatedRoot;
  836. }
  837. else if (updatedRoot.patchFlag > 0) {
  838. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  839. }
  840. }
  841. };
  842. return [normalizeVNode(childRoot), setRoot];
  843. };
  844. function filterSingleRoot(children) {
  845. let singleRoot;
  846. for (let i = 0; i < children.length; i++) {
  847. const child = children[i];
  848. if (isVNode(child)) {
  849. // ignore user comment
  850. if (child.type !== Comment || child.children === 'v-if') {
  851. if (singleRoot) {
  852. // has more than 1 non-comment child, return now
  853. return;
  854. }
  855. else {
  856. singleRoot = child;
  857. }
  858. }
  859. }
  860. else {
  861. return;
  862. }
  863. }
  864. return singleRoot;
  865. }
  866. const getFunctionalFallthrough = (attrs) => {
  867. let res;
  868. for (const key in attrs) {
  869. if (key === 'class' || key === 'style' || shared.isOn(key)) {
  870. (res || (res = {}))[key] = attrs[key];
  871. }
  872. }
  873. return res;
  874. };
  875. const filterModelListeners = (attrs, props) => {
  876. const res = {};
  877. for (const key in attrs) {
  878. if (!shared.isModelListener(key) || !(key.slice(9) in props)) {
  879. res[key] = attrs[key];
  880. }
  881. }
  882. return res;
  883. };
  884. const isElementRoot = (vnode) => {
  885. return (vnode.shapeFlag & 6 /* COMPONENT */ ||
  886. vnode.shapeFlag & 1 /* ELEMENT */ ||
  887. vnode.type === Comment // potential v-if branch switch
  888. );
  889. };
  890. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  891. const { props: prevProps, children: prevChildren, component } = prevVNode;
  892. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  893. const emits = component.emitsOptions;
  894. // Parent component's render function was hot-updated. Since this may have
  895. // caused the child component's slots content to have changed, we need to
  896. // force the child to update as well.
  897. if ((prevChildren || nextChildren) && isHmrUpdating) {
  898. return true;
  899. }
  900. // force child update for runtime directive or transition on component vnode.
  901. if (nextVNode.dirs || nextVNode.transition) {
  902. return true;
  903. }
  904. if (optimized && patchFlag >= 0) {
  905. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  906. // slot content that references values that might have changed,
  907. // e.g. in a v-for
  908. return true;
  909. }
  910. if (patchFlag & 16 /* FULL_PROPS */) {
  911. if (!prevProps) {
  912. return !!nextProps;
  913. }
  914. // presence of this flag indicates props are always non-null
  915. return hasPropsChanged(prevProps, nextProps, emits);
  916. }
  917. else if (patchFlag & 8 /* PROPS */) {
  918. const dynamicProps = nextVNode.dynamicProps;
  919. for (let i = 0; i < dynamicProps.length; i++) {
  920. const key = dynamicProps[i];
  921. if (nextProps[key] !== prevProps[key] &&
  922. !isEmitListener(emits, key)) {
  923. return true;
  924. }
  925. }
  926. }
  927. }
  928. else {
  929. // this path is only taken by manually written render functions
  930. // so presence of any children leads to a forced update
  931. if (prevChildren || nextChildren) {
  932. if (!nextChildren || !nextChildren.$stable) {
  933. return true;
  934. }
  935. }
  936. if (prevProps === nextProps) {
  937. return false;
  938. }
  939. if (!prevProps) {
  940. return !!nextProps;
  941. }
  942. if (!nextProps) {
  943. return true;
  944. }
  945. return hasPropsChanged(prevProps, nextProps, emits);
  946. }
  947. return false;
  948. }
  949. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  950. const nextKeys = Object.keys(nextProps);
  951. if (nextKeys.length !== Object.keys(prevProps).length) {
  952. return true;
  953. }
  954. for (let i = 0; i < nextKeys.length; i++) {
  955. const key = nextKeys[i];
  956. if (nextProps[key] !== prevProps[key] &&
  957. !isEmitListener(emitsOptions, key)) {
  958. return true;
  959. }
  960. }
  961. return false;
  962. }
  963. function updateHOCHostEl({ vnode, parent }, el // HostNode
  964. ) {
  965. while (parent && parent.subTree === vnode) {
  966. (vnode = parent.vnode).el = el;
  967. parent = parent.parent;
  968. }
  969. }
  970. const isSuspense = (type) => type.__isSuspense;
  971. // Suspense exposes a component-like API, and is treated like a component
  972. // in the compiler, but internally it's a special built-in type that hooks
  973. // directly into the renderer.
  974. const SuspenseImpl = {
  975. // In order to make Suspense tree-shakable, we need to avoid importing it
  976. // directly in the renderer. The renderer checks for the __isSuspense flag
  977. // on a vnode's type and calls the `process` method, passing in renderer
  978. // internals.
  979. __isSuspense: true,
  980. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized,
  981. // platform-specific impl passed from renderer
  982. rendererInternals) {
  983. if (n1 == null) {
  984. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals);
  985. }
  986. else {
  987. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, rendererInternals);
  988. }
  989. },
  990. hydrate: hydrateSuspense,
  991. create: createSuspenseBoundary
  992. };
  993. // Force-casted public typing for h and TSX props inference
  994. const Suspense = (SuspenseImpl
  995. );
  996. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals) {
  997. const { p: patch, o: { createElement } } = rendererInternals;
  998. const hiddenContainer = createElement('div');
  999. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals));
  1000. // start mounting the content subtree in an off-dom container
  1001. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG);
  1002. // now check if we have encountered any async deps
  1003. if (suspense.deps > 0) {
  1004. // has async
  1005. // mount the fallback tree
  1006. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  1007. isSVG);
  1008. setActiveBranch(suspense, vnode.ssFallback);
  1009. }
  1010. else {
  1011. // Suspense has no async deps. Just resolve.
  1012. suspense.resolve();
  1013. }
  1014. }
  1015. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, { p: patch, um: unmount, o: { createElement } }) {
  1016. const suspense = (n2.suspense = n1.suspense);
  1017. suspense.vnode = n2;
  1018. n2.el = n1.el;
  1019. const newBranch = n2.ssContent;
  1020. const newFallback = n2.ssFallback;
  1021. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  1022. if (pendingBranch) {
  1023. suspense.pendingBranch = newBranch;
  1024. if (isSameVNodeType(newBranch, pendingBranch)) {
  1025. // same root type but content may have changed.
  1026. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG);
  1027. if (suspense.deps <= 0) {
  1028. suspense.resolve();
  1029. }
  1030. else if (isInFallback) {
  1031. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  1032. isSVG);
  1033. setActiveBranch(suspense, newFallback);
  1034. }
  1035. }
  1036. else {
  1037. // toggled before pending tree is resolved
  1038. suspense.pendingId++;
  1039. if (isHydrating) {
  1040. // if toggled before hydration is finished, the current DOM tree is
  1041. // no longer valid. set it as the active branch so it will be unmounted
  1042. // when resolved
  1043. suspense.isHydrating = false;
  1044. suspense.activeBranch = pendingBranch;
  1045. }
  1046. else {
  1047. unmount(pendingBranch, parentComponent, suspense);
  1048. }
  1049. // increment pending ID. this is used to invalidate async callbacks
  1050. // reset suspense state
  1051. suspense.deps = 0;
  1052. // discard effects from pending branch
  1053. suspense.effects.length = 0;
  1054. // discard previous container
  1055. suspense.hiddenContainer = createElement('div');
  1056. if (isInFallback) {
  1057. // already in fallback state
  1058. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG);
  1059. if (suspense.deps <= 0) {
  1060. suspense.resolve();
  1061. }
  1062. else {
  1063. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  1064. isSVG);
  1065. setActiveBranch(suspense, newFallback);
  1066. }
  1067. }
  1068. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  1069. // toggled "back" to current active branch
  1070. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG);
  1071. // force resolve
  1072. suspense.resolve(true);
  1073. }
  1074. else {
  1075. // switched to a 3rd branch
  1076. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG);
  1077. if (suspense.deps <= 0) {
  1078. suspense.resolve();
  1079. }
  1080. }
  1081. }
  1082. }
  1083. else {
  1084. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  1085. // root did not change, just normal patch
  1086. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG);
  1087. setActiveBranch(suspense, newBranch);
  1088. }
  1089. else {
  1090. // root node toggled
  1091. // invoke @pending event
  1092. const onPending = n2.props && n2.props.onPending;
  1093. if (shared.isFunction(onPending)) {
  1094. onPending();
  1095. }
  1096. // mount pending branch in off-dom container
  1097. suspense.pendingBranch = newBranch;
  1098. suspense.pendingId++;
  1099. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG);
  1100. if (suspense.deps <= 0) {
  1101. // incoming branch has no async deps, resolve now.
  1102. suspense.resolve();
  1103. }
  1104. else {
  1105. const { timeout, pendingId } = suspense;
  1106. if (timeout > 0) {
  1107. setTimeout(() => {
  1108. if (suspense.pendingId === pendingId) {
  1109. suspense.fallback(newFallback);
  1110. }
  1111. }, timeout);
  1112. }
  1113. else if (timeout === 0) {
  1114. suspense.fallback(newFallback);
  1115. }
  1116. }
  1117. }
  1118. }
  1119. }
  1120. let hasWarned = false;
  1121. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals, isHydrating = false) {
  1122. /* istanbul ignore if */
  1123. if (!hasWarned) {
  1124. hasWarned = true;
  1125. // @ts-ignore `console.info` cannot be null error
  1126. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  1127. }
  1128. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  1129. const timeout = shared.toNumber(vnode.props && vnode.props.timeout);
  1130. const suspense = {
  1131. vnode,
  1132. parent,
  1133. parentComponent,
  1134. isSVG,
  1135. container,
  1136. hiddenContainer,
  1137. anchor,
  1138. deps: 0,
  1139. pendingId: 0,
  1140. timeout: typeof timeout === 'number' ? timeout : -1,
  1141. activeBranch: null,
  1142. pendingBranch: null,
  1143. isInFallback: true,
  1144. isHydrating,
  1145. isUnmounted: false,
  1146. effects: [],
  1147. resolve(resume = false) {
  1148. {
  1149. if (!resume && !suspense.pendingBranch) {
  1150. throw new Error(`suspense.resolve() is called without a pending branch.`);
  1151. }
  1152. if (suspense.isUnmounted) {
  1153. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  1154. }
  1155. }
  1156. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  1157. if (suspense.isHydrating) {
  1158. suspense.isHydrating = false;
  1159. }
  1160. else if (!resume) {
  1161. const delayEnter = activeBranch &&
  1162. pendingBranch.transition &&
  1163. pendingBranch.transition.mode === 'out-in';
  1164. if (delayEnter) {
  1165. activeBranch.transition.afterLeave = () => {
  1166. if (pendingId === suspense.pendingId) {
  1167. move(pendingBranch, container, anchor, 0 /* ENTER */);
  1168. }
  1169. };
  1170. }
  1171. // this is initial anchor on mount
  1172. let { anchor } = suspense;
  1173. // unmount current active tree
  1174. if (activeBranch) {
  1175. // if the fallback tree was mounted, it may have been moved
  1176. // as part of a parent suspense. get the latest anchor for insertion
  1177. anchor = next(activeBranch);
  1178. unmount(activeBranch, parentComponent, suspense, true);
  1179. }
  1180. if (!delayEnter) {
  1181. // move content from off-dom container to actual container
  1182. move(pendingBranch, container, anchor, 0 /* ENTER */);
  1183. }
  1184. }
  1185. setActiveBranch(suspense, pendingBranch);
  1186. suspense.pendingBranch = null;
  1187. suspense.isInFallback = false;
  1188. // flush buffered effects
  1189. // check if there is a pending parent suspense
  1190. let parent = suspense.parent;
  1191. let hasUnresolvedAncestor = false;
  1192. while (parent) {
  1193. if (parent.pendingBranch) {
  1194. // found a pending parent suspense, merge buffered post jobs
  1195. // into that parent
  1196. parent.effects.push(...effects);
  1197. hasUnresolvedAncestor = true;
  1198. break;
  1199. }
  1200. parent = parent.parent;
  1201. }
  1202. // no pending parent suspense, flush all jobs
  1203. if (!hasUnresolvedAncestor) {
  1204. queuePostFlushCb(effects);
  1205. }
  1206. suspense.effects = [];
  1207. // invoke @resolve event
  1208. const onResolve = vnode.props && vnode.props.onResolve;
  1209. if (shared.isFunction(onResolve)) {
  1210. onResolve();
  1211. }
  1212. },
  1213. fallback(fallbackVNode) {
  1214. if (!suspense.pendingBranch) {
  1215. return;
  1216. }
  1217. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  1218. // invoke @fallback event
  1219. const onFallback = vnode.props && vnode.props.onFallback;
  1220. if (shared.isFunction(onFallback)) {
  1221. onFallback();
  1222. }
  1223. const anchor = next(activeBranch);
  1224. const mountFallback = () => {
  1225. if (!suspense.isInFallback) {
  1226. return;
  1227. }
  1228. // mount the fallback tree
  1229. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  1230. isSVG);
  1231. setActiveBranch(suspense, fallbackVNode);
  1232. };
  1233. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  1234. if (delayEnter) {
  1235. activeBranch.transition.afterLeave = mountFallback;
  1236. }
  1237. // unmount current active branch
  1238. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  1239. true // shouldRemove
  1240. );
  1241. suspense.isInFallback = true;
  1242. if (!delayEnter) {
  1243. mountFallback();
  1244. }
  1245. },
  1246. move(container, anchor, type) {
  1247. suspense.activeBranch &&
  1248. move(suspense.activeBranch, container, anchor, type);
  1249. suspense.container = container;
  1250. },
  1251. next() {
  1252. return suspense.activeBranch && next(suspense.activeBranch);
  1253. },
  1254. registerDep(instance, setupRenderEffect) {
  1255. const isInPendingSuspense = !!suspense.pendingBranch;
  1256. if (isInPendingSuspense) {
  1257. suspense.deps++;
  1258. }
  1259. const hydratedEl = instance.vnode.el;
  1260. instance
  1261. .asyncDep.catch(err => {
  1262. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  1263. })
  1264. .then(asyncSetupResult => {
  1265. // retry when the setup() promise resolves.
  1266. // component may have been unmounted before resolve.
  1267. if (instance.isUnmounted ||
  1268. suspense.isUnmounted ||
  1269. suspense.pendingId !== instance.suspenseId) {
  1270. return;
  1271. }
  1272. // retry from this component
  1273. instance.asyncResolved = true;
  1274. const { vnode } = instance;
  1275. {
  1276. pushWarningContext(vnode);
  1277. }
  1278. handleSetupResult(instance, asyncSetupResult, false);
  1279. if (hydratedEl) {
  1280. // vnode may have been replaced if an update happened before the
  1281. // async dep is resolved.
  1282. vnode.el = hydratedEl;
  1283. }
  1284. const placeholder = !hydratedEl && instance.subTree.el;
  1285. setupRenderEffect(instance, vnode,
  1286. // component may have been moved before resolve.
  1287. // if this is not a hydration, instance.subTree will be the comment
  1288. // placeholder.
  1289. parentNode(hydratedEl || instance.subTree.el),
  1290. // anchor will not be used if this is hydration, so only need to
  1291. // consider the comment placeholder case.
  1292. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  1293. if (placeholder) {
  1294. remove(placeholder);
  1295. }
  1296. updateHOCHostEl(instance, vnode.el);
  1297. {
  1298. popWarningContext();
  1299. }
  1300. // only decrease deps count if suspense is not already resolved
  1301. if (isInPendingSuspense && --suspense.deps === 0) {
  1302. suspense.resolve();
  1303. }
  1304. });
  1305. },
  1306. unmount(parentSuspense, doRemove) {
  1307. suspense.isUnmounted = true;
  1308. if (suspense.activeBranch) {
  1309. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  1310. }
  1311. if (suspense.pendingBranch) {
  1312. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  1313. }
  1314. }
  1315. };
  1316. return suspense;
  1317. }
  1318. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, optimized, rendererInternals, hydrateNode) {
  1319. /* eslint-disable no-restricted-globals */
  1320. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, optimized, rendererInternals, true /* hydrating */));
  1321. // there are two possible scenarios for server-rendered suspense:
  1322. // - success: ssr content should be fully resolved
  1323. // - failure: ssr content should be the fallback branch.
  1324. // however, on the client we don't really know if it has failed or not
  1325. // attempt to hydrate the DOM assuming it has succeeded, but we still
  1326. // need to construct a suspense boundary first
  1327. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, optimized);
  1328. if (suspense.deps === 0) {
  1329. suspense.resolve();
  1330. }
  1331. return result;
  1332. /* eslint-enable no-restricted-globals */
  1333. }
  1334. function normalizeSuspenseChildren(vnode) {
  1335. const { shapeFlag, children } = vnode;
  1336. let content;
  1337. let fallback;
  1338. if (shapeFlag & 32 /* SLOTS_CHILDREN */) {
  1339. content = normalizeSuspenseSlot(children.default);
  1340. fallback = normalizeSuspenseSlot(children.fallback);
  1341. }
  1342. else {
  1343. content = normalizeSuspenseSlot(children);
  1344. fallback = normalizeVNode(null);
  1345. }
  1346. return {
  1347. content,
  1348. fallback
  1349. };
  1350. }
  1351. function normalizeSuspenseSlot(s) {
  1352. if (shared.isFunction(s)) {
  1353. s = s();
  1354. }
  1355. if (shared.isArray(s)) {
  1356. const singleChild = filterSingleRoot(s);
  1357. if (!singleChild) {
  1358. warn(`<Suspense> slots expect a single root node.`);
  1359. }
  1360. s = singleChild;
  1361. }
  1362. return normalizeVNode(s);
  1363. }
  1364. function queueEffectWithSuspense(fn, suspense) {
  1365. if (suspense && suspense.pendingBranch) {
  1366. if (shared.isArray(fn)) {
  1367. suspense.effects.push(...fn);
  1368. }
  1369. else {
  1370. suspense.effects.push(fn);
  1371. }
  1372. }
  1373. else {
  1374. queuePostFlushCb(fn);
  1375. }
  1376. }
  1377. function setActiveBranch(suspense, branch) {
  1378. suspense.activeBranch = branch;
  1379. const { vnode, parentComponent } = suspense;
  1380. const el = (vnode.el = branch.el);
  1381. // in case suspense is the root node of a component,
  1382. // recursively update the HOC el
  1383. if (parentComponent && parentComponent.subTree === vnode) {
  1384. parentComponent.vnode.el = el;
  1385. updateHOCHostEl(parentComponent, el);
  1386. }
  1387. }
  1388. let isRenderingCompiledSlot = 0;
  1389. const setCompiledSlotRendering = (n) => (isRenderingCompiledSlot += n);
  1390. /**
  1391. * Compiler runtime helper for rendering `<slot/>`
  1392. * @private
  1393. */
  1394. function renderSlot(slots, name, props = {},
  1395. // this is not a user-facing function, so the fallback is always generated by
  1396. // the compiler and guaranteed to be a function returning an array
  1397. fallback) {
  1398. let slot = slots[name];
  1399. if (slot && slot.length > 1) {
  1400. warn(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  1401. `function. You need to mark this component with $dynamic-slots in the ` +
  1402. `parent template.`);
  1403. slot = () => [];
  1404. }
  1405. // a compiled slot disables block tracking by default to avoid manual
  1406. // invocation interfering with template-based block tracking, but in
  1407. // `renderSlot` we can be sure that it's template-based so we can force
  1408. // enable it.
  1409. isRenderingCompiledSlot++;
  1410. openBlock();
  1411. const validSlotContent = slot && ensureValidVNode(slot(props));
  1412. const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
  1413. ? 64 /* STABLE_FRAGMENT */
  1414. : -2 /* BAIL */);
  1415. isRenderingCompiledSlot--;
  1416. return rendered;
  1417. }
  1418. function ensureValidVNode(vnodes) {
  1419. return vnodes.some(child => {
  1420. if (!isVNode(child))
  1421. return true;
  1422. if (child.type === Comment)
  1423. return false;
  1424. if (child.type === Fragment &&
  1425. !ensureValidVNode(child.children))
  1426. return false;
  1427. return true;
  1428. })
  1429. ? vnodes
  1430. : null;
  1431. }
  1432. /**
  1433. * Wrap a slot function to memoize current rendering instance
  1434. * @private
  1435. */
  1436. function withCtx(fn, ctx = currentRenderingInstance) {
  1437. if (!ctx)
  1438. return fn;
  1439. const renderFnWithContext = (...args) => {
  1440. // If a user calls a compiled slot inside a template expression (#1745), it
  1441. // can mess up block tracking, so by default we need to push a null block to
  1442. // avoid that. This isn't necessary if rendering a compiled `<slot>`.
  1443. if (!isRenderingCompiledSlot) {
  1444. openBlock(true /* null block that disables tracking */);
  1445. }
  1446. const owner = currentRenderingInstance;
  1447. setCurrentRenderingInstance(ctx);
  1448. const res = fn(...args);
  1449. setCurrentRenderingInstance(owner);
  1450. if (!isRenderingCompiledSlot) {
  1451. closeBlock();
  1452. }
  1453. return res;
  1454. };
  1455. renderFnWithContext._c = true;
  1456. return renderFnWithContext;
  1457. }
  1458. // SFC scoped style ID management.
  1459. let currentScopeId = null;
  1460. const scopeIdStack = [];
  1461. /**
  1462. * @private
  1463. */
  1464. function pushScopeId(id) {
  1465. scopeIdStack.push((currentScopeId = id));
  1466. }
  1467. /**
  1468. * @private
  1469. */
  1470. function popScopeId() {
  1471. scopeIdStack.pop();
  1472. currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null;
  1473. }
  1474. /**
  1475. * @private
  1476. */
  1477. function withScopeId(id) {
  1478. return ((fn) => withCtx(function () {
  1479. pushScopeId(id);
  1480. const res = fn.apply(this, arguments);
  1481. popScopeId();
  1482. return res;
  1483. }));
  1484. }
  1485. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  1486. isSSR = false) {
  1487. const props = {};
  1488. const attrs = {};
  1489. shared.def(attrs, InternalObjectKey, 1);
  1490. setFullProps(instance, rawProps, props, attrs);
  1491. // validation
  1492. {
  1493. validateProps(props, instance);
  1494. }
  1495. if (isStateful) {
  1496. // stateful
  1497. instance.props = isSSR ? props : reactivity.shallowReactive(props);
  1498. }
  1499. else {
  1500. if (!instance.type.props) {
  1501. // functional w/ optional props, props === attrs
  1502. instance.props = attrs;
  1503. }
  1504. else {
  1505. // functional w/ declared props
  1506. instance.props = props;
  1507. }
  1508. }
  1509. instance.attrs = attrs;
  1510. }
  1511. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  1512. const { props, attrs, vnode: { patchFlag } } = instance;
  1513. const rawCurrentProps = reactivity.toRaw(props);
  1514. const [options] = instance.propsOptions;
  1515. if (
  1516. // always force full diff in dev
  1517. // - #1942 if hmr is enabled with sfc component
  1518. // - vite#872 non-sfc component used by sfc component
  1519. !((instance.type.__hmrId ||
  1520. (instance.parent && instance.parent.type.__hmrId))) &&
  1521. (optimized || patchFlag > 0) &&
  1522. !(patchFlag & 16 /* FULL_PROPS */)) {
  1523. if (patchFlag & 8 /* PROPS */) {
  1524. // Compiler-generated props & no keys change, just set the updated
  1525. // the props.
  1526. const propsToUpdate = instance.vnode.dynamicProps;
  1527. for (let i = 0; i < propsToUpdate.length; i++) {
  1528. const key = propsToUpdate[i];
  1529. // PROPS flag guarantees rawProps to be non-null
  1530. const value = rawProps[key];
  1531. if (options) {
  1532. // attr / props separation was done on init and will be consistent
  1533. // in this code path, so just check if attrs have it.
  1534. if (shared.hasOwn(attrs, key)) {
  1535. attrs[key] = value;
  1536. }
  1537. else {
  1538. const camelizedKey = shared.camelize(key);
  1539. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance);
  1540. }
  1541. }
  1542. else {
  1543. attrs[key] = value;
  1544. }
  1545. }
  1546. }
  1547. }
  1548. else {
  1549. // full props update.
  1550. setFullProps(instance, rawProps, props, attrs);
  1551. // in case of dynamic props, check if we need to delete keys from
  1552. // the props object
  1553. let kebabKey;
  1554. for (const key in rawCurrentProps) {
  1555. if (!rawProps ||
  1556. // for camelCase
  1557. (!shared.hasOwn(rawProps, key) &&
  1558. // it's possible the original props was passed in as kebab-case
  1559. // and converted to camelCase (#955)
  1560. ((kebabKey = shared.hyphenate(key)) === key || !shared.hasOwn(rawProps, kebabKey)))) {
  1561. if (options) {
  1562. if (rawPrevProps &&
  1563. // for camelCase
  1564. (rawPrevProps[key] !== undefined ||
  1565. // for kebab-case
  1566. rawPrevProps[kebabKey] !== undefined)) {
  1567. props[key] = resolvePropValue(options, rawProps || shared.EMPTY_OBJ, key, undefined, instance);
  1568. }
  1569. }
  1570. else {
  1571. delete props[key];
  1572. }
  1573. }
  1574. }
  1575. // in the case of functional component w/o props declaration, props and
  1576. // attrs point to the same object so it should already have been updated.
  1577. if (attrs !== rawCurrentProps) {
  1578. for (const key in attrs) {
  1579. if (!rawProps || !shared.hasOwn(rawProps, key)) {
  1580. delete attrs[key];
  1581. }
  1582. }
  1583. }
  1584. }
  1585. // trigger updates for $attrs in case it's used in component slots
  1586. reactivity.trigger(instance, "set" /* SET */, '$attrs');
  1587. if (rawProps) {
  1588. validateProps(props, instance);
  1589. }
  1590. }
  1591. function setFullProps(instance, rawProps, props, attrs) {
  1592. const [options, needCastKeys] = instance.propsOptions;
  1593. if (rawProps) {
  1594. for (const key in rawProps) {
  1595. const value = rawProps[key];
  1596. // key, ref are reserved and never passed down
  1597. if (shared.isReservedProp(key)) {
  1598. continue;
  1599. }
  1600. // prop option names are camelized during normalization, so to support
  1601. // kebab -> camel conversion here we need to camelize the key.
  1602. let camelKey;
  1603. if (options && shared.hasOwn(options, (camelKey = shared.camelize(key)))) {
  1604. props[camelKey] = value;
  1605. }
  1606. else if (!isEmitListener(instance.emitsOptions, key)) {
  1607. // Any non-declared (either as a prop or an emitted event) props are put
  1608. // into a separate `attrs` object for spreading. Make sure to preserve
  1609. // original key casing
  1610. attrs[key] = value;
  1611. }
  1612. }
  1613. }
  1614. if (needCastKeys) {
  1615. const rawCurrentProps = reactivity.toRaw(props);
  1616. for (let i = 0; i < needCastKeys.length; i++) {
  1617. const key = needCastKeys[i];
  1618. props[key] = resolvePropValue(options, rawCurrentProps, key, rawCurrentProps[key], instance);
  1619. }
  1620. }
  1621. }
  1622. function resolvePropValue(options, props, key, value, instance) {
  1623. const opt = options[key];
  1624. if (opt != null) {
  1625. const hasDefault = shared.hasOwn(opt, 'default');
  1626. // default values
  1627. if (hasDefault && value === undefined) {
  1628. const defaultValue = opt.default;
  1629. if (opt.type !== Function && shared.isFunction(defaultValue)) {
  1630. setCurrentInstance(instance);
  1631. value = defaultValue(props);
  1632. setCurrentInstance(null);
  1633. }
  1634. else {
  1635. value = defaultValue;
  1636. }
  1637. }
  1638. // boolean casting
  1639. if (opt[0 /* shouldCast */]) {
  1640. if (!shared.hasOwn(props, key) && !hasDefault) {
  1641. value = false;
  1642. }
  1643. else if (opt[1 /* shouldCastTrue */] &&
  1644. (value === '' || value === shared.hyphenate(key))) {
  1645. value = true;
  1646. }
  1647. }
  1648. }
  1649. return value;
  1650. }
  1651. function normalizePropsOptions(comp, appContext, asMixin = false) {
  1652. if (!appContext.deopt && comp.__props) {
  1653. return comp.__props;
  1654. }
  1655. const raw = comp.props;
  1656. const normalized = {};
  1657. const needCastKeys = [];
  1658. // apply mixin/extends props
  1659. let hasExtends = false;
  1660. if (!shared.isFunction(comp)) {
  1661. const extendProps = (raw) => {
  1662. hasExtends = true;
  1663. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  1664. shared.extend(normalized, props);
  1665. if (keys)
  1666. needCastKeys.push(...keys);
  1667. };
  1668. if (!asMixin && appContext.mixins.length) {
  1669. appContext.mixins.forEach(extendProps);
  1670. }
  1671. if (comp.extends) {
  1672. extendProps(comp.extends);
  1673. }
  1674. if (comp.mixins) {
  1675. comp.mixins.forEach(extendProps);
  1676. }
  1677. }
  1678. if (!raw && !hasExtends) {
  1679. return (comp.__props = shared.EMPTY_ARR);
  1680. }
  1681. if (shared.isArray(raw)) {
  1682. for (let i = 0; i < raw.length; i++) {
  1683. if (!shared.isString(raw[i])) {
  1684. warn(`props must be strings when using array syntax.`, raw[i]);
  1685. }
  1686. const normalizedKey = shared.camelize(raw[i]);
  1687. if (validatePropName(normalizedKey)) {
  1688. normalized[normalizedKey] = shared.EMPTY_OBJ;
  1689. }
  1690. }
  1691. }
  1692. else if (raw) {
  1693. if (!shared.isObject(raw)) {
  1694. warn(`invalid props options`, raw);
  1695. }
  1696. for (const key in raw) {
  1697. const normalizedKey = shared.camelize(key);
  1698. if (validatePropName(normalizedKey)) {
  1699. const opt = raw[key];
  1700. const prop = (normalized[normalizedKey] =
  1701. shared.isArray(opt) || shared.isFunction(opt) ? { type: opt } : opt);
  1702. if (prop) {
  1703. const booleanIndex = getTypeIndex(Boolean, prop.type);
  1704. const stringIndex = getTypeIndex(String, prop.type);
  1705. prop[0 /* shouldCast */] = booleanIndex > -1;
  1706. prop[1 /* shouldCastTrue */] =
  1707. stringIndex < 0 || booleanIndex < stringIndex;
  1708. // if the prop needs boolean casting or default value
  1709. if (booleanIndex > -1 || shared.hasOwn(prop, 'default')) {
  1710. needCastKeys.push(normalizedKey);
  1711. }
  1712. }
  1713. }
  1714. }
  1715. }
  1716. return (comp.__props = [normalized, needCastKeys]);
  1717. }
  1718. function validatePropName(key) {
  1719. if (key[0] !== '$') {
  1720. return true;
  1721. }
  1722. else {
  1723. warn(`Invalid prop name: "${key}" is a reserved property.`);
  1724. }
  1725. return false;
  1726. }
  1727. // use function string name to check type constructors
  1728. // so that it works across vms / iframes.
  1729. function getType(ctor) {
  1730. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  1731. return match ? match[1] : '';
  1732. }
  1733. function isSameType(a, b) {
  1734. return getType(a) === getType(b);
  1735. }
  1736. function getTypeIndex(type, expectedTypes) {
  1737. if (shared.isArray(expectedTypes)) {
  1738. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  1739. if (isSameType(expectedTypes[i], type)) {
  1740. return i;
  1741. }
  1742. }
  1743. }
  1744. else if (shared.isFunction(expectedTypes)) {
  1745. return isSameType(expectedTypes, type) ? 0 : -1;
  1746. }
  1747. return -1;
  1748. }
  1749. /**
  1750. * dev only
  1751. */
  1752. function validateProps(props, instance) {
  1753. const rawValues = reactivity.toRaw(props);
  1754. const options = instance.propsOptions[0];
  1755. for (const key in options) {
  1756. let opt = options[key];
  1757. if (opt == null)
  1758. continue;
  1759. validateProp(key, rawValues[key], opt, !shared.hasOwn(rawValues, key));
  1760. }
  1761. }
  1762. /**
  1763. * dev only
  1764. */
  1765. function validateProp(name, value, prop, isAbsent) {
  1766. const { type, required, validator } = prop;
  1767. // required!
  1768. if (required && isAbsent) {
  1769. warn('Missing required prop: "' + name + '"');
  1770. return;
  1771. }
  1772. // missing but optional
  1773. if (value == null && !prop.required) {
  1774. return;
  1775. }
  1776. // type check
  1777. if (type != null && type !== true) {
  1778. let isValid = false;
  1779. const types = shared.isArray(type) ? type : [type];
  1780. const expectedTypes = [];
  1781. // value is valid as long as one of the specified types match
  1782. for (let i = 0; i < types.length && !isValid; i++) {
  1783. const { valid, expectedType } = assertType(value, types[i]);
  1784. expectedTypes.push(expectedType || '');
  1785. isValid = valid;
  1786. }
  1787. if (!isValid) {
  1788. warn(getInvalidTypeMessage(name, value, expectedTypes));
  1789. return;
  1790. }
  1791. }
  1792. // custom validator
  1793. if (validator && !validator(value)) {
  1794. warn('Invalid prop: custom validator check failed for prop "' + name + '".');
  1795. }
  1796. }
  1797. const isSimpleType = /*#__PURE__*/ shared.makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  1798. /**
  1799. * dev only
  1800. */
  1801. function assertType(value, type) {
  1802. let valid;
  1803. const expectedType = getType(type);
  1804. if (isSimpleType(expectedType)) {
  1805. const t = typeof value;
  1806. valid = t === expectedType.toLowerCase();
  1807. // for primitive wrapper objects
  1808. if (!valid && t === 'object') {
  1809. valid = value instanceof type;
  1810. }
  1811. }
  1812. else if (expectedType === 'Object') {
  1813. valid = shared.isObject(value);
  1814. }
  1815. else if (expectedType === 'Array') {
  1816. valid = shared.isArray(value);
  1817. }
  1818. else {
  1819. valid = value instanceof type;
  1820. }
  1821. return {
  1822. valid,
  1823. expectedType
  1824. };
  1825. }
  1826. /**
  1827. * dev only
  1828. */
  1829. function getInvalidTypeMessage(name, value, expectedTypes) {
  1830. let message = `Invalid prop: type check failed for prop "${name}".` +
  1831. ` Expected ${expectedTypes.map(shared.capitalize).join(', ')}`;
  1832. const expectedType = expectedTypes[0];
  1833. const receivedType = shared.toRawType(value);
  1834. const expectedValue = styleValue(value, expectedType);
  1835. const receivedValue = styleValue(value, receivedType);
  1836. // check if we need to specify expected value
  1837. if (expectedTypes.length === 1 &&
  1838. isExplicable(expectedType) &&
  1839. !isBoolean(expectedType, receivedType)) {
  1840. message += ` with value ${expectedValue}`;
  1841. }
  1842. message += `, got ${receivedType} `;
  1843. // check if we need to specify received value
  1844. if (isExplicable(receivedType)) {
  1845. message += `with value ${receivedValue}.`;
  1846. }
  1847. return message;
  1848. }
  1849. /**
  1850. * dev only
  1851. */
  1852. function styleValue(value, type) {
  1853. if (type === 'String') {
  1854. return `"${value}"`;
  1855. }
  1856. else if (type === 'Number') {
  1857. return `${Number(value)}`;
  1858. }
  1859. else {
  1860. return `${value}`;
  1861. }
  1862. }
  1863. /**
  1864. * dev only
  1865. */
  1866. function isExplicable(type) {
  1867. const explicitTypes = ['string', 'number', 'boolean'];
  1868. return explicitTypes.some(elem => type.toLowerCase() === elem);
  1869. }
  1870. /**
  1871. * dev only
  1872. */
  1873. function isBoolean(...args) {
  1874. return args.some(elem => elem.toLowerCase() === 'boolean');
  1875. }
  1876. function injectHook(type, hook, target = currentInstance, prepend = false) {
  1877. if (target) {
  1878. const hooks = target[type] || (target[type] = []);
  1879. // cache the error handling wrapper for injected hooks so the same hook
  1880. // can be properly deduped by the scheduler. "__weh" stands for "with error
  1881. // handling".
  1882. const wrappedHook = hook.__weh ||
  1883. (hook.__weh = (...args) => {
  1884. if (target.isUnmounted) {
  1885. return;
  1886. }
  1887. // disable tracking inside all lifecycle hooks
  1888. // since they can potentially be called inside effects.
  1889. reactivity.pauseTracking();
  1890. // Set currentInstance during hook invocation.
  1891. // This assumes the hook does not synchronously trigger other hooks, which
  1892. // can only be false when the user does something really funky.
  1893. setCurrentInstance(target);
  1894. const res = callWithAsyncErrorHandling(hook, target, type, args);
  1895. setCurrentInstance(null);
  1896. reactivity.resetTracking();
  1897. return res;
  1898. });
  1899. if (prepend) {
  1900. hooks.unshift(wrappedHook);
  1901. }
  1902. else {
  1903. hooks.push(wrappedHook);
  1904. }
  1905. return wrappedHook;
  1906. }
  1907. else {
  1908. const apiName = shared.toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  1909. warn(`${apiName} is called when there is no active component instance to be ` +
  1910. `associated with. ` +
  1911. `Lifecycle injection APIs can only be used during execution of setup().` +
  1912. (` If you are using async setup(), make sure to register lifecycle ` +
  1913. `hooks before the first await statement.`
  1914. ));
  1915. }
  1916. }
  1917. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  1918. // post-create lifecycle registrations are noops during SSR
  1919. !isInSSRComponentSetup && injectHook(lifecycle, hook, target);
  1920. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  1921. const onMounted = createHook("m" /* MOUNTED */);
  1922. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  1923. const onUpdated = createHook("u" /* UPDATED */);
  1924. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  1925. const onUnmounted = createHook("um" /* UNMOUNTED */);
  1926. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  1927. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  1928. const onErrorCaptured = (hook, target = currentInstance) => {
  1929. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  1930. };
  1931. // Simple effect.
  1932. function watchEffect(effect, options) {
  1933. return doWatch(effect, null, options);
  1934. }
  1935. // initial value for watchers to trigger on undefined initial values
  1936. const INITIAL_WATCHER_VALUE = {};
  1937. // implementation
  1938. function watch(source, cb, options) {
  1939. if (!shared.isFunction(cb)) {
  1940. warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  1941. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  1942. `supports \`watch(source, cb, options?) signature.`);
  1943. }
  1944. return doWatch(source, cb, options);
  1945. }
  1946. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = shared.EMPTY_OBJ, instance = currentInstance) {
  1947. if (!cb) {
  1948. if (immediate !== undefined) {
  1949. warn(`watch() "immediate" option is only respected when using the ` +
  1950. `watch(source, callback, options?) signature.`);
  1951. }
  1952. if (deep !== undefined) {
  1953. warn(`watch() "deep" option is only respected when using the ` +
  1954. `watch(source, callback, options?) signature.`);
  1955. }
  1956. }
  1957. const warnInvalidSource = (s) => {
  1958. warn(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  1959. `a reactive object, or an array of these types.`);
  1960. };
  1961. let getter;
  1962. let forceTrigger = false;
  1963. if (reactivity.isRef(source)) {
  1964. getter = () => source.value;
  1965. forceTrigger = !!source._shallow;
  1966. }
  1967. else if (reactivity.isReactive(source)) {
  1968. getter = () => source;
  1969. deep = true;
  1970. }
  1971. else if (shared.isArray(source)) {
  1972. getter = () => source.map(s => {
  1973. if (reactivity.isRef(s)) {
  1974. return s.value;
  1975. }
  1976. else if (reactivity.isReactive(s)) {
  1977. return traverse(s);
  1978. }
  1979. else if (shared.isFunction(s)) {
  1980. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */, [
  1981. instance && instance.proxy
  1982. ]);
  1983. }
  1984. else {
  1985. warnInvalidSource(s);
  1986. }
  1987. });
  1988. }
  1989. else if (shared.isFunction(source)) {
  1990. if (cb) {
  1991. // getter with cb
  1992. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */, [
  1993. instance && instance.proxy
  1994. ]);
  1995. }
  1996. else {
  1997. // no cb -> simple effect
  1998. getter = () => {
  1999. if (instance && instance.isUnmounted) {
  2000. return;
  2001. }
  2002. if (cleanup) {
  2003. cleanup();
  2004. }
  2005. return callWithErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]);
  2006. };
  2007. }
  2008. }
  2009. else {
  2010. getter = shared.NOOP;
  2011. warnInvalidSource(source);
  2012. }
  2013. if (cb && deep) {
  2014. const baseGetter = getter;
  2015. getter = () => traverse(baseGetter());
  2016. }
  2017. let cleanup;
  2018. const onInvalidate = (fn) => {
  2019. cleanup = runner.options.onStop = () => {
  2020. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  2021. };
  2022. };
  2023. // in SSR there is no need to setup an actual effect, and it should be noop
  2024. // unless it's eager
  2025. if (isInSSRComponentSetup) {
  2026. if (!cb) {
  2027. getter();
  2028. }
  2029. else if (immediate) {
  2030. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  2031. getter(),
  2032. undefined,
  2033. onInvalidate
  2034. ]);
  2035. }
  2036. return shared.NOOP;
  2037. }
  2038. let oldValue = shared.isArray(source) ? [] : INITIAL_WATCHER_VALUE;
  2039. const job = () => {
  2040. if (!runner.active) {
  2041. return;
  2042. }
  2043. if (cb) {
  2044. // watch(source, cb)
  2045. const newValue = runner();
  2046. if (deep || forceTrigger || shared.hasChanged(newValue, oldValue)) {
  2047. // cleanup before running cb again
  2048. if (cleanup) {
  2049. cleanup();
  2050. }
  2051. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  2052. newValue,
  2053. // pass undefined as the old value when it's changed for the first time
  2054. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  2055. onInvalidate
  2056. ]);
  2057. oldValue = newValue;
  2058. }
  2059. }
  2060. else {
  2061. // watchEffect
  2062. runner();
  2063. }
  2064. };
  2065. // important: mark the job as a watcher callback so that scheduler knows
  2066. // it is allowed to self-trigger (#1727)
  2067. job.allowRecurse = !!cb;
  2068. let scheduler;
  2069. if (flush === 'sync') {
  2070. scheduler = job;
  2071. }
  2072. else if (flush === 'post') {
  2073. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  2074. }
  2075. else {
  2076. // default: 'pre'
  2077. scheduler = () => {
  2078. if (!instance || instance.isMounted) {
  2079. queuePreFlushCb(job);
  2080. }
  2081. else {
  2082. // with 'pre' option, the first call must happen before
  2083. // the component is mounted so it is called synchronously.
  2084. job();
  2085. }
  2086. };
  2087. }
  2088. const runner = reactivity.effect(getter, {
  2089. lazy: true,
  2090. onTrack,
  2091. onTrigger,
  2092. scheduler
  2093. });
  2094. recordInstanceBoundEffect(runner, instance);
  2095. // initial run
  2096. if (cb) {
  2097. if (immediate) {
  2098. job();
  2099. }
  2100. else {
  2101. oldValue = runner();
  2102. }
  2103. }
  2104. else if (flush === 'post') {
  2105. queuePostRenderEffect(runner, instance && instance.suspense);
  2106. }
  2107. else {
  2108. runner();
  2109. }
  2110. return () => {
  2111. reactivity.stop(runner);
  2112. if (instance) {
  2113. shared.remove(instance.effects, runner);
  2114. }
  2115. };
  2116. }
  2117. // this.$watch
  2118. function instanceWatch(source, cb, options) {
  2119. const publicThis = this.proxy;
  2120. const getter = shared.isString(source)
  2121. ? () => publicThis[source]
  2122. : source.bind(publicThis);
  2123. return doWatch(getter, cb.bind(publicThis), options, this);
  2124. }
  2125. function traverse(value, seen = new Set()) {
  2126. if (!shared.isObject(value) || seen.has(value)) {
  2127. return value;
  2128. }
  2129. seen.add(value);
  2130. if (reactivity.isRef(value)) {
  2131. traverse(value.value, seen);
  2132. }
  2133. else if (shared.isArray(value)) {
  2134. for (let i = 0; i < value.length; i++) {
  2135. traverse(value[i], seen);
  2136. }
  2137. }
  2138. else if (shared.isSet(value) || shared.isMap(value)) {
  2139. value.forEach((v) => {
  2140. traverse(v, seen);
  2141. });
  2142. }
  2143. else {
  2144. for (const key in value) {
  2145. traverse(value[key], seen);
  2146. }
  2147. }
  2148. return value;
  2149. }
  2150. function useTransitionState() {
  2151. const state = {
  2152. isMounted: false,
  2153. isLeaving: false,
  2154. isUnmounting: false,
  2155. leavingVNodes: new Map()
  2156. };
  2157. onMounted(() => {
  2158. state.isMounted = true;
  2159. });
  2160. onBeforeUnmount(() => {
  2161. state.isUnmounting = true;
  2162. });
  2163. return state;
  2164. }
  2165. const TransitionHookValidator = [Function, Array];
  2166. const BaseTransitionImpl = {
  2167. name: `BaseTransition`,
  2168. props: {
  2169. mode: String,
  2170. appear: Boolean,
  2171. persisted: Boolean,
  2172. // enter
  2173. onBeforeEnter: TransitionHookValidator,
  2174. onEnter: TransitionHookValidator,
  2175. onAfterEnter: TransitionHookValidator,
  2176. onEnterCancelled: TransitionHookValidator,
  2177. // leave
  2178. onBeforeLeave: TransitionHookValidator,
  2179. onLeave: TransitionHookValidator,
  2180. onAfterLeave: TransitionHookValidator,
  2181. onLeaveCancelled: TransitionHookValidator,
  2182. // appear
  2183. onBeforeAppear: TransitionHookValidator,
  2184. onAppear: TransitionHookValidator,
  2185. onAfterAppear: TransitionHookValidator,
  2186. onAppearCancelled: TransitionHookValidator
  2187. },
  2188. setup(props, { slots }) {
  2189. const instance = getCurrentInstance();
  2190. const state = useTransitionState();
  2191. let prevTransitionKey;
  2192. return () => {
  2193. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  2194. if (!children || !children.length) {
  2195. return;
  2196. }
  2197. // warn multiple elements
  2198. if (children.length > 1) {
  2199. warn('<transition> can only be used on a single element or component. Use ' +
  2200. '<transition-group> for lists.');
  2201. }
  2202. // there's no need to track reactivity for these props so use the raw
  2203. // props for a bit better perf
  2204. const rawProps = reactivity.toRaw(props);
  2205. const { mode } = rawProps;
  2206. // check mode
  2207. if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
  2208. warn(`invalid <transition> mode: ${mode}`);
  2209. }
  2210. // at this point children has a guaranteed length of 1.
  2211. const child = children[0];
  2212. if (state.isLeaving) {
  2213. return emptyPlaceholder(child);
  2214. }
  2215. // in the case of <transition><keep-alive/></transition>, we need to
  2216. // compare the type of the kept-alive children.
  2217. const innerChild = getKeepAliveChild(child);
  2218. if (!innerChild) {
  2219. return emptyPlaceholder(child);
  2220. }
  2221. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  2222. setTransitionHooks(innerChild, enterHooks);
  2223. const oldChild = instance.subTree;
  2224. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  2225. let transitionKeyChanged = false;
  2226. const { getTransitionKey } = innerChild.type;
  2227. if (getTransitionKey) {
  2228. const key = getTransitionKey();
  2229. if (prevTransitionKey === undefined) {
  2230. prevTransitionKey = key;
  2231. }
  2232. else if (key !== prevTransitionKey) {
  2233. prevTransitionKey = key;
  2234. transitionKeyChanged = true;
  2235. }
  2236. }
  2237. // handle mode
  2238. if (oldInnerChild &&
  2239. oldInnerChild.type !== Comment &&
  2240. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  2241. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  2242. // update old tree's hooks in case of dynamic transition
  2243. setTransitionHooks(oldInnerChild, leavingHooks);
  2244. // switching between different views
  2245. if (mode === 'out-in') {
  2246. state.isLeaving = true;
  2247. // return placeholder node and queue update when leave finishes
  2248. leavingHooks.afterLeave = () => {
  2249. state.isLeaving = false;
  2250. instance.update();
  2251. };
  2252. return emptyPlaceholder(child);
  2253. }
  2254. else if (mode === 'in-out') {
  2255. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  2256. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  2257. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  2258. // early removal callback
  2259. el._leaveCb = () => {
  2260. earlyRemove();
  2261. el._leaveCb = undefined;
  2262. delete enterHooks.delayedLeave;
  2263. };
  2264. enterHooks.delayedLeave = delayedLeave;
  2265. };
  2266. }
  2267. }
  2268. return child;
  2269. };
  2270. }
  2271. };
  2272. // export the public type for h/tsx inference
  2273. // also to avoid inline import() in generated d.ts files
  2274. const BaseTransition = BaseTransitionImpl;
  2275. function getLeavingNodesForType(state, vnode) {
  2276. const { leavingVNodes } = state;
  2277. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  2278. if (!leavingVNodesCache) {
  2279. leavingVNodesCache = Object.create(null);
  2280. leavingVNodes.set(vnode.type, leavingVNodesCache);
  2281. }
  2282. return leavingVNodesCache;
  2283. }
  2284. // The transition hooks are attached to the vnode as vnode.transition
  2285. // and will be called at appropriate timing in the renderer.
  2286. function resolveTransitionHooks(vnode, props, state, instance) {
  2287. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  2288. const key = String(vnode.key);
  2289. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  2290. const callHook = (hook, args) => {
  2291. hook &&
  2292. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  2293. };
  2294. const hooks = {
  2295. mode,
  2296. persisted,
  2297. beforeEnter(el) {
  2298. let hook = onBeforeEnter;
  2299. if (!state.isMounted) {
  2300. if (appear) {
  2301. hook = onBeforeAppear || onBeforeEnter;
  2302. }
  2303. else {
  2304. return;
  2305. }
  2306. }
  2307. // for same element (v-show)
  2308. if (el._leaveCb) {
  2309. el._leaveCb(true /* cancelled */);
  2310. }
  2311. // for toggled element with same key (v-if)
  2312. const leavingVNode = leavingVNodesCache[key];
  2313. if (leavingVNode &&
  2314. isSameVNodeType(vnode, leavingVNode) &&
  2315. leavingVNode.el._leaveCb) {
  2316. // force early removal (not cancelled)
  2317. leavingVNode.el._leaveCb();
  2318. }
  2319. callHook(hook, [el]);
  2320. },
  2321. enter(el) {
  2322. let hook = onEnter;
  2323. let afterHook = onAfterEnter;
  2324. let cancelHook = onEnterCancelled;
  2325. if (!state.isMounted) {
  2326. if (appear) {
  2327. hook = onAppear || onEnter;
  2328. afterHook = onAfterAppear || onAfterEnter;
  2329. cancelHook = onAppearCancelled || onEnterCancelled;
  2330. }
  2331. else {
  2332. return;
  2333. }
  2334. }
  2335. let called = false;
  2336. const done = (el._enterCb = (cancelled) => {
  2337. if (called)
  2338. return;
  2339. called = true;
  2340. if (cancelled) {
  2341. callHook(cancelHook, [el]);
  2342. }
  2343. else {
  2344. callHook(afterHook, [el]);
  2345. }
  2346. if (hooks.delayedLeave) {
  2347. hooks.delayedLeave();
  2348. }
  2349. el._enterCb = undefined;
  2350. });
  2351. if (hook) {
  2352. hook(el, done);
  2353. if (hook.length <= 1) {
  2354. done();
  2355. }
  2356. }
  2357. else {
  2358. done();
  2359. }
  2360. },
  2361. leave(el, remove) {
  2362. const key = String(vnode.key);
  2363. if (el._enterCb) {
  2364. el._enterCb(true /* cancelled */);
  2365. }
  2366. if (state.isUnmounting) {
  2367. return remove();
  2368. }
  2369. callHook(onBeforeLeave, [el]);
  2370. let called = false;
  2371. const done = (el._leaveCb = (cancelled) => {
  2372. if (called)
  2373. return;
  2374. called = true;
  2375. remove();
  2376. if (cancelled) {
  2377. callHook(onLeaveCancelled, [el]);
  2378. }
  2379. else {
  2380. callHook(onAfterLeave, [el]);
  2381. }
  2382. el._leaveCb = undefined;
  2383. if (leavingVNodesCache[key] === vnode) {
  2384. delete leavingVNodesCache[key];
  2385. }
  2386. });
  2387. leavingVNodesCache[key] = vnode;
  2388. if (onLeave) {
  2389. onLeave(el, done);
  2390. if (onLeave.length <= 1) {
  2391. done();
  2392. }
  2393. }
  2394. else {
  2395. done();
  2396. }
  2397. },
  2398. clone(vnode) {
  2399. return resolveTransitionHooks(vnode, props, state, instance);
  2400. }
  2401. };
  2402. return hooks;
  2403. }
  2404. // the placeholder really only handles one special case: KeepAlive
  2405. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  2406. // placeholder with empty content to avoid the KeepAlive instance from being
  2407. // unmounted.
  2408. function emptyPlaceholder(vnode) {
  2409. if (isKeepAlive(vnode)) {
  2410. vnode = cloneVNode(vnode);
  2411. vnode.children = null;
  2412. return vnode;
  2413. }
  2414. }
  2415. function getKeepAliveChild(vnode) {
  2416. return isKeepAlive(vnode)
  2417. ? vnode.children
  2418. ? vnode.children[0]
  2419. : undefined
  2420. : vnode;
  2421. }
  2422. function setTransitionHooks(vnode, hooks) {
  2423. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  2424. setTransitionHooks(vnode.component.subTree, hooks);
  2425. }
  2426. else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  2427. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  2428. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  2429. }
  2430. else {
  2431. vnode.transition = hooks;
  2432. }
  2433. }
  2434. function getTransitionRawChildren(children, keepComment = false) {
  2435. let ret = [];
  2436. let keyedFragmentCount = 0;
  2437. for (let i = 0; i < children.length; i++) {
  2438. const child = children[i];
  2439. // handle fragment children case, e.g. v-for
  2440. if (child.type === Fragment) {
  2441. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  2442. keyedFragmentCount++;
  2443. ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
  2444. }
  2445. // comment placeholders should be skipped, e.g. v-if
  2446. else if (keepComment || child.type !== Comment) {
  2447. ret.push(child);
  2448. }
  2449. }
  2450. // #1126 if a transition children list contains multiple sub fragments, these
  2451. // fragments will be merged into a flat children array. Since each v-for
  2452. // fragment may contain different static bindings inside, we need to de-op
  2453. // these children to force full diffs to ensure correct behavior.
  2454. if (keyedFragmentCount > 1) {
  2455. for (let i = 0; i < ret.length; i++) {
  2456. ret[i].patchFlag = -2 /* BAIL */;
  2457. }
  2458. }
  2459. return ret;
  2460. }
  2461. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  2462. const KeepAliveImpl = {
  2463. name: `KeepAlive`,
  2464. // Marker for special handling inside the renderer. We are not using a ===
  2465. // check directly on KeepAlive in the renderer, because importing it directly
  2466. // would prevent it from being tree-shaken.
  2467. __isKeepAlive: true,
  2468. props: {
  2469. include: [String, RegExp, Array],
  2470. exclude: [String, RegExp, Array],
  2471. max: [String, Number]
  2472. },
  2473. setup(props, { slots }) {
  2474. const cache = new Map();
  2475. const keys = new Set();
  2476. let current = null;
  2477. const instance = getCurrentInstance();
  2478. const parentSuspense = instance.suspense;
  2479. // KeepAlive communicates with the instantiated renderer via the
  2480. // ctx where the renderer passes in its internals,
  2481. // and the KeepAlive instance exposes activate/deactivate implementations.
  2482. // The whole point of this is to avoid importing KeepAlive directly in the
  2483. // renderer to facilitate tree-shaking.
  2484. const sharedContext = instance.ctx;
  2485. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  2486. const storageContainer = createElement('div');
  2487. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  2488. const instance = vnode.component;
  2489. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  2490. // in case props have changed
  2491. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, optimized);
  2492. queuePostRenderEffect(() => {
  2493. instance.isDeactivated = false;
  2494. if (instance.a) {
  2495. shared.invokeArrayFns(instance.a);
  2496. }
  2497. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  2498. if (vnodeHook) {
  2499. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  2500. }
  2501. }, parentSuspense);
  2502. };
  2503. sharedContext.deactivate = (vnode) => {
  2504. const instance = vnode.component;
  2505. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  2506. queuePostRenderEffect(() => {
  2507. if (instance.da) {
  2508. shared.invokeArrayFns(instance.da);
  2509. }
  2510. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  2511. if (vnodeHook) {
  2512. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  2513. }
  2514. instance.isDeactivated = true;
  2515. }, parentSuspense);
  2516. };
  2517. function unmount(vnode) {
  2518. // reset the shapeFlag so it can be properly unmounted
  2519. resetShapeFlag(vnode);
  2520. _unmount(vnode, instance, parentSuspense);
  2521. }
  2522. function pruneCache(filter) {
  2523. cache.forEach((vnode, key) => {
  2524. const name = getComponentName(vnode.type);
  2525. if (name && (!filter || !filter(name))) {
  2526. pruneCacheEntry(key);
  2527. }
  2528. });
  2529. }
  2530. function pruneCacheEntry(key) {
  2531. const cached = cache.get(key);
  2532. if (!current || cached.type !== current.type) {
  2533. unmount(cached);
  2534. }
  2535. else if (current) {
  2536. // current active instance should no longer be kept-alive.
  2537. // we can't unmount it now but it might be later, so reset its flag now.
  2538. resetShapeFlag(current);
  2539. }
  2540. cache.delete(key);
  2541. keys.delete(key);
  2542. }
  2543. // prune cache on include/exclude prop change
  2544. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  2545. include && pruneCache(name => matches(include, name));
  2546. exclude && pruneCache(name => !matches(exclude, name));
  2547. },
  2548. // prune post-render after `current` has been updated
  2549. { flush: 'post', deep: true });
  2550. // cache sub tree after render
  2551. let pendingCacheKey = null;
  2552. const cacheSubtree = () => {
  2553. // fix #1621, the pendingCacheKey could be 0
  2554. if (pendingCacheKey != null) {
  2555. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  2556. }
  2557. };
  2558. onMounted(cacheSubtree);
  2559. onUpdated(cacheSubtree);
  2560. onBeforeUnmount(() => {
  2561. cache.forEach(cached => {
  2562. const { subTree, suspense } = instance;
  2563. const vnode = getInnerChild(subTree);
  2564. if (cached.type === vnode.type) {
  2565. // current instance will be unmounted as part of keep-alive's unmount
  2566. resetShapeFlag(vnode);
  2567. // but invoke its deactivated hook here
  2568. const da = vnode.component.da;
  2569. da && queuePostRenderEffect(da, suspense);
  2570. return;
  2571. }
  2572. unmount(cached);
  2573. });
  2574. });
  2575. return () => {
  2576. pendingCacheKey = null;
  2577. if (!slots.default) {
  2578. return null;
  2579. }
  2580. const children = slots.default();
  2581. const rawVNode = children[0];
  2582. if (children.length > 1) {
  2583. {
  2584. warn(`KeepAlive should contain exactly one component child.`);
  2585. }
  2586. current = null;
  2587. return children;
  2588. }
  2589. else if (!isVNode(rawVNode) ||
  2590. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  2591. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  2592. current = null;
  2593. return rawVNode;
  2594. }
  2595. let vnode = getInnerChild(rawVNode);
  2596. const comp = vnode.type;
  2597. const name = getComponentName(comp);
  2598. const { include, exclude, max } = props;
  2599. if ((include && (!name || !matches(include, name))) ||
  2600. (exclude && name && matches(exclude, name))) {
  2601. current = vnode;
  2602. return rawVNode;
  2603. }
  2604. const key = vnode.key == null ? comp : vnode.key;
  2605. const cachedVNode = cache.get(key);
  2606. // clone vnode if it's reused because we are going to mutate it
  2607. if (vnode.el) {
  2608. vnode = cloneVNode(vnode);
  2609. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  2610. rawVNode.ssContent = vnode;
  2611. }
  2612. }
  2613. // #1513 it's possible for the returned vnode to be cloned due to attr
  2614. // fallthrough or scopeId, so the vnode here may not be the final vnode
  2615. // that is mounted. Instead of caching it directly, we store the pending
  2616. // key and cache `instance.subTree` (the normalized vnode) in
  2617. // beforeMount/beforeUpdate hooks.
  2618. pendingCacheKey = key;
  2619. if (cachedVNode) {
  2620. // copy over mounted state
  2621. vnode.el = cachedVNode.el;
  2622. vnode.component = cachedVNode.component;
  2623. if (vnode.transition) {
  2624. // recursively update transition hooks on subTree
  2625. setTransitionHooks(vnode, vnode.transition);
  2626. }
  2627. // avoid vnode being mounted as fresh
  2628. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  2629. // make this key the freshest
  2630. keys.delete(key);
  2631. keys.add(key);
  2632. }
  2633. else {
  2634. keys.add(key);
  2635. // prune oldest entry
  2636. if (max && keys.size > parseInt(max, 10)) {
  2637. pruneCacheEntry(keys.values().next().value);
  2638. }
  2639. }
  2640. // avoid vnode being unmounted
  2641. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  2642. current = vnode;
  2643. return rawVNode;
  2644. };
  2645. }
  2646. };
  2647. // export the public type for h/tsx inference
  2648. // also to avoid inline import() in generated d.ts files
  2649. const KeepAlive = KeepAliveImpl;
  2650. function matches(pattern, name) {
  2651. if (shared.isArray(pattern)) {
  2652. return pattern.some((p) => matches(p, name));
  2653. }
  2654. else if (shared.isString(pattern)) {
  2655. return pattern.split(',').indexOf(name) > -1;
  2656. }
  2657. else if (pattern.test) {
  2658. return pattern.test(name);
  2659. }
  2660. /* istanbul ignore next */
  2661. return false;
  2662. }
  2663. function onActivated(hook, target) {
  2664. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  2665. }
  2666. function onDeactivated(hook, target) {
  2667. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  2668. }
  2669. function registerKeepAliveHook(hook, type, target = currentInstance) {
  2670. // cache the deactivate branch check wrapper for injected hooks so the same
  2671. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  2672. // deactivation check".
  2673. const wrappedHook = hook.__wdc ||
  2674. (hook.__wdc = () => {
  2675. // only fire the hook if the target instance is NOT in a deactivated branch.
  2676. let current = target;
  2677. while (current) {
  2678. if (current.isDeactivated) {
  2679. return;
  2680. }
  2681. current = current.parent;
  2682. }
  2683. hook();
  2684. });
  2685. injectHook(type, wrappedHook, target);
  2686. // In addition to registering it on the target instance, we walk up the parent
  2687. // chain and register it on all ancestor instances that are keep-alive roots.
  2688. // This avoids the need to walk the entire component tree when invoking these
  2689. // hooks, and more importantly, avoids the need to track child components in
  2690. // arrays.
  2691. if (target) {
  2692. let current = target.parent;
  2693. while (current && current.parent) {
  2694. if (isKeepAlive(current.parent.vnode)) {
  2695. injectToKeepAliveRoot(wrappedHook, type, target, current);
  2696. }
  2697. current = current.parent;
  2698. }
  2699. }
  2700. }
  2701. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  2702. // injectHook wraps the original for error handling, so make sure to remove
  2703. // the wrapped version.
  2704. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  2705. onUnmounted(() => {
  2706. shared.remove(keepAliveRoot[type], injected);
  2707. }, target);
  2708. }
  2709. function resetShapeFlag(vnode) {
  2710. let shapeFlag = vnode.shapeFlag;
  2711. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  2712. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  2713. }
  2714. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  2715. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  2716. }
  2717. vnode.shapeFlag = shapeFlag;
  2718. }
  2719. function getInnerChild(vnode) {
  2720. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  2721. }
  2722. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  2723. const normalizeSlotValue = (value) => shared.isArray(value)
  2724. ? value.map(normalizeVNode)
  2725. : [normalizeVNode(value)];
  2726. const normalizeSlot = (key, rawSlot, ctx) => withCtx((props) => {
  2727. if (currentInstance) {
  2728. warn(`Slot "${key}" invoked outside of the render function: ` +
  2729. `this will not track dependencies used in the slot. ` +
  2730. `Invoke the slot function inside the render function instead.`);
  2731. }
  2732. return normalizeSlotValue(rawSlot(props));
  2733. }, ctx);
  2734. const normalizeObjectSlots = (rawSlots, slots) => {
  2735. const ctx = rawSlots._ctx;
  2736. for (const key in rawSlots) {
  2737. if (isInternalKey(key))
  2738. continue;
  2739. const value = rawSlots[key];
  2740. if (shared.isFunction(value)) {
  2741. slots[key] = normalizeSlot(key, value, ctx);
  2742. }
  2743. else if (value != null) {
  2744. {
  2745. warn(`Non-function value encountered for slot "${key}". ` +
  2746. `Prefer function slots for better performance.`);
  2747. }
  2748. const normalized = normalizeSlotValue(value);
  2749. slots[key] = () => normalized;
  2750. }
  2751. }
  2752. };
  2753. const normalizeVNodeSlots = (instance, children) => {
  2754. if (!isKeepAlive(instance.vnode)) {
  2755. warn(`Non-function value encountered for default slot. ` +
  2756. `Prefer function slots for better performance.`);
  2757. }
  2758. const normalized = normalizeSlotValue(children);
  2759. instance.slots.default = () => normalized;
  2760. };
  2761. const initSlots = (instance, children) => {
  2762. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  2763. const type = children._;
  2764. if (type) {
  2765. instance.slots = children;
  2766. // make compiler marker non-enumerable
  2767. shared.def(children, '_', type);
  2768. }
  2769. else {
  2770. normalizeObjectSlots(children, (instance.slots = {}));
  2771. }
  2772. }
  2773. else {
  2774. instance.slots = {};
  2775. if (children) {
  2776. normalizeVNodeSlots(instance, children);
  2777. }
  2778. }
  2779. shared.def(instance.slots, InternalObjectKey, 1);
  2780. };
  2781. const updateSlots = (instance, children) => {
  2782. const { vnode, slots } = instance;
  2783. let needDeletionCheck = true;
  2784. let deletionComparisonTarget = shared.EMPTY_OBJ;
  2785. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  2786. const type = children._;
  2787. if (type) {
  2788. // compiled slots.
  2789. if (isHmrUpdating) {
  2790. // Parent was HMR updated so slot content may have changed.
  2791. // force update slots and mark instance for hmr as well
  2792. shared.extend(slots, children);
  2793. }
  2794. else if (type === 1 /* STABLE */) {
  2795. // compiled AND stable.
  2796. // no need to update, and skip stale slots removal.
  2797. needDeletionCheck = false;
  2798. }
  2799. else {
  2800. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  2801. // normalization.
  2802. shared.extend(slots, children);
  2803. }
  2804. }
  2805. else {
  2806. needDeletionCheck = !children.$stable;
  2807. normalizeObjectSlots(children, slots);
  2808. }
  2809. deletionComparisonTarget = children;
  2810. }
  2811. else if (children) {
  2812. // non slot object children (direct value) passed to a component
  2813. normalizeVNodeSlots(instance, children);
  2814. deletionComparisonTarget = { default: 1 };
  2815. }
  2816. // delete stale slots
  2817. if (needDeletionCheck) {
  2818. for (const key in slots) {
  2819. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  2820. delete slots[key];
  2821. }
  2822. }
  2823. }
  2824. };
  2825. /**
  2826. Runtime helper for applying directives to a vnode. Example usage:
  2827. const comp = resolveComponent('comp')
  2828. const foo = resolveDirective('foo')
  2829. const bar = resolveDirective('bar')
  2830. return withDirectives(h(comp), [
  2831. [foo, this.x],
  2832. [bar, this.y]
  2833. ])
  2834. */
  2835. const isBuiltInDirective = /*#__PURE__*/ shared.makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
  2836. function validateDirectiveName(name) {
  2837. if (isBuiltInDirective(name)) {
  2838. warn('Do not use built-in directive ids as custom directive id: ' + name);
  2839. }
  2840. }
  2841. /**
  2842. * Adds directives to a VNode.
  2843. */
  2844. function withDirectives(vnode, directives) {
  2845. const internalInstance = currentRenderingInstance;
  2846. if (internalInstance === null) {
  2847. warn(`withDirectives can only be used inside render functions.`);
  2848. return vnode;
  2849. }
  2850. const instance = internalInstance.proxy;
  2851. const bindings = vnode.dirs || (vnode.dirs = []);
  2852. for (let i = 0; i < directives.length; i++) {
  2853. let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
  2854. if (shared.isFunction(dir)) {
  2855. dir = {
  2856. mounted: dir,
  2857. updated: dir
  2858. };
  2859. }
  2860. bindings.push({
  2861. dir,
  2862. instance,
  2863. value,
  2864. oldValue: void 0,
  2865. arg,
  2866. modifiers
  2867. });
  2868. }
  2869. return vnode;
  2870. }
  2871. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  2872. const bindings = vnode.dirs;
  2873. const oldBindings = prevVNode && prevVNode.dirs;
  2874. for (let i = 0; i < bindings.length; i++) {
  2875. const binding = bindings[i];
  2876. if (oldBindings) {
  2877. binding.oldValue = oldBindings[i].value;
  2878. }
  2879. const hook = binding.dir[name];
  2880. if (hook) {
  2881. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  2882. vnode.el,
  2883. binding,
  2884. vnode,
  2885. prevVNode
  2886. ]);
  2887. }
  2888. }
  2889. }
  2890. function createAppContext() {
  2891. return {
  2892. app: null,
  2893. config: {
  2894. isNativeTag: shared.NO,
  2895. performance: false,
  2896. globalProperties: {},
  2897. optionMergeStrategies: {},
  2898. isCustomElement: shared.NO,
  2899. errorHandler: undefined,
  2900. warnHandler: undefined
  2901. },
  2902. mixins: [],
  2903. components: {},
  2904. directives: {},
  2905. provides: Object.create(null)
  2906. };
  2907. }
  2908. let uid = 0;
  2909. function createAppAPI(render, hydrate) {
  2910. return function createApp(rootComponent, rootProps = null) {
  2911. if (rootProps != null && !shared.isObject(rootProps)) {
  2912. warn(`root props passed to app.mount() must be an object.`);
  2913. rootProps = null;
  2914. }
  2915. const context = createAppContext();
  2916. const installedPlugins = new Set();
  2917. let isMounted = false;
  2918. const app = (context.app = {
  2919. _uid: uid++,
  2920. _component: rootComponent,
  2921. _props: rootProps,
  2922. _container: null,
  2923. _context: context,
  2924. version,
  2925. get config() {
  2926. return context.config;
  2927. },
  2928. set config(v) {
  2929. {
  2930. warn(`app.config cannot be replaced. Modify individual options instead.`);
  2931. }
  2932. },
  2933. use(plugin, ...options) {
  2934. if (installedPlugins.has(plugin)) {
  2935. warn(`Plugin has already been applied to target app.`);
  2936. }
  2937. else if (plugin && shared.isFunction(plugin.install)) {
  2938. installedPlugins.add(plugin);
  2939. plugin.install(app, ...options);
  2940. }
  2941. else if (shared.isFunction(plugin)) {
  2942. installedPlugins.add(plugin);
  2943. plugin(app, ...options);
  2944. }
  2945. else {
  2946. warn(`A plugin must either be a function or an object with an "install" ` +
  2947. `function.`);
  2948. }
  2949. return app;
  2950. },
  2951. mixin(mixin) {
  2952. {
  2953. if (!context.mixins.includes(mixin)) {
  2954. context.mixins.push(mixin);
  2955. // global mixin with props/emits de-optimizes props/emits
  2956. // normalization caching.
  2957. if (mixin.props || mixin.emits) {
  2958. context.deopt = true;
  2959. }
  2960. }
  2961. else {
  2962. warn('Mixin has already been applied to target app' +
  2963. (mixin.name ? `: ${mixin.name}` : ''));
  2964. }
  2965. }
  2966. return app;
  2967. },
  2968. component(name, component) {
  2969. {
  2970. validateComponentName(name, context.config);
  2971. }
  2972. if (!component) {
  2973. return context.components[name];
  2974. }
  2975. if (context.components[name]) {
  2976. warn(`Component "${name}" has already been registered in target app.`);
  2977. }
  2978. context.components[name] = component;
  2979. return app;
  2980. },
  2981. directive(name, directive) {
  2982. {
  2983. validateDirectiveName(name);
  2984. }
  2985. if (!directive) {
  2986. return context.directives[name];
  2987. }
  2988. if (context.directives[name]) {
  2989. warn(`Directive "${name}" has already been registered in target app.`);
  2990. }
  2991. context.directives[name] = directive;
  2992. return app;
  2993. },
  2994. mount(rootContainer, isHydrate) {
  2995. if (!isMounted) {
  2996. const vnode = createVNode(rootComponent, rootProps);
  2997. // store app context on the root VNode.
  2998. // this will be set on the root instance on initial mount.
  2999. vnode.appContext = context;
  3000. // HMR root reload
  3001. {
  3002. context.reload = () => {
  3003. render(cloneVNode(vnode), rootContainer);
  3004. };
  3005. }
  3006. if (isHydrate && hydrate) {
  3007. hydrate(vnode, rootContainer);
  3008. }
  3009. else {
  3010. render(vnode, rootContainer);
  3011. }
  3012. isMounted = true;
  3013. app._container = rootContainer;
  3014. rootContainer.__vue_app__ = app;
  3015. {
  3016. devtoolsInitApp(app, version);
  3017. }
  3018. return vnode.component.proxy;
  3019. }
  3020. else {
  3021. warn(`App has already been mounted.\n` +
  3022. `If you want to remount the same app, move your app creation logic ` +
  3023. `into a factory function and create fresh app instances for each ` +
  3024. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  3025. }
  3026. },
  3027. unmount() {
  3028. if (isMounted) {
  3029. render(null, app._container);
  3030. {
  3031. devtoolsUnmountApp(app);
  3032. }
  3033. delete app._container.__vue_app__;
  3034. }
  3035. else {
  3036. warn(`Cannot unmount an app that is not mounted.`);
  3037. }
  3038. },
  3039. provide(key, value) {
  3040. if (key in context.provides) {
  3041. warn(`App already provides property with key "${String(key)}". ` +
  3042. `It will be overwritten with the new value.`);
  3043. }
  3044. // TypeScript doesn't allow symbols as index type
  3045. // https://github.com/Microsoft/TypeScript/issues/24587
  3046. context.provides[key] = value;
  3047. return app;
  3048. }
  3049. });
  3050. return app;
  3051. };
  3052. }
  3053. let hasMismatch = false;
  3054. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  3055. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  3056. // Note: hydration is DOM-specific
  3057. // But we have to place it in core due to tight coupling with core - splitting
  3058. // it out creates a ton of unnecessary complexity.
  3059. // Hydration also depends on some renderer internal logic which needs to be
  3060. // passed in via arguments.
  3061. function createHydrationFunctions(rendererInternals) {
  3062. const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  3063. const hydrate = (vnode, container) => {
  3064. if (!container.hasChildNodes()) {
  3065. warn(`Attempting to hydrate existing markup but container is empty. ` +
  3066. `Performing full mount instead.`);
  3067. patch(null, vnode, container);
  3068. return;
  3069. }
  3070. hasMismatch = false;
  3071. hydrateNode(container.firstChild, vnode, null, null);
  3072. flushPostFlushCbs();
  3073. if (hasMismatch && !false) {
  3074. // this error should show up in production
  3075. console.error(`Hydration completed but contains mismatches.`);
  3076. }
  3077. };
  3078. const hydrateNode = (node, vnode, parentComponent, parentSuspense, optimized = false) => {
  3079. const isFragmentStart = isComment(node) && node.data === '[';
  3080. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, isFragmentStart);
  3081. const { type, ref, shapeFlag } = vnode;
  3082. const domType = node.nodeType;
  3083. vnode.el = node;
  3084. let nextNode = null;
  3085. switch (type) {
  3086. case Text:
  3087. if (domType !== 3 /* TEXT */) {
  3088. nextNode = onMismatch();
  3089. }
  3090. else {
  3091. if (node.data !== vnode.children) {
  3092. hasMismatch = true;
  3093. warn(`Hydration text mismatch:` +
  3094. `\n- Client: ${JSON.stringify(node.data)}` +
  3095. `\n- Server: ${JSON.stringify(vnode.children)}`);
  3096. node.data = vnode.children;
  3097. }
  3098. nextNode = nextSibling(node);
  3099. }
  3100. break;
  3101. case Comment:
  3102. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  3103. nextNode = onMismatch();
  3104. }
  3105. else {
  3106. nextNode = nextSibling(node);
  3107. }
  3108. break;
  3109. case Static:
  3110. if (domType !== 1 /* ELEMENT */) {
  3111. nextNode = onMismatch();
  3112. }
  3113. else {
  3114. // determine anchor, adopt content
  3115. nextNode = node;
  3116. // if the static vnode has its content stripped during build,
  3117. // adopt it from the server-rendered HTML.
  3118. const needToAdoptContent = !vnode.children.length;
  3119. for (let i = 0; i < vnode.staticCount; i++) {
  3120. if (needToAdoptContent)
  3121. vnode.children += nextNode.outerHTML;
  3122. if (i === vnode.staticCount - 1) {
  3123. vnode.anchor = nextNode;
  3124. }
  3125. nextNode = nextSibling(nextNode);
  3126. }
  3127. return nextNode;
  3128. }
  3129. break;
  3130. case Fragment:
  3131. if (!isFragmentStart) {
  3132. nextNode = onMismatch();
  3133. }
  3134. else {
  3135. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, optimized);
  3136. }
  3137. break;
  3138. default:
  3139. if (shapeFlag & 1 /* ELEMENT */) {
  3140. if (domType !== 1 /* ELEMENT */ ||
  3141. vnode.type !== node.tagName.toLowerCase()) {
  3142. nextNode = onMismatch();
  3143. }
  3144. else {
  3145. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, optimized);
  3146. }
  3147. }
  3148. else if (shapeFlag & 6 /* COMPONENT */) {
  3149. // when setting up the render effect, if the initial vnode already
  3150. // has .el set, the component will perform hydration instead of mount
  3151. // on its sub-tree.
  3152. const container = parentNode(node);
  3153. const hydrateComponent = () => {
  3154. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  3155. };
  3156. // async component
  3157. const loadAsync = vnode.type.__asyncLoader;
  3158. if (loadAsync) {
  3159. loadAsync().then(hydrateComponent);
  3160. }
  3161. else {
  3162. hydrateComponent();
  3163. }
  3164. // component may be async, so in the case of fragments we cannot rely
  3165. // on component's rendered output to determine the end of the fragment
  3166. // instead, we do a lookahead to find the end anchor node.
  3167. nextNode = isFragmentStart
  3168. ? locateClosingAsyncAnchor(node)
  3169. : nextSibling(node);
  3170. }
  3171. else if (shapeFlag & 64 /* TELEPORT */) {
  3172. if (domType !== 8 /* COMMENT */) {
  3173. nextNode = onMismatch();
  3174. }
  3175. else {
  3176. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, optimized, rendererInternals, hydrateChildren);
  3177. }
  3178. }
  3179. else if (shapeFlag & 128 /* SUSPENSE */) {
  3180. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), optimized, rendererInternals, hydrateNode);
  3181. }
  3182. else {
  3183. warn('Invalid HostVNode type:', type, `(${typeof type})`);
  3184. }
  3185. }
  3186. if (ref != null) {
  3187. setRef(ref, null, parentSuspense, vnode);
  3188. }
  3189. return nextNode;
  3190. };
  3191. const hydrateElement = (el, vnode, parentComponent, parentSuspense, optimized) => {
  3192. optimized = optimized || !!vnode.dynamicChildren;
  3193. const { props, patchFlag, shapeFlag, dirs } = vnode;
  3194. // skip props & children if this is hoisted static nodes
  3195. if (patchFlag !== -1 /* HOISTED */) {
  3196. if (dirs) {
  3197. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  3198. }
  3199. // props
  3200. if (props) {
  3201. if (!optimized ||
  3202. (patchFlag & 16 /* FULL_PROPS */ ||
  3203. patchFlag & 32 /* HYDRATE_EVENTS */)) {
  3204. for (const key in props) {
  3205. if (!shared.isReservedProp(key) && shared.isOn(key)) {
  3206. patchProp(el, key, null, props[key]);
  3207. }
  3208. }
  3209. }
  3210. else if (props.onClick) {
  3211. // Fast path for click listeners (which is most often) to avoid
  3212. // iterating through props.
  3213. patchProp(el, 'onClick', null, props.onClick);
  3214. }
  3215. }
  3216. // vnode / directive hooks
  3217. let vnodeHooks;
  3218. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  3219. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  3220. }
  3221. if (dirs) {
  3222. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  3223. }
  3224. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  3225. queueEffectWithSuspense(() => {
  3226. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  3227. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  3228. }, parentSuspense);
  3229. }
  3230. // children
  3231. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  3232. // skip if element has innerHTML / textContent
  3233. !(props && (props.innerHTML || props.textContent))) {
  3234. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, optimized);
  3235. let hasWarned = false;
  3236. while (next) {
  3237. hasMismatch = true;
  3238. if (!hasWarned) {
  3239. warn(`Hydration children mismatch in <${vnode.type}>: ` +
  3240. `server rendered element contains more child nodes than client vdom.`);
  3241. hasWarned = true;
  3242. }
  3243. // The SSRed DOM contains more nodes than it should. Remove them.
  3244. const cur = next;
  3245. next = next.nextSibling;
  3246. remove(cur);
  3247. }
  3248. }
  3249. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  3250. if (el.textContent !== vnode.children) {
  3251. hasMismatch = true;
  3252. warn(`Hydration text content mismatch in <${vnode.type}>:\n` +
  3253. `- Client: ${el.textContent}\n` +
  3254. `- Server: ${vnode.children}`);
  3255. el.textContent = vnode.children;
  3256. }
  3257. }
  3258. }
  3259. return el.nextSibling;
  3260. };
  3261. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, optimized) => {
  3262. optimized = optimized || !!parentVNode.dynamicChildren;
  3263. const children = parentVNode.children;
  3264. const l = children.length;
  3265. let hasWarned = false;
  3266. for (let i = 0; i < l; i++) {
  3267. const vnode = optimized
  3268. ? children[i]
  3269. : (children[i] = normalizeVNode(children[i]));
  3270. if (node) {
  3271. node = hydrateNode(node, vnode, parentComponent, parentSuspense, optimized);
  3272. }
  3273. else {
  3274. hasMismatch = true;
  3275. if (!hasWarned) {
  3276. warn(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  3277. `server rendered element contains fewer child nodes than client vdom.`);
  3278. hasWarned = true;
  3279. }
  3280. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  3281. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container));
  3282. }
  3283. }
  3284. return node;
  3285. };
  3286. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, optimized) => {
  3287. const container = parentNode(node);
  3288. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, optimized);
  3289. if (next && isComment(next) && next.data === ']') {
  3290. return nextSibling((vnode.anchor = next));
  3291. }
  3292. else {
  3293. // fragment didn't hydrate successfully, since we didn't get a end anchor
  3294. // back. This should have led to node/children mismatch warnings.
  3295. hasMismatch = true;
  3296. // since the anchor is missing, we need to create one and insert it
  3297. insert((vnode.anchor = createComment(`]`)), container, next);
  3298. return next;
  3299. }
  3300. };
  3301. const handleMismatch = (node, vnode, parentComponent, parentSuspense, isFragment) => {
  3302. hasMismatch = true;
  3303. warn(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  3304. ? `(text)`
  3305. : isComment(node) && node.data === '['
  3306. ? `(start of fragment)`
  3307. : ``);
  3308. vnode.el = null;
  3309. if (isFragment) {
  3310. // remove excessive fragment nodes
  3311. const end = locateClosingAsyncAnchor(node);
  3312. while (true) {
  3313. const next = nextSibling(node);
  3314. if (next && next !== end) {
  3315. remove(next);
  3316. }
  3317. else {
  3318. break;
  3319. }
  3320. }
  3321. }
  3322. const next = nextSibling(node);
  3323. const container = parentNode(node);
  3324. remove(node);
  3325. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container));
  3326. return next;
  3327. };
  3328. const locateClosingAsyncAnchor = (node) => {
  3329. let match = 0;
  3330. while (node) {
  3331. node = nextSibling(node);
  3332. if (node && isComment(node)) {
  3333. if (node.data === '[')
  3334. match++;
  3335. if (node.data === ']') {
  3336. if (match === 0) {
  3337. return nextSibling(node);
  3338. }
  3339. else {
  3340. match--;
  3341. }
  3342. }
  3343. }
  3344. }
  3345. return node;
  3346. };
  3347. return [hydrate, hydrateNode];
  3348. }
  3349. let supported;
  3350. let perf;
  3351. function startMeasure(instance, type) {
  3352. if (instance.appContext.config.performance && isSupported()) {
  3353. perf.mark(`vue-${type}-${instance.uid}`);
  3354. }
  3355. }
  3356. function endMeasure(instance, type) {
  3357. if (instance.appContext.config.performance && isSupported()) {
  3358. const startTag = `vue-${type}-${instance.uid}`;
  3359. const endTag = startTag + `:end`;
  3360. perf.mark(endTag);
  3361. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  3362. perf.clearMarks(startTag);
  3363. perf.clearMarks(endTag);
  3364. }
  3365. }
  3366. function isSupported() {
  3367. if (supported !== undefined) {
  3368. return supported;
  3369. }
  3370. /* eslint-disable no-restricted-globals */
  3371. if (typeof window !== 'undefined' && window.performance) {
  3372. supported = true;
  3373. perf = window.performance;
  3374. }
  3375. else {
  3376. supported = false;
  3377. }
  3378. /* eslint-enable no-restricted-globals */
  3379. return supported;
  3380. }
  3381. // implementation, close to no-op
  3382. function defineComponent(options) {
  3383. return shared.isFunction(options) ? { setup: options, name: options.name } : options;
  3384. }
  3385. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3386. function defineAsyncComponent(source) {
  3387. if (shared.isFunction(source)) {
  3388. source = { loader: source };
  3389. }
  3390. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3391. suspensible = true, onError: userOnError } = source;
  3392. let pendingRequest = null;
  3393. let resolvedComp;
  3394. let retries = 0;
  3395. const retry = () => {
  3396. retries++;
  3397. pendingRequest = null;
  3398. return load();
  3399. };
  3400. const load = () => {
  3401. let thisRequest;
  3402. return (pendingRequest ||
  3403. (thisRequest = pendingRequest = loader()
  3404. .catch(err => {
  3405. err = err instanceof Error ? err : new Error(String(err));
  3406. if (userOnError) {
  3407. return new Promise((resolve, reject) => {
  3408. const userRetry = () => resolve(retry());
  3409. const userFail = () => reject(err);
  3410. userOnError(err, userRetry, userFail, retries + 1);
  3411. });
  3412. }
  3413. else {
  3414. throw err;
  3415. }
  3416. })
  3417. .then((comp) => {
  3418. if (thisRequest !== pendingRequest && pendingRequest) {
  3419. return pendingRequest;
  3420. }
  3421. if (!comp) {
  3422. warn(`Async component loader resolved to undefined. ` +
  3423. `If you are using retry(), make sure to return its return value.`);
  3424. }
  3425. // interop module default
  3426. if (comp &&
  3427. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3428. comp = comp.default;
  3429. }
  3430. if (comp && !shared.isObject(comp) && !shared.isFunction(comp)) {
  3431. throw new Error(`Invalid async component load result: ${comp}`);
  3432. }
  3433. resolvedComp = comp;
  3434. return comp;
  3435. })));
  3436. };
  3437. return defineComponent({
  3438. __asyncLoader: load,
  3439. name: 'AsyncComponentWrapper',
  3440. setup() {
  3441. const instance = currentInstance;
  3442. // already resolved
  3443. if (resolvedComp) {
  3444. return () => createInnerComp(resolvedComp, instance);
  3445. }
  3446. const onError = (err) => {
  3447. pendingRequest = null;
  3448. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3449. };
  3450. // suspense-controlled or SSR.
  3451. if ((suspensible && instance.suspense) ||
  3452. (isInSSRComponentSetup)) {
  3453. return load()
  3454. .then(comp => {
  3455. return () => createInnerComp(comp, instance);
  3456. })
  3457. .catch(err => {
  3458. onError(err);
  3459. return () => errorComponent
  3460. ? createVNode(errorComponent, {
  3461. error: err
  3462. })
  3463. : null;
  3464. });
  3465. }
  3466. const loaded = reactivity.ref(false);
  3467. const error = reactivity.ref();
  3468. const delayed = reactivity.ref(!!delay);
  3469. if (delay) {
  3470. setTimeout(() => {
  3471. delayed.value = false;
  3472. }, delay);
  3473. }
  3474. if (timeout != null) {
  3475. setTimeout(() => {
  3476. if (!loaded.value && !error.value) {
  3477. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3478. onError(err);
  3479. error.value = err;
  3480. }
  3481. }, timeout);
  3482. }
  3483. load()
  3484. .then(() => {
  3485. loaded.value = true;
  3486. })
  3487. .catch(err => {
  3488. onError(err);
  3489. error.value = err;
  3490. });
  3491. return () => {
  3492. if (loaded.value && resolvedComp) {
  3493. return createInnerComp(resolvedComp, instance);
  3494. }
  3495. else if (error.value && errorComponent) {
  3496. return createVNode(errorComponent, {
  3497. error: error.value
  3498. });
  3499. }
  3500. else if (loadingComponent && !delayed.value) {
  3501. return createVNode(loadingComponent);
  3502. }
  3503. };
  3504. }
  3505. });
  3506. }
  3507. function createInnerComp(comp, { vnode: { ref, props, children } }) {
  3508. const vnode = createVNode(comp, props, children);
  3509. // ensure inner component inherits the async wrapper's ref owner
  3510. vnode.ref = ref;
  3511. return vnode;
  3512. }
  3513. function createDevEffectOptions(instance) {
  3514. return {
  3515. scheduler: queueJob,
  3516. allowRecurse: true,
  3517. onTrack: instance.rtc ? e => shared.invokeArrayFns(instance.rtc, e) : void 0,
  3518. onTrigger: instance.rtg ? e => shared.invokeArrayFns(instance.rtg, e) : void 0
  3519. };
  3520. }
  3521. const queuePostRenderEffect = queueEffectWithSuspense
  3522. ;
  3523. const setRef = (rawRef, oldRawRef, parentSuspense, vnode) => {
  3524. if (shared.isArray(rawRef)) {
  3525. rawRef.forEach((r, i) => setRef(r, oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode));
  3526. return;
  3527. }
  3528. let value;
  3529. if (!vnode || isAsyncWrapper(vnode)) {
  3530. value = null;
  3531. }
  3532. else {
  3533. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  3534. value = vnode.component.exposed || vnode.component.proxy;
  3535. }
  3536. else {
  3537. value = vnode.el;
  3538. }
  3539. }
  3540. const { i: owner, r: ref } = rawRef;
  3541. if (!owner) {
  3542. warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  3543. `A vnode with ref must be created inside the render function.`);
  3544. return;
  3545. }
  3546. const oldRef = oldRawRef && oldRawRef.r;
  3547. const refs = owner.refs === shared.EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  3548. const setupState = owner.setupState;
  3549. // unset old ref
  3550. if (oldRef != null && oldRef !== ref) {
  3551. if (shared.isString(oldRef)) {
  3552. refs[oldRef] = null;
  3553. if (shared.hasOwn(setupState, oldRef)) {
  3554. setupState[oldRef] = null;
  3555. }
  3556. }
  3557. else if (reactivity.isRef(oldRef)) {
  3558. oldRef.value = null;
  3559. }
  3560. }
  3561. if (shared.isString(ref)) {
  3562. const doSet = () => {
  3563. refs[ref] = value;
  3564. if (shared.hasOwn(setupState, ref)) {
  3565. setupState[ref] = value;
  3566. }
  3567. };
  3568. // #1789: for non-null values, set them after render
  3569. // null values means this is unmount and it should not overwrite another
  3570. // ref with the same key
  3571. if (value) {
  3572. doSet.id = -1;
  3573. queuePostRenderEffect(doSet, parentSuspense);
  3574. }
  3575. else {
  3576. doSet();
  3577. }
  3578. }
  3579. else if (reactivity.isRef(ref)) {
  3580. const doSet = () => {
  3581. ref.value = value;
  3582. };
  3583. if (value) {
  3584. doSet.id = -1;
  3585. queuePostRenderEffect(doSet, parentSuspense);
  3586. }
  3587. else {
  3588. doSet();
  3589. }
  3590. }
  3591. else if (shared.isFunction(ref)) {
  3592. callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
  3593. }
  3594. else {
  3595. warn('Invalid template ref type:', value, `(${typeof value})`);
  3596. }
  3597. };
  3598. /**
  3599. * The createRenderer function accepts two generic arguments:
  3600. * HostNode and HostElement, corresponding to Node and Element types in the
  3601. * host environment. For example, for runtime-dom, HostNode would be the DOM
  3602. * `Node` interface and HostElement would be the DOM `Element` interface.
  3603. *
  3604. * Custom renderers can pass in the platform specific types like this:
  3605. *
  3606. * ``` js
  3607. * const { render, createApp } = createRenderer<Node, Element>({
  3608. * patchProp,
  3609. * ...nodeOps
  3610. * })
  3611. * ```
  3612. */
  3613. function createRenderer(options) {
  3614. return baseCreateRenderer(options);
  3615. }
  3616. // Separate API for creating hydration-enabled renderer.
  3617. // Hydration logic is only used when calling this function, making it
  3618. // tree-shakable.
  3619. function createHydrationRenderer(options) {
  3620. return baseCreateRenderer(options, createHydrationFunctions);
  3621. }
  3622. // implementation
  3623. function baseCreateRenderer(options, createHydrationFns) {
  3624. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, forcePatchProp: hostForcePatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
  3625. // Note: functions inside this closure should use `const xxx = () => {}`
  3626. // style in order to prevent being inlined by minifiers.
  3627. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, optimized = false) => {
  3628. // patching & not same type, unmount old tree
  3629. if (n1 && !isSameVNodeType(n1, n2)) {
  3630. anchor = getNextHostNode(n1);
  3631. unmount(n1, parentComponent, parentSuspense, true);
  3632. n1 = null;
  3633. }
  3634. if (n2.patchFlag === -2 /* BAIL */) {
  3635. optimized = false;
  3636. n2.dynamicChildren = null;
  3637. }
  3638. const { type, ref, shapeFlag } = n2;
  3639. switch (type) {
  3640. case Text:
  3641. processText(n1, n2, container, anchor);
  3642. break;
  3643. case Comment:
  3644. processCommentNode(n1, n2, container, anchor);
  3645. break;
  3646. case Static:
  3647. if (n1 == null) {
  3648. mountStaticNode(n2, container, anchor, isSVG);
  3649. }
  3650. else {
  3651. patchStaticNode(n1, n2, container, isSVG);
  3652. }
  3653. break;
  3654. case Fragment:
  3655. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  3656. break;
  3657. default:
  3658. if (shapeFlag & 1 /* ELEMENT */) {
  3659. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  3660. }
  3661. else if (shapeFlag & 6 /* COMPONENT */) {
  3662. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  3663. }
  3664. else if (shapeFlag & 64 /* TELEPORT */) {
  3665. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals);
  3666. }
  3667. else if (shapeFlag & 128 /* SUSPENSE */) {
  3668. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals);
  3669. }
  3670. else {
  3671. warn('Invalid VNode type:', type, `(${typeof type})`);
  3672. }
  3673. }
  3674. // set ref
  3675. if (ref != null && parentComponent) {
  3676. setRef(ref, n1 && n1.ref, parentSuspense, n2);
  3677. }
  3678. };
  3679. const processText = (n1, n2, container, anchor) => {
  3680. if (n1 == null) {
  3681. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  3682. }
  3683. else {
  3684. const el = (n2.el = n1.el);
  3685. if (n2.children !== n1.children) {
  3686. hostSetText(el, n2.children);
  3687. }
  3688. }
  3689. };
  3690. const processCommentNode = (n1, n2, container, anchor) => {
  3691. if (n1 == null) {
  3692. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  3693. }
  3694. else {
  3695. // there's no support for dynamic comments
  3696. n2.el = n1.el;
  3697. }
  3698. };
  3699. const mountStaticNode = (n2, container, anchor, isSVG) => {
  3700. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  3701. };
  3702. /**
  3703. * Dev / HMR only
  3704. */
  3705. const patchStaticNode = (n1, n2, container, isSVG) => {
  3706. // static nodes are only patched during dev for HMR
  3707. if (n2.children !== n1.children) {
  3708. const anchor = hostNextSibling(n1.anchor);
  3709. // remove existing
  3710. removeStaticNode(n1);
  3711. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  3712. }
  3713. else {
  3714. n2.el = n1.el;
  3715. n2.anchor = n1.anchor;
  3716. }
  3717. };
  3718. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  3719. let next;
  3720. while (el && el !== anchor) {
  3721. next = hostNextSibling(el);
  3722. hostInsert(el, container, nextSibling);
  3723. el = next;
  3724. }
  3725. hostInsert(anchor, container, nextSibling);
  3726. };
  3727. const removeStaticNode = ({ el, anchor }) => {
  3728. let next;
  3729. while (el && el !== anchor) {
  3730. next = hostNextSibling(el);
  3731. hostRemove(el);
  3732. el = next;
  3733. }
  3734. hostRemove(anchor);
  3735. };
  3736. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  3737. isSVG = isSVG || n2.type === 'svg';
  3738. if (n1 == null) {
  3739. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  3740. }
  3741. else {
  3742. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, optimized);
  3743. }
  3744. };
  3745. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  3746. let el;
  3747. let vnodeHook;
  3748. const { type, props, shapeFlag, transition, scopeId, patchFlag, dirs } = vnode;
  3749. {
  3750. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is);
  3751. // mount children first, since some props may rely on child content
  3752. // being already rendered, e.g. `<select value>`
  3753. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  3754. hostSetElementText(el, vnode.children);
  3755. }
  3756. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  3757. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', optimized || !!vnode.dynamicChildren);
  3758. }
  3759. if (dirs) {
  3760. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  3761. }
  3762. // props
  3763. if (props) {
  3764. for (const key in props) {
  3765. if (!shared.isReservedProp(key)) {
  3766. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  3767. }
  3768. }
  3769. if ((vnodeHook = props.onVnodeBeforeMount)) {
  3770. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  3771. }
  3772. }
  3773. // scopeId
  3774. setScopeId(el, scopeId, vnode, parentComponent);
  3775. }
  3776. {
  3777. Object.defineProperty(el, '__vnode', {
  3778. value: vnode,
  3779. enumerable: false
  3780. });
  3781. Object.defineProperty(el, '__vueParentComponent', {
  3782. value: parentComponent,
  3783. enumerable: false
  3784. });
  3785. }
  3786. if (dirs) {
  3787. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  3788. }
  3789. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  3790. // #1689 For inside suspense + suspense resolved case, just call it
  3791. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  3792. transition &&
  3793. !transition.persisted;
  3794. if (needCallTransitionHooks) {
  3795. transition.beforeEnter(el);
  3796. }
  3797. hostInsert(el, container, anchor);
  3798. if ((vnodeHook = props && props.onVnodeMounted) ||
  3799. needCallTransitionHooks ||
  3800. dirs) {
  3801. queuePostRenderEffect(() => {
  3802. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  3803. needCallTransitionHooks && transition.enter(el);
  3804. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  3805. }, parentSuspense);
  3806. }
  3807. };
  3808. const setScopeId = (el, scopeId, vnode, parentComponent) => {
  3809. if (scopeId) {
  3810. hostSetScopeId(el, scopeId);
  3811. }
  3812. if (parentComponent) {
  3813. const treeOwnerId = parentComponent.type.__scopeId;
  3814. // vnode's own scopeId and the current patched component's scopeId is
  3815. // different - this is a slot content node.
  3816. if (treeOwnerId && treeOwnerId !== scopeId) {
  3817. hostSetScopeId(el, treeOwnerId + '-s');
  3818. }
  3819. let subTree = parentComponent.subTree;
  3820. if (subTree.type === Fragment) {
  3821. subTree =
  3822. filterSingleRoot(subTree.children) || subTree;
  3823. }
  3824. if (vnode === subTree) {
  3825. setScopeId(el, parentComponent.vnode.scopeId, parentComponent.vnode, parentComponent.parent);
  3826. }
  3827. }
  3828. };
  3829. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, optimized, start = 0) => {
  3830. for (let i = start; i < children.length; i++) {
  3831. const child = (children[i] = optimized
  3832. ? cloneIfMounted(children[i])
  3833. : normalizeVNode(children[i]));
  3834. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  3835. }
  3836. };
  3837. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, optimized) => {
  3838. const el = (n2.el = n1.el);
  3839. let { patchFlag, dynamicChildren, dirs } = n2;
  3840. // #1426 take the old vnode's patch flag into account since user may clone a
  3841. // compiler-generated vnode, which de-opts to FULL_PROPS
  3842. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  3843. const oldProps = n1.props || shared.EMPTY_OBJ;
  3844. const newProps = n2.props || shared.EMPTY_OBJ;
  3845. let vnodeHook;
  3846. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  3847. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  3848. }
  3849. if (dirs) {
  3850. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  3851. }
  3852. if (isHmrUpdating) {
  3853. // HMR updated, force full diff
  3854. patchFlag = 0;
  3855. optimized = false;
  3856. dynamicChildren = null;
  3857. }
  3858. if (patchFlag > 0) {
  3859. // the presence of a patchFlag means this element's render code was
  3860. // generated by the compiler and can take the fast path.
  3861. // in this path old node and new node are guaranteed to have the same shape
  3862. // (i.e. at the exact same position in the source template)
  3863. if (patchFlag & 16 /* FULL_PROPS */) {
  3864. // element props contain dynamic keys, full diff needed
  3865. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  3866. }
  3867. else {
  3868. // class
  3869. // this flag is matched when the element has dynamic class bindings.
  3870. if (patchFlag & 2 /* CLASS */) {
  3871. if (oldProps.class !== newProps.class) {
  3872. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  3873. }
  3874. }
  3875. // style
  3876. // this flag is matched when the element has dynamic style bindings
  3877. if (patchFlag & 4 /* STYLE */) {
  3878. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  3879. }
  3880. // props
  3881. // This flag is matched when the element has dynamic prop/attr bindings
  3882. // other than class and style. The keys of dynamic prop/attrs are saved for
  3883. // faster iteration.
  3884. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  3885. // bail out and go through a full diff because we need to unset the old key
  3886. if (patchFlag & 8 /* PROPS */) {
  3887. // if the flag is present then dynamicProps must be non-null
  3888. const propsToUpdate = n2.dynamicProps;
  3889. for (let i = 0; i < propsToUpdate.length; i++) {
  3890. const key = propsToUpdate[i];
  3891. const prev = oldProps[key];
  3892. const next = newProps[key];
  3893. if (next !== prev ||
  3894. (hostForcePatchProp && hostForcePatchProp(el, key))) {
  3895. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  3896. }
  3897. }
  3898. }
  3899. }
  3900. // text
  3901. // This flag is matched when the element has only dynamic text children.
  3902. if (patchFlag & 1 /* TEXT */) {
  3903. if (n1.children !== n2.children) {
  3904. hostSetElementText(el, n2.children);
  3905. }
  3906. }
  3907. }
  3908. else if (!optimized && dynamicChildren == null) {
  3909. // unoptimized, full diff
  3910. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  3911. }
  3912. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  3913. if (dynamicChildren) {
  3914. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG);
  3915. if (parentComponent && parentComponent.type.__hmrId) {
  3916. traverseStaticChildren(n1, n2);
  3917. }
  3918. }
  3919. else if (!optimized) {
  3920. // full diff
  3921. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG);
  3922. }
  3923. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  3924. queuePostRenderEffect(() => {
  3925. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  3926. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  3927. }, parentSuspense);
  3928. }
  3929. };
  3930. // The fast path for blocks.
  3931. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG) => {
  3932. for (let i = 0; i < newChildren.length; i++) {
  3933. const oldVNode = oldChildren[i];
  3934. const newVNode = newChildren[i];
  3935. // Determine the container (parent element) for the patch.
  3936. const container =
  3937. // - In the case of a Fragment, we need to provide the actual parent
  3938. // of the Fragment itself so it can move its children.
  3939. oldVNode.type === Fragment ||
  3940. // - In the case of different nodes, there is going to be a replacement
  3941. // which also requires the correct parent container
  3942. !isSameVNodeType(oldVNode, newVNode) ||
  3943. // - In the case of a component, it could contain anything.
  3944. oldVNode.shapeFlag & 6 /* COMPONENT */ ||
  3945. oldVNode.shapeFlag & 64 /* TELEPORT */
  3946. ? hostParentNode(oldVNode.el)
  3947. : // In other cases, the parent container is not actually used so we
  3948. // just pass the block element here to avoid a DOM parentNode call.
  3949. fallbackContainer;
  3950. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, true);
  3951. }
  3952. };
  3953. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  3954. if (oldProps !== newProps) {
  3955. for (const key in newProps) {
  3956. // empty string is not valid prop
  3957. if (shared.isReservedProp(key))
  3958. continue;
  3959. const next = newProps[key];
  3960. const prev = oldProps[key];
  3961. if (next !== prev ||
  3962. (hostForcePatchProp && hostForcePatchProp(el, key))) {
  3963. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  3964. }
  3965. }
  3966. if (oldProps !== shared.EMPTY_OBJ) {
  3967. for (const key in oldProps) {
  3968. if (!shared.isReservedProp(key) && !(key in newProps)) {
  3969. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  3970. }
  3971. }
  3972. }
  3973. }
  3974. };
  3975. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  3976. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  3977. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  3978. let { patchFlag, dynamicChildren } = n2;
  3979. if (patchFlag > 0) {
  3980. optimized = true;
  3981. }
  3982. if (isHmrUpdating) {
  3983. // HMR updated, force full diff
  3984. patchFlag = 0;
  3985. optimized = false;
  3986. dynamicChildren = null;
  3987. }
  3988. if (n1 == null) {
  3989. hostInsert(fragmentStartAnchor, container, anchor);
  3990. hostInsert(fragmentEndAnchor, container, anchor);
  3991. // a fragment can only have array children
  3992. // since they are either generated by the compiler, or implicitly created
  3993. // from arrays.
  3994. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, optimized);
  3995. }
  3996. else {
  3997. if (patchFlag > 0 &&
  3998. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  3999. dynamicChildren &&
  4000. // #2715 the previous fragment could've been a BAILed one as a result
  4001. // of renderSlot() with no valid children
  4002. n1.dynamicChildren) {
  4003. // a stable fragment (template root or <template v-for>) doesn't need to
  4004. // patch children order, but it may contain dynamicChildren.
  4005. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG);
  4006. if (parentComponent && parentComponent.type.__hmrId) {
  4007. traverseStaticChildren(n1, n2);
  4008. }
  4009. else if (
  4010. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  4011. // get moved around. Make sure all root level vnodes inherit el.
  4012. // #2134 or if it's a component root, it may also get moved around
  4013. // as the component is being moved.
  4014. n2.key != null ||
  4015. (parentComponent && n2 === parentComponent.subTree)) {
  4016. traverseStaticChildren(n1, n2, true /* shallow */);
  4017. }
  4018. }
  4019. else {
  4020. // keyed / unkeyed, or manual fragments.
  4021. // for keyed & unkeyed, since they are compiler generated from v-for,
  4022. // each child is guaranteed to be a block so the fragment will never
  4023. // have dynamicChildren.
  4024. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, optimized);
  4025. }
  4026. }
  4027. };
  4028. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  4029. if (n1 == null) {
  4030. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  4031. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  4032. }
  4033. else {
  4034. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4035. }
  4036. }
  4037. else {
  4038. updateComponent(n1, n2, optimized);
  4039. }
  4040. };
  4041. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  4042. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  4043. if (instance.type.__hmrId) {
  4044. registerHMR(instance);
  4045. }
  4046. {
  4047. pushWarningContext(initialVNode);
  4048. startMeasure(instance, `mount`);
  4049. }
  4050. // inject renderer internals for keepAlive
  4051. if (isKeepAlive(initialVNode)) {
  4052. instance.ctx.renderer = internals;
  4053. }
  4054. // resolve props and slots for setup context
  4055. {
  4056. startMeasure(instance, `init`);
  4057. }
  4058. setupComponent(instance);
  4059. {
  4060. endMeasure(instance, `init`);
  4061. }
  4062. // setup() is async. This component relies on async logic to be resolved
  4063. // before proceeding
  4064. if (instance.asyncDep) {
  4065. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  4066. // Give it a placeholder if this is not hydration
  4067. // TODO handle self-defined fallback
  4068. if (!initialVNode.el) {
  4069. const placeholder = (instance.subTree = createVNode(Comment));
  4070. processCommentNode(null, placeholder, container, anchor);
  4071. }
  4072. return;
  4073. }
  4074. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  4075. {
  4076. popWarningContext();
  4077. endMeasure(instance, `mount`);
  4078. }
  4079. };
  4080. const updateComponent = (n1, n2, optimized) => {
  4081. const instance = (n2.component = n1.component);
  4082. if (shouldUpdateComponent(n1, n2, optimized)) {
  4083. if (instance.asyncDep &&
  4084. !instance.asyncResolved) {
  4085. // async & still pending - just update props and slots
  4086. // since the component's reactive effect for render isn't set-up yet
  4087. {
  4088. pushWarningContext(n2);
  4089. }
  4090. updateComponentPreRender(instance, n2, optimized);
  4091. {
  4092. popWarningContext();
  4093. }
  4094. return;
  4095. }
  4096. else {
  4097. // normal update
  4098. instance.next = n2;
  4099. // in case the child component is also queued, remove it to avoid
  4100. // double updating the same child component in the same flush.
  4101. invalidateJob(instance.update);
  4102. // instance.update is the reactive effect runner.
  4103. instance.update();
  4104. }
  4105. }
  4106. else {
  4107. // no update needed. just copy over properties
  4108. n2.component = n1.component;
  4109. n2.el = n1.el;
  4110. instance.vnode = n2;
  4111. }
  4112. };
  4113. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  4114. // create reactive effect for rendering
  4115. instance.update = reactivity.effect(function componentEffect() {
  4116. if (!instance.isMounted) {
  4117. let vnodeHook;
  4118. const { el, props } = initialVNode;
  4119. const { bm, m, parent } = instance;
  4120. // beforeMount hook
  4121. if (bm) {
  4122. shared.invokeArrayFns(bm);
  4123. }
  4124. // onVnodeBeforeMount
  4125. if ((vnodeHook = props && props.onVnodeBeforeMount)) {
  4126. invokeVNodeHook(vnodeHook, parent, initialVNode);
  4127. }
  4128. // render
  4129. {
  4130. startMeasure(instance, `render`);
  4131. }
  4132. const subTree = (instance.subTree = renderComponentRoot(instance));
  4133. {
  4134. endMeasure(instance, `render`);
  4135. }
  4136. if (el && hydrateNode) {
  4137. {
  4138. startMeasure(instance, `hydrate`);
  4139. }
  4140. // vnode has adopted host node - perform hydration instead of mount.
  4141. hydrateNode(initialVNode.el, subTree, instance, parentSuspense);
  4142. {
  4143. endMeasure(instance, `hydrate`);
  4144. }
  4145. }
  4146. else {
  4147. {
  4148. startMeasure(instance, `patch`);
  4149. }
  4150. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  4151. {
  4152. endMeasure(instance, `patch`);
  4153. }
  4154. initialVNode.el = subTree.el;
  4155. }
  4156. // mounted hook
  4157. if (m) {
  4158. queuePostRenderEffect(m, parentSuspense);
  4159. }
  4160. // onVnodeMounted
  4161. if ((vnodeHook = props && props.onVnodeMounted)) {
  4162. const scopedInitialVNode = initialVNode;
  4163. queuePostRenderEffect(() => {
  4164. invokeVNodeHook(vnodeHook, parent, scopedInitialVNode);
  4165. }, parentSuspense);
  4166. }
  4167. // activated hook for keep-alive roots.
  4168. // #1742 activated hook must be accessed after first render
  4169. // since the hook may be injected by a child keep-alive
  4170. const { a } = instance;
  4171. if (a &&
  4172. initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4173. queuePostRenderEffect(a, parentSuspense);
  4174. }
  4175. instance.isMounted = true;
  4176. {
  4177. devtoolsComponentAdded(instance);
  4178. }
  4179. // #2458: deference mount-only object parameters to prevent memleaks
  4180. initialVNode = container = anchor = null;
  4181. }
  4182. else {
  4183. // updateComponent
  4184. // This is triggered by mutation of component's own state (next: null)
  4185. // OR parent calling processComponent (next: VNode)
  4186. let { next, bu, u, parent, vnode } = instance;
  4187. let originNext = next;
  4188. let vnodeHook;
  4189. {
  4190. pushWarningContext(next || instance.vnode);
  4191. }
  4192. if (next) {
  4193. next.el = vnode.el;
  4194. updateComponentPreRender(instance, next, optimized);
  4195. }
  4196. else {
  4197. next = vnode;
  4198. }
  4199. // beforeUpdate hook
  4200. if (bu) {
  4201. shared.invokeArrayFns(bu);
  4202. }
  4203. // onVnodeBeforeUpdate
  4204. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  4205. invokeVNodeHook(vnodeHook, parent, next, vnode);
  4206. }
  4207. // render
  4208. {
  4209. startMeasure(instance, `render`);
  4210. }
  4211. const nextTree = renderComponentRoot(instance);
  4212. {
  4213. endMeasure(instance, `render`);
  4214. }
  4215. const prevTree = instance.subTree;
  4216. instance.subTree = nextTree;
  4217. {
  4218. startMeasure(instance, `patch`);
  4219. }
  4220. patch(prevTree, nextTree,
  4221. // parent may have changed if it's in a teleport
  4222. hostParentNode(prevTree.el),
  4223. // anchor may have changed if it's in a fragment
  4224. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  4225. {
  4226. endMeasure(instance, `patch`);
  4227. }
  4228. next.el = nextTree.el;
  4229. if (originNext === null) {
  4230. // self-triggered update. In case of HOC, update parent component
  4231. // vnode el. HOC is indicated by parent instance's subTree pointing
  4232. // to child component's vnode
  4233. updateHOCHostEl(instance, nextTree.el);
  4234. }
  4235. // updated hook
  4236. if (u) {
  4237. queuePostRenderEffect(u, parentSuspense);
  4238. }
  4239. // onVnodeUpdated
  4240. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  4241. queuePostRenderEffect(() => {
  4242. invokeVNodeHook(vnodeHook, parent, next, vnode);
  4243. }, parentSuspense);
  4244. }
  4245. {
  4246. devtoolsComponentUpdated(instance);
  4247. }
  4248. {
  4249. popWarningContext();
  4250. }
  4251. }
  4252. }, createDevEffectOptions(instance) );
  4253. };
  4254. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  4255. nextVNode.component = instance;
  4256. const prevProps = instance.vnode.props;
  4257. instance.vnode = nextVNode;
  4258. instance.next = null;
  4259. updateProps(instance, nextVNode.props, prevProps, optimized);
  4260. updateSlots(instance, nextVNode.children);
  4261. // props update may have triggered pre-flush watchers.
  4262. // flush them before the render update.
  4263. flushPreFlushCbs(undefined, instance.update);
  4264. };
  4265. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized = false) => {
  4266. const c1 = n1 && n1.children;
  4267. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  4268. const c2 = n2.children;
  4269. const { patchFlag, shapeFlag } = n2;
  4270. // fast path
  4271. if (patchFlag > 0) {
  4272. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  4273. // this could be either fully-keyed or mixed (some keyed some not)
  4274. // presence of patchFlag means children are guaranteed to be arrays
  4275. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4276. return;
  4277. }
  4278. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  4279. // unkeyed
  4280. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4281. return;
  4282. }
  4283. }
  4284. // children has 3 possibilities: text, array or no children.
  4285. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  4286. // text children fast path
  4287. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  4288. unmountChildren(c1, parentComponent, parentSuspense);
  4289. }
  4290. if (c2 !== c1) {
  4291. hostSetElementText(container, c2);
  4292. }
  4293. }
  4294. else {
  4295. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  4296. // prev children was array
  4297. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  4298. // two arrays, cannot assume anything, do full diff
  4299. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4300. }
  4301. else {
  4302. // no new children, just unmount old
  4303. unmountChildren(c1, parentComponent, parentSuspense, true);
  4304. }
  4305. }
  4306. else {
  4307. // prev children was text OR null
  4308. // new children is array OR null
  4309. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  4310. hostSetElementText(container, '');
  4311. }
  4312. // mount new if array
  4313. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  4314. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4315. }
  4316. }
  4317. }
  4318. };
  4319. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  4320. c1 = c1 || shared.EMPTY_ARR;
  4321. c2 = c2 || shared.EMPTY_ARR;
  4322. const oldLength = c1.length;
  4323. const newLength = c2.length;
  4324. const commonLength = Math.min(oldLength, newLength);
  4325. let i;
  4326. for (i = 0; i < commonLength; i++) {
  4327. const nextChild = (c2[i] = optimized
  4328. ? cloneIfMounted(c2[i])
  4329. : normalizeVNode(c2[i]));
  4330. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, optimized);
  4331. }
  4332. if (oldLength > newLength) {
  4333. // remove old
  4334. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  4335. }
  4336. else {
  4337. // mount new
  4338. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, commonLength);
  4339. }
  4340. };
  4341. // can be all-keyed or mixed
  4342. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, optimized) => {
  4343. let i = 0;
  4344. const l2 = c2.length;
  4345. let e1 = c1.length - 1; // prev ending index
  4346. let e2 = l2 - 1; // next ending index
  4347. // 1. sync from start
  4348. // (a b) c
  4349. // (a b) d e
  4350. while (i <= e1 && i <= e2) {
  4351. const n1 = c1[i];
  4352. const n2 = (c2[i] = optimized
  4353. ? cloneIfMounted(c2[i])
  4354. : normalizeVNode(c2[i]));
  4355. if (isSameVNodeType(n1, n2)) {
  4356. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, optimized);
  4357. }
  4358. else {
  4359. break;
  4360. }
  4361. i++;
  4362. }
  4363. // 2. sync from end
  4364. // a (b c)
  4365. // d e (b c)
  4366. while (i <= e1 && i <= e2) {
  4367. const n1 = c1[e1];
  4368. const n2 = (c2[e2] = optimized
  4369. ? cloneIfMounted(c2[e2])
  4370. : normalizeVNode(c2[e2]));
  4371. if (isSameVNodeType(n1, n2)) {
  4372. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, optimized);
  4373. }
  4374. else {
  4375. break;
  4376. }
  4377. e1--;
  4378. e2--;
  4379. }
  4380. // 3. common sequence + mount
  4381. // (a b)
  4382. // (a b) c
  4383. // i = 2, e1 = 1, e2 = 2
  4384. // (a b)
  4385. // c (a b)
  4386. // i = 0, e1 = -1, e2 = 0
  4387. if (i > e1) {
  4388. if (i <= e2) {
  4389. const nextPos = e2 + 1;
  4390. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  4391. while (i <= e2) {
  4392. patch(null, (c2[i] = optimized
  4393. ? cloneIfMounted(c2[i])
  4394. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG);
  4395. i++;
  4396. }
  4397. }
  4398. }
  4399. // 4. common sequence + unmount
  4400. // (a b) c
  4401. // (a b)
  4402. // i = 2, e1 = 2, e2 = 1
  4403. // a (b c)
  4404. // (b c)
  4405. // i = 0, e1 = 0, e2 = -1
  4406. else if (i > e2) {
  4407. while (i <= e1) {
  4408. unmount(c1[i], parentComponent, parentSuspense, true);
  4409. i++;
  4410. }
  4411. }
  4412. // 5. unknown sequence
  4413. // [i ... e1 + 1]: a b [c d e] f g
  4414. // [i ... e2 + 1]: a b [e d c h] f g
  4415. // i = 2, e1 = 4, e2 = 5
  4416. else {
  4417. const s1 = i; // prev starting index
  4418. const s2 = i; // next starting index
  4419. // 5.1 build key:index map for newChildren
  4420. const keyToNewIndexMap = new Map();
  4421. for (i = s2; i <= e2; i++) {
  4422. const nextChild = (c2[i] = optimized
  4423. ? cloneIfMounted(c2[i])
  4424. : normalizeVNode(c2[i]));
  4425. if (nextChild.key != null) {
  4426. if (keyToNewIndexMap.has(nextChild.key)) {
  4427. warn(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  4428. }
  4429. keyToNewIndexMap.set(nextChild.key, i);
  4430. }
  4431. }
  4432. // 5.2 loop through old children left to be patched and try to patch
  4433. // matching nodes & remove nodes that are no longer present
  4434. let j;
  4435. let patched = 0;
  4436. const toBePatched = e2 - s2 + 1;
  4437. let moved = false;
  4438. // used to track whether any node has moved
  4439. let maxNewIndexSoFar = 0;
  4440. // works as Map<newIndex, oldIndex>
  4441. // Note that oldIndex is offset by +1
  4442. // and oldIndex = 0 is a special value indicating the new node has
  4443. // no corresponding old node.
  4444. // used for determining longest stable subsequence
  4445. const newIndexToOldIndexMap = new Array(toBePatched);
  4446. for (i = 0; i < toBePatched; i++)
  4447. newIndexToOldIndexMap[i] = 0;
  4448. for (i = s1; i <= e1; i++) {
  4449. const prevChild = c1[i];
  4450. if (patched >= toBePatched) {
  4451. // all new children have been patched so this can only be a removal
  4452. unmount(prevChild, parentComponent, parentSuspense, true);
  4453. continue;
  4454. }
  4455. let newIndex;
  4456. if (prevChild.key != null) {
  4457. newIndex = keyToNewIndexMap.get(prevChild.key);
  4458. }
  4459. else {
  4460. // key-less node, try to locate a key-less node of the same type
  4461. for (j = s2; j <= e2; j++) {
  4462. if (newIndexToOldIndexMap[j - s2] === 0 &&
  4463. isSameVNodeType(prevChild, c2[j])) {
  4464. newIndex = j;
  4465. break;
  4466. }
  4467. }
  4468. }
  4469. if (newIndex === undefined) {
  4470. unmount(prevChild, parentComponent, parentSuspense, true);
  4471. }
  4472. else {
  4473. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  4474. if (newIndex >= maxNewIndexSoFar) {
  4475. maxNewIndexSoFar = newIndex;
  4476. }
  4477. else {
  4478. moved = true;
  4479. }
  4480. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, optimized);
  4481. patched++;
  4482. }
  4483. }
  4484. // 5.3 move and mount
  4485. // generate longest stable subsequence only when nodes have moved
  4486. const increasingNewIndexSequence = moved
  4487. ? getSequence(newIndexToOldIndexMap)
  4488. : shared.EMPTY_ARR;
  4489. j = increasingNewIndexSequence.length - 1;
  4490. // looping backwards so that we can use last patched node as anchor
  4491. for (i = toBePatched - 1; i >= 0; i--) {
  4492. const nextIndex = s2 + i;
  4493. const nextChild = c2[nextIndex];
  4494. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  4495. if (newIndexToOldIndexMap[i] === 0) {
  4496. // mount new
  4497. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG);
  4498. }
  4499. else if (moved) {
  4500. // move if:
  4501. // There is no stable subsequence (e.g. a reverse)
  4502. // OR current node is not among the stable sequence
  4503. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  4504. move(nextChild, container, anchor, 2 /* REORDER */);
  4505. }
  4506. else {
  4507. j--;
  4508. }
  4509. }
  4510. }
  4511. }
  4512. };
  4513. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  4514. const { el, type, transition, children, shapeFlag } = vnode;
  4515. if (shapeFlag & 6 /* COMPONENT */) {
  4516. move(vnode.component.subTree, container, anchor, moveType);
  4517. return;
  4518. }
  4519. if (shapeFlag & 128 /* SUSPENSE */) {
  4520. vnode.suspense.move(container, anchor, moveType);
  4521. return;
  4522. }
  4523. if (shapeFlag & 64 /* TELEPORT */) {
  4524. type.move(vnode, container, anchor, internals);
  4525. return;
  4526. }
  4527. if (type === Fragment) {
  4528. hostInsert(el, container, anchor);
  4529. for (let i = 0; i < children.length; i++) {
  4530. move(children[i], container, anchor, moveType);
  4531. }
  4532. hostInsert(vnode.anchor, container, anchor);
  4533. return;
  4534. }
  4535. if (type === Static) {
  4536. moveStaticNode(vnode, container, anchor);
  4537. return;
  4538. }
  4539. // single nodes
  4540. const needTransition = moveType !== 2 /* REORDER */ &&
  4541. shapeFlag & 1 /* ELEMENT */ &&
  4542. transition;
  4543. if (needTransition) {
  4544. if (moveType === 0 /* ENTER */) {
  4545. transition.beforeEnter(el);
  4546. hostInsert(el, container, anchor);
  4547. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  4548. }
  4549. else {
  4550. const { leave, delayLeave, afterLeave } = transition;
  4551. const remove = () => hostInsert(el, container, anchor);
  4552. const performLeave = () => {
  4553. leave(el, () => {
  4554. remove();
  4555. afterLeave && afterLeave();
  4556. });
  4557. };
  4558. if (delayLeave) {
  4559. delayLeave(el, remove, performLeave);
  4560. }
  4561. else {
  4562. performLeave();
  4563. }
  4564. }
  4565. }
  4566. else {
  4567. hostInsert(el, container, anchor);
  4568. }
  4569. };
  4570. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  4571. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  4572. // unset ref
  4573. if (ref != null) {
  4574. setRef(ref, null, parentSuspense, null);
  4575. }
  4576. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4577. parentComponent.ctx.deactivate(vnode);
  4578. return;
  4579. }
  4580. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  4581. let vnodeHook;
  4582. if ((vnodeHook = props && props.onVnodeBeforeUnmount)) {
  4583. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  4584. }
  4585. if (shapeFlag & 6 /* COMPONENT */) {
  4586. unmountComponent(vnode.component, parentSuspense, doRemove);
  4587. }
  4588. else {
  4589. if (shapeFlag & 128 /* SUSPENSE */) {
  4590. vnode.suspense.unmount(parentSuspense, doRemove);
  4591. return;
  4592. }
  4593. if (shouldInvokeDirs) {
  4594. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  4595. }
  4596. if (dynamicChildren &&
  4597. // #1153: fast path should not be taken for non-stable (v-for) fragments
  4598. (type !== Fragment ||
  4599. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  4600. // fast path for block nodes: only need to unmount dynamic children.
  4601. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  4602. }
  4603. else if ((type === Fragment &&
  4604. (patchFlag & 128 /* KEYED_FRAGMENT */ ||
  4605. patchFlag & 256 /* UNKEYED_FRAGMENT */)) ||
  4606. (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
  4607. unmountChildren(children, parentComponent, parentSuspense);
  4608. }
  4609. // an unmounted teleport should always remove its children if not disabled
  4610. if (shapeFlag & 64 /* TELEPORT */ &&
  4611. (doRemove || !isTeleportDisabled(vnode.props))) {
  4612. vnode.type.remove(vnode, internals);
  4613. }
  4614. if (doRemove) {
  4615. remove(vnode);
  4616. }
  4617. }
  4618. if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  4619. queuePostRenderEffect(() => {
  4620. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  4621. shouldInvokeDirs &&
  4622. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  4623. }, parentSuspense);
  4624. }
  4625. };
  4626. const remove = vnode => {
  4627. const { type, el, anchor, transition } = vnode;
  4628. if (type === Fragment) {
  4629. removeFragment(el, anchor);
  4630. return;
  4631. }
  4632. if (type === Static) {
  4633. removeStaticNode(vnode);
  4634. return;
  4635. }
  4636. const performRemove = () => {
  4637. hostRemove(el);
  4638. if (transition && !transition.persisted && transition.afterLeave) {
  4639. transition.afterLeave();
  4640. }
  4641. };
  4642. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  4643. transition &&
  4644. !transition.persisted) {
  4645. const { leave, delayLeave } = transition;
  4646. const performLeave = () => leave(el, performRemove);
  4647. if (delayLeave) {
  4648. delayLeave(vnode.el, performRemove, performLeave);
  4649. }
  4650. else {
  4651. performLeave();
  4652. }
  4653. }
  4654. else {
  4655. performRemove();
  4656. }
  4657. };
  4658. const removeFragment = (cur, end) => {
  4659. // For fragments, directly remove all contained DOM nodes.
  4660. // (fragment child nodes cannot have transition)
  4661. let next;
  4662. while (cur !== end) {
  4663. next = hostNextSibling(cur);
  4664. hostRemove(cur);
  4665. cur = next;
  4666. }
  4667. hostRemove(end);
  4668. };
  4669. const unmountComponent = (instance, parentSuspense, doRemove) => {
  4670. if (instance.type.__hmrId) {
  4671. unregisterHMR(instance);
  4672. }
  4673. const { bum, effects, update, subTree, um } = instance;
  4674. // beforeUnmount hook
  4675. if (bum) {
  4676. shared.invokeArrayFns(bum);
  4677. }
  4678. if (effects) {
  4679. for (let i = 0; i < effects.length; i++) {
  4680. reactivity.stop(effects[i]);
  4681. }
  4682. }
  4683. // update may be null if a component is unmounted before its async
  4684. // setup has resolved.
  4685. if (update) {
  4686. reactivity.stop(update);
  4687. unmount(subTree, instance, parentSuspense, doRemove);
  4688. }
  4689. // unmounted hook
  4690. if (um) {
  4691. queuePostRenderEffect(um, parentSuspense);
  4692. }
  4693. queuePostRenderEffect(() => {
  4694. instance.isUnmounted = true;
  4695. }, parentSuspense);
  4696. // A component with async dep inside a pending suspense is unmounted before
  4697. // its async dep resolves. This should remove the dep from the suspense, and
  4698. // cause the suspense to resolve immediately if that was the last dep.
  4699. if (parentSuspense &&
  4700. parentSuspense.pendingBranch &&
  4701. !parentSuspense.isUnmounted &&
  4702. instance.asyncDep &&
  4703. !instance.asyncResolved &&
  4704. instance.suspenseId === parentSuspense.pendingId) {
  4705. parentSuspense.deps--;
  4706. if (parentSuspense.deps === 0) {
  4707. parentSuspense.resolve();
  4708. }
  4709. }
  4710. {
  4711. devtoolsComponentRemoved(instance);
  4712. }
  4713. };
  4714. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  4715. for (let i = start; i < children.length; i++) {
  4716. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  4717. }
  4718. };
  4719. const getNextHostNode = vnode => {
  4720. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  4721. return getNextHostNode(vnode.component.subTree);
  4722. }
  4723. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  4724. return vnode.suspense.next();
  4725. }
  4726. return hostNextSibling((vnode.anchor || vnode.el));
  4727. };
  4728. const render = (vnode, container) => {
  4729. if (vnode == null) {
  4730. if (container._vnode) {
  4731. unmount(container._vnode, null, null, true);
  4732. }
  4733. }
  4734. else {
  4735. patch(container._vnode || null, vnode, container);
  4736. }
  4737. flushPostFlushCbs();
  4738. container._vnode = vnode;
  4739. };
  4740. const internals = {
  4741. p: patch,
  4742. um: unmount,
  4743. m: move,
  4744. r: remove,
  4745. mt: mountComponent,
  4746. mc: mountChildren,
  4747. pc: patchChildren,
  4748. pbc: patchBlockChildren,
  4749. n: getNextHostNode,
  4750. o: options
  4751. };
  4752. let hydrate;
  4753. let hydrateNode;
  4754. if (createHydrationFns) {
  4755. [hydrate, hydrateNode] = createHydrationFns(internals);
  4756. }
  4757. return {
  4758. render,
  4759. hydrate,
  4760. createApp: createAppAPI(render, hydrate)
  4761. };
  4762. }
  4763. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  4764. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  4765. vnode,
  4766. prevVNode
  4767. ]);
  4768. }
  4769. /**
  4770. * #1156
  4771. * When a component is HMR-enabled, we need to make sure that all static nodes
  4772. * inside a block also inherit the DOM element from the previous tree so that
  4773. * HMR updates (which are full updates) can retrieve the element for patching.
  4774. *
  4775. * #2080
  4776. * Inside keyed `template` fragment static children, if a fragment is moved,
  4777. * the children will always moved so that need inherit el form previous nodes
  4778. * to ensure correct moved position.
  4779. */
  4780. function traverseStaticChildren(n1, n2, shallow = false) {
  4781. const ch1 = n1.children;
  4782. const ch2 = n2.children;
  4783. if (shared.isArray(ch1) && shared.isArray(ch2)) {
  4784. for (let i = 0; i < ch1.length; i++) {
  4785. // this is only called in the optimized path so array children are
  4786. // guaranteed to be vnodes
  4787. const c1 = ch1[i];
  4788. let c2 = ch2[i];
  4789. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  4790. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  4791. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  4792. c2.el = c1.el;
  4793. }
  4794. if (!shallow)
  4795. traverseStaticChildren(c1, c2);
  4796. }
  4797. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  4798. // would have received .el during block patch)
  4799. if (c2.type === Comment && !c2.el) {
  4800. c2.el = c1.el;
  4801. }
  4802. }
  4803. }
  4804. }
  4805. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  4806. function getSequence(arr) {
  4807. const p = arr.slice();
  4808. const result = [0];
  4809. let i, j, u, v, c;
  4810. const len = arr.length;
  4811. for (i = 0; i < len; i++) {
  4812. const arrI = arr[i];
  4813. if (arrI !== 0) {
  4814. j = result[result.length - 1];
  4815. if (arr[j] < arrI) {
  4816. p[i] = j;
  4817. result.push(i);
  4818. continue;
  4819. }
  4820. u = 0;
  4821. v = result.length - 1;
  4822. while (u < v) {
  4823. c = ((u + v) / 2) | 0;
  4824. if (arr[result[c]] < arrI) {
  4825. u = c + 1;
  4826. }
  4827. else {
  4828. v = c;
  4829. }
  4830. }
  4831. if (arrI < arr[result[u]]) {
  4832. if (u > 0) {
  4833. p[i] = result[u - 1];
  4834. }
  4835. result[u] = i;
  4836. }
  4837. }
  4838. }
  4839. u = result.length;
  4840. v = result[u - 1];
  4841. while (u-- > 0) {
  4842. result[u] = v;
  4843. v = p[v];
  4844. }
  4845. return result;
  4846. }
  4847. const isTeleport = (type) => type.__isTeleport;
  4848. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  4849. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  4850. const resolveTarget = (props, select) => {
  4851. const targetSelector = props && props.to;
  4852. if (shared.isString(targetSelector)) {
  4853. if (!select) {
  4854. warn(`Current renderer does not support string target for Teleports. ` +
  4855. `(missing querySelector renderer option)`);
  4856. return null;
  4857. }
  4858. else {
  4859. const target = select(targetSelector);
  4860. if (!target) {
  4861. warn(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  4862. `Note the target element must exist before the component is mounted - ` +
  4863. `i.e. the target cannot be rendered by the component itself, and ` +
  4864. `ideally should be outside of the entire Vue component tree.`);
  4865. }
  4866. return target;
  4867. }
  4868. }
  4869. else {
  4870. if (!targetSelector && !isTeleportDisabled(props)) {
  4871. warn(`Invalid Teleport target: ${targetSelector}`);
  4872. }
  4873. return targetSelector;
  4874. }
  4875. };
  4876. const TeleportImpl = {
  4877. __isTeleport: true,
  4878. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals) {
  4879. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  4880. const disabled = isTeleportDisabled(n2.props);
  4881. const { shapeFlag, children } = n2;
  4882. if (n1 == null) {
  4883. // insert anchors in the main view
  4884. const placeholder = (n2.el = createComment('teleport start')
  4885. );
  4886. const mainAnchor = (n2.anchor = createComment('teleport end')
  4887. );
  4888. insert(placeholder, container, anchor);
  4889. insert(mainAnchor, container, anchor);
  4890. const target = (n2.target = resolveTarget(n2.props, querySelector));
  4891. const targetAnchor = (n2.targetAnchor = createText(''));
  4892. if (target) {
  4893. insert(targetAnchor, target);
  4894. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  4895. isSVG = isSVG || isTargetSVG(target);
  4896. }
  4897. else if (!disabled) {
  4898. warn('Invalid Teleport target on mount:', target, `(${typeof target})`);
  4899. }
  4900. const mount = (container, anchor) => {
  4901. // Teleport *always* has Array children. This is enforced in both the
  4902. // compiler and vnode children normalization.
  4903. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  4904. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  4905. }
  4906. };
  4907. if (disabled) {
  4908. mount(container, mainAnchor);
  4909. }
  4910. else if (target) {
  4911. mount(target, targetAnchor);
  4912. }
  4913. }
  4914. else {
  4915. // update content
  4916. n2.el = n1.el;
  4917. const mainAnchor = (n2.anchor = n1.anchor);
  4918. const target = (n2.target = n1.target);
  4919. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  4920. const wasDisabled = isTeleportDisabled(n1.props);
  4921. const currentContainer = wasDisabled ? container : target;
  4922. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  4923. isSVG = isSVG || isTargetSVG(target);
  4924. if (n2.dynamicChildren) {
  4925. // fast path when the teleport happens to be a block root
  4926. patchBlockChildren(n1.dynamicChildren, n2.dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG);
  4927. // even in block tree mode we need to make sure all root-level nodes
  4928. // in the teleport inherit previous DOM references so that they can
  4929. // be moved in future patches.
  4930. traverseStaticChildren(n1, n2, true);
  4931. }
  4932. else if (!optimized) {
  4933. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG);
  4934. }
  4935. if (disabled) {
  4936. if (!wasDisabled) {
  4937. // enabled -> disabled
  4938. // move into main container
  4939. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  4940. }
  4941. }
  4942. else {
  4943. // target changed
  4944. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  4945. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  4946. if (nextTarget) {
  4947. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  4948. }
  4949. else {
  4950. warn('Invalid Teleport target on update:', target, `(${typeof target})`);
  4951. }
  4952. }
  4953. else if (wasDisabled) {
  4954. // disabled -> enabled
  4955. // move into teleport target
  4956. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  4957. }
  4958. }
  4959. }
  4960. },
  4961. remove(vnode, { r: remove, o: { remove: hostRemove } }) {
  4962. const { shapeFlag, children, anchor } = vnode;
  4963. hostRemove(anchor);
  4964. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  4965. for (let i = 0; i < children.length; i++) {
  4966. remove(children[i]);
  4967. }
  4968. }
  4969. },
  4970. move: moveTeleport,
  4971. hydrate: hydrateTeleport
  4972. };
  4973. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  4974. // move target anchor if this is a target change.
  4975. if (moveType === 0 /* TARGET_CHANGE */) {
  4976. insert(vnode.targetAnchor, container, parentAnchor);
  4977. }
  4978. const { el, anchor, shapeFlag, children, props } = vnode;
  4979. const isReorder = moveType === 2 /* REORDER */;
  4980. // move main view anchor if this is a re-order.
  4981. if (isReorder) {
  4982. insert(el, container, parentAnchor);
  4983. }
  4984. // if this is a re-order and teleport is enabled (content is in target)
  4985. // do not move children. So the opposite is: only move children if this
  4986. // is not a reorder, or the teleport is disabled
  4987. if (!isReorder || isTeleportDisabled(props)) {
  4988. // Teleport has either Array children or no children.
  4989. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  4990. for (let i = 0; i < children.length; i++) {
  4991. move(children[i], container, parentAnchor, 2 /* REORDER */);
  4992. }
  4993. }
  4994. }
  4995. // move main view anchor if this is a re-order.
  4996. if (isReorder) {
  4997. insert(anchor, container, parentAnchor);
  4998. }
  4999. }
  5000. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  5001. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  5002. if (target) {
  5003. // if multiple teleports rendered to the same target element, we need to
  5004. // pick up from where the last teleport finished instead of the first node
  5005. const targetNode = target._lpa || target.firstChild;
  5006. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5007. if (isTeleportDisabled(vnode.props)) {
  5008. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, optimized);
  5009. vnode.targetAnchor = targetNode;
  5010. }
  5011. else {
  5012. vnode.anchor = nextSibling(node);
  5013. vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, optimized);
  5014. }
  5015. target._lpa =
  5016. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  5017. }
  5018. }
  5019. return vnode.anchor && nextSibling(vnode.anchor);
  5020. }
  5021. // Force-casted public typing for h and TSX props inference
  5022. const Teleport = TeleportImpl;
  5023. const COMPONENTS = 'components';
  5024. const DIRECTIVES = 'directives';
  5025. /**
  5026. * @private
  5027. */
  5028. function resolveComponent(name) {
  5029. return resolveAsset(COMPONENTS, name) || name;
  5030. }
  5031. const NULL_DYNAMIC_COMPONENT = Symbol();
  5032. /**
  5033. * @private
  5034. */
  5035. function resolveDynamicComponent(component) {
  5036. if (shared.isString(component)) {
  5037. return resolveAsset(COMPONENTS, component, false) || component;
  5038. }
  5039. else {
  5040. // invalid types will fallthrough to createVNode and raise warning
  5041. return (component || NULL_DYNAMIC_COMPONENT);
  5042. }
  5043. }
  5044. /**
  5045. * @private
  5046. */
  5047. function resolveDirective(name) {
  5048. return resolveAsset(DIRECTIVES, name);
  5049. }
  5050. // implementation
  5051. function resolveAsset(type, name, warnMissing = true) {
  5052. const instance = currentRenderingInstance || currentInstance;
  5053. if (instance) {
  5054. const Component = instance.type;
  5055. // self name has highest priority
  5056. if (type === COMPONENTS) {
  5057. // special self referencing call generated by compiler
  5058. // inferred from SFC filename
  5059. if (name === `_self`) {
  5060. return Component;
  5061. }
  5062. const selfName = getComponentName(Component);
  5063. if (selfName &&
  5064. (selfName === name ||
  5065. selfName === shared.camelize(name) ||
  5066. selfName === shared.capitalize(shared.camelize(name)))) {
  5067. return Component;
  5068. }
  5069. }
  5070. const res =
  5071. // local registration
  5072. // check instance[type] first for components with mixin or extends.
  5073. resolve(instance[type] || Component[type], name) ||
  5074. // global registration
  5075. resolve(instance.appContext[type], name);
  5076. if (warnMissing && !res) {
  5077. warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
  5078. }
  5079. return res;
  5080. }
  5081. else {
  5082. warn(`resolve${shared.capitalize(type.slice(0, -1))} ` +
  5083. `can only be used in render() or setup().`);
  5084. }
  5085. }
  5086. function resolve(registry, name) {
  5087. return (registry &&
  5088. (registry[name] ||
  5089. registry[shared.camelize(name)] ||
  5090. registry[shared.capitalize(shared.camelize(name))]));
  5091. }
  5092. const Fragment = Symbol('Fragment' );
  5093. const Text = Symbol('Text' );
  5094. const Comment = Symbol('Comment' );
  5095. const Static = Symbol('Static' );
  5096. // Since v-if and v-for are the two possible ways node structure can dynamically
  5097. // change, once we consider v-if branches and each v-for fragment a block, we
  5098. // can divide a template into nested blocks, and within each block the node
  5099. // structure would be stable. This allows us to skip most children diffing
  5100. // and only worry about the dynamic nodes (indicated by patch flags).
  5101. const blockStack = [];
  5102. let currentBlock = null;
  5103. /**
  5104. * Open a block.
  5105. * This must be called before `createBlock`. It cannot be part of `createBlock`
  5106. * because the children of the block are evaluated before `createBlock` itself
  5107. * is called. The generated code typically looks like this:
  5108. *
  5109. * ```js
  5110. * function render() {
  5111. * return (openBlock(),createBlock('div', null, [...]))
  5112. * }
  5113. * ```
  5114. * disableTracking is true when creating a v-for fragment block, since a v-for
  5115. * fragment always diffs its children.
  5116. *
  5117. * @private
  5118. */
  5119. function openBlock(disableTracking = false) {
  5120. blockStack.push((currentBlock = disableTracking ? null : []));
  5121. }
  5122. function closeBlock() {
  5123. blockStack.pop();
  5124. currentBlock = blockStack[blockStack.length - 1] || null;
  5125. }
  5126. // Whether we should be tracking dynamic child nodes inside a block.
  5127. // Only tracks when this value is > 0
  5128. // We are not using a simple boolean because this value may need to be
  5129. // incremented/decremented by nested usage of v-once (see below)
  5130. let shouldTrack = 1;
  5131. /**
  5132. * Block tracking sometimes needs to be disabled, for example during the
  5133. * creation of a tree that needs to be cached by v-once. The compiler generates
  5134. * code like this:
  5135. *
  5136. * ``` js
  5137. * _cache[1] || (
  5138. * setBlockTracking(-1),
  5139. * _cache[1] = createVNode(...),
  5140. * setBlockTracking(1),
  5141. * _cache[1]
  5142. * )
  5143. * ```
  5144. *
  5145. * @private
  5146. */
  5147. function setBlockTracking(value) {
  5148. shouldTrack += value;
  5149. }
  5150. /**
  5151. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  5152. * A block root keeps track of dynamic nodes within the block in the
  5153. * `dynamicChildren` array.
  5154. *
  5155. * @private
  5156. */
  5157. function createBlock(type, props, children, patchFlag, dynamicProps) {
  5158. const vnode = createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */);
  5159. // save current block children on the block vnode
  5160. vnode.dynamicChildren = currentBlock || shared.EMPTY_ARR;
  5161. // close block
  5162. closeBlock();
  5163. // a block is always going to be patched, so track it as a child of its
  5164. // parent block
  5165. if (shouldTrack > 0 && currentBlock) {
  5166. currentBlock.push(vnode);
  5167. }
  5168. return vnode;
  5169. }
  5170. function isVNode(value) {
  5171. return value ? value.__v_isVNode === true : false;
  5172. }
  5173. function isSameVNodeType(n1, n2) {
  5174. if (n2.shapeFlag & 6 /* COMPONENT */ &&
  5175. hmrDirtyComponents.has(n2.type)) {
  5176. // HMR only: if the component has been hot-updated, force a reload.
  5177. return false;
  5178. }
  5179. return n1.type === n2.type && n1.key === n2.key;
  5180. }
  5181. let vnodeArgsTransformer;
  5182. /**
  5183. * Internal API for registering an arguments transform for createVNode
  5184. * used for creating stubs in the test-utils
  5185. * It is *internal* but needs to be exposed for test-utils to pick up proper
  5186. * typings
  5187. */
  5188. function transformVNodeArgs(transformer) {
  5189. vnodeArgsTransformer = transformer;
  5190. }
  5191. const createVNodeWithArgsTransform = (...args) => {
  5192. return _createVNode(...(vnodeArgsTransformer
  5193. ? vnodeArgsTransformer(args, currentRenderingInstance)
  5194. : args));
  5195. };
  5196. const InternalObjectKey = `__vInternal`;
  5197. const normalizeKey = ({ key }) => key != null ? key : null;
  5198. const normalizeRef = ({ ref }) => {
  5199. return (ref != null
  5200. ? shared.isString(ref) || reactivity.isRef(ref) || shared.isFunction(ref)
  5201. ? { i: currentRenderingInstance, r: ref }
  5202. : ref
  5203. : null);
  5204. };
  5205. const createVNode = (createVNodeWithArgsTransform
  5206. );
  5207. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  5208. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  5209. if (!type) {
  5210. warn(`Invalid vnode type when creating vnode: ${type}.`);
  5211. }
  5212. type = Comment;
  5213. }
  5214. if (isVNode(type)) {
  5215. // createVNode receiving an existing vnode. This happens in cases like
  5216. // <component :is="vnode"/>
  5217. // #2078 make sure to merge refs during the clone instead of overwriting it
  5218. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  5219. if (children) {
  5220. normalizeChildren(cloned, children);
  5221. }
  5222. return cloned;
  5223. }
  5224. // class component normalization.
  5225. if (isClassComponent(type)) {
  5226. type = type.__vccOpts;
  5227. }
  5228. // class & style normalization.
  5229. if (props) {
  5230. // for reactive or proxy objects, we need to clone it to enable mutation.
  5231. if (reactivity.isProxy(props) || InternalObjectKey in props) {
  5232. props = shared.extend({}, props);
  5233. }
  5234. let { class: klass, style } = props;
  5235. if (klass && !shared.isString(klass)) {
  5236. props.class = shared.normalizeClass(klass);
  5237. }
  5238. if (shared.isObject(style)) {
  5239. // reactive state objects need to be cloned since they are likely to be
  5240. // mutated
  5241. if (reactivity.isProxy(style) && !shared.isArray(style)) {
  5242. style = shared.extend({}, style);
  5243. }
  5244. props.style = shared.normalizeStyle(style);
  5245. }
  5246. }
  5247. // encode the vnode type information into a bitmap
  5248. const shapeFlag = shared.isString(type)
  5249. ? 1 /* ELEMENT */
  5250. : isSuspense(type)
  5251. ? 128 /* SUSPENSE */
  5252. : isTeleport(type)
  5253. ? 64 /* TELEPORT */
  5254. : shared.isObject(type)
  5255. ? 4 /* STATEFUL_COMPONENT */
  5256. : shared.isFunction(type)
  5257. ? 2 /* FUNCTIONAL_COMPONENT */
  5258. : 0;
  5259. if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && reactivity.isProxy(type)) {
  5260. type = reactivity.toRaw(type);
  5261. warn(`Vue received a Component which was made a reactive object. This can ` +
  5262. `lead to unnecessary performance overhead, and should be avoided by ` +
  5263. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  5264. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  5265. }
  5266. const vnode = {
  5267. __v_isVNode: true,
  5268. ["__v_skip" /* SKIP */]: true,
  5269. type,
  5270. props,
  5271. key: props && normalizeKey(props),
  5272. ref: props && normalizeRef(props),
  5273. scopeId: currentScopeId,
  5274. children: null,
  5275. component: null,
  5276. suspense: null,
  5277. ssContent: null,
  5278. ssFallback: null,
  5279. dirs: null,
  5280. transition: null,
  5281. el: null,
  5282. anchor: null,
  5283. target: null,
  5284. targetAnchor: null,
  5285. staticCount: 0,
  5286. shapeFlag,
  5287. patchFlag,
  5288. dynamicProps,
  5289. dynamicChildren: null,
  5290. appContext: null
  5291. };
  5292. // validate key
  5293. if (vnode.key !== vnode.key) {
  5294. warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  5295. }
  5296. normalizeChildren(vnode, children);
  5297. // normalize suspense children
  5298. if (shapeFlag & 128 /* SUSPENSE */) {
  5299. const { content, fallback } = normalizeSuspenseChildren(vnode);
  5300. vnode.ssContent = content;
  5301. vnode.ssFallback = fallback;
  5302. }
  5303. if (shouldTrack > 0 &&
  5304. // avoid a block node from tracking itself
  5305. !isBlockNode &&
  5306. // has current parent block
  5307. currentBlock &&
  5308. // presence of a patch flag indicates this node needs patching on updates.
  5309. // component nodes also should always be patched, because even if the
  5310. // component doesn't need to update, it needs to persist the instance on to
  5311. // the next vnode so that it can be properly unmounted later.
  5312. (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  5313. // the EVENTS flag is only for hydration and if it is the only flag, the
  5314. // vnode should not be considered dynamic due to handler caching.
  5315. patchFlag !== 32 /* HYDRATE_EVENTS */) {
  5316. currentBlock.push(vnode);
  5317. }
  5318. return vnode;
  5319. }
  5320. function cloneVNode(vnode, extraProps, mergeRef = false) {
  5321. // This is intentionally NOT using spread or extend to avoid the runtime
  5322. // key enumeration cost.
  5323. const { props, ref, patchFlag, children } = vnode;
  5324. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  5325. return {
  5326. __v_isVNode: true,
  5327. ["__v_skip" /* SKIP */]: true,
  5328. type: vnode.type,
  5329. props: mergedProps,
  5330. key: mergedProps && normalizeKey(mergedProps),
  5331. ref: extraProps && extraProps.ref
  5332. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  5333. // if the vnode itself already has a ref, cloneVNode will need to merge
  5334. // the refs so the single vnode can be set on multiple refs
  5335. mergeRef && ref
  5336. ? shared.isArray(ref)
  5337. ? ref.concat(normalizeRef(extraProps))
  5338. : [ref, normalizeRef(extraProps)]
  5339. : normalizeRef(extraProps)
  5340. : ref,
  5341. scopeId: vnode.scopeId,
  5342. children: patchFlag === -1 /* HOISTED */ && shared.isArray(children)
  5343. ? children.map(deepCloneVNode)
  5344. : children,
  5345. target: vnode.target,
  5346. targetAnchor: vnode.targetAnchor,
  5347. staticCount: vnode.staticCount,
  5348. shapeFlag: vnode.shapeFlag,
  5349. // if the vnode is cloned with extra props, we can no longer assume its
  5350. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  5351. // note: perserve flag for fragments since they use the flag for children
  5352. // fast paths only.
  5353. patchFlag: extraProps && vnode.type !== Fragment
  5354. ? patchFlag === -1 // hoisted node
  5355. ? 16 /* FULL_PROPS */
  5356. : patchFlag | 16 /* FULL_PROPS */
  5357. : patchFlag,
  5358. dynamicProps: vnode.dynamicProps,
  5359. dynamicChildren: vnode.dynamicChildren,
  5360. appContext: vnode.appContext,
  5361. dirs: vnode.dirs,
  5362. transition: vnode.transition,
  5363. // These should technically only be non-null on mounted VNodes. However,
  5364. // they *should* be copied for kept-alive vnodes. So we just always copy
  5365. // them since them being non-null during a mount doesn't affect the logic as
  5366. // they will simply be overwritten.
  5367. component: vnode.component,
  5368. suspense: vnode.suspense,
  5369. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  5370. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  5371. el: vnode.el,
  5372. anchor: vnode.anchor
  5373. };
  5374. }
  5375. /**
  5376. * Dev only, for HMR of hoisted vnodes reused in v-for
  5377. * https://github.com/vitejs/vite/issues/2022
  5378. */
  5379. function deepCloneVNode(vnode) {
  5380. const cloned = cloneVNode(vnode);
  5381. if (shared.isArray(vnode.children)) {
  5382. cloned.children = vnode.children.map(deepCloneVNode);
  5383. }
  5384. return cloned;
  5385. }
  5386. /**
  5387. * @private
  5388. */
  5389. function createTextVNode(text = ' ', flag = 0) {
  5390. return createVNode(Text, null, text, flag);
  5391. }
  5392. /**
  5393. * @private
  5394. */
  5395. function createStaticVNode(content, numberOfNodes) {
  5396. // A static vnode can contain multiple stringified elements, and the number
  5397. // of elements is necessary for hydration.
  5398. const vnode = createVNode(Static, null, content);
  5399. vnode.staticCount = numberOfNodes;
  5400. return vnode;
  5401. }
  5402. /**
  5403. * @private
  5404. */
  5405. function createCommentVNode(text = '',
  5406. // when used as the v-else branch, the comment node must be created as a
  5407. // block to ensure correct updates.
  5408. asBlock = false) {
  5409. return asBlock
  5410. ? (openBlock(), createBlock(Comment, null, text))
  5411. : createVNode(Comment, null, text);
  5412. }
  5413. function normalizeVNode(child) {
  5414. if (child == null || typeof child === 'boolean') {
  5415. // empty placeholder
  5416. return createVNode(Comment);
  5417. }
  5418. else if (shared.isArray(child)) {
  5419. // fragment
  5420. return createVNode(Fragment, null, child);
  5421. }
  5422. else if (typeof child === 'object') {
  5423. // already vnode, this should be the most common since compiled templates
  5424. // always produce all-vnode children arrays
  5425. return child.el === null ? child : cloneVNode(child);
  5426. }
  5427. else {
  5428. // strings and numbers
  5429. return createVNode(Text, null, String(child));
  5430. }
  5431. }
  5432. // optimized normalization for template-compiled render fns
  5433. function cloneIfMounted(child) {
  5434. return child.el === null ? child : cloneVNode(child);
  5435. }
  5436. function normalizeChildren(vnode, children) {
  5437. let type = 0;
  5438. const { shapeFlag } = vnode;
  5439. if (children == null) {
  5440. children = null;
  5441. }
  5442. else if (shared.isArray(children)) {
  5443. type = 16 /* ARRAY_CHILDREN */;
  5444. }
  5445. else if (typeof children === 'object') {
  5446. if (shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) {
  5447. // Normalize slot to plain children for plain element and Teleport
  5448. const slot = children.default;
  5449. if (slot) {
  5450. // _c marker is added by withCtx() indicating this is a compiled slot
  5451. slot._c && setCompiledSlotRendering(1);
  5452. normalizeChildren(vnode, slot());
  5453. slot._c && setCompiledSlotRendering(-1);
  5454. }
  5455. return;
  5456. }
  5457. else {
  5458. type = 32 /* SLOTS_CHILDREN */;
  5459. const slotFlag = children._;
  5460. if (!slotFlag && !(InternalObjectKey in children)) {
  5461. children._ctx = currentRenderingInstance;
  5462. }
  5463. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  5464. // a child component receives forwarded slots from the parent.
  5465. // its slot type is determined by its parent's slot type.
  5466. if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  5467. children._ = 2 /* DYNAMIC */;
  5468. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  5469. }
  5470. else {
  5471. children._ = 1 /* STABLE */;
  5472. }
  5473. }
  5474. }
  5475. }
  5476. else if (shared.isFunction(children)) {
  5477. children = { default: children, _ctx: currentRenderingInstance };
  5478. type = 32 /* SLOTS_CHILDREN */;
  5479. }
  5480. else {
  5481. children = String(children);
  5482. // force teleport children to array so it can be moved around
  5483. if (shapeFlag & 64 /* TELEPORT */) {
  5484. type = 16 /* ARRAY_CHILDREN */;
  5485. children = [createTextVNode(children)];
  5486. }
  5487. else {
  5488. type = 8 /* TEXT_CHILDREN */;
  5489. }
  5490. }
  5491. vnode.children = children;
  5492. vnode.shapeFlag |= type;
  5493. }
  5494. function mergeProps(...args) {
  5495. const ret = shared.extend({}, args[0]);
  5496. for (let i = 1; i < args.length; i++) {
  5497. const toMerge = args[i];
  5498. for (const key in toMerge) {
  5499. if (key === 'class') {
  5500. if (ret.class !== toMerge.class) {
  5501. ret.class = shared.normalizeClass([ret.class, toMerge.class]);
  5502. }
  5503. }
  5504. else if (key === 'style') {
  5505. ret.style = shared.normalizeStyle([ret.style, toMerge.style]);
  5506. }
  5507. else if (shared.isOn(key)) {
  5508. const existing = ret[key];
  5509. const incoming = toMerge[key];
  5510. if (existing !== incoming) {
  5511. ret[key] = existing
  5512. ? [].concat(existing, toMerge[key])
  5513. : incoming;
  5514. }
  5515. }
  5516. else if (key !== '') {
  5517. ret[key] = toMerge[key];
  5518. }
  5519. }
  5520. }
  5521. return ret;
  5522. }
  5523. function provide(key, value) {
  5524. if (!currentInstance) {
  5525. {
  5526. warn(`provide() can only be used inside setup().`);
  5527. }
  5528. }
  5529. else {
  5530. let provides = currentInstance.provides;
  5531. // by default an instance inherits its parent's provides object
  5532. // but when it needs to provide values of its own, it creates its
  5533. // own provides object using parent provides object as prototype.
  5534. // this way in `inject` we can simply look up injections from direct
  5535. // parent and let the prototype chain do the work.
  5536. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  5537. if (parentProvides === provides) {
  5538. provides = currentInstance.provides = Object.create(parentProvides);
  5539. }
  5540. // TS doesn't allow symbol as index type
  5541. provides[key] = value;
  5542. }
  5543. }
  5544. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  5545. // fallback to `currentRenderingInstance` so that this can be called in
  5546. // a functional component
  5547. const instance = currentInstance || currentRenderingInstance;
  5548. if (instance) {
  5549. // #2400
  5550. // to support `app.use` plugins,
  5551. // fallback to appContext's `provides` if the intance is at root
  5552. const provides = instance.parent == null
  5553. ? instance.vnode.appContext && instance.vnode.appContext.provides
  5554. : instance.parent.provides;
  5555. if (provides && key in provides) {
  5556. // TS doesn't allow symbol as index type
  5557. return provides[key];
  5558. }
  5559. else if (arguments.length > 1) {
  5560. return treatDefaultAsFactory && shared.isFunction(defaultValue)
  5561. ? defaultValue()
  5562. : defaultValue;
  5563. }
  5564. else {
  5565. warn(`injection "${String(key)}" not found.`);
  5566. }
  5567. }
  5568. else {
  5569. warn(`inject() can only be used inside setup() or functional components.`);
  5570. }
  5571. }
  5572. function createDuplicateChecker() {
  5573. const cache = Object.create(null);
  5574. return (type, key) => {
  5575. if (cache[key]) {
  5576. warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
  5577. }
  5578. else {
  5579. cache[key] = type;
  5580. }
  5581. };
  5582. }
  5583. let isInBeforeCreate = false;
  5584. function applyOptions(instance, options, deferredData = [], deferredWatch = [], deferredProvide = [], asMixin = false) {
  5585. const {
  5586. // composition
  5587. mixins, extends: extendsOptions,
  5588. // state
  5589. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  5590. // assets
  5591. components, directives,
  5592. // lifecycle
  5593. beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured,
  5594. // public API
  5595. expose } = options;
  5596. const publicThis = instance.proxy;
  5597. const ctx = instance.ctx;
  5598. const globalMixins = instance.appContext.mixins;
  5599. if (asMixin && render && instance.render === shared.NOOP) {
  5600. instance.render = render;
  5601. }
  5602. // applyOptions is called non-as-mixin once per instance
  5603. if (!asMixin) {
  5604. isInBeforeCreate = true;
  5605. callSyncHook('beforeCreate', "bc" /* BEFORE_CREATE */, options, instance, globalMixins);
  5606. isInBeforeCreate = false;
  5607. // global mixins are applied first
  5608. applyMixins(instance, globalMixins, deferredData, deferredWatch, deferredProvide);
  5609. }
  5610. // extending a base component...
  5611. if (extendsOptions) {
  5612. applyOptions(instance, extendsOptions, deferredData, deferredWatch, deferredProvide, true);
  5613. }
  5614. // local mixins
  5615. if (mixins) {
  5616. applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide);
  5617. }
  5618. const checkDuplicateProperties = createDuplicateChecker() ;
  5619. {
  5620. const [propsOptions] = instance.propsOptions;
  5621. if (propsOptions) {
  5622. for (const key in propsOptions) {
  5623. checkDuplicateProperties("Props" /* PROPS */, key);
  5624. }
  5625. }
  5626. }
  5627. // options initialization order (to be consistent with Vue 2):
  5628. // - props (already done outside of this function)
  5629. // - inject
  5630. // - methods
  5631. // - data (deferred since it relies on `this` access)
  5632. // - computed
  5633. // - watch (deferred since it relies on `this` access)
  5634. if (injectOptions) {
  5635. if (shared.isArray(injectOptions)) {
  5636. for (let i = 0; i < injectOptions.length; i++) {
  5637. const key = injectOptions[i];
  5638. ctx[key] = inject(key);
  5639. {
  5640. checkDuplicateProperties("Inject" /* INJECT */, key);
  5641. }
  5642. }
  5643. }
  5644. else {
  5645. for (const key in injectOptions) {
  5646. const opt = injectOptions[key];
  5647. if (shared.isObject(opt)) {
  5648. ctx[key] = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  5649. }
  5650. else {
  5651. ctx[key] = inject(opt);
  5652. }
  5653. {
  5654. checkDuplicateProperties("Inject" /* INJECT */, key);
  5655. }
  5656. }
  5657. }
  5658. }
  5659. if (methods) {
  5660. for (const key in methods) {
  5661. const methodHandler = methods[key];
  5662. if (shared.isFunction(methodHandler)) {
  5663. // In dev mode, we use the `createRenderContext` function to define methods to the proxy target,
  5664. // and those are read-only but reconfigurable, so it needs to be redefined here
  5665. {
  5666. Object.defineProperty(ctx, key, {
  5667. value: methodHandler.bind(publicThis),
  5668. configurable: true,
  5669. enumerable: false
  5670. });
  5671. }
  5672. {
  5673. checkDuplicateProperties("Methods" /* METHODS */, key);
  5674. }
  5675. }
  5676. else {
  5677. warn(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  5678. `Did you reference the function correctly?`);
  5679. }
  5680. }
  5681. }
  5682. if (!asMixin) {
  5683. if (deferredData.length) {
  5684. deferredData.forEach(dataFn => resolveData(instance, dataFn, publicThis));
  5685. }
  5686. if (dataOptions) {
  5687. // @ts-ignore dataOptions is not fully type safe
  5688. resolveData(instance, dataOptions, publicThis);
  5689. }
  5690. {
  5691. const rawData = reactivity.toRaw(instance.data);
  5692. for (const key in rawData) {
  5693. checkDuplicateProperties("Data" /* DATA */, key);
  5694. // expose data on ctx during dev
  5695. if (key[0] !== '$' && key[0] !== '_') {
  5696. Object.defineProperty(ctx, key, {
  5697. configurable: true,
  5698. enumerable: true,
  5699. get: () => rawData[key],
  5700. set: shared.NOOP
  5701. });
  5702. }
  5703. }
  5704. }
  5705. }
  5706. else if (dataOptions) {
  5707. deferredData.push(dataOptions);
  5708. }
  5709. if (computedOptions) {
  5710. for (const key in computedOptions) {
  5711. const opt = computedOptions[key];
  5712. const get = shared.isFunction(opt)
  5713. ? opt.bind(publicThis, publicThis)
  5714. : shared.isFunction(opt.get)
  5715. ? opt.get.bind(publicThis, publicThis)
  5716. : shared.NOOP;
  5717. if (get === shared.NOOP) {
  5718. warn(`Computed property "${key}" has no getter.`);
  5719. }
  5720. const set = !shared.isFunction(opt) && shared.isFunction(opt.set)
  5721. ? opt.set.bind(publicThis)
  5722. : () => {
  5723. warn(`Write operation failed: computed property "${key}" is readonly.`);
  5724. }
  5725. ;
  5726. const c = computed({
  5727. get,
  5728. set
  5729. });
  5730. Object.defineProperty(ctx, key, {
  5731. enumerable: true,
  5732. configurable: true,
  5733. get: () => c.value,
  5734. set: v => (c.value = v)
  5735. });
  5736. {
  5737. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  5738. }
  5739. }
  5740. }
  5741. if (watchOptions) {
  5742. deferredWatch.push(watchOptions);
  5743. }
  5744. if (!asMixin && deferredWatch.length) {
  5745. deferredWatch.forEach(watchOptions => {
  5746. for (const key in watchOptions) {
  5747. createWatcher(watchOptions[key], ctx, publicThis, key);
  5748. }
  5749. });
  5750. }
  5751. if (provideOptions) {
  5752. deferredProvide.push(provideOptions);
  5753. }
  5754. if (!asMixin && deferredProvide.length) {
  5755. deferredProvide.forEach(provideOptions => {
  5756. const provides = shared.isFunction(provideOptions)
  5757. ? provideOptions.call(publicThis)
  5758. : provideOptions;
  5759. Reflect.ownKeys(provides).forEach(key => {
  5760. provide(key, provides[key]);
  5761. });
  5762. });
  5763. }
  5764. // asset options.
  5765. // To reduce memory usage, only components with mixins or extends will have
  5766. // resolved asset registry attached to instance.
  5767. if (asMixin) {
  5768. if (components) {
  5769. shared.extend(instance.components ||
  5770. (instance.components = shared.extend({}, instance.type.components)), components);
  5771. }
  5772. if (directives) {
  5773. shared.extend(instance.directives ||
  5774. (instance.directives = shared.extend({}, instance.type.directives)), directives);
  5775. }
  5776. }
  5777. // lifecycle options
  5778. if (!asMixin) {
  5779. callSyncHook('created', "c" /* CREATED */, options, instance, globalMixins);
  5780. }
  5781. if (beforeMount) {
  5782. onBeforeMount(beforeMount.bind(publicThis));
  5783. }
  5784. if (mounted) {
  5785. onMounted(mounted.bind(publicThis));
  5786. }
  5787. if (beforeUpdate) {
  5788. onBeforeUpdate(beforeUpdate.bind(publicThis));
  5789. }
  5790. if (updated) {
  5791. onUpdated(updated.bind(publicThis));
  5792. }
  5793. if (activated) {
  5794. onActivated(activated.bind(publicThis));
  5795. }
  5796. if (deactivated) {
  5797. onDeactivated(deactivated.bind(publicThis));
  5798. }
  5799. if (errorCaptured) {
  5800. onErrorCaptured(errorCaptured.bind(publicThis));
  5801. }
  5802. if (renderTracked) {
  5803. onRenderTracked(renderTracked.bind(publicThis));
  5804. }
  5805. if (renderTriggered) {
  5806. onRenderTriggered(renderTriggered.bind(publicThis));
  5807. }
  5808. if (beforeDestroy) {
  5809. warn(`\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`);
  5810. }
  5811. if (beforeUnmount) {
  5812. onBeforeUnmount(beforeUnmount.bind(publicThis));
  5813. }
  5814. if (destroyed) {
  5815. warn(`\`destroyed\` has been renamed to \`unmounted\`.`);
  5816. }
  5817. if (unmounted) {
  5818. onUnmounted(unmounted.bind(publicThis));
  5819. }
  5820. if (shared.isArray(expose)) {
  5821. if (!asMixin) {
  5822. if (expose.length) {
  5823. const exposed = instance.exposed || (instance.exposed = reactivity.proxyRefs({}));
  5824. expose.forEach(key => {
  5825. exposed[key] = reactivity.toRef(publicThis, key);
  5826. });
  5827. }
  5828. else if (!instance.exposed) {
  5829. instance.exposed = shared.EMPTY_OBJ;
  5830. }
  5831. }
  5832. else {
  5833. warn(`The \`expose\` option is ignored when used in mixins.`);
  5834. }
  5835. }
  5836. }
  5837. function callSyncHook(name, type, options, instance, globalMixins) {
  5838. callHookFromMixins(name, type, globalMixins, instance);
  5839. const { extends: base, mixins } = options;
  5840. if (base) {
  5841. callHookFromExtends(name, type, base, instance);
  5842. }
  5843. if (mixins) {
  5844. callHookFromMixins(name, type, mixins, instance);
  5845. }
  5846. const selfHook = options[name];
  5847. if (selfHook) {
  5848. callWithAsyncErrorHandling(selfHook.bind(instance.proxy), instance, type);
  5849. }
  5850. }
  5851. function callHookFromExtends(name, type, base, instance) {
  5852. if (base.extends) {
  5853. callHookFromExtends(name, type, base.extends, instance);
  5854. }
  5855. const baseHook = base[name];
  5856. if (baseHook) {
  5857. callWithAsyncErrorHandling(baseHook.bind(instance.proxy), instance, type);
  5858. }
  5859. }
  5860. function callHookFromMixins(name, type, mixins, instance) {
  5861. for (let i = 0; i < mixins.length; i++) {
  5862. const chainedMixins = mixins[i].mixins;
  5863. if (chainedMixins) {
  5864. callHookFromMixins(name, type, chainedMixins, instance);
  5865. }
  5866. const fn = mixins[i][name];
  5867. if (fn) {
  5868. callWithAsyncErrorHandling(fn.bind(instance.proxy), instance, type);
  5869. }
  5870. }
  5871. }
  5872. function applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide) {
  5873. for (let i = 0; i < mixins.length; i++) {
  5874. applyOptions(instance, mixins[i], deferredData, deferredWatch, deferredProvide, true);
  5875. }
  5876. }
  5877. function resolveData(instance, dataFn, publicThis) {
  5878. if (!shared.isFunction(dataFn)) {
  5879. warn(`The data option must be a function. ` +
  5880. `Plain object usage is no longer supported.`);
  5881. }
  5882. const data = dataFn.call(publicThis, publicThis);
  5883. if (shared.isPromise(data)) {
  5884. warn(`data() returned a Promise - note data() cannot be async; If you ` +
  5885. `intend to perform data fetching before component renders, use ` +
  5886. `async setup() + <Suspense>.`);
  5887. }
  5888. if (!shared.isObject(data)) {
  5889. warn(`data() should return an object.`);
  5890. }
  5891. else if (instance.data === shared.EMPTY_OBJ) {
  5892. instance.data = reactivity.reactive(data);
  5893. }
  5894. else {
  5895. // existing data: this is a mixin or extends.
  5896. shared.extend(instance.data, data);
  5897. }
  5898. }
  5899. function createWatcher(raw, ctx, publicThis, key) {
  5900. const getter = key.includes('.')
  5901. ? createPathGetter(publicThis, key)
  5902. : () => publicThis[key];
  5903. if (shared.isString(raw)) {
  5904. const handler = ctx[raw];
  5905. if (shared.isFunction(handler)) {
  5906. watch(getter, handler);
  5907. }
  5908. else {
  5909. warn(`Invalid watch handler specified by key "${raw}"`, handler);
  5910. }
  5911. }
  5912. else if (shared.isFunction(raw)) {
  5913. watch(getter, raw.bind(publicThis));
  5914. }
  5915. else if (shared.isObject(raw)) {
  5916. if (shared.isArray(raw)) {
  5917. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  5918. }
  5919. else {
  5920. const handler = shared.isFunction(raw.handler)
  5921. ? raw.handler.bind(publicThis)
  5922. : ctx[raw.handler];
  5923. if (shared.isFunction(handler)) {
  5924. watch(getter, handler, raw);
  5925. }
  5926. else {
  5927. warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  5928. }
  5929. }
  5930. }
  5931. else {
  5932. warn(`Invalid watch option: "${key}"`, raw);
  5933. }
  5934. }
  5935. function createPathGetter(ctx, path) {
  5936. const segments = path.split('.');
  5937. return () => {
  5938. let cur = ctx;
  5939. for (let i = 0; i < segments.length && cur; i++) {
  5940. cur = cur[segments[i]];
  5941. }
  5942. return cur;
  5943. };
  5944. }
  5945. function resolveMergedOptions(instance) {
  5946. const raw = instance.type;
  5947. const { __merged, mixins, extends: extendsOptions } = raw;
  5948. if (__merged)
  5949. return __merged;
  5950. const globalMixins = instance.appContext.mixins;
  5951. if (!globalMixins.length && !mixins && !extendsOptions)
  5952. return raw;
  5953. const options = {};
  5954. globalMixins.forEach(m => mergeOptions(options, m, instance));
  5955. mergeOptions(options, raw, instance);
  5956. return (raw.__merged = options);
  5957. }
  5958. function mergeOptions(to, from, instance) {
  5959. const strats = instance.appContext.config.optionMergeStrategies;
  5960. const { mixins, extends: extendsOptions } = from;
  5961. extendsOptions && mergeOptions(to, extendsOptions, instance);
  5962. mixins &&
  5963. mixins.forEach((m) => mergeOptions(to, m, instance));
  5964. for (const key in from) {
  5965. if (strats && shared.hasOwn(strats, key)) {
  5966. to[key] = strats[key](to[key], from[key], instance.proxy, key);
  5967. }
  5968. else {
  5969. to[key] = from[key];
  5970. }
  5971. }
  5972. }
  5973. /**
  5974. * #2437 In Vue 3, functional components do not have a public instance proxy but
  5975. * they exist in the internal parent chain. For code that relies on traversing
  5976. * public $parent chains, skip functional ones and go to the parent instead.
  5977. */
  5978. const getPublicInstance = (i) => {
  5979. if (!i)
  5980. return null;
  5981. if (isStatefulComponent(i))
  5982. return i.exposed ? i.exposed : i.proxy;
  5983. return getPublicInstance(i.parent);
  5984. };
  5985. const publicPropertiesMap = shared.extend(Object.create(null), {
  5986. $: i => i,
  5987. $el: i => i.vnode.el,
  5988. $data: i => i.data,
  5989. $props: i => (reactivity.shallowReadonly(i.props) ),
  5990. $attrs: i => (reactivity.shallowReadonly(i.attrs) ),
  5991. $slots: i => (reactivity.shallowReadonly(i.slots) ),
  5992. $refs: i => (reactivity.shallowReadonly(i.refs) ),
  5993. $parent: i => getPublicInstance(i.parent),
  5994. $root: i => getPublicInstance(i.root),
  5995. $emit: i => i.emit,
  5996. $options: i => (resolveMergedOptions(i) ),
  5997. $forceUpdate: i => () => queueJob(i.update),
  5998. $nextTick: i => nextTick.bind(i.proxy),
  5999. $watch: i => (instanceWatch.bind(i) )
  6000. });
  6001. const PublicInstanceProxyHandlers = {
  6002. get({ _: instance }, key) {
  6003. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  6004. // let @vue/reactivity know it should never observe Vue public instances.
  6005. if (key === "__v_skip" /* SKIP */) {
  6006. return true;
  6007. }
  6008. // for internal formatters to know that this is a Vue instance
  6009. if (key === '__isVue') {
  6010. return true;
  6011. }
  6012. // data / props / ctx
  6013. // This getter gets called for every property access on the render context
  6014. // during render and is a major hotspot. The most expensive part of this
  6015. // is the multiple hasOwn() calls. It's much faster to do a simple property
  6016. // access on a plain object, so we use an accessCache object (with null
  6017. // prototype) to memoize what access type a key corresponds to.
  6018. let normalizedProps;
  6019. if (key[0] !== '$') {
  6020. const n = accessCache[key];
  6021. if (n !== undefined) {
  6022. switch (n) {
  6023. case 0 /* SETUP */:
  6024. return setupState[key];
  6025. case 1 /* DATA */:
  6026. return data[key];
  6027. case 3 /* CONTEXT */:
  6028. return ctx[key];
  6029. case 2 /* PROPS */:
  6030. return props[key];
  6031. // default: just fallthrough
  6032. }
  6033. }
  6034. else if (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) {
  6035. accessCache[key] = 0 /* SETUP */;
  6036. return setupState[key];
  6037. }
  6038. else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
  6039. accessCache[key] = 1 /* DATA */;
  6040. return data[key];
  6041. }
  6042. else if (
  6043. // only cache other properties when instance has declared (thus stable)
  6044. // props
  6045. (normalizedProps = instance.propsOptions[0]) &&
  6046. shared.hasOwn(normalizedProps, key)) {
  6047. accessCache[key] = 2 /* PROPS */;
  6048. return props[key];
  6049. }
  6050. else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
  6051. accessCache[key] = 3 /* CONTEXT */;
  6052. return ctx[key];
  6053. }
  6054. else if (!isInBeforeCreate) {
  6055. accessCache[key] = 4 /* OTHER */;
  6056. }
  6057. }
  6058. const publicGetter = publicPropertiesMap[key];
  6059. let cssModule, globalProperties;
  6060. // public $xxx properties
  6061. if (publicGetter) {
  6062. if (key === '$attrs') {
  6063. reactivity.track(instance, "get" /* GET */, key);
  6064. markAttrsAccessed();
  6065. }
  6066. return publicGetter(instance);
  6067. }
  6068. else if (
  6069. // css module (injected by vue-loader)
  6070. (cssModule = type.__cssModules) &&
  6071. (cssModule = cssModule[key])) {
  6072. return cssModule;
  6073. }
  6074. else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
  6075. // user may set custom properties to `this` that start with `$`
  6076. accessCache[key] = 3 /* CONTEXT */;
  6077. return ctx[key];
  6078. }
  6079. else if (
  6080. // global properties
  6081. ((globalProperties = appContext.config.globalProperties),
  6082. shared.hasOwn(globalProperties, key))) {
  6083. return globalProperties[key];
  6084. }
  6085. else if (currentRenderingInstance &&
  6086. (!shared.isString(key) ||
  6087. // #1091 avoid internal isRef/isVNode checks on component instance leading
  6088. // to infinite warning loop
  6089. key.indexOf('__v') !== 0)) {
  6090. if (data !== shared.EMPTY_OBJ &&
  6091. (key[0] === '$' || key[0] === '_') &&
  6092. shared.hasOwn(data, key)) {
  6093. warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  6094. `character ("$" or "_") and is not proxied on the render context.`);
  6095. }
  6096. else if (instance === currentRenderingInstance) {
  6097. warn(`Property ${JSON.stringify(key)} was accessed during render ` +
  6098. `but is not defined on instance.`);
  6099. }
  6100. }
  6101. },
  6102. set({ _: instance }, key, value) {
  6103. const { data, setupState, ctx } = instance;
  6104. if (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) {
  6105. setupState[key] = value;
  6106. }
  6107. else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
  6108. data[key] = value;
  6109. }
  6110. else if (shared.hasOwn(instance.props, key)) {
  6111. warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  6112. return false;
  6113. }
  6114. if (key[0] === '$' && key.slice(1) in instance) {
  6115. warn(`Attempting to mutate public property "${key}". ` +
  6116. `Properties starting with $ are reserved and readonly.`, instance);
  6117. return false;
  6118. }
  6119. else {
  6120. if (key in instance.appContext.config.globalProperties) {
  6121. Object.defineProperty(ctx, key, {
  6122. enumerable: true,
  6123. configurable: true,
  6124. value
  6125. });
  6126. }
  6127. else {
  6128. ctx[key] = value;
  6129. }
  6130. }
  6131. return true;
  6132. },
  6133. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  6134. let normalizedProps;
  6135. return (accessCache[key] !== undefined ||
  6136. (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) ||
  6137. (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) ||
  6138. ((normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key)) ||
  6139. shared.hasOwn(ctx, key) ||
  6140. shared.hasOwn(publicPropertiesMap, key) ||
  6141. shared.hasOwn(appContext.config.globalProperties, key));
  6142. }
  6143. };
  6144. {
  6145. PublicInstanceProxyHandlers.ownKeys = (target) => {
  6146. warn(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  6147. `The keys will be empty in production mode to avoid performance overhead.`);
  6148. return Reflect.ownKeys(target);
  6149. };
  6150. }
  6151. const RuntimeCompiledPublicInstanceProxyHandlers = shared.extend({}, PublicInstanceProxyHandlers, {
  6152. get(target, key) {
  6153. // fast path for unscopables when using `with` block
  6154. if (key === Symbol.unscopables) {
  6155. return;
  6156. }
  6157. return PublicInstanceProxyHandlers.get(target, key, target);
  6158. },
  6159. has(_, key) {
  6160. const has = key[0] !== '_' && !shared.isGloballyWhitelisted(key);
  6161. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  6162. warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  6163. }
  6164. return has;
  6165. }
  6166. });
  6167. // In dev mode, the proxy target exposes the same properties as seen on `this`
  6168. // for easier console inspection. In prod mode it will be an empty object so
  6169. // these properties definitions can be skipped.
  6170. function createRenderContext(instance) {
  6171. const target = {};
  6172. // expose internal instance for proxy handlers
  6173. Object.defineProperty(target, `_`, {
  6174. configurable: true,
  6175. enumerable: false,
  6176. get: () => instance
  6177. });
  6178. // expose public properties
  6179. Object.keys(publicPropertiesMap).forEach(key => {
  6180. Object.defineProperty(target, key, {
  6181. configurable: true,
  6182. enumerable: false,
  6183. get: () => publicPropertiesMap[key](instance),
  6184. // intercepted by the proxy so no need for implementation,
  6185. // but needed to prevent set errors
  6186. set: shared.NOOP
  6187. });
  6188. });
  6189. // expose global properties
  6190. const { globalProperties } = instance.appContext.config;
  6191. Object.keys(globalProperties).forEach(key => {
  6192. Object.defineProperty(target, key, {
  6193. configurable: true,
  6194. enumerable: false,
  6195. get: () => globalProperties[key],
  6196. set: shared.NOOP
  6197. });
  6198. });
  6199. return target;
  6200. }
  6201. // dev only
  6202. function exposePropsOnRenderContext(instance) {
  6203. const { ctx, propsOptions: [propsOptions] } = instance;
  6204. if (propsOptions) {
  6205. Object.keys(propsOptions).forEach(key => {
  6206. Object.defineProperty(ctx, key, {
  6207. enumerable: true,
  6208. configurable: true,
  6209. get: () => instance.props[key],
  6210. set: shared.NOOP
  6211. });
  6212. });
  6213. }
  6214. }
  6215. // dev only
  6216. function exposeSetupStateOnRenderContext(instance) {
  6217. const { ctx, setupState } = instance;
  6218. Object.keys(reactivity.toRaw(setupState)).forEach(key => {
  6219. if (key[0] === '$' || key[0] === '_') {
  6220. warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  6221. `which are reserved prefixes for Vue internals.`);
  6222. return;
  6223. }
  6224. Object.defineProperty(ctx, key, {
  6225. enumerable: true,
  6226. configurable: true,
  6227. get: () => setupState[key],
  6228. set: shared.NOOP
  6229. });
  6230. });
  6231. }
  6232. const emptyAppContext = createAppContext();
  6233. let uid$1 = 0;
  6234. function createComponentInstance(vnode, parent, suspense) {
  6235. const type = vnode.type;
  6236. // inherit parent app context - or - if root, adopt from root vnode
  6237. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  6238. const instance = {
  6239. uid: uid$1++,
  6240. vnode,
  6241. type,
  6242. parent,
  6243. appContext,
  6244. root: null,
  6245. next: null,
  6246. subTree: null,
  6247. update: null,
  6248. render: null,
  6249. proxy: null,
  6250. exposed: null,
  6251. withProxy: null,
  6252. effects: null,
  6253. provides: parent ? parent.provides : Object.create(appContext.provides),
  6254. accessCache: null,
  6255. renderCache: [],
  6256. // local resovled assets
  6257. components: null,
  6258. directives: null,
  6259. // resolved props and emits options
  6260. propsOptions: normalizePropsOptions(type, appContext),
  6261. emitsOptions: normalizeEmitsOptions(type, appContext),
  6262. // emit
  6263. emit: null,
  6264. emitted: null,
  6265. // state
  6266. ctx: shared.EMPTY_OBJ,
  6267. data: shared.EMPTY_OBJ,
  6268. props: shared.EMPTY_OBJ,
  6269. attrs: shared.EMPTY_OBJ,
  6270. slots: shared.EMPTY_OBJ,
  6271. refs: shared.EMPTY_OBJ,
  6272. setupState: shared.EMPTY_OBJ,
  6273. setupContext: null,
  6274. // suspense related
  6275. suspense,
  6276. suspenseId: suspense ? suspense.pendingId : 0,
  6277. asyncDep: null,
  6278. asyncResolved: false,
  6279. // lifecycle hooks
  6280. // not using enums here because it results in computed properties
  6281. isMounted: false,
  6282. isUnmounted: false,
  6283. isDeactivated: false,
  6284. bc: null,
  6285. c: null,
  6286. bm: null,
  6287. m: null,
  6288. bu: null,
  6289. u: null,
  6290. um: null,
  6291. bum: null,
  6292. da: null,
  6293. a: null,
  6294. rtg: null,
  6295. rtc: null,
  6296. ec: null
  6297. };
  6298. {
  6299. instance.ctx = createRenderContext(instance);
  6300. }
  6301. instance.root = parent ? parent.root : instance;
  6302. instance.emit = emit.bind(null, instance);
  6303. return instance;
  6304. }
  6305. let currentInstance = null;
  6306. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  6307. const setCurrentInstance = (instance) => {
  6308. currentInstance = instance;
  6309. };
  6310. const isBuiltInTag = /*#__PURE__*/ shared.makeMap('slot,component');
  6311. function validateComponentName(name, config) {
  6312. const appIsNativeTag = config.isNativeTag || shared.NO;
  6313. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  6314. warn('Do not use built-in or reserved HTML elements as component id: ' + name);
  6315. }
  6316. }
  6317. function isStatefulComponent(instance) {
  6318. return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
  6319. }
  6320. let isInSSRComponentSetup = false;
  6321. function setupComponent(instance, isSSR = false) {
  6322. isInSSRComponentSetup = isSSR;
  6323. const { props, children } = instance.vnode;
  6324. const isStateful = isStatefulComponent(instance);
  6325. initProps(instance, props, isStateful, isSSR);
  6326. initSlots(instance, children);
  6327. const setupResult = isStateful
  6328. ? setupStatefulComponent(instance, isSSR)
  6329. : undefined;
  6330. isInSSRComponentSetup = false;
  6331. return setupResult;
  6332. }
  6333. function setupStatefulComponent(instance, isSSR) {
  6334. const Component = instance.type;
  6335. {
  6336. if (Component.name) {
  6337. validateComponentName(Component.name, instance.appContext.config);
  6338. }
  6339. if (Component.components) {
  6340. const names = Object.keys(Component.components);
  6341. for (let i = 0; i < names.length; i++) {
  6342. validateComponentName(names[i], instance.appContext.config);
  6343. }
  6344. }
  6345. if (Component.directives) {
  6346. const names = Object.keys(Component.directives);
  6347. for (let i = 0; i < names.length; i++) {
  6348. validateDirectiveName(names[i]);
  6349. }
  6350. }
  6351. }
  6352. // 0. create render proxy property access cache
  6353. instance.accessCache = Object.create(null);
  6354. // 1. create public instance / render proxy
  6355. // also mark it raw so it's never observed
  6356. instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
  6357. {
  6358. exposePropsOnRenderContext(instance);
  6359. }
  6360. // 2. call setup()
  6361. const { setup } = Component;
  6362. if (setup) {
  6363. const setupContext = (instance.setupContext =
  6364. setup.length > 1 ? createSetupContext(instance) : null);
  6365. currentInstance = instance;
  6366. reactivity.pauseTracking();
  6367. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [reactivity.shallowReadonly(instance.props) , setupContext]);
  6368. reactivity.resetTracking();
  6369. currentInstance = null;
  6370. if (shared.isPromise(setupResult)) {
  6371. if (isSSR) {
  6372. // return the promise so server-renderer can wait on it
  6373. return setupResult.then((resolvedResult) => {
  6374. handleSetupResult(instance, resolvedResult, isSSR);
  6375. });
  6376. }
  6377. else {
  6378. // async setup returned Promise.
  6379. // bail here and wait for re-entry.
  6380. instance.asyncDep = setupResult;
  6381. }
  6382. }
  6383. else {
  6384. handleSetupResult(instance, setupResult, isSSR);
  6385. }
  6386. }
  6387. else {
  6388. finishComponentSetup(instance, isSSR);
  6389. }
  6390. }
  6391. function handleSetupResult(instance, setupResult, isSSR) {
  6392. if (shared.isFunction(setupResult)) {
  6393. // setup returned an inline render function
  6394. if (instance.type.__ssrInlineRender) {
  6395. // when the function's name is `ssrRender` (compiled by SFC inline mode),
  6396. // set it as ssrRender instead.
  6397. instance.ssrRender = setupResult;
  6398. }
  6399. else {
  6400. instance.render = setupResult;
  6401. }
  6402. }
  6403. else if (shared.isObject(setupResult)) {
  6404. if (isVNode(setupResult)) {
  6405. warn(`setup() should not return VNodes directly - ` +
  6406. `return a render function instead.`);
  6407. }
  6408. // setup returned bindings.
  6409. // assuming a render function compiled from template is present.
  6410. {
  6411. instance.devtoolsRawSetupState = setupResult;
  6412. }
  6413. instance.setupState = reactivity.proxyRefs(setupResult);
  6414. {
  6415. exposeSetupStateOnRenderContext(instance);
  6416. }
  6417. }
  6418. else if (setupResult !== undefined) {
  6419. warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  6420. }
  6421. finishComponentSetup(instance, isSSR);
  6422. }
  6423. let compile;
  6424. /**
  6425. * For runtime-dom to register the compiler.
  6426. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  6427. */
  6428. function registerRuntimeCompiler(_compile) {
  6429. compile = _compile;
  6430. }
  6431. function finishComponentSetup(instance, isSSR) {
  6432. const Component = instance.type;
  6433. // template / render function normalization
  6434. if (isSSR) {
  6435. if (Component.render) {
  6436. instance.render = Component.render;
  6437. }
  6438. }
  6439. else if (!instance.render) {
  6440. // could be set from setup()
  6441. if (compile && Component.template && !Component.render) {
  6442. {
  6443. startMeasure(instance, `compile`);
  6444. }
  6445. Component.render = compile(Component.template, {
  6446. isCustomElement: instance.appContext.config.isCustomElement,
  6447. delimiters: Component.delimiters
  6448. });
  6449. {
  6450. endMeasure(instance, `compile`);
  6451. }
  6452. }
  6453. instance.render = (Component.render || shared.NOOP);
  6454. // for runtime-compiled render functions using `with` blocks, the render
  6455. // proxy used needs a different `has` handler which is more performant and
  6456. // also only allows a whitelist of globals to fallthrough.
  6457. if (instance.render._rc) {
  6458. instance.withProxy = new Proxy(instance.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  6459. }
  6460. }
  6461. // support for 2.x options
  6462. {
  6463. currentInstance = instance;
  6464. reactivity.pauseTracking();
  6465. applyOptions(instance, Component);
  6466. reactivity.resetTracking();
  6467. currentInstance = null;
  6468. }
  6469. // warn missing template/render
  6470. if (!Component.render && instance.render === shared.NOOP) {
  6471. /* istanbul ignore if */
  6472. if (!compile && Component.template) {
  6473. warn(`Component provided template option but ` +
  6474. `runtime compilation is not supported in this build of Vue.` +
  6475. (``) /* should not happen */);
  6476. }
  6477. else {
  6478. warn(`Component is missing template or render function.`);
  6479. }
  6480. }
  6481. }
  6482. const attrHandlers = {
  6483. get: (target, key) => {
  6484. {
  6485. markAttrsAccessed();
  6486. }
  6487. return target[key];
  6488. },
  6489. set: () => {
  6490. warn(`setupContext.attrs is readonly.`);
  6491. return false;
  6492. },
  6493. deleteProperty: () => {
  6494. warn(`setupContext.attrs is readonly.`);
  6495. return false;
  6496. }
  6497. };
  6498. function createSetupContext(instance) {
  6499. const expose = exposed => {
  6500. if (instance.exposed) {
  6501. warn(`expose() should be called only once per setup().`);
  6502. }
  6503. instance.exposed = reactivity.proxyRefs(exposed);
  6504. };
  6505. {
  6506. // We use getters in dev in case libs like test-utils overwrite instance
  6507. // properties (overwrites should not be done in prod)
  6508. return Object.freeze({
  6509. get props() {
  6510. return instance.props;
  6511. },
  6512. get attrs() {
  6513. return new Proxy(instance.attrs, attrHandlers);
  6514. },
  6515. get slots() {
  6516. return reactivity.shallowReadonly(instance.slots);
  6517. },
  6518. get emit() {
  6519. return (event, ...args) => instance.emit(event, ...args);
  6520. },
  6521. expose
  6522. });
  6523. }
  6524. }
  6525. // record effects created during a component's setup() so that they can be
  6526. // stopped when the component unmounts
  6527. function recordInstanceBoundEffect(effect, instance = currentInstance) {
  6528. if (instance) {
  6529. (instance.effects || (instance.effects = [])).push(effect);
  6530. }
  6531. }
  6532. const classifyRE = /(?:^|[-_])(\w)/g;
  6533. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  6534. function getComponentName(Component) {
  6535. return shared.isFunction(Component)
  6536. ? Component.displayName || Component.name
  6537. : Component.name;
  6538. }
  6539. /* istanbul ignore next */
  6540. function formatComponentName(instance, Component, isRoot = false) {
  6541. let name = getComponentName(Component);
  6542. if (!name && Component.__file) {
  6543. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  6544. if (match) {
  6545. name = match[1];
  6546. }
  6547. }
  6548. if (!name && instance && instance.parent) {
  6549. // try to infer the name based on reverse resolution
  6550. const inferFromRegistry = (registry) => {
  6551. for (const key in registry) {
  6552. if (registry[key] === Component) {
  6553. return key;
  6554. }
  6555. }
  6556. };
  6557. name =
  6558. inferFromRegistry(instance.components ||
  6559. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  6560. }
  6561. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  6562. }
  6563. function isClassComponent(value) {
  6564. return shared.isFunction(value) && '__vccOpts' in value;
  6565. }
  6566. function computed(getterOrOptions) {
  6567. const c = reactivity.computed(getterOrOptions);
  6568. recordInstanceBoundEffect(c.effect);
  6569. return c;
  6570. }
  6571. // implementation
  6572. function defineProps() {
  6573. {
  6574. warn(`defineProps() is a compiler-hint helper that is only usable inside ` +
  6575. `<script setup> of a single file component. Its arguments should be ` +
  6576. `compiled away and passing it at runtime has no effect.`);
  6577. }
  6578. return null;
  6579. }
  6580. // implementation
  6581. function defineEmit() {
  6582. {
  6583. warn(`defineEmit() is a compiler-hint helper that is only usable inside ` +
  6584. `<script setup> of a single file component. Its arguments should be ` +
  6585. `compiled away and passing it at runtime has no effect.`);
  6586. }
  6587. return null;
  6588. }
  6589. function useContext() {
  6590. const i = getCurrentInstance();
  6591. if (!i) {
  6592. warn(`useContext() called without active instance.`);
  6593. }
  6594. return i.setupContext || (i.setupContext = createSetupContext(i));
  6595. }
  6596. // Actual implementation
  6597. function h(type, propsOrChildren, children) {
  6598. const l = arguments.length;
  6599. if (l === 2) {
  6600. if (shared.isObject(propsOrChildren) && !shared.isArray(propsOrChildren)) {
  6601. // single vnode without props
  6602. if (isVNode(propsOrChildren)) {
  6603. return createVNode(type, null, [propsOrChildren]);
  6604. }
  6605. // props without children
  6606. return createVNode(type, propsOrChildren);
  6607. }
  6608. else {
  6609. // omit props
  6610. return createVNode(type, null, propsOrChildren);
  6611. }
  6612. }
  6613. else {
  6614. if (l > 3) {
  6615. children = Array.prototype.slice.call(arguments, 2);
  6616. }
  6617. else if (l === 3 && isVNode(children)) {
  6618. children = [children];
  6619. }
  6620. return createVNode(type, propsOrChildren, children);
  6621. }
  6622. }
  6623. const ssrContextKey = Symbol(`ssrContext` );
  6624. const useSSRContext = () => {
  6625. {
  6626. const ctx = inject(ssrContextKey);
  6627. if (!ctx) {
  6628. warn(`Server rendering context not provided. Make sure to only call ` +
  6629. `useSSRContext() conditionally in the server build.`);
  6630. }
  6631. return ctx;
  6632. }
  6633. };
  6634. function initCustomFormatter() {
  6635. /* eslint-disable no-restricted-globals */
  6636. if (typeof window === 'undefined') {
  6637. return;
  6638. }
  6639. const vueStyle = { style: 'color:#3ba776' };
  6640. const numberStyle = { style: 'color:#0b1bc9' };
  6641. const stringStyle = { style: 'color:#b62e24' };
  6642. const keywordStyle = { style: 'color:#9d288c' };
  6643. // custom formatter for Chrome
  6644. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  6645. const formatter = {
  6646. header(obj) {
  6647. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  6648. if (!shared.isObject(obj)) {
  6649. return null;
  6650. }
  6651. if (obj.__isVue) {
  6652. return ['div', vueStyle, `VueInstance`];
  6653. }
  6654. else if (reactivity.isRef(obj)) {
  6655. return [
  6656. 'div',
  6657. {},
  6658. ['span', vueStyle, genRefFlag(obj)],
  6659. '<',
  6660. formatValue(obj.value),
  6661. `>`
  6662. ];
  6663. }
  6664. else if (reactivity.isReactive(obj)) {
  6665. return [
  6666. 'div',
  6667. {},
  6668. ['span', vueStyle, 'Reactive'],
  6669. '<',
  6670. formatValue(obj),
  6671. `>${reactivity.isReadonly(obj) ? ` (readonly)` : ``}`
  6672. ];
  6673. }
  6674. else if (reactivity.isReadonly(obj)) {
  6675. return [
  6676. 'div',
  6677. {},
  6678. ['span', vueStyle, 'Readonly'],
  6679. '<',
  6680. formatValue(obj),
  6681. '>'
  6682. ];
  6683. }
  6684. return null;
  6685. },
  6686. hasBody(obj) {
  6687. return obj && obj.__isVue;
  6688. },
  6689. body(obj) {
  6690. if (obj && obj.__isVue) {
  6691. return [
  6692. 'div',
  6693. {},
  6694. ...formatInstance(obj.$)
  6695. ];
  6696. }
  6697. }
  6698. };
  6699. function formatInstance(instance) {
  6700. const blocks = [];
  6701. if (instance.type.props && instance.props) {
  6702. blocks.push(createInstanceBlock('props', reactivity.toRaw(instance.props)));
  6703. }
  6704. if (instance.setupState !== shared.EMPTY_OBJ) {
  6705. blocks.push(createInstanceBlock('setup', instance.setupState));
  6706. }
  6707. if (instance.data !== shared.EMPTY_OBJ) {
  6708. blocks.push(createInstanceBlock('data', reactivity.toRaw(instance.data)));
  6709. }
  6710. const computed = extractKeys(instance, 'computed');
  6711. if (computed) {
  6712. blocks.push(createInstanceBlock('computed', computed));
  6713. }
  6714. const injected = extractKeys(instance, 'inject');
  6715. if (injected) {
  6716. blocks.push(createInstanceBlock('injected', injected));
  6717. }
  6718. blocks.push([
  6719. 'div',
  6720. {},
  6721. [
  6722. 'span',
  6723. {
  6724. style: keywordStyle.style + ';opacity:0.66'
  6725. },
  6726. '$ (internal): '
  6727. ],
  6728. ['object', { object: instance }]
  6729. ]);
  6730. return blocks;
  6731. }
  6732. function createInstanceBlock(type, target) {
  6733. target = shared.extend({}, target);
  6734. if (!Object.keys(target).length) {
  6735. return ['span', {}];
  6736. }
  6737. return [
  6738. 'div',
  6739. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  6740. [
  6741. 'div',
  6742. {
  6743. style: 'color:#476582'
  6744. },
  6745. type
  6746. ],
  6747. [
  6748. 'div',
  6749. {
  6750. style: 'padding-left:1.25em'
  6751. },
  6752. ...Object.keys(target).map(key => {
  6753. return [
  6754. 'div',
  6755. {},
  6756. ['span', keywordStyle, key + ': '],
  6757. formatValue(target[key], false)
  6758. ];
  6759. })
  6760. ]
  6761. ];
  6762. }
  6763. function formatValue(v, asRaw = true) {
  6764. if (typeof v === 'number') {
  6765. return ['span', numberStyle, v];
  6766. }
  6767. else if (typeof v === 'string') {
  6768. return ['span', stringStyle, JSON.stringify(v)];
  6769. }
  6770. else if (typeof v === 'boolean') {
  6771. return ['span', keywordStyle, v];
  6772. }
  6773. else if (shared.isObject(v)) {
  6774. return ['object', { object: asRaw ? reactivity.toRaw(v) : v }];
  6775. }
  6776. else {
  6777. return ['span', stringStyle, String(v)];
  6778. }
  6779. }
  6780. function extractKeys(instance, type) {
  6781. const Comp = instance.type;
  6782. if (shared.isFunction(Comp)) {
  6783. return;
  6784. }
  6785. const extracted = {};
  6786. for (const key in instance.ctx) {
  6787. if (isKeyOfType(Comp, key, type)) {
  6788. extracted[key] = instance.ctx[key];
  6789. }
  6790. }
  6791. return extracted;
  6792. }
  6793. function isKeyOfType(Comp, key, type) {
  6794. const opts = Comp[type];
  6795. if ((shared.isArray(opts) && opts.includes(key)) ||
  6796. (shared.isObject(opts) && key in opts)) {
  6797. return true;
  6798. }
  6799. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  6800. return true;
  6801. }
  6802. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  6803. return true;
  6804. }
  6805. }
  6806. function genRefFlag(v) {
  6807. if (v._shallow) {
  6808. return `ShallowRef`;
  6809. }
  6810. if (v.effect) {
  6811. return `ComputedRef`;
  6812. }
  6813. return `Ref`;
  6814. }
  6815. if (window.devtoolsFormatters) {
  6816. window.devtoolsFormatters.push(formatter);
  6817. }
  6818. else {
  6819. window.devtoolsFormatters = [formatter];
  6820. }
  6821. }
  6822. /**
  6823. * Actual implementation
  6824. */
  6825. function renderList(source, renderItem) {
  6826. let ret;
  6827. if (shared.isArray(source) || shared.isString(source)) {
  6828. ret = new Array(source.length);
  6829. for (let i = 0, l = source.length; i < l; i++) {
  6830. ret[i] = renderItem(source[i], i);
  6831. }
  6832. }
  6833. else if (typeof source === 'number') {
  6834. if (!Number.isInteger(source)) {
  6835. warn(`The v-for range expect an integer value but got ${source}.`);
  6836. return [];
  6837. }
  6838. ret = new Array(source);
  6839. for (let i = 0; i < source; i++) {
  6840. ret[i] = renderItem(i + 1, i);
  6841. }
  6842. }
  6843. else if (shared.isObject(source)) {
  6844. if (source[Symbol.iterator]) {
  6845. ret = Array.from(source, renderItem);
  6846. }
  6847. else {
  6848. const keys = Object.keys(source);
  6849. ret = new Array(keys.length);
  6850. for (let i = 0, l = keys.length; i < l; i++) {
  6851. const key = keys[i];
  6852. ret[i] = renderItem(source[key], key, i);
  6853. }
  6854. }
  6855. }
  6856. else {
  6857. ret = [];
  6858. }
  6859. return ret;
  6860. }
  6861. /**
  6862. * For prefixing keys in v-on="obj" with "on"
  6863. * @private
  6864. */
  6865. function toHandlers(obj) {
  6866. const ret = {};
  6867. if (!shared.isObject(obj)) {
  6868. warn(`v-on with no argument expects an object value.`);
  6869. return ret;
  6870. }
  6871. for (const key in obj) {
  6872. ret[shared.toHandlerKey(key)] = obj[key];
  6873. }
  6874. return ret;
  6875. }
  6876. /**
  6877. * Compiler runtime helper for creating dynamic slots object
  6878. * @private
  6879. */
  6880. function createSlots(slots, dynamicSlots) {
  6881. for (let i = 0; i < dynamicSlots.length; i++) {
  6882. const slot = dynamicSlots[i];
  6883. // array of dynamic slot generated by <template v-for="..." #[...]>
  6884. if (shared.isArray(slot)) {
  6885. for (let j = 0; j < slot.length; j++) {
  6886. slots[slot[j].name] = slot[j].fn;
  6887. }
  6888. }
  6889. else if (slot) {
  6890. // conditional single slot generated by <template v-if="..." #foo>
  6891. slots[slot.name] = slot.fn;
  6892. }
  6893. }
  6894. return slots;
  6895. }
  6896. // Core API ------------------------------------------------------------------
  6897. const version = "3.0.6";
  6898. const _ssrUtils = {
  6899. createComponentInstance,
  6900. setupComponent,
  6901. renderComponentRoot,
  6902. setCurrentRenderingInstance,
  6903. isVNode,
  6904. normalizeVNode
  6905. };
  6906. /**
  6907. * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
  6908. * @internal
  6909. */
  6910. const ssrUtils = (_ssrUtils );
  6911. exports.customRef = reactivity.customRef;
  6912. exports.isProxy = reactivity.isProxy;
  6913. exports.isReactive = reactivity.isReactive;
  6914. exports.isReadonly = reactivity.isReadonly;
  6915. exports.isRef = reactivity.isRef;
  6916. exports.markRaw = reactivity.markRaw;
  6917. exports.proxyRefs = reactivity.proxyRefs;
  6918. exports.reactive = reactivity.reactive;
  6919. exports.readonly = reactivity.readonly;
  6920. exports.ref = reactivity.ref;
  6921. exports.shallowReactive = reactivity.shallowReactive;
  6922. exports.shallowReadonly = reactivity.shallowReadonly;
  6923. exports.shallowRef = reactivity.shallowRef;
  6924. exports.toRaw = reactivity.toRaw;
  6925. exports.toRef = reactivity.toRef;
  6926. exports.toRefs = reactivity.toRefs;
  6927. exports.triggerRef = reactivity.triggerRef;
  6928. exports.unref = reactivity.unref;
  6929. exports.camelize = shared.camelize;
  6930. exports.capitalize = shared.capitalize;
  6931. exports.toDisplayString = shared.toDisplayString;
  6932. exports.toHandlerKey = shared.toHandlerKey;
  6933. exports.BaseTransition = BaseTransition;
  6934. exports.Comment = Comment;
  6935. exports.Fragment = Fragment;
  6936. exports.KeepAlive = KeepAlive;
  6937. exports.Static = Static;
  6938. exports.Suspense = Suspense;
  6939. exports.Teleport = Teleport;
  6940. exports.Text = Text;
  6941. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  6942. exports.callWithErrorHandling = callWithErrorHandling;
  6943. exports.cloneVNode = cloneVNode;
  6944. exports.computed = computed;
  6945. exports.createBlock = createBlock;
  6946. exports.createCommentVNode = createCommentVNode;
  6947. exports.createHydrationRenderer = createHydrationRenderer;
  6948. exports.createRenderer = createRenderer;
  6949. exports.createSlots = createSlots;
  6950. exports.createStaticVNode = createStaticVNode;
  6951. exports.createTextVNode = createTextVNode;
  6952. exports.createVNode = createVNode;
  6953. exports.defineAsyncComponent = defineAsyncComponent;
  6954. exports.defineComponent = defineComponent;
  6955. exports.defineEmit = defineEmit;
  6956. exports.defineProps = defineProps;
  6957. exports.getCurrentInstance = getCurrentInstance;
  6958. exports.getTransitionRawChildren = getTransitionRawChildren;
  6959. exports.h = h;
  6960. exports.handleError = handleError;
  6961. exports.initCustomFormatter = initCustomFormatter;
  6962. exports.inject = inject;
  6963. exports.isVNode = isVNode;
  6964. exports.mergeProps = mergeProps;
  6965. exports.nextTick = nextTick;
  6966. exports.onActivated = onActivated;
  6967. exports.onBeforeMount = onBeforeMount;
  6968. exports.onBeforeUnmount = onBeforeUnmount;
  6969. exports.onBeforeUpdate = onBeforeUpdate;
  6970. exports.onDeactivated = onDeactivated;
  6971. exports.onErrorCaptured = onErrorCaptured;
  6972. exports.onMounted = onMounted;
  6973. exports.onRenderTracked = onRenderTracked;
  6974. exports.onRenderTriggered = onRenderTriggered;
  6975. exports.onUnmounted = onUnmounted;
  6976. exports.onUpdated = onUpdated;
  6977. exports.openBlock = openBlock;
  6978. exports.popScopeId = popScopeId;
  6979. exports.provide = provide;
  6980. exports.pushScopeId = pushScopeId;
  6981. exports.queuePostFlushCb = queuePostFlushCb;
  6982. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  6983. exports.renderList = renderList;
  6984. exports.renderSlot = renderSlot;
  6985. exports.resolveComponent = resolveComponent;
  6986. exports.resolveDirective = resolveDirective;
  6987. exports.resolveDynamicComponent = resolveDynamicComponent;
  6988. exports.resolveTransitionHooks = resolveTransitionHooks;
  6989. exports.setBlockTracking = setBlockTracking;
  6990. exports.setDevtoolsHook = setDevtoolsHook;
  6991. exports.setTransitionHooks = setTransitionHooks;
  6992. exports.ssrContextKey = ssrContextKey;
  6993. exports.ssrUtils = ssrUtils;
  6994. exports.toHandlers = toHandlers;
  6995. exports.transformVNodeArgs = transformVNodeArgs;
  6996. exports.useContext = useContext;
  6997. exports.useSSRContext = useSSRContext;
  6998. exports.useTransitionState = useTransitionState;
  6999. exports.version = version;
  7000. exports.warn = warn;
  7001. exports.watch = watch;
  7002. exports.watchEffect = watchEffect;
  7003. exports.withCtx = withCtx;
  7004. exports.withDirectives = withDirectives;
  7005. exports.withScopeId = withScopeId;