vue.runtime.global.js 355 KB

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