vue.runtime.global.js 339 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054
  1. var Vue = (function (exports) {
  2. 'use strict';
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  19. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  20. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl';
  21. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  22. /**
  23. * On the client we only need to offer special cases for boolean attributes that
  24. * have different names from their corresponding dom properties:
  25. * - itemscope -> N/A
  26. * - allowfullscreen -> allowFullscreen
  27. * - formnovalidate -> formNoValidate
  28. * - ismap -> isMap
  29. * - nomodule -> noModule
  30. * - novalidate -> noValidate
  31. * - readonly -> readOnly
  32. */
  33. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  34. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  35. function normalizeStyle(value) {
  36. if (isArray(value)) {
  37. const res = {};
  38. for (let i = 0; i < value.length; i++) {
  39. const item = value[i];
  40. const normalized = normalizeStyle(isString(item) ? parseStringStyle(item) : item);
  41. if (normalized) {
  42. for (const key in normalized) {
  43. res[key] = normalized[key];
  44. }
  45. }
  46. }
  47. return res;
  48. }
  49. else if (isObject(value)) {
  50. return value;
  51. }
  52. }
  53. const listDelimiterRE = /;(?![^(]*\))/g;
  54. const propertyDelimiterRE = /:(.+)/;
  55. function parseStringStyle(cssText) {
  56. const ret = {};
  57. cssText.split(listDelimiterRE).forEach(item => {
  58. if (item) {
  59. const tmp = item.split(propertyDelimiterRE);
  60. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  61. }
  62. });
  63. return ret;
  64. }
  65. function normalizeClass(value) {
  66. let res = '';
  67. if (isString(value)) {
  68. res = value;
  69. }
  70. else if (isArray(value)) {
  71. for (let i = 0; i < value.length; i++) {
  72. res += normalizeClass(value[i]) + ' ';
  73. }
  74. }
  75. else if (isObject(value)) {
  76. for (const name in value) {
  77. if (value[name]) {
  78. res += name + ' ';
  79. }
  80. }
  81. }
  82. return res.trim();
  83. }
  84. // These tag configs are shared between compiler-dom and runtime-dom, so they
  85. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  86. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  87. 'header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,' +
  88. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  89. 'data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,' +
  90. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  91. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  92. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  93. 'option,output,progress,select,textarea,details,dialog,menu,' +
  94. 'summary,template,blockquote,iframe,tfoot';
  95. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  96. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  97. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  98. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  99. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  100. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  101. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  102. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  103. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  104. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  105. 'text,textPath,title,tspan,unknown,use,view';
  106. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  107. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  108. function looseCompareArrays(a, b) {
  109. if (a.length !== b.length)
  110. return false;
  111. let equal = true;
  112. for (let i = 0; equal && i < a.length; i++) {
  113. equal = looseEqual(a[i], b[i]);
  114. }
  115. return equal;
  116. }
  117. function looseEqual(a, b) {
  118. if (a === b)
  119. return true;
  120. let aValidType = isDate(a);
  121. let bValidType = isDate(b);
  122. if (aValidType || bValidType) {
  123. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  124. }
  125. aValidType = isArray(a);
  126. bValidType = isArray(b);
  127. if (aValidType || bValidType) {
  128. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  129. }
  130. aValidType = isObject(a);
  131. bValidType = isObject(b);
  132. if (aValidType || bValidType) {
  133. /* istanbul ignore if: this if will probably never be called */
  134. if (!aValidType || !bValidType) {
  135. return false;
  136. }
  137. const aKeysCount = Object.keys(a).length;
  138. const bKeysCount = Object.keys(b).length;
  139. if (aKeysCount !== bKeysCount) {
  140. return false;
  141. }
  142. for (const key in a) {
  143. const aHasKey = a.hasOwnProperty(key);
  144. const bHasKey = b.hasOwnProperty(key);
  145. if ((aHasKey && !bHasKey) ||
  146. (!aHasKey && bHasKey) ||
  147. !looseEqual(a[key], b[key])) {
  148. return false;
  149. }
  150. }
  151. }
  152. return String(a) === String(b);
  153. }
  154. function looseIndexOf(arr, val) {
  155. return arr.findIndex(item => looseEqual(item, val));
  156. }
  157. function looseHas(set, val) {
  158. for (let item of set) {
  159. if (looseEqual(item, val))
  160. return true;
  161. }
  162. return false;
  163. }
  164. /**
  165. * For converting {{ interpolation }} values to displayed strings.
  166. * @private
  167. */
  168. const toDisplayString = (val) => {
  169. return val == null
  170. ? ''
  171. : isObject(val)
  172. ? JSON.stringify(val, replacer, 2)
  173. : String(val);
  174. };
  175. const replacer = (_key, val) => {
  176. if (isMap(val)) {
  177. return {
  178. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  179. entries[`${key} =>`] = val;
  180. return entries;
  181. }, {})
  182. };
  183. }
  184. else if (isSet(val)) {
  185. return {
  186. [`Set(${val.size})`]: [...val.values()]
  187. };
  188. }
  189. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  190. return String(val);
  191. }
  192. return val;
  193. };
  194. const EMPTY_OBJ = Object.freeze({})
  195. ;
  196. const EMPTY_ARR = [];
  197. const NOOP = () => { };
  198. /**
  199. * Always return false.
  200. */
  201. const NO = () => false;
  202. const onRE = /^on[^a-z]/;
  203. const isOn = (key) => onRE.test(key);
  204. const isModelListener = (key) => key.startsWith('onUpdate:');
  205. const extend = Object.assign;
  206. const remove = (arr, el) => {
  207. const i = arr.indexOf(el);
  208. if (i > -1) {
  209. arr.splice(i, 1);
  210. }
  211. };
  212. const hasOwnProperty = Object.prototype.hasOwnProperty;
  213. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  214. const isArray = Array.isArray;
  215. const isMap = (val) => toTypeString(val) === '[object Map]';
  216. const isSet = (val) => toTypeString(val) === '[object Set]';
  217. const isDate = (val) => val instanceof Date;
  218. const isFunction = (val) => typeof val === 'function';
  219. const isString = (val) => typeof val === 'string';
  220. const isSymbol = (val) => typeof val === 'symbol';
  221. const isObject = (val) => val !== null && typeof val === 'object';
  222. const isPromise = (val) => {
  223. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  224. };
  225. const objectToString = Object.prototype.toString;
  226. const toTypeString = (value) => objectToString.call(value);
  227. const toRawType = (value) => {
  228. return toTypeString(value).slice(8, -1);
  229. };
  230. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  231. const isIntegerKey = (key) => isString(key) &&
  232. key !== 'NaN' &&
  233. key[0] !== '-' &&
  234. '' + parseInt(key, 10) === key;
  235. const isReservedProp = /*#__PURE__*/ makeMap('key,ref,' +
  236. 'onVnodeBeforeMount,onVnodeMounted,' +
  237. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  238. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  239. const cacheStringFunction = (fn) => {
  240. const cache = Object.create(null);
  241. return ((str) => {
  242. const hit = cache[str];
  243. return hit || (cache[str] = fn(str));
  244. });
  245. };
  246. const camelizeRE = /-(\w)/g;
  247. /**
  248. * @private
  249. */
  250. const camelize = cacheStringFunction((str) => {
  251. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  252. });
  253. const hyphenateRE = /\B([A-Z])/g;
  254. /**
  255. * @private
  256. */
  257. const hyphenate = cacheStringFunction((str) => {
  258. return str.replace(hyphenateRE, '-$1').toLowerCase();
  259. });
  260. /**
  261. * @private
  262. */
  263. const capitalize = cacheStringFunction((str) => {
  264. return str.charAt(0).toUpperCase() + str.slice(1);
  265. });
  266. // compare whether a value has changed, accounting for NaN.
  267. const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue);
  268. const invokeArrayFns = (fns, arg) => {
  269. for (let i = 0; i < fns.length; i++) {
  270. fns[i](arg);
  271. }
  272. };
  273. const def = (obj, key, value) => {
  274. Object.defineProperty(obj, key, {
  275. configurable: true,
  276. enumerable: false,
  277. value
  278. });
  279. };
  280. const toNumber = (val) => {
  281. const n = parseFloat(val);
  282. return isNaN(n) ? val : n;
  283. };
  284. let _globalThis;
  285. const getGlobalThis = () => {
  286. return (_globalThis ||
  287. (_globalThis =
  288. typeof globalThis !== 'undefined'
  289. ? globalThis
  290. : typeof self !== 'undefined'
  291. ? self
  292. : typeof window !== 'undefined'
  293. ? window
  294. : typeof global !== 'undefined'
  295. ? global
  296. : {}));
  297. };
  298. const targetMap = new WeakMap();
  299. const effectStack = [];
  300. let activeEffect;
  301. const ITERATE_KEY = Symbol( 'iterate' );
  302. const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
  303. function isEffect(fn) {
  304. return fn && fn._isEffect === true;
  305. }
  306. function effect(fn, options = EMPTY_OBJ) {
  307. if (isEffect(fn)) {
  308. fn = fn.raw;
  309. }
  310. const effect = createReactiveEffect(fn, options);
  311. if (!options.lazy) {
  312. effect();
  313. }
  314. return effect;
  315. }
  316. function stop(effect) {
  317. if (effect.active) {
  318. cleanup(effect);
  319. if (effect.options.onStop) {
  320. effect.options.onStop();
  321. }
  322. effect.active = false;
  323. }
  324. }
  325. let uid = 0;
  326. function createReactiveEffect(fn, options) {
  327. const effect = function reactiveEffect() {
  328. if (!effect.active) {
  329. return options.scheduler ? undefined : fn();
  330. }
  331. if (!effectStack.includes(effect)) {
  332. cleanup(effect);
  333. try {
  334. enableTracking();
  335. effectStack.push(effect);
  336. activeEffect = effect;
  337. return fn();
  338. }
  339. finally {
  340. effectStack.pop();
  341. resetTracking();
  342. activeEffect = effectStack[effectStack.length - 1];
  343. }
  344. }
  345. };
  346. effect.id = uid++;
  347. effect._isEffect = true;
  348. effect.active = true;
  349. effect.raw = fn;
  350. effect.deps = [];
  351. effect.options = options;
  352. return effect;
  353. }
  354. function cleanup(effect) {
  355. const { deps } = effect;
  356. if (deps.length) {
  357. for (let i = 0; i < deps.length; i++) {
  358. deps[i].delete(effect);
  359. }
  360. deps.length = 0;
  361. }
  362. }
  363. let shouldTrack = true;
  364. const trackStack = [];
  365. function pauseTracking() {
  366. trackStack.push(shouldTrack);
  367. shouldTrack = false;
  368. }
  369. function enableTracking() {
  370. trackStack.push(shouldTrack);
  371. shouldTrack = true;
  372. }
  373. function resetTracking() {
  374. const last = trackStack.pop();
  375. shouldTrack = last === undefined ? true : last;
  376. }
  377. function track(target, type, key) {
  378. if (!shouldTrack || activeEffect === undefined) {
  379. return;
  380. }
  381. let depsMap = targetMap.get(target);
  382. if (!depsMap) {
  383. targetMap.set(target, (depsMap = new Map()));
  384. }
  385. let dep = depsMap.get(key);
  386. if (!dep) {
  387. depsMap.set(key, (dep = new Set()));
  388. }
  389. if (!dep.has(activeEffect)) {
  390. dep.add(activeEffect);
  391. activeEffect.deps.push(dep);
  392. if ( activeEffect.options.onTrack) {
  393. activeEffect.options.onTrack({
  394. effect: activeEffect,
  395. target,
  396. type,
  397. key
  398. });
  399. }
  400. }
  401. }
  402. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  403. const depsMap = targetMap.get(target);
  404. if (!depsMap) {
  405. // never been tracked
  406. return;
  407. }
  408. const effects = new Set();
  409. const add = (effectsToAdd) => {
  410. if (effectsToAdd) {
  411. effectsToAdd.forEach(effect => {
  412. if (effect !== activeEffect || effect.options.allowRecurse) {
  413. effects.add(effect);
  414. }
  415. });
  416. }
  417. };
  418. if (type === "clear" /* CLEAR */) {
  419. // collection being cleared
  420. // trigger all effects for target
  421. depsMap.forEach(add);
  422. }
  423. else if (key === 'length' && isArray(target)) {
  424. depsMap.forEach((dep, key) => {
  425. if (key === 'length' || key >= newValue) {
  426. add(dep);
  427. }
  428. });
  429. }
  430. else {
  431. // schedule runs for SET | ADD | DELETE
  432. if (key !== void 0) {
  433. add(depsMap.get(key));
  434. }
  435. // also run for iteration key on ADD | DELETE | Map.SET
  436. switch (type) {
  437. case "add" /* ADD */:
  438. if (!isArray(target)) {
  439. add(depsMap.get(ITERATE_KEY));
  440. if (isMap(target)) {
  441. add(depsMap.get(MAP_KEY_ITERATE_KEY));
  442. }
  443. }
  444. else if (isIntegerKey(key)) {
  445. // new index added to array -> length changes
  446. add(depsMap.get('length'));
  447. }
  448. break;
  449. case "delete" /* DELETE */:
  450. if (!isArray(target)) {
  451. add(depsMap.get(ITERATE_KEY));
  452. if (isMap(target)) {
  453. add(depsMap.get(MAP_KEY_ITERATE_KEY));
  454. }
  455. }
  456. break;
  457. case "set" /* SET */:
  458. if (isMap(target)) {
  459. add(depsMap.get(ITERATE_KEY));
  460. }
  461. break;
  462. }
  463. }
  464. const run = (effect) => {
  465. if ( effect.options.onTrigger) {
  466. effect.options.onTrigger({
  467. effect,
  468. target,
  469. key,
  470. type,
  471. newValue,
  472. oldValue,
  473. oldTarget
  474. });
  475. }
  476. if (effect.options.scheduler) {
  477. effect.options.scheduler(effect);
  478. }
  479. else {
  480. effect();
  481. }
  482. };
  483. effects.forEach(run);
  484. }
  485. const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
  486. .map(key => Symbol[key])
  487. .filter(isSymbol));
  488. const get = /*#__PURE__*/ createGetter();
  489. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  490. const readonlyGet = /*#__PURE__*/ createGetter(true);
  491. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  492. const arrayInstrumentations = {};
  493. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  494. const method = Array.prototype[key];
  495. arrayInstrumentations[key] = function (...args) {
  496. const arr = toRaw(this);
  497. for (let i = 0, l = this.length; i < l; i++) {
  498. track(arr, "get" /* GET */, i + '');
  499. }
  500. // we run the method using the original args first (which may be reactive)
  501. const res = method.apply(arr, args);
  502. if (res === -1 || res === false) {
  503. // if that didn't work, run it again using raw values.
  504. return method.apply(arr, args.map(toRaw));
  505. }
  506. else {
  507. return res;
  508. }
  509. };
  510. });
  511. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  512. const method = Array.prototype[key];
  513. arrayInstrumentations[key] = function (...args) {
  514. pauseTracking();
  515. const res = method.apply(this, args);
  516. enableTracking();
  517. return res;
  518. };
  519. });
  520. function createGetter(isReadonly = false, shallow = false) {
  521. return function get(target, key, receiver) {
  522. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  523. return !isReadonly;
  524. }
  525. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  526. return isReadonly;
  527. }
  528. else if (key === "__v_raw" /* RAW */ &&
  529. receiver === (isReadonly ? readonlyMap : reactiveMap).get(target)) {
  530. return target;
  531. }
  532. const targetIsArray = isArray(target);
  533. if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
  534. return Reflect.get(arrayInstrumentations, key, receiver);
  535. }
  536. const res = Reflect.get(target, key, receiver);
  537. const keyIsSymbol = isSymbol(key);
  538. if (keyIsSymbol
  539. ? builtInSymbols.has(key)
  540. : key === `__proto__` || key === `__v_isRef`) {
  541. return res;
  542. }
  543. if (!isReadonly) {
  544. track(target, "get" /* GET */, key);
  545. }
  546. if (shallow) {
  547. return res;
  548. }
  549. if (isRef(res)) {
  550. // ref unwrapping - does not apply for Array + integer key.
  551. const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
  552. return shouldUnwrap ? res.value : res;
  553. }
  554. if (isObject(res)) {
  555. // Convert returned value into a proxy as well. we do the isObject check
  556. // here to avoid invalid value warning. Also need to lazy access readonly
  557. // and reactive here to avoid circular dependency.
  558. return isReadonly ? readonly(res) : reactive(res);
  559. }
  560. return res;
  561. };
  562. }
  563. const set = /*#__PURE__*/ createSetter();
  564. const shallowSet = /*#__PURE__*/ createSetter(true);
  565. function createSetter(shallow = false) {
  566. return function set(target, key, value, receiver) {
  567. const oldValue = target[key];
  568. if (!shallow) {
  569. value = toRaw(value);
  570. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  571. oldValue.value = value;
  572. return true;
  573. }
  574. }
  575. const hadKey = isArray(target) && isIntegerKey(key)
  576. ? Number(key) < target.length
  577. : hasOwn(target, key);
  578. const result = Reflect.set(target, key, value, receiver);
  579. // don't trigger if target is something up in the prototype chain of original
  580. if (target === toRaw(receiver)) {
  581. if (!hadKey) {
  582. trigger(target, "add" /* ADD */, key, value);
  583. }
  584. else if (hasChanged(value, oldValue)) {
  585. trigger(target, "set" /* SET */, key, value, oldValue);
  586. }
  587. }
  588. return result;
  589. };
  590. }
  591. function deleteProperty(target, key) {
  592. const hadKey = hasOwn(target, key);
  593. const oldValue = target[key];
  594. const result = Reflect.deleteProperty(target, key);
  595. if (result && hadKey) {
  596. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  597. }
  598. return result;
  599. }
  600. function has(target, key) {
  601. const result = Reflect.has(target, key);
  602. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  603. track(target, "has" /* HAS */, key);
  604. }
  605. return result;
  606. }
  607. function ownKeys(target) {
  608. track(target, "iterate" /* ITERATE */, ITERATE_KEY);
  609. return Reflect.ownKeys(target);
  610. }
  611. const mutableHandlers = {
  612. get,
  613. set,
  614. deleteProperty,
  615. has,
  616. ownKeys
  617. };
  618. const readonlyHandlers = {
  619. get: readonlyGet,
  620. set(target, key) {
  621. {
  622. console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  623. }
  624. return true;
  625. },
  626. deleteProperty(target, key) {
  627. {
  628. console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  629. }
  630. return true;
  631. }
  632. };
  633. const shallowReactiveHandlers = extend({}, mutableHandlers, {
  634. get: shallowGet,
  635. set: shallowSet
  636. });
  637. // Props handlers are special in the sense that it should not unwrap top-level
  638. // refs (in order to allow refs to be explicitly passed down), but should
  639. // retain the reactivity of the normal readonly object.
  640. const shallowReadonlyHandlers = extend({}, readonlyHandlers, {
  641. get: shallowReadonlyGet
  642. });
  643. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  644. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  645. const toShallow = (value) => value;
  646. const getProto = (v) => Reflect.getPrototypeOf(v);
  647. function get$1(target, key, isReadonly = false, isShallow = false) {
  648. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  649. // of the value
  650. target = target["__v_raw" /* RAW */];
  651. const rawTarget = toRaw(target);
  652. const rawKey = toRaw(key);
  653. if (key !== rawKey) {
  654. !isReadonly && track(rawTarget, "get" /* GET */, key);
  655. }
  656. !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
  657. const { has } = getProto(rawTarget);
  658. const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
  659. if (has.call(rawTarget, key)) {
  660. return wrap(target.get(key));
  661. }
  662. else if (has.call(rawTarget, rawKey)) {
  663. return wrap(target.get(rawKey));
  664. }
  665. }
  666. function has$1(key, isReadonly = false) {
  667. const target = this["__v_raw" /* RAW */];
  668. const rawTarget = toRaw(target);
  669. const rawKey = toRaw(key);
  670. if (key !== rawKey) {
  671. !isReadonly && track(rawTarget, "has" /* HAS */, key);
  672. }
  673. !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
  674. return key === rawKey
  675. ? target.has(key)
  676. : target.has(key) || target.has(rawKey);
  677. }
  678. function size(target, isReadonly = false) {
  679. target = target["__v_raw" /* RAW */];
  680. !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
  681. return Reflect.get(target, 'size', target);
  682. }
  683. function add(value) {
  684. value = toRaw(value);
  685. const target = toRaw(this);
  686. const proto = getProto(target);
  687. const hadKey = proto.has.call(target, value);
  688. const result = target.add(value);
  689. if (!hadKey) {
  690. trigger(target, "add" /* ADD */, value, value);
  691. }
  692. return result;
  693. }
  694. function set$1(key, value) {
  695. value = toRaw(value);
  696. const target = toRaw(this);
  697. const { has, get } = getProto(target);
  698. let hadKey = has.call(target, key);
  699. if (!hadKey) {
  700. key = toRaw(key);
  701. hadKey = has.call(target, key);
  702. }
  703. else {
  704. checkIdentityKeys(target, has, key);
  705. }
  706. const oldValue = get.call(target, key);
  707. const result = target.set(key, value);
  708. if (!hadKey) {
  709. trigger(target, "add" /* ADD */, key, value);
  710. }
  711. else if (hasChanged(value, oldValue)) {
  712. trigger(target, "set" /* SET */, key, value, oldValue);
  713. }
  714. return result;
  715. }
  716. function deleteEntry(key) {
  717. const target = toRaw(this);
  718. const { has, get } = getProto(target);
  719. let hadKey = has.call(target, key);
  720. if (!hadKey) {
  721. key = toRaw(key);
  722. hadKey = has.call(target, key);
  723. }
  724. else {
  725. checkIdentityKeys(target, has, key);
  726. }
  727. const oldValue = get ? get.call(target, key) : undefined;
  728. // forward the operation before queueing reactions
  729. const result = target.delete(key);
  730. if (hadKey) {
  731. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  732. }
  733. return result;
  734. }
  735. function clear() {
  736. const target = toRaw(this);
  737. const hadItems = target.size !== 0;
  738. const oldTarget = isMap(target)
  739. ? new Map(target)
  740. : new Set(target)
  741. ;
  742. // forward the operation before queueing reactions
  743. const result = target.clear();
  744. if (hadItems) {
  745. trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
  746. }
  747. return result;
  748. }
  749. function createForEach(isReadonly, isShallow) {
  750. return function forEach(callback, thisArg) {
  751. const observed = this;
  752. const target = observed["__v_raw" /* RAW */];
  753. const rawTarget = toRaw(target);
  754. const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
  755. !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
  756. return target.forEach((value, key) => {
  757. // important: make sure the callback is
  758. // 1. invoked with the reactive map as `this` and 3rd arg
  759. // 2. the value received should be a corresponding reactive/readonly.
  760. return callback.call(thisArg, wrap(value), wrap(key), observed);
  761. });
  762. };
  763. }
  764. function createIterableMethod(method, isReadonly, isShallow) {
  765. return function (...args) {
  766. const target = this["__v_raw" /* RAW */];
  767. const rawTarget = toRaw(target);
  768. const targetIsMap = isMap(rawTarget);
  769. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  770. const isKeyOnly = method === 'keys' && targetIsMap;
  771. const innerIterator = target[method](...args);
  772. const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive;
  773. !isReadonly &&
  774. track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  775. // return a wrapped iterator which returns observed versions of the
  776. // values emitted from the real iterator
  777. return {
  778. // iterator protocol
  779. next() {
  780. const { value, done } = innerIterator.next();
  781. return done
  782. ? { value, done }
  783. : {
  784. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  785. done
  786. };
  787. },
  788. // iterable protocol
  789. [Symbol.iterator]() {
  790. return this;
  791. }
  792. };
  793. };
  794. }
  795. function createReadonlyMethod(type) {
  796. return function (...args) {
  797. {
  798. const key = args[0] ? `on key "${args[0]}" ` : ``;
  799. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  800. }
  801. return type === "delete" /* DELETE */ ? false : this;
  802. };
  803. }
  804. const mutableInstrumentations = {
  805. get(key) {
  806. return get$1(this, key);
  807. },
  808. get size() {
  809. return size(this);
  810. },
  811. has: has$1,
  812. add,
  813. set: set$1,
  814. delete: deleteEntry,
  815. clear,
  816. forEach: createForEach(false, false)
  817. };
  818. const shallowInstrumentations = {
  819. get(key) {
  820. return get$1(this, key, false, true);
  821. },
  822. get size() {
  823. return size(this);
  824. },
  825. has: has$1,
  826. add,
  827. set: set$1,
  828. delete: deleteEntry,
  829. clear,
  830. forEach: createForEach(false, true)
  831. };
  832. const readonlyInstrumentations = {
  833. get(key) {
  834. return get$1(this, key, true);
  835. },
  836. get size() {
  837. return size(this, true);
  838. },
  839. has(key) {
  840. return has$1.call(this, key, true);
  841. },
  842. add: createReadonlyMethod("add" /* ADD */),
  843. set: createReadonlyMethod("set" /* SET */),
  844. delete: createReadonlyMethod("delete" /* DELETE */),
  845. clear: createReadonlyMethod("clear" /* CLEAR */),
  846. forEach: createForEach(true, false)
  847. };
  848. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  849. iteratorMethods.forEach(method => {
  850. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  851. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  852. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  853. });
  854. function createInstrumentationGetter(isReadonly, shallow) {
  855. const instrumentations = shallow
  856. ? shallowInstrumentations
  857. : isReadonly
  858. ? readonlyInstrumentations
  859. : mutableInstrumentations;
  860. return (target, key, receiver) => {
  861. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  862. return !isReadonly;
  863. }
  864. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  865. return isReadonly;
  866. }
  867. else if (key === "__v_raw" /* RAW */) {
  868. return target;
  869. }
  870. return Reflect.get(hasOwn(instrumentations, key) && key in target
  871. ? instrumentations
  872. : target, key, receiver);
  873. };
  874. }
  875. const mutableCollectionHandlers = {
  876. get: createInstrumentationGetter(false, false)
  877. };
  878. const shallowCollectionHandlers = {
  879. get: createInstrumentationGetter(false, true)
  880. };
  881. const readonlyCollectionHandlers = {
  882. get: createInstrumentationGetter(true, false)
  883. };
  884. function checkIdentityKeys(target, has, key) {
  885. const rawKey = toRaw(key);
  886. if (rawKey !== key && has.call(target, rawKey)) {
  887. const type = toRawType(target);
  888. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  889. `versions of the same object${type === `Map` ? `as keys` : ``}, ` +
  890. `which can lead to inconsistencies. ` +
  891. `Avoid differentiating between the raw and reactive versions ` +
  892. `of an object and only use the reactive version if possible.`);
  893. }
  894. }
  895. const reactiveMap = new WeakMap();
  896. const readonlyMap = new WeakMap();
  897. function targetTypeMap(rawType) {
  898. switch (rawType) {
  899. case 'Object':
  900. case 'Array':
  901. return 1 /* COMMON */;
  902. case 'Map':
  903. case 'Set':
  904. case 'WeakMap':
  905. case 'WeakSet':
  906. return 2 /* COLLECTION */;
  907. default:
  908. return 0 /* INVALID */;
  909. }
  910. }
  911. function getTargetType(value) {
  912. return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
  913. ? 0 /* INVALID */
  914. : targetTypeMap(toRawType(value));
  915. }
  916. function reactive(target) {
  917. // if trying to observe a readonly proxy, return the readonly version.
  918. if (target && target["__v_isReadonly" /* IS_READONLY */]) {
  919. return target;
  920. }
  921. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
  922. }
  923. // Return a reactive-copy of the original object, where only the root level
  924. // properties are reactive, and does NOT unwrap refs nor recursively convert
  925. // returned properties.
  926. function shallowReactive(target) {
  927. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
  928. }
  929. function readonly(target) {
  930. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
  931. }
  932. // Return a reactive-copy of the original object, where only the root level
  933. // properties are readonly, and does NOT unwrap refs nor recursively convert
  934. // returned properties.
  935. // This is used for creating the props proxy object for stateful components.
  936. function shallowReadonly(target) {
  937. return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
  938. }
  939. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) {
  940. if (!isObject(target)) {
  941. {
  942. console.warn(`value cannot be made reactive: ${String(target)}`);
  943. }
  944. return target;
  945. }
  946. // target is already a Proxy, return it.
  947. // exception: calling readonly() on a reactive object
  948. if (target["__v_raw" /* RAW */] &&
  949. !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
  950. return target;
  951. }
  952. // target already has corresponding Proxy
  953. const proxyMap = isReadonly ? readonlyMap : reactiveMap;
  954. const existingProxy = proxyMap.get(target);
  955. if (existingProxy) {
  956. return existingProxy;
  957. }
  958. // only a whitelist of value types can be observed.
  959. const targetType = getTargetType(target);
  960. if (targetType === 0 /* INVALID */) {
  961. return target;
  962. }
  963. const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
  964. proxyMap.set(target, proxy);
  965. return proxy;
  966. }
  967. function isReactive(value) {
  968. if (isReadonly(value)) {
  969. return isReactive(value["__v_raw" /* RAW */]);
  970. }
  971. return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
  972. }
  973. function isReadonly(value) {
  974. return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
  975. }
  976. function isProxy(value) {
  977. return isReactive(value) || isReadonly(value);
  978. }
  979. function toRaw(observed) {
  980. return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
  981. }
  982. function markRaw(value) {
  983. def(value, "__v_skip" /* SKIP */, true);
  984. return value;
  985. }
  986. const convert = (val) => isObject(val) ? reactive(val) : val;
  987. function isRef(r) {
  988. return Boolean(r && r.__v_isRef === true);
  989. }
  990. function ref(value) {
  991. return createRef(value);
  992. }
  993. function shallowRef(value) {
  994. return createRef(value, true);
  995. }
  996. class RefImpl {
  997. constructor(_rawValue, _shallow = false) {
  998. this._rawValue = _rawValue;
  999. this._shallow = _shallow;
  1000. this.__v_isRef = true;
  1001. this._value = _shallow ? _rawValue : convert(_rawValue);
  1002. }
  1003. get value() {
  1004. track(toRaw(this), "get" /* GET */, 'value');
  1005. return this._value;
  1006. }
  1007. set value(newVal) {
  1008. if (hasChanged(toRaw(newVal), this._rawValue)) {
  1009. this._rawValue = newVal;
  1010. this._value = this._shallow ? newVal : convert(newVal);
  1011. trigger(toRaw(this), "set" /* SET */, 'value', newVal);
  1012. }
  1013. }
  1014. }
  1015. function createRef(rawValue, shallow = false) {
  1016. if (isRef(rawValue)) {
  1017. return rawValue;
  1018. }
  1019. return new RefImpl(rawValue, shallow);
  1020. }
  1021. function triggerRef(ref) {
  1022. trigger(ref, "set" /* SET */, 'value', ref.value );
  1023. }
  1024. function unref(ref) {
  1025. return isRef(ref) ? ref.value : ref;
  1026. }
  1027. const shallowUnwrapHandlers = {
  1028. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1029. set: (target, key, value, receiver) => {
  1030. const oldValue = target[key];
  1031. if (isRef(oldValue) && !isRef(value)) {
  1032. oldValue.value = value;
  1033. return true;
  1034. }
  1035. else {
  1036. return Reflect.set(target, key, value, receiver);
  1037. }
  1038. }
  1039. };
  1040. function proxyRefs(objectWithRefs) {
  1041. return isReactive(objectWithRefs)
  1042. ? objectWithRefs
  1043. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1044. }
  1045. class CustomRefImpl {
  1046. constructor(factory) {
  1047. this.__v_isRef = true;
  1048. const { get, set } = factory(() => track(this, "get" /* GET */, 'value'), () => trigger(this, "set" /* SET */, 'value'));
  1049. this._get = get;
  1050. this._set = set;
  1051. }
  1052. get value() {
  1053. return this._get();
  1054. }
  1055. set value(newVal) {
  1056. this._set(newVal);
  1057. }
  1058. }
  1059. function customRef(factory) {
  1060. return new CustomRefImpl(factory);
  1061. }
  1062. function toRefs(object) {
  1063. if ( !isProxy(object)) {
  1064. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1065. }
  1066. const ret = isArray(object) ? new Array(object.length) : {};
  1067. for (const key in object) {
  1068. ret[key] = toRef(object, key);
  1069. }
  1070. return ret;
  1071. }
  1072. class ObjectRefImpl {
  1073. constructor(_object, _key) {
  1074. this._object = _object;
  1075. this._key = _key;
  1076. this.__v_isRef = true;
  1077. }
  1078. get value() {
  1079. return this._object[this._key];
  1080. }
  1081. set value(newVal) {
  1082. this._object[this._key] = newVal;
  1083. }
  1084. }
  1085. function toRef(object, key) {
  1086. return isRef(object[key])
  1087. ? object[key]
  1088. : new ObjectRefImpl(object, key);
  1089. }
  1090. class ComputedRefImpl {
  1091. constructor(getter, _setter, isReadonly) {
  1092. this._setter = _setter;
  1093. this._dirty = true;
  1094. this.__v_isRef = true;
  1095. this.effect = effect(getter, {
  1096. lazy: true,
  1097. scheduler: () => {
  1098. if (!this._dirty) {
  1099. this._dirty = true;
  1100. trigger(toRaw(this), "set" /* SET */, 'value');
  1101. }
  1102. }
  1103. });
  1104. this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
  1105. }
  1106. get value() {
  1107. if (this._dirty) {
  1108. this._value = this.effect();
  1109. this._dirty = false;
  1110. }
  1111. track(toRaw(this), "get" /* GET */, 'value');
  1112. return this._value;
  1113. }
  1114. set value(newValue) {
  1115. this._setter(newValue);
  1116. }
  1117. }
  1118. function computed(getterOrOptions) {
  1119. let getter;
  1120. let setter;
  1121. if (isFunction(getterOrOptions)) {
  1122. getter = getterOrOptions;
  1123. setter = () => {
  1124. console.warn('Write operation failed: computed value is readonly');
  1125. }
  1126. ;
  1127. }
  1128. else {
  1129. getter = getterOrOptions.get;
  1130. setter = getterOrOptions.set;
  1131. }
  1132. return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
  1133. }
  1134. const stack = [];
  1135. function pushWarningContext(vnode) {
  1136. stack.push(vnode);
  1137. }
  1138. function popWarningContext() {
  1139. stack.pop();
  1140. }
  1141. function warn(msg, ...args) {
  1142. // avoid props formatting or warn handler tracking deps that might be mutated
  1143. // during patch, leading to infinite recursion.
  1144. pauseTracking();
  1145. const instance = stack.length ? stack[stack.length - 1].component : null;
  1146. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1147. const trace = getComponentTrace();
  1148. if (appWarnHandler) {
  1149. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  1150. msg + args.join(''),
  1151. instance && instance.proxy,
  1152. trace
  1153. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1154. .join('\n'),
  1155. trace
  1156. ]);
  1157. }
  1158. else {
  1159. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1160. /* istanbul ignore if */
  1161. if (trace.length &&
  1162. // avoid spamming console during tests
  1163. !false) {
  1164. warnArgs.push(`\n`, ...formatTrace(trace));
  1165. }
  1166. console.warn(...warnArgs);
  1167. }
  1168. resetTracking();
  1169. }
  1170. function getComponentTrace() {
  1171. let currentVNode = stack[stack.length - 1];
  1172. if (!currentVNode) {
  1173. return [];
  1174. }
  1175. // we can't just use the stack because it will be incomplete during updates
  1176. // that did not start from the root. Re-construct the parent chain using
  1177. // instance parent pointers.
  1178. const normalizedStack = [];
  1179. while (currentVNode) {
  1180. const last = normalizedStack[0];
  1181. if (last && last.vnode === currentVNode) {
  1182. last.recurseCount++;
  1183. }
  1184. else {
  1185. normalizedStack.push({
  1186. vnode: currentVNode,
  1187. recurseCount: 0
  1188. });
  1189. }
  1190. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1191. currentVNode = parentInstance && parentInstance.vnode;
  1192. }
  1193. return normalizedStack;
  1194. }
  1195. /* istanbul ignore next */
  1196. function formatTrace(trace) {
  1197. const logs = [];
  1198. trace.forEach((entry, i) => {
  1199. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1200. });
  1201. return logs;
  1202. }
  1203. function formatTraceEntry({ vnode, recurseCount }) {
  1204. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1205. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1206. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1207. const close = `>` + postfix;
  1208. return vnode.props
  1209. ? [open, ...formatProps(vnode.props), close]
  1210. : [open + close];
  1211. }
  1212. /* istanbul ignore next */
  1213. function formatProps(props) {
  1214. const res = [];
  1215. const keys = Object.keys(props);
  1216. keys.slice(0, 3).forEach(key => {
  1217. res.push(...formatProp(key, props[key]));
  1218. });
  1219. if (keys.length > 3) {
  1220. res.push(` ...`);
  1221. }
  1222. return res;
  1223. }
  1224. /* istanbul ignore next */
  1225. function formatProp(key, value, raw) {
  1226. if (isString(value)) {
  1227. value = JSON.stringify(value);
  1228. return raw ? value : [`${key}=${value}`];
  1229. }
  1230. else if (typeof value === 'number' ||
  1231. typeof value === 'boolean' ||
  1232. value == null) {
  1233. return raw ? value : [`${key}=${value}`];
  1234. }
  1235. else if (isRef(value)) {
  1236. value = formatProp(key, toRaw(value.value), true);
  1237. return raw ? value : [`${key}=Ref<`, value, `>`];
  1238. }
  1239. else if (isFunction(value)) {
  1240. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1241. }
  1242. else {
  1243. value = toRaw(value);
  1244. return raw ? value : [`${key}=`, value];
  1245. }
  1246. }
  1247. const ErrorTypeStrings = {
  1248. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  1249. ["c" /* CREATED */]: 'created hook',
  1250. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  1251. ["m" /* MOUNTED */]: 'mounted hook',
  1252. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  1253. ["u" /* UPDATED */]: 'updated',
  1254. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1255. ["um" /* UNMOUNTED */]: 'unmounted hook',
  1256. ["a" /* ACTIVATED */]: 'activated hook',
  1257. ["da" /* DEACTIVATED */]: 'deactivated hook',
  1258. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  1259. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  1260. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  1261. [0 /* SETUP_FUNCTION */]: 'setup function',
  1262. [1 /* RENDER_FUNCTION */]: 'render function',
  1263. [2 /* WATCH_GETTER */]: 'watcher getter',
  1264. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  1265. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  1266. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  1267. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1268. [7 /* VNODE_HOOK */]: 'vnode hook',
  1269. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  1270. [9 /* TRANSITION_HOOK */]: 'transition hook',
  1271. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  1272. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  1273. [12 /* FUNCTION_REF */]: 'ref function',
  1274. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1275. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1276. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next'
  1277. };
  1278. function callWithErrorHandling(fn, instance, type, args) {
  1279. let res;
  1280. try {
  1281. res = args ? fn(...args) : fn();
  1282. }
  1283. catch (err) {
  1284. handleError(err, instance, type);
  1285. }
  1286. return res;
  1287. }
  1288. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1289. if (isFunction(fn)) {
  1290. const res = callWithErrorHandling(fn, instance, type, args);
  1291. if (res && isPromise(res)) {
  1292. res.catch(err => {
  1293. handleError(err, instance, type);
  1294. });
  1295. }
  1296. return res;
  1297. }
  1298. const values = [];
  1299. for (let i = 0; i < fn.length; i++) {
  1300. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1301. }
  1302. return values;
  1303. }
  1304. function handleError(err, instance, type, throwInDev = true) {
  1305. const contextVNode = instance ? instance.vnode : null;
  1306. if (instance) {
  1307. let cur = instance.parent;
  1308. // the exposed instance is the render proxy to keep it consistent with 2.x
  1309. const exposedInstance = instance.proxy;
  1310. // in production the hook receives only the error code
  1311. const errorInfo = ErrorTypeStrings[type] ;
  1312. while (cur) {
  1313. const errorCapturedHooks = cur.ec;
  1314. if (errorCapturedHooks) {
  1315. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1316. if (errorCapturedHooks[i](err, exposedInstance, errorInfo)) {
  1317. return;
  1318. }
  1319. }
  1320. }
  1321. cur = cur.parent;
  1322. }
  1323. // app-level handling
  1324. const appErrorHandler = instance.appContext.config.errorHandler;
  1325. if (appErrorHandler) {
  1326. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1327. return;
  1328. }
  1329. }
  1330. logError(err, type, contextVNode, throwInDev);
  1331. }
  1332. function logError(err, type, contextVNode, throwInDev = true) {
  1333. {
  1334. const info = ErrorTypeStrings[type];
  1335. if (contextVNode) {
  1336. pushWarningContext(contextVNode);
  1337. }
  1338. warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1339. if (contextVNode) {
  1340. popWarningContext();
  1341. }
  1342. // crash in dev by default so it's more noticeable
  1343. if (throwInDev) {
  1344. throw err;
  1345. }
  1346. else {
  1347. console.error(err);
  1348. }
  1349. }
  1350. }
  1351. let isFlushing = false;
  1352. let isFlushPending = false;
  1353. const queue = [];
  1354. let flushIndex = 0;
  1355. const pendingPreFlushCbs = [];
  1356. let activePreFlushCbs = null;
  1357. let preFlushIndex = 0;
  1358. const pendingPostFlushCbs = [];
  1359. let activePostFlushCbs = null;
  1360. let postFlushIndex = 0;
  1361. const resolvedPromise = Promise.resolve();
  1362. let currentFlushPromise = null;
  1363. let currentPreFlushParentJob = null;
  1364. const RECURSION_LIMIT = 100;
  1365. function nextTick(fn) {
  1366. const p = currentFlushPromise || resolvedPromise;
  1367. return fn ? p.then(fn) : p;
  1368. }
  1369. function queueJob(job) {
  1370. // the dedupe search uses the startIndex argument of Array.includes()
  1371. // by default the search index includes the current job that is being run
  1372. // so it cannot recursively trigger itself again.
  1373. // if the job is a watch() callback, the search will start with a +1 index to
  1374. // allow it recursively trigger itself - it is the user's responsibility to
  1375. // ensure it doesn't end up in an infinite loop.
  1376. if ((!queue.length ||
  1377. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  1378. job !== currentPreFlushParentJob) {
  1379. queue.push(job);
  1380. queueFlush();
  1381. }
  1382. }
  1383. function queueFlush() {
  1384. if (!isFlushing && !isFlushPending) {
  1385. isFlushPending = true;
  1386. currentFlushPromise = resolvedPromise.then(flushJobs);
  1387. }
  1388. }
  1389. function invalidateJob(job) {
  1390. const i = queue.indexOf(job);
  1391. if (i > -1) {
  1392. queue[i] = null;
  1393. }
  1394. }
  1395. function queueCb(cb, activeQueue, pendingQueue, index) {
  1396. if (!isArray(cb)) {
  1397. if (!activeQueue ||
  1398. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  1399. pendingQueue.push(cb);
  1400. }
  1401. }
  1402. else {
  1403. // if cb is an array, it is a component lifecycle hook which can only be
  1404. // triggered by a job, which is already deduped in the main queue, so
  1405. // we can skip duplicate check here to improve perf
  1406. pendingQueue.push(...cb);
  1407. }
  1408. queueFlush();
  1409. }
  1410. function queuePreFlushCb(cb) {
  1411. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  1412. }
  1413. function queuePostFlushCb(cb) {
  1414. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  1415. }
  1416. function flushPreFlushCbs(seen, parentJob = null) {
  1417. if (pendingPreFlushCbs.length) {
  1418. currentPreFlushParentJob = parentJob;
  1419. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  1420. pendingPreFlushCbs.length = 0;
  1421. {
  1422. seen = seen || new Map();
  1423. }
  1424. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  1425. {
  1426. checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex]);
  1427. }
  1428. activePreFlushCbs[preFlushIndex]();
  1429. }
  1430. activePreFlushCbs = null;
  1431. preFlushIndex = 0;
  1432. currentPreFlushParentJob = null;
  1433. // recursively flush until it drains
  1434. flushPreFlushCbs(seen, parentJob);
  1435. }
  1436. }
  1437. function flushPostFlushCbs(seen) {
  1438. if (pendingPostFlushCbs.length) {
  1439. const deduped = [...new Set(pendingPostFlushCbs)];
  1440. pendingPostFlushCbs.length = 0;
  1441. // #1947 already has active queue, nested flushPostFlushCbs call
  1442. if (activePostFlushCbs) {
  1443. activePostFlushCbs.push(...deduped);
  1444. return;
  1445. }
  1446. activePostFlushCbs = deduped;
  1447. {
  1448. seen = seen || new Map();
  1449. }
  1450. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1451. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1452. {
  1453. checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]);
  1454. }
  1455. activePostFlushCbs[postFlushIndex]();
  1456. }
  1457. activePostFlushCbs = null;
  1458. postFlushIndex = 0;
  1459. }
  1460. }
  1461. const getId = (job) => job.id == null ? Infinity : job.id;
  1462. function flushJobs(seen) {
  1463. isFlushPending = false;
  1464. isFlushing = true;
  1465. {
  1466. seen = seen || new Map();
  1467. }
  1468. flushPreFlushCbs(seen);
  1469. // Sort queue before flush.
  1470. // This ensures that:
  1471. // 1. Components are updated from parent to child. (because parent is always
  1472. // created before the child so its render effect will have smaller
  1473. // priority number)
  1474. // 2. If a component is unmounted during a parent component's update,
  1475. // its update can be skipped.
  1476. // Jobs can never be null before flush starts, since they are only invalidated
  1477. // during execution of another flushed job.
  1478. queue.sort((a, b) => getId(a) - getId(b));
  1479. try {
  1480. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1481. const job = queue[flushIndex];
  1482. if (job) {
  1483. if (true) {
  1484. checkRecursiveUpdates(seen, job);
  1485. }
  1486. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  1487. }
  1488. }
  1489. }
  1490. finally {
  1491. flushIndex = 0;
  1492. queue.length = 0;
  1493. flushPostFlushCbs(seen);
  1494. isFlushing = false;
  1495. currentFlushPromise = null;
  1496. // some postFlushCb queued jobs!
  1497. // keep flushing until it drains.
  1498. if (queue.length || pendingPostFlushCbs.length) {
  1499. flushJobs(seen);
  1500. }
  1501. }
  1502. }
  1503. function checkRecursiveUpdates(seen, fn) {
  1504. if (!seen.has(fn)) {
  1505. seen.set(fn, 1);
  1506. }
  1507. else {
  1508. const count = seen.get(fn);
  1509. if (count > RECURSION_LIMIT) {
  1510. throw new Error(`Maximum recursive updates exceeded. ` +
  1511. `This means you have a reactive effect that is mutating its own ` +
  1512. `dependencies and thus recursively triggering itself. Possible sources ` +
  1513. `include component template, render function, updated hook or ` +
  1514. `watcher source function.`);
  1515. }
  1516. else {
  1517. seen.set(fn, count + 1);
  1518. }
  1519. }
  1520. }
  1521. /* eslint-disable no-restricted-globals */
  1522. let isHmrUpdating = false;
  1523. const hmrDirtyComponents = new Set();
  1524. // Expose the HMR runtime on the global object
  1525. // This makes it entirely tree-shakable without polluting the exports and makes
  1526. // it easier to be used in toolings like vue-loader
  1527. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1528. // to be set so that its instances can be registered / removed.
  1529. {
  1530. const globalObject = typeof global !== 'undefined'
  1531. ? global
  1532. : typeof self !== 'undefined'
  1533. ? self
  1534. : typeof window !== 'undefined'
  1535. ? window
  1536. : {};
  1537. globalObject.__VUE_HMR_RUNTIME__ = {
  1538. createRecord: tryWrap(createRecord),
  1539. rerender: tryWrap(rerender),
  1540. reload: tryWrap(reload)
  1541. };
  1542. }
  1543. const map = new Map();
  1544. function registerHMR(instance) {
  1545. const id = instance.type.__hmrId;
  1546. let record = map.get(id);
  1547. if (!record) {
  1548. createRecord(id);
  1549. record = map.get(id);
  1550. }
  1551. record.add(instance);
  1552. }
  1553. function unregisterHMR(instance) {
  1554. map.get(instance.type.__hmrId).delete(instance);
  1555. }
  1556. function createRecord(id) {
  1557. if (map.has(id)) {
  1558. return false;
  1559. }
  1560. map.set(id, new Set());
  1561. return true;
  1562. }
  1563. function rerender(id, newRender) {
  1564. const record = map.get(id);
  1565. if (!record)
  1566. return;
  1567. // Array.from creates a snapshot which avoids the set being mutated during
  1568. // updates
  1569. Array.from(record).forEach(instance => {
  1570. if (newRender) {
  1571. instance.render = newRender;
  1572. }
  1573. instance.renderCache = [];
  1574. // this flag forces child components with slot content to update
  1575. isHmrUpdating = true;
  1576. instance.update();
  1577. isHmrUpdating = false;
  1578. });
  1579. }
  1580. function reload(id, newComp) {
  1581. const record = map.get(id);
  1582. if (!record)
  1583. return;
  1584. // Array.from creates a snapshot which avoids the set being mutated during
  1585. // updates
  1586. Array.from(record).forEach(instance => {
  1587. const comp = instance.type;
  1588. if (!hmrDirtyComponents.has(comp)) {
  1589. // 1. Update existing comp definition to match new one
  1590. newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
  1591. extend(comp, newComp);
  1592. for (const key in comp) {
  1593. if (!(key in newComp)) {
  1594. delete comp[key];
  1595. }
  1596. }
  1597. // 2. Mark component dirty. This forces the renderer to replace the component
  1598. // on patch.
  1599. hmrDirtyComponents.add(comp);
  1600. // 3. Make sure to unmark the component after the reload.
  1601. queuePostFlushCb(() => {
  1602. hmrDirtyComponents.delete(comp);
  1603. });
  1604. }
  1605. if (instance.parent) {
  1606. // 4. Force the parent instance to re-render. This will cause all updated
  1607. // components to be unmounted and re-mounted. Queue the update so that we
  1608. // don't end up forcing the same parent to re-render multiple times.
  1609. queueJob(instance.parent.update);
  1610. }
  1611. else if (instance.appContext.reload) {
  1612. // root instance mounted via createApp() has a reload method
  1613. instance.appContext.reload();
  1614. }
  1615. else if (typeof window !== 'undefined') {
  1616. // root instance inside tree created via raw render(). Force reload.
  1617. window.location.reload();
  1618. }
  1619. else {
  1620. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  1621. }
  1622. });
  1623. }
  1624. function tryWrap(fn) {
  1625. return (id, arg) => {
  1626. try {
  1627. return fn(id, arg);
  1628. }
  1629. catch (e) {
  1630. console.error(e);
  1631. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  1632. `Full reload required.`);
  1633. }
  1634. };
  1635. }
  1636. function setDevtoolsHook(hook) {
  1637. exports.devtools = hook;
  1638. }
  1639. function devtoolsInitApp(app, version) {
  1640. // TODO queue if devtools is undefined
  1641. if (!exports.devtools)
  1642. return;
  1643. exports.devtools.emit("app:init" /* APP_INIT */, app, version, {
  1644. Fragment,
  1645. Text,
  1646. Comment,
  1647. Static
  1648. });
  1649. }
  1650. function devtoolsUnmountApp(app) {
  1651. if (!exports.devtools)
  1652. return;
  1653. exports.devtools.emit("app:unmount" /* APP_UNMOUNT */, app);
  1654. }
  1655. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  1656. const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  1657. const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  1658. function createDevtoolsComponentHook(hook) {
  1659. return (component) => {
  1660. if (!exports.devtools)
  1661. return;
  1662. exports.devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined);
  1663. };
  1664. }
  1665. function devtoolsComponentEmit(component, event, params) {
  1666. if (!exports.devtools)
  1667. return;
  1668. exports.devtools.emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  1669. }
  1670. function emit(instance, event, ...args) {
  1671. const props = instance.vnode.props || EMPTY_OBJ;
  1672. {
  1673. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  1674. if (emitsOptions) {
  1675. if (!(event in emitsOptions)) {
  1676. if (!propsOptions || !(`on` + capitalize(event) in propsOptions)) {
  1677. warn(`Component emitted event "${event}" but it is neither declared in ` +
  1678. `the emits option nor as an "on${capitalize(event)}" prop.`);
  1679. }
  1680. }
  1681. else {
  1682. const validator = emitsOptions[event];
  1683. if (isFunction(validator)) {
  1684. const isValid = validator(...args);
  1685. if (!isValid) {
  1686. warn(`Invalid event arguments: event validation failed for event "${event}".`);
  1687. }
  1688. }
  1689. }
  1690. }
  1691. }
  1692. {
  1693. devtoolsComponentEmit(instance, event, args);
  1694. }
  1695. let handlerName = `on${capitalize(event)}`;
  1696. let handler = props[handlerName];
  1697. // for v-model update:xxx events, also trigger kebab-case equivalent
  1698. // for props passed via kebab-case
  1699. if (!handler && event.startsWith('update:')) {
  1700. handlerName = `on${capitalize(hyphenate(event))}`;
  1701. handler = props[handlerName];
  1702. }
  1703. if (!handler) {
  1704. handler = props[handlerName + `Once`];
  1705. if (!instance.emitted) {
  1706. (instance.emitted = {})[handlerName] = true;
  1707. }
  1708. else if (instance.emitted[handlerName]) {
  1709. return;
  1710. }
  1711. }
  1712. if (handler) {
  1713. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  1714. }
  1715. }
  1716. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  1717. const appId = appContext.app ? appContext.app._uid : -1;
  1718. const cache = comp.__emits || (comp.__emits = {});
  1719. const cached = cache[appId];
  1720. if (cached !== undefined) {
  1721. return cached;
  1722. }
  1723. const raw = comp.emits;
  1724. let normalized = {};
  1725. // apply mixin/extends props
  1726. let hasExtends = false;
  1727. if ( !isFunction(comp)) {
  1728. const extendEmits = (raw) => {
  1729. hasExtends = true;
  1730. extend(normalized, normalizeEmitsOptions(raw, appContext, true));
  1731. };
  1732. if (!asMixin && appContext.mixins.length) {
  1733. appContext.mixins.forEach(extendEmits);
  1734. }
  1735. if (comp.extends) {
  1736. extendEmits(comp.extends);
  1737. }
  1738. if (comp.mixins) {
  1739. comp.mixins.forEach(extendEmits);
  1740. }
  1741. }
  1742. if (!raw && !hasExtends) {
  1743. return (cache[appId] = null);
  1744. }
  1745. if (isArray(raw)) {
  1746. raw.forEach(key => (normalized[key] = null));
  1747. }
  1748. else {
  1749. extend(normalized, raw);
  1750. }
  1751. return (cache[appId] = normalized);
  1752. }
  1753. // Check if an incoming prop key is a declared emit event listener.
  1754. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  1755. // both considered matched listeners.
  1756. function isEmitListener(options, key) {
  1757. if (!options || !isOn(key)) {
  1758. return false;
  1759. }
  1760. key = key.replace(/Once$/, '');
  1761. return (hasOwn(options, key[2].toLowerCase() + key.slice(3)) ||
  1762. hasOwn(options, key.slice(2)));
  1763. }
  1764. // mark the current rendering instance for asset resolution (e.g.
  1765. // resolveComponent, resolveDirective) during render
  1766. let currentRenderingInstance = null;
  1767. function setCurrentRenderingInstance(instance) {
  1768. currentRenderingInstance = instance;
  1769. }
  1770. // dev only flag to track whether $attrs was used during render.
  1771. // If $attrs was used during render then the warning for failed attrs
  1772. // fallthrough can be suppressed.
  1773. let accessedAttrs = false;
  1774. function markAttrsAccessed() {
  1775. accessedAttrs = true;
  1776. }
  1777. function renderComponentRoot(instance) {
  1778. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
  1779. let result;
  1780. currentRenderingInstance = instance;
  1781. {
  1782. accessedAttrs = false;
  1783. }
  1784. try {
  1785. let fallthroughAttrs;
  1786. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  1787. // withProxy is a proxy with a different `has` trap only for
  1788. // runtime-compiled render functions using `with` block.
  1789. const proxyToUse = withProxy || proxy;
  1790. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  1791. fallthroughAttrs = attrs;
  1792. }
  1793. else {
  1794. // functional
  1795. const render = Component;
  1796. // in dev, mark attrs accessed if optional props (attrs === props)
  1797. if (true && attrs === props) {
  1798. markAttrsAccessed();
  1799. }
  1800. result = normalizeVNode(render.length > 1
  1801. ? render(props, true
  1802. ? {
  1803. get attrs() {
  1804. markAttrsAccessed();
  1805. return attrs;
  1806. },
  1807. slots,
  1808. emit
  1809. }
  1810. : { attrs, slots, emit })
  1811. : render(props, null /* we know it doesn't need it */));
  1812. fallthroughAttrs = Component.props
  1813. ? attrs
  1814. : getFunctionalFallthrough(attrs);
  1815. }
  1816. // attr merging
  1817. // in dev mode, comments are preserved, and it's possible for a template
  1818. // to have comments along side the root element which makes it a fragment
  1819. let root = result;
  1820. let setRoot = undefined;
  1821. if (true) {
  1822. ;
  1823. [root, setRoot] = getChildRoot(result);
  1824. }
  1825. if (Component.inheritAttrs !== false && fallthroughAttrs) {
  1826. const keys = Object.keys(fallthroughAttrs);
  1827. const { shapeFlag } = root;
  1828. if (keys.length) {
  1829. if (shapeFlag & 1 /* ELEMENT */ ||
  1830. shapeFlag & 6 /* COMPONENT */) {
  1831. if (propsOptions && keys.some(isModelListener)) {
  1832. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  1833. // prop, it indicates this component expects to handle v-model and
  1834. // it should not fallthrough.
  1835. // related: #1543, #1643, #1989
  1836. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  1837. }
  1838. root = cloneVNode(root, fallthroughAttrs);
  1839. }
  1840. else if (true && !accessedAttrs && root.type !== Comment) {
  1841. const allAttrs = Object.keys(attrs);
  1842. const eventAttrs = [];
  1843. const extraAttrs = [];
  1844. for (let i = 0, l = allAttrs.length; i < l; i++) {
  1845. const key = allAttrs[i];
  1846. if (isOn(key)) {
  1847. // ignore v-model handlers when they fail to fallthrough
  1848. if (!isModelListener(key)) {
  1849. // remove `on`, lowercase first letter to reflect event casing
  1850. // accurately
  1851. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  1852. }
  1853. }
  1854. else {
  1855. extraAttrs.push(key);
  1856. }
  1857. }
  1858. if (extraAttrs.length) {
  1859. warn(`Extraneous non-props attributes (` +
  1860. `${extraAttrs.join(', ')}) ` +
  1861. `were passed to component but could not be automatically inherited ` +
  1862. `because component renders fragment or text root nodes.`);
  1863. }
  1864. if (eventAttrs.length) {
  1865. warn(`Extraneous non-emits event listeners (` +
  1866. `${eventAttrs.join(', ')}) ` +
  1867. `were passed to component but could not be automatically inherited ` +
  1868. `because component renders fragment or text root nodes. ` +
  1869. `If the listener is intended to be a component custom event listener only, ` +
  1870. `declare it using the "emits" option.`);
  1871. }
  1872. }
  1873. }
  1874. }
  1875. // inherit directives
  1876. if (vnode.dirs) {
  1877. if (true && !isElementRoot(root)) {
  1878. warn(`Runtime directive used on component with non-element root node. ` +
  1879. `The directives will not function as intended.`);
  1880. }
  1881. root.dirs = vnode.dirs;
  1882. }
  1883. // inherit transition data
  1884. if (vnode.transition) {
  1885. if (true && !isElementRoot(root)) {
  1886. warn(`Component inside <Transition> renders non-element root node ` +
  1887. `that cannot be animated.`);
  1888. }
  1889. root.transition = vnode.transition;
  1890. }
  1891. if (true && setRoot) {
  1892. setRoot(root);
  1893. }
  1894. else {
  1895. result = root;
  1896. }
  1897. }
  1898. catch (err) {
  1899. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  1900. result = createVNode(Comment);
  1901. }
  1902. currentRenderingInstance = null;
  1903. return result;
  1904. }
  1905. /**
  1906. * dev only
  1907. * In dev mode, template root level comments are rendered, which turns the
  1908. * template into a fragment root, but we need to locate the single element
  1909. * root for attrs and scope id processing.
  1910. */
  1911. const getChildRoot = (vnode) => {
  1912. if (vnode.type !== Fragment) {
  1913. return [vnode, undefined];
  1914. }
  1915. const rawChildren = vnode.children;
  1916. const dynamicChildren = vnode.dynamicChildren;
  1917. const childRoot = filterSingleRoot(rawChildren);
  1918. if (!childRoot) {
  1919. return [vnode, undefined];
  1920. }
  1921. const index = rawChildren.indexOf(childRoot);
  1922. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  1923. const setRoot = (updatedRoot) => {
  1924. rawChildren[index] = updatedRoot;
  1925. if (dynamicIndex > -1) {
  1926. dynamicChildren[dynamicIndex] = updatedRoot;
  1927. }
  1928. else if (dynamicChildren && updatedRoot.patchFlag > 0) {
  1929. dynamicChildren.push(updatedRoot);
  1930. }
  1931. };
  1932. return [normalizeVNode(childRoot), setRoot];
  1933. };
  1934. /**
  1935. * dev only
  1936. */
  1937. function filterSingleRoot(children) {
  1938. const filtered = children.filter(child => {
  1939. return !(isVNode(child) &&
  1940. child.type === Comment &&
  1941. child.children !== 'v-if');
  1942. });
  1943. return filtered.length === 1 && isVNode(filtered[0]) ? filtered[0] : null;
  1944. }
  1945. const getFunctionalFallthrough = (attrs) => {
  1946. let res;
  1947. for (const key in attrs) {
  1948. if (key === 'class' || key === 'style' || isOn(key)) {
  1949. (res || (res = {}))[key] = attrs[key];
  1950. }
  1951. }
  1952. return res;
  1953. };
  1954. const filterModelListeners = (attrs, props) => {
  1955. const res = {};
  1956. for (const key in attrs) {
  1957. if (!isModelListener(key) || !(key.slice(9) in props)) {
  1958. res[key] = attrs[key];
  1959. }
  1960. }
  1961. return res;
  1962. };
  1963. const isElementRoot = (vnode) => {
  1964. return (vnode.shapeFlag & 6 /* COMPONENT */ ||
  1965. vnode.shapeFlag & 1 /* ELEMENT */ ||
  1966. vnode.type === Comment // potential v-if branch switch
  1967. );
  1968. };
  1969. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  1970. const { props: prevProps, children: prevChildren, component } = prevVNode;
  1971. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  1972. const emits = component.emitsOptions;
  1973. // Parent component's render function was hot-updated. Since this may have
  1974. // caused the child component's slots content to have changed, we need to
  1975. // force the child to update as well.
  1976. if ( (prevChildren || nextChildren) && isHmrUpdating) {
  1977. return true;
  1978. }
  1979. // force child update for runtime directive or transition on component vnode.
  1980. if (nextVNode.dirs || nextVNode.transition) {
  1981. return true;
  1982. }
  1983. if (optimized && patchFlag > 0) {
  1984. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  1985. // slot content that references values that might have changed,
  1986. // e.g. in a v-for
  1987. return true;
  1988. }
  1989. if (patchFlag & 16 /* FULL_PROPS */) {
  1990. if (!prevProps) {
  1991. return !!nextProps;
  1992. }
  1993. // presence of this flag indicates props are always non-null
  1994. return hasPropsChanged(prevProps, nextProps, emits);
  1995. }
  1996. else if (patchFlag & 8 /* PROPS */) {
  1997. const dynamicProps = nextVNode.dynamicProps;
  1998. for (let i = 0; i < dynamicProps.length; i++) {
  1999. const key = dynamicProps[i];
  2000. if (nextProps[key] !== prevProps[key] &&
  2001. !isEmitListener(emits, key)) {
  2002. return true;
  2003. }
  2004. }
  2005. }
  2006. }
  2007. else {
  2008. // this path is only taken by manually written render functions
  2009. // so presence of any children leads to a forced update
  2010. if (prevChildren || nextChildren) {
  2011. if (!nextChildren || !nextChildren.$stable) {
  2012. return true;
  2013. }
  2014. }
  2015. if (prevProps === nextProps) {
  2016. return false;
  2017. }
  2018. if (!prevProps) {
  2019. return !!nextProps;
  2020. }
  2021. if (!nextProps) {
  2022. return true;
  2023. }
  2024. return hasPropsChanged(prevProps, nextProps, emits);
  2025. }
  2026. return false;
  2027. }
  2028. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2029. const nextKeys = Object.keys(nextProps);
  2030. if (nextKeys.length !== Object.keys(prevProps).length) {
  2031. return true;
  2032. }
  2033. for (let i = 0; i < nextKeys.length; i++) {
  2034. const key = nextKeys[i];
  2035. if (nextProps[key] !== prevProps[key] &&
  2036. !isEmitListener(emitsOptions, key)) {
  2037. return true;
  2038. }
  2039. }
  2040. return false;
  2041. }
  2042. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2043. ) {
  2044. while (parent && parent.subTree === vnode) {
  2045. (vnode = parent.vnode).el = el;
  2046. parent = parent.parent;
  2047. }
  2048. }
  2049. const isSuspense = (type) => type.__isSuspense;
  2050. // Suspense exposes a component-like API, and is treated like a component
  2051. // in the compiler, but internally it's a special built-in type that hooks
  2052. // directly into the renderer.
  2053. const SuspenseImpl = {
  2054. // In order to make Suspense tree-shakable, we need to avoid importing it
  2055. // directly in the renderer. The renderer checks for the __isSuspense flag
  2056. // on a vnode's type and calls the `process` method, passing in renderer
  2057. // internals.
  2058. __isSuspense: true,
  2059. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized,
  2060. // platform-specific impl passed from renderer
  2061. rendererInternals) {
  2062. if (n1 == null) {
  2063. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals);
  2064. }
  2065. else {
  2066. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, optimized, rendererInternals);
  2067. }
  2068. },
  2069. hydrate: hydrateSuspense,
  2070. create: createSuspenseBoundary
  2071. };
  2072. // Force-casted public typing for h and TSX props inference
  2073. const Suspense = ( SuspenseImpl
  2074. );
  2075. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals) {
  2076. const { p: patch, o: { createElement } } = rendererInternals;
  2077. const hiddenContainer = createElement('div');
  2078. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals));
  2079. // start mounting the content subtree in an off-dom container
  2080. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, optimized);
  2081. // now check if we have encountered any async deps
  2082. if (suspense.deps > 0) {
  2083. // has async
  2084. // mount the fallback tree
  2085. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2086. isSVG, optimized);
  2087. setActiveBranch(suspense, vnode.ssFallback);
  2088. }
  2089. else {
  2090. // Suspense has no async deps. Just resolve.
  2091. suspense.resolve();
  2092. }
  2093. }
  2094. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2095. const suspense = (n2.suspense = n1.suspense);
  2096. suspense.vnode = n2;
  2097. n2.el = n1.el;
  2098. const newBranch = n2.ssContent;
  2099. const newFallback = n2.ssFallback;
  2100. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2101. if (pendingBranch) {
  2102. suspense.pendingBranch = newBranch;
  2103. if (isSameVNodeType(newBranch, pendingBranch)) {
  2104. // same root type but content may have changed.
  2105. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);
  2106. if (suspense.deps <= 0) {
  2107. suspense.resolve();
  2108. }
  2109. else if (isInFallback) {
  2110. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2111. isSVG, optimized);
  2112. setActiveBranch(suspense, newFallback);
  2113. }
  2114. }
  2115. else {
  2116. // toggled before pending tree is resolved
  2117. suspense.pendingId++;
  2118. if (isHydrating) {
  2119. // if toggled before hydration is finished, the current DOM tree is
  2120. // no longer valid. set it as the active branch so it will be unmounted
  2121. // when resolved
  2122. suspense.isHydrating = false;
  2123. suspense.activeBranch = pendingBranch;
  2124. }
  2125. else {
  2126. unmount(pendingBranch, parentComponent, suspense);
  2127. }
  2128. // increment pending ID. this is used to invalidate async callbacks
  2129. // reset suspense state
  2130. suspense.deps = 0;
  2131. // discard effects from pending branch
  2132. suspense.effects.length = 0;
  2133. // discard previous container
  2134. suspense.hiddenContainer = createElement('div');
  2135. if (isInFallback) {
  2136. // already in fallback state
  2137. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);
  2138. if (suspense.deps <= 0) {
  2139. suspense.resolve();
  2140. }
  2141. else {
  2142. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2143. isSVG, optimized);
  2144. setActiveBranch(suspense, newFallback);
  2145. }
  2146. }
  2147. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2148. // toggled "back" to current active branch
  2149. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, optimized);
  2150. // force resolve
  2151. suspense.resolve(true);
  2152. }
  2153. else {
  2154. // switched to a 3rd branch
  2155. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);
  2156. if (suspense.deps <= 0) {
  2157. suspense.resolve();
  2158. }
  2159. }
  2160. }
  2161. }
  2162. else {
  2163. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2164. // root did not change, just normal patch
  2165. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, optimized);
  2166. setActiveBranch(suspense, newBranch);
  2167. }
  2168. else {
  2169. // root node toggled
  2170. // invoke @pending event
  2171. const onPending = n2.props && n2.props.onPending;
  2172. if (isFunction(onPending)) {
  2173. onPending();
  2174. }
  2175. // mount pending branch in off-dom container
  2176. suspense.pendingBranch = newBranch;
  2177. suspense.pendingId++;
  2178. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);
  2179. if (suspense.deps <= 0) {
  2180. // incoming branch has no async deps, resolve now.
  2181. suspense.resolve();
  2182. }
  2183. else {
  2184. const { timeout, pendingId } = suspense;
  2185. if (timeout > 0) {
  2186. setTimeout(() => {
  2187. if (suspense.pendingId === pendingId) {
  2188. suspense.fallback(newFallback);
  2189. }
  2190. }, timeout);
  2191. }
  2192. else if (timeout === 0) {
  2193. suspense.fallback(newFallback);
  2194. }
  2195. }
  2196. }
  2197. }
  2198. }
  2199. let hasWarned = false;
  2200. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals, isHydrating = false) {
  2201. /* istanbul ignore if */
  2202. if ( !hasWarned) {
  2203. hasWarned = true;
  2204. // @ts-ignore `console.info` cannot be null error
  2205. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2206. }
  2207. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2208. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2209. const suspense = {
  2210. vnode,
  2211. parent,
  2212. parentComponent,
  2213. isSVG,
  2214. optimized,
  2215. container,
  2216. hiddenContainer,
  2217. anchor,
  2218. deps: 0,
  2219. pendingId: 0,
  2220. timeout: typeof timeout === 'number' ? timeout : -1,
  2221. activeBranch: null,
  2222. pendingBranch: null,
  2223. isInFallback: true,
  2224. isHydrating,
  2225. isUnmounted: false,
  2226. effects: [],
  2227. resolve(resume = false) {
  2228. {
  2229. if (!resume && !suspense.pendingBranch) {
  2230. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2231. }
  2232. if (suspense.isUnmounted) {
  2233. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2234. }
  2235. }
  2236. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2237. if (suspense.isHydrating) {
  2238. suspense.isHydrating = false;
  2239. }
  2240. else if (!resume) {
  2241. const delayEnter = activeBranch &&
  2242. pendingBranch.transition &&
  2243. pendingBranch.transition.mode === 'out-in';
  2244. if (delayEnter) {
  2245. activeBranch.transition.afterLeave = () => {
  2246. if (pendingId === suspense.pendingId) {
  2247. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2248. }
  2249. };
  2250. }
  2251. // this is initial anchor on mount
  2252. let { anchor } = suspense;
  2253. // unmount current active tree
  2254. if (activeBranch) {
  2255. // if the fallback tree was mounted, it may have been moved
  2256. // as part of a parent suspense. get the latest anchor for insertion
  2257. anchor = next(activeBranch);
  2258. unmount(activeBranch, parentComponent, suspense, true);
  2259. }
  2260. if (!delayEnter) {
  2261. // move content from off-dom container to actual container
  2262. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2263. }
  2264. }
  2265. setActiveBranch(suspense, pendingBranch);
  2266. suspense.pendingBranch = null;
  2267. suspense.isInFallback = false;
  2268. // flush buffered effects
  2269. // check if there is a pending parent suspense
  2270. let parent = suspense.parent;
  2271. let hasUnresolvedAncestor = false;
  2272. while (parent) {
  2273. if (parent.pendingBranch) {
  2274. // found a pending parent suspense, merge buffered post jobs
  2275. // into that parent
  2276. parent.effects.push(...effects);
  2277. hasUnresolvedAncestor = true;
  2278. break;
  2279. }
  2280. parent = parent.parent;
  2281. }
  2282. // no pending parent suspense, flush all jobs
  2283. if (!hasUnresolvedAncestor) {
  2284. queuePostFlushCb(effects);
  2285. }
  2286. suspense.effects = [];
  2287. // invoke @resolve event
  2288. const onResolve = vnode.props && vnode.props.onResolve;
  2289. if (isFunction(onResolve)) {
  2290. onResolve();
  2291. }
  2292. },
  2293. fallback(fallbackVNode) {
  2294. if (!suspense.pendingBranch) {
  2295. return;
  2296. }
  2297. const { vnode, activeBranch, parentComponent, container, isSVG, optimized } = suspense;
  2298. // invoke @fallback event
  2299. const onFallback = vnode.props && vnode.props.onFallback;
  2300. if (isFunction(onFallback)) {
  2301. onFallback();
  2302. }
  2303. const anchor = next(activeBranch);
  2304. const mountFallback = () => {
  2305. if (!suspense.isInFallback) {
  2306. return;
  2307. }
  2308. // mount the fallback tree
  2309. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2310. isSVG, optimized);
  2311. setActiveBranch(suspense, fallbackVNode);
  2312. };
  2313. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2314. if (delayEnter) {
  2315. activeBranch.transition.afterLeave = mountFallback;
  2316. }
  2317. // unmount current active branch
  2318. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2319. true // shouldRemove
  2320. );
  2321. suspense.isInFallback = true;
  2322. if (!delayEnter) {
  2323. mountFallback();
  2324. }
  2325. },
  2326. move(container, anchor, type) {
  2327. suspense.activeBranch &&
  2328. move(suspense.activeBranch, container, anchor, type);
  2329. suspense.container = container;
  2330. },
  2331. next() {
  2332. return suspense.activeBranch && next(suspense.activeBranch);
  2333. },
  2334. registerDep(instance, setupRenderEffect) {
  2335. if (!suspense.pendingBranch) {
  2336. return;
  2337. }
  2338. const hydratedEl = instance.vnode.el;
  2339. suspense.deps++;
  2340. instance
  2341. .asyncDep.catch(err => {
  2342. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  2343. })
  2344. .then(asyncSetupResult => {
  2345. // retry when the setup() promise resolves.
  2346. // component may have been unmounted before resolve.
  2347. if (instance.isUnmounted ||
  2348. suspense.isUnmounted ||
  2349. suspense.pendingId !== instance.suspenseId) {
  2350. return;
  2351. }
  2352. suspense.deps--;
  2353. // retry from this component
  2354. instance.asyncResolved = true;
  2355. const { vnode } = instance;
  2356. {
  2357. pushWarningContext(vnode);
  2358. }
  2359. handleSetupResult(instance, asyncSetupResult);
  2360. if (hydratedEl) {
  2361. // vnode may have been replaced if an update happened before the
  2362. // async dep is resolved.
  2363. vnode.el = hydratedEl;
  2364. }
  2365. const placeholder = !hydratedEl && instance.subTree.el;
  2366. setupRenderEffect(instance, vnode,
  2367. // component may have been moved before resolve.
  2368. // if this is not a hydration, instance.subTree will be the comment
  2369. // placeholder.
  2370. parentNode(hydratedEl || instance.subTree.el),
  2371. // anchor will not be used if this is hydration, so only need to
  2372. // consider the comment placeholder case.
  2373. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2374. if (placeholder) {
  2375. remove(placeholder);
  2376. }
  2377. updateHOCHostEl(instance, vnode.el);
  2378. {
  2379. popWarningContext();
  2380. }
  2381. if (suspense.deps === 0) {
  2382. suspense.resolve();
  2383. }
  2384. });
  2385. },
  2386. unmount(parentSuspense, doRemove) {
  2387. suspense.isUnmounted = true;
  2388. if (suspense.activeBranch) {
  2389. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2390. }
  2391. if (suspense.pendingBranch) {
  2392. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2393. }
  2394. }
  2395. };
  2396. return suspense;
  2397. }
  2398. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, optimized, rendererInternals, hydrateNode) {
  2399. /* eslint-disable no-restricted-globals */
  2400. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, optimized, rendererInternals, true /* hydrating */));
  2401. // there are two possible scenarios for server-rendered suspense:
  2402. // - success: ssr content should be fully resolved
  2403. // - failure: ssr content should be the fallback branch.
  2404. // however, on the client we don't really know if it has failed or not
  2405. // attempt to hydrate the DOM assuming it has succeeded, but we still
  2406. // need to construct a suspense boundary first
  2407. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, optimized);
  2408. if (suspense.deps === 0) {
  2409. suspense.resolve();
  2410. }
  2411. return result;
  2412. /* eslint-enable no-restricted-globals */
  2413. }
  2414. function normalizeSuspenseChildren(vnode) {
  2415. const { shapeFlag, children } = vnode;
  2416. let content;
  2417. let fallback;
  2418. if (shapeFlag & 32 /* SLOTS_CHILDREN */) {
  2419. content = normalizeSuspenseSlot(children.default);
  2420. fallback = normalizeSuspenseSlot(children.fallback);
  2421. }
  2422. else {
  2423. content = normalizeSuspenseSlot(children);
  2424. fallback = normalizeVNode(null);
  2425. }
  2426. return {
  2427. content,
  2428. fallback
  2429. };
  2430. }
  2431. function normalizeSuspenseSlot(s) {
  2432. if (isFunction(s)) {
  2433. s = s();
  2434. }
  2435. if (isArray(s)) {
  2436. const singleChild = filterSingleRoot(s);
  2437. if ( !singleChild) {
  2438. warn(`<Suspense> slots expect a single root node.`);
  2439. }
  2440. s = singleChild;
  2441. }
  2442. return normalizeVNode(s);
  2443. }
  2444. function queueEffectWithSuspense(fn, suspense) {
  2445. if (suspense && suspense.pendingBranch) {
  2446. if (isArray(fn)) {
  2447. suspense.effects.push(...fn);
  2448. }
  2449. else {
  2450. suspense.effects.push(fn);
  2451. }
  2452. }
  2453. else {
  2454. queuePostFlushCb(fn);
  2455. }
  2456. }
  2457. function setActiveBranch(suspense, branch) {
  2458. suspense.activeBranch = branch;
  2459. const { vnode, parentComponent } = suspense;
  2460. const el = (vnode.el = branch.el);
  2461. // in case suspense is the root node of a component,
  2462. // recursively update the HOC el
  2463. if (parentComponent && parentComponent.subTree === vnode) {
  2464. parentComponent.vnode.el = el;
  2465. updateHOCHostEl(parentComponent, el);
  2466. }
  2467. }
  2468. let isRenderingCompiledSlot = 0;
  2469. const setCompiledSlotRendering = (n) => (isRenderingCompiledSlot += n);
  2470. /**
  2471. * Compiler runtime helper for rendering `<slot/>`
  2472. * @private
  2473. */
  2474. function renderSlot(slots, name, props = {},
  2475. // this is not a user-facing function, so the fallback is always generated by
  2476. // the compiler and guaranteed to be a function returning an array
  2477. fallback) {
  2478. let slot = slots[name];
  2479. if ( slot && slot.length > 1) {
  2480. warn(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  2481. `function. You need to mark this component with $dynamic-slots in the ` +
  2482. `parent template.`);
  2483. slot = () => [];
  2484. }
  2485. // a compiled slot disables block tracking by default to avoid manual
  2486. // invocation interfering with template-based block tracking, but in
  2487. // `renderSlot` we can be sure that it's template-based so we can force
  2488. // enable it.
  2489. isRenderingCompiledSlot++;
  2490. const rendered = (openBlock(),
  2491. createBlock(Fragment, { key: props.key }, slot ? slot(props) : fallback ? fallback() : [], slots._ === 1 /* STABLE */
  2492. ? 64 /* STABLE_FRAGMENT */
  2493. : -2 /* BAIL */));
  2494. isRenderingCompiledSlot--;
  2495. return rendered;
  2496. }
  2497. /**
  2498. * Wrap a slot function to memoize current rendering instance
  2499. * @private
  2500. */
  2501. function withCtx(fn, ctx = currentRenderingInstance) {
  2502. if (!ctx)
  2503. return fn;
  2504. const renderFnWithContext = (...args) => {
  2505. // If a user calls a compiled slot inside a template expression (#1745), it
  2506. // can mess up block tracking, so by default we need to push a null block to
  2507. // avoid that. This isn't necessary if rendering a compiled `<slot>`.
  2508. if (!isRenderingCompiledSlot) {
  2509. openBlock(true /* null block that disables tracking */);
  2510. }
  2511. const owner = currentRenderingInstance;
  2512. setCurrentRenderingInstance(ctx);
  2513. const res = fn(...args);
  2514. setCurrentRenderingInstance(owner);
  2515. if (!isRenderingCompiledSlot) {
  2516. closeBlock();
  2517. }
  2518. return res;
  2519. };
  2520. renderFnWithContext._c = true;
  2521. return renderFnWithContext;
  2522. }
  2523. // SFC scoped style ID management.
  2524. let currentScopeId = null;
  2525. const scopeIdStack = [];
  2526. /**
  2527. * @private
  2528. */
  2529. function pushScopeId(id) {
  2530. scopeIdStack.push((currentScopeId = id));
  2531. }
  2532. /**
  2533. * @private
  2534. */
  2535. function popScopeId() {
  2536. scopeIdStack.pop();
  2537. currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null;
  2538. }
  2539. /**
  2540. * @private
  2541. */
  2542. function withScopeId(id) {
  2543. return ((fn) => withCtx(function () {
  2544. pushScopeId(id);
  2545. const res = fn.apply(this, arguments);
  2546. popScopeId();
  2547. return res;
  2548. }));
  2549. }
  2550. const isTeleport = (type) => type.__isTeleport;
  2551. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  2552. const resolveTarget = (props, select) => {
  2553. const targetSelector = props && props.to;
  2554. if (isString(targetSelector)) {
  2555. if (!select) {
  2556. warn(`Current renderer does not support string target for Teleports. ` +
  2557. `(missing querySelector renderer option)`);
  2558. return null;
  2559. }
  2560. else {
  2561. const target = select(targetSelector);
  2562. if (!target) {
  2563. warn(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  2564. `Note the target element must exist before the component is mounted - ` +
  2565. `i.e. the target cannot be rendered by the component itself, and ` +
  2566. `ideally should be outside of the entire Vue component tree.`);
  2567. }
  2568. return target;
  2569. }
  2570. }
  2571. else {
  2572. if ( !targetSelector && !isTeleportDisabled(props)) {
  2573. warn(`Invalid Teleport target: ${targetSelector}`);
  2574. }
  2575. return targetSelector;
  2576. }
  2577. };
  2578. const TeleportImpl = {
  2579. __isTeleport: true,
  2580. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals) {
  2581. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  2582. const disabled = isTeleportDisabled(n2.props);
  2583. const { shapeFlag, children } = n2;
  2584. if (n1 == null) {
  2585. // insert anchors in the main view
  2586. const placeholder = (n2.el = createComment('teleport start')
  2587. );
  2588. const mainAnchor = (n2.anchor = createComment('teleport end')
  2589. );
  2590. insert(placeholder, container, anchor);
  2591. insert(mainAnchor, container, anchor);
  2592. const target = (n2.target = resolveTarget(n2.props, querySelector));
  2593. const targetAnchor = (n2.targetAnchor = createText(''));
  2594. if (target) {
  2595. insert(targetAnchor, target);
  2596. }
  2597. else if ( !disabled) {
  2598. warn('Invalid Teleport target on mount:', target, `(${typeof target})`);
  2599. }
  2600. const mount = (container, anchor) => {
  2601. // Teleport *always* has Array children. This is enforced in both the
  2602. // compiler and vnode children normalization.
  2603. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  2604. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  2605. }
  2606. };
  2607. if (disabled) {
  2608. mount(container, mainAnchor);
  2609. }
  2610. else if (target) {
  2611. mount(target, targetAnchor);
  2612. }
  2613. }
  2614. else {
  2615. // update content
  2616. n2.el = n1.el;
  2617. const mainAnchor = (n2.anchor = n1.anchor);
  2618. const target = (n2.target = n1.target);
  2619. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  2620. const wasDisabled = isTeleportDisabled(n1.props);
  2621. const currentContainer = wasDisabled ? container : target;
  2622. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  2623. if (n2.dynamicChildren) {
  2624. // fast path when the teleport happens to be a block root
  2625. patchBlockChildren(n1.dynamicChildren, n2.dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG);
  2626. // even in block tree mode we need to make sure all root-level nodes
  2627. // in the teleport inherit previous DOM references so that they can
  2628. // be moved in future patches.
  2629. if (n2.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  2630. const oldChildren = n1.children;
  2631. const children = n2.children;
  2632. for (let i = 0; i < children.length; i++) {
  2633. // only inherit for non-patched nodes (i.e. static ones)
  2634. if (!children[i].el) {
  2635. children[i].el = oldChildren[i].el;
  2636. }
  2637. }
  2638. }
  2639. }
  2640. else if (!optimized) {
  2641. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG);
  2642. }
  2643. if (disabled) {
  2644. if (!wasDisabled) {
  2645. // enabled -> disabled
  2646. // move into main container
  2647. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  2648. }
  2649. }
  2650. else {
  2651. // target changed
  2652. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  2653. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  2654. if (nextTarget) {
  2655. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  2656. }
  2657. else {
  2658. warn('Invalid Teleport target on update:', target, `(${typeof target})`);
  2659. }
  2660. }
  2661. else if (wasDisabled) {
  2662. // disabled -> enabled
  2663. // move into teleport target
  2664. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  2665. }
  2666. }
  2667. }
  2668. },
  2669. remove(vnode, { r: remove, o: { remove: hostRemove } }) {
  2670. const { shapeFlag, children, anchor } = vnode;
  2671. hostRemove(anchor);
  2672. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  2673. for (let i = 0; i < children.length; i++) {
  2674. remove(children[i]);
  2675. }
  2676. }
  2677. },
  2678. move: moveTeleport,
  2679. hydrate: hydrateTeleport
  2680. };
  2681. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  2682. // move target anchor if this is a target change.
  2683. if (moveType === 0 /* TARGET_CHANGE */) {
  2684. insert(vnode.targetAnchor, container, parentAnchor);
  2685. }
  2686. const { el, anchor, shapeFlag, children, props } = vnode;
  2687. const isReorder = moveType === 2 /* REORDER */;
  2688. // move main view anchor if this is a re-order.
  2689. if (isReorder) {
  2690. insert(el, container, parentAnchor);
  2691. }
  2692. // if this is a re-order and teleport is enabled (content is in target)
  2693. // do not move children. So the opposite is: only move children if this
  2694. // is not a reorder, or the teleport is disabled
  2695. if (!isReorder || isTeleportDisabled(props)) {
  2696. // Teleport has either Array children or no children.
  2697. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  2698. for (let i = 0; i < children.length; i++) {
  2699. move(children[i], container, parentAnchor, 2 /* REORDER */);
  2700. }
  2701. }
  2702. }
  2703. // move main view anchor if this is a re-order.
  2704. if (isReorder) {
  2705. insert(anchor, container, parentAnchor);
  2706. }
  2707. }
  2708. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  2709. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  2710. if (target) {
  2711. // if multiple teleports rendered to the same target element, we need to
  2712. // pick up from where the last teleport finished instead of the first node
  2713. const targetNode = target._lpa || target.firstChild;
  2714. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  2715. if (isTeleportDisabled(vnode.props)) {
  2716. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, optimized);
  2717. vnode.targetAnchor = targetNode;
  2718. }
  2719. else {
  2720. vnode.anchor = nextSibling(node);
  2721. vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, optimized);
  2722. }
  2723. target._lpa =
  2724. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  2725. }
  2726. }
  2727. return vnode.anchor && nextSibling(vnode.anchor);
  2728. }
  2729. // Force-casted public typing for h and TSX props inference
  2730. const Teleport = TeleportImpl;
  2731. const COMPONENTS = 'components';
  2732. const DIRECTIVES = 'directives';
  2733. /**
  2734. * @private
  2735. */
  2736. function resolveComponent(name) {
  2737. return resolveAsset(COMPONENTS, name) || name;
  2738. }
  2739. const NULL_DYNAMIC_COMPONENT = Symbol();
  2740. /**
  2741. * @private
  2742. */
  2743. function resolveDynamicComponent(component) {
  2744. if (isString(component)) {
  2745. return resolveAsset(COMPONENTS, component, false) || component;
  2746. }
  2747. else {
  2748. // invalid types will fallthrough to createVNode and raise warning
  2749. return (component || NULL_DYNAMIC_COMPONENT);
  2750. }
  2751. }
  2752. /**
  2753. * @private
  2754. */
  2755. function resolveDirective(name) {
  2756. return resolveAsset(DIRECTIVES, name);
  2757. }
  2758. // implementation
  2759. function resolveAsset(type, name, warnMissing = true) {
  2760. const instance = currentRenderingInstance || currentInstance;
  2761. if (instance) {
  2762. const Component = instance.type;
  2763. // self name has highest priority
  2764. if (type === COMPONENTS) {
  2765. const selfName = Component.displayName || Component.name;
  2766. if (selfName &&
  2767. (selfName === name ||
  2768. selfName === camelize(name) ||
  2769. selfName === capitalize(camelize(name)))) {
  2770. return Component;
  2771. }
  2772. }
  2773. const res =
  2774. // local registration
  2775. // check instance[type] first for components with mixin or extends.
  2776. resolve(instance[type] || Component[type], name) ||
  2777. // global registration
  2778. resolve(instance.appContext[type], name);
  2779. if ( warnMissing && !res) {
  2780. warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
  2781. }
  2782. return res;
  2783. }
  2784. else {
  2785. warn(`resolve${capitalize(type.slice(0, -1))} ` +
  2786. `can only be used in render() or setup().`);
  2787. }
  2788. }
  2789. function resolve(registry, name) {
  2790. return (registry &&
  2791. (registry[name] ||
  2792. registry[camelize(name)] ||
  2793. registry[capitalize(camelize(name))]));
  2794. }
  2795. const Fragment = Symbol( 'Fragment' );
  2796. const Text = Symbol( 'Text' );
  2797. const Comment = Symbol( 'Comment' );
  2798. const Static = Symbol( 'Static' );
  2799. // Since v-if and v-for are the two possible ways node structure can dynamically
  2800. // change, once we consider v-if branches and each v-for fragment a block, we
  2801. // can divide a template into nested blocks, and within each block the node
  2802. // structure would be stable. This allows us to skip most children diffing
  2803. // and only worry about the dynamic nodes (indicated by patch flags).
  2804. const blockStack = [];
  2805. let currentBlock = null;
  2806. /**
  2807. * Open a block.
  2808. * This must be called before `createBlock`. It cannot be part of `createBlock`
  2809. * because the children of the block are evaluated before `createBlock` itself
  2810. * is called. The generated code typically looks like this:
  2811. *
  2812. * ```js
  2813. * function render() {
  2814. * return (openBlock(),createBlock('div', null, [...]))
  2815. * }
  2816. * ```
  2817. * disableTracking is true when creating a v-for fragment block, since a v-for
  2818. * fragment always diffs its children.
  2819. *
  2820. * @private
  2821. */
  2822. function openBlock(disableTracking = false) {
  2823. blockStack.push((currentBlock = disableTracking ? null : []));
  2824. }
  2825. function closeBlock() {
  2826. blockStack.pop();
  2827. currentBlock = blockStack[blockStack.length - 1] || null;
  2828. }
  2829. // Whether we should be tracking dynamic child nodes inside a block.
  2830. // Only tracks when this value is > 0
  2831. // We are not using a simple boolean because this value may need to be
  2832. // incremented/decremented by nested usage of v-once (see below)
  2833. let shouldTrack$1 = 1;
  2834. /**
  2835. * Block tracking sometimes needs to be disabled, for example during the
  2836. * creation of a tree that needs to be cached by v-once. The compiler generates
  2837. * code like this:
  2838. *
  2839. * ``` js
  2840. * _cache[1] || (
  2841. * setBlockTracking(-1),
  2842. * _cache[1] = createVNode(...),
  2843. * setBlockTracking(1),
  2844. * _cache[1]
  2845. * )
  2846. * ```
  2847. *
  2848. * @private
  2849. */
  2850. function setBlockTracking(value) {
  2851. shouldTrack$1 += value;
  2852. }
  2853. /**
  2854. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  2855. * A block root keeps track of dynamic nodes within the block in the
  2856. * `dynamicChildren` array.
  2857. *
  2858. * @private
  2859. */
  2860. function createBlock(type, props, children, patchFlag, dynamicProps) {
  2861. const vnode = createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */);
  2862. // save current block children on the block vnode
  2863. vnode.dynamicChildren = currentBlock || EMPTY_ARR;
  2864. // close block
  2865. closeBlock();
  2866. // a block is always going to be patched, so track it as a child of its
  2867. // parent block
  2868. if (shouldTrack$1 > 0 && currentBlock) {
  2869. currentBlock.push(vnode);
  2870. }
  2871. return vnode;
  2872. }
  2873. function isVNode(value) {
  2874. return value ? value.__v_isVNode === true : false;
  2875. }
  2876. function isSameVNodeType(n1, n2) {
  2877. if (
  2878. n2.shapeFlag & 6 /* COMPONENT */ &&
  2879. hmrDirtyComponents.has(n2.type)) {
  2880. // HMR only: if the component has been hot-updated, force a reload.
  2881. return false;
  2882. }
  2883. return n1.type === n2.type && n1.key === n2.key;
  2884. }
  2885. let vnodeArgsTransformer;
  2886. /**
  2887. * Internal API for registering an arguments transform for createVNode
  2888. * used for creating stubs in the test-utils
  2889. * It is *internal* but needs to be exposed for test-utils to pick up proper
  2890. * typings
  2891. */
  2892. function transformVNodeArgs(transformer) {
  2893. vnodeArgsTransformer = transformer;
  2894. }
  2895. const createVNodeWithArgsTransform = (...args) => {
  2896. return _createVNode(...(vnodeArgsTransformer
  2897. ? vnodeArgsTransformer(args, currentRenderingInstance)
  2898. : args));
  2899. };
  2900. const InternalObjectKey = `__vInternal`;
  2901. const normalizeKey = ({ key }) => key != null ? key : null;
  2902. const normalizeRef = ({ ref }) => {
  2903. return (ref != null
  2904. ? isArray(ref)
  2905. ? ref
  2906. : { i: currentRenderingInstance, r: ref }
  2907. : null);
  2908. };
  2909. const createVNode = ( createVNodeWithArgsTransform
  2910. );
  2911. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  2912. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  2913. if ( !type) {
  2914. warn(`Invalid vnode type when creating vnode: ${type}.`);
  2915. }
  2916. type = Comment;
  2917. }
  2918. if (isVNode(type)) {
  2919. // createVNode receiving an existing vnode. This happens in cases like
  2920. // <component :is="vnode"/>
  2921. // #2078 make sure to merge refs during the clone instead of overwriting it
  2922. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  2923. if (children) {
  2924. normalizeChildren(cloned, children);
  2925. }
  2926. return cloned;
  2927. }
  2928. // class component normalization.
  2929. if (isClassComponent(type)) {
  2930. type = type.__vccOpts;
  2931. }
  2932. // class & style normalization.
  2933. if (props) {
  2934. // for reactive or proxy objects, we need to clone it to enable mutation.
  2935. if (isProxy(props) || InternalObjectKey in props) {
  2936. props = extend({}, props);
  2937. }
  2938. let { class: klass, style } = props;
  2939. if (klass && !isString(klass)) {
  2940. props.class = normalizeClass(klass);
  2941. }
  2942. if (isObject(style)) {
  2943. // reactive state objects need to be cloned since they are likely to be
  2944. // mutated
  2945. if (isProxy(style) && !isArray(style)) {
  2946. style = extend({}, style);
  2947. }
  2948. props.style = normalizeStyle(style);
  2949. }
  2950. }
  2951. // encode the vnode type information into a bitmap
  2952. const shapeFlag = isString(type)
  2953. ? 1 /* ELEMENT */
  2954. : isSuspense(type)
  2955. ? 128 /* SUSPENSE */
  2956. : isTeleport(type)
  2957. ? 64 /* TELEPORT */
  2958. : isObject(type)
  2959. ? 4 /* STATEFUL_COMPONENT */
  2960. : isFunction(type)
  2961. ? 2 /* FUNCTIONAL_COMPONENT */
  2962. : 0;
  2963. if ( shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
  2964. type = toRaw(type);
  2965. warn(`Vue received a Component which was made a reactive object. This can ` +
  2966. `lead to unnecessary performance overhead, and should be avoided by ` +
  2967. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  2968. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  2969. }
  2970. const vnode = {
  2971. __v_isVNode: true,
  2972. ["__v_skip" /* SKIP */]: true,
  2973. type,
  2974. props,
  2975. key: props && normalizeKey(props),
  2976. ref: props && normalizeRef(props),
  2977. scopeId: currentScopeId,
  2978. children: null,
  2979. component: null,
  2980. suspense: null,
  2981. ssContent: null,
  2982. ssFallback: null,
  2983. dirs: null,
  2984. transition: null,
  2985. el: null,
  2986. anchor: null,
  2987. target: null,
  2988. targetAnchor: null,
  2989. staticCount: 0,
  2990. shapeFlag,
  2991. patchFlag,
  2992. dynamicProps,
  2993. dynamicChildren: null,
  2994. appContext: null
  2995. };
  2996. // validate key
  2997. if ( vnode.key !== vnode.key) {
  2998. warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  2999. }
  3000. normalizeChildren(vnode, children);
  3001. // normalize suspense children
  3002. if ( shapeFlag & 128 /* SUSPENSE */) {
  3003. const { content, fallback } = normalizeSuspenseChildren(vnode);
  3004. vnode.ssContent = content;
  3005. vnode.ssFallback = fallback;
  3006. }
  3007. if (shouldTrack$1 > 0 &&
  3008. // avoid a block node from tracking itself
  3009. !isBlockNode &&
  3010. // has current parent block
  3011. currentBlock &&
  3012. // presence of a patch flag indicates this node needs patching on updates.
  3013. // component nodes also should always be patched, because even if the
  3014. // component doesn't need to update, it needs to persist the instance on to
  3015. // the next vnode so that it can be properly unmounted later.
  3016. (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  3017. // the EVENTS flag is only for hydration and if it is the only flag, the
  3018. // vnode should not be considered dynamic due to handler caching.
  3019. patchFlag !== 32 /* HYDRATE_EVENTS */) {
  3020. currentBlock.push(vnode);
  3021. }
  3022. return vnode;
  3023. }
  3024. function cloneVNode(vnode, extraProps, mergeRef = false) {
  3025. // This is intentionally NOT using spread or extend to avoid the runtime
  3026. // key enumeration cost.
  3027. const { props, ref, patchFlag } = vnode;
  3028. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  3029. return {
  3030. __v_isVNode: true,
  3031. ["__v_skip" /* SKIP */]: true,
  3032. type: vnode.type,
  3033. props: mergedProps,
  3034. key: mergedProps && normalizeKey(mergedProps),
  3035. ref: extraProps && extraProps.ref
  3036. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  3037. // if the vnode itself already has a ref, cloneVNode will need to merge
  3038. // the refs so the single vnode can be set on multiple refs
  3039. mergeRef && ref
  3040. ? isArray(ref)
  3041. ? ref.concat(normalizeRef(extraProps))
  3042. : [ref, normalizeRef(extraProps)]
  3043. : normalizeRef(extraProps)
  3044. : ref,
  3045. scopeId: vnode.scopeId,
  3046. children: vnode.children,
  3047. target: vnode.target,
  3048. targetAnchor: vnode.targetAnchor,
  3049. staticCount: vnode.staticCount,
  3050. shapeFlag: vnode.shapeFlag,
  3051. // if the vnode is cloned with extra props, we can no longer assume its
  3052. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  3053. // note: perserve flag for fragments since they use the flag for children
  3054. // fast paths only.
  3055. patchFlag: extraProps && vnode.type !== Fragment
  3056. ? patchFlag === -1 // hoisted node
  3057. ? 16 /* FULL_PROPS */
  3058. : patchFlag | 16 /* FULL_PROPS */
  3059. : patchFlag,
  3060. dynamicProps: vnode.dynamicProps,
  3061. dynamicChildren: vnode.dynamicChildren,
  3062. appContext: vnode.appContext,
  3063. dirs: vnode.dirs,
  3064. transition: vnode.transition,
  3065. // These should technically only be non-null on mounted VNodes. However,
  3066. // they *should* be copied for kept-alive vnodes. So we just always copy
  3067. // them since them being non-null during a mount doesn't affect the logic as
  3068. // they will simply be overwritten.
  3069. component: vnode.component,
  3070. suspense: vnode.suspense,
  3071. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  3072. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  3073. el: vnode.el,
  3074. anchor: vnode.anchor
  3075. };
  3076. }
  3077. /**
  3078. * @private
  3079. */
  3080. function createTextVNode(text = ' ', flag = 0) {
  3081. return createVNode(Text, null, text, flag);
  3082. }
  3083. /**
  3084. * @private
  3085. */
  3086. function createStaticVNode(content, numberOfNodes) {
  3087. // A static vnode can contain multiple stringified elements, and the number
  3088. // of elements is necessary for hydration.
  3089. const vnode = createVNode(Static, null, content);
  3090. vnode.staticCount = numberOfNodes;
  3091. return vnode;
  3092. }
  3093. /**
  3094. * @private
  3095. */
  3096. function createCommentVNode(text = '',
  3097. // when used as the v-else branch, the comment node must be created as a
  3098. // block to ensure correct updates.
  3099. asBlock = false) {
  3100. return asBlock
  3101. ? (openBlock(), createBlock(Comment, null, text))
  3102. : createVNode(Comment, null, text);
  3103. }
  3104. function normalizeVNode(child) {
  3105. if (child == null || typeof child === 'boolean') {
  3106. // empty placeholder
  3107. return createVNode(Comment);
  3108. }
  3109. else if (isArray(child)) {
  3110. // fragment
  3111. return createVNode(Fragment, null, child);
  3112. }
  3113. else if (typeof child === 'object') {
  3114. // already vnode, this should be the most common since compiled templates
  3115. // always produce all-vnode children arrays
  3116. return child.el === null ? child : cloneVNode(child);
  3117. }
  3118. else {
  3119. // strings and numbers
  3120. return createVNode(Text, null, String(child));
  3121. }
  3122. }
  3123. // optimized normalization for template-compiled render fns
  3124. function cloneIfMounted(child) {
  3125. return child.el === null ? child : cloneVNode(child);
  3126. }
  3127. function normalizeChildren(vnode, children) {
  3128. let type = 0;
  3129. const { shapeFlag } = vnode;
  3130. if (children == null) {
  3131. children = null;
  3132. }
  3133. else if (isArray(children)) {
  3134. type = 16 /* ARRAY_CHILDREN */;
  3135. }
  3136. else if (typeof children === 'object') {
  3137. if (shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) {
  3138. // Normalize slot to plain children for plain element and Teleport
  3139. const slot = children.default;
  3140. if (slot) {
  3141. // _c marker is added by withCtx() indicating this is a compiled slot
  3142. slot._c && setCompiledSlotRendering(1);
  3143. normalizeChildren(vnode, slot());
  3144. slot._c && setCompiledSlotRendering(-1);
  3145. }
  3146. return;
  3147. }
  3148. else {
  3149. type = 32 /* SLOTS_CHILDREN */;
  3150. const slotFlag = children._;
  3151. if (!slotFlag && !(InternalObjectKey in children)) {
  3152. children._ctx = currentRenderingInstance;
  3153. }
  3154. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  3155. // a child component receives forwarded slots from the parent.
  3156. // its slot type is determined by its parent's slot type.
  3157. if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  3158. children._ = 2 /* DYNAMIC */;
  3159. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  3160. }
  3161. else {
  3162. children._ = 1 /* STABLE */;
  3163. }
  3164. }
  3165. }
  3166. }
  3167. else if (isFunction(children)) {
  3168. children = { default: children, _ctx: currentRenderingInstance };
  3169. type = 32 /* SLOTS_CHILDREN */;
  3170. }
  3171. else {
  3172. children = String(children);
  3173. // force teleport children to array so it can be moved around
  3174. if (shapeFlag & 64 /* TELEPORT */) {
  3175. type = 16 /* ARRAY_CHILDREN */;
  3176. children = [createTextVNode(children)];
  3177. }
  3178. else {
  3179. type = 8 /* TEXT_CHILDREN */;
  3180. }
  3181. }
  3182. vnode.children = children;
  3183. vnode.shapeFlag |= type;
  3184. }
  3185. function mergeProps(...args) {
  3186. const ret = extend({}, args[0]);
  3187. for (let i = 1; i < args.length; i++) {
  3188. const toMerge = args[i];
  3189. for (const key in toMerge) {
  3190. if (key === 'class') {
  3191. if (ret.class !== toMerge.class) {
  3192. ret.class = normalizeClass([ret.class, toMerge.class]);
  3193. }
  3194. }
  3195. else if (key === 'style') {
  3196. ret.style = normalizeStyle([ret.style, toMerge.style]);
  3197. }
  3198. else if (isOn(key)) {
  3199. const existing = ret[key];
  3200. const incoming = toMerge[key];
  3201. if (existing !== incoming) {
  3202. ret[key] = existing
  3203. ? [].concat(existing, toMerge[key])
  3204. : incoming;
  3205. }
  3206. }
  3207. else {
  3208. ret[key] = toMerge[key];
  3209. }
  3210. }
  3211. }
  3212. return ret;
  3213. }
  3214. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  3215. isSSR = false) {
  3216. const props = {};
  3217. const attrs = {};
  3218. def(attrs, InternalObjectKey, 1);
  3219. setFullProps(instance, rawProps, props, attrs);
  3220. // validation
  3221. {
  3222. validateProps(props, instance);
  3223. }
  3224. if (isStateful) {
  3225. // stateful
  3226. instance.props = isSSR ? props : shallowReactive(props);
  3227. }
  3228. else {
  3229. if (!instance.type.props) {
  3230. // functional w/ optional props, props === attrs
  3231. instance.props = attrs;
  3232. }
  3233. else {
  3234. // functional w/ declared props
  3235. instance.props = props;
  3236. }
  3237. }
  3238. instance.attrs = attrs;
  3239. }
  3240. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  3241. const { props, attrs, vnode: { patchFlag } } = instance;
  3242. const rawCurrentProps = toRaw(props);
  3243. const [options] = instance.propsOptions;
  3244. if (
  3245. // always force full diff if hmr is enabled
  3246. !( instance.type.__hmrId) &&
  3247. (optimized || patchFlag > 0) &&
  3248. !(patchFlag & 16 /* FULL_PROPS */)) {
  3249. if (patchFlag & 8 /* PROPS */) {
  3250. // Compiler-generated props & no keys change, just set the updated
  3251. // the props.
  3252. const propsToUpdate = instance.vnode.dynamicProps;
  3253. for (let i = 0; i < propsToUpdate.length; i++) {
  3254. const key = propsToUpdate[i];
  3255. // PROPS flag guarantees rawProps to be non-null
  3256. const value = rawProps[key];
  3257. if (options) {
  3258. // attr / props separation was done on init and will be consistent
  3259. // in this code path, so just check if attrs have it.
  3260. if (hasOwn(attrs, key)) {
  3261. attrs[key] = value;
  3262. }
  3263. else {
  3264. const camelizedKey = camelize(key);
  3265. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance);
  3266. }
  3267. }
  3268. else {
  3269. attrs[key] = value;
  3270. }
  3271. }
  3272. }
  3273. }
  3274. else {
  3275. // full props update.
  3276. setFullProps(instance, rawProps, props, attrs);
  3277. // in case of dynamic props, check if we need to delete keys from
  3278. // the props object
  3279. let kebabKey;
  3280. for (const key in rawCurrentProps) {
  3281. if (!rawProps ||
  3282. // for camelCase
  3283. (!hasOwn(rawProps, key) &&
  3284. // it's possible the original props was passed in as kebab-case
  3285. // and converted to camelCase (#955)
  3286. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  3287. if (options) {
  3288. if (rawPrevProps &&
  3289. // for camelCase
  3290. (rawPrevProps[key] !== undefined ||
  3291. // for kebab-case
  3292. rawPrevProps[kebabKey] !== undefined)) {
  3293. props[key] = resolvePropValue(options, rawProps || EMPTY_OBJ, key, undefined, instance);
  3294. }
  3295. }
  3296. else {
  3297. delete props[key];
  3298. }
  3299. }
  3300. }
  3301. // in the case of functional component w/o props declaration, props and
  3302. // attrs point to the same object so it should already have been updated.
  3303. if (attrs !== rawCurrentProps) {
  3304. for (const key in attrs) {
  3305. if (!rawProps || !hasOwn(rawProps, key)) {
  3306. delete attrs[key];
  3307. }
  3308. }
  3309. }
  3310. }
  3311. // trigger updates for $attrs in case it's used in component slots
  3312. trigger(instance, "set" /* SET */, '$attrs');
  3313. if ( rawProps) {
  3314. validateProps(props, instance);
  3315. }
  3316. }
  3317. function setFullProps(instance, rawProps, props, attrs) {
  3318. const [options, needCastKeys] = instance.propsOptions;
  3319. if (rawProps) {
  3320. for (const key in rawProps) {
  3321. const value = rawProps[key];
  3322. // key, ref are reserved and never passed down
  3323. if (isReservedProp(key)) {
  3324. continue;
  3325. }
  3326. // prop option names are camelized during normalization, so to support
  3327. // kebab -> camel conversion here we need to camelize the key.
  3328. let camelKey;
  3329. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  3330. props[camelKey] = value;
  3331. }
  3332. else if (!isEmitListener(instance.emitsOptions, key)) {
  3333. // Any non-declared (either as a prop or an emitted event) props are put
  3334. // into a separate `attrs` object for spreading. Make sure to preserve
  3335. // original key casing
  3336. attrs[key] = value;
  3337. }
  3338. }
  3339. }
  3340. if (needCastKeys) {
  3341. const rawCurrentProps = toRaw(props);
  3342. for (let i = 0; i < needCastKeys.length; i++) {
  3343. const key = needCastKeys[i];
  3344. props[key] = resolvePropValue(options, rawCurrentProps, key, rawCurrentProps[key], instance);
  3345. }
  3346. }
  3347. }
  3348. function resolvePropValue(options, props, key, value, instance) {
  3349. const opt = options[key];
  3350. if (opt != null) {
  3351. const hasDefault = hasOwn(opt, 'default');
  3352. // default values
  3353. if (hasDefault && value === undefined) {
  3354. const defaultValue = opt.default;
  3355. if (opt.type !== Function && isFunction(defaultValue)) {
  3356. setCurrentInstance(instance);
  3357. value = defaultValue(props);
  3358. setCurrentInstance(null);
  3359. }
  3360. else {
  3361. value = defaultValue;
  3362. }
  3363. }
  3364. // boolean casting
  3365. if (opt[0 /* shouldCast */]) {
  3366. if (!hasOwn(props, key) && !hasDefault) {
  3367. value = false;
  3368. }
  3369. else if (opt[1 /* shouldCastTrue */] &&
  3370. (value === '' || value === hyphenate(key))) {
  3371. value = true;
  3372. }
  3373. }
  3374. }
  3375. return value;
  3376. }
  3377. function normalizePropsOptions(comp, appContext, asMixin = false) {
  3378. const appId = appContext.app ? appContext.app._uid : -1;
  3379. const cache = comp.__props || (comp.__props = {});
  3380. const cached = cache[appId];
  3381. if (cached) {
  3382. return cached;
  3383. }
  3384. const raw = comp.props;
  3385. const normalized = {};
  3386. const needCastKeys = [];
  3387. // apply mixin/extends props
  3388. let hasExtends = false;
  3389. if ( !isFunction(comp)) {
  3390. const extendProps = (raw) => {
  3391. hasExtends = true;
  3392. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  3393. extend(normalized, props);
  3394. if (keys)
  3395. needCastKeys.push(...keys);
  3396. };
  3397. if (!asMixin && appContext.mixins.length) {
  3398. appContext.mixins.forEach(extendProps);
  3399. }
  3400. if (comp.extends) {
  3401. extendProps(comp.extends);
  3402. }
  3403. if (comp.mixins) {
  3404. comp.mixins.forEach(extendProps);
  3405. }
  3406. }
  3407. if (!raw && !hasExtends) {
  3408. return (cache[appId] = EMPTY_ARR);
  3409. }
  3410. if (isArray(raw)) {
  3411. for (let i = 0; i < raw.length; i++) {
  3412. if ( !isString(raw[i])) {
  3413. warn(`props must be strings when using array syntax.`, raw[i]);
  3414. }
  3415. const normalizedKey = camelize(raw[i]);
  3416. if (validatePropName(normalizedKey)) {
  3417. normalized[normalizedKey] = EMPTY_OBJ;
  3418. }
  3419. }
  3420. }
  3421. else if (raw) {
  3422. if ( !isObject(raw)) {
  3423. warn(`invalid props options`, raw);
  3424. }
  3425. for (const key in raw) {
  3426. const normalizedKey = camelize(key);
  3427. if (validatePropName(normalizedKey)) {
  3428. const opt = raw[key];
  3429. const prop = (normalized[normalizedKey] =
  3430. isArray(opt) || isFunction(opt) ? { type: opt } : opt);
  3431. if (prop) {
  3432. const booleanIndex = getTypeIndex(Boolean, prop.type);
  3433. const stringIndex = getTypeIndex(String, prop.type);
  3434. prop[0 /* shouldCast */] = booleanIndex > -1;
  3435. prop[1 /* shouldCastTrue */] =
  3436. stringIndex < 0 || booleanIndex < stringIndex;
  3437. // if the prop needs boolean casting or default value
  3438. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  3439. needCastKeys.push(normalizedKey);
  3440. }
  3441. }
  3442. }
  3443. }
  3444. }
  3445. return (cache[appId] = [normalized, needCastKeys]);
  3446. }
  3447. // use function string name to check type constructors
  3448. // so that it works across vms / iframes.
  3449. function getType(ctor) {
  3450. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  3451. return match ? match[1] : '';
  3452. }
  3453. function isSameType(a, b) {
  3454. return getType(a) === getType(b);
  3455. }
  3456. function getTypeIndex(type, expectedTypes) {
  3457. if (isArray(expectedTypes)) {
  3458. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  3459. if (isSameType(expectedTypes[i], type)) {
  3460. return i;
  3461. }
  3462. }
  3463. }
  3464. else if (isFunction(expectedTypes)) {
  3465. return isSameType(expectedTypes, type) ? 0 : -1;
  3466. }
  3467. return -1;
  3468. }
  3469. /**
  3470. * dev only
  3471. */
  3472. function validateProps(props, instance) {
  3473. const rawValues = toRaw(props);
  3474. const options = instance.propsOptions[0];
  3475. for (const key in options) {
  3476. let opt = options[key];
  3477. if (opt == null)
  3478. continue;
  3479. validateProp(key, rawValues[key], opt, !hasOwn(rawValues, key));
  3480. }
  3481. }
  3482. /**
  3483. * dev only
  3484. */
  3485. function validatePropName(key) {
  3486. if (key[0] !== '$') {
  3487. return true;
  3488. }
  3489. else {
  3490. warn(`Invalid prop name: "${key}" is a reserved property.`);
  3491. }
  3492. return false;
  3493. }
  3494. /**
  3495. * dev only
  3496. */
  3497. function validateProp(name, value, prop, isAbsent) {
  3498. const { type, required, validator } = prop;
  3499. // required!
  3500. if (required && isAbsent) {
  3501. warn('Missing required prop: "' + name + '"');
  3502. return;
  3503. }
  3504. // missing but optional
  3505. if (value == null && !prop.required) {
  3506. return;
  3507. }
  3508. // type check
  3509. if (type != null && type !== true) {
  3510. let isValid = false;
  3511. const types = isArray(type) ? type : [type];
  3512. const expectedTypes = [];
  3513. // value is valid as long as one of the specified types match
  3514. for (let i = 0; i < types.length && !isValid; i++) {
  3515. const { valid, expectedType } = assertType(value, types[i]);
  3516. expectedTypes.push(expectedType || '');
  3517. isValid = valid;
  3518. }
  3519. if (!isValid) {
  3520. warn(getInvalidTypeMessage(name, value, expectedTypes));
  3521. return;
  3522. }
  3523. }
  3524. // custom validator
  3525. if (validator && !validator(value)) {
  3526. warn('Invalid prop: custom validator check failed for prop "' + name + '".');
  3527. }
  3528. }
  3529. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol');
  3530. /**
  3531. * dev only
  3532. */
  3533. function assertType(value, type) {
  3534. let valid;
  3535. const expectedType = getType(type);
  3536. if (isSimpleType(expectedType)) {
  3537. const t = typeof value;
  3538. valid = t === expectedType.toLowerCase();
  3539. // for primitive wrapper objects
  3540. if (!valid && t === 'object') {
  3541. valid = value instanceof type;
  3542. }
  3543. }
  3544. else if (expectedType === 'Object') {
  3545. valid = isObject(value);
  3546. }
  3547. else if (expectedType === 'Array') {
  3548. valid = isArray(value);
  3549. }
  3550. else {
  3551. valid = value instanceof type;
  3552. }
  3553. return {
  3554. valid,
  3555. expectedType
  3556. };
  3557. }
  3558. /**
  3559. * dev only
  3560. */
  3561. function getInvalidTypeMessage(name, value, expectedTypes) {
  3562. let message = `Invalid prop: type check failed for prop "${name}".` +
  3563. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  3564. const expectedType = expectedTypes[0];
  3565. const receivedType = toRawType(value);
  3566. const expectedValue = styleValue(value, expectedType);
  3567. const receivedValue = styleValue(value, receivedType);
  3568. // check if we need to specify expected value
  3569. if (expectedTypes.length === 1 &&
  3570. isExplicable(expectedType) &&
  3571. !isBoolean(expectedType, receivedType)) {
  3572. message += ` with value ${expectedValue}`;
  3573. }
  3574. message += `, got ${receivedType} `;
  3575. // check if we need to specify received value
  3576. if (isExplicable(receivedType)) {
  3577. message += `with value ${receivedValue}.`;
  3578. }
  3579. return message;
  3580. }
  3581. /**
  3582. * dev only
  3583. */
  3584. function styleValue(value, type) {
  3585. if (type === 'String') {
  3586. return `"${value}"`;
  3587. }
  3588. else if (type === 'Number') {
  3589. return `${Number(value)}`;
  3590. }
  3591. else {
  3592. return `${value}`;
  3593. }
  3594. }
  3595. /**
  3596. * dev only
  3597. */
  3598. function isExplicable(type) {
  3599. const explicitTypes = ['string', 'number', 'boolean'];
  3600. return explicitTypes.some(elem => type.toLowerCase() === elem);
  3601. }
  3602. /**
  3603. * dev only
  3604. */
  3605. function isBoolean(...args) {
  3606. return args.some(elem => elem.toLowerCase() === 'boolean');
  3607. }
  3608. function injectHook(type, hook, target = currentInstance, prepend = false) {
  3609. if (target) {
  3610. const hooks = target[type] || (target[type] = []);
  3611. // cache the error handling wrapper for injected hooks so the same hook
  3612. // can be properly deduped by the scheduler. "__weh" stands for "with error
  3613. // handling".
  3614. const wrappedHook = hook.__weh ||
  3615. (hook.__weh = (...args) => {
  3616. if (target.isUnmounted) {
  3617. return;
  3618. }
  3619. // disable tracking inside all lifecycle hooks
  3620. // since they can potentially be called inside effects.
  3621. pauseTracking();
  3622. // Set currentInstance during hook invocation.
  3623. // This assumes the hook does not synchronously trigger other hooks, which
  3624. // can only be false when the user does something really funky.
  3625. setCurrentInstance(target);
  3626. const res = callWithAsyncErrorHandling(hook, target, type, args);
  3627. setCurrentInstance(null);
  3628. resetTracking();
  3629. return res;
  3630. });
  3631. if (prepend) {
  3632. hooks.unshift(wrappedHook);
  3633. }
  3634. else {
  3635. hooks.push(wrappedHook);
  3636. }
  3637. return wrappedHook;
  3638. }
  3639. else {
  3640. const apiName = `on${capitalize(ErrorTypeStrings[type].replace(/ hook$/, ''))}`;
  3641. warn(`${apiName} is called when there is no active component instance to be ` +
  3642. `associated with. ` +
  3643. `Lifecycle injection APIs can only be used during execution of setup().` +
  3644. ( ` If you are using async setup(), make sure to register lifecycle ` +
  3645. `hooks before the first await statement.`
  3646. ));
  3647. }
  3648. }
  3649. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  3650. // post-create lifecycle registrations are noops during SSR
  3651. !isInSSRComponentSetup && injectHook(lifecycle, hook, target);
  3652. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  3653. const onMounted = createHook("m" /* MOUNTED */);
  3654. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  3655. const onUpdated = createHook("u" /* UPDATED */);
  3656. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  3657. const onUnmounted = createHook("um" /* UNMOUNTED */);
  3658. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  3659. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  3660. const onErrorCaptured = (hook, target = currentInstance) => {
  3661. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  3662. };
  3663. function useTransitionState() {
  3664. const state = {
  3665. isMounted: false,
  3666. isLeaving: false,
  3667. isUnmounting: false,
  3668. leavingVNodes: new Map()
  3669. };
  3670. onMounted(() => {
  3671. state.isMounted = true;
  3672. });
  3673. onBeforeUnmount(() => {
  3674. state.isUnmounting = true;
  3675. });
  3676. return state;
  3677. }
  3678. const TransitionHookValidator = [Function, Array];
  3679. const BaseTransitionImpl = {
  3680. name: `BaseTransition`,
  3681. props: {
  3682. mode: String,
  3683. appear: Boolean,
  3684. persisted: Boolean,
  3685. // enter
  3686. onBeforeEnter: TransitionHookValidator,
  3687. onEnter: TransitionHookValidator,
  3688. onAfterEnter: TransitionHookValidator,
  3689. onEnterCancelled: TransitionHookValidator,
  3690. // leave
  3691. onBeforeLeave: TransitionHookValidator,
  3692. onLeave: TransitionHookValidator,
  3693. onAfterLeave: TransitionHookValidator,
  3694. onLeaveCancelled: TransitionHookValidator,
  3695. // appear
  3696. onBeforeAppear: TransitionHookValidator,
  3697. onAppear: TransitionHookValidator,
  3698. onAfterAppear: TransitionHookValidator,
  3699. onAppearCancelled: TransitionHookValidator
  3700. },
  3701. setup(props, { slots }) {
  3702. const instance = getCurrentInstance();
  3703. const state = useTransitionState();
  3704. let prevTransitionKey;
  3705. return () => {
  3706. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3707. if (!children || !children.length) {
  3708. return;
  3709. }
  3710. // warn multiple elements
  3711. if ( children.length > 1) {
  3712. warn('<transition> can only be used on a single element or component. Use ' +
  3713. '<transition-group> for lists.');
  3714. }
  3715. // there's no need to track reactivity for these props so use the raw
  3716. // props for a bit better perf
  3717. const rawProps = toRaw(props);
  3718. const { mode } = rawProps;
  3719. // check mode
  3720. if ( mode && !['in-out', 'out-in', 'default'].includes(mode)) {
  3721. warn(`invalid <transition> mode: ${mode}`);
  3722. }
  3723. // at this point children has a guaranteed length of 1.
  3724. const child = children[0];
  3725. if (state.isLeaving) {
  3726. return emptyPlaceholder(child);
  3727. }
  3728. // in the case of <transition><keep-alive/></transition>, we need to
  3729. // compare the type of the kept-alive children.
  3730. const innerChild = getKeepAliveChild(child);
  3731. if (!innerChild) {
  3732. return emptyPlaceholder(child);
  3733. }
  3734. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3735. setTransitionHooks(innerChild, enterHooks);
  3736. const oldChild = instance.subTree;
  3737. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3738. let transitionKeyChanged = false;
  3739. const { getTransitionKey } = innerChild.type;
  3740. if (getTransitionKey) {
  3741. const key = getTransitionKey();
  3742. if (prevTransitionKey === undefined) {
  3743. prevTransitionKey = key;
  3744. }
  3745. else if (key !== prevTransitionKey) {
  3746. prevTransitionKey = key;
  3747. transitionKeyChanged = true;
  3748. }
  3749. }
  3750. // handle mode
  3751. if (oldInnerChild &&
  3752. oldInnerChild.type !== Comment &&
  3753. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3754. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3755. // update old tree's hooks in case of dynamic transition
  3756. setTransitionHooks(oldInnerChild, leavingHooks);
  3757. // switching between different views
  3758. if (mode === 'out-in') {
  3759. state.isLeaving = true;
  3760. // return placeholder node and queue update when leave finishes
  3761. leavingHooks.afterLeave = () => {
  3762. state.isLeaving = false;
  3763. instance.update();
  3764. };
  3765. return emptyPlaceholder(child);
  3766. }
  3767. else if (mode === 'in-out') {
  3768. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3769. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3770. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3771. // early removal callback
  3772. el._leaveCb = () => {
  3773. earlyRemove();
  3774. el._leaveCb = undefined;
  3775. delete enterHooks.delayedLeave;
  3776. };
  3777. enterHooks.delayedLeave = delayedLeave;
  3778. };
  3779. }
  3780. }
  3781. return child;
  3782. };
  3783. }
  3784. };
  3785. // export the public type for h/tsx inference
  3786. // also to avoid inline import() in generated d.ts files
  3787. const BaseTransition = BaseTransitionImpl;
  3788. function getLeavingNodesForType(state, vnode) {
  3789. const { leavingVNodes } = state;
  3790. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3791. if (!leavingVNodesCache) {
  3792. leavingVNodesCache = Object.create(null);
  3793. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3794. }
  3795. return leavingVNodesCache;
  3796. }
  3797. // The transition hooks are attached to the vnode as vnode.transition
  3798. // and will be called at appropriate timing in the renderer.
  3799. function resolveTransitionHooks(vnode, props, state, instance) {
  3800. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3801. const key = String(vnode.key);
  3802. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3803. const callHook = (hook, args) => {
  3804. hook &&
  3805. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  3806. };
  3807. const hooks = {
  3808. mode,
  3809. persisted,
  3810. beforeEnter(el) {
  3811. let hook = onBeforeEnter;
  3812. if (!state.isMounted) {
  3813. if (appear) {
  3814. hook = onBeforeAppear || onBeforeEnter;
  3815. }
  3816. else {
  3817. return;
  3818. }
  3819. }
  3820. // for same element (v-show)
  3821. if (el._leaveCb) {
  3822. el._leaveCb(true /* cancelled */);
  3823. }
  3824. // for toggled element with same key (v-if)
  3825. const leavingVNode = leavingVNodesCache[key];
  3826. if (leavingVNode &&
  3827. isSameVNodeType(vnode, leavingVNode) &&
  3828. leavingVNode.el._leaveCb) {
  3829. // force early removal (not cancelled)
  3830. leavingVNode.el._leaveCb();
  3831. }
  3832. callHook(hook, [el]);
  3833. },
  3834. enter(el) {
  3835. let hook = onEnter;
  3836. let afterHook = onAfterEnter;
  3837. let cancelHook = onEnterCancelled;
  3838. if (!state.isMounted) {
  3839. if (appear) {
  3840. hook = onAppear || onEnter;
  3841. afterHook = onAfterAppear || onAfterEnter;
  3842. cancelHook = onAppearCancelled || onEnterCancelled;
  3843. }
  3844. else {
  3845. return;
  3846. }
  3847. }
  3848. let called = false;
  3849. const done = (el._enterCb = (cancelled) => {
  3850. if (called)
  3851. return;
  3852. called = true;
  3853. if (cancelled) {
  3854. callHook(cancelHook, [el]);
  3855. }
  3856. else {
  3857. callHook(afterHook, [el]);
  3858. }
  3859. if (hooks.delayedLeave) {
  3860. hooks.delayedLeave();
  3861. }
  3862. el._enterCb = undefined;
  3863. });
  3864. if (hook) {
  3865. hook(el, done);
  3866. if (hook.length <= 1) {
  3867. done();
  3868. }
  3869. }
  3870. else {
  3871. done();
  3872. }
  3873. },
  3874. leave(el, remove) {
  3875. const key = String(vnode.key);
  3876. if (el._enterCb) {
  3877. el._enterCb(true /* cancelled */);
  3878. }
  3879. if (state.isUnmounting) {
  3880. return remove();
  3881. }
  3882. callHook(onBeforeLeave, [el]);
  3883. let called = false;
  3884. const done = (el._leaveCb = (cancelled) => {
  3885. if (called)
  3886. return;
  3887. called = true;
  3888. remove();
  3889. if (cancelled) {
  3890. callHook(onLeaveCancelled, [el]);
  3891. }
  3892. else {
  3893. callHook(onAfterLeave, [el]);
  3894. }
  3895. el._leaveCb = undefined;
  3896. if (leavingVNodesCache[key] === vnode) {
  3897. delete leavingVNodesCache[key];
  3898. }
  3899. });
  3900. leavingVNodesCache[key] = vnode;
  3901. if (onLeave) {
  3902. onLeave(el, done);
  3903. if (onLeave.length <= 1) {
  3904. done();
  3905. }
  3906. }
  3907. else {
  3908. done();
  3909. }
  3910. },
  3911. clone(vnode) {
  3912. return resolveTransitionHooks(vnode, props, state, instance);
  3913. }
  3914. };
  3915. return hooks;
  3916. }
  3917. // the placeholder really only handles one special case: KeepAlive
  3918. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3919. // placeholder with empty content to avoid the KeepAlive instance from being
  3920. // unmounted.
  3921. function emptyPlaceholder(vnode) {
  3922. if (isKeepAlive(vnode)) {
  3923. vnode = cloneVNode(vnode);
  3924. vnode.children = null;
  3925. return vnode;
  3926. }
  3927. }
  3928. function getKeepAliveChild(vnode) {
  3929. return isKeepAlive(vnode)
  3930. ? vnode.children
  3931. ? vnode.children[0]
  3932. : undefined
  3933. : vnode;
  3934. }
  3935. function setTransitionHooks(vnode, hooks) {
  3936. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  3937. setTransitionHooks(vnode.component.subTree, hooks);
  3938. }
  3939. else if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
  3940. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3941. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3942. }
  3943. else {
  3944. vnode.transition = hooks;
  3945. }
  3946. }
  3947. function getTransitionRawChildren(children, keepComment = false) {
  3948. let ret = [];
  3949. let keyedFragmentCount = 0;
  3950. for (let i = 0; i < children.length; i++) {
  3951. const child = children[i];
  3952. // handle fragment children case, e.g. v-for
  3953. if (child.type === Fragment) {
  3954. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  3955. keyedFragmentCount++;
  3956. ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
  3957. }
  3958. // comment placeholders should be skipped, e.g. v-if
  3959. else if (keepComment || child.type !== Comment) {
  3960. ret.push(child);
  3961. }
  3962. }
  3963. // #1126 if a transition children list contains multiple sub fragments, these
  3964. // fragments will be merged into a flat children array. Since each v-for
  3965. // fragment may contain different static bindings inside, we need to de-top
  3966. // these children to force full diffs to ensure correct behavior.
  3967. if (keyedFragmentCount > 1) {
  3968. for (let i = 0; i < ret.length; i++) {
  3969. ret[i].patchFlag = -2 /* BAIL */;
  3970. }
  3971. }
  3972. return ret;
  3973. }
  3974. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3975. const KeepAliveImpl = {
  3976. name: `KeepAlive`,
  3977. // Marker for special handling inside the renderer. We are not using a ===
  3978. // check directly on KeepAlive in the renderer, because importing it directly
  3979. // would prevent it from being tree-shaken.
  3980. __isKeepAlive: true,
  3981. inheritRef: true,
  3982. props: {
  3983. include: [String, RegExp, Array],
  3984. exclude: [String, RegExp, Array],
  3985. max: [String, Number]
  3986. },
  3987. setup(props, { slots }) {
  3988. const cache = new Map();
  3989. const keys = new Set();
  3990. let current = null;
  3991. const instance = getCurrentInstance();
  3992. const parentSuspense = instance.suspense;
  3993. // KeepAlive communicates with the instantiated renderer via the
  3994. // ctx where the renderer passes in its internals,
  3995. // and the KeepAlive instance exposes activate/deactivate implementations.
  3996. // The whole point of this is to avoid importing KeepAlive directly in the
  3997. // renderer to facilitate tree-shaking.
  3998. const sharedContext = instance.ctx;
  3999. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  4000. const storageContainer = createElement('div');
  4001. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  4002. const instance = vnode.component;
  4003. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  4004. // in case props have changed
  4005. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, optimized);
  4006. queuePostRenderEffect(() => {
  4007. instance.isDeactivated = false;
  4008. if (instance.a) {
  4009. invokeArrayFns(instance.a);
  4010. }
  4011. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  4012. if (vnodeHook) {
  4013. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  4014. }
  4015. }, parentSuspense);
  4016. };
  4017. sharedContext.deactivate = (vnode) => {
  4018. const instance = vnode.component;
  4019. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  4020. queuePostRenderEffect(() => {
  4021. if (instance.da) {
  4022. invokeArrayFns(instance.da);
  4023. }
  4024. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  4025. if (vnodeHook) {
  4026. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  4027. }
  4028. instance.isDeactivated = true;
  4029. }, parentSuspense);
  4030. };
  4031. function unmount(vnode) {
  4032. // reset the shapeFlag so it can be properly unmounted
  4033. resetShapeFlag(vnode);
  4034. _unmount(vnode, instance, parentSuspense);
  4035. }
  4036. function pruneCache(filter) {
  4037. cache.forEach((vnode, key) => {
  4038. const name = getName(vnode.type);
  4039. if (name && (!filter || !filter(name))) {
  4040. pruneCacheEntry(key);
  4041. }
  4042. });
  4043. }
  4044. function pruneCacheEntry(key) {
  4045. const cached = cache.get(key);
  4046. if (!current || cached.type !== current.type) {
  4047. unmount(cached);
  4048. }
  4049. else if (current) {
  4050. // current active instance should no longer be kept-alive.
  4051. // we can't unmount it now but it might be later, so reset its flag now.
  4052. resetShapeFlag(current);
  4053. }
  4054. cache.delete(key);
  4055. keys.delete(key);
  4056. }
  4057. // prune cache on include/exclude prop change
  4058. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  4059. include && pruneCache(name => matches(include, name));
  4060. exclude && pruneCache(name => !matches(exclude, name));
  4061. },
  4062. // prune post-render after `current` has been updated
  4063. { flush: 'post' });
  4064. // cache sub tree after render
  4065. let pendingCacheKey = null;
  4066. const cacheSubtree = () => {
  4067. // fix #1621, the pendingCacheKey could be 0
  4068. if (pendingCacheKey != null) {
  4069. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  4070. }
  4071. };
  4072. onMounted(cacheSubtree);
  4073. onUpdated(cacheSubtree);
  4074. onBeforeUnmount(() => {
  4075. cache.forEach(cached => {
  4076. const { subTree, suspense } = instance;
  4077. const vnode = getInnerChild(subTree);
  4078. if (cached.type === vnode.type) {
  4079. // current instance will be unmounted as part of keep-alive's unmount
  4080. resetShapeFlag(vnode);
  4081. // but invoke its deactivated hook here
  4082. const da = vnode.component.da;
  4083. da && queuePostRenderEffect(da, suspense);
  4084. return;
  4085. }
  4086. unmount(cached);
  4087. });
  4088. });
  4089. return () => {
  4090. pendingCacheKey = null;
  4091. if (!slots.default) {
  4092. return null;
  4093. }
  4094. const children = slots.default();
  4095. const rawVNode = children[0];
  4096. if (children.length > 1) {
  4097. {
  4098. warn(`KeepAlive should contain exactly one component child.`);
  4099. }
  4100. current = null;
  4101. return children;
  4102. }
  4103. else if (!isVNode(rawVNode) ||
  4104. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  4105. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  4106. current = null;
  4107. return rawVNode;
  4108. }
  4109. let vnode = getInnerChild(rawVNode);
  4110. const comp = vnode.type;
  4111. const name = getName(comp);
  4112. const { include, exclude, max } = props;
  4113. if ((include && (!name || !matches(include, name))) ||
  4114. (exclude && name && matches(exclude, name))) {
  4115. current = vnode;
  4116. return rawVNode;
  4117. }
  4118. const key = vnode.key == null ? comp : vnode.key;
  4119. const cachedVNode = cache.get(key);
  4120. // clone vnode if it's reused because we are going to mutate it
  4121. if (vnode.el) {
  4122. vnode = cloneVNode(vnode);
  4123. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  4124. rawVNode.ssContent = vnode;
  4125. }
  4126. }
  4127. // #1513 it's possible for the returned vnode to be cloned due to attr
  4128. // fallthrough or scopeId, so the vnode here may not be the final vnode
  4129. // that is mounted. Instead of caching it directly, we store the pending
  4130. // key and cache `instance.subTree` (the normalized vnode) in
  4131. // beforeMount/beforeUpdate hooks.
  4132. pendingCacheKey = key;
  4133. if (cachedVNode) {
  4134. // copy over mounted state
  4135. vnode.el = cachedVNode.el;
  4136. vnode.component = cachedVNode.component;
  4137. if (vnode.transition) {
  4138. // recursively update transition hooks on subTree
  4139. setTransitionHooks(vnode, vnode.transition);
  4140. }
  4141. // avoid vnode being mounted as fresh
  4142. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  4143. // make this key the freshest
  4144. keys.delete(key);
  4145. keys.add(key);
  4146. }
  4147. else {
  4148. keys.add(key);
  4149. // prune oldest entry
  4150. if (max && keys.size > parseInt(max, 10)) {
  4151. pruneCacheEntry(keys.values().next().value);
  4152. }
  4153. }
  4154. // avoid vnode being unmounted
  4155. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4156. current = vnode;
  4157. return rawVNode;
  4158. };
  4159. }
  4160. };
  4161. // export the public type for h/tsx inference
  4162. // also to avoid inline import() in generated d.ts files
  4163. const KeepAlive = KeepAliveImpl;
  4164. function getName(comp) {
  4165. return comp.displayName || comp.name;
  4166. }
  4167. function matches(pattern, name) {
  4168. if (isArray(pattern)) {
  4169. return pattern.some((p) => matches(p, name));
  4170. }
  4171. else if (isString(pattern)) {
  4172. return pattern.split(',').indexOf(name) > -1;
  4173. }
  4174. else if (pattern.test) {
  4175. return pattern.test(name);
  4176. }
  4177. /* istanbul ignore next */
  4178. return false;
  4179. }
  4180. function onActivated(hook, target) {
  4181. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  4182. }
  4183. function onDeactivated(hook, target) {
  4184. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  4185. }
  4186. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4187. // cache the deactivate branch check wrapper for injected hooks so the same
  4188. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4189. // deactivation check".
  4190. const wrappedHook = hook.__wdc ||
  4191. (hook.__wdc = () => {
  4192. // only fire the hook if the target instance is NOT in a deactivated branch.
  4193. let current = target;
  4194. while (current) {
  4195. if (current.isDeactivated) {
  4196. return;
  4197. }
  4198. current = current.parent;
  4199. }
  4200. hook();
  4201. });
  4202. injectHook(type, wrappedHook, target);
  4203. // In addition to registering it on the target instance, we walk up the parent
  4204. // chain and register it on all ancestor instances that are keep-alive roots.
  4205. // This avoids the need to walk the entire component tree when invoking these
  4206. // hooks, and more importantly, avoids the need to track child components in
  4207. // arrays.
  4208. if (target) {
  4209. let current = target.parent;
  4210. while (current && current.parent) {
  4211. if (isKeepAlive(current.parent.vnode)) {
  4212. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4213. }
  4214. current = current.parent;
  4215. }
  4216. }
  4217. }
  4218. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4219. // injectHook wraps the original for error handling, so make sure to remove
  4220. // the wrapped version.
  4221. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4222. onUnmounted(() => {
  4223. remove(keepAliveRoot[type], injected);
  4224. }, target);
  4225. }
  4226. function resetShapeFlag(vnode) {
  4227. let shapeFlag = vnode.shapeFlag;
  4228. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4229. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4230. }
  4231. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  4232. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  4233. }
  4234. vnode.shapeFlag = shapeFlag;
  4235. }
  4236. function getInnerChild(vnode) {
  4237. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  4238. }
  4239. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  4240. const normalizeSlotValue = (value) => isArray(value)
  4241. ? value.map(normalizeVNode)
  4242. : [normalizeVNode(value)];
  4243. const normalizeSlot = (key, rawSlot, ctx) => withCtx((props) => {
  4244. if ( currentInstance) {
  4245. warn(`Slot "${key}" invoked outside of the render function: ` +
  4246. `this will not track dependencies used in the slot. ` +
  4247. `Invoke the slot function inside the render function instead.`);
  4248. }
  4249. return normalizeSlotValue(rawSlot(props));
  4250. }, ctx);
  4251. const normalizeObjectSlots = (rawSlots, slots) => {
  4252. const ctx = rawSlots._ctx;
  4253. for (const key in rawSlots) {
  4254. if (isInternalKey(key))
  4255. continue;
  4256. const value = rawSlots[key];
  4257. if (isFunction(value)) {
  4258. slots[key] = normalizeSlot(key, value, ctx);
  4259. }
  4260. else if (value != null) {
  4261. {
  4262. warn(`Non-function value encountered for slot "${key}". ` +
  4263. `Prefer function slots for better performance.`);
  4264. }
  4265. const normalized = normalizeSlotValue(value);
  4266. slots[key] = () => normalized;
  4267. }
  4268. }
  4269. };
  4270. const normalizeVNodeSlots = (instance, children) => {
  4271. if ( !isKeepAlive(instance.vnode)) {
  4272. warn(`Non-function value encountered for default slot. ` +
  4273. `Prefer function slots for better performance.`);
  4274. }
  4275. const normalized = normalizeSlotValue(children);
  4276. instance.slots.default = () => normalized;
  4277. };
  4278. const initSlots = (instance, children) => {
  4279. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  4280. const type = children._;
  4281. if (type) {
  4282. instance.slots = children;
  4283. // make compiler marker non-enumerable
  4284. def(children, '_', type);
  4285. }
  4286. else {
  4287. normalizeObjectSlots(children, (instance.slots = {}));
  4288. }
  4289. }
  4290. else {
  4291. instance.slots = {};
  4292. if (children) {
  4293. normalizeVNodeSlots(instance, children);
  4294. }
  4295. }
  4296. def(instance.slots, InternalObjectKey, 1);
  4297. };
  4298. const updateSlots = (instance, children) => {
  4299. const { vnode, slots } = instance;
  4300. let needDeletionCheck = true;
  4301. let deletionComparisonTarget = EMPTY_OBJ;
  4302. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  4303. const type = children._;
  4304. if (type) {
  4305. // compiled slots.
  4306. if ( isHmrUpdating) {
  4307. // Parent was HMR updated so slot content may have changed.
  4308. // force update slots and mark instance for hmr as well
  4309. extend(slots, children);
  4310. }
  4311. else if (type === 1 /* STABLE */) {
  4312. // compiled AND stable.
  4313. // no need to update, and skip stale slots removal.
  4314. needDeletionCheck = false;
  4315. }
  4316. else {
  4317. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  4318. // normalization.
  4319. extend(slots, children);
  4320. }
  4321. }
  4322. else {
  4323. needDeletionCheck = !children.$stable;
  4324. normalizeObjectSlots(children, slots);
  4325. }
  4326. deletionComparisonTarget = children;
  4327. }
  4328. else if (children) {
  4329. // non slot object children (direct value) passed to a component
  4330. normalizeVNodeSlots(instance, children);
  4331. deletionComparisonTarget = { default: 1 };
  4332. }
  4333. // delete stale slots
  4334. if (needDeletionCheck) {
  4335. for (const key in slots) {
  4336. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  4337. delete slots[key];
  4338. }
  4339. }
  4340. }
  4341. };
  4342. /**
  4343. Runtime helper for applying directives to a vnode. Example usage:
  4344. const comp = resolveComponent('comp')
  4345. const foo = resolveDirective('foo')
  4346. const bar = resolveDirective('bar')
  4347. return withDirectives(h(comp), [
  4348. [foo, this.x],
  4349. [bar, this.y]
  4350. ])
  4351. */
  4352. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
  4353. function validateDirectiveName(name) {
  4354. if (isBuiltInDirective(name)) {
  4355. warn('Do not use built-in directive ids as custom directive id: ' + name);
  4356. }
  4357. }
  4358. /**
  4359. * Adds directives to a VNode.
  4360. */
  4361. function withDirectives(vnode, directives) {
  4362. const internalInstance = currentRenderingInstance;
  4363. if (internalInstance === null) {
  4364. warn(`withDirectives can only be used inside render functions.`);
  4365. return vnode;
  4366. }
  4367. const instance = internalInstance.proxy;
  4368. const bindings = vnode.dirs || (vnode.dirs = []);
  4369. for (let i = 0; i < directives.length; i++) {
  4370. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4371. if (isFunction(dir)) {
  4372. dir = {
  4373. mounted: dir,
  4374. updated: dir
  4375. };
  4376. }
  4377. bindings.push({
  4378. dir,
  4379. instance,
  4380. value,
  4381. oldValue: void 0,
  4382. arg,
  4383. modifiers
  4384. });
  4385. }
  4386. return vnode;
  4387. }
  4388. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4389. const bindings = vnode.dirs;
  4390. const oldBindings = prevVNode && prevVNode.dirs;
  4391. for (let i = 0; i < bindings.length; i++) {
  4392. const binding = bindings[i];
  4393. if (oldBindings) {
  4394. binding.oldValue = oldBindings[i].value;
  4395. }
  4396. const hook = binding.dir[name];
  4397. if (hook) {
  4398. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  4399. vnode.el,
  4400. binding,
  4401. vnode,
  4402. prevVNode
  4403. ]);
  4404. }
  4405. }
  4406. }
  4407. function createAppContext() {
  4408. return {
  4409. app: null,
  4410. config: {
  4411. isNativeTag: NO,
  4412. performance: false,
  4413. globalProperties: {},
  4414. optionMergeStrategies: {},
  4415. isCustomElement: NO,
  4416. errorHandler: undefined,
  4417. warnHandler: undefined
  4418. },
  4419. mixins: [],
  4420. components: {},
  4421. directives: {},
  4422. provides: Object.create(null)
  4423. };
  4424. }
  4425. let uid$1 = 0;
  4426. function createAppAPI(render, hydrate) {
  4427. return function createApp(rootComponent, rootProps = null) {
  4428. if (rootProps != null && !isObject(rootProps)) {
  4429. warn(`root props passed to app.mount() must be an object.`);
  4430. rootProps = null;
  4431. }
  4432. const context = createAppContext();
  4433. const installedPlugins = new Set();
  4434. let isMounted = false;
  4435. const app = (context.app = {
  4436. _uid: uid$1++,
  4437. _component: rootComponent,
  4438. _props: rootProps,
  4439. _container: null,
  4440. _context: context,
  4441. version,
  4442. get config() {
  4443. return context.config;
  4444. },
  4445. set config(v) {
  4446. {
  4447. warn(`app.config cannot be replaced. Modify individual options instead.`);
  4448. }
  4449. },
  4450. use(plugin, ...options) {
  4451. if (installedPlugins.has(plugin)) {
  4452. warn(`Plugin has already been applied to target app.`);
  4453. }
  4454. else if (plugin && isFunction(plugin.install)) {
  4455. installedPlugins.add(plugin);
  4456. plugin.install(app, ...options);
  4457. }
  4458. else if (isFunction(plugin)) {
  4459. installedPlugins.add(plugin);
  4460. plugin(app, ...options);
  4461. }
  4462. else {
  4463. warn(`A plugin must either be a function or an object with an "install" ` +
  4464. `function.`);
  4465. }
  4466. return app;
  4467. },
  4468. mixin(mixin) {
  4469. {
  4470. if (!context.mixins.includes(mixin)) {
  4471. context.mixins.push(mixin);
  4472. }
  4473. else {
  4474. warn('Mixin has already been applied to target app' +
  4475. (mixin.name ? `: ${mixin.name}` : ''));
  4476. }
  4477. }
  4478. return app;
  4479. },
  4480. component(name, component) {
  4481. {
  4482. validateComponentName(name, context.config);
  4483. }
  4484. if (!component) {
  4485. return context.components[name];
  4486. }
  4487. if ( context.components[name]) {
  4488. warn(`Component "${name}" has already been registered in target app.`);
  4489. }
  4490. context.components[name] = component;
  4491. return app;
  4492. },
  4493. directive(name, directive) {
  4494. {
  4495. validateDirectiveName(name);
  4496. }
  4497. if (!directive) {
  4498. return context.directives[name];
  4499. }
  4500. if ( context.directives[name]) {
  4501. warn(`Directive "${name}" has already been registered in target app.`);
  4502. }
  4503. context.directives[name] = directive;
  4504. return app;
  4505. },
  4506. mount(rootContainer, isHydrate) {
  4507. if (!isMounted) {
  4508. const vnode = createVNode(rootComponent, rootProps);
  4509. // store app context on the root VNode.
  4510. // this will be set on the root instance on initial mount.
  4511. vnode.appContext = context;
  4512. // HMR root reload
  4513. {
  4514. context.reload = () => {
  4515. render(cloneVNode(vnode), rootContainer);
  4516. };
  4517. }
  4518. if (isHydrate && hydrate) {
  4519. hydrate(vnode, rootContainer);
  4520. }
  4521. else {
  4522. render(vnode, rootContainer);
  4523. }
  4524. isMounted = true;
  4525. app._container = rootContainer;
  4526. rootContainer.__vue_app__ = app;
  4527. {
  4528. devtoolsInitApp(app, version);
  4529. }
  4530. return vnode.component.proxy;
  4531. }
  4532. else {
  4533. warn(`App has already been mounted.\n` +
  4534. `If you want to remount the same app, move your app creation logic ` +
  4535. `into a factory function and create fresh app instances for each ` +
  4536. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  4537. }
  4538. },
  4539. unmount() {
  4540. if (isMounted) {
  4541. render(null, app._container);
  4542. {
  4543. devtoolsUnmountApp(app);
  4544. }
  4545. }
  4546. else {
  4547. warn(`Cannot unmount an app that is not mounted.`);
  4548. }
  4549. },
  4550. provide(key, value) {
  4551. if ( key in context.provides) {
  4552. warn(`App already provides property with key "${String(key)}". ` +
  4553. `It will be overwritten with the new value.`);
  4554. }
  4555. // TypeScript doesn't allow symbols as index type
  4556. // https://github.com/Microsoft/TypeScript/issues/24587
  4557. context.provides[key] = value;
  4558. return app;
  4559. }
  4560. });
  4561. return app;
  4562. };
  4563. }
  4564. let hasMismatch = false;
  4565. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  4566. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  4567. // Note: hydration is DOM-specific
  4568. // But we have to place it in core due to tight coupling with core - splitting
  4569. // it out creates a ton of unnecessary complexity.
  4570. // Hydration also depends on some renderer internal logic which needs to be
  4571. // passed in via arguments.
  4572. function createHydrationFunctions(rendererInternals) {
  4573. const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  4574. const hydrate = (vnode, container) => {
  4575. if ( !container.hasChildNodes()) {
  4576. warn(`Attempting to hydrate existing markup but container is empty. ` +
  4577. `Performing full mount instead.`);
  4578. patch(null, vnode, container);
  4579. return;
  4580. }
  4581. hasMismatch = false;
  4582. hydrateNode(container.firstChild, vnode, null, null);
  4583. flushPostFlushCbs();
  4584. if (hasMismatch && !false) {
  4585. // this error should show up in production
  4586. console.error(`Hydration completed but contains mismatches.`);
  4587. }
  4588. };
  4589. const hydrateNode = (node, vnode, parentComponent, parentSuspense, optimized = false) => {
  4590. const isFragmentStart = isComment(node) && node.data === '[';
  4591. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, isFragmentStart);
  4592. const { type, ref, shapeFlag } = vnode;
  4593. const domType = node.nodeType;
  4594. vnode.el = node;
  4595. let nextNode = null;
  4596. switch (type) {
  4597. case Text:
  4598. if (domType !== 3 /* TEXT */) {
  4599. nextNode = onMismatch();
  4600. }
  4601. else {
  4602. if (node.data !== vnode.children) {
  4603. hasMismatch = true;
  4604. warn(`Hydration text mismatch:` +
  4605. `\n- Client: ${JSON.stringify(node.data)}` +
  4606. `\n- Server: ${JSON.stringify(vnode.children)}`);
  4607. node.data = vnode.children;
  4608. }
  4609. nextNode = nextSibling(node);
  4610. }
  4611. break;
  4612. case Comment:
  4613. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  4614. nextNode = onMismatch();
  4615. }
  4616. else {
  4617. nextNode = nextSibling(node);
  4618. }
  4619. break;
  4620. case Static:
  4621. if (domType !== 1 /* ELEMENT */) {
  4622. nextNode = onMismatch();
  4623. }
  4624. else {
  4625. // determine anchor, adopt content
  4626. nextNode = node;
  4627. // if the static vnode has its content stripped during build,
  4628. // adopt it from the server-rendered HTML.
  4629. const needToAdoptContent = !vnode.children.length;
  4630. for (let i = 0; i < vnode.staticCount; i++) {
  4631. if (needToAdoptContent)
  4632. vnode.children += nextNode.outerHTML;
  4633. if (i === vnode.staticCount - 1) {
  4634. vnode.anchor = nextNode;
  4635. }
  4636. nextNode = nextSibling(nextNode);
  4637. }
  4638. return nextNode;
  4639. }
  4640. break;
  4641. case Fragment:
  4642. if (!isFragmentStart) {
  4643. nextNode = onMismatch();
  4644. }
  4645. else {
  4646. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, optimized);
  4647. }
  4648. break;
  4649. default:
  4650. if (shapeFlag & 1 /* ELEMENT */) {
  4651. if (domType !== 1 /* ELEMENT */ ||
  4652. vnode.type !== node.tagName.toLowerCase()) {
  4653. nextNode = onMismatch();
  4654. }
  4655. else {
  4656. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, optimized);
  4657. }
  4658. }
  4659. else if (shapeFlag & 6 /* COMPONENT */) {
  4660. // when setting up the render effect, if the initial vnode already
  4661. // has .el set, the component will perform hydration instead of mount
  4662. // on its sub-tree.
  4663. const container = parentNode(node);
  4664. const hydrateComponent = () => {
  4665. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  4666. };
  4667. // async component
  4668. const loadAsync = vnode.type.__asyncLoader;
  4669. if (loadAsync) {
  4670. loadAsync().then(hydrateComponent);
  4671. }
  4672. else {
  4673. hydrateComponent();
  4674. }
  4675. // component may be async, so in the case of fragments we cannot rely
  4676. // on component's rendered output to determine the end of the fragment
  4677. // instead, we do a lookahead to find the end anchor node.
  4678. nextNode = isFragmentStart
  4679. ? locateClosingAsyncAnchor(node)
  4680. : nextSibling(node);
  4681. }
  4682. else if (shapeFlag & 64 /* TELEPORT */) {
  4683. if (domType !== 8 /* COMMENT */) {
  4684. nextNode = onMismatch();
  4685. }
  4686. else {
  4687. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, optimized, rendererInternals, hydrateChildren);
  4688. }
  4689. }
  4690. else if ( shapeFlag & 128 /* SUSPENSE */) {
  4691. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), optimized, rendererInternals, hydrateNode);
  4692. }
  4693. else {
  4694. warn('Invalid HostVNode type:', type, `(${typeof type})`);
  4695. }
  4696. }
  4697. if (ref != null && parentComponent) {
  4698. setRef(ref, null, parentComponent, parentSuspense, vnode);
  4699. }
  4700. return nextNode;
  4701. };
  4702. const hydrateElement = (el, vnode, parentComponent, parentSuspense, optimized) => {
  4703. optimized = optimized || !!vnode.dynamicChildren;
  4704. const { props, patchFlag, shapeFlag, dirs } = vnode;
  4705. // skip props & children if this is hoisted static nodes
  4706. if (patchFlag !== -1 /* HOISTED */) {
  4707. if (dirs) {
  4708. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  4709. }
  4710. // props
  4711. if (props) {
  4712. if (!optimized ||
  4713. (patchFlag & 16 /* FULL_PROPS */ ||
  4714. patchFlag & 32 /* HYDRATE_EVENTS */)) {
  4715. for (const key in props) {
  4716. if (!isReservedProp(key) && isOn(key)) {
  4717. patchProp(el, key, null, props[key]);
  4718. }
  4719. }
  4720. }
  4721. else if (props.onClick) {
  4722. // Fast path for click listeners (which is most often) to avoid
  4723. // iterating through props.
  4724. patchProp(el, 'onClick', null, props.onClick);
  4725. }
  4726. }
  4727. // vnode / directive hooks
  4728. let vnodeHooks;
  4729. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  4730. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4731. }
  4732. if (dirs) {
  4733. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  4734. }
  4735. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  4736. queueEffectWithSuspense(() => {
  4737. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  4738. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  4739. }, parentSuspense);
  4740. }
  4741. // children
  4742. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  4743. // skip if element has innerHTML / textContent
  4744. !(props && (props.innerHTML || props.textContent))) {
  4745. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, optimized);
  4746. let hasWarned = false;
  4747. while (next) {
  4748. hasMismatch = true;
  4749. if ( !hasWarned) {
  4750. warn(`Hydration children mismatch in <${vnode.type}>: ` +
  4751. `server rendered element contains more child nodes than client vdom.`);
  4752. hasWarned = true;
  4753. }
  4754. // The SSRed DOM contains more nodes than it should. Remove them.
  4755. const cur = next;
  4756. next = next.nextSibling;
  4757. remove(cur);
  4758. }
  4759. }
  4760. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  4761. if (el.textContent !== vnode.children) {
  4762. hasMismatch = true;
  4763. warn(`Hydration text content mismatch in <${vnode.type}>:\n` +
  4764. `- Client: ${el.textContent}\n` +
  4765. `- Server: ${vnode.children}`);
  4766. el.textContent = vnode.children;
  4767. }
  4768. }
  4769. }
  4770. return el.nextSibling;
  4771. };
  4772. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, optimized) => {
  4773. optimized = optimized || !!parentVNode.dynamicChildren;
  4774. const children = parentVNode.children;
  4775. const l = children.length;
  4776. let hasWarned = false;
  4777. for (let i = 0; i < l; i++) {
  4778. const vnode = optimized
  4779. ? children[i]
  4780. : (children[i] = normalizeVNode(children[i]));
  4781. if (node) {
  4782. node = hydrateNode(node, vnode, parentComponent, parentSuspense, optimized);
  4783. }
  4784. else {
  4785. hasMismatch = true;
  4786. if ( !hasWarned) {
  4787. warn(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  4788. `server rendered element contains fewer child nodes than client vdom.`);
  4789. hasWarned = true;
  4790. }
  4791. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  4792. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container));
  4793. }
  4794. }
  4795. return node;
  4796. };
  4797. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, optimized) => {
  4798. const container = parentNode(node);
  4799. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, optimized);
  4800. if (next && isComment(next) && next.data === ']') {
  4801. return nextSibling((vnode.anchor = next));
  4802. }
  4803. else {
  4804. // fragment didn't hydrate successfully, since we didn't get a end anchor
  4805. // back. This should have led to node/children mismatch warnings.
  4806. hasMismatch = true;
  4807. // since the anchor is missing, we need to create one and insert it
  4808. insert((vnode.anchor = createComment(`]`)), container, next);
  4809. return next;
  4810. }
  4811. };
  4812. const handleMismatch = (node, vnode, parentComponent, parentSuspense, isFragment) => {
  4813. hasMismatch = true;
  4814. warn(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  4815. ? `(text)`
  4816. : isComment(node) && node.data === '['
  4817. ? `(start of fragment)`
  4818. : ``);
  4819. vnode.el = null;
  4820. if (isFragment) {
  4821. // remove excessive fragment nodes
  4822. const end = locateClosingAsyncAnchor(node);
  4823. while (true) {
  4824. const next = nextSibling(node);
  4825. if (next && next !== end) {
  4826. remove(next);
  4827. }
  4828. else {
  4829. break;
  4830. }
  4831. }
  4832. }
  4833. const next = nextSibling(node);
  4834. const container = parentNode(node);
  4835. remove(node);
  4836. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container));
  4837. return next;
  4838. };
  4839. const locateClosingAsyncAnchor = (node) => {
  4840. let match = 0;
  4841. while (node) {
  4842. node = nextSibling(node);
  4843. if (node && isComment(node)) {
  4844. if (node.data === '[')
  4845. match++;
  4846. if (node.data === ']') {
  4847. if (match === 0) {
  4848. return nextSibling(node);
  4849. }
  4850. else {
  4851. match--;
  4852. }
  4853. }
  4854. }
  4855. }
  4856. return node;
  4857. };
  4858. return [hydrate, hydrateNode];
  4859. }
  4860. let supported;
  4861. let perf;
  4862. function startMeasure(instance, type) {
  4863. if (instance.appContext.config.performance && isSupported()) {
  4864. perf.mark(`vue-${type}-${instance.uid}`);
  4865. }
  4866. }
  4867. function endMeasure(instance, type) {
  4868. if (instance.appContext.config.performance && isSupported()) {
  4869. const startTag = `vue-${type}-${instance.uid}`;
  4870. const endTag = startTag + `:end`;
  4871. perf.mark(endTag);
  4872. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  4873. perf.clearMarks(startTag);
  4874. perf.clearMarks(endTag);
  4875. }
  4876. }
  4877. function isSupported() {
  4878. if (supported !== undefined) {
  4879. return supported;
  4880. }
  4881. /* eslint-disable no-restricted-globals */
  4882. if (typeof window !== 'undefined' && window.performance) {
  4883. supported = true;
  4884. perf = window.performance;
  4885. }
  4886. else {
  4887. supported = false;
  4888. }
  4889. /* eslint-enable no-restricted-globals */
  4890. return supported;
  4891. }
  4892. function createDevEffectOptions(instance) {
  4893. return {
  4894. scheduler: queueJob,
  4895. allowRecurse: true,
  4896. onTrack: instance.rtc ? e => invokeArrayFns(instance.rtc, e) : void 0,
  4897. onTrigger: instance.rtg ? e => invokeArrayFns(instance.rtg, e) : void 0
  4898. };
  4899. }
  4900. const queuePostRenderEffect = queueEffectWithSuspense
  4901. ;
  4902. const setRef = (rawRef, oldRawRef, parentComponent, parentSuspense, vnode) => {
  4903. if (isArray(rawRef)) {
  4904. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentComponent, parentSuspense, vnode));
  4905. return;
  4906. }
  4907. let value;
  4908. if (!vnode) {
  4909. value = null;
  4910. }
  4911. else {
  4912. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  4913. value = vnode.component.proxy;
  4914. }
  4915. else {
  4916. value = vnode.el;
  4917. }
  4918. }
  4919. const { i: owner, r: ref } = rawRef;
  4920. if ( !owner) {
  4921. warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  4922. `A vnode with ref must be created inside the render function.`);
  4923. return;
  4924. }
  4925. const oldRef = oldRawRef && oldRawRef.r;
  4926. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  4927. const setupState = owner.setupState;
  4928. // unset old ref
  4929. if (oldRef != null && oldRef !== ref) {
  4930. if (isString(oldRef)) {
  4931. refs[oldRef] = null;
  4932. if (hasOwn(setupState, oldRef)) {
  4933. setupState[oldRef] = null;
  4934. }
  4935. }
  4936. else if (isRef(oldRef)) {
  4937. oldRef.value = null;
  4938. }
  4939. }
  4940. if (isString(ref)) {
  4941. const doSet = () => {
  4942. refs[ref] = value;
  4943. if (hasOwn(setupState, ref)) {
  4944. setupState[ref] = value;
  4945. }
  4946. };
  4947. // #1789: for non-null values, set them after render
  4948. // null values means this is unmount and it should not overwrite another
  4949. // ref with the same key
  4950. if (value) {
  4951. doSet.id = -1;
  4952. queuePostRenderEffect(doSet, parentSuspense);
  4953. }
  4954. else {
  4955. doSet();
  4956. }
  4957. }
  4958. else if (isRef(ref)) {
  4959. const doSet = () => {
  4960. ref.value = value;
  4961. };
  4962. if (value) {
  4963. doSet.id = -1;
  4964. queuePostRenderEffect(doSet, parentSuspense);
  4965. }
  4966. else {
  4967. doSet();
  4968. }
  4969. }
  4970. else if (isFunction(ref)) {
  4971. callWithErrorHandling(ref, parentComponent, 12 /* FUNCTION_REF */, [
  4972. value,
  4973. refs
  4974. ]);
  4975. }
  4976. else {
  4977. warn('Invalid template ref type:', value, `(${typeof value})`);
  4978. }
  4979. };
  4980. /**
  4981. * The createRenderer function accepts two generic arguments:
  4982. * HostNode and HostElement, corresponding to Node and Element types in the
  4983. * host environment. For example, for runtime-dom, HostNode would be the DOM
  4984. * `Node` interface and HostElement would be the DOM `Element` interface.
  4985. *
  4986. * Custom renderers can pass in the platform specific types like this:
  4987. *
  4988. * ``` js
  4989. * const { render, createApp } = createRenderer<Node, Element>({
  4990. * patchProp,
  4991. * ...nodeOps
  4992. * })
  4993. * ```
  4994. */
  4995. function createRenderer(options) {
  4996. return baseCreateRenderer(options);
  4997. }
  4998. // Separate API for creating hydration-enabled renderer.
  4999. // Hydration logic is only used when calling this function, making it
  5000. // tree-shakable.
  5001. function createHydrationRenderer(options) {
  5002. return baseCreateRenderer(options, createHydrationFunctions);
  5003. }
  5004. // implementation
  5005. function baseCreateRenderer(options, createHydrationFns) {
  5006. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, forcePatchProp: hostForcePatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
  5007. // Note: functions inside this closure should use `const xxx = () => {}`
  5008. // style in order to prevent being inlined by minifiers.
  5009. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, optimized = false) => {
  5010. // patching & not same type, unmount old tree
  5011. if (n1 && !isSameVNodeType(n1, n2)) {
  5012. anchor = getNextHostNode(n1);
  5013. unmount(n1, parentComponent, parentSuspense, true);
  5014. n1 = null;
  5015. }
  5016. if (n2.patchFlag === -2 /* BAIL */) {
  5017. optimized = false;
  5018. n2.dynamicChildren = null;
  5019. }
  5020. const { type, ref, shapeFlag } = n2;
  5021. switch (type) {
  5022. case Text:
  5023. processText(n1, n2, container, anchor);
  5024. break;
  5025. case Comment:
  5026. processCommentNode(n1, n2, container, anchor);
  5027. break;
  5028. case Static:
  5029. if (n1 == null) {
  5030. mountStaticNode(n2, container, anchor, isSVG);
  5031. }
  5032. else {
  5033. patchStaticNode(n1, n2, container, isSVG);
  5034. }
  5035. break;
  5036. case Fragment:
  5037. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5038. break;
  5039. default:
  5040. if (shapeFlag & 1 /* ELEMENT */) {
  5041. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5042. }
  5043. else if (shapeFlag & 6 /* COMPONENT */) {
  5044. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5045. }
  5046. else if (shapeFlag & 64 /* TELEPORT */) {
  5047. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals);
  5048. }
  5049. else if ( shapeFlag & 128 /* SUSPENSE */) {
  5050. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals);
  5051. }
  5052. else {
  5053. warn('Invalid VNode type:', type, `(${typeof type})`);
  5054. }
  5055. }
  5056. // set ref
  5057. if (ref != null && parentComponent) {
  5058. setRef(ref, n1 && n1.ref, parentComponent, parentSuspense, n2);
  5059. }
  5060. };
  5061. const processText = (n1, n2, container, anchor) => {
  5062. if (n1 == null) {
  5063. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  5064. }
  5065. else {
  5066. const el = (n2.el = n1.el);
  5067. if (n2.children !== n1.children) {
  5068. hostSetText(el, n2.children);
  5069. }
  5070. }
  5071. };
  5072. const processCommentNode = (n1, n2, container, anchor) => {
  5073. if (n1 == null) {
  5074. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  5075. }
  5076. else {
  5077. // there's no support for dynamic comments
  5078. n2.el = n1.el;
  5079. }
  5080. };
  5081. const mountStaticNode = (n2, container, anchor, isSVG) => {
  5082. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  5083. };
  5084. /**
  5085. * Dev / HMR only
  5086. */
  5087. const patchStaticNode = (n1, n2, container, isSVG) => {
  5088. // static nodes are only patched during dev for HMR
  5089. if (n2.children !== n1.children) {
  5090. const anchor = hostNextSibling(n1.anchor);
  5091. // remove existing
  5092. removeStaticNode(n1);
  5093. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  5094. }
  5095. else {
  5096. n2.el = n1.el;
  5097. n2.anchor = n1.anchor;
  5098. }
  5099. };
  5100. /**
  5101. * Dev / HMR only
  5102. */
  5103. const moveStaticNode = (vnode, container, anchor) => {
  5104. let cur = vnode.el;
  5105. const end = vnode.anchor;
  5106. while (cur && cur !== end) {
  5107. const next = hostNextSibling(cur);
  5108. hostInsert(cur, container, anchor);
  5109. cur = next;
  5110. }
  5111. hostInsert(end, container, anchor);
  5112. };
  5113. /**
  5114. * Dev / HMR only
  5115. */
  5116. const removeStaticNode = (vnode) => {
  5117. let cur = vnode.el;
  5118. while (cur && cur !== vnode.anchor) {
  5119. const next = hostNextSibling(cur);
  5120. hostRemove(cur);
  5121. cur = next;
  5122. }
  5123. hostRemove(vnode.anchor);
  5124. };
  5125. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5126. isSVG = isSVG || n2.type === 'svg';
  5127. if (n1 == null) {
  5128. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5129. }
  5130. else {
  5131. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, optimized);
  5132. }
  5133. };
  5134. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5135. let el;
  5136. let vnodeHook;
  5137. const { type, props, shapeFlag, transition, scopeId, patchFlag, dirs } = vnode;
  5138. {
  5139. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is);
  5140. // mount children first, since some props may rely on child content
  5141. // being already rendered, e.g. `<select value>`
  5142. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5143. hostSetElementText(el, vnode.children);
  5144. }
  5145. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5146. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', optimized || !!vnode.dynamicChildren);
  5147. }
  5148. if (dirs) {
  5149. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  5150. }
  5151. // props
  5152. if (props) {
  5153. for (const key in props) {
  5154. if (!isReservedProp(key)) {
  5155. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5156. }
  5157. }
  5158. if ((vnodeHook = props.onVnodeBeforeMount)) {
  5159. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5160. }
  5161. }
  5162. // scopeId
  5163. setScopeId(el, scopeId, vnode, parentComponent);
  5164. }
  5165. {
  5166. Object.defineProperty(el, '__vnode', {
  5167. value: vnode,
  5168. enumerable: false
  5169. });
  5170. Object.defineProperty(el, '__vueParentComponent', {
  5171. value: parentComponent,
  5172. enumerable: false
  5173. });
  5174. }
  5175. if (dirs) {
  5176. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  5177. }
  5178. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  5179. // #1689 For inside suspense + suspense resolved case, just call it
  5180. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  5181. transition &&
  5182. !transition.persisted;
  5183. if (needCallTransitionHooks) {
  5184. transition.beforeEnter(el);
  5185. }
  5186. hostInsert(el, container, anchor);
  5187. if ((vnodeHook = props && props.onVnodeMounted) ||
  5188. needCallTransitionHooks ||
  5189. dirs) {
  5190. queuePostRenderEffect(() => {
  5191. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5192. needCallTransitionHooks && transition.enter(el);
  5193. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  5194. }, parentSuspense);
  5195. }
  5196. };
  5197. const setScopeId = (el, scopeId, vnode, parentComponent) => {
  5198. if (scopeId) {
  5199. hostSetScopeId(el, scopeId);
  5200. }
  5201. if (parentComponent) {
  5202. const treeOwnerId = parentComponent.type.__scopeId;
  5203. // vnode's own scopeId and the current patched component's scopeId is
  5204. // different - this is a slot content node.
  5205. if (treeOwnerId && treeOwnerId !== scopeId) {
  5206. hostSetScopeId(el, treeOwnerId + '-s');
  5207. }
  5208. let subTree = parentComponent.subTree;
  5209. if ( subTree.type === Fragment) {
  5210. subTree =
  5211. filterSingleRoot(subTree.children) || subTree;
  5212. }
  5213. if (vnode === subTree) {
  5214. setScopeId(el, parentComponent.vnode.scopeId, parentComponent.vnode, parentComponent.parent);
  5215. }
  5216. }
  5217. };
  5218. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, optimized, start = 0) => {
  5219. for (let i = start; i < children.length; i++) {
  5220. const child = (children[i] = optimized
  5221. ? cloneIfMounted(children[i])
  5222. : normalizeVNode(children[i]));
  5223. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5224. }
  5225. };
  5226. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, optimized) => {
  5227. const el = (n2.el = n1.el);
  5228. let { patchFlag, dynamicChildren, dirs } = n2;
  5229. // #1426 take the old vnode's patch flag into account since user may clone a
  5230. // compiler-generated vnode, which de-opts to FULL_PROPS
  5231. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  5232. const oldProps = n1.props || EMPTY_OBJ;
  5233. const newProps = n2.props || EMPTY_OBJ;
  5234. let vnodeHook;
  5235. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  5236. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  5237. }
  5238. if (dirs) {
  5239. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  5240. }
  5241. if ( isHmrUpdating) {
  5242. // HMR updated, force full diff
  5243. patchFlag = 0;
  5244. optimized = false;
  5245. dynamicChildren = null;
  5246. }
  5247. if (patchFlag > 0) {
  5248. // the presence of a patchFlag means this element's render code was
  5249. // generated by the compiler and can take the fast path.
  5250. // in this path old node and new node are guaranteed to have the same shape
  5251. // (i.e. at the exact same position in the source template)
  5252. if (patchFlag & 16 /* FULL_PROPS */) {
  5253. // element props contain dynamic keys, full diff needed
  5254. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  5255. }
  5256. else {
  5257. // class
  5258. // this flag is matched when the element has dynamic class bindings.
  5259. if (patchFlag & 2 /* CLASS */) {
  5260. if (oldProps.class !== newProps.class) {
  5261. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  5262. }
  5263. }
  5264. // style
  5265. // this flag is matched when the element has dynamic style bindings
  5266. if (patchFlag & 4 /* STYLE */) {
  5267. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  5268. }
  5269. // props
  5270. // This flag is matched when the element has dynamic prop/attr bindings
  5271. // other than class and style. The keys of dynamic prop/attrs are saved for
  5272. // faster iteration.
  5273. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  5274. // bail out and go through a full diff because we need to unset the old key
  5275. if (patchFlag & 8 /* PROPS */) {
  5276. // if the flag is present then dynamicProps must be non-null
  5277. const propsToUpdate = n2.dynamicProps;
  5278. for (let i = 0; i < propsToUpdate.length; i++) {
  5279. const key = propsToUpdate[i];
  5280. const prev = oldProps[key];
  5281. const next = newProps[key];
  5282. if (next !== prev ||
  5283. (hostForcePatchProp && hostForcePatchProp(el, key))) {
  5284. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  5285. }
  5286. }
  5287. }
  5288. }
  5289. // text
  5290. // This flag is matched when the element has only dynamic text children.
  5291. if (patchFlag & 1 /* TEXT */) {
  5292. if (n1.children !== n2.children) {
  5293. hostSetElementText(el, n2.children);
  5294. }
  5295. }
  5296. }
  5297. else if (!optimized && dynamicChildren == null) {
  5298. // unoptimized, full diff
  5299. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  5300. }
  5301. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  5302. if (dynamicChildren) {
  5303. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG);
  5304. if ( parentComponent && parentComponent.type.__hmrId) {
  5305. traverseStaticChildren(n1, n2);
  5306. }
  5307. }
  5308. else if (!optimized) {
  5309. // full diff
  5310. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG);
  5311. }
  5312. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  5313. queuePostRenderEffect(() => {
  5314. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  5315. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  5316. }, parentSuspense);
  5317. }
  5318. };
  5319. // The fast path for blocks.
  5320. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG) => {
  5321. for (let i = 0; i < newChildren.length; i++) {
  5322. const oldVNode = oldChildren[i];
  5323. const newVNode = newChildren[i];
  5324. // Determine the container (parent element) for the patch.
  5325. const container =
  5326. // - In the case of a Fragment, we need to provide the actual parent
  5327. // of the Fragment itself so it can move its children.
  5328. oldVNode.type === Fragment ||
  5329. // - In the case of different nodes, there is going to be a replacement
  5330. // which also requires the correct parent container
  5331. !isSameVNodeType(oldVNode, newVNode) ||
  5332. // - In the case of a component, it could contain anything.
  5333. oldVNode.shapeFlag & 6 /* COMPONENT */ ||
  5334. oldVNode.shapeFlag & 64 /* TELEPORT */
  5335. ? hostParentNode(oldVNode.el)
  5336. : // In other cases, the parent container is not actually used so we
  5337. // just pass the block element here to avoid a DOM parentNode call.
  5338. fallbackContainer;
  5339. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, true);
  5340. }
  5341. };
  5342. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  5343. if (oldProps !== newProps) {
  5344. for (const key in newProps) {
  5345. if (isReservedProp(key))
  5346. continue;
  5347. const next = newProps[key];
  5348. const prev = oldProps[key];
  5349. if (next !== prev ||
  5350. (hostForcePatchProp && hostForcePatchProp(el, key))) {
  5351. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5352. }
  5353. }
  5354. if (oldProps !== EMPTY_OBJ) {
  5355. for (const key in oldProps) {
  5356. if (!isReservedProp(key) && !(key in newProps)) {
  5357. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  5358. }
  5359. }
  5360. }
  5361. }
  5362. };
  5363. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5364. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  5365. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  5366. let { patchFlag, dynamicChildren } = n2;
  5367. if (patchFlag > 0) {
  5368. optimized = true;
  5369. }
  5370. if ( isHmrUpdating) {
  5371. // HMR updated, force full diff
  5372. patchFlag = 0;
  5373. optimized = false;
  5374. dynamicChildren = null;
  5375. }
  5376. if (n1 == null) {
  5377. hostInsert(fragmentStartAnchor, container, anchor);
  5378. hostInsert(fragmentEndAnchor, container, anchor);
  5379. // a fragment can only have array children
  5380. // since they are either generated by the compiler, or implicitly created
  5381. // from arrays.
  5382. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, optimized);
  5383. }
  5384. else {
  5385. if (patchFlag > 0 &&
  5386. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  5387. dynamicChildren) {
  5388. // a stable fragment (template root or <template v-for>) doesn't need to
  5389. // patch children order, but it may contain dynamicChildren.
  5390. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG);
  5391. if ( parentComponent && parentComponent.type.__hmrId) {
  5392. traverseStaticChildren(n1, n2);
  5393. }
  5394. else if (
  5395. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  5396. // get moved around. Make sure all root level vnodes inherit el.
  5397. // #2134 or if it's a component root, it may also get moved around
  5398. // as the component is being moved.
  5399. n2.key != null ||
  5400. (parentComponent && n2 === parentComponent.subTree)) {
  5401. traverseStaticChildren(n1, n2, true /* shallow */);
  5402. }
  5403. }
  5404. else {
  5405. // keyed / unkeyed, or manual fragments.
  5406. // for keyed & unkeyed, since they are compiler generated from v-for,
  5407. // each child is guaranteed to be a block so the fragment will never
  5408. // have dynamicChildren.
  5409. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, optimized);
  5410. }
  5411. }
  5412. };
  5413. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5414. if (n1 == null) {
  5415. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  5416. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  5417. }
  5418. else {
  5419. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5420. }
  5421. }
  5422. else {
  5423. updateComponent(n1, n2, optimized);
  5424. }
  5425. };
  5426. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5427. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  5428. if ( instance.type.__hmrId) {
  5429. registerHMR(instance);
  5430. }
  5431. {
  5432. pushWarningContext(initialVNode);
  5433. startMeasure(instance, `mount`);
  5434. }
  5435. // inject renderer internals for keepAlive
  5436. if (isKeepAlive(initialVNode)) {
  5437. instance.ctx.renderer = internals;
  5438. }
  5439. // resolve props and slots for setup context
  5440. {
  5441. startMeasure(instance, `init`);
  5442. }
  5443. setupComponent(instance);
  5444. {
  5445. endMeasure(instance, `init`);
  5446. }
  5447. // setup() is async. This component relies on async logic to be resolved
  5448. // before proceeding
  5449. if ( instance.asyncDep) {
  5450. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  5451. // Give it a placeholder if this is not hydration
  5452. // TODO handle self-defined fallback
  5453. if (!initialVNode.el) {
  5454. const placeholder = (instance.subTree = createVNode(Comment));
  5455. processCommentNode(null, placeholder, container, anchor);
  5456. }
  5457. return;
  5458. }
  5459. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  5460. {
  5461. popWarningContext();
  5462. endMeasure(instance, `mount`);
  5463. }
  5464. };
  5465. const updateComponent = (n1, n2, optimized) => {
  5466. const instance = (n2.component = n1.component);
  5467. if (shouldUpdateComponent(n1, n2, optimized)) {
  5468. if (
  5469. instance.asyncDep &&
  5470. !instance.asyncResolved) {
  5471. // async & still pending - just update props and slots
  5472. // since the component's reactive effect for render isn't set-up yet
  5473. {
  5474. pushWarningContext(n2);
  5475. }
  5476. updateComponentPreRender(instance, n2, optimized);
  5477. {
  5478. popWarningContext();
  5479. }
  5480. return;
  5481. }
  5482. else {
  5483. // normal update
  5484. instance.next = n2;
  5485. // in case the child component is also queued, remove it to avoid
  5486. // double updating the same child component in the same flush.
  5487. invalidateJob(instance.update);
  5488. // instance.update is the reactive effect runner.
  5489. instance.update();
  5490. }
  5491. }
  5492. else {
  5493. // no update needed. just copy over properties
  5494. n2.component = n1.component;
  5495. n2.el = n1.el;
  5496. instance.vnode = n2;
  5497. }
  5498. };
  5499. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  5500. // create reactive effect for rendering
  5501. instance.update = effect(function componentEffect() {
  5502. if (!instance.isMounted) {
  5503. let vnodeHook;
  5504. const { el, props } = initialVNode;
  5505. const { bm, m, parent } = instance;
  5506. // beforeMount hook
  5507. if (bm) {
  5508. invokeArrayFns(bm);
  5509. }
  5510. // onVnodeBeforeMount
  5511. if ((vnodeHook = props && props.onVnodeBeforeMount)) {
  5512. invokeVNodeHook(vnodeHook, parent, initialVNode);
  5513. }
  5514. // render
  5515. {
  5516. startMeasure(instance, `render`);
  5517. }
  5518. const subTree = (instance.subTree = renderComponentRoot(instance));
  5519. {
  5520. endMeasure(instance, `render`);
  5521. }
  5522. if (el && hydrateNode) {
  5523. {
  5524. startMeasure(instance, `hydrate`);
  5525. }
  5526. // vnode has adopted host node - perform hydration instead of mount.
  5527. hydrateNode(initialVNode.el, subTree, instance, parentSuspense);
  5528. {
  5529. endMeasure(instance, `hydrate`);
  5530. }
  5531. }
  5532. else {
  5533. {
  5534. startMeasure(instance, `patch`);
  5535. }
  5536. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  5537. {
  5538. endMeasure(instance, `patch`);
  5539. }
  5540. initialVNode.el = subTree.el;
  5541. }
  5542. // mounted hook
  5543. if (m) {
  5544. queuePostRenderEffect(m, parentSuspense);
  5545. }
  5546. // onVnodeMounted
  5547. if ((vnodeHook = props && props.onVnodeMounted)) {
  5548. queuePostRenderEffect(() => {
  5549. invokeVNodeHook(vnodeHook, parent, initialVNode);
  5550. }, parentSuspense);
  5551. }
  5552. // activated hook for keep-alive roots.
  5553. // #1742 activated hook must be accessed after first render
  5554. // since the hook may be injected by a child keep-alive
  5555. const { a } = instance;
  5556. if (a &&
  5557. initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  5558. queuePostRenderEffect(a, parentSuspense);
  5559. }
  5560. instance.isMounted = true;
  5561. }
  5562. else {
  5563. // updateComponent
  5564. // This is triggered by mutation of component's own state (next: null)
  5565. // OR parent calling processComponent (next: VNode)
  5566. let { next, bu, u, parent, vnode } = instance;
  5567. let originNext = next;
  5568. let vnodeHook;
  5569. {
  5570. pushWarningContext(next || instance.vnode);
  5571. }
  5572. if (next) {
  5573. updateComponentPreRender(instance, next, optimized);
  5574. }
  5575. else {
  5576. next = vnode;
  5577. }
  5578. next.el = vnode.el;
  5579. // beforeUpdate hook
  5580. if (bu) {
  5581. invokeArrayFns(bu);
  5582. }
  5583. // onVnodeBeforeUpdate
  5584. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  5585. invokeVNodeHook(vnodeHook, parent, next, vnode);
  5586. }
  5587. // render
  5588. {
  5589. startMeasure(instance, `render`);
  5590. }
  5591. const nextTree = renderComponentRoot(instance);
  5592. {
  5593. endMeasure(instance, `render`);
  5594. }
  5595. const prevTree = instance.subTree;
  5596. instance.subTree = nextTree;
  5597. // reset refs
  5598. // only needed if previous patch had refs
  5599. if (instance.refs !== EMPTY_OBJ) {
  5600. instance.refs = {};
  5601. }
  5602. {
  5603. startMeasure(instance, `patch`);
  5604. }
  5605. patch(prevTree, nextTree,
  5606. // parent may have changed if it's in a teleport
  5607. hostParentNode(prevTree.el),
  5608. // anchor may have changed if it's in a fragment
  5609. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  5610. {
  5611. endMeasure(instance, `patch`);
  5612. }
  5613. next.el = nextTree.el;
  5614. if (originNext === null) {
  5615. // self-triggered update. In case of HOC, update parent component
  5616. // vnode el. HOC is indicated by parent instance's subTree pointing
  5617. // to child component's vnode
  5618. updateHOCHostEl(instance, nextTree.el);
  5619. }
  5620. // updated hook
  5621. if (u) {
  5622. queuePostRenderEffect(u, parentSuspense);
  5623. }
  5624. // onVnodeUpdated
  5625. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  5626. queuePostRenderEffect(() => {
  5627. invokeVNodeHook(vnodeHook, parent, next, vnode);
  5628. }, parentSuspense);
  5629. }
  5630. {
  5631. devtoolsComponentUpdated(instance);
  5632. }
  5633. {
  5634. popWarningContext();
  5635. }
  5636. }
  5637. }, createDevEffectOptions(instance) );
  5638. };
  5639. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  5640. nextVNode.component = instance;
  5641. const prevProps = instance.vnode.props;
  5642. instance.vnode = nextVNode;
  5643. instance.next = null;
  5644. updateProps(instance, nextVNode.props, prevProps, optimized);
  5645. updateSlots(instance, nextVNode.children);
  5646. // props update may have triggered pre-flush watchers.
  5647. // flush them before the render update.
  5648. flushPreFlushCbs(undefined, instance.update);
  5649. };
  5650. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized = false) => {
  5651. const c1 = n1 && n1.children;
  5652. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  5653. const c2 = n2.children;
  5654. const { patchFlag, shapeFlag } = n2;
  5655. // fast path
  5656. if (patchFlag > 0) {
  5657. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  5658. // this could be either fully-keyed or mixed (some keyed some not)
  5659. // presence of patchFlag means children are guaranteed to be arrays
  5660. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5661. return;
  5662. }
  5663. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  5664. // unkeyed
  5665. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5666. return;
  5667. }
  5668. }
  5669. // children has 3 possibilities: text, array or no children.
  5670. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  5671. // text children fast path
  5672. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  5673. unmountChildren(c1, parentComponent, parentSuspense);
  5674. }
  5675. if (c2 !== c1) {
  5676. hostSetElementText(container, c2);
  5677. }
  5678. }
  5679. else {
  5680. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  5681. // prev children was array
  5682. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5683. // two arrays, cannot assume anything, do full diff
  5684. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5685. }
  5686. else {
  5687. // no new children, just unmount old
  5688. unmountChildren(c1, parentComponent, parentSuspense, true);
  5689. }
  5690. }
  5691. else {
  5692. // prev children was text OR null
  5693. // new children is array OR null
  5694. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  5695. hostSetElementText(container, '');
  5696. }
  5697. // mount new if array
  5698. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5699. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  5700. }
  5701. }
  5702. }
  5703. };
  5704. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5705. c1 = c1 || EMPTY_ARR;
  5706. c2 = c2 || EMPTY_ARR;
  5707. const oldLength = c1.length;
  5708. const newLength = c2.length;
  5709. const commonLength = Math.min(oldLength, newLength);
  5710. let i;
  5711. for (i = 0; i < commonLength; i++) {
  5712. const nextChild = (c2[i] = optimized
  5713. ? cloneIfMounted(c2[i])
  5714. : normalizeVNode(c2[i]));
  5715. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, optimized);
  5716. }
  5717. if (oldLength > newLength) {
  5718. // remove old
  5719. unmountChildren(c1, parentComponent, parentSuspense, true, commonLength);
  5720. }
  5721. else {
  5722. // mount new
  5723. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, commonLength);
  5724. }
  5725. };
  5726. // can be all-keyed or mixed
  5727. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, optimized) => {
  5728. let i = 0;
  5729. const l2 = c2.length;
  5730. let e1 = c1.length - 1; // prev ending index
  5731. let e2 = l2 - 1; // next ending index
  5732. // 1. sync from start
  5733. // (a b) c
  5734. // (a b) d e
  5735. while (i <= e1 && i <= e2) {
  5736. const n1 = c1[i];
  5737. const n2 = (c2[i] = optimized
  5738. ? cloneIfMounted(c2[i])
  5739. : normalizeVNode(c2[i]));
  5740. if (isSameVNodeType(n1, n2)) {
  5741. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, optimized);
  5742. }
  5743. else {
  5744. break;
  5745. }
  5746. i++;
  5747. }
  5748. // 2. sync from end
  5749. // a (b c)
  5750. // d e (b c)
  5751. while (i <= e1 && i <= e2) {
  5752. const n1 = c1[e1];
  5753. const n2 = (c2[e2] = optimized
  5754. ? cloneIfMounted(c2[e2])
  5755. : normalizeVNode(c2[e2]));
  5756. if (isSameVNodeType(n1, n2)) {
  5757. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, optimized);
  5758. }
  5759. else {
  5760. break;
  5761. }
  5762. e1--;
  5763. e2--;
  5764. }
  5765. // 3. common sequence + mount
  5766. // (a b)
  5767. // (a b) c
  5768. // i = 2, e1 = 1, e2 = 2
  5769. // (a b)
  5770. // c (a b)
  5771. // i = 0, e1 = -1, e2 = 0
  5772. if (i > e1) {
  5773. if (i <= e2) {
  5774. const nextPos = e2 + 1;
  5775. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  5776. while (i <= e2) {
  5777. patch(null, (c2[i] = optimized
  5778. ? cloneIfMounted(c2[i])
  5779. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG);
  5780. i++;
  5781. }
  5782. }
  5783. }
  5784. // 4. common sequence + unmount
  5785. // (a b) c
  5786. // (a b)
  5787. // i = 2, e1 = 2, e2 = 1
  5788. // a (b c)
  5789. // (b c)
  5790. // i = 0, e1 = 0, e2 = -1
  5791. else if (i > e2) {
  5792. while (i <= e1) {
  5793. unmount(c1[i], parentComponent, parentSuspense, true);
  5794. i++;
  5795. }
  5796. }
  5797. // 5. unknown sequence
  5798. // [i ... e1 + 1]: a b [c d e] f g
  5799. // [i ... e2 + 1]: a b [e d c h] f g
  5800. // i = 2, e1 = 4, e2 = 5
  5801. else {
  5802. const s1 = i; // prev starting index
  5803. const s2 = i; // next starting index
  5804. // 5.1 build key:index map for newChildren
  5805. const keyToNewIndexMap = new Map();
  5806. for (i = s2; i <= e2; i++) {
  5807. const nextChild = (c2[i] = optimized
  5808. ? cloneIfMounted(c2[i])
  5809. : normalizeVNode(c2[i]));
  5810. if (nextChild.key != null) {
  5811. if ( keyToNewIndexMap.has(nextChild.key)) {
  5812. warn(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  5813. }
  5814. keyToNewIndexMap.set(nextChild.key, i);
  5815. }
  5816. }
  5817. // 5.2 loop through old children left to be patched and try to patch
  5818. // matching nodes & remove nodes that are no longer present
  5819. let j;
  5820. let patched = 0;
  5821. const toBePatched = e2 - s2 + 1;
  5822. let moved = false;
  5823. // used to track whether any node has moved
  5824. let maxNewIndexSoFar = 0;
  5825. // works as Map<newIndex, oldIndex>
  5826. // Note that oldIndex is offset by +1
  5827. // and oldIndex = 0 is a special value indicating the new node has
  5828. // no corresponding old node.
  5829. // used for determining longest stable subsequence
  5830. const newIndexToOldIndexMap = new Array(toBePatched);
  5831. for (i = 0; i < toBePatched; i++)
  5832. newIndexToOldIndexMap[i] = 0;
  5833. for (i = s1; i <= e1; i++) {
  5834. const prevChild = c1[i];
  5835. if (patched >= toBePatched) {
  5836. // all new children have been patched so this can only be a removal
  5837. unmount(prevChild, parentComponent, parentSuspense, true);
  5838. continue;
  5839. }
  5840. let newIndex;
  5841. if (prevChild.key != null) {
  5842. newIndex = keyToNewIndexMap.get(prevChild.key);
  5843. }
  5844. else {
  5845. // key-less node, try to locate a key-less node of the same type
  5846. for (j = s2; j <= e2; j++) {
  5847. if (newIndexToOldIndexMap[j - s2] === 0 &&
  5848. isSameVNodeType(prevChild, c2[j])) {
  5849. newIndex = j;
  5850. break;
  5851. }
  5852. }
  5853. }
  5854. if (newIndex === undefined) {
  5855. unmount(prevChild, parentComponent, parentSuspense, true);
  5856. }
  5857. else {
  5858. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  5859. if (newIndex >= maxNewIndexSoFar) {
  5860. maxNewIndexSoFar = newIndex;
  5861. }
  5862. else {
  5863. moved = true;
  5864. }
  5865. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, optimized);
  5866. patched++;
  5867. }
  5868. }
  5869. // 5.3 move and mount
  5870. // generate longest stable subsequence only when nodes have moved
  5871. const increasingNewIndexSequence = moved
  5872. ? getSequence(newIndexToOldIndexMap)
  5873. : EMPTY_ARR;
  5874. j = increasingNewIndexSequence.length - 1;
  5875. // looping backwards so that we can use last patched node as anchor
  5876. for (i = toBePatched - 1; i >= 0; i--) {
  5877. const nextIndex = s2 + i;
  5878. const nextChild = c2[nextIndex];
  5879. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  5880. if (newIndexToOldIndexMap[i] === 0) {
  5881. // mount new
  5882. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG);
  5883. }
  5884. else if (moved) {
  5885. // move if:
  5886. // There is no stable subsequence (e.g. a reverse)
  5887. // OR current node is not among the stable sequence
  5888. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  5889. move(nextChild, container, anchor, 2 /* REORDER */);
  5890. }
  5891. else {
  5892. j--;
  5893. }
  5894. }
  5895. }
  5896. }
  5897. };
  5898. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  5899. const { el, type, transition, children, shapeFlag } = vnode;
  5900. if (shapeFlag & 6 /* COMPONENT */) {
  5901. move(vnode.component.subTree, container, anchor, moveType);
  5902. return;
  5903. }
  5904. if ( shapeFlag & 128 /* SUSPENSE */) {
  5905. vnode.suspense.move(container, anchor, moveType);
  5906. return;
  5907. }
  5908. if (shapeFlag & 64 /* TELEPORT */) {
  5909. type.move(vnode, container, anchor, internals);
  5910. return;
  5911. }
  5912. if (type === Fragment) {
  5913. hostInsert(el, container, anchor);
  5914. for (let i = 0; i < children.length; i++) {
  5915. move(children[i], container, anchor, moveType);
  5916. }
  5917. hostInsert(vnode.anchor, container, anchor);
  5918. return;
  5919. }
  5920. // static node move can only happen when force updating HMR
  5921. if ( type === Static) {
  5922. moveStaticNode(vnode, container, anchor);
  5923. return;
  5924. }
  5925. // single nodes
  5926. const needTransition = moveType !== 2 /* REORDER */ &&
  5927. shapeFlag & 1 /* ELEMENT */ &&
  5928. transition;
  5929. if (needTransition) {
  5930. if (moveType === 0 /* ENTER */) {
  5931. transition.beforeEnter(el);
  5932. hostInsert(el, container, anchor);
  5933. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  5934. }
  5935. else {
  5936. const { leave, delayLeave, afterLeave } = transition;
  5937. const remove = () => hostInsert(el, container, anchor);
  5938. const performLeave = () => {
  5939. leave(el, () => {
  5940. remove();
  5941. afterLeave && afterLeave();
  5942. });
  5943. };
  5944. if (delayLeave) {
  5945. delayLeave(el, remove, performLeave);
  5946. }
  5947. else {
  5948. performLeave();
  5949. }
  5950. }
  5951. }
  5952. else {
  5953. hostInsert(el, container, anchor);
  5954. }
  5955. };
  5956. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false) => {
  5957. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  5958. // unset ref
  5959. if (ref != null && parentComponent) {
  5960. setRef(ref, null, parentComponent, parentSuspense, null);
  5961. }
  5962. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  5963. parentComponent.ctx.deactivate(vnode);
  5964. return;
  5965. }
  5966. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  5967. let vnodeHook;
  5968. if ((vnodeHook = props && props.onVnodeBeforeUnmount)) {
  5969. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  5970. }
  5971. if (shapeFlag & 6 /* COMPONENT */) {
  5972. unmountComponent(vnode.component, parentSuspense, doRemove);
  5973. }
  5974. else {
  5975. if ( shapeFlag & 128 /* SUSPENSE */) {
  5976. vnode.suspense.unmount(parentSuspense, doRemove);
  5977. return;
  5978. }
  5979. if (shouldInvokeDirs) {
  5980. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  5981. }
  5982. if (dynamicChildren &&
  5983. // #1153: fast path should not be taken for non-stable (v-for) fragments
  5984. (type !== Fragment ||
  5985. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  5986. // fast path for block nodes: only need to unmount dynamic children.
  5987. unmountChildren(dynamicChildren, parentComponent, parentSuspense);
  5988. }
  5989. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  5990. unmountChildren(children, parentComponent, parentSuspense);
  5991. }
  5992. // an unmounted teleport should always remove its children
  5993. if (shapeFlag & 64 /* TELEPORT */) {
  5994. vnode.type.remove(vnode, internals);
  5995. }
  5996. if (doRemove) {
  5997. remove(vnode);
  5998. }
  5999. }
  6000. if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  6001. queuePostRenderEffect(() => {
  6002. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6003. shouldInvokeDirs &&
  6004. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  6005. }, parentSuspense);
  6006. }
  6007. };
  6008. const remove = vnode => {
  6009. const { type, el, anchor, transition } = vnode;
  6010. if (type === Fragment) {
  6011. removeFragment(el, anchor);
  6012. return;
  6013. }
  6014. if ( type === Static) {
  6015. removeStaticNode(vnode);
  6016. return;
  6017. }
  6018. const performRemove = () => {
  6019. hostRemove(el);
  6020. if (transition && !transition.persisted && transition.afterLeave) {
  6021. transition.afterLeave();
  6022. }
  6023. };
  6024. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  6025. transition &&
  6026. !transition.persisted) {
  6027. const { leave, delayLeave } = transition;
  6028. const performLeave = () => leave(el, performRemove);
  6029. if (delayLeave) {
  6030. delayLeave(vnode.el, performRemove, performLeave);
  6031. }
  6032. else {
  6033. performLeave();
  6034. }
  6035. }
  6036. else {
  6037. performRemove();
  6038. }
  6039. };
  6040. const removeFragment = (cur, end) => {
  6041. // For fragments, directly remove all contained DOM nodes.
  6042. // (fragment child nodes cannot have transition)
  6043. let next;
  6044. while (cur !== end) {
  6045. next = hostNextSibling(cur);
  6046. hostRemove(cur);
  6047. cur = next;
  6048. }
  6049. hostRemove(end);
  6050. };
  6051. const unmountComponent = (instance, parentSuspense, doRemove) => {
  6052. if ( instance.type.__hmrId) {
  6053. unregisterHMR(instance);
  6054. }
  6055. const { bum, effects, update, subTree, um } = instance;
  6056. // beforeUnmount hook
  6057. if (bum) {
  6058. invokeArrayFns(bum);
  6059. }
  6060. if (effects) {
  6061. for (let i = 0; i < effects.length; i++) {
  6062. stop(effects[i]);
  6063. }
  6064. }
  6065. // update may be null if a component is unmounted before its async
  6066. // setup has resolved.
  6067. if (update) {
  6068. stop(update);
  6069. unmount(subTree, instance, parentSuspense, doRemove);
  6070. }
  6071. // unmounted hook
  6072. if (um) {
  6073. queuePostRenderEffect(um, parentSuspense);
  6074. }
  6075. queuePostRenderEffect(() => {
  6076. instance.isUnmounted = true;
  6077. }, parentSuspense);
  6078. // A component with async dep inside a pending suspense is unmounted before
  6079. // its async dep resolves. This should remove the dep from the suspense, and
  6080. // cause the suspense to resolve immediately if that was the last dep.
  6081. if (
  6082. parentSuspense &&
  6083. parentSuspense.pendingBranch &&
  6084. !parentSuspense.isUnmounted &&
  6085. instance.asyncDep &&
  6086. !instance.asyncResolved &&
  6087. instance.suspenseId === parentSuspense.pendingId) {
  6088. parentSuspense.deps--;
  6089. if (parentSuspense.deps === 0) {
  6090. parentSuspense.resolve();
  6091. }
  6092. }
  6093. {
  6094. devtoolsComponentRemoved(instance);
  6095. }
  6096. };
  6097. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, start = 0) => {
  6098. for (let i = start; i < children.length; i++) {
  6099. unmount(children[i], parentComponent, parentSuspense, doRemove);
  6100. }
  6101. };
  6102. const getNextHostNode = vnode => {
  6103. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  6104. return getNextHostNode(vnode.component.subTree);
  6105. }
  6106. if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
  6107. return vnode.suspense.next();
  6108. }
  6109. return hostNextSibling((vnode.anchor || vnode.el));
  6110. };
  6111. /**
  6112. * #1156
  6113. * When a component is HMR-enabled, we need to make sure that all static nodes
  6114. * inside a block also inherit the DOM element from the previous tree so that
  6115. * HMR updates (which are full updates) can retrieve the element for patching.
  6116. *
  6117. * #2080
  6118. * Inside keyed `template` fragment static children, if a fragment is moved,
  6119. * the children will always moved so that need inherit el form previous nodes
  6120. * to ensure correct moved position.
  6121. */
  6122. const traverseStaticChildren = (n1, n2, shallow = false) => {
  6123. const ch1 = n1.children;
  6124. const ch2 = n2.children;
  6125. if (isArray(ch1) && isArray(ch2)) {
  6126. for (let i = 0; i < ch1.length; i++) {
  6127. // this is only called in the optimized path so array children are
  6128. // guaranteed to be vnodes
  6129. const c1 = ch1[i];
  6130. const c2 = (ch2[i] = cloneIfMounted(ch2[i]));
  6131. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  6132. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  6133. c2.el = c1.el;
  6134. }
  6135. if (!shallow)
  6136. traverseStaticChildren(c1, c2);
  6137. }
  6138. if ( c2.type === Comment) {
  6139. c2.el = c1.el;
  6140. }
  6141. }
  6142. }
  6143. };
  6144. const render = (vnode, container) => {
  6145. if (vnode == null) {
  6146. if (container._vnode) {
  6147. unmount(container._vnode, null, null, true);
  6148. }
  6149. }
  6150. else {
  6151. patch(container._vnode || null, vnode, container);
  6152. }
  6153. flushPostFlushCbs();
  6154. container._vnode = vnode;
  6155. };
  6156. const internals = {
  6157. p: patch,
  6158. um: unmount,
  6159. m: move,
  6160. r: remove,
  6161. mt: mountComponent,
  6162. mc: mountChildren,
  6163. pc: patchChildren,
  6164. pbc: patchBlockChildren,
  6165. n: getNextHostNode,
  6166. o: options
  6167. };
  6168. let hydrate;
  6169. let hydrateNode;
  6170. if (createHydrationFns) {
  6171. [hydrate, hydrateNode] = createHydrationFns(internals);
  6172. }
  6173. return {
  6174. render,
  6175. hydrate,
  6176. createApp: createAppAPI(render, hydrate)
  6177. };
  6178. }
  6179. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  6180. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  6181. vnode,
  6182. prevVNode
  6183. ]);
  6184. }
  6185. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  6186. function getSequence(arr) {
  6187. const p = arr.slice();
  6188. const result = [0];
  6189. let i, j, u, v, c;
  6190. const len = arr.length;
  6191. for (i = 0; i < len; i++) {
  6192. const arrI = arr[i];
  6193. if (arrI !== 0) {
  6194. j = result[result.length - 1];
  6195. if (arr[j] < arrI) {
  6196. p[i] = j;
  6197. result.push(i);
  6198. continue;
  6199. }
  6200. u = 0;
  6201. v = result.length - 1;
  6202. while (u < v) {
  6203. c = ((u + v) / 2) | 0;
  6204. if (arr[result[c]] < arrI) {
  6205. u = c + 1;
  6206. }
  6207. else {
  6208. v = c;
  6209. }
  6210. }
  6211. if (arrI < arr[result[u]]) {
  6212. if (u > 0) {
  6213. p[i] = result[u - 1];
  6214. }
  6215. result[u] = i;
  6216. }
  6217. }
  6218. }
  6219. u = result.length;
  6220. v = result[u - 1];
  6221. while (u-- > 0) {
  6222. result[u] = v;
  6223. v = p[v];
  6224. }
  6225. return result;
  6226. }
  6227. // Simple effect.
  6228. function watchEffect(effect, options) {
  6229. return doWatch(effect, null, options);
  6230. }
  6231. // initial value for watchers to trigger on undefined initial values
  6232. const INITIAL_WATCHER_VALUE = {};
  6233. // implementation
  6234. function watch(source, cb, options) {
  6235. if ( !isFunction(cb)) {
  6236. warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  6237. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  6238. `supports \`watch(source, cb, options?) signature.`);
  6239. }
  6240. return doWatch(source, cb, options);
  6241. }
  6242. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ, instance = currentInstance) {
  6243. if ( !cb) {
  6244. if (immediate !== undefined) {
  6245. warn(`watch() "immediate" option is only respected when using the ` +
  6246. `watch(source, callback, options?) signature.`);
  6247. }
  6248. if (deep !== undefined) {
  6249. warn(`watch() "deep" option is only respected when using the ` +
  6250. `watch(source, callback, options?) signature.`);
  6251. }
  6252. }
  6253. const warnInvalidSource = (s) => {
  6254. warn(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  6255. `a reactive object, or an array of these types.`);
  6256. };
  6257. let getter;
  6258. const isRefSource = isRef(source);
  6259. if (isRefSource) {
  6260. getter = () => source.value;
  6261. }
  6262. else if (isReactive(source)) {
  6263. getter = () => source;
  6264. deep = true;
  6265. }
  6266. else if (isArray(source)) {
  6267. getter = () => source.map(s => {
  6268. if (isRef(s)) {
  6269. return s.value;
  6270. }
  6271. else if (isReactive(s)) {
  6272. return traverse(s);
  6273. }
  6274. else if (isFunction(s)) {
  6275. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
  6276. }
  6277. else {
  6278. warnInvalidSource(s);
  6279. }
  6280. });
  6281. }
  6282. else if (isFunction(source)) {
  6283. if (cb) {
  6284. // getter with cb
  6285. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
  6286. }
  6287. else {
  6288. // no cb -> simple effect
  6289. getter = () => {
  6290. if (instance && instance.isUnmounted) {
  6291. return;
  6292. }
  6293. if (cleanup) {
  6294. cleanup();
  6295. }
  6296. return callWithErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]);
  6297. };
  6298. }
  6299. }
  6300. else {
  6301. getter = NOOP;
  6302. warnInvalidSource(source);
  6303. }
  6304. if (cb && deep) {
  6305. const baseGetter = getter;
  6306. getter = () => traverse(baseGetter());
  6307. }
  6308. let cleanup;
  6309. const onInvalidate = (fn) => {
  6310. cleanup = runner.options.onStop = () => {
  6311. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  6312. };
  6313. };
  6314. let oldValue = isArray(source) ? [] : INITIAL_WATCHER_VALUE;
  6315. const job = () => {
  6316. if (!runner.active) {
  6317. return;
  6318. }
  6319. if (cb) {
  6320. // watch(source, cb)
  6321. const newValue = runner();
  6322. if (deep || isRefSource || hasChanged(newValue, oldValue)) {
  6323. // cleanup before running cb again
  6324. if (cleanup) {
  6325. cleanup();
  6326. }
  6327. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  6328. newValue,
  6329. // pass undefined as the old value when it's changed for the first time
  6330. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  6331. onInvalidate
  6332. ]);
  6333. oldValue = newValue;
  6334. }
  6335. }
  6336. else {
  6337. // watchEffect
  6338. runner();
  6339. }
  6340. };
  6341. // important: mark the job as a watcher callback so that scheduler knows it
  6342. // it is allowed to self-trigger (#1727)
  6343. job.allowRecurse = !!cb;
  6344. let scheduler;
  6345. if (flush === 'sync') {
  6346. scheduler = job;
  6347. }
  6348. else if (flush === 'post') {
  6349. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  6350. }
  6351. else {
  6352. // default: 'pre'
  6353. scheduler = () => {
  6354. if (!instance || instance.isMounted) {
  6355. queuePreFlushCb(job);
  6356. }
  6357. else {
  6358. // with 'pre' option, the first call must happen before
  6359. // the component is mounted so it is called synchronously.
  6360. job();
  6361. }
  6362. };
  6363. }
  6364. const runner = effect(getter, {
  6365. lazy: true,
  6366. onTrack,
  6367. onTrigger,
  6368. scheduler
  6369. });
  6370. recordInstanceBoundEffect(runner);
  6371. // initial run
  6372. if (cb) {
  6373. if (immediate) {
  6374. job();
  6375. }
  6376. else {
  6377. oldValue = runner();
  6378. }
  6379. }
  6380. else if (flush === 'post') {
  6381. queuePostRenderEffect(runner, instance && instance.suspense);
  6382. }
  6383. else {
  6384. runner();
  6385. }
  6386. return () => {
  6387. stop(runner);
  6388. if (instance) {
  6389. remove(instance.effects, runner);
  6390. }
  6391. };
  6392. }
  6393. // this.$watch
  6394. function instanceWatch(source, cb, options) {
  6395. const publicThis = this.proxy;
  6396. const getter = isString(source)
  6397. ? () => publicThis[source]
  6398. : source.bind(publicThis);
  6399. return doWatch(getter, cb.bind(publicThis), options, this);
  6400. }
  6401. function traverse(value, seen = new Set()) {
  6402. if (!isObject(value) || seen.has(value)) {
  6403. return value;
  6404. }
  6405. seen.add(value);
  6406. if (isRef(value)) {
  6407. traverse(value.value, seen);
  6408. }
  6409. else if (isArray(value)) {
  6410. for (let i = 0; i < value.length; i++) {
  6411. traverse(value[i], seen);
  6412. }
  6413. }
  6414. else if (isMap(value)) {
  6415. value.forEach((_, key) => {
  6416. // to register mutation dep for existing keys
  6417. traverse(value.get(key), seen);
  6418. });
  6419. }
  6420. else if (isSet(value)) {
  6421. value.forEach(v => {
  6422. traverse(v, seen);
  6423. });
  6424. }
  6425. else {
  6426. for (const key in value) {
  6427. traverse(value[key], seen);
  6428. }
  6429. }
  6430. return value;
  6431. }
  6432. function provide(key, value) {
  6433. if (!currentInstance) {
  6434. {
  6435. warn(`provide() can only be used inside setup().`);
  6436. }
  6437. }
  6438. else {
  6439. let provides = currentInstance.provides;
  6440. // by default an instance inherits its parent's provides object
  6441. // but when it needs to provide values of its own, it creates its
  6442. // own provides object using parent provides object as prototype.
  6443. // this way in `inject` we can simply look up injections from direct
  6444. // parent and let the prototype chain do the work.
  6445. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  6446. if (parentProvides === provides) {
  6447. provides = currentInstance.provides = Object.create(parentProvides);
  6448. }
  6449. // TS doesn't allow symbol as index type
  6450. provides[key] = value;
  6451. }
  6452. }
  6453. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  6454. // fallback to `currentRenderingInstance` so that this can be called in
  6455. // a functional component
  6456. const instance = currentInstance || currentRenderingInstance;
  6457. if (instance) {
  6458. const provides = instance.provides;
  6459. if (key in provides) {
  6460. // TS doesn't allow symbol as index type
  6461. return provides[key];
  6462. }
  6463. else if (arguments.length > 1) {
  6464. return treatDefaultAsFactory && isFunction(defaultValue)
  6465. ? defaultValue()
  6466. : defaultValue;
  6467. }
  6468. else {
  6469. warn(`injection "${String(key)}" not found.`);
  6470. }
  6471. }
  6472. else {
  6473. warn(`inject() can only be used inside setup() or functional components.`);
  6474. }
  6475. }
  6476. function createDuplicateChecker() {
  6477. const cache = Object.create(null);
  6478. return (type, key) => {
  6479. if (cache[key]) {
  6480. warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
  6481. }
  6482. else {
  6483. cache[key] = type;
  6484. }
  6485. };
  6486. }
  6487. let isInBeforeCreate = false;
  6488. function applyOptions(instance, options, deferredData = [], deferredWatch = [], asMixin = false) {
  6489. const {
  6490. // composition
  6491. mixins, extends: extendsOptions,
  6492. // state
  6493. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  6494. // assets
  6495. components, directives,
  6496. // lifecycle
  6497. beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured } = options;
  6498. const publicThis = instance.proxy;
  6499. const ctx = instance.ctx;
  6500. const globalMixins = instance.appContext.mixins;
  6501. if (asMixin && render && instance.render === NOOP) {
  6502. instance.render = render;
  6503. }
  6504. // applyOptions is called non-as-mixin once per instance
  6505. if (!asMixin) {
  6506. isInBeforeCreate = true;
  6507. callSyncHook('beforeCreate', options, publicThis, globalMixins);
  6508. isInBeforeCreate = false;
  6509. // global mixins are applied first
  6510. applyMixins(instance, globalMixins, deferredData, deferredWatch);
  6511. }
  6512. // extending a base component...
  6513. if (extendsOptions) {
  6514. applyOptions(instance, extendsOptions, deferredData, deferredWatch, true);
  6515. }
  6516. // local mixins
  6517. if (mixins) {
  6518. applyMixins(instance, mixins, deferredData, deferredWatch);
  6519. }
  6520. const checkDuplicateProperties = createDuplicateChecker() ;
  6521. {
  6522. const [propsOptions] = instance.propsOptions;
  6523. if (propsOptions) {
  6524. for (const key in propsOptions) {
  6525. checkDuplicateProperties("Props" /* PROPS */, key);
  6526. }
  6527. }
  6528. }
  6529. // options initialization order (to be consistent with Vue 2):
  6530. // - props (already done outside of this function)
  6531. // - inject
  6532. // - methods
  6533. // - data (deferred since it relies on `this` access)
  6534. // - computed
  6535. // - watch (deferred since it relies on `this` access)
  6536. if (injectOptions) {
  6537. if (isArray(injectOptions)) {
  6538. for (let i = 0; i < injectOptions.length; i++) {
  6539. const key = injectOptions[i];
  6540. ctx[key] = inject(key);
  6541. {
  6542. checkDuplicateProperties("Inject" /* INJECT */, key);
  6543. }
  6544. }
  6545. }
  6546. else {
  6547. for (const key in injectOptions) {
  6548. const opt = injectOptions[key];
  6549. if (isObject(opt)) {
  6550. ctx[key] = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  6551. }
  6552. else {
  6553. ctx[key] = inject(opt);
  6554. }
  6555. {
  6556. checkDuplicateProperties("Inject" /* INJECT */, key);
  6557. }
  6558. }
  6559. }
  6560. }
  6561. if (methods) {
  6562. for (const key in methods) {
  6563. const methodHandler = methods[key];
  6564. if (isFunction(methodHandler)) {
  6565. ctx[key] = methodHandler.bind(publicThis);
  6566. {
  6567. checkDuplicateProperties("Methods" /* METHODS */, key);
  6568. }
  6569. }
  6570. else {
  6571. warn(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  6572. `Did you reference the function correctly?`);
  6573. }
  6574. }
  6575. }
  6576. if (!asMixin) {
  6577. if (deferredData.length) {
  6578. deferredData.forEach(dataFn => resolveData(instance, dataFn, publicThis));
  6579. }
  6580. if (dataOptions) {
  6581. resolveData(instance, dataOptions, publicThis);
  6582. }
  6583. {
  6584. const rawData = toRaw(instance.data);
  6585. for (const key in rawData) {
  6586. checkDuplicateProperties("Data" /* DATA */, key);
  6587. // expose data on ctx during dev
  6588. if (key[0] !== '$' && key[0] !== '_') {
  6589. Object.defineProperty(ctx, key, {
  6590. configurable: true,
  6591. enumerable: true,
  6592. get: () => rawData[key],
  6593. set: NOOP
  6594. });
  6595. }
  6596. }
  6597. }
  6598. }
  6599. else if (dataOptions) {
  6600. deferredData.push(dataOptions);
  6601. }
  6602. if (computedOptions) {
  6603. for (const key in computedOptions) {
  6604. const opt = computedOptions[key];
  6605. const get = isFunction(opt)
  6606. ? opt.bind(publicThis, publicThis)
  6607. : isFunction(opt.get)
  6608. ? opt.get.bind(publicThis, publicThis)
  6609. : NOOP;
  6610. if ( get === NOOP) {
  6611. warn(`Computed property "${key}" has no getter.`);
  6612. }
  6613. const set = !isFunction(opt) && isFunction(opt.set)
  6614. ? opt.set.bind(publicThis)
  6615. : () => {
  6616. warn(`Write operation failed: computed property "${key}" is readonly.`);
  6617. }
  6618. ;
  6619. const c = computed$1({
  6620. get,
  6621. set
  6622. });
  6623. Object.defineProperty(ctx, key, {
  6624. enumerable: true,
  6625. configurable: true,
  6626. get: () => c.value,
  6627. set: v => (c.value = v)
  6628. });
  6629. {
  6630. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  6631. }
  6632. }
  6633. }
  6634. if (watchOptions) {
  6635. deferredWatch.push(watchOptions);
  6636. }
  6637. if (!asMixin && deferredWatch.length) {
  6638. deferredWatch.forEach(watchOptions => {
  6639. for (const key in watchOptions) {
  6640. createWatcher(watchOptions[key], ctx, publicThis, key);
  6641. }
  6642. });
  6643. }
  6644. if (provideOptions) {
  6645. const provides = isFunction(provideOptions)
  6646. ? provideOptions.call(publicThis)
  6647. : provideOptions;
  6648. for (const key in provides) {
  6649. provide(key, provides[key]);
  6650. }
  6651. }
  6652. // asset options.
  6653. // To reduce memory usage, only components with mixins or extends will have
  6654. // resolved asset registry attached to instance.
  6655. if (asMixin) {
  6656. if (components) {
  6657. extend(instance.components ||
  6658. (instance.components = extend({}, instance.type.components)), components);
  6659. }
  6660. if (directives) {
  6661. extend(instance.directives ||
  6662. (instance.directives = extend({}, instance.type.directives)), directives);
  6663. }
  6664. }
  6665. // lifecycle options
  6666. if (!asMixin) {
  6667. callSyncHook('created', options, publicThis, globalMixins);
  6668. }
  6669. if (beforeMount) {
  6670. onBeforeMount(beforeMount.bind(publicThis));
  6671. }
  6672. if (mounted) {
  6673. onMounted(mounted.bind(publicThis));
  6674. }
  6675. if (beforeUpdate) {
  6676. onBeforeUpdate(beforeUpdate.bind(publicThis));
  6677. }
  6678. if (updated) {
  6679. onUpdated(updated.bind(publicThis));
  6680. }
  6681. if (activated) {
  6682. onActivated(activated.bind(publicThis));
  6683. }
  6684. if (deactivated) {
  6685. onDeactivated(deactivated.bind(publicThis));
  6686. }
  6687. if (errorCaptured) {
  6688. onErrorCaptured(errorCaptured.bind(publicThis));
  6689. }
  6690. if (renderTracked) {
  6691. onRenderTracked(renderTracked.bind(publicThis));
  6692. }
  6693. if (renderTriggered) {
  6694. onRenderTriggered(renderTriggered.bind(publicThis));
  6695. }
  6696. if ( beforeDestroy) {
  6697. warn(`\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`);
  6698. }
  6699. if (beforeUnmount) {
  6700. onBeforeUnmount(beforeUnmount.bind(publicThis));
  6701. }
  6702. if ( destroyed) {
  6703. warn(`\`destroyed\` has been renamed to \`unmounted\`.`);
  6704. }
  6705. if (unmounted) {
  6706. onUnmounted(unmounted.bind(publicThis));
  6707. }
  6708. }
  6709. function callSyncHook(name, options, ctx, globalMixins) {
  6710. callHookFromMixins(name, globalMixins, ctx);
  6711. const { extends: base, mixins } = options;
  6712. if (base) {
  6713. callHookFromExtends(name, base, ctx);
  6714. }
  6715. if (mixins) {
  6716. callHookFromMixins(name, mixins, ctx);
  6717. }
  6718. const selfHook = options[name];
  6719. if (selfHook) {
  6720. selfHook.call(ctx);
  6721. }
  6722. }
  6723. function callHookFromExtends(name, base, ctx) {
  6724. if (base.extends) {
  6725. callHookFromExtends(name, base.extends, ctx);
  6726. }
  6727. const baseHook = base[name];
  6728. if (baseHook) {
  6729. baseHook.call(ctx);
  6730. }
  6731. }
  6732. function callHookFromMixins(name, mixins, ctx) {
  6733. for (let i = 0; i < mixins.length; i++) {
  6734. const chainedMixins = mixins[i].mixins;
  6735. if (chainedMixins) {
  6736. callHookFromMixins(name, chainedMixins, ctx);
  6737. }
  6738. const fn = mixins[i][name];
  6739. if (fn) {
  6740. fn.call(ctx);
  6741. }
  6742. }
  6743. }
  6744. function applyMixins(instance, mixins, deferredData, deferredWatch) {
  6745. for (let i = 0; i < mixins.length; i++) {
  6746. applyOptions(instance, mixins[i], deferredData, deferredWatch, true);
  6747. }
  6748. }
  6749. function resolveData(instance, dataFn, publicThis) {
  6750. if ( !isFunction(dataFn)) {
  6751. warn(`The data option must be a function. ` +
  6752. `Plain object usage is no longer supported.`);
  6753. }
  6754. const data = dataFn.call(publicThis, publicThis);
  6755. if ( isPromise(data)) {
  6756. warn(`data() returned a Promise - note data() cannot be async; If you ` +
  6757. `intend to perform data fetching before component renders, use ` +
  6758. `async setup() + <Suspense>.`);
  6759. }
  6760. if (!isObject(data)) {
  6761. warn(`data() should return an object.`);
  6762. }
  6763. else if (instance.data === EMPTY_OBJ) {
  6764. instance.data = reactive(data);
  6765. }
  6766. else {
  6767. // existing data: this is a mixin or extends.
  6768. extend(instance.data, data);
  6769. }
  6770. }
  6771. function createWatcher(raw, ctx, publicThis, key) {
  6772. const getter = key.includes('.')
  6773. ? createPathGetter(publicThis, key)
  6774. : () => publicThis[key];
  6775. if (isString(raw)) {
  6776. const handler = ctx[raw];
  6777. if (isFunction(handler)) {
  6778. watch(getter, handler);
  6779. }
  6780. else {
  6781. warn(`Invalid watch handler specified by key "${raw}"`, handler);
  6782. }
  6783. }
  6784. else if (isFunction(raw)) {
  6785. watch(getter, raw.bind(publicThis));
  6786. }
  6787. else if (isObject(raw)) {
  6788. if (isArray(raw)) {
  6789. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  6790. }
  6791. else {
  6792. const handler = isFunction(raw.handler)
  6793. ? raw.handler.bind(publicThis)
  6794. : ctx[raw.handler];
  6795. if (isFunction(handler)) {
  6796. watch(getter, handler, raw);
  6797. }
  6798. else {
  6799. warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  6800. }
  6801. }
  6802. }
  6803. else {
  6804. warn(`Invalid watch option: "${key}"`, raw);
  6805. }
  6806. }
  6807. function createPathGetter(ctx, path) {
  6808. const segments = path.split('.');
  6809. return () => {
  6810. let cur = ctx;
  6811. for (let i = 0; i < segments.length && cur; i++) {
  6812. cur = cur[segments[i]];
  6813. }
  6814. return cur;
  6815. };
  6816. }
  6817. function resolveMergedOptions(instance) {
  6818. const raw = instance.type;
  6819. const { __merged, mixins, extends: extendsOptions } = raw;
  6820. if (__merged)
  6821. return __merged;
  6822. const globalMixins = instance.appContext.mixins;
  6823. if (!globalMixins.length && !mixins && !extendsOptions)
  6824. return raw;
  6825. const options = {};
  6826. globalMixins.forEach(m => mergeOptions(options, m, instance));
  6827. mergeOptions(options, raw, instance);
  6828. return (raw.__merged = options);
  6829. }
  6830. function mergeOptions(to, from, instance) {
  6831. const strats = instance.appContext.config.optionMergeStrategies;
  6832. const { mixins, extends: extendsOptions } = from;
  6833. extendsOptions && mergeOptions(to, extendsOptions, instance);
  6834. mixins &&
  6835. mixins.forEach((m) => mergeOptions(to, m, instance));
  6836. for (const key in from) {
  6837. if (strats && hasOwn(strats, key)) {
  6838. to[key] = strats[key](to[key], from[key], instance.proxy, key);
  6839. }
  6840. else {
  6841. to[key] = from[key];
  6842. }
  6843. }
  6844. }
  6845. const publicPropertiesMap = extend(Object.create(null), {
  6846. $: i => i,
  6847. $el: i => i.vnode.el,
  6848. $data: i => i.data,
  6849. $props: i => ( shallowReadonly(i.props) ),
  6850. $attrs: i => ( shallowReadonly(i.attrs) ),
  6851. $slots: i => ( shallowReadonly(i.slots) ),
  6852. $refs: i => ( shallowReadonly(i.refs) ),
  6853. $parent: i => i.parent && i.parent.proxy,
  6854. $root: i => i.root && i.root.proxy,
  6855. $emit: i => i.emit,
  6856. $options: i => ( resolveMergedOptions(i) ),
  6857. $forceUpdate: i => () => queueJob(i.update),
  6858. $nextTick: () => nextTick,
  6859. $watch: i => ( instanceWatch.bind(i) )
  6860. });
  6861. const PublicInstanceProxyHandlers = {
  6862. get({ _: instance }, key) {
  6863. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  6864. // let @vue/reactivity know it should never observe Vue public instances.
  6865. if (key === "__v_skip" /* SKIP */) {
  6866. return true;
  6867. }
  6868. // data / props / ctx
  6869. // This getter gets called for every property access on the render context
  6870. // during render and is a major hotspot. The most expensive part of this
  6871. // is the multiple hasOwn() calls. It's much faster to do a simple property
  6872. // access on a plain object, so we use an accessCache object (with null
  6873. // prototype) to memoize what access type a key corresponds to.
  6874. let normalizedProps;
  6875. if (key[0] !== '$') {
  6876. const n = accessCache[key];
  6877. if (n !== undefined) {
  6878. switch (n) {
  6879. case 0 /* SETUP */:
  6880. return setupState[key];
  6881. case 1 /* DATA */:
  6882. return data[key];
  6883. case 3 /* CONTEXT */:
  6884. return ctx[key];
  6885. case 2 /* PROPS */:
  6886. return props[key];
  6887. // default: just fallthrough
  6888. }
  6889. }
  6890. else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  6891. accessCache[key] = 0 /* SETUP */;
  6892. return setupState[key];
  6893. }
  6894. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  6895. accessCache[key] = 1 /* DATA */;
  6896. return data[key];
  6897. }
  6898. else if (
  6899. // only cache other properties when instance has declared (thus stable)
  6900. // props
  6901. (normalizedProps = instance.propsOptions[0]) &&
  6902. hasOwn(normalizedProps, key)) {
  6903. accessCache[key] = 2 /* PROPS */;
  6904. return props[key];
  6905. }
  6906. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  6907. accessCache[key] = 3 /* CONTEXT */;
  6908. return ctx[key];
  6909. }
  6910. else if ( !isInBeforeCreate) {
  6911. accessCache[key] = 4 /* OTHER */;
  6912. }
  6913. }
  6914. const publicGetter = publicPropertiesMap[key];
  6915. let cssModule, globalProperties;
  6916. // public $xxx properties
  6917. if (publicGetter) {
  6918. if (key === '$attrs') {
  6919. track(instance, "get" /* GET */, key);
  6920. markAttrsAccessed();
  6921. }
  6922. return publicGetter(instance);
  6923. }
  6924. else if (
  6925. // css module (injected by vue-loader)
  6926. (cssModule = type.__cssModules) &&
  6927. (cssModule = cssModule[key])) {
  6928. return cssModule;
  6929. }
  6930. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  6931. // user may set custom properties to `this` that start with `$`
  6932. accessCache[key] = 3 /* CONTEXT */;
  6933. return ctx[key];
  6934. }
  6935. else if (
  6936. // global properties
  6937. ((globalProperties = appContext.config.globalProperties),
  6938. hasOwn(globalProperties, key))) {
  6939. return globalProperties[key];
  6940. }
  6941. else if (
  6942. currentRenderingInstance &&
  6943. (!isString(key) ||
  6944. // #1091 avoid internal isRef/isVNode checks on component instance leading
  6945. // to infinite warning loop
  6946. key.indexOf('__v') !== 0)) {
  6947. if (data !== EMPTY_OBJ &&
  6948. (key[0] === '$' || key[0] === '_') &&
  6949. hasOwn(data, key)) {
  6950. warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  6951. `character ("$" or "_") and is not proxied on the render context.`);
  6952. }
  6953. else {
  6954. warn(`Property ${JSON.stringify(key)} was accessed during render ` +
  6955. `but is not defined on instance.`);
  6956. }
  6957. }
  6958. },
  6959. set({ _: instance }, key, value) {
  6960. const { data, setupState, ctx } = instance;
  6961. if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  6962. setupState[key] = value;
  6963. }
  6964. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  6965. data[key] = value;
  6966. }
  6967. else if (key in instance.props) {
  6968. warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  6969. return false;
  6970. }
  6971. if (key[0] === '$' && key.slice(1) in instance) {
  6972. warn(`Attempting to mutate public property "${key}". ` +
  6973. `Properties starting with $ are reserved and readonly.`, instance);
  6974. return false;
  6975. }
  6976. else {
  6977. if ( key in instance.appContext.config.globalProperties) {
  6978. Object.defineProperty(ctx, key, {
  6979. enumerable: true,
  6980. configurable: true,
  6981. value
  6982. });
  6983. }
  6984. else {
  6985. ctx[key] = value;
  6986. }
  6987. }
  6988. return true;
  6989. },
  6990. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  6991. let normalizedProps;
  6992. return (accessCache[key] !== undefined ||
  6993. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  6994. (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
  6995. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  6996. hasOwn(ctx, key) ||
  6997. hasOwn(publicPropertiesMap, key) ||
  6998. hasOwn(appContext.config.globalProperties, key));
  6999. }
  7000. };
  7001. {
  7002. PublicInstanceProxyHandlers.ownKeys = (target) => {
  7003. warn(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  7004. `The keys will be empty in production mode to avoid performance overhead.`);
  7005. return Reflect.ownKeys(target);
  7006. };
  7007. }
  7008. const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, {
  7009. get(target, key) {
  7010. // fast path for unscopables when using `with` block
  7011. if (key === Symbol.unscopables) {
  7012. return;
  7013. }
  7014. return PublicInstanceProxyHandlers.get(target, key, target);
  7015. },
  7016. has(_, key) {
  7017. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  7018. if ( !has && PublicInstanceProxyHandlers.has(_, key)) {
  7019. warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  7020. }
  7021. return has;
  7022. }
  7023. });
  7024. // In dev mode, the proxy target exposes the same properties as seen on `this`
  7025. // for easier console inspection. In prod mode it will be an empty object so
  7026. // these properties definitions can be skipped.
  7027. function createRenderContext(instance) {
  7028. const target = {};
  7029. // expose internal instance for proxy handlers
  7030. Object.defineProperty(target, `_`, {
  7031. configurable: true,
  7032. enumerable: false,
  7033. get: () => instance
  7034. });
  7035. // expose public properties
  7036. Object.keys(publicPropertiesMap).forEach(key => {
  7037. Object.defineProperty(target, key, {
  7038. configurable: true,
  7039. enumerable: false,
  7040. get: () => publicPropertiesMap[key](instance),
  7041. // intercepted by the proxy so no need for implementation,
  7042. // but needed to prevent set errors
  7043. set: NOOP
  7044. });
  7045. });
  7046. // expose global properties
  7047. const { globalProperties } = instance.appContext.config;
  7048. Object.keys(globalProperties).forEach(key => {
  7049. Object.defineProperty(target, key, {
  7050. configurable: true,
  7051. enumerable: false,
  7052. get: () => globalProperties[key],
  7053. set: NOOP
  7054. });
  7055. });
  7056. return target;
  7057. }
  7058. // dev only
  7059. function exposePropsOnRenderContext(instance) {
  7060. const { ctx, propsOptions: [propsOptions] } = instance;
  7061. if (propsOptions) {
  7062. Object.keys(propsOptions).forEach(key => {
  7063. Object.defineProperty(ctx, key, {
  7064. enumerable: true,
  7065. configurable: true,
  7066. get: () => instance.props[key],
  7067. set: NOOP
  7068. });
  7069. });
  7070. }
  7071. }
  7072. // dev only
  7073. function exposeSetupStateOnRenderContext(instance) {
  7074. const { ctx, setupState } = instance;
  7075. Object.keys(toRaw(setupState)).forEach(key => {
  7076. if (key[0] === '$' || key[0] === '_') {
  7077. warn(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  7078. `which are reserved prefixes for Vue internals.`);
  7079. return;
  7080. }
  7081. Object.defineProperty(ctx, key, {
  7082. enumerable: true,
  7083. configurable: true,
  7084. get: () => setupState[key],
  7085. set: NOOP
  7086. });
  7087. });
  7088. }
  7089. const emptyAppContext = createAppContext();
  7090. let uid$2 = 0;
  7091. function createComponentInstance(vnode, parent, suspense) {
  7092. const type = vnode.type;
  7093. // inherit parent app context - or - if root, adopt from root vnode
  7094. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  7095. const instance = {
  7096. uid: uid$2++,
  7097. vnode,
  7098. type,
  7099. parent,
  7100. appContext,
  7101. root: null,
  7102. next: null,
  7103. subTree: null,
  7104. update: null,
  7105. render: null,
  7106. proxy: null,
  7107. withProxy: null,
  7108. effects: null,
  7109. provides: parent ? parent.provides : Object.create(appContext.provides),
  7110. accessCache: null,
  7111. renderCache: [],
  7112. // local resovled assets
  7113. components: null,
  7114. directives: null,
  7115. // resolved props and emits options
  7116. propsOptions: normalizePropsOptions(type, appContext),
  7117. emitsOptions: normalizeEmitsOptions(type, appContext),
  7118. // emit
  7119. emit: null,
  7120. emitted: null,
  7121. // state
  7122. ctx: EMPTY_OBJ,
  7123. data: EMPTY_OBJ,
  7124. props: EMPTY_OBJ,
  7125. attrs: EMPTY_OBJ,
  7126. slots: EMPTY_OBJ,
  7127. refs: EMPTY_OBJ,
  7128. setupState: EMPTY_OBJ,
  7129. setupContext: null,
  7130. // suspense related
  7131. suspense,
  7132. suspenseId: suspense ? suspense.pendingId : 0,
  7133. asyncDep: null,
  7134. asyncResolved: false,
  7135. // lifecycle hooks
  7136. // not using enums here because it results in computed properties
  7137. isMounted: false,
  7138. isUnmounted: false,
  7139. isDeactivated: false,
  7140. bc: null,
  7141. c: null,
  7142. bm: null,
  7143. m: null,
  7144. bu: null,
  7145. u: null,
  7146. um: null,
  7147. bum: null,
  7148. da: null,
  7149. a: null,
  7150. rtg: null,
  7151. rtc: null,
  7152. ec: null
  7153. };
  7154. {
  7155. instance.ctx = createRenderContext(instance);
  7156. }
  7157. instance.root = parent ? parent.root : instance;
  7158. instance.emit = emit.bind(null, instance);
  7159. {
  7160. devtoolsComponentAdded(instance);
  7161. }
  7162. return instance;
  7163. }
  7164. let currentInstance = null;
  7165. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  7166. const setCurrentInstance = (instance) => {
  7167. currentInstance = instance;
  7168. };
  7169. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  7170. function validateComponentName(name, config) {
  7171. const appIsNativeTag = config.isNativeTag || NO;
  7172. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  7173. warn('Do not use built-in or reserved HTML elements as component id: ' + name);
  7174. }
  7175. }
  7176. let isInSSRComponentSetup = false;
  7177. function setupComponent(instance, isSSR = false) {
  7178. isInSSRComponentSetup = isSSR;
  7179. const { props, children, shapeFlag } = instance.vnode;
  7180. const isStateful = shapeFlag & 4 /* STATEFUL_COMPONENT */;
  7181. initProps(instance, props, isStateful, isSSR);
  7182. initSlots(instance, children);
  7183. const setupResult = isStateful
  7184. ? setupStatefulComponent(instance, isSSR)
  7185. : undefined;
  7186. isInSSRComponentSetup = false;
  7187. return setupResult;
  7188. }
  7189. function setupStatefulComponent(instance, isSSR) {
  7190. const Component = instance.type;
  7191. {
  7192. if (Component.name) {
  7193. validateComponentName(Component.name, instance.appContext.config);
  7194. }
  7195. if (Component.components) {
  7196. const names = Object.keys(Component.components);
  7197. for (let i = 0; i < names.length; i++) {
  7198. validateComponentName(names[i], instance.appContext.config);
  7199. }
  7200. }
  7201. if (Component.directives) {
  7202. const names = Object.keys(Component.directives);
  7203. for (let i = 0; i < names.length; i++) {
  7204. validateDirectiveName(names[i]);
  7205. }
  7206. }
  7207. }
  7208. // 0. create render proxy property access cache
  7209. instance.accessCache = {};
  7210. // 1. create public instance / render proxy
  7211. // also mark it raw so it's never observed
  7212. instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
  7213. {
  7214. exposePropsOnRenderContext(instance);
  7215. }
  7216. // 2. call setup()
  7217. const { setup } = Component;
  7218. if (setup) {
  7219. const setupContext = (instance.setupContext =
  7220. setup.length > 1 ? createSetupContext(instance) : null);
  7221. currentInstance = instance;
  7222. pauseTracking();
  7223. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [ shallowReadonly(instance.props) , setupContext]);
  7224. resetTracking();
  7225. currentInstance = null;
  7226. if (isPromise(setupResult)) {
  7227. if (isSSR) {
  7228. // return the promise so server-renderer can wait on it
  7229. return setupResult.then((resolvedResult) => {
  7230. handleSetupResult(instance, resolvedResult);
  7231. });
  7232. }
  7233. else {
  7234. // async setup returned Promise.
  7235. // bail here and wait for re-entry.
  7236. instance.asyncDep = setupResult;
  7237. }
  7238. }
  7239. else {
  7240. handleSetupResult(instance, setupResult);
  7241. }
  7242. }
  7243. else {
  7244. finishComponentSetup(instance);
  7245. }
  7246. }
  7247. function handleSetupResult(instance, setupResult, isSSR) {
  7248. if (isFunction(setupResult)) {
  7249. // setup returned an inline render function
  7250. instance.render = setupResult;
  7251. }
  7252. else if (isObject(setupResult)) {
  7253. if ( isVNode(setupResult)) {
  7254. warn(`setup() should not return VNodes directly - ` +
  7255. `return a render function instead.`);
  7256. }
  7257. // setup returned bindings.
  7258. // assuming a render function compiled from template is present.
  7259. {
  7260. instance.devtoolsRawSetupState = setupResult;
  7261. }
  7262. instance.setupState = proxyRefs(setupResult);
  7263. {
  7264. exposeSetupStateOnRenderContext(instance);
  7265. }
  7266. }
  7267. else if ( setupResult !== undefined) {
  7268. warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  7269. }
  7270. finishComponentSetup(instance);
  7271. }
  7272. let compile;
  7273. /**
  7274. * For runtime-dom to register the compiler.
  7275. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  7276. */
  7277. function registerRuntimeCompiler(_compile) {
  7278. compile = _compile;
  7279. }
  7280. function finishComponentSetup(instance, isSSR) {
  7281. const Component = instance.type;
  7282. // template / render function normalization
  7283. if (!instance.render) {
  7284. // could be set from setup()
  7285. if (compile && Component.template && !Component.render) {
  7286. {
  7287. startMeasure(instance, `compile`);
  7288. }
  7289. Component.render = compile(Component.template, {
  7290. isCustomElement: instance.appContext.config.isCustomElement,
  7291. delimiters: Component.delimiters
  7292. });
  7293. {
  7294. endMeasure(instance, `compile`);
  7295. }
  7296. }
  7297. instance.render = (Component.render || NOOP);
  7298. // for runtime-compiled render functions using `with` blocks, the render
  7299. // proxy used needs a different `has` handler which is more performant and
  7300. // also only allows a whitelist of globals to fallthrough.
  7301. if (instance.render._rc) {
  7302. instance.withProxy = new Proxy(instance.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  7303. }
  7304. }
  7305. // support for 2.x options
  7306. {
  7307. currentInstance = instance;
  7308. applyOptions(instance, Component);
  7309. currentInstance = null;
  7310. }
  7311. // warn missing template/render
  7312. if ( !Component.render && instance.render === NOOP) {
  7313. /* istanbul ignore if */
  7314. if (!compile && Component.template) {
  7315. warn(`Component provided template option but ` +
  7316. `runtime compilation is not supported in this build of Vue.` +
  7317. ( ` Use "vue.global.js" instead.`
  7318. ) /* should not happen */);
  7319. }
  7320. else {
  7321. warn(`Component is missing template or render function.`);
  7322. }
  7323. }
  7324. }
  7325. const attrHandlers = {
  7326. get: (target, key) => {
  7327. {
  7328. markAttrsAccessed();
  7329. }
  7330. return target[key];
  7331. },
  7332. set: () => {
  7333. warn(`setupContext.attrs is readonly.`);
  7334. return false;
  7335. },
  7336. deleteProperty: () => {
  7337. warn(`setupContext.attrs is readonly.`);
  7338. return false;
  7339. }
  7340. };
  7341. function createSetupContext(instance) {
  7342. {
  7343. // We use getters in dev in case libs like test-utils overwrite instance
  7344. // properties (overwrites should not be done in prod)
  7345. return Object.freeze({
  7346. get attrs() {
  7347. return new Proxy(instance.attrs, attrHandlers);
  7348. },
  7349. get slots() {
  7350. return shallowReadonly(instance.slots);
  7351. },
  7352. get emit() {
  7353. return (event, ...args) => instance.emit(event, ...args);
  7354. }
  7355. });
  7356. }
  7357. }
  7358. // record effects created during a component's setup() so that they can be
  7359. // stopped when the component unmounts
  7360. function recordInstanceBoundEffect(effect) {
  7361. if (currentInstance) {
  7362. (currentInstance.effects || (currentInstance.effects = [])).push(effect);
  7363. }
  7364. }
  7365. const classifyRE = /(?:^|[-_])(\w)/g;
  7366. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  7367. /* istanbul ignore next */
  7368. function formatComponentName(instance, Component, isRoot = false) {
  7369. let name = isFunction(Component)
  7370. ? Component.displayName || Component.name
  7371. : Component.name;
  7372. if (!name && Component.__file) {
  7373. const match = Component.__file.match(/([^/\\]+)\.vue$/);
  7374. if (match) {
  7375. name = match[1];
  7376. }
  7377. }
  7378. if (!name && instance && instance.parent) {
  7379. // try to infer the name based on reverse resolution
  7380. const inferFromRegistry = (registry) => {
  7381. for (const key in registry) {
  7382. if (registry[key] === Component) {
  7383. return key;
  7384. }
  7385. }
  7386. };
  7387. name =
  7388. inferFromRegistry(instance.components ||
  7389. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  7390. }
  7391. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  7392. }
  7393. function isClassComponent(value) {
  7394. return isFunction(value) && '__vccOpts' in value;
  7395. }
  7396. function computed$1(getterOrOptions) {
  7397. const c = computed(getterOrOptions);
  7398. recordInstanceBoundEffect(c.effect);
  7399. return c;
  7400. }
  7401. // implementation, close to no-op
  7402. function defineComponent(options) {
  7403. return isFunction(options) ? { setup: options, name: options.name } : options;
  7404. }
  7405. function defineAsyncComponent(source) {
  7406. if (isFunction(source)) {
  7407. source = { loader: source };
  7408. }
  7409. const { loader, loadingComponent: loadingComponent, errorComponent: errorComponent, delay = 200, timeout, // undefined = never times out
  7410. suspensible = true, onError: userOnError } = source;
  7411. let pendingRequest = null;
  7412. let resolvedComp;
  7413. let retries = 0;
  7414. const retry = () => {
  7415. retries++;
  7416. pendingRequest = null;
  7417. return load();
  7418. };
  7419. const load = () => {
  7420. let thisRequest;
  7421. return (pendingRequest ||
  7422. (thisRequest = pendingRequest = loader()
  7423. .catch(err => {
  7424. err = err instanceof Error ? err : new Error(String(err));
  7425. if (userOnError) {
  7426. return new Promise((resolve, reject) => {
  7427. const userRetry = () => resolve(retry());
  7428. const userFail = () => reject(err);
  7429. userOnError(err, userRetry, userFail, retries + 1);
  7430. });
  7431. }
  7432. else {
  7433. throw err;
  7434. }
  7435. })
  7436. .then((comp) => {
  7437. if (thisRequest !== pendingRequest && pendingRequest) {
  7438. return pendingRequest;
  7439. }
  7440. if ( !comp) {
  7441. warn(`Async component loader resolved to undefined. ` +
  7442. `If you are using retry(), make sure to return its return value.`);
  7443. }
  7444. // interop module default
  7445. if (comp &&
  7446. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  7447. comp = comp.default;
  7448. }
  7449. if ( comp && !isObject(comp) && !isFunction(comp)) {
  7450. throw new Error(`Invalid async component load result: ${comp}`);
  7451. }
  7452. resolvedComp = comp;
  7453. return comp;
  7454. })));
  7455. };
  7456. return defineComponent({
  7457. __asyncLoader: load,
  7458. name: 'AsyncComponentWrapper',
  7459. setup() {
  7460. const instance = currentInstance;
  7461. // already resolved
  7462. if (resolvedComp) {
  7463. return () => createInnerComp(resolvedComp, instance);
  7464. }
  7465. const onError = (err) => {
  7466. pendingRequest = null;
  7467. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  7468. };
  7469. // suspense-controlled or SSR.
  7470. if (( suspensible && instance.suspense) ||
  7471. (false )) {
  7472. return load()
  7473. .then(comp => {
  7474. return () => createInnerComp(comp, instance);
  7475. })
  7476. .catch(err => {
  7477. onError(err);
  7478. return () => errorComponent
  7479. ? createVNode(errorComponent, {
  7480. error: err
  7481. })
  7482. : null;
  7483. });
  7484. }
  7485. const loaded = ref(false);
  7486. const error = ref();
  7487. const delayed = ref(!!delay);
  7488. if (delay) {
  7489. setTimeout(() => {
  7490. delayed.value = false;
  7491. }, delay);
  7492. }
  7493. if (timeout != null) {
  7494. setTimeout(() => {
  7495. if (!loaded.value && !error.value) {
  7496. const err = new Error(`Async component timed out after ${timeout}ms.`);
  7497. onError(err);
  7498. error.value = err;
  7499. }
  7500. }, timeout);
  7501. }
  7502. load()
  7503. .then(() => {
  7504. loaded.value = true;
  7505. })
  7506. .catch(err => {
  7507. onError(err);
  7508. error.value = err;
  7509. });
  7510. return () => {
  7511. if (loaded.value && resolvedComp) {
  7512. return createInnerComp(resolvedComp, instance);
  7513. }
  7514. else if (error.value && errorComponent) {
  7515. return createVNode(errorComponent, {
  7516. error: error.value
  7517. });
  7518. }
  7519. else if (loadingComponent && !delayed.value) {
  7520. return createVNode(loadingComponent);
  7521. }
  7522. };
  7523. }
  7524. });
  7525. }
  7526. function createInnerComp(comp, { vnode: { props, children } }) {
  7527. return createVNode(comp, props, children);
  7528. }
  7529. // Actual implementation
  7530. function h(type, propsOrChildren, children) {
  7531. const l = arguments.length;
  7532. if (l === 2) {
  7533. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  7534. // single vnode without props
  7535. if (isVNode(propsOrChildren)) {
  7536. return createVNode(type, null, [propsOrChildren]);
  7537. }
  7538. // props without children
  7539. return createVNode(type, propsOrChildren);
  7540. }
  7541. else {
  7542. // omit props
  7543. return createVNode(type, null, propsOrChildren);
  7544. }
  7545. }
  7546. else {
  7547. if (l > 3) {
  7548. children = Array.prototype.slice.call(arguments, 2);
  7549. }
  7550. else if (l === 3 && isVNode(children)) {
  7551. children = [children];
  7552. }
  7553. return createVNode(type, propsOrChildren, children);
  7554. }
  7555. }
  7556. const ssrContextKey = Symbol( `ssrContext` );
  7557. const useSSRContext = () => {
  7558. {
  7559. warn(`useSsrContext() is not supported in the global build.`);
  7560. }
  7561. };
  7562. /**
  7563. * Actual implementation
  7564. */
  7565. function renderList(source, renderItem) {
  7566. let ret;
  7567. if (isArray(source) || isString(source)) {
  7568. ret = new Array(source.length);
  7569. for (let i = 0, l = source.length; i < l; i++) {
  7570. ret[i] = renderItem(source[i], i);
  7571. }
  7572. }
  7573. else if (typeof source === 'number') {
  7574. ret = new Array(source);
  7575. for (let i = 0; i < source; i++) {
  7576. ret[i] = renderItem(i + 1, i);
  7577. }
  7578. }
  7579. else if (isObject(source)) {
  7580. if (source[Symbol.iterator]) {
  7581. ret = Array.from(source, renderItem);
  7582. }
  7583. else {
  7584. const keys = Object.keys(source);
  7585. ret = new Array(keys.length);
  7586. for (let i = 0, l = keys.length; i < l; i++) {
  7587. const key = keys[i];
  7588. ret[i] = renderItem(source[key], key, i);
  7589. }
  7590. }
  7591. }
  7592. else {
  7593. ret = [];
  7594. }
  7595. return ret;
  7596. }
  7597. /**
  7598. * For prefixing keys in v-on="obj" with "on"
  7599. * @private
  7600. */
  7601. function toHandlers(obj) {
  7602. const ret = {};
  7603. if ( !isObject(obj)) {
  7604. warn(`v-on with no argument expects an object value.`);
  7605. return ret;
  7606. }
  7607. for (const key in obj) {
  7608. ret[`on${capitalize(key)}`] = obj[key];
  7609. }
  7610. return ret;
  7611. }
  7612. /**
  7613. * Compiler runtime helper for creating dynamic slots object
  7614. * @private
  7615. */
  7616. function createSlots(slots, dynamicSlots) {
  7617. for (let i = 0; i < dynamicSlots.length; i++) {
  7618. const slot = dynamicSlots[i];
  7619. // array of dynamic slot generated by <template v-for="..." #[...]>
  7620. if (isArray(slot)) {
  7621. for (let j = 0; j < slot.length; j++) {
  7622. slots[slot[j].name] = slot[j].fn;
  7623. }
  7624. }
  7625. else if (slot) {
  7626. // conditional single slot generated by <template v-if="..." #foo>
  7627. slots[slot.name] = slot.fn;
  7628. }
  7629. }
  7630. return slots;
  7631. }
  7632. // Core API ------------------------------------------------------------------
  7633. const version = "3.0.0";
  7634. /**
  7635. * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
  7636. * @internal
  7637. */
  7638. const ssrUtils = ( null);
  7639. const svgNS = 'http://www.w3.org/2000/svg';
  7640. const doc = (typeof document !== 'undefined' ? document : null);
  7641. let tempContainer;
  7642. let tempSVGContainer;
  7643. const nodeOps = {
  7644. insert: (child, parent, anchor) => {
  7645. parent.insertBefore(child, anchor || null);
  7646. },
  7647. remove: child => {
  7648. const parent = child.parentNode;
  7649. if (parent) {
  7650. parent.removeChild(child);
  7651. }
  7652. },
  7653. createElement: (tag, isSVG, is) => isSVG
  7654. ? doc.createElementNS(svgNS, tag)
  7655. : doc.createElement(tag, is ? { is } : undefined),
  7656. createText: text => doc.createTextNode(text),
  7657. createComment: text => doc.createComment(text),
  7658. setText: (node, text) => {
  7659. node.nodeValue = text;
  7660. },
  7661. setElementText: (el, text) => {
  7662. el.textContent = text;
  7663. },
  7664. parentNode: node => node.parentNode,
  7665. nextSibling: node => node.nextSibling,
  7666. querySelector: selector => doc.querySelector(selector),
  7667. setScopeId(el, id) {
  7668. el.setAttribute(id, '');
  7669. },
  7670. cloneNode(el) {
  7671. return el.cloneNode(true);
  7672. },
  7673. // __UNSAFE__
  7674. // Reason: innerHTML.
  7675. // Static content here can only come from compiled templates.
  7676. // As long as the user only uses trusted templates, this is safe.
  7677. insertStaticContent(content, parent, anchor, isSVG) {
  7678. const temp = isSVG
  7679. ? tempSVGContainer ||
  7680. (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
  7681. : tempContainer || (tempContainer = doc.createElement('div'));
  7682. temp.innerHTML = content;
  7683. const first = temp.firstChild;
  7684. let node = first;
  7685. let last = node;
  7686. while (node) {
  7687. last = node;
  7688. nodeOps.insert(node, parent, anchor);
  7689. node = temp.firstChild;
  7690. }
  7691. return [first, last];
  7692. }
  7693. };
  7694. // compiler should normalize class + :class bindings on the same element
  7695. // into a single binding ['staticClass', dynamic]
  7696. function patchClass(el, value, isSVG) {
  7697. if (value == null) {
  7698. value = '';
  7699. }
  7700. if (isSVG) {
  7701. el.setAttribute('class', value);
  7702. }
  7703. else {
  7704. // directly setting className should be faster than setAttribute in theory
  7705. // if this is an element during a transition, take the temporary transition
  7706. // classes into account.
  7707. const transitionClasses = el._vtc;
  7708. if (transitionClasses) {
  7709. value = (value
  7710. ? [value, ...transitionClasses]
  7711. : [...transitionClasses]).join(' ');
  7712. }
  7713. el.className = value;
  7714. }
  7715. }
  7716. function patchStyle(el, prev, next) {
  7717. const style = el.style;
  7718. if (!next) {
  7719. el.removeAttribute('style');
  7720. }
  7721. else if (isString(next)) {
  7722. if (prev !== next) {
  7723. style.cssText = next;
  7724. }
  7725. }
  7726. else {
  7727. for (const key in next) {
  7728. setStyle(style, key, next[key]);
  7729. }
  7730. if (prev && !isString(prev)) {
  7731. for (const key in prev) {
  7732. if (next[key] == null) {
  7733. setStyle(style, key, '');
  7734. }
  7735. }
  7736. }
  7737. }
  7738. }
  7739. const importantRE = /\s*!important$/;
  7740. function setStyle(style, name, val) {
  7741. if (isArray(val)) {
  7742. val.forEach(v => setStyle(style, name, v));
  7743. }
  7744. else {
  7745. if (name.startsWith('--')) {
  7746. // custom property definition
  7747. style.setProperty(name, val);
  7748. }
  7749. else {
  7750. const prefixed = autoPrefix(style, name);
  7751. if (importantRE.test(val)) {
  7752. // !important
  7753. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  7754. }
  7755. else {
  7756. style[prefixed] = val;
  7757. }
  7758. }
  7759. }
  7760. }
  7761. const prefixes = ['Webkit', 'Moz', 'ms'];
  7762. const prefixCache = {};
  7763. function autoPrefix(style, rawName) {
  7764. const cached = prefixCache[rawName];
  7765. if (cached) {
  7766. return cached;
  7767. }
  7768. let name = camelize(rawName);
  7769. if (name !== 'filter' && name in style) {
  7770. return (prefixCache[rawName] = name);
  7771. }
  7772. name = capitalize(name);
  7773. for (let i = 0; i < prefixes.length; i++) {
  7774. const prefixed = prefixes[i] + name;
  7775. if (prefixed in style) {
  7776. return (prefixCache[rawName] = prefixed);
  7777. }
  7778. }
  7779. return rawName;
  7780. }
  7781. const xlinkNS = 'http://www.w3.org/1999/xlink';
  7782. function patchAttr(el, key, value, isSVG) {
  7783. if (isSVG && key.startsWith('xlink:')) {
  7784. if (value == null) {
  7785. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  7786. }
  7787. else {
  7788. el.setAttributeNS(xlinkNS, key, value);
  7789. }
  7790. }
  7791. else {
  7792. // note we are only checking boolean attributes that don't have a
  7793. // corresponding dom prop of the same name here.
  7794. const isBoolean = isSpecialBooleanAttr(key);
  7795. if (value == null || (isBoolean && value === false)) {
  7796. el.removeAttribute(key);
  7797. }
  7798. else {
  7799. el.setAttribute(key, isBoolean ? '' : value);
  7800. }
  7801. }
  7802. }
  7803. // __UNSAFE__
  7804. // functions. The user is responsible for using them with only trusted content.
  7805. function patchDOMProp(el, key, value,
  7806. // the following args are passed only due to potential innerHTML/textContent
  7807. // overriding existing VNodes, in which case the old tree must be properly
  7808. // unmounted.
  7809. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  7810. if (key === 'innerHTML' || key === 'textContent') {
  7811. if (prevChildren) {
  7812. unmountChildren(prevChildren, parentComponent, parentSuspense);
  7813. }
  7814. el[key] = value == null ? '' : value;
  7815. return;
  7816. }
  7817. if (key === 'value' && el.tagName !== 'PROGRESS') {
  7818. // store value as _value as well since
  7819. // non-string values will be stringified.
  7820. el._value = value;
  7821. const newValue = value == null ? '' : value;
  7822. if (el.value !== newValue) {
  7823. el.value = newValue;
  7824. }
  7825. return;
  7826. }
  7827. if (value === '' && typeof el[key] === 'boolean') {
  7828. // e.g. <select multiple> compiles to { multiple: '' }
  7829. el[key] = true;
  7830. }
  7831. else if (value == null && typeof el[key] === 'string') {
  7832. // e.g. <div :id="null">
  7833. el[key] = '';
  7834. el.removeAttribute(key);
  7835. }
  7836. else {
  7837. // some properties perform value validation and throw
  7838. try {
  7839. el[key] = value;
  7840. }
  7841. catch (e) {
  7842. {
  7843. warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  7844. `value ${value} is invalid.`, e);
  7845. }
  7846. }
  7847. }
  7848. }
  7849. // Async edge case fix requires storing an event listener's attach timestamp.
  7850. let _getNow = Date.now;
  7851. // Determine what event timestamp the browser is using. Annoyingly, the
  7852. // timestamp can either be hi-res (relative to page load) or low-res
  7853. // (relative to UNIX epoch), so in order to compare time we have to use the
  7854. // same timestamp type when saving the flush timestamp.
  7855. if (typeof document !== 'undefined' &&
  7856. _getNow() > document.createEvent('Event').timeStamp) {
  7857. // if the low-res timestamp which is bigger than the event timestamp
  7858. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  7859. // and we need to use the hi-res version for event listeners as well.
  7860. _getNow = () => performance.now();
  7861. }
  7862. // To avoid the overhead of repeatedly calling performance.now(), we cache
  7863. // and use the same timestamp for all event listeners attached in the same tick.
  7864. let cachedNow = 0;
  7865. const p = Promise.resolve();
  7866. const reset = () => {
  7867. cachedNow = 0;
  7868. };
  7869. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  7870. function addEventListener(el, event, handler, options) {
  7871. el.addEventListener(event, handler, options);
  7872. }
  7873. function removeEventListener(el, event, handler, options) {
  7874. el.removeEventListener(event, handler, options);
  7875. }
  7876. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  7877. // vei = vue event invokers
  7878. const invokers = el._vei || (el._vei = {});
  7879. const existingInvoker = invokers[rawName];
  7880. if (nextValue && existingInvoker) {
  7881. // patch
  7882. existingInvoker.value = nextValue;
  7883. }
  7884. else {
  7885. const [name, options] = parseName(rawName);
  7886. if (nextValue) {
  7887. // add
  7888. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  7889. addEventListener(el, name, invoker, options);
  7890. }
  7891. else if (existingInvoker) {
  7892. // remove
  7893. removeEventListener(el, name, existingInvoker, options);
  7894. invokers[rawName] = undefined;
  7895. }
  7896. }
  7897. }
  7898. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  7899. function parseName(name) {
  7900. let options;
  7901. if (optionsModifierRE.test(name)) {
  7902. options = {};
  7903. let m;
  7904. while ((m = name.match(optionsModifierRE))) {
  7905. name = name.slice(0, name.length - m[0].length);
  7906. options[m[0].toLowerCase()] = true;
  7907. }
  7908. }
  7909. return [name.slice(2).toLowerCase(), options];
  7910. }
  7911. function createInvoker(initialValue, instance) {
  7912. const invoker = (e) => {
  7913. // async edge case #6566: inner click event triggers patch, event handler
  7914. // attached to outer element during patch, and triggered again. This
  7915. // happens because browsers fire microtask ticks between event propagation.
  7916. // the solution is simple: we save the timestamp when a handler is attached,
  7917. // and the handler would only fire if the event passed to it was fired
  7918. // AFTER it was attached.
  7919. const timeStamp = e.timeStamp || _getNow();
  7920. if (timeStamp >= invoker.attached - 1) {
  7921. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  7922. }
  7923. };
  7924. invoker.value = initialValue;
  7925. invoker.attached = getNow();
  7926. return invoker;
  7927. }
  7928. function patchStopImmediatePropagation(e, value) {
  7929. if (isArray(value)) {
  7930. const originalStop = e.stopImmediatePropagation;
  7931. e.stopImmediatePropagation = () => {
  7932. originalStop.call(e);
  7933. e._stopped = true;
  7934. };
  7935. return value.map(fn => (e) => !e._stopped && fn(e));
  7936. }
  7937. else {
  7938. return value;
  7939. }
  7940. }
  7941. const nativeOnRE = /^on[a-z]/;
  7942. const forcePatchProp = (_, key) => key === 'value';
  7943. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  7944. switch (key) {
  7945. // special
  7946. case 'class':
  7947. patchClass(el, nextValue, isSVG);
  7948. break;
  7949. case 'style':
  7950. patchStyle(el, prevValue, nextValue);
  7951. break;
  7952. default:
  7953. if (isOn(key)) {
  7954. // ignore v-model listeners
  7955. if (!isModelListener(key)) {
  7956. patchEvent(el, key, prevValue, nextValue, parentComponent);
  7957. }
  7958. }
  7959. else if (shouldSetAsProp(el, key, nextValue, isSVG)) {
  7960. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  7961. }
  7962. else {
  7963. // special case for <input v-model type="checkbox"> with
  7964. // :true-value & :false-value
  7965. // store value as dom properties since non-string values will be
  7966. // stringified.
  7967. if (key === 'true-value') {
  7968. el._trueValue = nextValue;
  7969. }
  7970. else if (key === 'false-value') {
  7971. el._falseValue = nextValue;
  7972. }
  7973. patchAttr(el, key, nextValue, isSVG);
  7974. }
  7975. break;
  7976. }
  7977. };
  7978. function shouldSetAsProp(el, key, value, isSVG) {
  7979. if (isSVG) {
  7980. // most keys must be set as attribute on svg elements to work
  7981. // ...except innerHTML
  7982. if (key === 'innerHTML') {
  7983. return true;
  7984. }
  7985. // or native onclick with function values
  7986. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  7987. return true;
  7988. }
  7989. return false;
  7990. }
  7991. // spellcheck and draggable are numerated attrs, however their
  7992. // corresponding DOM properties are actually booleans - this leads to
  7993. // setting it with a string "false" value leading it to be coerced to
  7994. // `true`, so we need to always treat them as attributes.
  7995. // Note that `contentEditable` doesn't have this problem: its DOM
  7996. // property is also enumerated string values.
  7997. if (key === 'spellcheck' || key === 'draggable') {
  7998. return false;
  7999. }
  8000. // #1787 form as an attribute must be a string, while it accepts an Element as
  8001. // a prop
  8002. if (key === 'form' && typeof value === 'string') {
  8003. return false;
  8004. }
  8005. // #1526 <input list> must be set as attribute
  8006. if (key === 'list' && el.tagName === 'INPUT') {
  8007. return false;
  8008. }
  8009. // native onclick with string value, must be set as attribute
  8010. if (nativeOnRE.test(key) && isString(value)) {
  8011. return false;
  8012. }
  8013. return key in el;
  8014. }
  8015. function useCssModule(name = '$style') {
  8016. /* istanbul ignore else */
  8017. {
  8018. {
  8019. warn(`useCssModule() is not supported in the global build.`);
  8020. }
  8021. return EMPTY_OBJ;
  8022. }
  8023. }
  8024. function useCssVars(getter, scoped = false) {
  8025. const instance = getCurrentInstance();
  8026. /* istanbul ignore next */
  8027. if (!instance) {
  8028. warn(`useCssVars is called without current active component instance.`);
  8029. return;
  8030. }
  8031. const prefix = scoped && instance.type.__scopeId
  8032. ? `${instance.type.__scopeId.replace(/^data-v-/, '')}-`
  8033. : ``;
  8034. onMounted(() => {
  8035. watchEffect(() => {
  8036. setVarsOnVNode(instance.subTree, getter(instance.proxy), prefix);
  8037. });
  8038. });
  8039. }
  8040. function setVarsOnVNode(vnode, vars, prefix) {
  8041. if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
  8042. const suspense = vnode.suspense;
  8043. vnode = suspense.activeBranch;
  8044. if (suspense.pendingBranch && !suspense.isHydrating) {
  8045. suspense.effects.push(() => {
  8046. setVarsOnVNode(suspense.activeBranch, vars, prefix);
  8047. });
  8048. }
  8049. }
  8050. // drill down HOCs until it's a non-component vnode
  8051. while (vnode.component) {
  8052. vnode = vnode.component.subTree;
  8053. }
  8054. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  8055. const style = vnode.el.style;
  8056. for (const key in vars) {
  8057. style.setProperty(`--${prefix}${key}`, unref(vars[key]));
  8058. }
  8059. }
  8060. else if (vnode.type === Fragment) {
  8061. vnode.children.forEach(c => setVarsOnVNode(c, vars, prefix));
  8062. }
  8063. }
  8064. const TRANSITION = 'transition';
  8065. const ANIMATION = 'animation';
  8066. // DOM Transition is a higher-order-component based on the platform-agnostic
  8067. // base Transition component, with DOM-specific logic.
  8068. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  8069. Transition.displayName = 'Transition';
  8070. const DOMTransitionPropsValidators = {
  8071. name: String,
  8072. type: String,
  8073. css: {
  8074. type: Boolean,
  8075. default: true
  8076. },
  8077. duration: [String, Number, Object],
  8078. enterFromClass: String,
  8079. enterActiveClass: String,
  8080. enterToClass: String,
  8081. appearFromClass: String,
  8082. appearActiveClass: String,
  8083. appearToClass: String,
  8084. leaveFromClass: String,
  8085. leaveActiveClass: String,
  8086. leaveToClass: String
  8087. };
  8088. const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  8089. function resolveTransitionProps(rawProps) {
  8090. let { name = 'v', type, css = true, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
  8091. const baseProps = {};
  8092. for (const key in rawProps) {
  8093. if (!(key in DOMTransitionPropsValidators)) {
  8094. baseProps[key] = rawProps[key];
  8095. }
  8096. }
  8097. if (!css) {
  8098. return baseProps;
  8099. }
  8100. const durations = normalizeDuration(duration);
  8101. const enterDuration = durations && durations[0];
  8102. const leaveDuration = durations && durations[1];
  8103. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  8104. const finishEnter = (el, isAppear, done) => {
  8105. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  8106. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  8107. done && done();
  8108. };
  8109. const finishLeave = (el, done) => {
  8110. removeTransitionClass(el, leaveToClass);
  8111. removeTransitionClass(el, leaveActiveClass);
  8112. done && done();
  8113. };
  8114. const makeEnterHook = (isAppear) => {
  8115. return (el, done) => {
  8116. const hook = isAppear ? onAppear : onEnter;
  8117. const resolve = () => finishEnter(el, isAppear, done);
  8118. hook && hook(el, resolve);
  8119. nextFrame(() => {
  8120. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  8121. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  8122. if (!(hook && hook.length > 1)) {
  8123. if (enterDuration) {
  8124. setTimeout(resolve, enterDuration);
  8125. }
  8126. else {
  8127. whenTransitionEnds(el, type, resolve);
  8128. }
  8129. }
  8130. });
  8131. };
  8132. };
  8133. return extend(baseProps, {
  8134. onBeforeEnter(el) {
  8135. onBeforeEnter && onBeforeEnter(el);
  8136. addTransitionClass(el, enterActiveClass);
  8137. addTransitionClass(el, enterFromClass);
  8138. },
  8139. onBeforeAppear(el) {
  8140. onBeforeAppear && onBeforeAppear(el);
  8141. addTransitionClass(el, appearActiveClass);
  8142. addTransitionClass(el, appearFromClass);
  8143. },
  8144. onEnter: makeEnterHook(false),
  8145. onAppear: makeEnterHook(true),
  8146. onLeave(el, done) {
  8147. const resolve = () => finishLeave(el, done);
  8148. addTransitionClass(el, leaveActiveClass);
  8149. addTransitionClass(el, leaveFromClass);
  8150. nextFrame(() => {
  8151. removeTransitionClass(el, leaveFromClass);
  8152. addTransitionClass(el, leaveToClass);
  8153. if (!(onLeave && onLeave.length > 1)) {
  8154. if (leaveDuration) {
  8155. setTimeout(resolve, leaveDuration);
  8156. }
  8157. else {
  8158. whenTransitionEnds(el, type, resolve);
  8159. }
  8160. }
  8161. });
  8162. onLeave && onLeave(el, resolve);
  8163. },
  8164. onEnterCancelled(el) {
  8165. finishEnter(el, false);
  8166. onEnterCancelled && onEnterCancelled(el);
  8167. },
  8168. onAppearCancelled(el) {
  8169. finishEnter(el, true);
  8170. onAppearCancelled && onAppearCancelled(el);
  8171. },
  8172. onLeaveCancelled(el) {
  8173. finishLeave(el);
  8174. onLeaveCancelled && onLeaveCancelled(el);
  8175. }
  8176. });
  8177. }
  8178. function normalizeDuration(duration) {
  8179. if (duration == null) {
  8180. return null;
  8181. }
  8182. else if (isObject(duration)) {
  8183. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  8184. }
  8185. else {
  8186. const n = NumberOf(duration);
  8187. return [n, n];
  8188. }
  8189. }
  8190. function NumberOf(val) {
  8191. const res = toNumber(val);
  8192. validateDuration(res);
  8193. return res;
  8194. }
  8195. function validateDuration(val) {
  8196. if (typeof val !== 'number') {
  8197. warn(`<transition> explicit duration is not a valid number - ` +
  8198. `got ${JSON.stringify(val)}.`);
  8199. }
  8200. else if (isNaN(val)) {
  8201. warn(`<transition> explicit duration is NaN - ` +
  8202. 'the duration expression might be incorrect.');
  8203. }
  8204. }
  8205. function addTransitionClass(el, cls) {
  8206. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  8207. (el._vtc ||
  8208. (el._vtc = new Set())).add(cls);
  8209. }
  8210. function removeTransitionClass(el, cls) {
  8211. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  8212. const { _vtc } = el;
  8213. if (_vtc) {
  8214. _vtc.delete(cls);
  8215. if (!_vtc.size) {
  8216. el._vtc = undefined;
  8217. }
  8218. }
  8219. }
  8220. function nextFrame(cb) {
  8221. requestAnimationFrame(() => {
  8222. requestAnimationFrame(cb);
  8223. });
  8224. }
  8225. function whenTransitionEnds(el, expectedType, cb) {
  8226. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  8227. if (!type) {
  8228. return cb();
  8229. }
  8230. const endEvent = type + 'end';
  8231. let ended = 0;
  8232. const end = () => {
  8233. el.removeEventListener(endEvent, onEnd);
  8234. cb();
  8235. };
  8236. const onEnd = (e) => {
  8237. if (e.target === el) {
  8238. if (++ended >= propCount) {
  8239. end();
  8240. }
  8241. }
  8242. };
  8243. setTimeout(() => {
  8244. if (ended < propCount) {
  8245. end();
  8246. }
  8247. }, timeout + 1);
  8248. el.addEventListener(endEvent, onEnd);
  8249. }
  8250. function getTransitionInfo(el, expectedType) {
  8251. const styles = window.getComputedStyle(el);
  8252. // JSDOM may return undefined for transition properties
  8253. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  8254. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  8255. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  8256. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  8257. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  8258. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  8259. const animationTimeout = getTimeout(animationDelays, animationDurations);
  8260. let type = null;
  8261. let timeout = 0;
  8262. let propCount = 0;
  8263. /* istanbul ignore if */
  8264. if (expectedType === TRANSITION) {
  8265. if (transitionTimeout > 0) {
  8266. type = TRANSITION;
  8267. timeout = transitionTimeout;
  8268. propCount = transitionDurations.length;
  8269. }
  8270. }
  8271. else if (expectedType === ANIMATION) {
  8272. if (animationTimeout > 0) {
  8273. type = ANIMATION;
  8274. timeout = animationTimeout;
  8275. propCount = animationDurations.length;
  8276. }
  8277. }
  8278. else {
  8279. timeout = Math.max(transitionTimeout, animationTimeout);
  8280. type =
  8281. timeout > 0
  8282. ? transitionTimeout > animationTimeout
  8283. ? TRANSITION
  8284. : ANIMATION
  8285. : null;
  8286. propCount = type
  8287. ? type === TRANSITION
  8288. ? transitionDurations.length
  8289. : animationDurations.length
  8290. : 0;
  8291. }
  8292. const hasTransform = type === TRANSITION &&
  8293. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  8294. return {
  8295. type,
  8296. timeout,
  8297. propCount,
  8298. hasTransform
  8299. };
  8300. }
  8301. function getTimeout(delays, durations) {
  8302. while (delays.length < durations.length) {
  8303. delays = delays.concat(delays);
  8304. }
  8305. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  8306. }
  8307. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  8308. // numbers in a locale-dependent way, using a comma instead of a dot.
  8309. // If comma is not replaced with a dot, the input will be rounded down
  8310. // (i.e. acting as a floor function) causing unexpected behaviors
  8311. function toMs(s) {
  8312. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  8313. }
  8314. const positionMap = new WeakMap();
  8315. const newPositionMap = new WeakMap();
  8316. const TransitionGroupImpl = {
  8317. name: 'TransitionGroup',
  8318. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  8319. tag: String,
  8320. moveClass: String
  8321. }),
  8322. setup(props, { slots }) {
  8323. const instance = getCurrentInstance();
  8324. const state = useTransitionState();
  8325. let prevChildren;
  8326. let children;
  8327. onUpdated(() => {
  8328. // children is guaranteed to exist after initial render
  8329. if (!prevChildren.length) {
  8330. return;
  8331. }
  8332. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  8333. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  8334. return;
  8335. }
  8336. // we divide the work into three loops to avoid mixing DOM reads and writes
  8337. // in each iteration - which helps prevent layout thrashing.
  8338. prevChildren.forEach(callPendingCbs);
  8339. prevChildren.forEach(recordPosition);
  8340. const movedChildren = prevChildren.filter(applyTranslation);
  8341. // force reflow to put everything in position
  8342. forceReflow();
  8343. movedChildren.forEach(c => {
  8344. const el = c.el;
  8345. const style = el.style;
  8346. addTransitionClass(el, moveClass);
  8347. style.transform = style.webkitTransform = style.transitionDuration = '';
  8348. const cb = (el._moveCb = (e) => {
  8349. if (e && e.target !== el) {
  8350. return;
  8351. }
  8352. if (!e || /transform$/.test(e.propertyName)) {
  8353. el.removeEventListener('transitionend', cb);
  8354. el._moveCb = null;
  8355. removeTransitionClass(el, moveClass);
  8356. }
  8357. });
  8358. el.addEventListener('transitionend', cb);
  8359. });
  8360. });
  8361. return () => {
  8362. const rawProps = toRaw(props);
  8363. const cssTransitionProps = resolveTransitionProps(rawProps);
  8364. const tag = rawProps.tag || Fragment;
  8365. prevChildren = children;
  8366. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  8367. for (let i = 0; i < children.length; i++) {
  8368. const child = children[i];
  8369. if (child.key != null) {
  8370. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  8371. }
  8372. else {
  8373. warn(`<TransitionGroup> children must be keyed.`);
  8374. }
  8375. }
  8376. if (prevChildren) {
  8377. for (let i = 0; i < prevChildren.length; i++) {
  8378. const child = prevChildren[i];
  8379. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  8380. positionMap.set(child, child.el.getBoundingClientRect());
  8381. }
  8382. }
  8383. return createVNode(tag, null, children);
  8384. };
  8385. }
  8386. };
  8387. const TransitionGroup = TransitionGroupImpl;
  8388. function callPendingCbs(c) {
  8389. const el = c.el;
  8390. if (el._moveCb) {
  8391. el._moveCb();
  8392. }
  8393. if (el._enterCb) {
  8394. el._enterCb();
  8395. }
  8396. }
  8397. function recordPosition(c) {
  8398. newPositionMap.set(c, c.el.getBoundingClientRect());
  8399. }
  8400. function applyTranslation(c) {
  8401. const oldPos = positionMap.get(c);
  8402. const newPos = newPositionMap.get(c);
  8403. const dx = oldPos.left - newPos.left;
  8404. const dy = oldPos.top - newPos.top;
  8405. if (dx || dy) {
  8406. const s = c.el.style;
  8407. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  8408. s.transitionDuration = '0s';
  8409. return c;
  8410. }
  8411. }
  8412. // this is put in a dedicated function to avoid the line from being treeshaken
  8413. function forceReflow() {
  8414. return document.body.offsetHeight;
  8415. }
  8416. function hasCSSTransform(el, root, moveClass) {
  8417. // Detect whether an element with the move class applied has
  8418. // CSS transitions. Since the element may be inside an entering
  8419. // transition at this very moment, we make a clone of it and remove
  8420. // all other transition classes applied to ensure only the move class
  8421. // is applied.
  8422. const clone = el.cloneNode();
  8423. if (el._vtc) {
  8424. el._vtc.forEach(cls => {
  8425. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  8426. });
  8427. }
  8428. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  8429. clone.style.display = 'none';
  8430. const container = (root.nodeType === 1
  8431. ? root
  8432. : root.parentNode);
  8433. container.appendChild(clone);
  8434. const { hasTransform } = getTransitionInfo(clone);
  8435. container.removeChild(clone);
  8436. return hasTransform;
  8437. }
  8438. const getModelAssigner = (vnode) => {
  8439. const fn = vnode.props['onUpdate:modelValue'];
  8440. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  8441. };
  8442. function onCompositionStart(e) {
  8443. e.target.composing = true;
  8444. }
  8445. function onCompositionEnd(e) {
  8446. const target = e.target;
  8447. if (target.composing) {
  8448. target.composing = false;
  8449. trigger$1(target, 'input');
  8450. }
  8451. }
  8452. function trigger$1(el, type) {
  8453. const e = document.createEvent('HTMLEvents');
  8454. e.initEvent(type, true, true);
  8455. el.dispatchEvent(e);
  8456. }
  8457. // We are exporting the v-model runtime directly as vnode hooks so that it can
  8458. // be tree-shaken in case v-model is never used.
  8459. const vModelText = {
  8460. created(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  8461. el.value = value == null ? '' : value;
  8462. el._assign = getModelAssigner(vnode);
  8463. const castToNumber = number || el.type === 'number';
  8464. addEventListener(el, lazy ? 'change' : 'input', e => {
  8465. if (e.target.composing)
  8466. return;
  8467. let domValue = el.value;
  8468. if (trim) {
  8469. domValue = domValue.trim();
  8470. }
  8471. else if (castToNumber) {
  8472. domValue = toNumber(domValue);
  8473. }
  8474. el._assign(domValue);
  8475. });
  8476. if (trim) {
  8477. addEventListener(el, 'change', () => {
  8478. el.value = el.value.trim();
  8479. });
  8480. }
  8481. if (!lazy) {
  8482. addEventListener(el, 'compositionstart', onCompositionStart);
  8483. addEventListener(el, 'compositionend', onCompositionEnd);
  8484. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8485. // switching focus before confirming composition choice
  8486. // this also fixes the issue where some browsers e.g. iOS Chrome
  8487. // fires "change" instead of "input" on autocomplete.
  8488. addEventListener(el, 'change', onCompositionEnd);
  8489. }
  8490. },
  8491. beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) {
  8492. el._assign = getModelAssigner(vnode);
  8493. if (document.activeElement === el) {
  8494. if (trim && el.value.trim() === value) {
  8495. return;
  8496. }
  8497. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  8498. return;
  8499. }
  8500. }
  8501. const newValue = value == null ? '' : value;
  8502. if (el.value !== newValue) {
  8503. el.value = newValue;
  8504. }
  8505. }
  8506. };
  8507. const vModelCheckbox = {
  8508. created(el, binding, vnode) {
  8509. setChecked(el, binding, vnode);
  8510. el._assign = getModelAssigner(vnode);
  8511. addEventListener(el, 'change', () => {
  8512. const modelValue = el._modelValue;
  8513. const elementValue = getValue(el);
  8514. const checked = el.checked;
  8515. const assign = el._assign;
  8516. if (isArray(modelValue)) {
  8517. const index = looseIndexOf(modelValue, elementValue);
  8518. const found = index !== -1;
  8519. if (checked && !found) {
  8520. assign(modelValue.concat(elementValue));
  8521. }
  8522. else if (!checked && found) {
  8523. const filtered = [...modelValue];
  8524. filtered.splice(index, 1);
  8525. assign(filtered);
  8526. }
  8527. }
  8528. else if (isSet(modelValue)) {
  8529. const found = modelValue.has(elementValue);
  8530. if (checked && !found) {
  8531. assign(modelValue.add(elementValue));
  8532. }
  8533. else if (!checked && found) {
  8534. modelValue.delete(elementValue);
  8535. assign(modelValue);
  8536. }
  8537. }
  8538. else {
  8539. assign(getCheckboxValue(el, checked));
  8540. }
  8541. });
  8542. },
  8543. beforeUpdate(el, binding, vnode) {
  8544. el._assign = getModelAssigner(vnode);
  8545. setChecked(el, binding, vnode);
  8546. }
  8547. };
  8548. function setChecked(el, { value, oldValue }, vnode) {
  8549. el._modelValue = value;
  8550. if (isArray(value)) {
  8551. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  8552. }
  8553. else if (isSet(value)) {
  8554. el.checked = looseHas(value, vnode.props.value);
  8555. }
  8556. else if (value !== oldValue) {
  8557. el.checked = looseEqual(value, getCheckboxValue(el, true));
  8558. }
  8559. }
  8560. const vModelRadio = {
  8561. created(el, { value }, vnode) {
  8562. el.checked = looseEqual(value, vnode.props.value);
  8563. el._assign = getModelAssigner(vnode);
  8564. addEventListener(el, 'change', () => {
  8565. el._assign(getValue(el));
  8566. });
  8567. },
  8568. beforeUpdate(el, { value, oldValue }, vnode) {
  8569. el._assign = getModelAssigner(vnode);
  8570. if (value !== oldValue) {
  8571. el.checked = looseEqual(value, vnode.props.value);
  8572. }
  8573. }
  8574. };
  8575. const vModelSelect = {
  8576. created(el, binding, vnode) {
  8577. addEventListener(el, 'change', () => {
  8578. const selectedVal = Array.prototype.filter
  8579. .call(el.options, (o) => o.selected)
  8580. .map(getValue);
  8581. el._assign(el.multiple ? selectedVal : selectedVal[0]);
  8582. });
  8583. el._assign = getModelAssigner(vnode);
  8584. },
  8585. // set value in mounted & updated because <select> relies on its children
  8586. // <option>s.
  8587. mounted(el, { value }) {
  8588. setSelected(el, value);
  8589. },
  8590. beforeUpdate(el, _binding, vnode) {
  8591. el._assign = getModelAssigner(vnode);
  8592. },
  8593. updated(el, { value }) {
  8594. setSelected(el, value);
  8595. }
  8596. };
  8597. function setSelected(el, value) {
  8598. const isMultiple = el.multiple;
  8599. if (isMultiple && !isArray(value) && !isSet(value)) {
  8600. warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  8601. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  8602. return;
  8603. }
  8604. for (let i = 0, l = el.options.length; i < l; i++) {
  8605. const option = el.options[i];
  8606. const optionValue = getValue(option);
  8607. if (isMultiple) {
  8608. if (isArray(value)) {
  8609. option.selected = looseIndexOf(value, optionValue) > -1;
  8610. }
  8611. else {
  8612. option.selected = looseHas(value, optionValue);
  8613. }
  8614. }
  8615. else {
  8616. if (looseEqual(getValue(option), value)) {
  8617. el.selectedIndex = i;
  8618. return;
  8619. }
  8620. }
  8621. }
  8622. if (!isMultiple) {
  8623. el.selectedIndex = -1;
  8624. }
  8625. }
  8626. // retrieve raw value set via :value bindings
  8627. function getValue(el) {
  8628. return '_value' in el ? el._value : el.value;
  8629. }
  8630. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  8631. function getCheckboxValue(el, checked) {
  8632. const key = checked ? '_trueValue' : '_falseValue';
  8633. return key in el ? el[key] : checked;
  8634. }
  8635. const vModelDynamic = {
  8636. created(el, binding, vnode) {
  8637. callModelHook(el, binding, vnode, null, 'created');
  8638. },
  8639. mounted(el, binding, vnode) {
  8640. callModelHook(el, binding, vnode, null, 'mounted');
  8641. },
  8642. beforeUpdate(el, binding, vnode, prevVNode) {
  8643. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  8644. },
  8645. updated(el, binding, vnode, prevVNode) {
  8646. callModelHook(el, binding, vnode, prevVNode, 'updated');
  8647. }
  8648. };
  8649. function callModelHook(el, binding, vnode, prevVNode, hook) {
  8650. let modelToUse;
  8651. switch (el.tagName) {
  8652. case 'SELECT':
  8653. modelToUse = vModelSelect;
  8654. break;
  8655. case 'TEXTAREA':
  8656. modelToUse = vModelText;
  8657. break;
  8658. default:
  8659. switch (vnode.props && vnode.props.type) {
  8660. case 'checkbox':
  8661. modelToUse = vModelCheckbox;
  8662. break;
  8663. case 'radio':
  8664. modelToUse = vModelRadio;
  8665. break;
  8666. default:
  8667. modelToUse = vModelText;
  8668. }
  8669. }
  8670. const fn = modelToUse[hook];
  8671. fn && fn(el, binding, vnode, prevVNode);
  8672. }
  8673. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  8674. const modifierGuards = {
  8675. stop: e => e.stopPropagation(),
  8676. prevent: e => e.preventDefault(),
  8677. self: e => e.target !== e.currentTarget,
  8678. ctrl: e => !e.ctrlKey,
  8679. shift: e => !e.shiftKey,
  8680. alt: e => !e.altKey,
  8681. meta: e => !e.metaKey,
  8682. left: e => 'button' in e && e.button !== 0,
  8683. middle: e => 'button' in e && e.button !== 1,
  8684. right: e => 'button' in e && e.button !== 2,
  8685. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  8686. };
  8687. /**
  8688. * @private
  8689. */
  8690. const withModifiers = (fn, modifiers) => {
  8691. return (event, ...args) => {
  8692. for (let i = 0; i < modifiers.length; i++) {
  8693. const guard = modifierGuards[modifiers[i]];
  8694. if (guard && guard(event, modifiers))
  8695. return;
  8696. }
  8697. return fn(event, ...args);
  8698. };
  8699. };
  8700. // Kept for 2.x compat.
  8701. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  8702. const keyNames = {
  8703. esc: 'escape',
  8704. space: ' ',
  8705. up: 'arrow-up',
  8706. left: 'arrow-left',
  8707. right: 'arrow-right',
  8708. down: 'arrow-down',
  8709. delete: 'backspace'
  8710. };
  8711. /**
  8712. * @private
  8713. */
  8714. const withKeys = (fn, modifiers) => {
  8715. return (event) => {
  8716. if (!('key' in event))
  8717. return;
  8718. const eventKey = hyphenate(event.key);
  8719. if (
  8720. // None of the provided key modifiers match the current event key
  8721. !modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  8722. return;
  8723. }
  8724. return fn(event);
  8725. };
  8726. };
  8727. const vShow = {
  8728. beforeMount(el, { value }, { transition }) {
  8729. el._vod = el.style.display === 'none' ? '' : el.style.display;
  8730. if (transition && value) {
  8731. transition.beforeEnter(el);
  8732. }
  8733. else {
  8734. setDisplay(el, value);
  8735. }
  8736. },
  8737. mounted(el, { value }, { transition }) {
  8738. if (transition && value) {
  8739. transition.enter(el);
  8740. }
  8741. },
  8742. updated(el, { value, oldValue }, { transition }) {
  8743. if (!value === !oldValue)
  8744. return;
  8745. if (transition) {
  8746. if (value) {
  8747. transition.beforeEnter(el);
  8748. setDisplay(el, true);
  8749. transition.enter(el);
  8750. }
  8751. else {
  8752. transition.leave(el, () => {
  8753. setDisplay(el, false);
  8754. });
  8755. }
  8756. }
  8757. else {
  8758. setDisplay(el, value);
  8759. }
  8760. },
  8761. beforeUnmount(el, { value }) {
  8762. setDisplay(el, value);
  8763. }
  8764. };
  8765. function setDisplay(el, value) {
  8766. el.style.display = value ? el._vod : 'none';
  8767. }
  8768. const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps);
  8769. // lazy create the renderer - this makes core renderer logic tree-shakable
  8770. // in case the user only imports reactivity utilities from Vue.
  8771. let renderer;
  8772. let enabledHydration = false;
  8773. function ensureRenderer() {
  8774. return renderer || (renderer = createRenderer(rendererOptions));
  8775. }
  8776. function ensureHydrationRenderer() {
  8777. renderer = enabledHydration
  8778. ? renderer
  8779. : createHydrationRenderer(rendererOptions);
  8780. enabledHydration = true;
  8781. return renderer;
  8782. }
  8783. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  8784. const render = ((...args) => {
  8785. ensureRenderer().render(...args);
  8786. });
  8787. const hydrate = ((...args) => {
  8788. ensureHydrationRenderer().hydrate(...args);
  8789. });
  8790. const createApp = ((...args) => {
  8791. const app = ensureRenderer().createApp(...args);
  8792. {
  8793. injectNativeTagCheck(app);
  8794. }
  8795. const { mount } = app;
  8796. app.mount = (containerOrSelector) => {
  8797. const container = normalizeContainer(containerOrSelector);
  8798. if (!container)
  8799. return;
  8800. const component = app._component;
  8801. if (!isFunction(component) && !component.render && !component.template) {
  8802. component.template = container.innerHTML;
  8803. }
  8804. // clear content before mounting
  8805. container.innerHTML = '';
  8806. const proxy = mount(container);
  8807. container.removeAttribute('v-cloak');
  8808. container.setAttribute('data-v-app', '');
  8809. return proxy;
  8810. };
  8811. return app;
  8812. });
  8813. const createSSRApp = ((...args) => {
  8814. const app = ensureHydrationRenderer().createApp(...args);
  8815. {
  8816. injectNativeTagCheck(app);
  8817. }
  8818. const { mount } = app;
  8819. app.mount = (containerOrSelector) => {
  8820. const container = normalizeContainer(containerOrSelector);
  8821. if (container) {
  8822. return mount(container, true);
  8823. }
  8824. };
  8825. return app;
  8826. });
  8827. function injectNativeTagCheck(app) {
  8828. // Inject `isNativeTag`
  8829. // this is used for component name validation (dev only)
  8830. Object.defineProperty(app.config, 'isNativeTag', {
  8831. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  8832. writable: false
  8833. });
  8834. }
  8835. function normalizeContainer(container) {
  8836. if (isString(container)) {
  8837. const res = document.querySelector(container);
  8838. if ( !res) {
  8839. warn(`Failed to mount app: mount target selector returned null.`);
  8840. }
  8841. return res;
  8842. }
  8843. return container;
  8844. }
  8845. function initDev() {
  8846. const target = getGlobalThis();
  8847. target.__VUE__ = true;
  8848. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
  8849. {
  8850. console.info(`You are running a development build of Vue.\n` +
  8851. `Make sure to use the production build (*.prod.js) when deploying for production.`);
  8852. }
  8853. }
  8854. // This entry exports the runtime only, and is built as
  8855. initDev();
  8856. const compile$1 = () => {
  8857. {
  8858. warn(`Runtime compilation is not supported in this build of Vue.` +
  8859. ( ` Use "vue.global.js" instead.`
  8860. ) /* should not happen */);
  8861. }
  8862. };
  8863. exports.BaseTransition = BaseTransition;
  8864. exports.Comment = Comment;
  8865. exports.Fragment = Fragment;
  8866. exports.KeepAlive = KeepAlive;
  8867. exports.Static = Static;
  8868. exports.Suspense = Suspense;
  8869. exports.Teleport = Teleport;
  8870. exports.Text = Text;
  8871. exports.Transition = Transition;
  8872. exports.TransitionGroup = TransitionGroup;
  8873. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  8874. exports.callWithErrorHandling = callWithErrorHandling;
  8875. exports.camelize = camelize;
  8876. exports.capitalize = capitalize;
  8877. exports.cloneVNode = cloneVNode;
  8878. exports.compile = compile$1;
  8879. exports.computed = computed$1;
  8880. exports.createApp = createApp;
  8881. exports.createBlock = createBlock;
  8882. exports.createCommentVNode = createCommentVNode;
  8883. exports.createHydrationRenderer = createHydrationRenderer;
  8884. exports.createRenderer = createRenderer;
  8885. exports.createSSRApp = createSSRApp;
  8886. exports.createSlots = createSlots;
  8887. exports.createStaticVNode = createStaticVNode;
  8888. exports.createTextVNode = createTextVNode;
  8889. exports.createVNode = createVNode;
  8890. exports.customRef = customRef;
  8891. exports.defineAsyncComponent = defineAsyncComponent;
  8892. exports.defineComponent = defineComponent;
  8893. exports.getCurrentInstance = getCurrentInstance;
  8894. exports.getTransitionRawChildren = getTransitionRawChildren;
  8895. exports.h = h;
  8896. exports.handleError = handleError;
  8897. exports.hydrate = hydrate;
  8898. exports.inject = inject;
  8899. exports.isProxy = isProxy;
  8900. exports.isReactive = isReactive;
  8901. exports.isReadonly = isReadonly;
  8902. exports.isRef = isRef;
  8903. exports.isVNode = isVNode;
  8904. exports.markRaw = markRaw;
  8905. exports.mergeProps = mergeProps;
  8906. exports.nextTick = nextTick;
  8907. exports.onActivated = onActivated;
  8908. exports.onBeforeMount = onBeforeMount;
  8909. exports.onBeforeUnmount = onBeforeUnmount;
  8910. exports.onBeforeUpdate = onBeforeUpdate;
  8911. exports.onDeactivated = onDeactivated;
  8912. exports.onErrorCaptured = onErrorCaptured;
  8913. exports.onMounted = onMounted;
  8914. exports.onRenderTracked = onRenderTracked;
  8915. exports.onRenderTriggered = onRenderTriggered;
  8916. exports.onUnmounted = onUnmounted;
  8917. exports.onUpdated = onUpdated;
  8918. exports.openBlock = openBlock;
  8919. exports.popScopeId = popScopeId;
  8920. exports.provide = provide;
  8921. exports.proxyRefs = proxyRefs;
  8922. exports.pushScopeId = pushScopeId;
  8923. exports.queuePostFlushCb = queuePostFlushCb;
  8924. exports.reactive = reactive;
  8925. exports.readonly = readonly;
  8926. exports.ref = ref;
  8927. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  8928. exports.render = render;
  8929. exports.renderList = renderList;
  8930. exports.renderSlot = renderSlot;
  8931. exports.resolveComponent = resolveComponent;
  8932. exports.resolveDirective = resolveDirective;
  8933. exports.resolveDynamicComponent = resolveDynamicComponent;
  8934. exports.resolveTransitionHooks = resolveTransitionHooks;
  8935. exports.setBlockTracking = setBlockTracking;
  8936. exports.setDevtoolsHook = setDevtoolsHook;
  8937. exports.setTransitionHooks = setTransitionHooks;
  8938. exports.shallowReactive = shallowReactive;
  8939. exports.shallowReadonly = shallowReadonly;
  8940. exports.shallowRef = shallowRef;
  8941. exports.ssrContextKey = ssrContextKey;
  8942. exports.ssrUtils = ssrUtils;
  8943. exports.toDisplayString = toDisplayString;
  8944. exports.toHandlers = toHandlers;
  8945. exports.toRaw = toRaw;
  8946. exports.toRef = toRef;
  8947. exports.toRefs = toRefs;
  8948. exports.transformVNodeArgs = transformVNodeArgs;
  8949. exports.triggerRef = triggerRef;
  8950. exports.unref = unref;
  8951. exports.useCssModule = useCssModule;
  8952. exports.useCssVars = useCssVars;
  8953. exports.useSSRContext = useSSRContext;
  8954. exports.useTransitionState = useTransitionState;
  8955. exports.vModelCheckbox = vModelCheckbox;
  8956. exports.vModelDynamic = vModelDynamic;
  8957. exports.vModelRadio = vModelRadio;
  8958. exports.vModelSelect = vModelSelect;
  8959. exports.vModelText = vModelText;
  8960. exports.vShow = vShow;
  8961. exports.version = version;
  8962. exports.warn = warn;
  8963. exports.watch = watch;
  8964. exports.watchEffect = watchEffect;
  8965. exports.withCtx = withCtx;
  8966. exports.withDirectives = withDirectives;
  8967. exports.withKeys = withKeys;
  8968. exports.withModifiers = withModifiers;
  8969. exports.withScopeId = withScopeId;
  8970. return exports;
  8971. }({}));