runtime-core.cjs.prod.js 237 KB

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