runtime-dom.global.js 354 KB

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